Network: Remove NETWORK_SEND_DOUBLE_SEED define
This commit is contained in:
@@ -634,11 +634,9 @@ char *CrashLog::FillDesyncCrashLog(char *buffer, const char *last, const DesyncE
|
|||||||
auto flag_check = [&](DesyncExtraInfo::Flags flag, const char *str) {
|
auto flag_check = [&](DesyncExtraInfo::Flags flag, const char *str) {
|
||||||
return info.flags & flag ? str : "";
|
return info.flags & flag ? str : "";
|
||||||
};
|
};
|
||||||
buffer += seprintf(buffer, last, "Flags: %s%s%s%s\n",
|
buffer += seprintf(buffer, last, "Flags: %s%s\n",
|
||||||
flag_check(DesyncExtraInfo::DEIF_RAND1, "R"),
|
flag_check(DesyncExtraInfo::DEIF_RAND, "R"),
|
||||||
flag_check(DesyncExtraInfo::DEIF_RAND2, "Z"),
|
flag_check(DesyncExtraInfo::DEIF_STATE, "S"));
|
||||||
flag_check(DesyncExtraInfo::DEIF_STATE, "S"),
|
|
||||||
flag_check(DesyncExtraInfo::DEIF_DBL_RAND, "D"));
|
|
||||||
}
|
}
|
||||||
if (_network_server && (info.desync_frame_seed || info.desync_frame_state_checksum)) {
|
if (_network_server && (info.desync_frame_seed || info.desync_frame_state_checksum)) {
|
||||||
buffer += seprintf(buffer, last, "Desync frame: %08X (seed), %08X (state checksum)\n", info.desync_frame_seed, info.desync_frame_state_checksum);
|
buffer += seprintf(buffer, last, "Desync frame: %08X (seed), %08X (state checksum)\n", info.desync_frame_seed, info.desync_frame_state_checksum);
|
||||||
|
@@ -21,10 +21,8 @@ struct DesyncDeferredSaveInfo {
|
|||||||
struct DesyncExtraInfo {
|
struct DesyncExtraInfo {
|
||||||
enum Flags {
|
enum Flags {
|
||||||
DEIF_NONE = 0, ///< no flags
|
DEIF_NONE = 0, ///< no flags
|
||||||
DEIF_RAND1 = 1 << 0, ///< random 1 mismatch
|
DEIF_RAND = 1 << 0, ///< random mismatch
|
||||||
DEIF_RAND2 = 1 << 1, ///< random 2 mismatch
|
DEIF_STATE = 1 << 1, ///< state mismatch
|
||||||
DEIF_STATE = 1 << 2, ///< state mismatch
|
|
||||||
DEIF_DBL_RAND = 1 << 3, ///< double-seed sent
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Flags flags = DEIF_NONE;
|
Flags flags = DEIF_NONE;
|
||||||
|
@@ -81,9 +81,6 @@ uint32 _frame_counter; ///< The current frame.
|
|||||||
uint32 _last_sync_frame; ///< Used in the server to store the last time a sync packet was sent to clients.
|
uint32 _last_sync_frame; ///< Used in the server to store the last time a sync packet was sent to clients.
|
||||||
NetworkAddressList _broadcast_list; ///< List of broadcast addresses.
|
NetworkAddressList _broadcast_list; ///< List of broadcast addresses.
|
||||||
uint32 _sync_seed_1; ///< Seed to compare during sync checks.
|
uint32 _sync_seed_1; ///< Seed to compare during sync checks.
|
||||||
#ifdef NETWORK_SEND_DOUBLE_SEED
|
|
||||||
uint32 _sync_seed_2; ///< Second part of the seed.
|
|
||||||
#endif
|
|
||||||
uint64 _sync_state_checksum; ///< State checksum to compare during sync checks.
|
uint64 _sync_state_checksum; ///< State checksum to compare during sync checks.
|
||||||
uint32 _sync_frame; ///< The frame to perform the sync check.
|
uint32 _sync_frame; ///< The frame to perform the sync check.
|
||||||
Date _last_sync_date; ///< The game date of the last successfully received sync frame
|
Date _last_sync_date; ///< The game date of the last successfully received sync frame
|
||||||
@@ -1264,9 +1261,6 @@ void NetworkGameLoop()
|
|||||||
StateGameLoop();
|
StateGameLoop();
|
||||||
|
|
||||||
_sync_seed_1 = _random.state[0];
|
_sync_seed_1 = _random.state[0];
|
||||||
#ifdef NETWORK_SEND_DOUBLE_SEED
|
|
||||||
_sync_seed_2 = _random.state[1];
|
|
||||||
#endif
|
|
||||||
_sync_state_checksum = _state_checksum.state;
|
_sync_state_checksum = _state_checksum.state;
|
||||||
|
|
||||||
(*_network_server_sync_records)[_network_server_sync_records_next] = { _frame_counter, _random.state[0], _state_checksum.state };
|
(*_network_server_sync_records)[_network_server_sync_records_next] = { _frame_counter, _random.state[0], _state_checksum.state };
|
||||||
|
@@ -316,17 +316,9 @@ void ClientNetworkGameSocketHandler::ClientError(NetworkRecvStatus res)
|
|||||||
/* Check if we are in sync! */
|
/* Check if we are in sync! */
|
||||||
if (_sync_frame != 0) {
|
if (_sync_frame != 0) {
|
||||||
if (_sync_frame == _frame_counter) {
|
if (_sync_frame == _frame_counter) {
|
||||||
#ifdef NETWORK_SEND_DOUBLE_SEED
|
|
||||||
if (_sync_seed_1 != _random.state[0] || _sync_seed_2 != _random.state[1] || (_sync_state_checksum != _state_checksum.state && !HasChickenBit(DCBF_MP_NO_STATE_CSUM_CHECK))) {
|
|
||||||
#else
|
|
||||||
if (_sync_seed_1 != _random.state[0] || (_sync_state_checksum != _state_checksum.state && !HasChickenBit(DCBF_MP_NO_STATE_CSUM_CHECK))) {
|
if (_sync_seed_1 != _random.state[0] || (_sync_state_checksum != _state_checksum.state && !HasChickenBit(DCBF_MP_NO_STATE_CSUM_CHECK))) {
|
||||||
#endif
|
|
||||||
DesyncExtraInfo info;
|
DesyncExtraInfo info;
|
||||||
if (_sync_seed_1 != _random.state[0]) info.flags |= DesyncExtraInfo::DEIF_RAND1;
|
if (_sync_seed_1 != _random.state[0]) info.flags |= DesyncExtraInfo::DEIF_RAND;
|
||||||
#ifdef NETWORK_SEND_DOUBLE_SEED
|
|
||||||
if (_sync_seed_2 != _random.state[1]) info.flags |= DesyncExtraInfo::DEIF_RAND2;
|
|
||||||
info.flags |= DesyncExtraInfo::DEIF_DBL_RAND;
|
|
||||||
#endif
|
|
||||||
if (_sync_state_checksum != _state_checksum.state) info.flags |= DesyncExtraInfo::DEIF_STATE;
|
if (_sync_state_checksum != _state_checksum.state) info.flags |= DesyncExtraInfo::DEIF_STATE;
|
||||||
|
|
||||||
ShowNetworkError(STR_NETWORK_ERROR_DESYNC);
|
ShowNetworkError(STR_NETWORK_ERROR_DESYNC);
|
||||||
@@ -1074,16 +1066,9 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_FRAME(Packet *p
|
|||||||
#ifdef ENABLE_NETWORK_SYNC_EVERY_FRAME
|
#ifdef ENABLE_NETWORK_SYNC_EVERY_FRAME
|
||||||
/* Test if the server supports this option
|
/* Test if the server supports this option
|
||||||
* and if we are at the frame the server is */
|
* and if we are at the frame the server is */
|
||||||
#ifdef NETWORK_SEND_DOUBLE_SEED
|
|
||||||
if (p->CanReadFromPacket(4 + 4 + 8)) {
|
|
||||||
#else
|
|
||||||
if (p->CanReadFromPacket(4 + 8)) {
|
if (p->CanReadFromPacket(4 + 8)) {
|
||||||
#endif
|
|
||||||
_sync_frame = _frame_counter_server;
|
_sync_frame = _frame_counter_server;
|
||||||
_sync_seed_1 = p->Recv_uint32();
|
_sync_seed_1 = p->Recv_uint32();
|
||||||
#ifdef NETWORK_SEND_DOUBLE_SEED
|
|
||||||
_sync_seed_2 = p->Recv_uint32();
|
|
||||||
#endif
|
|
||||||
_sync_state_checksum = p->Recv_uint64();
|
_sync_state_checksum = p->Recv_uint64();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -1110,9 +1095,6 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_SYNC(Packet *p)
|
|||||||
|
|
||||||
_sync_frame = p->Recv_uint32();
|
_sync_frame = p->Recv_uint32();
|
||||||
_sync_seed_1 = p->Recv_uint32();
|
_sync_seed_1 = p->Recv_uint32();
|
||||||
#ifdef NETWORK_SEND_DOUBLE_SEED
|
|
||||||
_sync_seed_2 = p->Recv_uint32();
|
|
||||||
#endif
|
|
||||||
_sync_state_checksum = p->Recv_uint64();
|
_sync_state_checksum = p->Recv_uint64();
|
||||||
|
|
||||||
return NETWORK_RECV_STATUS_OKAY;
|
return NETWORK_RECV_STATUS_OKAY;
|
||||||
|
@@ -34,12 +34,6 @@ static const uint32 FIND_SERVER_EXTENDED_TOKEN = 0x2A49582A;
|
|||||||
* nothing will happen.
|
* nothing will happen.
|
||||||
*/
|
*/
|
||||||
#define ENABLE_NETWORK_SYNC_EVERY_FRAME
|
#define ENABLE_NETWORK_SYNC_EVERY_FRAME
|
||||||
|
|
||||||
/**
|
|
||||||
* In theory sending 1 of the 2 seeds is enough to check for desyncs
|
|
||||||
* so in theory, this next define can be left off.
|
|
||||||
*/
|
|
||||||
#define NETWORK_SEND_DOUBLE_SEED
|
|
||||||
#endif /* RANDOM_DEBUG */
|
#endif /* RANDOM_DEBUG */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -80,9 +74,6 @@ extern uint32 _last_sync_frame; // Used in the server to store the last time a s
|
|||||||
extern NetworkAddressList _broadcast_list;
|
extern NetworkAddressList _broadcast_list;
|
||||||
|
|
||||||
extern uint32 _sync_seed_1;
|
extern uint32 _sync_seed_1;
|
||||||
#ifdef NETWORK_SEND_DOUBLE_SEED
|
|
||||||
extern uint32 _sync_seed_2;
|
|
||||||
#endif
|
|
||||||
extern uint64 _sync_state_checksum;
|
extern uint64 _sync_state_checksum;
|
||||||
extern uint32 _sync_frame;
|
extern uint32 _sync_frame;
|
||||||
extern Date _last_sync_date;
|
extern Date _last_sync_date;
|
||||||
|
@@ -701,9 +701,6 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendFrame()
|
|||||||
p->Send_uint32(_frame_counter_max);
|
p->Send_uint32(_frame_counter_max);
|
||||||
#ifdef ENABLE_NETWORK_SYNC_EVERY_FRAME
|
#ifdef ENABLE_NETWORK_SYNC_EVERY_FRAME
|
||||||
p->Send_uint32(_sync_seed_1);
|
p->Send_uint32(_sync_seed_1);
|
||||||
#ifdef NETWORK_SEND_DOUBLE_SEED
|
|
||||||
p->Send_uint32(_sync_seed_2);
|
|
||||||
#endif
|
|
||||||
p->Send_uint64(_sync_state_checksum);
|
p->Send_uint64(_sync_state_checksum);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -724,9 +721,6 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendSync()
|
|||||||
p->Send_uint32(_frame_counter);
|
p->Send_uint32(_frame_counter);
|
||||||
p->Send_uint32(_sync_seed_1);
|
p->Send_uint32(_sync_seed_1);
|
||||||
|
|
||||||
#ifdef NETWORK_SEND_DOUBLE_SEED
|
|
||||||
p->Send_uint32(_sync_seed_2);
|
|
||||||
#endif
|
|
||||||
p->Send_uint64(_sync_state_checksum);
|
p->Send_uint64(_sync_state_checksum);
|
||||||
this->SendPacket(p);
|
this->SendPacket(p);
|
||||||
return NETWORK_RECV_STATUS_OKAY;
|
return NETWORK_RECV_STATUS_OKAY;
|
||||||
|
Reference in New Issue
Block a user