Index: client/Client/GameRender.cpp
===================================================================
--- client/Client/GameRender.cpp	(revision 949cf702c364fd81f5261f60f7f4b14f92d65c87)
+++ client/Client/GameRender.cpp	(revision 5b923076767a61d7f5790a8c4bfca4fa002edcb4)
@@ -74,5 +74,5 @@
       pos = mapToScreen(p->pos.toInt());
 
-      if (p->id == curPlayerId)
+      if (p->getId() == curPlayerId)
          al_draw_filled_circle(pos.x, pos.y, 14, al_map_rgb(0, 0, 0));
       
Index: client/Client/main.cpp
===================================================================
--- client/Client/main.cpp	(revision 949cf702c364fd81f5261f60f7f4b14f92d65c87)
+++ client/Client/main.cpp	(revision 5b923076767a61d7f5790a8c4bfca4fa002edcb4)
@@ -432,11 +432,13 @@
                   target = it->second;
                   cout << "set target" << endl;
-                  if (target->id != curPlayerId && target->team != curPlayer->team)
+                  if (target->getId() != curPlayerId && target->team != curPlayer->team)
                   {
                      cout << "Found valid target" << endl;
 
+                     unsigned int targetId = target->getId();
+
                      msgTo.type = MSG_TYPE_ATTACK;
                      memcpy(msgTo.buffer, &curPlayerId, 4);
-                     memcpy(msgTo.buffer+4, &target->id, 4);
+                     memcpy(msgTo.buffer+4, &targetId, 4);
 
                      msgProcessor.sendMessage(&msgTo, &server);
@@ -678,8 +680,8 @@
                   p->deserialize(msg.buffer);
 
-                  if (mapPlayers.find(p->id) != mapPlayers.end())
-                     delete mapPlayers[p->id];
-                  mapPlayers[p->id] = p;
-                  curPlayerId = p->id;
+                  if (mapPlayers.find(p->getId()) != mapPlayers.end())
+                     delete mapPlayers[p->getId()];
+                  mapPlayers[p->getId()] = p;
+                  curPlayerId = p->getId();
 
                   cout << "Got a valid login response with the player" << endl;
@@ -732,8 +734,8 @@
                   p.isDead = false;
 
-               if (mapPlayers.find(p.id) != mapPlayers.end())
-                  *(mapPlayers[p.id]) = p;
+               if (mapPlayers.find(p.getId()) != mapPlayers.end())
+                  *(mapPlayers[p.getId()]) = p;
                else
-                  mapPlayers[p.id] = new Player(p);
+                  mapPlayers[p.getId()] = new Player(p);
 
                break;
@@ -771,5 +773,5 @@
 
                Player* source = mapPlayers[id];
-               source->targetPlayer = targetID;
+               source->setTargetPlayer(targetID);
                source->isChasing = true;
 
@@ -953,8 +955,8 @@
                   p.isDead = false;
 
-               if (mapPlayers.find(p.id) != mapPlayers.end())
-                  *(mapPlayers[p.id]) = p;
+               if (mapPlayers.find(p.getId()) != mapPlayers.end())
+                  *(mapPlayers[p.getId()]) = p;
                else
-                  mapPlayers[p.id] = new Player(p);
+                  mapPlayers[p.getId()] = new Player(p);
 
                break;
@@ -966,4 +968,5 @@
                Player p("", "");
                p.deserialize(msg.buffer);
+               cout << "Deserialized player" << endl;
                p.timeLastUpdated = getCurrentMillis();
                p.isChasing = false;
@@ -973,10 +976,10 @@
                   p.isDead = false;
 
-               if (mapPlayers.find(p.id) != mapPlayers.end())
-                  *(mapPlayers[p.id]) = p;
+               if (mapPlayers.find(p.getId()) != mapPlayers.end())
+                  *(mapPlayers[p.getId()]) = p;
                else
-                  mapPlayers[p.id] = new Player(p);
-
-               game->addPlayer(mapPlayers[p.id]);
+                  mapPlayers[p.getId()] = new Player(p);
+
+               game->addPlayer(mapPlayers[p.getId()]);
 
                break;
@@ -1051,5 +1054,5 @@
                // need to check the target exists in the current game
                Player* source = game->getPlayers()[id];
-               source->targetPlayer = targetId;
+               source->setTargetPlayer(targetId);
                source->isChasing = true;
 
Index: common/Game.cpp
===================================================================
--- common/Game.cpp	(revision 949cf702c364fd81f5261f60f7f4b14f92d65c87)
+++ common/Game.cpp	(revision 5b923076767a61d7f5790a8c4bfca4fa002edcb4)
@@ -43,6 +43,6 @@
 
 bool Game::addPlayer(Player* p) {
-   if (players.find(p->id) == players.end()) {
-      players[p->id] = p;
+   if (players.find(p->getId()) == players.end()) {
+      players[p->getId()] = p;
       return true;
    }
@@ -429,5 +429,5 @@
          cout << "Melee attack" << endl;
 
-         Player* target = players[p->targetPlayer];
+         Player* target = players[p->getTargetPlayer()];
          this->dealDamageToPlayer(target, p->damage);
       }
@@ -436,5 +436,5 @@
          cout << "Ranged attack" << endl;
 
-         Projectile proj(p->pos.x, p->pos.y, p->targetPlayer, p->damage);
+         Projectile proj(p->pos.x, p->pos.y, p->getTargetPlayer(), p->damage);
          this->assignProjectileId(&proj);
          this->addProjectile(proj);
@@ -442,4 +442,5 @@
          int x = p->pos.x;
          int y = p->pos.y;
+         unsigned int targetId = p->getTargetPlayer();
 
          serverMsg.type = MSG_TYPE_PROJECTILE;
@@ -447,5 +448,5 @@
          memcpy(serverMsg.buffer+4, &x, 4);
          memcpy(serverMsg.buffer+8, &y, 4);
-         memcpy(serverMsg.buffer+12, &p->targetPlayer, 4);
+         memcpy(serverMsg.buffer+12, &targetId, 4);
          msgProcessor->broadcastMessage(serverMsg, players);
       }
Index: common/Player.cpp
===================================================================
--- common/Player.cpp	(revision 949cf702c364fd81f5261f60f7f4b14f92d65c87)
+++ common/Player.cpp	(revision 5b923076767a61d7f5790a8c4bfca4fa002edcb4)
@@ -15,4 +15,5 @@
    this->pos.x = this->target.x = 0;
    this->pos.y = this->target.y = 0;
+   this->targetPlayer = 0;
    this->timeLastUpdated = 0;
    this->timeAttackStarted = 0;
@@ -46,4 +47,5 @@
    this->target.x = p.target.x;
    this->target.y = p.target.y;
+   this->targetPlayer = p.targetPlayer;
    this->timeLastUpdated = p.timeLastUpdated;
    this->timeAttackStarted = p.timeAttackStarted;
@@ -75,4 +77,5 @@
    this->pos.x = this->target.x = 200;
    this->pos.y = this->target.y = 200;
+   this->targetPlayer = 0;
    this->timeLastUpdated = 0;
    this->timeAttackStarted = 0;
@@ -100,7 +103,22 @@
 }
 
