NBlood icon indicating copy to clipboard operation
NBlood copied to clipboard

BLOOD: fix linux windows multiplayer desync

Open zZeck opened this issue 3 years ago • 1 comments

Fixes Out of sync between Linux and Windows #191.

MinGW by default was using ms_struct style packing. This made XSPRITE a have different structure in memory, and different size. Checksums don't match as a result. In network.cpp CalcGameChecksum this code

    sum = 0;
    length = sizeof(XSPRITE)/4;
    while (length--)
    {
        sum += *pBuffer++;
    }

would give a different sum.

This should fix GCC and Clang builds at least. Not sure what should be done about MSVC build on windows connecting to GCC build on linux.

I suppose the other option is to ALWAYS force ms style packing. Unless there's a way to change MSVC's packing behavior.

zZeck avatar Jan 27 '22 01:01 zZeck

disabling check for xsprite checksum altogether might be a better idea. ENet code is robust enough I think

nukeykt avatar Feb 28 '22 20:02 nukeykt

I think that I recently got this reproduced (i.e., an out of sync message during what still looked like a functional game with no sync issue), albeit while using NotBlood.

So, maybe a fix can be applied? I currently think about two options:

  1. Disable the xsprite checksum check as suggested by @nukeykt.
  2. Calculate the checksum in a cross-platform manner, similar in idea to struct serialization.

NY00123 avatar Aug 03 '23 21:08 NY00123

Let's move discussion to #191.

Hendricks266 avatar Aug 03 '23 21:08 Hendricks266