User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 15

Thread: Precautions to avoid savegame corruption?

  1. #1
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export Module
    Outcast's Avatar
    Join Date
    Jan 2011
    Location
    Sweden
    Posts
    3,237
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)

    Question Precautions to avoid savegame corruption?

    One problem I have had from user in my latest game is that saved games sometimes corrupt or disappear, especially on the mobile versions of the game. This of course cause great frustrations of the user, especially if they have bought ingame inapps like gems etc. It is thankfully not common, but I have still had a bunch of one stars from people this have happened to. One of the "problems" with my game I guess is that the game is always "on" (there is no level complete screen etc) so saving happens in even intervals. I guess this makes it so the user could quit the game in the middle of a save, or like I have heard also having it crash on them just in the middle of a save. I am using an ini to save to.

    Now, my question is if there are ways to minimize this and prevent data loss in this way?

  2. #2
    Clicker Fusion 2.5Android Export Module

    Join Date
    Feb 2014
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The way I do this (which I'm sure is grossly inefficient, but, it works) is:
    Write all counter contents (or whatever format variables are saved as) to the .ini. Have a second set of (identical) variables reserved for checking. Only allow exit once a group that does the following has completed:

    1. Pulls all variables out of the ini (and into the second set of variables)
    2. Compare each variable that "variable from set 1" = [it's mirrored counterpart from] "variable from set 2".
    3. If they *all* match, allow exit.
    4. If there's a discrepancy, repeat the process of writing "set 1" variable to the ini and restart this group.

    If people actually force the app to shut (EG 'terminating the process' or pulling the battery out mid-game), they're stupid to expect it to save and deserve corrupt data.

  3. #3
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,159
    Mentioned
    28 Post(s)
    Tagged
    1 Thread(s)
    Some other ideas:

    Keep two save files,
    save at different time intervals,
    add a control line as last operation to validate the save file
    and only load the "uncorrupted" (validated) save file on game restart

    This could limit the problem I guess?

    If you were not saving all time,
    you could have added a "progress bar" also,
    once saving is complete
    (test for last control line written)
    print out something like "save ok - safe to quit"
    but people like to mess anyway

  4. #4
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export Module
    Outcast's Avatar
    Join Date
    Jan 2011
    Location
    Sweden
    Posts
    3,237
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the tips!

    About this one though: add a control line as last operation to validate the save file
    and only load the "uncorrupted" (validated) save file on game restart

    How would this look like in practice to check if it is not corrupted?

  5. #5
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,159
    Mentioned
    28 Post(s)
    Tagged
    1 Thread(s)
    *I think*
    (never actually did something like that, so it's just theory )
    you can write your savedata as you already do,
    i.e.

    Lives = 5
    Score = 1000
    (...)

    And then, as last operation when saving data,
    add something like this:

    Control_line = 1234

    Then on loading,
    if you don't find the "control line",
    it means the file has been corrupted
    (since writing to ini would have been stopped before that last line being added)

    and then you would check the other save file for the same control line, hoping that is not corrupted
    (which would be highly unlikely, because one can't quit the application at the same time one second after and one second before )

  6. #6
    Clicker Fusion 2.5Android Export Module

    Join Date
    Feb 2014
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yep, I've done it previously with a .ini, where the last thing it does is write a aboveAreAllValid=1 line. Then future frames/restarted games that need to reference it can check that it's in place and write a warning saying "possible ini file corruption" when it's missing.

    Technically of course, the values above it could be corrupted. In practice, I've yet to have it fail though and have written this ini file hundreds of times on a dozen phones.

  7. #7
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export Module
    Outcast's Avatar
    Join Date
    Jan 2011
    Location
    Sweden
    Posts
    3,237
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the input about this! I have read though that using arrays is better for saving since it is not as easy for the user to just edit the ini file. I might go over to using an array in my next project. Would this method also work with an array file?

  8. #8
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export Module
    Outcast's Avatar
    Join Date
    Jan 2011
    Location
    Sweden
    Posts
    3,237
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    Btw, how would one go about to alternate saving to the two different ini files? Could I do it in an event, or would I need to do double the amount of save conditions depending on what ini to save to? (would suck :/ )

    Also if you are going to do this thing I assume you need to save every single data every time you save? You can't just update the save with the player losing a life for example, since then it will only update in one of the files and if you then save another data to the other file it will not have been updated with the player losing a life in the previous file etc.

  9. #9
    Clicker Fusion 2.5Fusion 2.5+ DLC
    casleziro's Avatar
    Join Date
    Mar 2013
    Location
    United States
    Posts
    679
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    Call me obsessed with arrays, but if your system used arrays instead of INI, you could run a nested loop through the main array and simply have the other array copy each index. So you effectively have a "copy" function. Might also make checking for corruption easier, since you can move through cells the same way and compare.

  10. #10
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    King_Cool's Avatar
    Join Date
    Aug 2008
    Posts
    2,335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    "I guess this makes it so the user could quit the game in the middle of a save, or like I have heard also having it crash on them just in the middle of a save."

    Have you actually checked that this does/ can corrupt the savegame, on your end i mean?
    Just so your not missplacing your efforts to solve the problem

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Different savegame files not working properly
    By Blue66 in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 7th April 2009, 11:44 PM
  2. Plugin SaveGame
    By Dbzes in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 26th May 2008, 05:34 PM
  3. Savegame humm comment ca marche
    By Dbzes in forum Multimedia Fusion 2 - Technical Support
    Replies: 11
    Last Post: 31st March 2008, 05:11 PM
  4. Savegame Object Broke
    By Jcw87 in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 30th March 2007, 10:04 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •