From 947cb7b77b2aaf56b0666719f1bd34957f8f3e49 Mon Sep 17 00:00:00 2001 From: avolkov Date: Wed, 20 Apr 2005 04:38:18 +0000 Subject: [PATCH] Make (get|set)GameState funcs non-inline; avoids MSVC6 optimization bug git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1662 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/src/sc2code/globdata.c | 39 ++++++++++++++++++++++++++++++++++++++ sc2/src/sc2code/globdata.h | 35 +++------------------------------- 2 files changed, 42 insertions(+), 32 deletions(-) diff --git a/sc2/src/sc2code/globdata.c b/sc2/src/sc2code/globdata.c index 7e02c1cc1..26be99bf0 100644 --- a/sc2/src/sc2code/globdata.c +++ b/sc2/src/sc2code/globdata.c @@ -28,6 +28,9 @@ #include "gamestr.h" #include +#ifdef STATE_DEBUG +# include +#endif static void CreateRadar (void); @@ -40,6 +43,42 @@ GLOBDATA GlobData; extern FRAME flagship_status, misc_data; BOOLEAN initedSIS = 0; + +BYTE +getGameState (int startBit, int endBit) +{ + return (BYTE) (((startBit >> 3) == (endBit >> 3) + ? (GLOBAL (GameState[startBit >> 3]) >> (startBit & 7)) + : ((GLOBAL (GameState[startBit >> 3]) >> (startBit & 7)) + | (GLOBAL (GameState[endBit >> 3]) + << (endBit - startBit - (endBit & 7))))) + & ((1 << (endBit - startBit + 1)) - 1)); +} + +void +setGameState (int startBit, int endBit, BYTE val +#ifdef STATE_DEBUG + , const char *name +#endif +) +{ + GLOBAL (GameState[startBit >> 3]) = + (GLOBAL (GameState[startBit >> 3]) + & (BYTE) ~(((1 << (endBit - startBit + 1)) - 1) << (startBit & 7))) + | (BYTE)((val) << (startBit & 7)); + + if ((startBit >> 3) < (endBit >> 3)) { + GLOBAL (GameState[endBit >> 3]) = + (GLOBAL (GameState[endBit >> 3]) + & (BYTE)~((1 << ((endBit & 7) + 1)) - 1)) + | (BYTE)((val) >> (endBit - startBit - (endBit & 7))); + } +#ifdef STATE_DEBUG + fprintf (stderr, "State '%s' set to %d.\n", name, val); +#endif +} + + static void CreateRadar (void) { diff --git a/sc2/src/sc2code/globdata.h b/sc2/src/sc2code/globdata.h index 597404fa0..7261dc5cb 100644 --- a/sc2/src/sc2code/globdata.h +++ b/sc2/src/sc2code/globdata.h @@ -919,41 +919,12 @@ extern GLOBDATA GlobData; //#define STATE_DEBUG -#ifdef STATE_DEBUG -# include -#endif - -static inline BYTE -getGameState (int startBit, int endBit) { - return (BYTE) (((startBit >> 3) == (endBit >> 3) - ? (GLOBAL (GameState[startBit >> 3]) >> (startBit & 7)) - : ((GLOBAL (GameState[startBit >> 3]) >> (startBit & 7)) - | (GLOBAL (GameState[endBit >> 3]) - << (endBit - startBit - (endBit & 7))))) - & ((1 << (endBit - startBit + 1)) - 1)); -} - -static inline -void setGameState (int startBit, int endBit, BYTE val +extern BYTE getGameState (int startBit, int endBit); +extern void setGameState (int startBit, int endBit, BYTE val #ifdef STATE_DEBUG , const char *name #endif - ) { - GLOBAL (GameState[startBit >> 3]) = - (GLOBAL (GameState[startBit >> 3]) - & (BYTE) ~(((1 << (endBit - startBit + 1)) - 1) << (startBit & 7))) - | (BYTE)((val) << (startBit & 7)); - - if ((startBit >> 3) < (endBit >> 3)) { - GLOBAL (GameState[endBit >> 3]) = - (GLOBAL (GameState[endBit >> 3]) - & (BYTE)~((1 << ((endBit & 7) + 1)) - 1)) - | (BYTE)((val) >> (endBit - startBit - (endBit & 7))); - } -#ifdef STATE_DEBUG - fprintf (stderr, "State '%s' set to %d.\n", name, val); -#endif -} + ); #define GET_GAME_STATE(SName) getGameState ((SName), (END_##SName)) #ifdef STATE_DEBUG