NullSystemWorks / mtabg

Official MTA:BattleGrounds Gamemode Repository
GNU Affero General Public License v3.0
6 stars 6 forks source link

Starting the server empties all LUA file contents #37

Closed Dutchman101 closed 6 years ago

Dutchman101 commented 6 years ago

All .LUA files will be emptied once the server is started. It seems not everyone can reproduce this, it was done with both a clean MTA server (1.5.5-r12430) directory and my usual local with the same results, everything was set up and running as it's supposed to be and the resources are master. Script files are emptied as soon the server is ready.

Reproduction video showing this behaviour which is opposite of what is expected: https://www.youtube.com/watch?v=anDrc1s8VW8

@expert975 suspects that the behaviour of File() (FileOpen function) has changed, or that the introduction of this issue relies on the lack of using read-only with FileOpen. I didn't investigate this gamemode bug at all so far, he did. Expert975 (on fileOpen function behaviour): "Perhaps what was opening a file to read now is opening to write (not to append)"

ghost commented 6 years ago

Unable to reproduce

ghost commented 6 years ago

By reading the source code it's clear to me that File() is not simply fileOpen() as I would expect. File() is more like a mix of fileOpen() and fileCreate(), with no option to open a file in read-only mode. I suspect this problem happens to you and not to me because I'm on GNU/Linux, and your Windows server might interpret the filepaths in a different way. I suppose that when trying to open a file, the gobbler File() function fails to identify the existence of the file and takes care of creating a new one.

https://github.com/multitheftauto/mtasa-blue/blob/49e0ce473287f43403e6cd759a599b8bec5484c8/Shared/mods/deathmatch/logic/luadefs/CLuaFileDefs.cpp#L72

Dutchman101 commented 6 years ago

Fixed in 32da40f

qaisjp commented 6 years ago

You can use File.open if you want to keep OOPyness

0xCiBeR commented 6 years ago

Done in 0730411906002e17747249f2702b85ca338a2a22