Changeset 2168 for code/branches/objecthierarchy/src
- Timestamp:
- Nov 9, 2008, 7:11:53 PM (16 years ago)
- Location:
- code/branches/objecthierarchy/src
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/network/Synchronisable.cc
r2156 r2168 79 79 classID = (unsigned int)-1; 80 80 syncList = new std::list<synchronisableVariable *>; 81 82 81 82 83 83 #ifndef NDEBUG 84 84 ObjectList<Synchronisable>::iterator it; … … 173 173 return 0; 174 174 } 175 175 176 176 COUT(4) << "fabricating object with id: " << header->objectID << std::endl; 177 177 … … 240 240 if (it1 != objectMap_.end()) 241 241 return it1->second; 242 242 243 243 ObjectList<Synchronisable>::iterator it; 244 244 for(it = ObjectList<Synchronisable>::begin(); it; ++it){ … … 295 295 #endif 296 296 } 297 297 298 298 void Synchronisable::unregisterVariable(void *var){ 299 299 std::list<synchronisableVariable *>::iterator it = syncList->begin(); … … 311 311 // the variable has not been registered before 312 312 } 313 313 314 314 315 315 /** … … 366 366 continue; // this variable should only be received 367 367 } 368 368 369 369 // =========== start bidirectional stuff ============= 370 370 // if the variable gets synchronised bidirectional, then add the reference to the bytestream … … 397 397 } 398 398 // ================== end bidirectional stuff 399 399 400 400 switch((*i)->type){ 401 401 case DATA: … … 461 461 bool callback=false; 462 462 bool master=false; 463 463 464 464 if( ( (*i)->mode & direction::bidirectional ) == direction::bidirectional ) 465 465 { … … 505 505 mem += sizeof((*i)->varReference); 506 506 } 507 507 508 508 switch((*i)->type){ 509 509 case DATA: … … 525 525 (*i)->size = *(size_t *)mem; 526 526 mem += sizeof(size_t); 527 527 528 528 if( (*i)->callback) // check whether this string changed 529 529 if( *static_cast<std::string*>((*i)->var) != std::string((char *)mem) ) … … 535 535 *static_cast<std::string*>((*i)->varBuffer)=*static_cast<std::string*>( (void*)(mem+sizeof(size_t)) ); 536 536 } 537 537 538 538 *((std::string *)((*i)->var)) = std::string((const char*)mem); 539 539 COUT(5) << "synchronisable: char: " << (const char*)mem << " string: " << std::string((const char*)mem) << std::endl; -
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.