From 5205cb3444397cd60c50b0b538d5ecb9c5e73e48 Mon Sep 17 00:00:00 2001 From: Meep-Eep Date: Fri, 29 Jun 2007 15:05:18 +0000 Subject: [PATCH] Don't checksum elements with BACKGROUND_OBJECT set. Allows for certain types of graphics mods which don't influence netplay synchronisation. git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2793 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/src/sc2code/element.h | 5 ++++ sc2/src/sc2code/netplay/checksum.c | 46 ++++++++++++++++++------------ 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/sc2/src/sc2code/element.h b/sc2/src/sc2code/element.h index 46abac90e..e0faaecd2 100644 --- a/sc2/src/sc2code/element.h +++ b/sc2/src/sc2code/element.h @@ -70,6 +70,11 @@ typedef HLINK HELEMENT; #define IGNORE_VELOCITY (1 << 13) #define CREW_OBJECT (1 << 14) #define BACKGROUND_OBJECT (1 << 15) + // The BACKGROUND_OBJECT flag existed originally but wasn't used. + // It can now be used for objects that never influence the state + // of other elements; elements that have this flag set are not + // included in the checksum used for netplay games. + // It can be used for graphical mods that don't impede netplay. #define HYPERJUMP_LIFE 15 diff --git a/sc2/src/sc2code/netplay/checksum.c b/sc2/src/sc2code/netplay/checksum.c index 2f59b7237..14779147b 100644 --- a/sc2/src/sc2code/netplay/checksum.c +++ b/sc2/src/sc2code/netplay/checksum.c @@ -109,28 +109,36 @@ crc_processELEMENT(crc_State *state, const ELEMENT *val) { #ifdef DUMP_CRC_OPS crc_log("START crc_processELEMENT()."); #endif - crc_processELEMENT_FLAGS(state, val->state_flags); - crc_processCOUNT(state, val->life_span); - crc_processCOUNT(state, val->crew_level); - crc_processBYTE(state, val->mass_points); + if (val->state_flags & BACKGROUND_OBJECT) { + // The element never influences the state of other elements, + // and is to be excluded from checksums. +#ifdef DUMP_CRC_OPS + crc_log(" BACKGROUND_OBJECT element omited"); +#endif + } else { + crc_processELEMENT_FLAGS(state, val->state_flags); + crc_processCOUNT(state, val->life_span); + crc_processCOUNT(state, val->crew_level); + crc_processBYTE(state, val->mass_points); - // HACK: when a ship is being destroyed, turn_wait is abused to store - // the side this ship is on. This must be excluded from the checksum - // as this does not have to be the same for both sides. - { - extern void new_ship(ELEMENT *ElementPtr); - BYTE turn_wait = val->turn_wait; - - if (val->preprocess_func == new_ship) - turn_wait = 0; + // HACK: when a ship is being destroyed, turn_wait is abused to store + // the side this ship is on. This must be excluded from the checksum + // as this does not have to be the same for both sides. + { + extern void new_ship(ELEMENT *ElementPtr); + BYTE turn_wait = val->turn_wait; + + if (val->preprocess_func == new_ship) + turn_wait = 0; - crc_processBYTE(state, turn_wait); + crc_processBYTE(state, turn_wait); + } + + crc_processBYTE(state, val->thrust_wait); + crc_processVELOCITY_DESC(state, &val->velocity); + crc_processSTATE(state, &val->current); + crc_processSTATE(state, &val->next); } - - crc_processBYTE(state, val->thrust_wait); - crc_processVELOCITY_DESC(state, &val->velocity); - crc_processSTATE(state, &val->current); - crc_processSTATE(state, &val->next); #ifdef DUMP_CRC_OPS crc_log("END crc_processELEMENT()."); #endif