Index: server/server.cpp
===================================================================
--- server/server.cpp	(revision 11d21ee11d4c61808a4280cdafbf7778a7af72c9)
+++ server/server.cpp	(revision ff2133aee0f65c9b2661b1823a42193172c15167)
@@ -149,6 +149,8 @@
          // set targets for all chasing players (or make them attack if they're close enough)
          for (it = mapPlayers.begin(); it != mapPlayers.end(); it++) {
-            Player* p = &it->second;
-
+            //Player* p = &it->second;
+            it->second.updateTarget(mapPlayers);
+
+            /*
             if (p->isChasing) {
                p->target.x = mapPlayers[p->targetPlayer].pos.x;
@@ -164,4 +166,5 @@
                }
             }
+            */
          }
 
@@ -171,4 +174,5 @@
          bool broadcastMove = false;
          for (it = mapPlayers.begin(); it != mapPlayers.end(); it++) {
+            cout << "Starting new for loop iteration" << endl;
             oldPos = it->second.pos;
             if (it->second.move(gameMap)) {
@@ -362,4 +366,6 @@
 
                if (it->second.attackType == Player::ATTACK_MELEE) {
+                  cout << "Melee attack" << endl;
+
                   Player* target = &mapPlayers[it->second.targetPlayer];
 
@@ -371,4 +377,6 @@
                   target->serialize(serverMsg.buffer);
                }else if (it->second.attackType == Player::ATTACK_RANGED) {
+                  cout << "Ranged attack" << endl;
+
                   Projectile proj(it->second.pos.x, it->second.pos.y, it->second.targetPlayer, it->second.damage);
                   proj.id = unusedProjectileId;
@@ -389,4 +397,29 @@
 
                // broadcast either a PLAYER or PROJECTILE message
+               cout << "Broadcasting player or projectile message" << endl;
+               for (it2 = mapPlayers.begin(); it2 != mapPlayers.end(); it2++)
+               {
+                  if (sendMessage(&serverMsg, sock, &(it2->second.addr)) < 0 )
+                     error("sendMessage");
+               }
+               cout << "Done broadcasting" << endl;
+            }
+         }
+
+         cout << "Done with the for loop" << endl;
+
+         // move all projectiles
+         cout << "Moving projectiles" << endl;
+         map<unsigned int, Projectile>::iterator itProj;
+         for (itProj = mapProjectiles.begin(); itProj != mapProjectiles.end(); itProj++) {
+            if (itProj->second.move(mapPlayers)) {
+               // send a REMOVE_PROJECTILE message
+               cout << "send a REMOVE_PROJECTILE message" << endl;
+               serverMsg.type = MSG_TYPE_REMOVE_PROJECTILE;
+               memcpy(serverMsg.buffer, &itProj->second.id, 4);
+               mapProjectiles.erase(itProj->second.id);
+
+               map<unsigned int, Player>::iterator it2;
+               cout << "Broadcasting REMOVE_PROJECTILE" << endl;
                for (it2 = mapPlayers.begin(); it2 != mapPlayers.end(); it2++)
                {
@@ -394,17 +427,17 @@
                      error("sendMessage");
                }
-            }
-         }
-
-         // move all projectiles
-         map<unsigned int, Projectile>::iterator itProj;
-         for (itProj = mapProjectiles.begin(); itProj != mapProjectiles.end(); itProj++) {
-            if (itProj->second.move(mapPlayers)) {
-               // send a REMOVE_PROJECTILE message
-               serverMsg.type = MSG_TYPE_REMOVE_PROJECTILE;
-               memcpy(serverMsg.buffer, &itProj->second.id, 4);
-               mapProjectiles.erase(itProj->second.id);
-
-               map<unsigned int, Player>::iterator it2;
+
+               cout << "send a PLAYER message after dealing damage" << endl;
+               // send a PLAYER message after dealing damage
+               Player* target = &mapPlayers[itProj->second.target];
+
+               target->health -= itProj->second.damage;
+               if (target->health < 0)
+                  target->health = 0;
+
+               serverMsg.type = MSG_TYPE_PLAYER;
+               target->serialize(serverMsg.buffer);
+
+               cout << "Sending a PLAYER message" << endl;
                for (it2 = mapPlayers.begin(); it2 != mapPlayers.end(); it2++)
                {
@@ -412,23 +445,8 @@
                      error("sendMessage");
                }
-
-               // send a PLAYER message after dealing damage
-               Player* target = &mapPlayers[itProj->second.target];
-
-               target->health -= itProj->second.damage;
-               if (target->health < 0)
-                  target->health = 0;
-
-               serverMsg.type = MSG_TYPE_PLAYER;
-               target->serialize(serverMsg.buffer);
-
-               for (it2 = mapPlayers.begin(); it2 != mapPlayers.end(); it2++)
-               {
-                  if ( sendMessage(&serverMsg, sock, &(it2->second.addr)) < 0 )
-                     error("sendMessage");
-               }
-            }
-         }
-      }
+            }
+         }
+      }
+      cout << "Done moving projectiles" << endl;
 
       n = receiveMessage(&clientMsg, sock, &from);
