add turnIsLocal to android db

So we can filter on it determining the display order of games in games
list.
This commit is contained in:
Eric House 2016-08-31 19:37:56 -07:00
parent a450aceab3
commit adf71c85a5
4 changed files with 14 additions and 4 deletions

View file

@ -1664,7 +1664,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1summarize
XP_Bool isLocal;
setInt( env, jsummary, "turn",
server_getCurrentTurn( state->game.server, &isLocal ) );
// setBool( env, jsummary, "turnIsLocal", isLocal );
setBool( env, jsummary, "turnIsLocal", isLocal );
setInt( env, jsummary, "lastMoveTime",
server_getLastMoveTime(state->game.server) );

View file

@ -46,12 +46,13 @@ public class DBHelper extends SQLiteOpenHelper {
public static final String TABLE_NAME_CHAT = "chat";
public static final String TABLE_NAME_LOGS = "logs";
private static final String DB_NAME = "xwdb";
private static final int DB_VERSION = 27;
private static final int DB_VERSION = 28;
public static final String GAME_NAME = "GAME_NAME";
public static final String VISID = "VISID";
public static final String NUM_MOVES = "NUM_MOVES";
public static final String TURN = "TURN";
public static final String TURN_LOCAL = "TURN_LOCAL";
public static final String GIFLAGS = "GIFLAGS";
public static final String PLAYERS = "PLAYERS";
@ -126,6 +127,7 @@ public class DBHelper extends SQLiteOpenHelper {
,{ GAME_NAME, "TEXT" }
,{ NUM_MOVES, "INTEGER" }
,{ TURN, "INTEGER" }
,{ TURN_LOCAL, "INTEGER" }
,{ GIFLAGS, "INTEGER" }
,{ NUM_PLAYERS, "INTEGER" }
,{ MISSINGPLYRS,"INTEGER" }
@ -322,6 +324,10 @@ public class DBHelper extends SQLiteOpenHelper {
createChatsTable( db );
case 26:
createLogsTable( db );
case 27:
if ( !madeSumTable ) {
addSumColumn( db, TURN_LOCAL );
}
break;
default:

View file

@ -125,7 +125,7 @@ public class DBUtils {
DBHelper.NUM_MOVES, DBHelper.NUM_PLAYERS,
DBHelper.MISSINGPLYRS,
DBHelper.GAME_OVER, DBHelper.PLAYERS,
DBHelper.TURN, DBHelper.GIFLAGS,
DBHelper.TURN, DBHelper.TURN_LOCAL, DBHelper.GIFLAGS,
DBHelper.CONTYPE, DBHelper.SERVERROLE,
DBHelper.ROOMNAME, DBHelper.RELAYID,
/*DBHelper.SMSPHONE,*/ DBHelper.SEED,
@ -159,6 +159,8 @@ public class DBUtils {
summary.turn =
cursor.getInt(cursor.
getColumnIndex(DBHelper.TURN));
summary.turnIsLocal = 0 != cursor.getInt(cursor.
getColumnIndex(DBHelper.TURN_LOCAL));
summary.
setGiFlags( cursor.getInt(cursor.
getColumnIndex(DBHelper.GIFLAGS))
@ -269,6 +271,7 @@ public class DBUtils {
values.put( DBHelper.NUM_PLAYERS, summary.nPlayers );
values.put( DBHelper.MISSINGPLYRS, summary.missingPlayers );
values.put( DBHelper.TURN, summary.turn );
values.put( DBHelper.TURN_LOCAL, summary.turnIsLocal? 1 : 0 );
values.put( DBHelper.GIFLAGS, summary.giflags() );
values.put( DBHelper.PLAYERS,
summary.summarizePlayers() );

View file

@ -50,9 +50,10 @@ public class GameSummary {
public static final int MSG_FLAGS_GAMEOVER = 4;
public static final int MSG_FLAGS_ALL = 7;
public int lastMoveTime;
public int lastMoveTime; // set by jni's server.c on move receipt
public int nMoves;
public int turn;
public boolean turnIsLocal;
public int nPlayers;
public int missingPlayers;
public int[] scores;