Changeset 5b92307 in network-game for common/Game.cpp
- Timestamp:
- Jan 20, 2014, 6:47:58 PM (11 years ago)
- Branches:
- master
- Children:
- 204edcf
- Parents:
- 949cf70
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
common/Game.cpp
r949cf70 r5b92307 43 43 44 44 bool 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; 47 47 return true; 48 48 } … … 429 429 cout << "Melee attack" << endl; 430 430 431 Player* target = players[p-> targetPlayer];431 Player* target = players[p->getTargetPlayer()]; 432 432 this->dealDamageToPlayer(target, p->damage); 433 433 } … … 436 436 cout << "Ranged attack" << endl; 437 437 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); 439 439 this->assignProjectileId(&proj); 440 440 this->addProjectile(proj); … … 442 442 int x = p->pos.x; 443 443 int y = p->pos.y; 444 unsigned int targetId = p->getTargetPlayer(); 444 445 445 446 serverMsg.type = MSG_TYPE_PROJECTILE; … … 447 448 memcpy(serverMsg.buffer+4, &x, 4); 448 449 memcpy(serverMsg.buffer+8, &y, 4); 449 memcpy(serverMsg.buffer+12, & p->targetPlayer, 4);450 memcpy(serverMsg.buffer+12, &targetId, 4); 450 451 msgProcessor->broadcastMessage(serverMsg, players); 451 452 }
Note:
See TracChangeset
for help on using the changeset viewer.