Changeset 1502 for code/trunk/src/network/ClientInformation.cc
- Timestamp:
- Jun 1, 2008, 3:54:20 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/network/ClientInformation.cc
r1360 r1502 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 if(preve!=0) 88 preve->setNext(this->nexte); 89 if(nexte!=0) 90 nexte->setPrev(this->preve); 85 if(prev()!=0) 86 prev()->setNext(this->next()); 87 if(next()!=0) 88 next()->setPrev(this->prev()); 91 89 } 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 this->nexte->setPrev(ins); 126 ins->setNext(this->nexte); 118 this->next()->setPrev(ins); 119 ins->setNext(this->next()); 127 120 ins->setPrev(this); 128 121 this->nexte = ins; … … 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; 136 128 this->prev()->setNext(ins); 137 ins->setPrev(this->prev e);129 ins->setPrev(this->prev()); 138 130 this->preve=ins; 139 131 ins->setNext(this); … … 142 134 143 135 void ClientInformation::setID(int clientID){ 144 boost::recursive_mutex::scoped_lock lock(mutex_); 136 if(!this) 137 return; 145 138 clientID_ = clientID; 146 139 } 147 140 148 141 bool ClientInformation::setPeer(ENetPeer *peer){ 149 boost::recursive_mutex::scoped_lock lock(mutex_);150 142 if(!this) 151 143 return false; … … 154 146 } 155 147 156 bool ClientInformation::setGamestateID(int id){ 157 boost::recursive_mutex::scoped_lock lock(mutex_); 148 bool ClientInformation::setGameStateID(int id){ 158 149 if(!this) 159 150 return false; … … 163 154 164 155 bool ClientInformation::setPartialGamestateID(int id){ 165 boost::recursive_mutex::scoped_lock lock(mutex_);166 156 if(!this) 167 157 return false; … … 171 161 172 162 int ClientInformation::getID() { 173 boost::recursive_mutex::scoped_lock lock(mutex_);174 163 if(!this) 175 164 return CLIENTID_UNKNOWN; … … 179 168 180 169 ENetPeer *ClientInformation::getPeer() { 181 boost::recursive_mutex::scoped_lock lock(mutex_);182 170 if(this) 183 171 return peer_; … … 187 175 188 176 bool ClientInformation::getHead(){ 189 boost::recursive_mutex::scoped_lock lock(mutex_);190 177 return head_; 191 178 } 192 179 193 180 void ClientInformation::setHead(bool h){ 194 boost::recursive_mutex::scoped_lock lock(mutex_);195 181 head_=h; 196 182 } 197 183 198 184 int ClientInformation::getFailures(){ 199 boost::recursive_mutex::scoped_lock lock(mutex_);200 185 return failures_; 201 186 } 202 187 void ClientInformation::addFailure(){ 203 boost::recursive_mutex::scoped_lock lock(mutex_);204 188 failures_++; 205 189 } 206 190 void ClientInformation::resetFailures(){ 207 boost::recursive_mutex::scoped_lock lock(mutex_);208 191 failures_=0; 209 192 } 210 193 211 194 int ClientInformation::getGamestateID() { 212 boost::recursive_mutex::scoped_lock lock(mutex_);213 195 if(this) 214 196 return gamestateID_; … … 218 200 219 201 int ClientInformation::getPartialGamestateID() { 220 boost::recursive_mutex::scoped_lock lock(mutex_);221 202 if(this) 222 203 return partialGamestateID_; … … 226 207 227 208 ClientInformation *ClientInformation::insertBack(ClientInformation *ins) { 228 boost::recursive_mutex::scoped_lock lock(mutex_);229 209 if(!this) 230 210 return NULL; … … 239 219 240 220 bool ClientInformation::removeClient(int clientID) { 241 boost::recursive_mutex::scoped_lock lock(mutex_);242 221 if(!this || clientID==CLIENTID_UNKNOWN) 243 222 return false; … … 252 231 253 232 bool ClientInformation::removeClient(ENetPeer *peer) { 254 boost::recursive_mutex::scoped_lock lock(mutex_);255 233 if(!this || !peer) 256 234 return false; … … 275 253 */ 276 254 ClientInformation *ClientInformation::findClient(int clientID, bool look_backwards) { 277 boost::recursive_mutex::scoped_lock lock(mutex_);278 255 ClientInformation *temp = this; 279 256 if (temp->head_) … … 293 270 */ 294 271 ClientInformation *ClientInformation::findClient(ENetAddress *address, bool look_backwards) { 295 boost::recursive_mutex::scoped_lock lock(mutex_);296 272 ClientInformation *temp = this; 297 273 while(temp!=0){ … … 309 285 310 286 bool ClientInformation::setSynched(bool s) { 311 boost::recursive_mutex::scoped_lock lock(mutex_);312 287 if(!this) 313 288 return false; … … 317 292 318 293 bool ClientInformation::getSynched() { 319 boost::recursive_mutex::scoped_lock lock(mutex_);320 294 if(this) 321 295 return synched_;
Note: See TracChangeset
for help on using the changeset viewer.