Changeset 1299 for code/branches/merge/src/network/ClientInformation.cc
- Timestamp:
- May 15, 2008, 10:08:41 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/merge/src/network/ClientInformation.cc
r1264 r1299 121 121 122 122 ClientInformation *ClientInformation::insertBefore(ClientInformation *ins){ 123 if(!this) 124 return NULL; 123 125 this->prev()->setNext(ins); 124 126 ins->setPrev(this->preve); … … 132 134 } 133 135 134 void ClientInformation::setPeer(ENetPeer *peer){ 136 bool ClientInformation::setPeer(ENetPeer *peer){ 137 if(!this) 138 return false; 135 139 peer_ = peer; 136 } 137 138 void ClientInformation::setGamestateID(int id){ 140 return true; 141 } 142 143 bool ClientInformation::setGamestateID(int id){ 144 if(!this) 145 return false; 139 146 gamestateID_=id; 147 return true; 140 148 } 141 149 142 150 int ClientInformation::getID() { 143 return clientID_; 151 if(!this) 152 return CLIENTID_UNKNOWN; 153 else 154 return clientID_; 144 155 } 145 156 146 157 ENetPeer *ClientInformation::getPeer() { 147 return peer_; 158 if(this) 159 return peer_; 160 else 161 return NULL; 148 162 } 149 163 150 164 int ClientInformation::getGamestateID() { 151 return gamestateID_; 165 if(this) 166 return gamestateID_; 167 else 168 return -1; 152 169 } 153 170 154 171 ClientInformation *ClientInformation::insertBack(ClientInformation *ins) { 172 if(!this) 173 return NULL; 155 174 ClientInformation *temp = this; 156 175 while(temp->next()!=0){ … … 163 182 164 183 bool ClientInformation::removeClient(int clientID) { 184 if(!this || clientID==CLIENTID_UNKNOWN) 185 return false; 165 186 ClientInformation *temp = this; 166 187 while(temp!=0 && temp->getID()!=clientID) … … 173 194 174 195 bool ClientInformation::removeClient(ENetPeer *peer) { 196 if(!this || !peer) 197 return false; 175 198 ClientInformation *temp = this; 176 199 while(temp!=0){ … … 196 219 if (temp->head) 197 220 temp=temp->next(); 198 //bugfix: temp to temp->next(), get last elem if not found, not segflt 199 while(temp->next()!=0 && temp->getID()!=clientID){ 221 while(temp!=0 && temp->getID()!=clientID){ 200 222 temp = temp->next(); 201 223 } … … 212 234 ClientInformation *ClientInformation::findClient(ENetAddress *address, bool look_backwards) { 213 235 ClientInformation *temp = this; 214 //bugfix: temp to temp->next(), get last elem if not found, not segflt 215 while(temp->next()!=0){ 236 while(temp!=0){ 216 237 if(temp->head){ 217 238 temp = temp->next(); … … 226 247 } 227 248 228 void ClientInformation::setSynched(bool s) { 249 bool ClientInformation::setSynched(bool s) { 250 if(!this) 251 return false; 229 252 synched_=s; 253 return true; 230 254 } 231 255 232 256 bool ClientInformation::getSynched() { 233 return synched_; 257 if(this) 258 return synched_; 259 else 260 return false; 234 261 } 235 262
Note: See TracChangeset
for help on using the changeset viewer.