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:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user