Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1253


Ignore:
Timestamp:
May 8, 2008, 4:15:45 PM (17 years ago)
Author:
scheusso
Message:

fixes over fixes

Location:
code/branches/network3/src/network
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network3/src/network/ClientConnection.cc

    r1168 r1253  
    112112    if(server==NULL)
    113113      return false;
    114     if(enet_peer_send(server, 1, packet)!=0)
    115       return false;
    116     return true;
     114    if(!packet){
     115      COUT(4) << "Cl.con: addpacket: invalid packet" << std::endl;
     116      return false;
     117    }
     118    if(enet_peer_send(server, 0, packet)<0)
     119      return false;
     120    else
     121      return true;
    117122  }
    118123
  • code/branches/network3/src/network/GameStateClient.cc

    r1246 r1253  
    6464      if(!reference){
    6565        COUT(4) << "pushGameState: no reference found to diff" << std::endl;
     66        delete[] compstate->data;
     67        delete compstate;
    6668        return false;
    6769      }
     
    8991  GameStateCompressed *GameStateClient::popPartialGameState(){
    9092    GameState *gs = getPartialSnapshot();
    91     return compress_(gs);
     93    GameStateCompressed *cgs = compress_(gs);
     94    delete[] gs->data;
     95    delete gs;
     96    return cgs;
    9297  }
    9398 
     
    166171
    167172  GameState *GameStateClient::getPartialSnapshot(){
    168    
    169     GameState *reference;
    170 //     std::map<int, GameState*>::iterator it = --gameStateMap.end();
    171 //     reference=(--gameStateMap.end())->second;
    172    
    173173    //std::cout << "begin getSnapshot" << std::endl;
    174174    //the size of the gamestate
     
    306306    compressedGamestate->complete = a->complete;
    307307    compressedGamestate->base_id = a->base_id;
    308     delete[] a->data;
    309     delete a;
    310308    return compressedGamestate;
    311309  }
     
    344342    gamestate->complete = a->complete;
    345343
    346     delete[] a->data; //delete compressed data
    347     delete a; //we do not need the old (struct) gamestate anymore
    348344
    349345    return gamestate;
     
    353349    COUT(4) << "using diffed gamestate" << std::endl;
    354350    GameState *t = decode(diff);
    355     return undiff(old, t);
    356 //     return t;
     351    GameState *r = undiff(old, t);
     352    delete[] t->data;
     353    delete t;
     354    return r;
    357355  }
    358356
    359357  GameState *GameStateClient::decode(GameStateCompressed *x) {
    360358    GameState *t = decompress(x);
    361     /*GameState *t = new GameState;
    362     t->base_id = x->base_id;
    363     t->id = x->id;
    364     t->diffed = x->diffed;
    365     t->data = x->data;
    366     t->size = x->normsize;*/
     359    delete[] x->data;
     360    delete x;
    367361    return t;
    368362  }
  • code/branches/network3/src/network/GameStateManager.cc

    r1251 r1253  
    129129  bool GameStateManager::pushGameState( GameStateCompressed *gs, int clientID ){
    130130    GameState *ugs = decompress(gs);
    131     return loadPartialSnapshot(ugs, clientID);
    132    
     131    delete[] gs->data;
     132    delete gs;
     133    bool result = loadPartialSnapshot(ugs, clientID);
     134    delete[] ugs->data;
     135    delete ugs;
     136    return result;
    133137  }
    134138
     
    261265    }
    262266   
    263     delete[] state->data;
    264     delete state;
    265267    return true;
    266268  }
     
    280282    COUT(4) << "G.St.Man: this will be a DIFFED gamestate" << std::endl;
    281283    GameState *r = diff(a,b);
    282 //     r->diffed = true;
    283 //     GameState *r = b;
    284 //     r->diffed = false;
    285     return compress_(r);
    286     /*GameStateCompressed *g = new GameStateCompressed;
    287     g->base_id = r->base_id;
    288     g->id = r->id;
    289     g->diffed = r->diffed;
    290     g->data = r->data;
    291     g->normsize = r->size;
    292     g->compsize = r->size;
    293     return g*/;
     284    GameStateCompressed *c = compress_(r);
     285    delete[] r->data;
     286    delete r;
     287    return c;
    294288  }
    295289
    296290  GameStateCompressed *GameStateManager::encode(GameState *a) {
    297291    COUT(5) << "G.St.Man: encoding gamestate (compress)" << std::endl;
     292    a->base_id=GAMESTATEID_INITIAL;
    298293    return compress_(a);
    299294    /*GameStateCompressed *g = new GameStateCompressed;
  • code/branches/network3/src/network/Server.cc

    r1248 r1253  
    223223
    224224  void Server::processAck( ack *data, int clientID) {
    225     COUT(4) << "Server: processing ack from client: " << clientID << "; ack-id: " << data->a << std::endl;
     225    COUT(4) << "\b\b\b\n\n\n\n\nServer: processing ack from client: " << clientID << "; ack-id: " << data->a << std::endl;
    226226    gamestates->ackGameState(clientID, data->a);
    227227    delete data;
     
    240240    if(!gamestates->pushGameState(data, clientID))
    241241        COUT(3) << "Could not push gamestate\t\t\t\t=====" << std::endl;
    242     delete[] data->data;
    243     delete data;
    244242  }
    245243
Note: See TracChangeset for help on using the changeset viewer.