Changeset 1946 for code/branches/objecthierarchy/src
- Timestamp:
- Oct 19, 2008, 3:23:52 AM (16 years ago)
- Location:
- code/branches/objecthierarchy/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/core/ConfigValueContainer.h
r1887 r1946 52 52 #include "util/MultiType.h" 53 53 #include "ConfigFileManager.h" 54 #include "Identifier.h" 54 55 55 56 namespace orxonox … … 69 70 inline virtual ~ConfigValueCallback() {} 70 71 inline virtual void call(void* object) 71 { (((T*)object)->*this->function_)();}72 { if (!Identifier::isCreatingHierarchy()) { (((T*)object)->*this->function_)(); } } 72 73 73 74 private: -
code/branches/objecthierarchy/src/orxonox/objects/infos/PlayerInfo.cc
r1945 r1946 58 58 this->registerVariables(); 59 59 60 COUT(0) << "created PlayerInfo " << std::endl;60 COUT(0) << "created PlayerInfo (" << this->getObjectID() << ")" << std::endl; 61 61 } 62 62 … … 66 66 if (gametype) 67 67 gametype->removePlayer(this); 68 COUT(0) << "destroyed PlayerInfo (" << this->getObjectID() << ")" << std::endl; 68 69 } 69 70 … … 75 76 void PlayerInfo::checkName() 76 77 { 77 std::cout << "# P layerInfo: checkName: " << this->bLocalPlayer_ << std::endl;78 if (this->bLocalPlayer_ )78 std::cout << "# PI(" << this->getObjectID() << "): checkName: " << this->bLocalPlayer_ << std::endl; 79 if (this->bLocalPlayer_ && Settings::isMaster()) 79 80 this->setName(this->playerName_); 81 } 82 83 void PlayerInfo::changedName() 84 { 85 std::cout << "# PI(" << this->getObjectID() << "): changedName to " << this->getName() << std::endl; 80 86 } 81 87 82 88 void PlayerInfo::registerVariables() 83 89 { 84 this->setObjectMode(network::direction::bidirectional); 90 REGISTERSTRING(name_, network::direction::toclient, new network::NetworkCallback<PlayerInfo>(this, &PlayerInfo::changedName)); 91 REGISTERSTRING(playerName_, network::direction::toserver, new network::NetworkCallback<PlayerInfo>(this, &PlayerInfo::clientChangedName)); 92 REGISTERDATA(clientID_, network::direction::toclient, new network::NetworkCallback<PlayerInfo>(this, &PlayerInfo::checkClientID)); 93 REGISTERDATA(ping_, network::direction::toclient); 94 REGISTERDATA(bHumanPlayer_, network::direction::toclient); 95 REGISTERDATA(bFinishedSetup_, network::direction::bidirectional, new network::NetworkCallback<PlayerInfo>(this, &PlayerInfo::finishedSetup)); 96 } 85 97 86 REGISTERSTRING(name_, network::direction::bidirectional, new network::NetworkCallback<PlayerInfo>(this, &PlayerInfo::changedName)); 87 REGISTERDATA(clientID_, network::direction::toclient, new network::NetworkCallback<PlayerInfo>(this, &PlayerInfo::checkClientID)); 88 REGISTERDATA(ping_, network::direction::toclient); 89 REGISTERDATA(bHumanPlayer_, network::direction::toclient); 90 REGISTERDATA(bFinishedSetup_, network::direction::bidirectional, new network::NetworkCallback<PlayerInfo>(this, &PlayerInfo::finishedSetup)); 98 void PlayerInfo::clientChangedName() 99 { 100 std::cout << "# PI(" << this->getObjectID() << "): clientChangedName() to " << this->playerName_ << std::endl; 101 this->setName(this->playerName_); 91 102 } 92 103 93 104 void PlayerInfo::checkClientID() 94 105 { 95 std::cout << "# P layerInfo: checkClientID" << std::endl;106 std::cout << "# PI(" << this->getObjectID() << "): checkClientID()" << std::endl; 96 107 this->bHumanPlayer_ = true; 97 108 98 109 if (this->clientID_ == network::Host::getPlayerID()) 99 110 { 100 std::cout << "# 111 std::cout << "# PI(" << this->getObjectID() << "): checkClientID(): it's the client's ID" << std::endl; 101 112 this->bLocalPlayer_ = true; 102 this->setName(this->playerName_); 103 std::cout << "# " << this->getName() << std::endl; 113 //std::cout << "# PI(" << this->getObjectID() << "): checkClientID(): name: " << this->getName() << std::endl; 104 114 105 if ( !Settings::isClient())115 if (Settings::isClient()) 106 116 { 107 std::cout << "# not client: finish setup" << std::endl; 117 std::cout << "# PI(" << this->getObjectID() << "): checkClientID(): we're on a client: set object mode to bidirectional" << std::endl; 118 this->setObjectMode(network::direction::bidirectional); 119 this->playerName_ += "blub"; 120 std::cout << "# PI(" << this->getObjectID() << "): checkClientID(): proposed name: " << this->playerName_ << std::endl; 121 } 122 else 123 { 124 std::cout << "# PI(" << this->getObjectID() << "): checkClientID(): we're not on a client: finish setup" << std::endl; 125 this->clientChangedName(); 108 126 this->bFinishedSetup_ = true; 109 127 this->finishedSetup(); … … 114 132 void PlayerInfo::finishedSetup() 115 133 { 116 std::cout << "# P layerInfo: finishedSetup: " << this->bFinishedSetup_ << std::endl;134 std::cout << "# PI(" << this->getObjectID() << "): finishedSetup(): " << this->bFinishedSetup_ << std::endl; 117 135 if (Settings::isClient()) 118 136 { 119 std::cout << "# client: set to true" << std::endl;137 std::cout << "# PI(" << this->getObjectID() << "): finishedSetup(): we're a client: finish setup" << std::endl; 120 138 this->bFinishedSetup_ = true; 121 139 } 122 140 else if (this->bFinishedSetup_) 123 141 { 124 std::cout << "# not client but finished: add player" << std::endl;142 std::cout << "# PI(" << this->getObjectID() << "): finishedSetup(): we're a server: add player" << std::endl; 125 143 Gametype* gametype = Gametype::getCurrentGametype(); 126 144 if (gametype) … … 129 147 else 130 148 { 131 std::cout << "# not client and not finished" << std::endl;149 std::cout << "# PI(" << this->getObjectID() << "): finishedSetup(): we're a server: client not yet finished" << std::endl; 132 150 } 133 151 } -
code/branches/objecthierarchy/src/orxonox/objects/infos/PlayerInfo.h
r1940 r1946 45 45 void registerVariables(); 46 46 47 virtual void changedName(); 48 47 49 inline void setClientID(unsigned int clientID) 48 50 { this->clientID_ = clientID; this->checkClientID(); } … … 59 61 void finishedSetup(); 60 62 void checkName(); 63 void clientChangedName(); 61 64 62 65 unsigned int clientID_;
Note: See TracChangeset
for help on using the changeset viewer.