jamesmgittins / incremancer

Idle Necromancer Game
62 stars 77 forks source link

Golems vanishing while being offline #5

Open lythro opened 4 years ago

lythro commented 4 years ago

Hey there,

someone on kong talked about his golems vanishing while being offline over night. I didn't try to reproduce this myself, but I looked at the loading-code and see two (or three) possible issues:

  1. If I saw that correctly, the game runs two loading procedures during startup: One from local storage, and one from the kongregate servers/playfab thingy.
  2. The code that selects whether to overwrite the local save with the one loaded from kong seems really.. strange. I think the if clause could be wrong, especially the savegame.saveCreated < model.persistentData.saveCreated part -- shouldn't that be the other way round? https://github.com/jamesmgittins/incremancer/blob/e30693af6df4ba6ad39f428ac39918b700d17baf/js/gamemodel.js#L801-L810
  3. In the importFile function you reset the creature factories spawnedSavedCreatures flag to false before setupLevel, but this is not done in either loadData nor in loadFromPlayFab. So if both are executed, the first will set the flag to true, and the second will reset the golems but not respawn them? https://github.com/jamesmgittins/incremancer/blob/e30693af6df4ba6ad39f428ac39918b700d17baf/js/gamemodel.js#L636-L642

My best guess is that (1) and (3) together cause this problem. Should be an easy fix, right? 🙂

jamesmgittins commented 4 years ago

Thanks. I'll take a look at it.

The saveCreated variable is set only when the save is first created, not when it is saved in future. It is a timestamp of when the player first started playing the game and should never change.

In the case where someone has a cloud save but starts playing on a new PC, I check to see if the cloud save began before the local save, and then overwrite it. So I'm pretty sure that if clause is correct.

I had to put the spawnedSavedCreatures = false into the importFile function, since it was possible to exploit by repeatedly importing the save file which would spawn golems every time and couldn't check to see if they were already spawned. I suppose it would make more sense to just destroy any active golems before spawning saved ones, but that was the quick fix I put in to fix the exploit at the time.

lythro commented 4 years ago

Thanks for the fast reply! :)

Sounds totally reasonable, both the saveCreated and the spawnedSavedCreatures variables. Just on a side note: I think if you really worry about exploits/hacks, javascript was probably not the best choice of language, since all modern webbrowsers give you access to a console. :wink:

TaipionsSalemClient commented 4 years ago

Yea, a fix for this might be a better idea than worrying about exploits which is apparently super easy in that game anyways. I constantly lose all my golems with cloud save which now forces me to also use save files, just had it that the golems, with parts I accumulated over 3 days, just vanished through a random browser crash before I could make any use of them => lost 3 days, no fun