Skip to content

Commit

Permalink
Don't store repeated games
Browse files Browse the repository at this point in the history
git-svn-id: https://ai-contest.googlecode.com/svn/trunk@644 9d0e4ec5-6d14-e29b-3149-cabf4038ef1e
  • Loading branch information
Janzert committed Nov 30, 2010
1 parent 6b173fb commit 5ea274c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions planet_wars/www/api_record_game.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@

$gamedata = json_decode(file_get_contents('php://input'));

$sql = "SELECT count(1) FROM games
WHERE player_one = ".$gamedata->player_one."
AND player_two = ".$gamedata->player_two."
AND map_id = ".$gamedata->map_id;
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
if ($row['count(1)'] != 0) {
die("Appears this pairing and map are already in the database");
}

$sql = "INSERT INTO games (winner,loser,map_id,draw,timestamp,".
"player_one,player_two,worker)
VALUES (".
Expand Down

0 comments on commit 5ea274c

Please sign in to comment.