Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8362 in orxonox.OLD for trunk/src/lib/network


Ignore:
Timestamp:
Jun 14, 2006, 10:08:41 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: removed stupid included in base_object.h
this should lead to faster compile-times

Location:
trunk/src/lib/network
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/network/connection_monitor.h

    r8068 r8362  
    1111
    1212#include <map>
     13#include <list>
    1314
    1415#define N_PACKETS_FOR_PING 20
     
    2425    void processUnzippedOutgoingPacket( int tick, byte * data, int length, int stateId );
    2526    void processUnzippedIncomingPacket( int tick, byte * data, int length, int stateId, int ackedState );
    26    
     27
    2728    void processZippedOutgoingPacket( int tick, byte * data, int length, int stateId );
    2829    void processZippedIncomingPacket( int tick, byte * data, int length );
    29    
     30
    3031    void calculatePing();
    31    
     32
    3233    bool hasTimedOut();
    33    
     34
    3435    void printStatis();
    35    
     36
    3637  private:
    3738    float calculateBandWidth( std::map<int,int> packetHistory, int tick );
    38    
    39     int userId;       //!< user's id 
     39
     40    int userId;       //!< user's id
    4041
    4142    std::map<int,int>   sentStateTicks;
    42    
     43
    4344    std::map<int,int>   incomingUnzippedPacketHistory;
    4445    std::map<int,int>   outgoingUnzippedPacketHistory;
    45    
     46
    4647    std::map<int,int>   incomingZippedPacketHistory;
    4748    std::map<int,int>   outgoingZippedPacketHistory;
    48    
     49
    4950    std::list<int>      ackDelay;
    5051    int                 ping;
     
    5253    float               incomingUnzippedBandWidth;
    5354    float               outgoingUnzippedBandWidth;
    54    
     55
    5556    float               incomingZippedBandWidth;
    5657    float               outgoingZippedBandWidth;
    57    
     58
    5859    int                 nIncomingPackets;
    5960    int                 nOutgoingPackets;
    60    
     61
    6162    int                 nZIncomingPackets;
    6263    int                 nZOutgoingPackets;
    63    
     64
    6465    int                 lastPacketTick;
    65    
     66
    6667    int                 lastPrintTick;
    6768  };
  • trunk/src/lib/network/converter.cc

    r7954 r8362  
    2323#include "converter.h"
    2424#include "shell_command.h"
    25 
     25#include "debug.h"
    2626#include <limits>
    2727
     
    489489  {
    490490    PRINTF(1)("something went wrong length > remaining bytes in buffer\n" );
    491    
     491
    492492    //TODO remove this
    493493    for ( int i = -1000; i < 1001; i++ )
     
    499499    }
    500500    printf("\n");
    501    
     501
    502502    s = "";
    503503    return -1;
  • trunk/src/lib/network/handshake.cc

    r7954 r8362  
    2323
    2424#include <cassert>
     25#include "debug.h"
    2526
    2627Handshake::Handshake( bool server, int clientId, int networkGameManagerId, int messageManagerId )
     
    3132
    3233  this->setIsServer(server);
    33  
     34
    3435  orxId_handler = registerVarId( new SynchronizeableInt( &localState.orxId, &remoteState.orxId, "orxonoxId", PERMISSION_ALL ) );
    3536  version_handler = registerVarId( new SynchronizeableInt( &localState.version, &remoteState.version, "version", PERMISSION_ALL ) );
     
    4041  error_handler = registerVarId( new SynchronizeableInt( &localState.error, &remoteState.error, "error", PERMISSION_ALL ) );
    4142  errorString_handler = registerVarId( new SynchronizeableString( &localState.errorString, &remoteState.errorString, "errorString", PERMISSION_ALL ) );
    42  
     43
    4344  candel_id = registerVarId( new SynchronizeableInt( &localState.canDel, &remoteState.canDel, "canDel", PERMISSION_ALL ) );
    44  
     45
    4546  localState.completed = 0;
    4647  localState.error = 0;
     
    5253  localState.version = _ORXONOX_VERSION;
    5354  localState.canDel = 0;
    54  
     55
    5556  remoteState.completed = 0;
    5657  remoteState.error = 0;
     
    8687
    8788    }
    88      
     89
    8990    if ( *it == version_handler )
    9091    {
     
    9899
    99100    }
    100    
     101
    101102    if ( *it == candel_id )
    102103    {
    103104      PRINTF(0)("handshake finished candel changed\n");
    104105    }
    105    
     106
    106107  }
    107  
     108
    108109  if (
    109110      remoteState.orxId == _ORXONOX_ID &&
  • trunk/src/lib/network/network_game_manager.cc

    r8228 r8362  
    3939#include "network_game_manager.h"
    4040
     41#include "debug.h"
     42
    4143
    4244/* using namespace std is default, this needs to be here */
     
    5759
    5860  this->setSynchronized(true);
    59  
     61
    6062  MessageManager::getInstance()->registerMessageHandler( MSGID_DELETESYNCHRONIZEABLE, delSynchronizeableHandler, NULL );
    6163  MessageManager::getInstance()->registerMessageHandler( MSGID_PREFEREDTEAM, preferedTeamHandler, NULL );
    62  
     64
    6365  this->gameState = 0;
    6466  registerVar( new SynchronizeableInt( &gameState, &gameState, "gameState" ) );
     
    7577/**
    7678 * insert new player into game
    77  * @param userId 
    78  * @return 
     79 * @param userId
     80 * @return
    7981 */
    8082bool NetworkGameManager::signalNewPlayer( int userId )
     
    8385  assert( State::getGameRules() );
    8486  assert( State::getGameRules()->isA( CL_NETWORK_GAME_RULES ) );
    85  
     87
    8688  NetworkGameRules & rules = *(dynamic_cast<NetworkGameRules*>(State::getGameRules()));
    87  
     89
    8890  int team = rules.getTeamForNewUser();
    8991  ClassID playableClassId = rules.getPlayableClassId( userId, team );
    9092  std::string playableModel = rules.getPlayableModelFileName( userId, team, playableClassId );
    91  
     93
    9294  BaseObject * bo = Factory::fabricate( playableClassId );
    93  
     95
    9496  assert( bo != NULL );
    9597  assert( bo->isA( CL_PLAYABLE ) );
    96  
     98
    9799  Playable & playable = *(dynamic_cast<Playable*>(bo));
    98  
     100
    99101  playable.loadModel( playableModel );
    100102  playable.setOwner( userId );
    101103  playable.setUniqueID( SharedNetworkData::getInstance()->getNewUniqueID() );
    102104  playable.setSynchronized( true );
    103  
     105
    104106  PlayerStats * stats = rules.getNewPlayerStats( userId );
    105  
     107
    106108  stats->setUniqueID( SharedNetworkData::getInstance()->getNewUniqueID() );
    107109  stats->setSynchronized( true );
    108110  stats->setOwner( getHostID() );
    109  
     111
    110112  stats->setTeamId( team );
    111113  stats->setPlayableClassId( playableClassId );
    112114  stats->setPlayableUniqueId( playable.getUniqueID() );
    113115  stats->setModelFileName( playableModel );
    114  
     116
    115117  return true;
    116118}
     
    119121/**
    120122 * remove player from game
    121  * @param userID 
    122  * @return 
     123 * @param userID
     124 * @return
    123125 */
    124126bool NetworkGameManager::signalLeftPlayer(int userID)
     
    130132    delete PlayerStats::getStats( userID );
    131133  }
    132  
     134
    133135  return true;
    134136}
     
    138140/**
    139141 * handler for remove synchronizeable messages
    140  * @param messageId 
    141  * @param data 
    142  * @param dataLength 
    143  * @param someData 
    144  * @param userId 
     142 * @param messageId
     143 * @param data
     144 * @param dataLength
     145 * @param someData
     146 * @param userId
    145147 * @return true on successfull handling else handler will be called again
    146148 */
     
    152154    return true;
    153155  }
    154  
     156
    155157  int uniqueId = 0;
    156158  int len = Converter::byteArrayToInt( data, &uniqueId );
    157  
     159
    158160  if ( len != dataLength )
    159161  {
     
    161163    return true;
    162164  }
    163  
     165
    164166  const std::list<BaseObject*> * list = ClassList::getList( CL_SYNCHRONIZEABLE );
    165  
     167
    166168  for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
    167169  {
     
    173175        return true;
    174176      }
    175      
     177
    176178      delete dynamic_cast<Synchronizeable*>(*it);
    177179      return true;
    178180    }
    179181  }
    180  
     182
    181183  return true;
    182184}
     
    189191{
    190192  byte buf[INTSIZE];
    191  
     193
    192194  assert( Converter::intToByteArray( uniqueId, buf, INTSIZE ) == INTSIZE );
    193  
     195
    194196  MessageManager::getInstance()->sendMessage( MSGID_DELETESYNCHRONIZEABLE, buf, INTSIZE, RT_ALL_NOT_ME, 0, MP_HIGHBANDWIDTH );
    195197}
     
    199201/**
    200202 * handler for MSGID_PREFEREDTEAM message
    201  * @param messageId 
    202  * @param data 
    203  * @param dataLength 
    204  * @param someData 
    205  * @param userId 
    206  * @return 
     203 * @param messageId
     204 * @param data
     205 * @param dataLength
     206 * @param someData
     207 * @param userId
     208 * @return
    207209 */
    208210bool NetworkGameManager::preferedTeamHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId )
    209211{
    210212  assert( NetworkGameManager::getInstance()->isServer() );
    211  
     213
    212214  int teamId = 0;
    213215  int len = Converter::byteArrayToInt( data, &teamId );
    214  
     216
    215217  if ( len != dataLength )
    216218  {
     
    218220    return true;
    219221  }
    220  
     222
    221223  NetworkGameManager::getInstance()->setPreferedTeam( userId, teamId );
    222  
     224
    223225  return true;
    224226}
     
    228230  if ( !PlayerStats::getStats( userId ) )
    229231    return;
    230  
     232
    231233  PlayerStats & stats = *(PlayerStats::getStats( userId ));
    232  
     234
    233235  stats.setPreferedTeamId( teamId );
    234236}
     
    236238/**
    237239 * set prefered team for this host
    238  * @param teamId 
     240 * @param teamId
    239241 */
    240242void NetworkGameManager::prefereTeam( int teamId )
     
    245247  {
    246248    byte buf[INTSIZE];
    247    
     249
    248250    assert( Converter::intToByteArray( teamId, buf, INTSIZE) == INTSIZE );
    249    
     251
    250252    MessageManager::getInstance()->sendMessage( MSGID_PREFEREDTEAM, buf, INTSIZE, RT_USER, 0, MP_HIGHBANDWIDTH );
    251253  }
  • trunk/src/lib/network/player_stats.cc

    r8228 r8362  
    2323#include "shared_network_data.h"
    2424
     25#include "debug.h"
     26
    2527
    2628CREATE_FACTORY(PlayerStats, CL_PLAYER_STATS);
     
    3234{
    3335  init();
    34  
     36
    3537  this->userId = userId;
    3638}
     
    5456  this->playableClassId = 0;
    5557  this->modelFileName = "";
    56  
     58
    5759  userId_handle = registerVarId( new SynchronizeableInt( &userId, &userId, "userId" ) );
    5860  teamId_handle = registerVarId( new SynchronizeableInt( &teamId, &teamId, "teamId" ) );
     
    6264  playableUniqueId_handle = registerVarId( new SynchronizeableInt( &playableUniqueId, &playableUniqueId, "playableUniqueId" ) );
    6365  modelFileName_handle = registerVarId( new SynchronizeableString( &modelFileName, &modelFileName, "modelFileName" ) );
    64  
     66
    6567  PRINTF(0)("PlayerStats created\n");
    6668}
     
    8587  {
    8688    this->setPlayableUniqueId( this->playableUniqueId );
    87    
     89
    8890    PRINTF(0)("uniqueID changed %d %d %d\n", userId, getHostID(), getUniqueID());
    8991  }
     
    98100{
    99101  const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS );
    100  
     102
    101103  if ( !list )
    102104  {
    103105    return NULL;
    104106  }
    105  
     107
    106108  for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
    107109  {
     
    111113    }
    112114  }
    113  
     115
    114116  return NULL;
    115117}
     
    121123{
    122124  const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYABLE );
    123  
     125
    124126  if ( !list )
    125127  {
     
    127129    return;
    128130  }
    129  
     131
    130132  this->playable = NULL;
    131133  for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
     
    139141    }
    140142  }
    141  
     143
    142144  if ( this->playable && userId == getHostID() )
    143145  {
    144146    State::getPlayer()->setPlayable( this->playable );
    145147  }
    146  
     148
    147149  this->playableUniqueId = uniqueId;
    148150}
     
    156158  if ( playable )
    157159    return playable;
    158  
     160
    159161  assert( playableUniqueId > 0 );
    160  
     162
    161163  setPlayableUniqueId( playableUniqueId );
    162  
     164
    163165  assert( playable );
    164  
     166
    165167  return playable;
    166168}
  • trunk/src/lib/network/udp_server_socket.cc

    r8228 r8362  
    1515
    1616#include "udp_server_socket.h"
     17#include "debug.h"
    1718
    1819
     
    2021/**
    2122 * constructor
    22  * @param port port to listen on 
     23 * @param port port to listen on
    2324 */
    2425UdpServerSocket::UdpServerSocket( int port ) : ServerSocket( port )
    2526{
    2627  packet = SDLNet_AllocPacket( UDP_PACKET_SIZE );
    27  
     28
    2829  if ( !packet )
    2930  {
    3031    PRINTF(1)("SDLNet_AllocPacket: %s\n", SDLNet_GetError());
    31    
     32
    3233    assert( false );
    3334    bOk = false;
    3435  }
    35  
     36
    3637  memset( packet->data, 0, UDP_PACKET_SIZE );
    37  
     38
    3839  listen( port );
    3940}
     
    4647  for ( int i = 0; i < (int)packetBuffer.size(); i++ )
    4748    removeUserPackets( i );
    48  
     49
    4950  if ( packet )
    5051    SDLNet_FreePacket( packet );
    51  
     52
    5253  if ( socket )
    5354    SDLNet_UDP_Close( socket );
     
    6263{
    6364  socket = SDLNet_UDP_Open( port );
    64  
     65
    6566  PRINTF(0)("listening on port: %d\n", port);
    66  
     67
    6768  if ( !socket )
    6869  {
    69    
     70
    7071    bOk = false;
    7172    return false;
    7273  }
    73  
     74
    7475  return true;
    7576}
     
    8283{
    8384  NetworkSocket * result = NULL;
    84  
     85
    8586  if ( newSocketList.size() > 0 )
    8687  {
    8788    result = newSocketList.front();
    88  
     89
    8990    newSocketList.pop_front();
    9091  }
    91  
     92
    9293  return result;
    9394}
     
    9899void UdpServerSocket::close( )
    99100{
    100  
     101
    101102  for ( int i = 0; i < (int)packetBuffer.size(); i++ )
    102103    removeUserPackets( i );
    103  
     104
    104105  packetBuffer.clear();
    105106  userList.clear();
    106  
     107
    107108  SDLNet_UDP_Close( socket );
    108109  socket = NULL;
     
    117118  if ( userId >= (int)packetBuffer.size() )
    118119    return;
    119  
     120
    120121  for ( NetworkPacketList::iterator it = packetBuffer[userId].begin(); it!=packetBuffer[userId].end(); it++ )
    121122  {
     
    126127    }
    127128  }
    128  
     129
    129130  packetBuffer[userId].clear();
    130131}
     
    140141  res.data = NULL;
    141142  res.length = 0;
    142  
     143
    143144  if ( (int)packetBuffer.size() > userId && (int)packetBuffer[userId].size() > 0 )
    144145  {
     
    146147    res.length = packetBuffer[userId].front().length;
    147148    packetBuffer[userId].pop_front();
    148    
     149
    149150    if ( res.length == 0 )
    150151      res.length = -1;
    151152  }
    152  
     153
    153154  return res;
    154155}
     
    163164  if ( userId >= (int)packetBuffer.size() )
    164165    return -1;
    165  
     166
    166167  return packetBuffer[userId].size();
    167168}
    168169
    169170/**
    170  * will set user state 
     171 * will set user state
    171172 * @param userId users id
    172173 * @param ip users host / port
     
    175176{
    176177  int channel = SDLNet_UDP_Bind( socket, userId, &ip );
    177   if( channel != userId ) 
     178  if( channel != userId )
    178179  {
    179180    PRINTF(1)("SDLNet_UDP_Bind: %s\n", SDLNet_GetError());
     
    181182    return;
    182183  }
    183  
     184
    184185  if ( userId < (int)packetBuffer.size() )
    185186    removeUserPackets( userId );
    186  
     187
    187188  if ( (int)packetBuffer.size() <= userId )
    188189    packetBuffer.resize( userId + 1 );
    189  
     190
    190191  if ( (int)userList.size() <= userId )
    191192    userList.resize( userId + 1 );
    192  
     193
    193194  userList[ userId ] = ip;
    194195}
     
    201202{
    202203  removeUserPackets( userId );
    203  
     204
    204205  if ( userId >= (int)userList.size() )
    205206    return;
    206  
     207
    207208  userList[userId].host = 0;
    208209  userList[userId].port = 0;
    209  
     210
    210211  SDLNet_UDP_Unbind( socket, userId );
    211212}
     
    220221{
    221222  assert( networkPacket.length <= UDP_PACKET_SIZE );
    222  
     223
    223224  memcpy( packet->data, networkPacket.data, networkPacket.length );
    224225  packet->len = networkPacket.length;
    225226  packet->channel = -1;
    226  
     227
    227228  if ( SDLNet_UDP_Send( socket, userId, packet ) == 0 )
    228229  {
     
    230231    return false;
    231232  }
    232  
     233
    233234  return true;
    234235}
     
    241242  int res;
    242243  int newConn = 0;
    243  
     244
    244245  for ( res = SDLNet_UDP_Recv( socket, packet ); res == 1; res = SDLNet_UDP_Recv( socket, packet ) )
    245246  {
    246247    int userId;
    247248    bool isNewConnection = false;
    248    
     249
    249250    for ( userId =0; userId < (int)userList.size(); userId++ )
    250251      if ( userList[userId].host == packet->address.host && userList[userId].port == packet->address.port )
    251252        break;
    252    
     253
    253254    if ( userId >= (int)userList.size() )
    254255    {
    255      
     256
    256257      newConn++;
    257258      isNewConnection = true;
    258      
     259
    259260      if ( newConn > MAX_NEW_CONNECTIONS )
    260261      {
     
    262263        continue;
    263264      }
    264      
     265
    265266      for ( userId =0; userId < (int)userList.size(); userId++ )
    266267        if ( userList[userId].host == 0 && userList[userId].port == 0 )
    267268          break;
    268      
     269
    269270      initUser( userId, packet->address );
    270271      UdpSocket * sock = new UdpSocket( this, packet->address, userId );
     
    272273      PRINTF(0)("NEW CONNECTION %x\n", packet->address.host );
    273274    }
    274    
     275
    275276    //add new packet to packetbuffer
    276277
     
    290291
    291292  }
    292  
     293
    293294  assert( res == 0 );
    294295}
  • trunk/src/lib/network/udp_socket.cc

    r8228 r8362  
    1616#include "udp_socket.h"
    1717#include "udp_server_socket.h"
     18#include "debug.h"
    1819
    1920
     
    3637  init();
    3738  this->packet = SDLNet_AllocPacket( UDP_PACKET_SIZE );
    38  
     39
    3940  assert( this->packet );
    40  
     41
    4142  memset( packet->data, 0, UDP_PACKET_SIZE );
    4243  PRINTF(0)("PACKET DATA: %x\n", packet->data);
    43  
     44
    4445  this->connectToServer( host, port );
    4546}
     
    5253  this->init();
    5354  this->packet = SDLNet_AllocPacket( UDP_PACKET_SIZE );
    54  
     55
    5556  if ( !packet )
    5657  {
    5758    PRINTF(1)("SDLNet_AllocPacket: %s\n", SDLNet_GetError());
    58    
     59
    5960    assert( false );
    6061    bOk = false;
    6162  }
    62  
     63
    6364}
    6465
     
    8283{
    8384  this->disconnectServer();
    84  
     85
    8586  if ( serverSocket )
    8687    serverSocket->removeUser( userId );
     
    8889  if ( this->packet )
    8990    SDLNet_FreePacket( this->packet );
    90  
     91
    9192  if ( socket )
    9293    SDLNet_UDP_Close( socket );
     
    101102{
    102103  assert( serverSocket == NULL );
    103  
     104
    104105  IPaddress ip;
    105  
     106
    106107  PRINTF(0)("connect to server %s on port %d\n", host.c_str(), port);
    107  
     108
    108109  if ( SDLNet_ResolveHost( &ip, host.c_str(), port ) != 0 )
    109110  {
     
    112113    return;
    113114  }
    114  
     115
    115116  socket = SDLNet_UDP_Open(0);
    116117  if ( !socket )
     
    120121    return;
    121122  }
    122  
     123
    123124  int channel = SDLNet_UDP_Bind(socket, 1, &ip);
    124   if ( channel == -1 ) 
     125  if ( channel == -1 )
    125126  {
    126127    PRINTF(1)("SDLNet_UDP_Bind: %s\n", SDLNet_GetError());
     
    167168  {
    168169    assert( length <= packet->maxlen );
    169    
     170
    170171    memcpy( packet->data, data, length );
    171172    packet->len = length;
    172    
     173
    173174    if ( socket && SDLNet_UDP_Send( socket, 1, packet) == 0 )
    174175    {
     
    177178      return false;
    178179    }
    179    
     180
    180181    return true;
    181182  }
     
    191192{
    192193  assert( maxLength <= UDP_PACKET_SIZE );
    193  
     194
    194195  if ( serverSocket )
    195196  {
    196197    NetworkPacket networkPacket = serverSocket->getPacket( this->userId );
    197    
     198
    198199    if ( networkPacket.length == -1 )
    199200    {
     
    201202      return 0;
    202203    }
    203    
     204
    204205    if ( networkPacket.length > 0 )
    205206    {
    206207      assert( maxLength > networkPacket.length );
    207      
     208
    208209      memcpy( data, networkPacket.data, networkPacket.length );
    209210    }
    210    
     211
    211212    if ( networkPacket.data )
    212213    {
     
    214215      networkPacket.data = NULL;
    215216    }
    216    
     217
    217218    return networkPacket.length;
    218219  }
     
    220221  {
    221222    int numrecv = SDLNet_UDP_Recv( socket, packet);
    222     if ( numrecv > 0) 
     223    if ( numrecv > 0)
    223224    {
    224225      assert( packet->len <= maxLength );
    225      
     226
    226227      if ( packet->len == 0 )
    227228      {
     
    229230        return 0;
    230231      }
    231      
     232
    232233      memcpy( data, packet->data, packet->len );
    233234      return packet->len;
     
    244245    }
    245246  }
    246  
     247
    247248  return 0;
    248249}
  • trunk/src/lib/network/zip.cc

    r7954 r8362  
    1717
    1818#include "src/lib/util/loading/resource_manager.h"
     19#include "debug.h"
    1920
    2021/**
     
    5455  fileName = fileName + "/dicts/" + name;
    5556  //PRINTF(0)("filename: %s\n", fileName.c_str());
    56  
     57
    5758  FILE * f = fopen( fileName.c_str(), "r" );
    58  
     59
    5960  if ( !f )
    6061  {
     
    6263    return false;
    6364  }
    64  
     65
    6566  byte buf[1024];
    66  
     67
    6768  int nBytesRead = 0;
    68  
     69
    6970  while ( !feof( f ) )
    7071  {
    7172    nBytesRead += fread( buf, 1, sizeof(buf), f );
    7273  }
    73  
     74
    7475  DictionaryEntry entry;
    75  
     76
    7677  entry.dictLen = nBytesRead;
    7778  entry.dict = new Byte[nBytesRead];
    78  
     79
    7980  fseek( f, 0, SEEK_SET );
    80  
     81
    8182  assert( fread( entry.dict, 1, nBytesRead, f ) == nBytesRead );
    82  
     83
    8384  entry.adler = adler32( adler32( 0L, Z_NULL, 0 ), entry.dict, nBytesRead );
    84  
     85
    8586  dicts.push_back( entry );
    86  
     87
    8788  PRINTF(3)("Loaded dictionary '%s' with adler = %d\n", name.c_str(), entry.adler );
    88  
     89
    8990  return true;
    9091}
     
    106107    return -1;
    107108  }
    108  
     109
    109110  int res;
    110111
     
    124125
    125126  res = deflateSetDictionary( &strm, (Bytef*)(dicts[dict].dict), dicts[dict].dictLen );
    126        
     127
    127128  if ( res != Z_OK )
    128129  {
     
    139140
    140141  res = deflate( &strm, Z_FINISH );
    141        
     142
    142143  if ( res != Z_STREAM_END )
    143144  {
     
    152153
    153154  res = deflateEnd( &strm );
    154        
     155
    155156  if ( res != Z_OK )
    156157  {
     
    161162    else
    162163      PRINTF(1)("deflateEnd error: dont know\n");
    163    
    164     return -1;
    165   }
    166  
     164
     165    return -1;
     166  }
     167
    167168  return zippedlen;
    168169
     
    181182  z_stream strm;
    182183  int res = 0;
    183  
     184
    184185  strm.zalloc = Z_NULL;
    185186  strm.zfree = Z_NULL;
     
    193194    return -1;
    194195  }
    195        
     196
    196197  strm.next_out = (Bytef*)to;
    197198  strm.avail_out = maxLength;
     
    202203
    203204  assert( inflate( &strm, Z_NO_FLUSH ) == Z_NEED_DICT );
    204        
     205
    205206  int dictId = -1;
    206  
     207
    207208  for ( int i = 0; i < dicts.size(); i++ )
    208209  {
     
    213214    }
    214215  }
    215  
     216
    216217  if ( dictId == -1 )
    217218  {
     
    219220    return -1;
    220221  }
    221      
     222
    222223  res = inflateSetDictionary( &strm, (Bytef*)dicts[dictId].dict, dicts[dictId].dictLen );
    223        
     224
    224225  if ( res != Z_OK )
    225226  {
     
    230231
    231232  res = inflate( &strm, Z_FINISH );
    232        
     233
    233234  if ( res != Z_STREAM_END )
    234235  {
     
    243244
    244245  res = inflateEnd( &strm );
    245        
     246
    246247  if ( res != Z_OK )
    247248  {
     
    249250    return -1;
    250251  }
    251  
     252
    252253  return unzippedlen;
    253254}
Note: See TracChangeset for help on using the changeset viewer.