- Timestamp:
- Dec 21, 2013, 7:15:00 PM (11 years ago)
- Branches:
- master
- Children:
- b8abc90
- Parents:
- 686589c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
server/server.cpp
r686589c rffadc8e 159 159 for (it = mapPlayers.begin(); it != mapPlayers.end(); it++) 160 160 { 161 Player* p = it->second; 162 161 163 // check if it's time to revive dead players 162 if ( it->second->isDead)164 if (p->isDead) 163 165 { 164 if (getCurrentMillis() - it->second->timeDied >= 10000)165 { 166 it->second->isDead = false;166 if (getCurrentMillis() - p->timeDied >= 10000) 167 { 168 p->isDead = false; 167 169 168 170 POSITION spawnPos; 169 171 170 switch ( it->second->team)172 switch (p->team) 171 173 { 172 174 case 0:// blue team … … 186 188 spawnPos.y = spawnPos.y * 25 + 12; 187 189 188 it->second->pos = spawnPos.toFloat();189 it->second->target = spawnPos;190 it->second->health = it->second->maxHealth;190 p->pos = spawnPos.toFloat(); 191 p->target = spawnPos; 192 p->health = p->maxHealth; 191 193 192 194 serverMsg.type = MSG_TYPE_PLAYER; 193 it->second->serialize(serverMsg.buffer);195 p->serialize(serverMsg.buffer); 194 196 195 197 map<unsigned int, Player*>::iterator it2; 196 198 for (it2 = mapPlayers.begin(); it2 != mapPlayers.end(); it2++) 199 { 200 if ( msgProcessor.sendMessage(&serverMsg, sock, &(p->addr), &outputLog) < 0 ) 201 error("sendMessage"); 202 } 203 } 204 205 continue; 206 } 207 208 if (p->currentGame != NULL) { 209 map<unsigned int, Player*> playersInGame = p->currentGame->getPlayers(); 210 if (p->updateTarget(playersInGame)) 211 { 212 serverMsg.type = MSG_TYPE_PLAYER; 213 p->serialize(serverMsg.buffer); 214 215 map<unsigned int, Player*>::iterator it2; 216 for (it2 = playersInGame.begin(); it2 != playersInGame.end(); it2++) 197 217 { 198 218 if ( msgProcessor.sendMessage(&serverMsg, sock, &(it2->second->addr), &outputLog) < 0 ) 199 219 error("sendMessage"); 200 220 } 201 }202 203 continue;204 }205 206 if (it->second->updateTarget(mapPlayers))207 {208 serverMsg.type = MSG_TYPE_PLAYER;209 it->second->serialize(serverMsg.buffer);210 211 map<unsigned int, Player*>::iterator it2;212 for (it2 = mapPlayers.begin(); it2 != mapPlayers.end(); it2++)213 {214 if ( msgProcessor.sendMessage(&serverMsg, sock, &(it2->second->addr), &outputLog) < 0 )215 error("sendMessage");216 221 } 217 222 } … … 936 941 memcpy(&targetId, clientMsg.buffer+4, 4); 937 942 943 // need to make sure the target is in the sender's game 944 938 945 Player* source = mapPlayers[id]; 939 946 source->targetPlayer = targetId;
Note:
See TracChangeset
for help on using the changeset viewer.