From b0cc6dd74425388c34db973cd9f7ffc6f3fe7405 Mon Sep 17 00:00:00 2001 From: Eric House Date: Mon, 8 Mar 2021 07:54:05 -0800 Subject: [PATCH] clear name on delete; remove logging --- xwords4/common/movestak.c | 2 +- xwords4/common/server.c | 5 ++--- xwords4/wasm/main.c | 34 +++++++++++++++++++--------------- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/xwords4/common/movestak.c b/xwords4/common/movestak.c index 7455347aa..c52163dda 100644 --- a/xwords4/common/movestak.c +++ b/xwords4/common/movestak.c @@ -541,7 +541,7 @@ stack_getNextTurn( StackCtxt* stack ) stack_freeEntry( stack, &dummy ); } - LOG_RETURNF( "%d", result ); + // LOG_RETURNF( "%d", result ); return result; } diff --git a/xwords4/common/server.c b/xwords4/common/server.c index 16aab9885..65a58a869 100644 --- a/xwords4/common/server.c +++ b/xwords4/common/server.c @@ -3685,7 +3685,6 @@ server_commitMove( ServerCtxt* server, XWEnv xwe, XP_U16 player, TrayTileSet* ne static void finishMove( ServerCtxt* server, XWEnv xwe, TrayTileSet* newTiles, XP_U16 turn ) { - LOG_FUNC(); ModelCtxt* model = server->vol.model; CurGameInfo* gi = server->vol.gi; @@ -3732,8 +3731,8 @@ finishMove( ServerCtxt* server, XWEnv xwe, TrayTileSet* newTiles, XP_U16 turn ) } else { nextTurn( server, xwe, PICK_NEXT ); } - XP_LOGFF( "player %d now has %d tiles", turn, - model_getNumTilesInTray( model, turn ) ); + /* XP_LOGFF( "player %d now has %d tiles", turn, */ + /* model_getNumTilesInTray( model, turn ) ); */ } /* finishMove */ XP_Bool diff --git a/xwords4/wasm/main.c b/xwords4/wasm/main.c index 07edeec2c..120e89d86 100644 --- a/xwords4/wasm/main.c +++ b/xwords4/wasm/main.c @@ -132,7 +132,7 @@ EM_JS(void, call_get_dict, (const char* lc, GotDictProc proc, }); EM_JS(void, show_name, (const char* name), { - let jsname = UTF8ToString(name); + let jsname = name ? UTF8ToString(name) : ""; document.getElementById('gamename').textContent = jsname; }); @@ -493,20 +493,23 @@ updateGameButtons( Globals* globals ) static void showName( GameState* gs ) { - Globals* globals = gs->globals; - const char* title = gs->gameName; - char buf[64]; - if ( true || 1 < countDicts( globals ) ) { - char langName[32]; - const char* lc = lcToLocale(gs->gi.dictLang); - const XP_UCHAR* keys[] = {KEY_DICTS, lc, KEY_LANG_NAME, NULL }; - XP_U32 len = sizeof(langName); - dutil_loadPtr( globals->dutil, NULL, keys, langName, &len ); - if ( 0 != len ) { - lc = langName; + const char* title = NULL; + if ( !!gs ) { + Globals* globals = gs->globals; + title = gs->gameName; + char buf[64]; + if ( true || 1 < countDicts( globals ) ) { + char langName[32]; + const char* lc = lcToLocale(gs->gi.dictLang); + const XP_UCHAR* keys[] = {KEY_DICTS, lc, KEY_LANG_NAME, NULL }; + XP_U32 len = sizeof(langName); + dutil_loadPtr( globals->dutil, NULL, keys, langName, &len ); + if ( 0 != len ) { + lc = langName; + } + sprintf( buf, "%s (%s)", title, lc ); + title = buf; } - sprintf( buf, "%s (%s)", title, lc ); - title = buf; } show_name( title ); } @@ -633,6 +636,7 @@ deleteGame( GameState* gs ) formatGameID( gameIDStr, sizeof(gameIDStr), gameID ); const XP_UCHAR* keys[] = {KEY_GAMES, gameIDStr, NULL}; dutil_remove( globals->dutil, keys ); + showName( NULL ); } static void @@ -1006,7 +1010,7 @@ gameFromInvite( Globals* globals, const NetLaunchInfo* invite ) } else { char msg[128]; sprintf( msg, "Invitation requires a wordlist %s for " - "language %s; download now?", invite->dict, lc ); + "locale %s; download now?", invite->dict, lc ); DictDownState* dds = XP_MALLOC( globals->mpool, sizeof(*dds) ); dds->globals = globals;