Changeset 2171 for code/trunk/src/orxonox/LevelManager.cc
- Timestamp:
- Nov 10, 2008, 12:05:03 AM (16 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/objecthierarchy merged: 2111-2115,2123,2132-2134,2143-2144,2153-2158,2160-2169
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/LevelManager.cc
r2087 r2171 28 28 29 29 #include "OrxonoxStableHeaders.h" 30 31 30 #include "LevelManager.h" 32 31 33 #include "core/CoreIncludes.h" 34 35 #include "objects/infos/Level.h" 32 #include "PlayerManager.h" 33 #include "objects/Level.h" 36 34 #include "objects/infos/HumanPlayer.h" 37 35 … … 42 40 LevelManager::LevelManager() 43 41 { 44 RegisterRootObject(LevelManager);45 46 42 assert(singletonRef_s == 0); 47 43 singletonRef_s = this; 48 49 this->getConnectedClients();50 44 } 51 45 … … 95 89 { 96 90 this->levels_s.front()->setActive(true); 97 for (std::map<unsigned int, PlayerInfo*>:: iterator it = this->clients_.begin(); it != this->clients_.end(); ++it)91 for (std::map<unsigned int, PlayerInfo*>::const_iterator it = PlayerManager::getInstance().getClients().begin(); it != PlayerManager::getInstance().getClients().end(); ++it) 98 92 this->levels_s.front()->playerEntered(it->second); 99 93 } 100 94 } 101 102 103 void LevelManager::clientConnected(unsigned int clientID)104 {105 COUT(3) << "client connected" << std::endl;106 107 // create new HumanPlayer instance108 HumanPlayer* player = new HumanPlayer(0);109 player->setClientID(clientID);110 111 // add to clients-map112 assert(!this->clients_[clientID]);113 this->clients_[clientID] = player;114 115 if (this->getActiveLevel())116 this->getActiveLevel()->playerEntered(player);117 }118 119 void LevelManager::clientDisconnected(unsigned int clientID)120 {121 COUT(3) << "client disconnected" << std::endl;122 123 // remove from clients-map124 PlayerInfo* player = this->clients_[clientID];125 this->clients_.erase(clientID);126 127 if (this->getActiveLevel())128 this->getActiveLevel()->playerLeft(player);129 130 // delete PlayerInfo instance131 if (player)132 delete player;133 }134 135 136 PlayerInfo* LevelManager::getClient(unsigned int clientID) const137 {138 std::map<unsigned int, PlayerInfo*>::const_iterator it = this->clients_.find(clientID);139 if (it != this->clients_.end())140 return it->second;141 else142 return 0;143 }144 95 }
Note: See TracChangeset
for help on using the changeset viewer.