Index: common/Game.cpp
===================================================================
--- common/Game.cpp	(revision 9ba9b968bccdc6fe97763cbbad7fb022eac68c94)
+++ 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 9ba9b968bccdc6fe97763cbbad7fb022eac68c94)
+++ 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 9ba9b968bccdc6fe97763cbbad7fb022eac68c94)
+++ 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;
 
