Changeset 1318 for code/branches/merge/src/network/ClientInformation.cc
- Timestamp:
- May 18, 2008, 10:00:17 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/merge/src/network/ClientInformation.cc
r1299 r1318 45 45 namespace network 46 46 { 47 boost::recursive_mutex ClientInformation::mutex_; 48 47 49 ClientInformation::ClientInformation() { 48 50 gamestateID_=GAMESTATEID_INITIAL; 49 51 preve=0; 50 52 nexte=0; 51 this->head =false;53 this->head_=false; 52 54 synched_=false; 53 55 } … … 57 59 preve=0; 58 60 nexte=0; 59 this->head =head;61 this->head_=head; 60 62 synched_=false; 61 63 } … … 80 82 81 83 ClientInformation::~ClientInformation() { 84 boost::recursive_mutex::scoped_lock lock(mutex_); 82 85 if(preve!=0) 83 86 preve->setNext(this->nexte); … … 87 90 88 91 ClientInformation *ClientInformation::next() { 92 boost::recursive_mutex::scoped_lock lock(mutex_); 89 93 if(this!=0) 90 94 return this->nexte; … … 93 97 } 94 98 ClientInformation *ClientInformation::prev() { 99 boost::recursive_mutex::scoped_lock lock(mutex_); 95 100 if(this!=0) 96 101 return this->preve; … … 100 105 101 106 bool ClientInformation::setPrev(ClientInformation *prev) { 102 if(!head) 107 boost::recursive_mutex::scoped_lock lock(mutex_); 108 if(!head_) 103 109 this->preve = prev; 104 110 else … … 108 114 109 115 bool ClientInformation::setNext(ClientInformation *next) { 116 boost::recursive_mutex::scoped_lock lock(mutex_); 110 117 this->nexte = next; 111 118 return true; … … 113 120 114 121 ClientInformation *ClientInformation::insertAfter(ClientInformation *ins) { 122 boost::recursive_mutex::scoped_lock lock(mutex_); 115 123 this->nexte->setPrev(ins); 116 124 ins->setNext(this->nexte); … … 121 129 122 130 ClientInformation *ClientInformation::insertBefore(ClientInformation *ins){ 131 boost::recursive_mutex::scoped_lock lock(mutex_); 123 132 if(!this) 124 133 return NULL; … … 131 140 132 141 void ClientInformation::setID(int clientID){ 142 boost::recursive_mutex::scoped_lock lock(mutex_); 133 143 clientID_ = clientID; 134 144 } 135 145 136 146 bool ClientInformation::setPeer(ENetPeer *peer){ 147 boost::recursive_mutex::scoped_lock lock(mutex_); 137 148 if(!this) 138 149 return false; … … 142 153 143 154 bool ClientInformation::setGamestateID(int id){ 155 boost::recursive_mutex::scoped_lock lock(mutex_); 144 156 if(!this) 145 157 return false; … … 149 161 150 162 int ClientInformation::getID() { 163 boost::recursive_mutex::scoped_lock lock(mutex_); 151 164 if(!this) 152 165 return CLIENTID_UNKNOWN; … … 156 169 157 170 ENetPeer *ClientInformation::getPeer() { 171 boost::recursive_mutex::scoped_lock lock(mutex_); 158 172 if(this) 159 173 return peer_; … … 161 175 return NULL; 162 176 } 177 178 bool ClientInformation::getHead(){ 179 boost::recursive_mutex::scoped_lock lock(mutex_); 180 return head_; 181 } 182 183 void ClientInformation::setHead(bool h){ 184 boost::recursive_mutex::scoped_lock lock(mutex_); 185 head_=h; 186 } 187 188 int ClientInformation::getFailures(){ 189 boost::recursive_mutex::scoped_lock lock(mutex_); 190 return failures_; 191 } 192 void ClientInformation::addFailure(){ 193 boost::recursive_mutex::scoped_lock lock(mutex_); 194 failures_++; 195 } 196 void ClientInformation::resetFailures(){ 197 boost::recursive_mutex::scoped_lock lock(mutex_); 198 failures_=0; 199 } 163 200 164 201 int ClientInformation::getGamestateID() { 202 boost::recursive_mutex::scoped_lock lock(mutex_); 165 203 if(this) 166 204 return gamestateID_; … … 170 208 171 209 ClientInformation *ClientInformation::insertBack(ClientInformation *ins) { 210 boost::recursive_mutex::scoped_lock lock(mutex_); 172 211 if(!this) 173 212 return NULL; … … 182 221 183 222 bool ClientInformation::removeClient(int clientID) { 223 boost::recursive_mutex::scoped_lock lock(mutex_); 184 224 if(!this || clientID==CLIENTID_UNKNOWN) 185 225 return false; … … 194 234 195 235 bool ClientInformation::removeClient(ENetPeer *peer) { 236 boost::recursive_mutex::scoped_lock lock(mutex_); 196 237 if(!this || !peer) 197 238 return false; 198 239 ClientInformation *temp = this; 199 240 while(temp!=0){ 200 if(!temp->head )241 if(!temp->head_) 201 242 if(temp->getPeer()->address.host==peer->address.host && temp->getPeer()->address.port==peer->address.port) 202 243 break; … … 216 257 */ 217 258 ClientInformation *ClientInformation::findClient(int clientID, bool look_backwards) { 218 ClientInformation *temp = this; 219 if (temp->head) 259 boost::recursive_mutex::scoped_lock lock(mutex_); 260 ClientInformation *temp = this; 261 if (temp->head_) 220 262 temp=temp->next(); 221 263 while(temp!=0 && temp->getID()!=clientID){ … … 233 275 */ 234 276 ClientInformation *ClientInformation::findClient(ENetAddress *address, bool look_backwards) { 277 boost::recursive_mutex::scoped_lock lock(mutex_); 235 278 ClientInformation *temp = this; 236 279 while(temp!=0){ 237 if(temp->head ){280 if(temp->head_){ 238 281 temp = temp->next(); 239 282 continue; … … 248 291 249 292 bool ClientInformation::setSynched(bool s) { 293 boost::recursive_mutex::scoped_lock lock(mutex_); 250 294 if(!this) 251 295 return false; … … 255 299 256 300 bool ClientInformation::getSynched() { 301 boost::recursive_mutex::scoped_lock lock(mutex_); 257 302 if(this) 258 303 return synched_;
Note: See TracChangeset
for help on using the changeset viewer.