×

Dsync error!

Please fix it. That's a 180k sec game, it took me 3 days :( https://imgur.com/tKA3JqV https://imgur.com/0YUwdCf

Oh no, I'm terribly sorry this happened! Thank you for submitting the debug data to track down the problem of the dsync. So what happened is that the simulation on my server calculated a different outcome as your client device. I will look into the debug data and post an update here as soon as I know what was going on.

Wow this was unexpected! The problem was a treasure goblin... So this was my code to calculate the gold for a round (since treasure goblin is alone he will later get all gold for himself):
public static int getGoldForRound(int round) {
   int gold = (int) StrictMath.round(StrictMath.pow(1.0125, round) * 50.0);
   return gold > 1000 ? 1000 : gold;
}
Now, in the high bonus round this causes an integer overflow. The gold becomes negative! Which by itself is already a bug, but somehow your device decided to do the integer cast slightly different:
Client: int=-1738923812
Server: int=-1738923813
And this is what caused the dsync in the end. My fixed code is now this:
public static int getGoldForRound(int round, int version) {
   double rawGold = StrictMath.pow(1.0125, round) * 50.0;
   int gold = (int) StrictMath.round(rawGold);

   if (version >= Sim.v16) {
      if (rawGold > 1000.0) {
         return 1000;
      }
   } else {
      if (gold > 1000) {
         return 1000;
      }
   }
   return gold;
}
I have to keep the old, broken code in here, otherwise games with older versions will suddenly stop working and it won't be possible to watch their replays anymore.. I will release a new version this weekend with this (and another health related dsync) bugfix.

Thanks for the answer :)

I've uploaded a new release tonight, including this fix! Thanks again for helping me to track it down. If you're interested in the details, I wrote a little blog post about that dsync bug hunt, as it was quite a ride the last weeks :-) I really hope it is over now!