diff options
author | Arun Persaud <arun@nubati.net> | 2007-10-31 10:45:28 +0100 |
---|---|---|
committer | Arun Persaud <arun@nubati.net> | 2007-10-31 10:45:28 +0100 |
commit | 981af305085c3f31cc80ec5c22c79ebc3a3aec95 (patch) | |
tree | e21f65bdf1f4a0bcaf8652506cf3e0877966163f | |
parent | 01e982e40cc5679cdb4647aec7c37d3d789eeb4b (diff) | |
download | e-DoKo-981af305085c3f31cc80ec5c22c79ebc3a3aec95.tar.gz e-DoKo-981af305085c3f31cc80ec5c22c79ebc3a3aec95.tar.bz2 e-DoKo-981af305085c3f31cc80ec5c22c79ebc3a3aec95.zip |
BUGFIX: no check for a followup game if someone else already started one
several people could start a followup game (or one person hitting reload) and several games were started. Now the prog checks if there is already an active game.
-rw-r--r-- | db.php | 12 | ||||
-rw-r--r-- | index.php | 17 |
2 files changed, 29 insertions, 0 deletions
@@ -939,5 +939,17 @@ function DB_set_reminder($user,$gameid) return 0; } +function DB_is_session_active($session) +{ + $queryresult = mysql_query("SELECT COUNT(*) FROM Game ". + " WHERE session=$session ". + " AND status<>'gameover' "); + + $r = mysql_fetch_array($queryresult,MYSQL_NUM); + if($r) + return $r[0]; + else + return -1; +} ?>
\ No newline at end of file @@ -85,6 +85,23 @@ else if(myisset("new")) $session = DB_get_session_by_gameid($followup); $ruleset = DB_get_ruleset_by_gameid($followup); /* just copy ruleset from old game, this way no manipulation is possible */ + + /* check if there is a game in pre or play mode, in that case do nothing */ + if( DB_is_session_active($session) > 0 ) + { + echo "<p class=\"message\"> There is already a game going on in session $session, you can't start a new one</p>"; + output_footer(); + DB_close(); + exit(); + } + else if ( DB_is_session_active($session) < 0 ) + { + echo "<p class=\"message\"> ERROR: status of session $session couldn't be determined.</p>"; + output_footer(); + DB_close(); + exit(); + } + if($session) mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', 'normal', NULL,NULL,'1',NULL,'pre',". "'$ruleset','$session' ,NULL)"); |