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
This commit is contained in:
avolkov
2005-04-20 04:38:18 +00:00
parent 01c000cf7b
commit 947cb7b77b
2 changed files with 42 additions and 32 deletions
+39
View File
@@ -28,6 +28,9 @@
#include "gamestr.h"
#include <stdlib.h>
#ifdef STATE_DEBUG
# include <stdio.h>
#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)
{
+3 -32
View File
@@ -919,41 +919,12 @@ extern GLOBDATA GlobData;
//#define STATE_DEBUG
#ifdef STATE_DEBUG
# include <stdio.h>
#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