- Timestamp:
- Jan 20, 2014, 7:10:55 PM (11 years ago)
- Branches:
- master
- Children:
- 0678d60
- Parents:
- 5b92307
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
server/server.cpp
r5b92307 r204edcf 171 171 if (p->currentGame != NULL) { 172 172 map<unsigned int, Player*> playersInGame = p->currentGame->getPlayers(); 173 if (p->updateTarget(playersInGame [p->targetPlayer]))173 if (p->updateTarget(playersInGame)) 174 174 { 175 175 serverMsg.type = MSG_TYPE_PLAYER; … … 333 333 { 334 334 updateUnusedPlayerId(unusedPlayerId, mapPlayers); 335 p-> id = unusedPlayerId;336 cout << "new player id: " << p-> id<< endl;335 p->setId(unusedPlayerId); 336 cout << "new player id: " << p->getId() << endl; 337 337 p->setAddr(from); 338 338 p->currentGame = NULL; … … 351 351 352 352 cout << "sending info about " << it->second->name << endl; 353 cout << "sending id " << it->second-> id<< endl;353 cout << "sending id " << it->second->getId() << endl; 354 354 msgProcessor.sendMessage(&serverMsg, &from); 355 355 } … … 403 403 { 404 404 // broadcast to all players before deleting p from the map 405 unsigned int playerId = p->getId(); 405 406 serverMsg.type = MSG_TYPE_LOGOUT; 406 memcpy(serverMsg.buffer, &p ->id, 4);407 memcpy(serverMsg.buffer, &playerId, 4); 407 408 408 409 msgProcessor.broadcastMessage(serverMsg, mapPlayers); 409 410 410 if (p-> id< unusedPlayerId)411 unusedPlayerId = p-> id;412 413 mapPlayers.erase(p-> id);411 if (p->getId() < unusedPlayerId) 412 unusedPlayerId = p->getId(); 413 414 mapPlayers.erase(p->getId()); 414 415 delete p; 415 416 … … 559 560 560 561 Player* p = mapPlayers[id]; 561 p-> targetPlayer = targetId;562 p->setTargetPlayer(targetId); 562 563 p->isChasing = true; 563 564 … … 627 628 Player* p = findPlayerByAddr(mapPlayers, from); 628 629 629 if (players.find(p-> id) != players.end()) {630 if (players.find(p->getId()) != players.end()) { 630 631 cout << "Player " << p->name << " trying to join a game he's already in" << endl; 631 632 serverMsg.type = MSG_TYPE_JOIN_GAME_FAILURE; … … 667 668 668 669 p->currentGame = NULL; 669 g->removePlayer(p->id); 670 670 g->removePlayer(p->getId()); 671 672 unsigned int playerId = p->getId(); 671 673 serverMsg.type = MSG_TYPE_LEAVE_GAME; 672 memcpy(serverMsg.buffer, &p ->id, 4);674 memcpy(serverMsg.buffer, &playerId, 4); 673 675 strcpy(serverMsg.buffer+4, g->getName().c_str()); 674 676 msgProcessor.broadcastMessage(serverMsg, g->getPlayers()); … … 755 757 756 758 cout << "sending info about " << it->second->name << endl; 757 cout << "sending id " << it->second-> id<< endl;759 cout << "sending id " << it->second->getId() << endl; 758 760 msgProcessor.sendMessage(&serverMsg, &from); 759 761 }
Note:
See TracChangeset
for help on using the changeset viewer.