Forum rules - please read before posting.

Save system can break down if you're inconsistent about putting player into scene

Another somewhat weird bug report. :P (I'm in the middle of beta testing with lots of folks playing my game in a variety of ways on lots of different machines, so I've hit a few weird things)

If you have a scene where an instance of the player already exists, the player is given an id of -1, while if AC has to create the player, the player gets an id of 1. So, if you first save in a scene where AC created the player, saveData.playerData will get a new PlayerData where the id is 1. If you go on to a scene where the player already existed, and you save there, the old PlayerData won't be removed, and your new save will have both the original PlayerData with id 1 and the new PlayerData with id -1. If you then load this save, the first PlayerData will be used, thus loading the first save you made, not the save it should have loaded.

In summary: It appears that this is part of a feature for supporting multiple players. If you're not using that feature, but you have one scene where you put the player into the scene manually and another scene where AC automatically creates the player, then you may get into a situation where all saves actually write the first save you made.

The relevant code is in SaveSystem@SaveSaveGame, L951. You can see the part there where it loops through the existing PlayerDatas and deletes ones with matching ids, which breaks down if AC has accidentally given the same player two different ids. I have it now working for my particular use case by just commenting out the first half of the if, ensuring that a new SaveData is always made. It's to be seen if that has negative side effects. :P

Comments

  • edited April 2017
    I've been frequently taking a look at this post, but I guess it would probably be a better idea to wait for Chris for this one, lol. We'll probably need further digging around, but I guess most people stick to one method or the other so it's one of those things hard to notice (in my case I always place players manually, so... lol).
  • Haha, yeah, it's definitely not a normal case. In my game, I was consistent about always putting the player into the scene, except for my "intro" scene which handles an intro sequence, which is basically some video and such before you take control of the player. As such, I didn't put the player into that scene, which made this possible. (I had a couple other scenes that existed to run cutscenes, which could also enable this)
  • Update to the latest release.  v1.56 made some changes under the hood to this area - basically any save file made for a "local" player now assigns the ID with the calculation:

    -2 - (current scene index)

    This means that -1 is now decrepit and local players will only ever have values of -2, -3 and so on.  As they are now unique to their scene, AC shouldn't get confused about this aspect any more.
  • Cool, thanks Chris! :D
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.