include game name in nli when rematching

This commit is contained in:
Eric House 2022-11-18 21:51:13 -08:00
parent e7cebe1d46
commit 34f68a435b
7 changed files with 22 additions and 14 deletions

View file

@ -569,7 +569,7 @@ public class GameUtils {
UtilCtxt util = new UtilCtxtImpl( context );
CommonPrefs cp = CommonPrefs.get(context);
try ( GamePtr gamePtrNew = XwJNI
.game_makeRematch( gamePtr, util, cp ) ) {
.game_makeRematch( gamePtr, util, cp, gameName ) ) {
if ( null != gamePtrNew ) {
rowid = saveNewGame1( context, gamePtrNew,
groupID, gameName );

View file

@ -325,12 +325,11 @@ public class XwJNI {
return gamePtr;
}
public static GamePtr game_makeRematch( GamePtr gamePtr,
UtilCtxt util,
CommonPrefs cp )
public static GamePtr game_makeRematch( GamePtr gamePtr, UtilCtxt util,
CommonPrefs cp, String gameName )
{
GamePtr gamePtrNew = initGameJNI( 0 );
game_makeRematch( gamePtr, gamePtrNew, util, cp );
game_makeRematch( gamePtr, gamePtrNew, util, cp, gameName );
return gamePtrNew;
}
@ -370,8 +369,8 @@ public class XwJNI {
private static native void game_makeRematch( GamePtr gamePtr,
GamePtr gamePtrNew,
UtilCtxt util,
CommonPrefs cp );
UtilCtxt util, CommonPrefs cp,
String gameName );
private static native boolean game_makeFromInvite( GamePtr gamePtr, NetLaunchInfo nli,
UtilCtxt util,

View file

@ -1434,7 +1434,7 @@ initGameGlobals( JNIEnv* env, JNIState* state, jobject jutil, jobject jprocs )
JNIEXPORT void JNICALL
Java_org_eehouse_android_xw4_jni_XwJNI_game_1makeRematch
( JNIEnv* env, jclass C, GamePtrType gamePtr, GamePtrType gamePtrNew,
jobject jutil, jobject jcp )
jobject jutil, jobject jcp, jstring jGameName )
{
LOG_FUNC();
XWJNI_START_GLOBALS(gamePtr);
@ -1447,7 +1447,10 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1makeRematch
CommonPrefs cp;
loadCommonPrefs( env, &cp, jcp );
game_makeRematch( &oldState->game, env, globals->util, &cp, &state->game );
const char* gameName = (*env)->GetStringUTFChars( env, jGameName, NULL );
game_makeRematch( &oldState->game, env, globals->util, &cp,
&state->game, gameName );
(*env)->ReleaseStringUTFChars( env, jGameName, gameName );
XWJNI_END();
XWJNI_END();

View file

@ -233,7 +233,8 @@ game_makeNewGame( MPFORMAL XWEnv xwe, XWGame* game, CurGameInfo* gi,
void
game_makeRematch( const XWGame* oldGame, XWEnv xwe, XW_UtilCtxt* newUtil,
const CommonPrefs* newCp, XWGame* newGame )
const CommonPrefs* newCp, XWGame* newGame,
const XP_UCHAR* newName )
{
LOG_FUNC();
CurGameInfo* newGI = newUtil->gameInfo;
@ -273,6 +274,9 @@ game_makeRematch( const XWGame* oldGame, XWEnv xwe, XW_UtilCtxt* newUtil,
if ( !!newGame->comms ) {
NetLaunchInfo nli;
nli_init( &nli, newGI, selfAddrP, 1, 1 );
if ( !!newName ) {
nli_setGameName( &nli, newName );
}
LOGNLI( &nli );
comms_invite( newGame->comms, xwe, &nli, &hostAddr );
}

View file

@ -84,7 +84,8 @@ XP_Bool game_makeNewGame( MPFORMAL XWEnv xwe, XWGame* game, CurGameInfo* gi,
#endif
);
void game_makeRematch( const XWGame* game, XWEnv xwe, XW_UtilCtxt* util,
const CommonPrefs* cp, XWGame* newGame );
const CommonPrefs* cp, XWGame* newGame,
const XP_UCHAR* newName );
XP_Bool game_reset( MPFORMAL XWGame* game, XWEnv xwe, CurGameInfo* gi,
const CommsAddrRec* selfAddr, const CommsAddrRec* hostAddr,

View file

@ -302,9 +302,9 @@ logNLI( const NetLaunchInfo* nli, const char* callerFunc, const int callerLine )
XP_UCHAR buf[1024];
XP_SNPRINTF( buf, VSIZE(buf), "{ctyps: [%s], nPlayersT: %d, nPlayersH: %d, "
"channel: %d, isoCode: '%s', gameID: %d",
"channel: %d, isoCode: '%s', gameID: %d, gameName: %s",
conTypes, nli->nPlayersT, nli->nPlayersH, nli->forceChannel,
nli->isoCodeStr, nli->gameID );
nli->isoCodeStr, nli->gameID, nli->gameName );
if ( types_hasType( nli->_conTypes, COMMS_CONN_MQTT ) ) {
XP_UCHAR smallBuf[128];
XP_SNPRINTF( smallBuf, VSIZE(smallBuf), ", mqttid: %s", nli->mqttDevID );

View file

@ -363,7 +363,8 @@ make_rematch( GtkAppGlobals* apg, const CommonGlobals* cGlobals )
XW_UtilCtxt* util = newGlobals->cGlobals.util;
const CommonPrefs* cp = &newGlobals->cGlobals.cp;
game_makeRematch( &cGlobals->game, NULL_XWE, util, cp, &newGlobals->cGlobals.game );
game_makeRematch( &cGlobals->game, NULL_XWE, util, cp,
&newGlobals->cGlobals.game, NULL );
linuxSaveGame( &newGlobals->cGlobals );
sqlite3_int64 rowid = newGlobals->cGlobals.rowid;