Changeset 1953 for code/branches/objecthierarchy/src/orxonox/objects/infos
- Timestamp:
- Oct 19, 2008, 9:50:36 PM (16 years ago)
- Location:
- code/branches/objecthierarchy/src/orxonox/objects/infos
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/orxonox/objects/infos/PlayerInfo.cc
r1950 r1953 51 51 52 52 this->ping_ = -1; 53 this->clientID_ = (unsigned int)-1;53 this->clientID_ = network::CLIENTID_UNKNOWN; 54 54 this->bLocalPlayer_ = Core::isStandalone(); 55 55 this->bLocalPlayer_ = false; … … 60 60 this->registerVariables(); 61 61 62 62 //COUT(0) << "created PlayerInfo (" << this->getObjectID() << ")" << std::endl; 63 63 } 64 64 … … 68 68 if (gametype) 69 69 gametype->removePlayer(this); 70 70 //COUT(0) << "destroyed PlayerInfo (" << this->getObjectID() << ")" << std::endl; 71 71 } 72 72 73 73 void PlayerInfo::setConfigValues() 74 74 { 75 SetConfigValue( playerName_, "Player").callback(this, &PlayerInfo::checkName);75 SetConfigValue(nick_, "Player").callback(this, &PlayerInfo::checkNick); 76 76 } 77 77 78 void PlayerInfo::checkN ame()78 void PlayerInfo::checkNick() 79 79 { 80 std::cout << "# PI(" << this->getObjectID() << "): checkName: " << this->bLocalPlayer_ << std::endl; 81 if (this->bLocalPlayer_ && Core::isMaster()) 82 this->setName(this->playerName_); 80 //std::cout << "# PI(" << this->getObjectID() << "): checkName: " << this->bLocalPlayer_ << std::endl; 81 if (this->bLocalPlayer_) 82 { 83 this->playerName_ = this->nick_; 84 85 if (Core::isMaster()) 86 this->setName(this->playerName_); 87 } 83 88 } 84 89 85 90 void PlayerInfo::changedName() 86 91 { 87 std::cout << "# PI(" << this->getObjectID() << "): changedName to " << this->getName() << std::endl;92 //std::cout << "# PI(" << this->getObjectID() << "): changedName to " << this->getName() << std::endl; 88 93 Gametype* gametype = Gametype::getCurrentGametype(); 89 94 if (gametype) … … 103 108 void PlayerInfo::clientChangedName() 104 109 { 105 std::cout << "# PI(" << this->getObjectID() << "): clientChangedName()to " << this->playerName_ << std::endl;110 //std::cout << "# PI(" << this->getObjectID() << "): clientChangedName() from " << this->getName() << " to " << this->playerName_ << std::endl; 106 111 this->setName(this->playerName_); 107 112 } … … 109 114 void PlayerInfo::checkClientID() 110 115 { 111 std::cout << "# PI(" << this->getObjectID() << "): checkClientID()" << std::endl;116 //std::cout << "# PI(" << this->getObjectID() << "): checkClientID()" << std::endl; 112 117 this->bHumanPlayer_ = true; 113 118 114 119 if (this->clientID_ == network::Host::getPlayerID()) 115 120 { 116 std::cout << "# PI(" << this->getObjectID() << "): checkClientID(): it's the client's ID" << std::endl;121 //std::cout << "# PI(" << this->getObjectID() << "): checkClientID(): it's the client's ID" << std::endl; 117 122 this->bLocalPlayer_ = true; 123 this->playerName_ = this->nick_; 118 124 //std::cout << "# PI(" << this->getObjectID() << "): checkClientID(): name: " << this->getName() << std::endl; 119 125 120 126 if (Core::isClient()) 121 127 { 122 std::cout << "# PI(" << this->getObjectID() << "): checkClientID(): we're on a client: set object mode to bidirectional" << std::endl;128 //std::cout << "# PI(" << this->getObjectID() << "): checkClientID(): we're on a client: set object mode to bidirectional" << std::endl; 123 129 this->setObjectMode(network::direction::bidirectional); 124 this->playerName_ += "blub"; 125 std::cout << "# PI(" << this->getObjectID() << "): checkClientID(): proposed name: " << this->playerName_ << std::endl; 130 //std::cout << "# PI(" << this->getObjectID() << "): checkClientID(): proposed name: " << this->playerName_ << std::endl; 126 131 } 127 132 else 128 133 { 129 std::cout << "# PI(" << this->getObjectID() << "): checkClientID(): we're not on a client: finish setup" << std::endl;134 //std::cout << "# PI(" << this->getObjectID() << "): checkClientID(): we're not on a client: finish setup" << std::endl; 130 135 this->clientChangedName(); 131 136 this->bFinishedSetup_ = true; … … 137 142 void PlayerInfo::finishedSetup() 138 143 { 139 std::cout << "# PI(" << this->getObjectID() << "): finishedSetup(): " << this->bFinishedSetup_ << std::endl;144 //std::cout << "# PI(" << this->getObjectID() << "): finishedSetup(): " << this->bFinishedSetup_ << std::endl; 140 145 if (Core::isClient()) 141 146 { 142 std::cout << "# PI(" << this->getObjectID() << "): finishedSetup(): we're a client: finish setup" << std::endl;147 //std::cout << "# PI(" << this->getObjectID() << "): finishedSetup(): we're a client: finish setup" << std::endl; 143 148 this->bFinishedSetup_ = true; 144 149 } 145 150 else if (this->bFinishedSetup_) 146 151 { 147 std::cout << "# PI(" << this->getObjectID() << "): finishedSetup(): we're a server: add player" << std::endl;152 //std::cout << "# PI(" << this->getObjectID() << "): finishedSetup(): we're a server: add player" << std::endl; 148 153 Gametype* gametype = Gametype::getCurrentGametype(); 149 154 if (gametype) … … 152 157 else 153 158 { 154 std::cout << "# PI(" << this->getObjectID() << "): finishedSetup(): we're a server: client not yet finished" << std::endl;159 //std::cout << "# PI(" << this->getObjectID() << "): finishedSetup(): we're a server: client not yet finished" << std::endl; 155 160 } 156 161 } -
code/branches/objecthierarchy/src/orxonox/objects/infos/PlayerInfo.h
r1946 r1953 60 60 void checkClientID(); 61 61 void finishedSetup(); 62 void checkN ame();62 void checkNick(); 63 63 void clientChangedName(); 64 64 … … 70 70 71 71 std::string playerName_; 72 std::string nick_; 72 73 }; 73 74 }
Note: See TracChangeset
for help on using the changeset viewer.