Index: common/Common.cpp
===================================================================
--- common/Common.cpp	(revision b81cea1525249587daadca75386913a591187256)
+++ common/Common.cpp	(revision b07eeac0258a8440bdd8dfc2331130f1c005ba4b)
@@ -2,5 +2,5 @@
 
 #include <iostream>
-using namespace std;
+#include <cmath>
 
 #if defined WINDOWS
@@ -9,4 +9,16 @@
    #include <time.h>
 #endif
+
+using namespace std;
+
+/*
+FLOAT_POSITION POSITION::toFloat() {
+   FLOAT_POSITION floatPosition;
+   floatPosition.x = x;
+   floatPosition.y = y;
+
+   return floatPosition;
+}
+*/
 
 void set_nonblock(int sock)
@@ -38,2 +50,9 @@
    return numMilliseconds;
 }
+
+float posDistance(FLOAT_POSITION pos1, FLOAT_POSITION pos2) {
+   float xDiff = pos2.x - pos1.x;
+   float yDiff = pos2.y - pos1.y;
+
+   return sqrt( pow(xDiff,2) + pow(yDiff,2) );   
+}
Index: common/Common.h
===================================================================
--- common/Common.h	(revision b81cea1525249587daadca75386913a591187256)
+++ common/Common.h	(revision b07eeac0258a8440bdd8dfc2331130f1c005ba4b)
@@ -12,13 +12,4 @@
 #endif
 
-void set_nonblock(int sock);
-unsigned long long getCurrentMillis();
-
-typedef struct
-{
-   int x;
-   int y;
-} POSITION;
-
 typedef struct
 {
@@ -27,3 +18,21 @@
 } FLOAT_POSITION;
 
+typedef struct
+{
+   int x;
+   int y;
+   //FLOAT_POSITION toFloat();
+   FLOAT_POSITION toFloat() {
+      FLOAT_POSITION floatPosition;
+      floatPosition.x = x;
+      floatPosition.y = y;
+
+      return floatPosition;
+   }
+} POSITION;
+
+void set_nonblock(int sock);
+unsigned long long getCurrentMillis();
+float posDistance(FLOAT_POSITION pos1, FLOAT_POSITION pos2);
+
 #endif
Index: common/Message.cpp
===================================================================
--- common/Message.cpp	(revision b81cea1525249587daadca75386913a591187256)
+++ common/Message.cpp	(revision b07eeac0258a8440bdd8dfc2331130f1c005ba4b)
@@ -19,4 +19,6 @@
    int ret =  sendto(sock, (char*)msg, sizeof(NETWORK_MSG), 0, (struct sockaddr *)dest, sizeof(struct sockaddr_in));
 
+   cout << "Send a message of type " << msg->type << endl;
+
    return ret;
 }
Index: server/server.cpp
===================================================================
--- server/server.cpp	(revision b81cea1525249587daadca75386913a591187256)
+++ server/server.cpp	(revision b07eeac0258a8440bdd8dfc2331130f1c005ba4b)
@@ -161,15 +161,34 @@
                }
 
-               switch(gameMap->getStructure(it->second.pos.x/25, it->second.pos.y/25)) {
-                  case WorldMap::STRUCTURE_BLUE_FLAG:
-                     cout << "Got blue flag" << endl;
-                     it->second.hasBlueFlag = true;
-                     broadcastMove = true;
-                     break;
-                  case WorldMap::STRUCTURE_RED_FLAG:
-                     cout << "Got red flag" << endl;
-                     it->second.hasRedFlag = true;
-                     broadcastMove = true;
-                     break;
+               vector<WorldMap::Object> vctObjects = gameMap->getObjects();
+               vector<WorldMap::Object>::iterator itObjects;
+
+               for (itObjects = vctObjects.begin(); itObjects != vctObjects.end(); itObjects++) {
+                  POSITION pos = itObjects->pos;
+                  if (posDistance(it->second.pos, pos.toFloat()) < 10) {
+                     switch (itObjects->type) {
+                        case WorldMap::OBJECT_BLUE_FLAG:
+                           cout << "Got blue flag" << endl;
+                           it->second.hasBlueFlag = true;
+                           broadcastMove = true;
+                           break;
+                        case WorldMap::OBJECT_RED_FLAG:
+                           cout << "Got red flag" << endl;
+                           it->second.hasRedFlag = true;
+                           broadcastMove = true;
+                           break;
+                     }
+
+                     // send a MSG_TYPE_REMOVE_OBJECT message
+                     serverMsg.type = MSG_TYPE_REMOVE_OBJECT;
+                     memcpy(serverMsg.buffer, &itObjects->id, 4);
+
+                     map<unsigned int, Player>::iterator it2;
+                     for (it2 = mapPlayers.begin(); it2 != mapPlayers.end(); it2++)
+                     {
+                        if ( sendMessage(&serverMsg, sock, &(it2->second.addr)) < 0 )
+                           error("sendMessage");
+                     }
+                  }
                }
 
@@ -179,5 +198,5 @@
 
                   cout << "about to broadcast move" << endl;
-                  map<unsigned int, Player>::iterator it, it2;
+                  map<unsigned int, Player>::iterator it2;
                   for (it2 = mapPlayers.begin(); it2 != mapPlayers.end(); it2++)
                   {
@@ -415,6 +434,4 @@
                mapPlayers[id].target.x = x;
                mapPlayers[id].target.y = y;
-               int xDiff = mapPlayers[id].target.x - mapPlayers[id].pos.x;
-               int yDiff = mapPlayers[id].target.y - mapPlayers[id].pos.y;
 
                serverMsg.type = MSG_TYPE_PLAYER_MOVE;
