mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-05 20:45:49 +01:00
use gameID as inviteID, so that all devices in a game will be using
the same gameID -- and use that to reject as duplicates attempts to use the same invitation more than once.
This commit is contained in:
parent
d7239323bc
commit
45fcd19e6e
5 changed files with 24 additions and 10 deletions
|
@ -2173,7 +2173,8 @@
|
|||
|
||||
<string name="prefs_thumb">Thumbnails</string>
|
||||
<string name="prefs_thumb_summary">Setting for game snapshots</string>
|
||||
<string name="dropped_dupe">Invitation ignored: already used</string>
|
||||
<string name="dropped_dupe">Invitation received but ignored: it
|
||||
has already been used to create a game.</string>
|
||||
<string name="cur_menu_markerf">%1$s (yours)</string>
|
||||
<string name="board_menu_invite">Invite</string>
|
||||
|
||||
|
|
|
@ -128,6 +128,7 @@ public class BoardActivity extends XWActivity
|
|||
private int m_jniGamePtr;
|
||||
private GameLock m_gameLock;
|
||||
private CurGameInfo m_gi;
|
||||
private GameSummary m_summary;
|
||||
private CommsTransport m_xport;
|
||||
private Handler m_handler = null;
|
||||
private TimerRunnable[] m_timers;
|
||||
|
@ -1197,8 +1198,10 @@ public class BoardActivity extends XWActivity
|
|||
{
|
||||
String data = null;
|
||||
if ( 0 < m_missing ) { // Isn't there a better test??
|
||||
String inviteID = GameUtils.makeRandomID();
|
||||
data = NetLaunchInfo.makeLaunchJSON( this, m_room, inviteID,
|
||||
String inviteID = String.format( "%X", m_gi.gameID );
|
||||
String room = m_summary.roomName;
|
||||
Assert.assertNotNull( room );
|
||||
data = NetLaunchInfo.makeLaunchJSON( this, room, inviteID,
|
||||
m_gi.dictLang,
|
||||
m_gi.dictName, m_gi.nPlayers );
|
||||
}
|
||||
|
@ -1844,6 +1847,9 @@ public class BoardActivity extends XWActivity
|
|||
pairs.m_paths, langName );
|
||||
}
|
||||
|
||||
m_summary = new GameSummary( this, m_gi );
|
||||
XwJNI.game_summarize( m_jniGamePtr, m_summary );
|
||||
|
||||
Handler handler = new Handler() {
|
||||
public void handleMessage( Message msg ) {
|
||||
switch( msg.what ) {
|
||||
|
|
|
@ -411,7 +411,8 @@ public class GameUtils {
|
|||
{
|
||||
long rowid = -1;
|
||||
|
||||
CurGameInfo gi = new CurGameInfo( context, true );
|
||||
Assert.assertNotNull( inviteID );
|
||||
CurGameInfo gi = new CurGameInfo( context, inviteID );
|
||||
gi.setLang( lang[0], dict[0] );
|
||||
lang[0] = gi.dictLang;
|
||||
dict[0] = gi.dictName;
|
||||
|
|
|
@ -1068,9 +1068,9 @@ public class GamesList extends XWExpandableListActivity
|
|||
String msg = getString( R.string.dup_game_queryf,
|
||||
create.toString() );
|
||||
m_netLaunchInfo = nli;
|
||||
showConfirmThen( msg, GamesActions.NEW_NET_GAME.ordinal() );
|
||||
showConfirmThen( msg, GamesActions.NEW_NET_GAME.ordinal(), nli );
|
||||
} else {
|
||||
Utils.showToast( this, R.string.dropped_dupe );
|
||||
showOKOnlyDialog( R.string.dropped_dupe );
|
||||
}
|
||||
} // startNewNetGame
|
||||
|
||||
|
@ -1252,9 +1252,9 @@ public class GamesList extends XWExpandableListActivity
|
|||
launchGame( rowid, false );
|
||||
}
|
||||
|
||||
private void makeNewNetGame( NetLaunchInfo info )
|
||||
private void makeNewNetGame( NetLaunchInfo nli )
|
||||
{
|
||||
long rowid = GameUtils.makeNewNetGame( this, info );
|
||||
long rowid = GameUtils.makeNewNetGame( this, nli );
|
||||
launchGame( rowid, true );
|
||||
}
|
||||
|
||||
|
|
|
@ -60,11 +60,12 @@ public class CurGameInfo {
|
|||
|
||||
public CurGameInfo( Context context )
|
||||
{
|
||||
this( context, false );
|
||||
this( context, (String)null );
|
||||
}
|
||||
|
||||
public CurGameInfo( Context context, boolean isNetworked )
|
||||
public CurGameInfo( Context context, String inviteID )
|
||||
{
|
||||
boolean isNetworked = null != inviteID;
|
||||
m_context = context;
|
||||
nPlayers = 2;
|
||||
gameSeconds = 60 * nPlayers *
|
||||
|
@ -81,6 +82,11 @@ public class CurGameInfo {
|
|||
allowHintRect = false;
|
||||
m_smartness = 0; // needs to be set from players
|
||||
|
||||
try {
|
||||
gameID = (null == inviteID) ? 0 : Integer.parseInt( inviteID, 16 );
|
||||
} catch ( Exception ex ) {
|
||||
}
|
||||
|
||||
// Always create MAX_NUM_PLAYERS so jni code doesn't ever have
|
||||
// to cons up a LocalPlayer instance.
|
||||
for ( int ii = 0; ii < MAX_NUM_PLAYERS; ++ii ) {
|
||||
|
|
Loading…
Add table
Reference in a new issue