Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1180


Ignore:
Timestamp:
Apr 24, 2008, 6:01:12 PM (17 years ago)
Author:
scheusso
Message:

synchronisation made progress

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

Legend:

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

    r1168 r1180  
    108108    //std::cout << "states->compsize " << states->compsize << std::endl;
    109109    int gid = GAMESTATE; //first assign the correct enet id
    110     int totalLen = 4*sizeof( int ) + sizeof(bool) + states->compsize; //calculate the total size of the datastream memory
     110    int totalLen = 5*sizeof( int ) + sizeof(bool) + states->compsize; //calculate the total size of the datastream memory
    111111    //std::cout << "totalLen " << totalLen << std::endl;
    112112    unsigned char *data = (unsigned char*)malloc( totalLen ); //allocate the memory for datastream
     
    120120    memcpy( (void*)(data+5*sizeof( int ) + sizeof(bool)), (const void*)states->data, states->compsize );
    121121    //create an enet packet with the generated bytestream
     122    COUT(4) << "PacketGenerator generating totalLen " << totalLen << std::endl;
    122123    ENetPacket *packet = enet_packet_create( data , totalLen, reliable );
    123124    //delete data;
  • code/branches/network3/src/network/Synchronisable.cc

    r1177 r1180  
    7070  * @param size size of the datatype the variable consists of
    7171  */
    72   void Synchronisable::registerVar(const void *var, int size, variableType t){
     72  void Synchronisable::registerVar(void *var, int size, variableType t){
    7373    // create temporary synch.Var struct
    7474    synchronisableVariable *temp = new synchronisableVariable;
     
    155155      switch((*i)->type){
    156156      case DATA:
    157         std::memcpy( (void *)(retVal.data+n), (const void*)((*i)->var), (*i)->size);
     157        std::memcpy( (void *)(retVal.data+n), (void*)((*i)->var), (*i)->size);
    158158        n+=(*i)->size;
    159159        break;
    160160      case STRING:
    161         memcpy( (void *)(retVal.data+n), (const void *)&((*i)->size), sizeof(int) );
     161        memcpy( (void *)(retVal.data+n), (void *)&((*i)->size), sizeof(int) );
    162162        n+=sizeof(int);
    163         std::memcpy( retVal.data+n, (const void*)( ( (std::string *) (*i)->var)->c_str()), (*i)->size);
     163        const char *data = ( ( *(std::string *) (*i)->var).c_str());
     164        std::memcpy( retVal.data+n, (void*)data, (*i)->size);
     165        COUT(4) << "synchronisable: char: " << (const char *)(retVal.data+n) << " data: " << data << " string: " << *(std::string *)((*i)->var) << std::endl;
    164166        n+=(*i)->size;
    165167        break;
     
    191193      case STRING:
    192194        (*i)->size = *(int *)data;
     195        COUT(4) << "string size: " << (*i)->size << std::endl;
    193196        data+=sizeof(int);
    194197        *((std::string *)((*i)->var)) = std::string((const char*)data);
     198        COUT(4) << "synchronisable: char: " << (const char*)data << " string: " << std::string((const char*)data) << std::endl;
    195199        data += (*i)->size;
    196200        break;
     
    215219        tsize+=sizeof(int);
    216220        (*i)->size=((std::string *)(*i)->var)->length()+1;
     221        COUT(4) << "String size: " << (*i)->size << std::endl;
    217222        tsize+=(*i)->size;
    218223        break;
  • code/branches/network3/src/network/Synchronisable.h

    r1168 r1180  
    6262  typedef struct synchronisableVariable{
    6363    int size;
    64     const void *var;
     64    void *var;
    6565    variableType type;
    6666  }SYNCVAR;
     
    7979    int classID;
    8080
    81     void registerVar(const void *var, int size, variableType t);
     81    void registerVar(void *var, int size, variableType t);
    8282    //  syncData getData();
    8383    syncData getData(unsigned char *mem);
  • code/branches/network3/src/orxonox/objects/SpaceShip.cc

    r1064 r1180  
    158158
    159159    void SpaceShip::registerAllVariables(){
    160       Model::registerAllVariables();
    161160
    162161
Note: See TracChangeset for help on using the changeset viewer.