wrap test-only feature in new compile-time flag

This commit is contained in:
Eric House 2020-04-24 13:33:40 -07:00
parent 3ee6f95a16
commit 99df8806c3
8 changed files with 22 additions and 3 deletions

View file

@ -237,7 +237,9 @@ typedef struct CommonPrefs {
#ifdef XWFEATURE_CROSSHAIRS
XP_Bool hideCrosshairs; /* applies to all games */
#endif
#ifdef XWFEATURE_ROBOTPHONIES
XP_U16 makePhonyPct;
#endif
} CommonPrefs;
typedef struct _PlayerDicts {

View file

@ -1255,8 +1255,10 @@ juggleMoveIfDebug( MoveInfo* move )
}
}
}
#endif
/* Reverse the *letters on* the tiles */
#ifdef XWFEATURE_ROBOTPHONIES
void
reverseTiles( MoveInfo* move )
{

View file

@ -106,7 +106,9 @@ typedef struct ServerNonvolatiles {
XP_U16 robotThinkMin, robotThinkMax; /* not saved (yet) */
XP_U16 robotTradePct;
#endif
#ifdef XWFEATURE_ROBOTPHONIES
XP_U16 makePhonyPct;
#endif
RemoteAddress addresses[MAX_NUM_PLAYERS];
XWStreamCtxt* prevMoveStream; /* save it to print later */
@ -625,7 +627,9 @@ server_prefsChanged( ServerCtxt* server, const CommonPrefs* cp )
server->nv.robotThinkMax = cp->robotThinkMax;
server->nv.robotTradePct = cp->robotTradePct;
#endif
#ifdef XWFEATURE_ROBOTPHONIES
server->nv.makePhonyPct = cp->makePhonyPct;
#endif
} /* server_prefsChanged */
XP_S16
@ -1370,7 +1374,7 @@ makeRobotMove( ServerCtxt* server )
/* if canMove is false, this is a fake move, a pass */
if ( canMove || NPASSES_OK(server) ) {
#ifdef DEBUG
#ifdef XWFEATURE_ROBOTPHONIES
if ( server->nv.makePhonyPct > XP_RANDOM() % 100 ) {
reverseTiles( &newMove );
}

View file

@ -161,7 +161,7 @@ DEFINES += -DXWFEATURE_SMS -DXWFEATURE_BASE64
DEFINES += -DXWFEATURE_DIRECTIP
# Robot can be made to think, to simulate for relay mostly
DEFINES += -DXWFEATURE_SLOW_ROBOT
DEFINES += -DXWFEATURE_SLOW_ROBOT -DXWFEATURE_ROBOTPHONIES
DEFINES += -DXWFEATURE_DEVICE

View file

@ -591,7 +591,9 @@ initNoDraw( CursesBoardState* cbState, sqlite3_int64 rowid,
cGlobals->cp.robotThinkMax = params->robotThinkMax;
cGlobals->cp.robotTradePct = params->robotTradePct;
#endif
#ifdef XWFEATURE_ROBOTPHONIES
cGlobals->cp.makePhonyPct = params->makePhonyPct;
#endif
if ( linuxOpenGame( cGlobals, &result->procs, returnAddr ) ) {
result = ref( result );

View file

@ -2372,7 +2372,9 @@ initGlobalsNoDraw( GtkGameGlobals* globals, LaunchParams* params,
cGlobals->cp.robotThinkMax = params->robotThinkMax;
cGlobals->cp.robotTradePct = params->robotTradePct;
#endif
#ifdef XWFEATURE_ROBOTPHONIES
cGlobals->cp.makePhonyPct = params->makePhonyPct;
#endif
#ifdef XWFEATURE_CROSSHAIRS
cGlobals->cp.hideCrosshairs = params->hideCrosshairs;
#endif

View file

@ -897,7 +897,9 @@ typedef enum {
,CMD_SLOWROBOT
,CMD_TRADEPCT
#endif
#ifdef XWFEATURE_ROBOTPHONIES
,CMD_MAKE_PHONY_PCT
#endif
#ifdef USE_GLIBLOOP /* just because hard to implement otherwise */
,CMD_UNDOPCT
#endif
@ -1035,8 +1037,10 @@ static CmdInfoRec CmdInfoRecs[] = {
,{ CMD_SLOWROBOT, true, "slow-robot", "make robot slower to test network" }
,{ CMD_TRADEPCT, true, "trade-pct", "what pct of the time should robot trade" }
#endif
#ifdef XWFEATURE_ROBOTPHONIES
,{ CMD_MAKE_PHONY_PCT, true, "make-phony-pct",
"what pct of the time should robot play a bad word" }
#endif
#ifdef USE_GLIBLOOP
,{ CMD_UNDOPCT, true, "undo-pct",
"each second, what are the odds of doing an undo" }
@ -2964,7 +2968,8 @@ main( int argc, char** argv )
usage(argv[0], "must be 0 <= n <= 100" );
}
break;
#endif
#ifdef XWFEATURE_ROBOTPHONIES
case CMD_MAKE_PHONY_PCT:
mainParams.makePhonyPct = atoi( optarg );
if ( mainParams.makePhonyPct < 0 || mainParams.makePhonyPct > 100 ) {

View file

@ -129,7 +129,9 @@ typedef struct LaunchParams {
XP_U16 robotThinkMin, robotThinkMax;
XP_U16 robotTradePct;
#endif
#ifdef XWFEATURE_ROBOTPHONIES
XP_U16 makePhonyPct;
#endif
XP_Bool commsDisableds[COMMS_CONN_NTYPES][2];
DeviceRole serverRole;