Index: common/Game.cpp
===================================================================
--- common/Game.cpp	(revision 6c9bcdd776598f0b4c9d61b1db2b6abf28453d86)
+++ common/Game.cpp	(revision ce2bb8713e893a7b12416d609f4f11969ca936f3)
@@ -1,3 +1,5 @@
 #include "Game.h"
+
+#include "Common.h"
 
 using namespace std;
@@ -112,4 +114,37 @@
 }
 
+// returns the id of the picked-up flag or -1 if none was picked up
+int Game::processFlagPickupRequest(Player* p) {
+   vector<WorldMap::Object>* vctObjects = this->worldMap->getObjects();
+   vector<WorldMap::Object>::iterator it;
+   int playerId = -1;
+
+   for (it = vctObjects->begin(); it != vctObjects->end(); it++) {
+      if (posDistance(p->pos, it->pos.toFloat()) < 10) {
+         switch (it->type) {
+            case WorldMap::OBJECT_BLUE_FLAG:
+               if (p->team == 1) {
+                  p->hasBlueFlag = true;
+                  playerId = it->id;
+               }
+               break;
+            case WorldMap::OBJECT_RED_FLAG:
+               if (p->team == 0) {
+                  p->hasRedFlag = true;
+                  playerId = it->id;
+               }
+               break;
+         }
+
+         if (playerId > -1) {
+            vctObjects->erase(it);
+            return playerId;
+         }
+      }
+   }
+
+   return playerId;
+}
+
 void Game::setRedScore(int score) {
    this->redScore = score;
Index: common/Game.h
===================================================================
--- common/Game.h	(revision 6c9bcdd776598f0b4c9d61b1db2b6abf28453d86)
+++ common/Game.h	(revision ce2bb8713e893a7b12416d609f4f11969ca936f3)
@@ -43,4 +43,5 @@
    bool startPlayerMovement(unsigned int id, int x, int y);
    bool processPlayerMovement(Player* p, FLOAT_POSITION oldPos);
+   int processFlagPickupRequest(Player* p);
 
    void setBlueScore(int score);
Index: server/server.cpp
===================================================================
--- server/server.cpp	(revision 6c9bcdd776598f0b4c9d61b1db2b6abf28453d86)
+++ server/server.cpp	(revision ce2bb8713e893a7b12416d609f4f11969ca936f3)
@@ -153,4 +153,6 @@
 
          map<unsigned int, Player*>::iterator it;
+
+         cout << "Updating player targets and respawning dead players" << endl;
 
          // set targets for all chasing players (or make them attack if they're close enough)
@@ -216,8 +218,14 @@
          }
 
+         cout << "Processing players in a game" << endl;
+
          // process players currently in a game
          FLOAT_POSITION oldPos;
          for (it = mapPlayers.begin(); it != mapPlayers.end(); it++)
          {
+            if (it->second->currentGame == NULL)
+               continue;
+
+            cout << "moving player" << endl;
             bool broadcastMove = false;
 
@@ -226,6 +234,8 @@
             if (it->second->move(it->second->currentGame->getMap())) {
 
+               cout << "player moved" << endl;
                if (it->second->currentGame->processPlayerMovement(it->second, oldPos))
                    broadcastMove = true;
+               cout << "player move processed" << endl;
 
                /*
@@ -386,4 +396,5 @@
                if (broadcastMove)
                {
+                  cout << "broadcasting player move" << endl;
                   serverMsg.type = MSG_TYPE_PLAYER;
                   it->second->serialize(serverMsg.buffer);
@@ -394,11 +405,14 @@
                   map<unsigned int, Player*> playersInGame = it->second->currentGame->getPlayers();
                   map<unsigned int, Player*>::iterator it2;
-                  for (it2 = playersInGame.begin(); it2 != playersInGamePlayers.end(); it2++)
+                  for (it2 = playersInGame.begin(); it2 != playersInGame.end(); it2++)
                   {
                      if ( msgProcessor.sendMessage(&serverMsg, sock, &(it2->second->addr), &outputLog) < 0 )
                         error("sendMessage");
                   }
-               }
-            }
+                  cout << "done broadcasting player move" << endl;
+               }
+            }
+
+            cout << "processing player attack" << endl;
 
             // check if the player's attack animation is complete
@@ -476,4 +490,6 @@
             }
          }
+
+         cout << "Processing projectiles"  << endl;
 
          // move all projectiles
@@ -540,4 +556,5 @@
             cout << "Should be broadcasting the message" << endl;
 
+            // needs to be updated to use the players from the game
             map<unsigned int, Player*>::iterator it;
             for (it = mapPlayers.begin(); it != mapPlayers.end(); it++)
@@ -555,4 +572,6 @@
                error("sendMessage");
          }
+
+         cout << "Finished processing the message" << endl;
       }
    }
@@ -651,4 +670,5 @@
             cout << "new player id: " << p->id << endl;
             p->setAddr(from);
+            p->currentGame = NULL;
 
             // choose a random team (either 0 or 1)
@@ -835,52 +855,21 @@
 
          Player* p = mapPlayers[id];
-
-         vector<WorldMap::Object>* vctObjects = gameMap->getObjects();
-         vector<WorldMap::Object>::iterator itObjects;
-
-         for (itObjects = vctObjects->begin(); itObjects != vctObjects->end();) {
-            POSITION pos = itObjects->pos;
-            bool gotFlag = false;
-
-            if (posDistance(p->pos, pos.toFloat()) < 10) {
-               switch (itObjects->type) {
-                  case WorldMap::OBJECT_BLUE_FLAG:
-                     if (p->team == 1) {
-                        gotFlag = true;
-                        p->hasBlueFlag = true;
-                        broadcastResponse = true;
-                     }
-                     break;
-                  case WorldMap::OBJECT_RED_FLAG:
-                     if (p->team == 0) {
-                        gotFlag = true;
-                        p->hasRedFlag = true;
-                        broadcastResponse = true;
-                     }
-                     break;
-               }
-
-               if (gotFlag) {
-                  serverMsg.type = MSG_TYPE_REMOVE_OBJECT;
-                  memcpy(serverMsg.buffer, &itObjects->id, 4);
-
-                  map<unsigned int, Player*>::iterator it;
-                  for (it = mapPlayers.begin(); it != mapPlayers.end(); it++)
-                  {
-                     if ( msgProcessor.sendMessage(&serverMsg, sock, &(it->second->addr), &outputLog) < 0 )
-                        error("sendMessage");
-                  }
-
-                  // remove the object from the server-side map
-                  cout << "size before: " << gameMap->getObjects()->size() << endl;
-                  itObjects = vctObjects->erase(itObjects);
-                  cout << "size after: " << gameMap->getObjects()->size() << endl;
-               }
-            }
-
-            if (!gotFlag)
-               itObjects++;
-         }
-
+         int objectId = p->currentGame->processFlagPickupRequest(p);
+
+         if (objectId >= 0) {
+            serverMsg.type = MSG_TYPE_REMOVE_OBJECT;
+            memcpy(serverMsg.buffer, &objectId, 4);
+
+            map<unsigned int, Player*> players = p->currentGame->getPlayers();
+            map<unsigned int, Player*>::iterator it;
+            for (it = players.begin(); it != players.end(); it++)
+            {
+               if ( msgProcessor.sendMessage(&serverMsg, sock, &(it->second->addr), &outputLog) < 0 )
+                  error("sendMessage");
+            }
+
+         }
+
+         // if there was no flag to pickup, we really don't need to send a message
          serverMsg.type = MSG_TYPE_PLAYER;
          p->serialize(serverMsg.buffer);
