Index: server/server.cpp
===================================================================
--- server/server.cpp	(revision ad1e2fc65ad7e34d9baa1e487d246857faafd96a)
+++ server/server.cpp	(revision e5b96e258150b95d4dd4b691e0d5fc4074bef926)
@@ -230,9 +230,11 @@
          Game* game = NULL;
          WorldMap* gameMap = NULL;
-
-         for (itGames = mapGames.begin(); itGames != mapGames.end(); itGames++) { 
+         bool gameFinished;
+
+         for (itGames = mapGames.begin(); itGames != mapGames.end();) { 
             game = itGames->second;
             gameMap = game->getMap();
             map<unsigned int, Player*>& playersInGame = game->getPlayers();
+            gameFinished = false;
 
             for (it = game->getPlayers().begin(); it != game->getPlayers().end(); it++)
@@ -363,7 +365,8 @@
                      }
 
-                     /*
+                     // check to see if the game should end
+                     // move to its own method
                      if (scoreBlue == 3 || scoreRed == 3) {
-                        gameOver = true;
+                        gameFinished = true;
 
                         unsigned int winningTeam;
@@ -377,15 +380,4 @@
                         memcpy(serverMsg.buffer+4, &scoreBlue, 4);
                         memcpy(serverMsg.buffer+8, &scoreRed, 4);
-
-                        for (it2 = playersInGame.begin(); it2 != playersInGame.end(); it2++)
-                        {
-                           if ( msgProcessor.sendMessage(&serverMsg, sock, &(it2->second->addr), &outputLog) < 0 )
-                              error("sendMessage");
-                        }
-
-                        // send a GAME_INFO message with 0 players to force clients to delete the game
-                        int numPlayers = 0;
-                        serverMsg.type = MSG_TYPE_GAME_INFO;
-                        memcpy(serverMsg.buffer, &numPlayers, 4);
 
                         for (it2 = playersInGame.begin(); it2 != playersInGame.end(); it2++)
@@ -395,5 +387,4 @@
                         }
                      }
-                     */
 
                      // this means a PLAYER message will be sent
@@ -539,4 +530,22 @@
                }
             }
+
+            if (gameFinished) {
+                // send a GAME_INFO message with 0 players to force clients to delete the game
+               int numPlayers = 0;
+               serverMsg.type = MSG_TYPE_GAME_INFO;
+               memcpy(serverMsg.buffer, &numPlayers, 4);
+
+               map<unsigned int, Player*>::iterator it2;
+               for (it2 = mapPLayers.begin(); it2 != mapPLayers.end(); it2++)
+               {
+                  if ( msgProcessor.sendMessage(&serverMsg, sock, &(it2->second->addr), &outputLog) < 0 )
+                     error("sendMessage");
+               }
+
+               // erase game from server
+               mapGames.erase(itGames);
+            }else
+               itGames++;
          }
 
