add comments about problems with signed gameIDs

This commit is contained in:
Eric House 2024-01-04 18:03:38 -08:00
parent ac71aac787
commit 8388b27002
4 changed files with 16 additions and 7 deletions

View file

@ -87,8 +87,16 @@ makeGameID( XW_UtilCtxt* XP_UNUSED_DBG(util) )
/* High bit never set by XP_RANDOM() alone */
gameID = (XP_RANDOM() << 16) ^ XP_RANDOM();
/* But let's clear it -- set high-bit causes problems for existing
postgres DB where INTEGER is apparently a signed 32-bit */
gameID &= 0x7FFFFFFF;
postgres DB where INTEGER is apparently a signed 32-bit. Recently
confirmed that working around that in the code that moves between
incoming web api calls and postgres would be much harder than using
8-char hex strings instead. But I'll leave the test change in
place. */
#ifdef HIGH_GAMEID_BITS
gameID |= 0x80000000;
#else
gameID &= ~0x80000000;
#endif
}
LOG_RETURNF( "%08X", gameID );
return gameID;

View file

@ -1227,7 +1227,7 @@ handleRegistrationMsg( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* stream )
if ( 0 < stream_getSize(stream) ) {
XP_U8 streamVersion = stream_getU8( stream );
if ( streamVersion >= STREAM_VERS_BIGBOARD ) {
SRVR_LOGFF( "upping device %d streamVersion to %d",
SRVR_LOGFF( "upping device %d streamVersion to 0x%x",
clientIndex, streamVersion );
server->nv.addresses[clientIndex].streamVersion = streamVersion;
}

View file

@ -25,7 +25,7 @@ DEFINES += -DLOG_COMMS_MSGNOS
DEFINES += -DDI_DEBUG
CFLAGS += -g $(GPROFFLAG) -Wall -Wunused-parameter -Wcast-align -Werror -O0
DEFINES += -DDEBUG_HASHING
CFLAGS += -DDEBUG_TS -rdynamic
CFLAGS += -DDEBUG_TS -rdynamic
PLATFORM = obj_linux_memdbg
else
DEFINES =
@ -273,6 +273,7 @@ LIBS += `pkg-config --libs glib-2.0`
CFLAGS += $(POINTER_SUPPORT)
CFLAGS += -DDROP_BITMAPS
# CFLAGS += -DHIGH_GAMEID_BITS
ifneq (,$(findstring DPLATFORM_NCURSES,$(DEFINES)))
LIBS += $(OE_LIBDIR) -lncursesw

View file

@ -158,7 +158,6 @@ class GameStatus():
player = status.players[indx-1]
hostMarker = status.hostName == player and '*' or ' '
initial = GameStatus._abbrev(player)
arg3 = -1
dev = Device._devs.get(player)
gameState = dev.gameFor(gid).state
if gameState:
@ -168,7 +167,8 @@ class GameStatus():
else:
arg3 = gameState.get('nTiles')
if arg3 > 0: GameStatus._tileCount += arg3
line = '{}{:3}{: 3}'.format(hostMarker, initial, arg3)
arg3 = 0 <= arg3 and '{: 3}'.format(arg3) or ' - '
line = '{}{:3}{}'.format(hostMarker, initial, arg3)
results.append(line.center(len(gid)))
return ' '.join(results)
@ -199,7 +199,7 @@ class Device():
self.guestGames = []
self.script = '{}/{}.sh'.format(Device._logdir, host)
self.dbName = '{}/{}.db'.format(Device._logdir, host)
self.logfile = '{}/{}_log.txt'.format(Device._logdir, host)
self.logfile = '{}/{}_logs.txt'.format(Device._logdir, host)
self.cmdSocketName = '{}/{}.sock'.format(Device._logdir, host)
self._keyCur = 10000 * (1 + g_NAMES.index(host))