Changeset d998572 in network-game


Ignore:
Timestamp:
Jan 19, 2014, 8:19:18 PM (11 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
9ba9b96
Parents:
1f6233e
Message:

updateTarget (from the Player class) now takes the target as a parameter instead of the whole player map

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • common/Player.cpp

    r1f6233e rd998572  
    217217}
    218218
    219 bool Player::updateTarget(map<unsigned int, Player*>& mapPlayers) {
     219bool Player::updateTarget(const Player* targetPlayer) {
    220220   if (this->isChasing) {
    221       this->target.x = mapPlayers[this->targetPlayer]->pos.x;
    222       this->target.y = mapPlayers[this->targetPlayer]->pos.y;
     221      this->target.x = targetPlayer->pos.x;
     222      this->target.y = targetPlayer->pos.y;
    223223
    224224      if (posDistance(this->pos, this->target.toFloat()) <= this->range) {
  • common/Player.h

    r1f6233e rd998572  
    4848   void deserialize(char* buffer);
    4949
    50    bool updateTarget(map<unsigned int, Player*>& mapPlayers);
     50   bool updateTarget(const Player* targetPlayer);
    5151   bool move(WorldMap *map);
    5252   void takeDamage(int damage);
  • server/server.cpp

    r1f6233e rd998572  
    171171            if (p->currentGame != NULL) {
    172172               map<unsigned int, Player*> playersInGame = p->currentGame->getPlayers();
    173                if (p->updateTarget(playersInGame))
     173               if (p->updateTarget(playersInGame[p->targetPlayer]))
    174174               {
    175175                  serverMsg.type = MSG_TYPE_PLAYER;
Note: See TracChangeset for help on using the changeset viewer.