Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 891


Ignore:
Timestamp:
Mar 13, 2008, 4:01:48 PM (17 years ago)
Author:
scheusso
Message:

some bugfixing/debug output

Location:
code/branches/network/src/network
Files:
6 edited

Legend:

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

    r790 r891  
    184184    while(!(client_connection.queueEmpty())){
    185185      packet = client_connection.getPacket();
    186       //std::cout << "tick packet size " << packet->dataLength << std::endl;
     186      COUT(5) << "tick gamestate packet size " << packet->dataLength << std::endl;
    187187      elaborate(packet, 0); // ================= i guess we got to change this .... (client_ID is always same = server)
    188188    }
     
    192192  void Client::processGamestate( GameStateCompressed *data){
    193193    gamestate.pushGameState(data);
    194     std::cout << "received gamestate id: " << data->id << std::endl;
     194    COUT(5) << "received gamestate id: " << data->id << std::endl;
    195195    client_connection.addPacket(pck_gen.acknowledgement(data->id));
    196196    client_connection.sendPackets();
     
    207207
    208208  void Client::processChat( chat *data){
    209     std::cout << "Server: " << data->message << std::endl;
     209    COUT(0) << "Server: " << data->message << std::endl;
    210210  }
    211211
  • code/branches/network/src/network/ClientConnection.cc

    r889 r891  
    4343
    4444#include "util/Sleep.h"
     45#include "orxonox/core/Debug.h"
    4546#include "ClientConnection.h"
    4647
  • code/branches/network/src/network/GameStateManager.cc

    r889 r891  
    7272      GameState *server = reference;
    7373      //head_->findClient(clientID)->setGamestateID(id);
    74       return encode(client, server);
     74      return *encode(client, server);
    7575    } else {
    7676      GameState *server = reference;
    7777      //head_->findClient(clientID)->setGamestateID(id);
    78       return encode(server);
     78      return *encode(server);
    7979      // return an undiffed gamestate and set appropriate flags
    8080    }
     
    142142  }
    143143
    144   GameStateCompressed GameStateManager::encode(GameState *a, GameState *b) {
     144  GameStateCompressed *GameStateManager::encode(GameState *a, GameState *b) {
    145145    //GameState r = diff(a,b);
    146146    //r.diffed = true;
    147     GameState r = *b;
    148     r.diffed = false;
    149     return compress_(&r);
    150   }
    151 
    152   GameStateCompressed GameStateManager::encode(GameState *a) {
     147    GameState *r = b;
     148    r->diffed = false;
     149    return compress_(r);
     150  }
     151
     152  GameStateCompressed *GameStateManager::encode(GameState *a) {
    153153    a->diffed=false;
    154154    return compress_(a);
    155155  }
    156156
    157   GameState GameStateManager::diff(GameState *a, GameState *b) {
     157  GameState *GameStateManager::diff(GameState *a, GameState *b) {
    158158    unsigned char *ap = a->data, *bp = b->data;
    159159    int of=0; // pointers offset
     
    182182      }
    183183    }
    184     // should be finished now
    185     // FIXME: is it true or false now? (struct has changed, producing warnings)
    186     GameState r = {b->id, dest_length, true, dp};
     184   
     185    GameState *r = new GameState;
     186    r->id = b->id;
     187    r->size = dest_length;
     188    r->diffed = true;
     189    r->data = dp;
    187190    return r;
    188191  }
    189192
    190   GameStateCompressed GameStateManager::compress_(GameState *a) {
     193  GameStateCompressed *GameStateManager::compress_(GameState *a) {
    191194    COUT(5) << "compressing gamestate" << std::endl;
    192195    int size = a->size;
     
    199202
    200203    switch ( retval ) {
    201       case Z_OK: std::cout << "successfully compressed" << std::endl; break;
    202       case Z_MEM_ERROR: std::cout << "not enough memory available" << std::endl; break;
    203       case Z_BUF_ERROR: std::cout << "not enough memory available in the buffer" << std::endl; break;
    204       case Z_DATA_ERROR: std::cout << "decompress: data corrupted" << std::endl; break;
    205     }
    206 
    207     GameStateCompressed compressedGamestate;
    208     compressedGamestate.compsize = buffer;
     204      case Z_OK: COUT(5) << "successfully compressed" << std::endl; break;
     205      case Z_MEM_ERROR: COUT(1) << "not enough memory available in gamestate.compress" << std::endl;
     206      return NULL;
     207      case Z_BUF_ERROR: COUT(2) << "not enough memory available in the buffer in gamestate.compress" << std::endl;
     208      return NULL;
     209      case Z_DATA_ERROR: COUT(2) << "decompress: data corrupted in gamestate.compress" << std::endl;
     210      return NULL;
     211    }
     212
     213    GameStateCompressed *compressedGamestate = new GameStateCompressed;
     214    compressedGamestate->compsize = buffer;
    209215//     std::cout << "compressedGamestate.compsize = buffer; " << buffer << std::endl;
    210     compressedGamestate.normsize = size;
     216    compressedGamestate->normsize = size;
    211217//     std::cout << "compressedGamestate.normsize = size; " << size << std::endl;
    212     compressedGamestate.id = a->id;
    213     compressedGamestate.data = dest;
    214     compressedGamestate.diffed = a->diffed;
     218    compressedGamestate->id = a->id;
     219    compressedGamestate->data = dest;
     220    compressedGamestate->diffed = a->diffed;
    215221
    216222    return compressedGamestate;
  • code/branches/network/src/network/GameStateManager.h

    r790 r891  
    4848  private:
    4949    GameState *getSnapshot(int id);
    50     GameStateCompressed encode(GameState *a, GameState *b);
    51     GameStateCompressed encode(GameState *a);
    52     GameState diff(GameState *a, GameState *b);
    53     GameStateCompressed compress_(GameState *a);
     50    GameStateCompressed *encode(GameState *a, GameState *b);
     51    GameStateCompressed *encode(GameState *a);
     52    GameState *diff(GameState *a, GameState *b);
     53    GameStateCompressed *compress_(GameState *a);
    5454    bool deleteUnusedGameState(int gamestateID);
    5555
  • code/branches/network/src/network/PacketDecoder.cc

    r889 r891  
    3838#include "PacketTypes.h"
    3939#include "PacketManager.h"
     40#include "orxonox/core/Debug.h"
    4041
    4142namespace network
  • code/branches/network/src/network/dummyclient3.cc

    r790 r891  
    1313  network::PacketGenerator pck;
    1414  const int PORT = 55556;
    15   std::cout << "Enter address of the server xxx.xxx.xxx.xxx (enter for localhost)" << std::endl;
     15  COUT(0) << "Enter address of the server xxx.xxx.xxx.xxx (enter for localhost)" << std::endl;
    1616  std::string str;
    1717  std::getline(std::cin, str);
    18   std::cout << "You entered: " << str << std::endl;
     18  COUT(3) << "You entered: " << str << std::endl;
    1919  if(str.compare("")==0)
    2020    str="127.0.0.1";
     
    2222  Client client( str, PORT );
    2323  if ( client.establishConnection() )
    24     std::cout << "connection established" << std::endl;
    25   else std::cout << "problems establishing connection" << std::endl;
     24    COUT(3) << "connection established" << std::endl;
     25  else COUT(0) << "problems establishing connection" << std::endl;
    2626  char message[10000];
    2727  char signs[] = "abcdefghijklmnopqrstuvwxy";
Note: See TracChangeset for help on using the changeset viewer.