Changeset 5b92307 in network-game for client/Client/main.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
  • client/Client/main.cpp

    r949cf70 r5b92307  
    432432                  target = it->second;
    433433                  cout << "set target" << endl;
    434                   if (target->id != curPlayerId && target->team != curPlayer->team)
     434                  if (target->getId() != curPlayerId && target->team != curPlayer->team)
    435435                  {
    436436                     cout << "Found valid target" << endl;
    437437
     438                     unsigned int targetId = target->getId();
     439
    438440                     msgTo.type = MSG_TYPE_ATTACK;
    439441                     memcpy(msgTo.buffer, &curPlayerId, 4);
    440                      memcpy(msgTo.buffer+4, &target->id, 4);
     442                     memcpy(msgTo.buffer+4, &targetId, 4);
    441443
    442444                     msgProcessor.sendMessage(&msgTo, &server);
     
    678680                  p->deserialize(msg.buffer);
    679681
    680                   if (mapPlayers.find(p->id) != mapPlayers.end())
    681                      delete mapPlayers[p->id];
    682                   mapPlayers[p->id] = p;
    683                   curPlayerId = p->id;
     682                  if (mapPlayers.find(p->getId()) != mapPlayers.end())
     683                     delete mapPlayers[p->getId()];
     684                  mapPlayers[p->getId()] = p;
     685                  curPlayerId = p->getId();
    684686
    685687                  cout << "Got a valid login response with the player" << endl;
     
    732734                  p.isDead = false;
    733735
    734                if (mapPlayers.find(p.id) != mapPlayers.end())
    735                   *(mapPlayers[p.id]) = p;
     736               if (mapPlayers.find(p.getId()) != mapPlayers.end())
     737                  *(mapPlayers[p.getId()]) = p;
    736738               else
    737                   mapPlayers[p.id] = new Player(p);
     739                  mapPlayers[p.getId()] = new Player(p);
    738740
    739741               break;
     
    771773
    772774               Player* source = mapPlayers[id];
    773                source->targetPlayer = targetID;
     775               source->setTargetPlayer(targetID);
    774776               source->isChasing = true;
    775777
     
    953955                  p.isDead = false;
    954956
    955                if (mapPlayers.find(p.id) != mapPlayers.end())
    956                   *(mapPlayers[p.id]) = p;
     957               if (mapPlayers.find(p.getId()) != mapPlayers.end())
     958                  *(mapPlayers[p.getId()]) = p;
    957959               else
    958                   mapPlayers[p.id] = new Player(p);
     960                  mapPlayers[p.getId()] = new Player(p);
    959961
    960962               break;
     
    966968               Player p("", "");
    967969               p.deserialize(msg.buffer);
     970               cout << "Deserialized player" << endl;
    968971               p.timeLastUpdated = getCurrentMillis();
    969972               p.isChasing = false;
     
    973976                  p.isDead = false;
    974977
    975                if (mapPlayers.find(p.id) != mapPlayers.end())
    976                   *(mapPlayers[p.id]) = p;
     978               if (mapPlayers.find(p.getId()) != mapPlayers.end())
     979                  *(mapPlayers[p.getId()]) = p;
    977980               else
    978                   mapPlayers[p.id] = new Player(p);
    979 
    980                game->addPlayer(mapPlayers[p.id]);
     981                  mapPlayers[p.getId()] = new Player(p);
     982
     983               game->addPlayer(mapPlayers[p.getId()]);
    981984
    982985               break;
     
    10511054               // need to check the target exists in the current game
    10521055               Player* source = game->getPlayers()[id];
    1053                source->targetPlayer = targetId;
     1056               source->setTargetPlayer(targetId);
    10541057               source->isChasing = true;
    10551058
Note: See TracChangeset for help on using the changeset viewer.