add debug pref to not add mqtt to all games

I want it for testing that stuff like NBS (data SMS) works for more
than connecting. MQTT works so well nothing ever gets used once it's
there.
This commit is contained in:
Eric House 2022-05-09 15:10:15 -07:00
parent 216c16f360
commit da23bfe23b
11 changed files with 29 additions and 2 deletions

View file

@ -70,6 +70,7 @@ public class CommonPrefs extends XWPrefs {
public boolean sortNewTiles;
public boolean allowPeek;
public boolean hideCrosshairs;
public boolean skipMQTTAdd;
public TileValueType tvType;
public int[] playerColors;
@ -101,6 +102,7 @@ public class CommonPrefs extends XWPrefs {
showColors = getBoolean( context, sp, R.string.key_color_tiles, true );
sortNewTiles = getBoolean( context, sp, R.string.key_sort_tiles, true );
allowPeek = getBoolean( context, sp, R.string.key_peek_other, false );
skipMQTTAdd = getBoolean( context, sp, R.string.key_skip_mqtt_add, false );
hideCrosshairs = getBoolean( context, sp, R.string.key_hide_crosshairs, false );
int ord = getInt(context, sp, R.string.key_tile_valuetype, 0);

View file

@ -14,6 +14,7 @@
<string name="key_disable_nag_solo">key_disable_nag_solo</string>
<string name="key_sort_tiles">key_sort_tiles</string>
<string name="key_peek_other">key_peek_other</string>
<string name="key_skip_mqtt_add">key_skip_mqtt_add</string>
<string name="key_hide_crosshairs">key_hide_crosshairs</string>
<string name="key_tile_valuetype">key_tile_valuetype</string>
<string name="key_hide_values">key_hide_values</string>

View file

@ -2732,4 +2732,7 @@
<!-- Button giving option of opening just-downloaded wordlist -->
<string name="button_open_dict">Open</string>
<!-- Debug option to NOT augment whatever comm-vias are chosen with MQTT when possible -->
<string name="skip_mqtt_add_title">Skip adding MQTT</string>
<string name="skip_mqtt_add_summary">Do NOT attempt to send all messages by MQTT</string>
</resources>

View file

@ -57,5 +57,10 @@
android:numeric="decimal"
/>
<CheckBoxPreference android:key="@string/key_skip_mqtt_add"
android:title="@string/skip_mqtt_add_title"
android:summary="@string/skip_mqtt_add_summary"
android:defaultValue="false"
/>
</PreferenceCategory>
</PreferenceScreen>

View file

@ -597,6 +597,7 @@ loadCommonPrefs( JNIEnv* env, CommonPrefs* cp, jobject j_cp )
cp->showColors = getBool( env, j_cp, "showColors" );
cp->sortNewTiles = getBool( env, j_cp, "sortNewTiles" );
cp->allowPeek = getBool( env, j_cp, "allowPeek" );
cp->skipMQTTAdd = getBool( env, j_cp, "skipMQTTAdd" );
#ifdef XWFEATURE_CROSSHAIRS
cp->hideCrosshairs = getBool( env, j_cp, "hideCrosshairs" );
#endif

View file

@ -261,6 +261,7 @@ typedef struct CommonPrefs {
XP_Bool hideTileValues;
XP_Bool skipCommitConfirm; /* applies to all games */
XP_Bool sortNewTiles; /* applies to all games */
XP_Bool skipMQTTAdd; /* Debugging only? Don't add MQTT to all comms in server.c */
#ifdef XWFEATURE_SLOW_ROBOT
XP_U16 robotThinkMin, robotThinkMax;
XP_U16 robotTradePct;

View file

@ -128,6 +128,7 @@ typedef struct ServerNonvolatiles {
XP_U8 pendingRegistrations; /* server-case only */
XP_Bool showRobotScores;
XP_Bool sortNewTiles;
XP_Bool skipMQTTAdd;
#ifdef STREAM_VERS_BIGBOARD
XP_U8 streamVersion;
#endif
@ -697,6 +698,7 @@ server_prefsChanged( ServerCtxt* server, const CommonPrefs* cp )
{
server->nv.showRobotScores = cp->showRobotScores;
server->nv.sortNewTiles = cp->sortNewTiles;
server->nv.skipMQTTAdd = cp->skipMQTTAdd;
#ifdef XWFEATURE_SLOW_ROBOT
server->nv.robotThinkMin = cp->robotThinkMin;
server->nv.robotThinkMax = cp->robotThinkMax;
@ -754,8 +756,12 @@ readMQTTDevID( ServerCtxt* server, XWStreamCtxt* stream )
MQTTDevID devID;
if ( strToMQTTCDevID( buf, &devID ) ) {
XP_PlayerAddr channelNo = stream_getAddress( stream );
comms_addMQTTDevID( server->vol.comms, channelNo, &devID );
if ( server->nv.skipMQTTAdd ) {
XP_LOGFF( "skipMQTTAdd: %s", boolToStr(server->nv.skipMQTTAdd) );
} else {
XP_PlayerAddr channelNo = stream_getAddress( stream );
comms_addMQTTDevID( server->vol.comms, channelNo, &devID );
}
}
}
}

View file

@ -572,6 +572,7 @@ initNoDraw( CursesBoardState* cbState, sqlite3_int64 rowid,
cGlobals->cp.showBoardArrow = XP_TRUE;
cGlobals->cp.showRobotScores = params->showRobotScores;
cGlobals->cp.hideTileValues = params->hideValues;
cGlobals->cp.skipMQTTAdd = params->skipMQTTAdd;
cGlobals->cp.skipCommitConfirm = params->skipCommitConfirm;
cGlobals->cp.sortNewTiles = params->sortNewTiles;
cGlobals->cp.showColors = params->showColors;

View file

@ -2466,6 +2466,7 @@ initGlobalsNoDraw( GtkGameGlobals* globals, LaunchParams* params,
cGlobals->cp.showBoardArrow = XP_TRUE;
cGlobals->cp.hideTileValues = params->hideValues;
cGlobals->cp.skipMQTTAdd = params->skipMQTTAdd;
cGlobals->cp.skipCommitConfirm = params->skipCommitConfirm;
cGlobals->cp.sortNewTiles = params->sortNewTiles;
cGlobals->cp.showColors = params->showColors;

View file

@ -754,6 +754,7 @@ typedef enum {
CMD_HELP
,CMD_SKIP_GAMEOVER
,CMD_SHOW_OTHERSCORES
,CMD_SKIP_MQTT
,CMD_HOSTIP
,CMD_HOSTPORT
,CMD_MYPORT
@ -896,6 +897,7 @@ static CmdInfoRec CmdInfoRecs[] = {
{ CMD_HELP, false, "help", "print this message" }
,{ CMD_SKIP_GAMEOVER, false, "skip-final", "skip final scores display" }
,{ CMD_SHOW_OTHERSCORES, false, "show-other", "show robot/remote scores" }
,{ CMD_SKIP_MQTT, false, "skip-mqtt-add", "Do not add MQTT to games as they connect" }
,{ CMD_HOSTIP, true, "host-ip", "remote host ip address (for direct connect)" }
,{ CMD_HOSTPORT, true, "host-port", "remote host ip address (for direct connect)" }
,{ CMD_MYPORT, true, "my-port", "remote host ip address (for direct connect)" }
@ -2762,6 +2764,9 @@ main( int argc, char** argv )
case CMD_SHOW_OTHERSCORES:
mainParams.showRobotScores = XP_TRUE;
break;
case CMD_SKIP_MQTT:
mainParams.skipMQTTAdd = XP_TRUE;
break;
#ifdef XWFEATURE_RELAY
case CMD_ROOMNAME:
mainParams.connInfo.relay.invite = optarg;

View file

@ -95,6 +95,7 @@ typedef struct _LaunchParams {
XP_Bool undoWhenDone;
XP_Bool verticalScore;
XP_Bool hideValues;
XP_Bool skipMQTTAdd;
XP_Bool showColors;
XP_Bool allowPeek;
XP_Bool sortNewTiles;