mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-27 07:58:49 +01:00
add GameFull -- database, not in-memory state, knows if game is full.
This commit is contained in:
parent
14579c6e30
commit
feca7345dc
2 changed files with 18 additions and 0 deletions
|
@ -173,6 +173,23 @@ DBMgr::FindOpen( const char* cookie, int lang, int nPlayersT, int nPlayersH,
|
|||
return cid;
|
||||
} /* FindOpen */
|
||||
|
||||
bool
|
||||
DBMgr::GameFull( const char* const connName )
|
||||
{
|
||||
const char* cmd = "SELECT ntotal=sum_array(nperdevice) from " GAMES_TABLE
|
||||
" WHERE connName='%s'";
|
||||
char query[256];
|
||||
snprintf( query, sizeof(query), cmd, connName );
|
||||
logf( XW_LOGINFO, "query: %s", query );
|
||||
|
||||
PGresult* result = PQexec( getThreadConn(), query );
|
||||
int nTuples = PQntuples( result );
|
||||
assert( nTuples <= 1 );
|
||||
bool full = 't' == PQgetvalue( result, 0, 0 )[0];
|
||||
PQclear( result );
|
||||
return full;
|
||||
}
|
||||
|
||||
HostID
|
||||
DBMgr::AddDevice( const char* connName, HostID curID, int nToAdd,
|
||||
unsigned short seed )
|
||||
|
|
|
@ -46,6 +46,7 @@ class DBMgr {
|
|||
CookieID FindOpen( const char* cookie, int lang, int nPlayersT,
|
||||
int nPlayersH, bool wantsPublic,
|
||||
char* connNameBuf, int bufLen, int* nPlayersHP );
|
||||
bool GameFull( const char* const connName );
|
||||
|
||||
HostID AddDevice( const char* const connName, HostID curID,
|
||||
int nToAdd, unsigned short seed );
|
||||
|
|
Loading…
Add table
Reference in a new issue