- Timestamp:
- Dec 22, 2013, 10:14:43 PM (11 years ago)
- Branches:
- master
- Children:
- 58ca135
- Parents:
- 1d96513
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
server/server.cpp
r1d96513 r45734ff 48 48 49 49 void updateUnusedPlayerId(unsigned int& id, map<unsigned int, Player*>& mapPlayers); 50 void updateUnusedProjectileId(unsigned int& id, map<unsigned int, Projectile>& mapProjectiles);51 50 Player *findPlayerByName(map<unsigned int, Player*> &m, string name); 52 51 Player *findPlayerByAddr(map<unsigned int, Player*> &m, const sockaddr_in &addr); … … 476 475 477 476 Projectile proj(p->pos.x, p->pos.y, p->targetPlayer, p->damage); 478 p roj.id = unusedProjectileId;479 updateUnusedProjectileId(unusedProjectileId, mapProjectiles);480 mapProjectiles[proj.id] = proj;481 482 int x = it->second->pos.x;483 int y = it->second->pos.y;477 p->currentGame->assignProjectileId(&proj); 478 479 p->currentGame->addProjectile(proj); 480 481 int x = p->pos.x; 482 int y = p->pos.y; 484 483 485 484 serverMsg.type = MSG_TYPE_PROJECTILE; … … 487 486 memcpy(serverMsg.buffer+4, &x, 4); 488 487 memcpy(serverMsg.buffer+8, &y, 4); 489 memcpy(serverMsg.buffer+12, & it->second->targetPlayer, 4);488 memcpy(serverMsg.buffer+12, &p->targetPlayer, 4); 490 489 } 491 490 else … … 507 506 // move all projectiles 508 507 // see if this can be moved inside the game class 508 // this method can be moved when I add a MessageProcessor to the Game class 509 509 map<unsigned int, Projectile>::iterator itProj; 510 510 for (itProj = mapProjectiles.begin(); itProj != mapProjectiles.end(); itProj++) … … 1198 1198 } 1199 1199 1200 void updateUnusedProjectileId(unsigned int& id, map<unsigned int, Projectile>& mapProjectiles)1201 {1202 while (mapProjectiles.find(id) != mapProjectiles.end())1203 id++;1204 }1205 1206 1200 Player *findPlayerByName(map<unsigned int, Player*> &m, string name) 1207 1201 {
Note:
See TracChangeset
for help on using the changeset viewer.