Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 26, 2008, 10:06:36 PM (16 years ago)
Author:
scheusso
Message:

found a bug in gamestate diffing (in some cases the gamestate diffed was
filled with zeros at the end)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network/src/network/PacketDecoder.cc

    r1360 r1432  
    127127  bool PacketDecoder::command( ENetPacket* packet, int clientId ){
    128128    int length = *(int*)((unsigned char *)packet->data+sizeof(int));
     129    if(length<=0)
     130      return false;
    129131    void *data = (void *)new unsigned char[length];
    130132    memcpy(data, (void *)(packet->data+2*sizeof(int)), length);
     
    158160  {
    159161    chat* chatting = new chat;
     162    if(packet->dataLength==4)
     163      return;
    160164    chatting->id = (int)*packet->data; //first copy id into new struct
    161165    //since the chat message is a char*, allocate the memory needed
     
    204208      COUT(2) << "PacketDecoder: compsize is 0" << std::endl;
    205209//     currentState->data = (unsigned char*)(malloc( currentState->compsize ));
     210    if(currentState->compsize==0)
     211      return;
    206212    currentState->data = new unsigned char[currentState->compsize];
    207213    if(currentState->data==NULL)
     
    221227    cid->id = ((classid *)(packet->data))->id;
    222228    cid->clid = ((classid *)(packet->data))->clid;
     229    if(cid->length==0)
     230      return;
    223231//     cid->message = (const char *)malloc(cid->length);
    224232    cid->message = new char[cid->length];
Note: See TracChangeset for help on using the changeset viewer.