mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-15 15:41:24 +01:00
receipt of invitations works
This commit is contained in:
parent
5382941f63
commit
95e9647ff0
3 changed files with 41 additions and 10 deletions
|
@ -803,8 +803,8 @@ onDeleteConfirmed( void* closure, bool confirmed )
|
|||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
getLocalName( Globals* globals, char* playerName, size_t buflen )
|
||||
bool
|
||||
main_getLocalName( Globals* globals, char* playerName, size_t buflen )
|
||||
{
|
||||
XP_U32 len = buflen;
|
||||
const XP_UCHAR* keys[] = {KEY_PLAYER_NAME, NULL};
|
||||
|
@ -898,7 +898,7 @@ onDeviceButton( void* closure, const char* button )
|
|||
call_confirm( globals, msg, onDeleteConfirmed, curGS );
|
||||
} else if ( 0 == strcmp(button, BUTTON_NAME ) ) {
|
||||
char playerName[32];
|
||||
getLocalName( globals, playerName, sizeof(playerName)-1 );
|
||||
main_getLocalName( globals, playerName, sizeof(playerName)-1 );
|
||||
call_get_string( "Set your (local) player name", playerName,
|
||||
onPlayerNamed, globals );
|
||||
}
|
||||
|
@ -1188,7 +1188,7 @@ newFromInvite( Globals* globals, const NetLaunchInfo* nli )
|
|||
globals->dutil, gs );
|
||||
|
||||
char playerName[32];
|
||||
getLocalName( globals, playerName, sizeof(playerName) );
|
||||
main_getLocalName( globals, playerName, sizeof(playerName) );
|
||||
|
||||
const CommsAddrRec* selfAddr = NULL;
|
||||
game_makeFromInvite( &gs->game, NULL_XWE, nli,
|
||||
|
@ -1495,7 +1495,7 @@ loadAndDraw( Globals* globals, const NetLaunchInfo* invite,
|
|||
DictionaryCtxt* dict = loadAnyDict( globals, langName );
|
||||
if ( !!dict ) {
|
||||
char playerName[32];
|
||||
getLocalName( globals, playerName, sizeof(playerName) );
|
||||
main_getLocalName( globals, playerName, sizeof(playerName) );
|
||||
|
||||
gs = newGameState( globals );
|
||||
gs->gi.serverRole = !!params && !params->isRobot
|
||||
|
@ -1991,6 +1991,27 @@ main_needDictForGame( GameState* gs, const char* lc,
|
|||
call_get_dict( lc, onGotMissingDict, gs->globals );
|
||||
}
|
||||
|
||||
|
||||
static XP_Bool
|
||||
checkForChannel( void* closure, const XP_UCHAR* keysIn[] )
|
||||
{
|
||||
XP_Bool* foundp = (XP_Bool*)closure;
|
||||
*foundp = XP_TRUE;
|
||||
return XP_TRUE;
|
||||
}
|
||||
|
||||
XP_Bool
|
||||
main_haveGame( Globals* globals, XP_U32 gameID, XP_U8 channel )
|
||||
{
|
||||
char gameIDStr[32];
|
||||
formatGameID( gameIDStr, sizeof(gameIDStr), gameID );
|
||||
const XP_UCHAR* keys[] = {KEY_GAMES, gameIDStr, KEY_GAME, NULL};
|
||||
XP_Bool found = XP_FALSE;
|
||||
dutil_forEach( globals->dutil, NULL_XWE, keys,
|
||||
checkForChannel, &found );
|
||||
return found;
|
||||
}
|
||||
|
||||
static void
|
||||
looper( void* closure )
|
||||
{
|
||||
|
@ -2290,7 +2311,7 @@ startLaunchSequence( Globals* globals, NetLaunchInfo* nli )
|
|||
}
|
||||
|
||||
/* No saved name? Ask. Politely */
|
||||
if ( getLocalName( globals, ls->playerName, sizeof(ls->playerName) ) ) {
|
||||
if ( main_getLocalName( globals, ls->playerName, sizeof(ls->playerName) ) ) {
|
||||
ls->hadName = true;
|
||||
onPlayerNamedAtLaunch( ls, NULL );
|
||||
} else {
|
||||
|
|
|
@ -109,6 +109,7 @@ void main_onGameMessage( Globals* globals, XP_U32 gameID,
|
|||
XP_U16 len );
|
||||
void main_onCtrlReceived( Globals* globals, const XP_U8* buf, XP_U16 len );
|
||||
void main_onGameGone( Globals* globals, XP_U32 gameID );
|
||||
XP_Bool main_haveGame( Globals* globals, XP_U32 gameID, XP_U8 channel );
|
||||
void main_sendOnClose( XWStreamCtxt* stream, XWEnv env, void* closure );
|
||||
void main_playerScoreHeld( GameState* gs, XP_U16 player );
|
||||
void main_showGameOver( GameState* gs );
|
||||
|
@ -119,5 +120,6 @@ void main_pickBlank( GameState* gs, int playerNum, int col, int row,
|
|||
const char** tileFaces, int nTiles );
|
||||
void main_updateScreen( GameState* gs );
|
||||
void main_needDictForGame(GameState* gs, const char* lc, const XP_UCHAR* dictName);
|
||||
bool main_getLocalName( Globals* globals, char* playerName, size_t buflen );
|
||||
|
||||
#endif
|
||||
|
|
|
@ -439,7 +439,15 @@ wasm_dutil_getUsername( XW_DUtilCtxt* duc, XWEnv xwe, XP_U16 num,
|
|||
XP_UCHAR* buf, XP_U16* len )
|
||||
{
|
||||
LOG_FUNC();
|
||||
XP_ASSERT(0);
|
||||
if ( isRobot ) {
|
||||
*len = snprintf( buf, *len, "Robot %d", num );
|
||||
} else if ( isLocal ) {
|
||||
Globals* globals = (Globals*)duc->closure;
|
||||
main_getLocalName( globals, buf, *len );
|
||||
*len = strlen( buf );
|
||||
} else {
|
||||
*len = snprintf( buf, *len, "Remote %d", num );
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -454,10 +462,10 @@ wasm_dutil_notifyPause( XW_DUtilCtxt* XP_UNUSED(duc), XWEnv XP_UNUSED(xwe),
|
|||
}
|
||||
|
||||
static XP_Bool
|
||||
wasm_dutil_haveGame( XW_DUtilCtxt* duc, XWEnv xwe, XP_U32 gameID,XP_U8 channel )
|
||||
wasm_dutil_haveGame( XW_DUtilCtxt* duc, XWEnv xwe, XP_U32 gameID, XP_U8 channel )
|
||||
{
|
||||
XP_ASSERT(0);
|
||||
return XP_TRUE;
|
||||
Globals* globals = (Globals*)duc->closure;
|
||||
return main_haveGame( globals, gameID, channel );
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in a new issue