Index: common/Player.cpp
===================================================================
--- common/Player.cpp	(revision 45b2750be478f0b876f68707f4c72976433a90f5)
+++ common/Player.cpp	(revision 23559e775f9b0a88ba79a1fe4a2b9944b6efb009)
@@ -89,10 +89,11 @@
 
 bool Player::move(WorldMap *map) {
-   int speed = 100; // pixels per second
+   int speed = 100; // pixels per second. should probably be in the constructor
    unsigned long long curTime = getCurrentMillis();
-   bool moveCanceled = false;
 
    // if we're at our target, don't move
-   if (pos.x != target.x || pos.y != target.y) {
+   bool moving = (pos.x != target.x || pos.y != target.y);
+
+   if (moving) {
       float pixels = speed * (curTime-timeLastUpdated) / 1000.0;
       double angle = atan2(target.y-pos.y, target.x-pos.x);
@@ -107,35 +108,8 @@
          newPos.y = pos.y + sin(angle)*pixels;
       }
-
-      switch(map->getElement(newPos.x/25, newPos.y/25)) {
-      case WorldMap::TERRAIN_NONE:
-      case WorldMap::TERRAIN_OCEAN:
-      case WorldMap::TERRAIN_ROCK:
-         target.x = pos.x;
-         target.y = pos.y;
-         moveCanceled = true;
-         break;
-      default: // if there are no obstacles
-         pos.x = newPos.x;
-         pos.y = newPos.y;
-         break;
-      }
-
-      // using moveCanceled in a hacky way just to indicate that the server
-      // has updated some player info. Should change the variable name
-      switch(map->getStructure(newPos.x/25, newPos.y/25)) {
-      case WorldMap::STRUCTURE_BLUE_FLAG:
-         hasBlueFlag = true;
-         moveCanceled = true;
-         break;
-      case WorldMap::STRUCTURE_RED_FLAG:
-         hasRedFlag = true;
-         moveCanceled = true;
-         break;
-      }
    }
 
    timeLastUpdated = curTime;
 
-   return !moveCanceled;
+   return moving;
 }
Index: server/server.cpp
===================================================================
--- server/server.cpp	(revision 45b2750be478f0b876f68707f4c72976433a90f5)
+++ server/server.cpp	(revision 23559e775f9b0a88ba79a1fe4a2b9944b6efb009)
@@ -139,23 +139,50 @@
 
          // maybe put this in a separate method
-         map<unsigned int, Player>::iterator it, it2;
+         map<unsigned int, Player>::iterator it;
+         FLOAT_POSITION oldPos;
+         bool broadcastMove = false;
          for (it = mapPlayers.begin(); it != mapPlayers.end(); it++) {
-            if (!it->second.move(gameMap)) {
-               cout << "Cenceling move" << endl;
-               serverMsg.type = MSG_TYPE_PLAYER;
-               it->second.serialize(serverMsg.buffer);
-
-               cout << "(" << it->second.pos.x << "," << it->second.pos.y << ")" << endl;
-
-               if (it->second.hasBlueFlag)
-                  cout << "Got blue flag" << endl;
-               if (it->second.hasRedFlag)
-                  cout << "Got red flag" << endl;
-
-               cout << "about to send move cencellation" << endl;
-               for (it2 = mapPlayers.begin(); it2 != mapPlayers.end(); it2++)
-               {
-                  if ( sendMessage(&serverMsg, sock, &(it2->second.addr)) < 0 )
-                     error("sendMessage");
+            oldPos = it->second.pos;
+            if (it->second.move(gameMap)) {
+
+               // check if the move needs to be canceled
+               switch(gameMap->getElement(it->second.pos.x/25, it->second.pos.y/25)) {
+                  case WorldMap::TERRAIN_NONE:
+                  case WorldMap::TERRAIN_OCEAN:
+                  case WorldMap::TERRAIN_ROCK:
+                     it->second.pos = oldPos;
+                     it->second.target.x = it->second.pos.x;
+                     it->second.target.y = it->second.pos.y;
+                     broadcastMove = true;
+                     break;
+                  default:
+                     // if there are no obstacles, do nothing
+                     break;
+               }
+
+               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;
+               }
+
+               if (broadcastMove) {
+                  serverMsg.type = MSG_TYPE_PLAYER;
+                  it->second.serialize(serverMsg.buffer);
+
+                  cout << "about to broadcast move" << endl;
+                  map<unsigned int, Player>::iterator it, it2;
+                  for (it2 = mapPlayers.begin(); it2 != mapPlayers.end(); it2++)
+                  {
+                     if ( sendMessage(&serverMsg, sock, &(it2->second.addr)) < 0 )
+                        error("sendMessage");
+                  }
                }
             }