+unsigned int Player::getId()
+{
+   return this->id;
+}
+
+unsigned int Player::getTargetPlayer()
+{
+   return this->targetPlayer;
+}
+
 void Player::setId(unsigned int id)
 {
    this->id = id;
+}
+
+void Player::setTargetPlayer(unsigned int id)
+{
+   this->targetPlayer = id;
 }
 
@@ -217,8 +235,12 @@
 }
 
-bool Player::updateTarget(const Player* targetPlayer) {
-   if (this->isChasing) {
-      this->target.x = targetPlayer->pos.x;
-      this->target.y = targetPlayer->pos.y;
+bool Player::updateTarget(map<unsigned int, Player*>& players) {
+   Player* p = NULL;
+   if (this->targetPlayer > 0)
+      p =players[this->targetPlayer];
+
+   if (p != NULL && this->isChasing) {
+      this->target.x = p->pos.x;
+      this->target.y = p->pos.y;
 
       if (posDistance(this->pos, this->target.toFloat()) <= this->range) {
Index: common/Player.h
===================================================================
--- common/Player.h	(revision 949cf702c364fd81f5261f60f7f4b14f92d65c87)
+++ common/Player.h	(revision 5b923076767a61d7f5790a8c4bfca4fa002edcb4)
@@ -21,4 +21,8 @@
 
 class Player {
+private:
+   unsigned int id;
+   unsigned int targetPlayer;
+
 public:
 
@@ -41,5 +45,9 @@
    ~Player();
 
+   unsigned int getId();
+   unsigned int getTargetPlayer();
+
    void setId(unsigned int id);
+   void setTargetPlayer(unsigned int id);
    void setAddr(sockaddr_in addr);
    void setClass(PlayerClass c);
@@ -48,5 +56,5 @@
    void deserialize(char* buffer);
 
-   bool updateTarget(const Player* targetPlayer);
+   bool updateTarget(map<unsigned int, Player*>& players);
    bool move(WorldMap *map);
    void takeDamage(int damage);
@@ -55,5 +63,4 @@
    void dropFlag(unsigned int flag, WorldMap* map);
 
-   unsigned int id;
    string name;
    string password;
@@ -66,5 +73,4 @@
    bool isChasing;
    bool isAttacking;
-   unsigned int targetPlayer;
    bool isDead;
 
