Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 15, 2008, 10:08:41 PM (16 years ago)
Author:
scheusso
Message:

a huge fix in packetbuffer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/merge/src/network/ClientInformation.cc

    r1264 r1299  
    121121
    122122  ClientInformation *ClientInformation::insertBefore(ClientInformation *ins){
     123    if(!this)
     124      return NULL;
    123125    this->prev()->setNext(ins);
    124126    ins->setPrev(this->preve);
     
    132134  }
    133135
    134   void ClientInformation::setPeer(ENetPeer *peer){
     136  bool ClientInformation::setPeer(ENetPeer *peer){
     137    if(!this)
     138      return false;
    135139    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;
    139146    gamestateID_=id;
     147    return true;
    140148  }
    141149
    142150  int ClientInformation::getID() {
    143     return clientID_;
     151    if(!this)
     152      return CLIENTID_UNKNOWN;
     153    else
     154      return clientID_;
    144155  }
    145156
    146157  ENetPeer *ClientInformation::getPeer() {
    147     return peer_;
     158    if(this)
     159      return peer_;
     160    else
     161      return NULL;
    148162  }
    149163
    150164  int ClientInformation::getGamestateID() {
    151     return gamestateID_;
     165    if(this)
     166      return gamestateID_;
     167    else
     168      return -1;
    152169  }
    153170
    154171  ClientInformation *ClientInformation::insertBack(ClientInformation *ins) {
     172    if(!this)
     173      return NULL;
    155174    ClientInformation *temp = this;
    156175    while(temp->next()!=0){
     
    163182
    164183  bool ClientInformation::removeClient(int clientID) {
     184    if(!this || clientID==CLIENTID_UNKNOWN)
     185      return false;
    165186    ClientInformation *temp = this;
    166187    while(temp!=0 && temp->getID()!=clientID)
     
    173194
    174195  bool ClientInformation::removeClient(ENetPeer *peer) {
     196    if(!this || !peer)
     197      return false;
    175198    ClientInformation *temp = this;
    176199    while(temp!=0){
     
    196219    if (temp->head)
    197220      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){
    200222      temp = temp->next();
    201223    }
     
    212234  ClientInformation *ClientInformation::findClient(ENetAddress *address, bool look_backwards) {
    213235    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){
    216237      if(temp->head){
    217238        temp = temp->next();
     
    226247  }
    227248
    228   void ClientInformation::setSynched(bool s) {
     249  bool ClientInformation::setSynched(bool s) {
     250    if(!this)
     251      return false;
    229252    synched_=s;
     253    return true;
    230254  }
    231255
    232256  bool ClientInformation::getSynched() {
    233     return synched_;
     257    if(this)
     258      return synched_;
     259    else
     260      return false;
    234261  }
    235262
Note: See TracChangeset for help on using the changeset viewer.