mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-29 08:34:37 +01:00
add lastMoveTime to summary table (gtk version)
This commit is contained in:
parent
dd779597d8
commit
53e40be2e3
3 changed files with 13 additions and 6 deletions
|
@ -52,6 +52,7 @@ openGamesDB( const char* dbName )
|
|||
",gameid INT"
|
||||
",ntotal INT(2)"
|
||||
",nmissing INT(2)"
|
||||
",lastMoveTime INT"
|
||||
")";
|
||||
result = sqlite3_exec( pDb, createGamesStr, NULL, NULL, NULL );
|
||||
|
||||
|
@ -159,6 +160,7 @@ summarize( CommonGlobals* cGlobals )
|
|||
XP_S16 nMoves = model_getNMoves( cGlobals->game.model );
|
||||
XP_Bool gameOver = server_getGameIsOver( cGlobals->game.server );
|
||||
XP_S16 turn = server_getCurrentTurn( cGlobals->game.server );
|
||||
XP_U32 lastMoveTime = server_getLastMoveTime( cGlobals->game.server );
|
||||
XP_U16 seed = 0;
|
||||
XP_S16 nMissing = 0;
|
||||
XP_U16 nTotal = cGlobals->gi->nPlayers;
|
||||
|
@ -203,11 +205,12 @@ summarize( CommonGlobals* cGlobals )
|
|||
}
|
||||
|
||||
const char* fmt = "UPDATE games "
|
||||
" SET room='%s', ended=%d, turn=%d, ntotal=%d, nmissing=%d, nmoves=%d, seed=%d, gameid=%d, connvia='%s'"
|
||||
" SET room='%s', ended=%d, turn=%d, ntotal=%d, nmissing=%d, nmoves=%d, seed=%d, "
|
||||
" gameid=%d, connvia='%s', lastMoveTime=%d"
|
||||
" WHERE rowid=%lld";
|
||||
XP_UCHAR buf[256];
|
||||
snprintf( buf, sizeof(buf), fmt, room, gameOver?1:0, turn, nTotal, nMissing,
|
||||
nMoves, seed, gameID, connvia, cGlobals->selRow );
|
||||
nMoves, seed, gameID, connvia, lastMoveTime, cGlobals->selRow );
|
||||
XP_LOGF( "query: %s", buf );
|
||||
sqlite3_stmt* stmt = NULL;
|
||||
int result = sqlite3_prepare_v2( cGlobals->pDb, buf, -1, &stmt, NULL );
|
||||
|
@ -259,7 +262,7 @@ getGameInfo( sqlite3* pDb, sqlite3_int64 rowid, GameInfo* gib )
|
|||
{
|
||||
XP_Bool success = XP_FALSE;
|
||||
const char* fmt = "SELECT room, ended, turn, nmoves, ntotal, nmissing, "
|
||||
"seed, connvia, gameid "
|
||||
"seed, connvia, gameid, lastMoveTime "
|
||||
"FROM games WHERE rowid = %lld";
|
||||
XP_UCHAR query[256];
|
||||
snprintf( query, sizeof(query), fmt, rowid );
|
||||
|
@ -279,6 +282,7 @@ getGameInfo( sqlite3* pDb, sqlite3_int64 rowid, GameInfo* gib )
|
|||
gib->seed = sqlite3_column_int( ppStmt, 6 );
|
||||
getColumnText( ppStmt, 7, gib->conn, sizeof(gib->conn) );
|
||||
gib->gameID = sqlite3_column_int( ppStmt, 8 );
|
||||
gib->lastMoveTime = sqlite3_column_int( ppStmt, 9 );
|
||||
snprintf( gib->name, sizeof(gib->name), "Game %lld", rowid );
|
||||
}
|
||||
sqlite3_finalize( ppStmt );
|
||||
|
|
|
@ -38,9 +38,9 @@ typedef struct _GameInfo {
|
|||
XP_U16 nTotal;
|
||||
XP_S16 nMissing;
|
||||
XP_U16 seed;
|
||||
XP_U32 lastMoveTime;
|
||||
} GameInfo;
|
||||
|
||||
|
||||
sqlite3* openGamesDB( const char* dbName );
|
||||
void closeGamesDB( sqlite3* dbp );
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ findOpenGame( const GtkAppGlobals* apg, sqlite3_int64 rowid )
|
|||
}
|
||||
|
||||
enum { ROW_ITEM, NAME_ITEM, ROOM_ITEM, GAMEID_ITEM, SEED_ITEM, CONN_ITEM, OVER_ITEM, TURN_ITEM,
|
||||
NMOVES_ITEM, NTOTAL_ITEM, MISSING_ITEM, N_ITEMS };
|
||||
NMOVES_ITEM, NTOTAL_ITEM, MISSING_ITEM, LASTTURN_ITEM, N_ITEMS };
|
||||
|
||||
static void
|
||||
foreachProc( GtkTreeModel* model, GtkTreePath* XP_UNUSED(path),
|
||||
|
@ -159,6 +159,7 @@ init_games_list( GtkAppGlobals* apg )
|
|||
addTextColumn( list, "NMoves", NMOVES_ITEM );
|
||||
addTextColumn( list, "NTotal", NTOTAL_ITEM );
|
||||
addTextColumn( list, "NMissing", MISSING_ITEM );
|
||||
addTextColumn( list, "LastTurn", LASTTURN_ITEM );
|
||||
|
||||
GtkListStore* store = gtk_list_store_new( N_ITEMS,
|
||||
G_TYPE_INT64, /* ROW_ITEM */
|
||||
|
@ -171,7 +172,8 @@ init_games_list( GtkAppGlobals* apg )
|
|||
G_TYPE_INT, /* TURN_ITEM */
|
||||
G_TYPE_INT, /* NMOVES_ITEM */
|
||||
G_TYPE_INT, /* NTOTAL_ITEM */
|
||||
G_TYPE_INT /* MISSING_ITEM */
|
||||
G_TYPE_INT, /* MISSING_ITEM */
|
||||
G_TYPE_INT /* LASTTURN_ITEM */
|
||||
);
|
||||
gtk_tree_view_set_model( GTK_TREE_VIEW(list), GTK_TREE_MODEL(store) );
|
||||
g_object_unref( store );
|
||||
|
@ -220,6 +222,7 @@ add_to_list( GtkWidget* list, sqlite3_int64 rowid, XP_Bool isNew,
|
|||
NMOVES_ITEM, gib->nMoves,
|
||||
NTOTAL_ITEM, gib->nTotal,
|
||||
MISSING_ITEM, gib->nMissing,
|
||||
LASTTURN_ITEM, gib->lastMoveTime,
|
||||
-1 );
|
||||
XP_LOGF( "DONE adding" );
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue