Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1432


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)

Location:
code/branches/network
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network/TODO

    r1293 r1432  
    1 very urgent: make sure receiver thread of connectionmanager is
    2 threadsafe (event_type_receive, findclient)
  • code/branches/network/src/network/ClientInformation.h

    r1431 r1432  
    4848#define GAMESTATEID_INITIAL -1
    4949#define CLIENTID_UNKNOWN -2
     50
     51// WATCH OUT: THE CLIENTINFORMATION LIST IS NOT THREADSAFE ANYMORE
    5052
    5153namespace network
  • code/branches/network/src/network/GameStateClient.cc

    r1431 r1432  
    238238    }
    239239    //retval->data = (unsigned char*)malloc(size);
     240    if(size==0)
     241      return NULL;
    240242    retval->data = new unsigned char[size];
    241243    if(!retval->data){
     
    283285      dest_length=diff->size;
    284286//     unsigned char *dp = (unsigned char *)malloc(dest_length*sizeof(unsigned char));
     287    if(dest_length==0)
     288      return NULL;
    285289    unsigned char *dp = new unsigned char[dest_length*sizeof(unsigned char)];
    286290    while(of<old->size && of<diff->size){
     
    322326
    323327    uLongf buffer = (uLongf)((a->size + 12)*1.01)+1;
     328    if(buffer==0)
     329      return NULL;
    324330    unsigned char *dest = new unsigned char[buffer];
    325331    int retval;
     
    358364      bufsize = normsize;
    359365//     unsigned char* dest = (unsigned char*)malloc( bufsize );
     366    if(bufsize==0)
     367      return NULL;
    360368    unsigned char *dest = new unsigned char[bufsize];
    361369    int retval;
  • code/branches/network/src/network/GameStateManager.cc

    r1431 r1432  
    193193    }
    194194    //retval->data = (unsigned char*)malloc(size);
     195    if(size==0)
     196      return NULL;
    195197    retval->data = new unsigned char[size];
    196198    if(!retval->data){
     
    347349    else*/
    348350      dest_length=neu->size;
     351    if(dest_length==0)
     352      return NULL;
    349353    //unsigned char *dp = (unsigned char *)malloc(dest_length*sizeof(unsigned char));
    350354    unsigned char *dp = new unsigned char[dest_length*sizeof(unsigned char)];
     
    387391    //COUT(4) << "size: " << size << ", buffer: " << buffer << std::endl;
    388392    //unsigned char* dest = (unsigned char*)malloc( buffer );
     393    if(buffer==0)
     394      return NULL;
    389395    unsigned char *dest = new unsigned char[buffer];
    390396    //COUT(4) << "dest: " << dest << std::endl;
     
    429435      bufsize = normsize;
    430436//     unsigned char* dest = (unsigned char*)malloc( bufsize );
     437    if(bufsize==0)
     438      return NULL;
    431439    unsigned char *dest = new unsigned char[bufsize];
    432440    int retval;
  • 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];
  • code/branches/network/src/network/PacketGenerator.cc

    r1360 r1432  
    8989  ENetPacket* command( int dataLength, void *data, int reliable = ENET_PACKET_FLAG_RELIABLE )
    9090  {
     91    if(dataLength==0)
     92      return NULL;
    9193    unsigned char *stream = new unsigned char[dataLength + 2*sizeof(int)];
    9294    if(!stream)
     
    150152    //std::cout << "totalLen " << totalLen << std::endl;
    151153    //unsigned char *data = (unsigned char*)malloc( totalLen ); //allocate the memory for datastream
     154    if(totalLen==0)
     155      return NULL;
    152156    unsigned char *data = new unsigned char[totalLen];
    153157    memcpy( (void*)(data), (const void*)&gid, sizeof( int ) ); //this is the enet id
     
    173177  {
    174178    //unsigned char* data = (unsigned char *)malloc(3*sizeof(int)+classname.length()+1);
     179    if(classname.length()==0)
     180      return NULL;
    175181    unsigned char *data = new unsigned char[3*sizeof(int)+classname.length()+1];
    176182    std::cout << "PacketGenerator: classid: " << classid << ", name: " << classname << std::endl;
  • code/branches/network/src/orxonox/Orxonox.cc

    r1422 r1432  
    494494        renderTime = 0.0f;
    495495      }
    496 
     496     
    497497      // Call those objects that need the real time
    498498      for (Iterator<TickableReal> it = ObjectList<TickableReal>::start(); it; ++it)
Note: See TracChangeset for help on using the changeset viewer.