INI file contents get deleted on their own

M

mza1979m

Guest
I've been having this disturbing issue with my game. I've been developing it for 2 months on GMS2 and have put massive amounts of effort into it, but there is just one issue that is constant, and no matter what I do, it won't go away...
The game would run, and everything appears to be fine. I have about 73 ini_open() and ini_close() statements to save variable values to an INI file. The maximum size of the INI file reaches 33kb. I could launch the game 20 times and everything would be fine and it would preserve all variable values as expected and recall them on the next run. However, once in a while I would launch the game and find that everything in my INI file has been deleted and the game literally restarts from the beginning as if no progress was saved to the INI file at all. This happens maybe once every 20 launches. It has happened during testing on my Android phone as well. I actually tried replacing the entire INI file saving system with a 3rd party saving asset (playerprefs_gm), and strangely it now does it more frequently. The .sav file created would just get erased once in a while and progress is reset. Could this be a problem with GMS2? Or could this be related to the fact that I'm in 'test' mode and the game isn't actually compiled?
 
Don't mess with the ini files so often. Create a script to save the game and a script to load the game. Only call the save script when you want to save all the variables at once, and only call the load script at the start of the game. Otherwise you're just asking for trouble.
 
M

mza1979m

Guest
Are you referring to the new built-in save/load features of GMS2? If not, then what would the contents of these scripts look like?
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
I would think your issue is caused by the cache being cleaned and rebuilt. When testing GMS2 caches al the files to make the build process faster, but this can be cleared, especially when large changes are made to the project). You should make a final build (create Executable) and install that APK on your device and see if it still happens. If it does then file a bug.
 
M

mza1979m

Guest
Still did the same thing after creating a final build and playing on Android. Reported it as a bug.
 

gnysek

Member
That shouldn't happen on Windows at all, as files are kept in %LOCALAPPDATA%/GameName/ even after you delete/uninstall it. Strange, I never encountered this, yet I've run my game which uses .ini files for saves about 1000 times (save and options are separately kept, and none of them was wiped out even on GM Crashes).
 

kkarnage

Member
What exactly happens is that the files in %LOCALAPPDATA%/GameName/ are not deleted but their content is ( the files are empty ), it seems to not be specific to ini files because also the txt files got their content deleted. An other thing is that only the files used were emptied obviously, other ini and text files that were not used are intact
 

curato

Member
Yeah it sounds like you need to simplify you ini save. you need to make one function call that saves everything and one that loads everything. Then you can test that in one spot. It will be a lot easier than trying to track down which of the 73 places you have ini code is causing the issue.
 

kkarnage

Member
Update :
I had the same issue happen again, what I can notice is that in both cases it happened after the game was running for over 48h maybe 72h. So i'm suspecting maybe some stack overflow problem or something related to the game being on for too long or a built-in variable exceeding a certain value

In context i'm using game maker as a game server for my game that's why i have it running for these extended periods of time, i'll try doing server restarts every 24h to see if it eliminates this issue. Maybe something to note as well is that the game has been having a lot of traffic lately with over 500 player instances online simultaneously

EDIT: Fixed the bug by fixing a memory leak in the game (wasn't deleteing a ds_list)
 
Last edited:
Top