add logging of CurGameInfo

Trying to track down why some player names aren't preserved
This commit is contained in:
Eric House 2019-03-12 07:05:12 -07:00
parent 79aab3ead1
commit 91ff2175f6
5 changed files with 22 additions and 3 deletions

View file

@ -201,6 +201,7 @@ public class GameUtils {
private static GameSummary summarize( Context context, GameLock lock,
GamePtr gamePtr, CurGameInfo gi )
{
Log.d( TAG, "summarize(gi=%s)", gi );
GameSummary summary = new GameSummary( gi );
XwJNI.game_summarize( gamePtr, summary );
@ -233,6 +234,14 @@ public class GameUtils {
result = DBUtils.getSummary( context, lock );
}
} catch ( GameLock.GameLockedException gle ) {
if ( false && BuildConfig.DEBUG ) {
String dump = GameLock.getHolderDump( rowid );
Log.d( TAG, "getSummary() got gle: %s; cur owner: %s",
gle, dump );
String msg = "getSummary() unable to lock; owner: " + dump;
CrashTrack.logAndSend( TAG, msg );
}
}
}
}
@ -514,6 +523,7 @@ public class GameUtils {
CurGameInfo gi, GameLock lock,
boolean setCreate )
{
Log.d( TAG, "saveGame() gi: %s", gi );
byte[] stream = XwJNI.game_saveToStream( gamePtr, gi );
return saveGame( context, stream, lock, setCreate );
}
@ -521,6 +531,7 @@ public class GameUtils {
public static long saveNewGame( Context context, GamePtr gamePtr,
CurGameInfo gi, long groupID )
{
Log.d( TAG, "saveNewGame() gi: %s", gi );
byte[] stream = XwJNI.game_saveToStream( gamePtr, gi );
long rowid;
try ( GameLock lock = DBUtils.saveNewGame( context, stream, groupID, null ) ) {
@ -1036,6 +1047,7 @@ public class GameUtils {
DBUtils.setMsgFlags( rowid, flags | curFlags );
}
}
Log.d( TAG, "feedMessage(): gi: %s)", gi );
}
} catch ( GameLock.GameLockedException gle ) {
DbgUtils.toastNoLock( TAG, context, rowid,

View file

@ -123,6 +123,7 @@ abstract class XWServiceHelper {
String device, DictFetchOwner dfo )
{
boolean success = nli.isValid() && checkNotInFlight( nli );
CurGameInfo gi = null;
if ( success ) {
long[] rowids = DBUtils.getRowIDsFor( mService, nli.gameID() );
if ( 0 == rowids.length ) {
@ -135,7 +136,6 @@ abstract class XWServiceHelper {
// for duplicates! forceChannel's hard to dig up, but works
for ( int ii = 0; success && ii < rowids.length; ++ii ) {
long rowid = rowids[ii];
CurGameInfo gi = null;
try ( GameLock lock = GameLock.tryLockRO( rowid ) ) {
// drop invite if can't open game; likely a dupe!
if ( null != lock ) {
@ -182,7 +182,7 @@ abstract class XWServiceHelper {
}
}
}
Log.d( TAG, "handleInvitation() => %b", success );
Log.d( TAG, "handleInvitation() => %b (gi: %s)", success, gi );
return success;
}

View file

@ -167,7 +167,10 @@ public class CurGameInfo implements Serializable {
sb.append( players[ii] )
.append( ", " );
}
sb.append( "], gameID: ").append( gameID );
sb.append( "], gameID: ").append( gameID )
.append( ", hashCode: ").append( hashCode() )
.append('}');
result = sb.toString();
} else {
result = super.toString();

View file

@ -388,6 +388,7 @@ public class JNIThread extends Thread implements AutoCloseable {
if ( null != m_newDict ) {
m_gi.dictName = m_newDict;
}
Log.d( TAG, "save_jni(); m_gi: %s", m_gi );
byte[] state = XwJNI.game_saveToStream( m_jniGamePtr, m_gi );
int newHash = Arrays.hashCode( state );
boolean hashesEqual = m_lastSavedState == newHash;

View file

@ -163,6 +163,7 @@ public class XwJNI {
public static void gi_from_stream( CurGameInfo gi, byte[] stream )
{
gi_from_stream( getJNI().m_ptr, gi, stream );
Log.d( TAG, "gi_from_stream() read: %s", gi );
}
public static byte[] nliToStream( NetLaunchInfo nli )
@ -207,6 +208,8 @@ public class XwJNI {
cp, procs ) ) {
gamePtr.release();
gamePtr = null;
} else {
Log.d( TAG, "initFromStream() read: %s", gi );
}
return gamePtr;