Changeset 1433 for code/branches
- Timestamp:
- May 26, 2008, 10:10:55 PM (17 years ago)
- Location:
- code/branches/network/src/network
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/network/ClientInformation.cc
r1431 r1433 45 45 namespace network 46 46 { 47 boost::recursive_mutex ClientInformation::mutex_;48 47 49 48 ClientInformation::ClientInformation() { … … 84 83 85 84 ClientInformation::~ClientInformation() { 86 boost::recursive_mutex::scoped_lock lock(mutex_);87 85 if(prev()!=0) 88 86 prev()->setNext(this->next()); … … 92 90 93 91 ClientInformation *ClientInformation::next() { 94 boost::recursive_mutex::scoped_lock lock(mutex_);95 92 if(this!=0) 96 93 return this->nexte; … … 99 96 } 100 97 ClientInformation *ClientInformation::prev() { 101 boost::recursive_mutex::scoped_lock lock(mutex_);102 98 if(this!=0) 103 99 return this->preve; … … 107 103 108 104 bool ClientInformation::setPrev(ClientInformation *prev) { 109 boost::recursive_mutex::scoped_lock lock(mutex_);110 105 if(!head_) 111 106 this->preve = prev; … … 116 111 117 112 bool ClientInformation::setNext(ClientInformation *next) { 118 boost::recursive_mutex::scoped_lock lock(mutex_);119 113 this->nexte = next; 120 114 return true; … … 122 116 123 117 ClientInformation *ClientInformation::insertAfter(ClientInformation *ins) { 124 boost::recursive_mutex::scoped_lock lock(mutex_);125 118 this->next()->setPrev(ins); 126 119 ins->setNext(this->next()); … … 131 124 132 125 ClientInformation *ClientInformation::insertBefore(ClientInformation *ins){ 133 boost::recursive_mutex::scoped_lock lock(mutex_);134 126 if(!this) 135 127 return NULL; … … 144 136 if(!this) 145 137 return; 146 boost::recursive_mutex::scoped_lock lock(mutex_);147 138 clientID_ = clientID; 148 139 } 149 140 150 141 bool ClientInformation::setPeer(ENetPeer *peer){ 151 boost::recursive_mutex::scoped_lock lock(mutex_);152 142 if(!this) 153 143 return false; … … 157 147 158 148 bool ClientInformation::setGameStateID(int id){ 159 boost::recursive_mutex::scoped_lock lock(mutex_);160 149 if(!this) 161 150 return false; … … 165 154 166 155 bool ClientInformation::setPartialGamestateID(int id){ 167 boost::recursive_mutex::scoped_lock lock(mutex_);168 156 if(!this) 169 157 return false; … … 173 161 174 162 int ClientInformation::getID() { 175 boost::recursive_mutex::scoped_lock lock(mutex_);176 163 if(!this) 177 164 return CLIENTID_UNKNOWN; … … 181 168 182 169 ENetPeer *ClientInformation::getPeer() { 183 boost::recursive_mutex::scoped_lock lock(mutex_);184 170 if(this) 185 171 return peer_; … … 189 175 190 176 bool ClientInformation::getHead(){ 191 boost::recursive_mutex::scoped_lock lock(mutex_);192 177 return head_; 193 178 } 194 179 195 180 void ClientInformation::setHead(bool h){ 196 boost::recursive_mutex::scoped_lock lock(mutex_);197 181 head_=h; 198 182 } 199 183 200 184 int ClientInformation::getFailures(){ 201 boost::recursive_mutex::scoped_lock lock(mutex_);202 185 return failures_; 203 186 } 204 187 void ClientInformation::addFailure(){ 205 boost::recursive_mutex::scoped_lock lock(mutex_);206 188 failures_++; 207 189 } 208 190 void ClientInformation::resetFailures(){ 209 boost::recursive_mutex::scoped_lock lock(mutex_);210 191 failures_=0; 211 192 } 212 193 213 194 int ClientInformation::getGamestateID() { 214 boost::recursive_mutex::scoped_lock lock(mutex_);215 195 if(this) 216 196 return gamestateID_; … … 220 200 221 201 int ClientInformation::getPartialGamestateID() { 222 boost::recursive_mutex::scoped_lock lock(mutex_);223 202 if(this) 224 203 return partialGamestateID_; … … 228 207 229 208 ClientInformation *ClientInformation::insertBack(ClientInformation *ins) { 230 boost::recursive_mutex::scoped_lock lock(mutex_);231 209 if(!this) 232 210 return NULL; … … 241 219 242 220 bool ClientInformation::removeClient(int clientID) { 243 boost::recursive_mutex::scoped_lock lock(mutex_);244 221 if(!this || clientID==CLIENTID_UNKNOWN) 245 222 return false; … … 254 231 255 232 bool ClientInformation::removeClient(ENetPeer *peer) { 256 boost::recursive_mutex::scoped_lock lock(mutex_);257 233 if(!this || !peer) 258 234 return false; … … 277 253 */ 278 254 ClientInformation *ClientInformation::findClient(int clientID, bool look_backwards) { 279 boost::recursive_mutex::scoped_lock lock(mutex_);280 255 ClientInformation *temp = this; 281 256 if (temp->head_) … … 295 270 */ 296 271 ClientInformation *ClientInformation::findClient(ENetAddress *address, bool look_backwards) { 297 boost::recursive_mutex::scoped_lock lock(mutex_);298 272 ClientInformation *temp = this; 299 273 while(temp!=0){ … … 311 285 312 286 bool ClientInformation::setSynched(bool s) { 313 boost::recursive_mutex::scoped_lock lock(mutex_);314 287 if(!this) 315 288 return false; … … 319 292 320 293 bool ClientInformation::getSynched() { 321 boost::recursive_mutex::scoped_lock lock(mutex_);322 294 if(this) 323 295 return synched_; -
code/branches/network/src/network/ClientInformation.h
r1432 r1433 97 97 bool setSynched(bool s); 98 98 bool getSynched(); 99 static boost::recursive_mutex mutex_;100 99 101 100 -
code/branches/network/src/network/Server.cc
r1431 r1433 215 215 bool Server::sendGameState() { 216 216 COUT(5) << "Server: starting function sendGameState" << std::endl; 217 boost::recursive_mutex::scoped_lock lock(clients->mutex_);218 217 ClientInformation *temp = clients; 219 218 bool added=false;
Note: See TracChangeset
for help on using the changeset viewer.