Changeset 5b92307 in network-game for common/Game.cpp


Ignore:
Timestamp:
Jan 20, 2014, 6:47:58 PM (11 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
204edcf
Parents:
949cf70
Message:

id and targetPlayer are now both private members of the Player class and have getters and setters to access them

File:
1 edited

Legend:

Unmodified
Added
Removed
  • common/Game.cpp

    r949cf70 r5b92307  
    4343
    4444bool Game::addPlayer(Player* p) {
    45    if (players.find(p->id) == players.end()) {
    46       players[p->id] = p;
     45   if (players.find(p->getId()) == players.end()) {
     46      players[p->getId()] = p;
    4747      return true;
    4848   }
     
    429429         cout << "Melee attack" << endl;
    430430
    431          Player* target = players[p->targetPlayer];
     431         Player* target = players[p->getTargetPlayer()];
    432432         this->dealDamageToPlayer(target, p->damage);
    433433      }
     
    436436         cout << "Ranged attack" << endl;
    437437
    438          Projectile proj(p->pos.x, p->pos.y, p->targetPlayer, p->damage);
     438         Projectile proj(p->pos.x, p->pos.y, p->getTargetPlayer(), p->damage);
    439439         this->assignProjectileId(&proj);
    440440         this->addProjectile(proj);
     
    442442         int x = p->pos.x;
    443443         int y = p->pos.y;
     444         unsigned int targetId = p->getTargetPlayer();
    444445
    445446         serverMsg.type = MSG_TYPE_PROJECTILE;
     
    447448         memcpy(serverMsg.buffer+4, &x, 4);
    448449         memcpy(serverMsg.buffer+8, &y, 4);
    449          memcpy(serverMsg.buffer+12, &p->targetPlayer, 4);
     450         memcpy(serverMsg.buffer+12, &targetId, 4);
    450451         msgProcessor->broadcastMessage(serverMsg, players);
    451452      }
Note: See TracChangeset for help on using the changeset viewer.