Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 405 for code/branches/FICN/src


Ignore:
Timestamp:
Dec 5, 2007, 4:40:46 PM (17 years ago)
Author:
scheusso
Message:

corrected errors

Location:
code/branches/FICN/src/network
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • code/branches/FICN/src/network/Client.cc

    r401 r405  
    7373   */
    7474  bool Client::sendMouse(double x, double y){
    75     ENetEvent event;
    7675    // generate packet and add it to the queue
    7776    if(!client_connection.addPacket(pck_gen.mousem(x, y)))
     
    8786   */
    8887  bool Client::sendKeyboard(char key_code){
    89     ENetEvent event;
    9088    // generate packet and add it to queue
    9189    if(!client_connection.addPacket(pck_gen.keystrike(key_code)))
     
    115113   */
    116114  bool Client::addKeyboard(char key_code){
    117     ENetEvent event;
    118115    // generate packet and add it to queue
    119116    if(client_connection.addPacket(pck_gen.keystrike(key_code)))
     
    149146  }
    150147 
    151   void Client::processGamestate( GameState *data){
     148  void Client::processGamestate( GameStateCompressed *data){
    152149    gamestate.loadSnapshot( *data );
    153150    return;
  • code/branches/FICN/src/network/Client.h

    r400 r405  
    5656 
    5757  // implement data processing functions of PacketDecoder
    58   void processGamestate( GameState *data);
     58  void processGamestate( GameStateCompressed *data);
    5959  void processClassid(classid *clid);
    6060
  • code/branches/FICN/src/network/GameStateManager.cc

    r403 r405  
    2727 * @return struct of type gamestate containing the size of the whole gamestate and a pointer linking to the flat list
    2828 */
    29 GameState GameStateManager::getSnapshot(int id)
     29GameStateCompressed GameStateManager::getSnapshot(int id)
    3030{
    3131  //the size of the gamestate
     
    6363  }
    6464  retval.size=totalsize;
    65   return retval;
     65  return compress(retval);
    6666}
    6767
     
    7070 * @param state a GameState struct containing the size of the gamestate and a pointer linking to a flat list (returned by getSnapshot)
    7171 */
    72 bool GameStateManager::loadSnapshot(GameState state)
     72bool GameStateManager::loadSnapshot(GameStateCompressed compstate)
    7373{
     74  GameState state = decompress(compstate);
    7475  unsigned char *data=state.data;
    7576  // get the start of the Synchronisable list
     
    125126}
    126127
    127 GameState GameStateManager::encode(GameState a, GameState b){
     128GameStateCompressed GameStateManager::encode(GameState a, GameState b){
    128129  GameState r = diff(a,b);
    129130  return compress(r);
    130131}
    131132
    132 GameState GameStateManager::decode(GameState a, GameState x){
     133GameState GameStateManager::decode(GameState a, GameStateCompressed x){
    133134  GameState t = decompress(x);
    134135  return diff(a, t);
     
    167168}
    168169
    169 GameState GameStateManager::compress(GameState a){
    170   a.
    171   return a;
     170GameStateCompressed GameStateManager::compress(GameState a){
     171  //to be implemented
     172  GameStateCompressed b;
     173  return b;
    172174}
    173175
    174 GameState GameStateManager::decompress(GameState a){
     176GameState GameStateManager::decompress(GameStateCompressed a){
    175177  // to be implemented !!!!!!!!!!!!!!
    176   return a;
     178  GameState b;
     179  return b;
    177180}
    178181
  • code/branches/FICN/src/network/GameStateManager.h

    r403 r405  
    6262  GameStateManager();
    6363  ~GameStateManager();
    64   GameState getSnapshot(int id);
    65   bool loadSnapshot(GameState state);
    66   GameState encode(GameState a, GameState b);
    67   GameState decode(GameState a, GameState x);
     64  GameStateCompressed getSnapshot(int id);
     65  bool loadSnapshot(GameStateCompressed state);
     66  GameStateCompressed encode(GameState a, GameState b);
     67  GameState decode(GameState a, GameStateCompressed x);
    6868private:
    6969  void removeObject(orxonox::Iterator<Synchronisable> &it);
    7070  GameState diff(GameState a, GameState b);
    71   GameState compress(GameState a);
    72   GameState decompress(GameState a);
     71  GameStateCompressed compress(GameState a);
     72  GameState decompress(GameStateCompressed a);
    7373};
    7474
  • code/branches/FICN/src/network/PacketDecoder.cc

    r403 r405  
    121121        memcpy( (void*)&(currentState->normsize), (const void*)(data+3*sizeof( int )), sizeof( int ) );
    122122        //since data is not allocated, because it's just a pointer, allocate it with size of gamestatedatastream
    123         currentState->data = (unsigned char*)(malloc( currentState->size ));
     123        currentState->data = (unsigned char*)(malloc( currentState->compsize ));
    124124        //copy the GameStateCompressed data
    125125        memcpy( (void*)(currentState->data), (const void*)(data+4*sizeof( int )), currentState->compsize );
     
    186186{
    187187        cout << "id of GameStateCompressed:   " << data->id << endl;
    188         cout << "size of GameStateCompressed: " << data->size << endl;
     188        cout << "size of GameStateCompressed: " << data->compsize << endl;
    189189}
    190190
  • code/branches/FICN/src/network/PacketGenerator.cc

    r403 r405  
    7272ENetPacket* PacketGenerator::gstate( GameStateCompressed* states, int reliable )
    7373{
    74         int* gid; *gid = GAMESTATE; //first assign the correct enet id
    75         int totalLen = 3*sizeof( int ) + states->size; //calculate the total size of the datastream memory
     74        int* gid = new int;
     75        *gid = GAMESTATE; //first assign the correct enet id
     76        int totalLen = 3*sizeof( int ) + states->compsize; //calculate the total size of the datastream memory
    7677        unsigned char* data = (unsigned char*)malloc( totalLen ); //allocate the memory for datastream
    7778        memcpy( (void*)(data), (const void*)gid, sizeof( int ) ); //this is the enet id
  • code/branches/FICN/src/network/PacketManager.h

    r403 r405  
    3333        ENetPacket* keystrike( char press, int reliable = ENET_PACKET_FLAG_RELIABLE );
    3434        ENetPacket* chatMessage( const char* message, int reliable = ENET_PACKET_FLAG_RELIABLE );
    35         ENetPacket* gstate( GameState* states, int reliable = ENET_PACKET_FLAG_RELIABLE );
     35        ENetPacket* gstate( GameStateCompressed* states, int reliable = ENET_PACKET_FLAG_RELIABLE );
    3636        ENetPacket* clid( int classid, std::string classname, int reliable = ENET_PACKET_FLAG_RELIABLE );
    3737private:
     
    116116        void printKey( keyboard* data );
    117117        void printChat( chat* data );
    118         void printGamestate( GameState* data );
     118        void printGamestate( GameStateCompressed* data );
    119119    void printClassid( classid *cid);
    120120};
  • code/branches/FICN/src/network/Synchronisable.cc

    r401 r405  
    131131      return false; //there was some problem with registerVar
    132132  }
     133  return true;
    133134}
    134135
Note: See TracChangeset for help on using the changeset viewer.