NBlood
NBlood copied to clipboard
BLOOD: fix linux windows multiplayer desync
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.
disabling check for xsprite checksum altogether might be a better idea. ENet code is robust enough I think
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:
- Disable the xsprite checksum check as suggested by @nukeykt.
- Calculate the checksum in a cross-platform manner, similar in idea to struct serialization.
Let's move discussion to #191.