NiklasEi / cookieclicker-for-gamebox

Cookie Clicker for GameBox
1 stars 4 forks source link

Weird thing about Cookie Clicker #13

Closed Matocolotoe closed 5 years ago

Matocolotoe commented 5 years ago

Are data.yml and saves.yml synchronized regarding the amount of total cookies per player ? Because when the server reboots and some of the cookies haven't been saved, the total amount of cookies in the top list increases but not for the player

NiklasEi commented 5 years ago

They should have the same values. The value is written to both files whenever the game is closed. The game will always be closed for a normal server shutdown/reboot. They are not actively syncronized though.

Are you comparing the amount in the inventory title with the top list, or really the entries in the files?

Matocolotoe commented 5 years ago

I'm comparing the amount in the in-game GUIs

NiklasEi commented 5 years ago

The cookie clicker gui will only tell you how many cookies you own at the moment. The top list tells you how many you produced.

So if you produce 15 cookies, then buy a cursor for 10, you own 5, but your highscore is 15.

Matocolotoe commented 5 years ago

ikr, but a player had like 30 million cookies, the server rebooted, the top list score and his personal total score had a difference of about 2 million cookies

NiklasEi commented 5 years ago

Two million cookies is not much. There are a lot of updates or buildings that cost a lot more than that. Are you sure that he didn't just buy something? I am not saying, that I am 100% sure that nothing went wrong, but for now, it doesn't sound like it. Were there any errors in the console? Does this happen regularly?

Matocolotoe commented 5 years ago

No, it happens when the server reboots while people are playing Cookie Clicker But i'm pretty sure there was a difference between the score in the top list and the personal total amount

NiklasEi commented 5 years ago

If I understood correctly, the top list had the right amount, but the player was missing cookies. The first is done in GameBox, the second in Cookieclicker. So I transferred the issue (also I wanted to test that Beta feature ^^).

I went over the code that should be triggered on a reboot, but couldn't find a problem. Most things that could go wrong should throw an error in the console. You can take a look yourself:

  1. "onDisable" of the game gets called: https://github.com/NiklasEi/cookieclicker-for-gamebox/blob/master/src/main/java/me/nikl/cookieclicker/CookieClicker.java#L164-L167
  2. The game manager quits and saves all games to the database (sync, because the server is shutting down): https://github.com/NiklasEi/cookieclicker-for-gamebox/blob/master/src/main/java/me/nikl/cookieclicker/CCGameManager.java#L117
  3. The database is saved (looking at the file implementation here, because you mentioned saves.yml). Also sync because of the shutdown: https://github.com/NiklasEi/cookieclicker-for-gamebox/blob/master/src/main/java/me/nikl/cookieclicker/data/FileDatabase.java#L96

When I reboot my server the file is written to.

Sorry, without a stack trace or steps to reproduce I can't do more here.