Changeset 2168 for code/branches/objecthierarchy/src/orxonox
- Timestamp:
- Nov 9, 2008, 7:11:53 PM (16 years ago)
- Location:
- code/branches/objecthierarchy/src/orxonox
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/orxonox/CMakeLists.txt
r2074 r2168 4 4 LevelManager.cc 5 5 Main.cc 6 PlayerManager.cc 6 7 Settings.cc 7 8 -
code/branches/objecthierarchy/src/orxonox/LevelManager.cc
r2086 r2168 28 28 29 29 #include "OrxonoxStableHeaders.h" 30 31 30 #include "LevelManager.h" 32 31 33 #include "core/CoreIncludes.h" 34 32 #include "PlayerManager.h" 35 33 #include "objects/infos/Level.h" 36 34 #include "objects/infos/HumanPlayer.h" … … 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 } -
code/branches/objecthierarchy/src/orxonox/LevelManager.h
r2112 r2168 36 36 #include <cassert> 37 37 38 #include "network/ClientConnectionListener.h"39 40 38 namespace orxonox 41 39 { 42 class _OrxonoxExport LevelManager : public ClientConnectionListener40 class _OrxonoxExport LevelManager 43 41 { 44 42 public: … … 50 48 Level* getActiveLevel(); 51 49 52 PlayerInfo* getClient(unsigned int clientID) const; 53 inline const std::map<unsigned int, PlayerInfo*>& getClients() const 54 { return this->clients_; } 55 50 static LevelManager* getInstancePtr() { return singletonRef_s; } 56 51 static LevelManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; } 57 52 … … 59 54 LevelManager(const LevelManager&); 60 55 61 void clientConnected(unsigned int clientID);62 void clientDisconnected(unsigned int clientID);63 64 56 void activateNextLevel(); 65 57 66 58 std::list<Level*> levels_s; 67 std::map<unsigned int, PlayerInfo*> clients_;68 69 59 static LevelManager* singletonRef_s; 70 60 }; -
code/branches/objecthierarchy/src/orxonox/OrxonoxPrereqs.h
r2074 r2168 82 82 class CameraManager; 83 83 class LevelManager; 84 class PlayerManager; 84 85 85 86 // objects -
code/branches/objecthierarchy/src/orxonox/objects/infos/Level.cc
r2112 r2168 40 40 #include "PlayerInfo.h" 41 41 #include "objects/gametypes/Gametype.h" 42 #include "overlays/OverlayGroup.h" 42 43 43 44 #include "util/Math.h" … … 62 63 if (this->isInitialized()) 63 64 { 64 LevelManager::getInstance().releaseActivity(this); 65 if (LevelManager::getInstancePtr()) 66 LevelManager::getInstance().releaseActivity(this); 65 67 66 68 if (this->xmlfile_) … … 93 95 mask.exclude(Class(BaseObject)); 94 96 mask.include(Class(Template)); 97 mask.include(Class(OverlayGroup)); // HACK to include the ChatOverlay 95 98 96 99 this->xmlfile_ = new XMLFile(Settings::getDataPath() + this->xmlfilename_, mask); … … 112 115 (*it)->setGametype(rootgametype); 113 116 114 LevelManager::getInstance().requestActivity(this); 117 if (LevelManager::getInstancePtr()) 118 LevelManager::getInstance().requestActivity(this); 115 119 } 116 120 } -
code/branches/objecthierarchy/src/orxonox/overlays/hud/ChatOverlay.cc
r2112 r2168 38 38 #include "network/ClientInformation.h" 39 39 40 #include " LevelManager.h"40 #include "PlayerManager.h" 41 41 #include "objects/infos/PlayerInfo.h" 42 42 #include "overlays/console/InGameConsole.h" … … 76 76 std::string name = "unknown"; 77 77 78 PlayerInfo* player = LevelManager::getInstance().getClient(senderID);78 PlayerInfo* player = PlayerManager::getInstance().getClient(senderID); 79 79 if (player) 80 80 name = player->getName();
Note: See TracChangeset
for help on using the changeset viewer.