Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6668 in orxonox.OLD


Ignore:
Timestamp:
Jan 24, 2006, 2:23:44 PM (18 years ago)
Author:
patrick
Message:

network: restructured the writeBytes a little bit and added the new functions

Location:
branches/network/src/lib/network
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/lib/network/network_game_manager.cc

    r6667 r6668  
    8282    b = data[i++];
    8383
     84    /**************** Commands only processed by servers ****************/
    8485    if ( isServer() )
    8586    {
     
    9091        continue;
    9192      }
    92       if ( b == NET_REQUEST_REMOVE )
     93      else if ( b == NET_REQUEST_REMOVE )
    9394      {
    9495        if ( !handleRequestRemove( i, data, length, sender ) )
     
    9697        continue;
    9798      }
    98       if ( b == NET_REQUEST_PNODE_PATH )
     99      else if ( b == NET_REQUEST_PNODE_PATH )
    99100      {
    100101        if ( !handleRequestPNodePath( i, data, length, sender ) )
     
    102103        continue;
    103104      }
     105      else
     106      {
     107        PRINTF(1)("Network is asynchronous: couldn't decode the command sent by %i\n", sender);
     108        PRINTF(1)("Probably this is because the network protocol has different \n");
     109        PRINTF(1)("versions or there occured an error in the sending algorithm\n");
     110      }
    104111    }
    105112    else
    106113    {
     114      /**************** Commands only processed by clients ****************/
    107115      if ( b == NET_CREATE_ENTITY )
    108116      {
     
    112120        continue;
    113121      }
    114       if ( b == NET_REMOVE_ENTITY )
     122      else if ( b == NET_REMOVE_ENTITY )
    115123      {
    116124        if ( !handleRemoveEntity( i, data, length, sender ) )
     
    118126        continue;
    119127      }
    120       if ( b == NET_CREATE_ENTITY_LIST )
     128      else if ( b == NET_CREATE_ENTITY_LIST )
    121129      {
    122130        if ( !handleCreateEntityList( i, data, length, sender ) )
     
    124132        continue;
    125133      }
    126       if ( b == NET_REMOVE_ENTITY_LIST )
     134      else if ( b == NET_REMOVE_ENTITY_LIST )
    127135      {
    128136        if ( !handleRemoveEntityList( i, data, length, sender ) )
     
    130138        continue;
    131139      }
    132       if ( b == NET_YOU_ARE_ENTITY )
     140      else if ( b == NET_YOU_ARE_ENTITY )
    133141      {
    134142        if ( !handleYouAreEntity( i, data, length, sender ) )
     
    138146    }
    139147
     148    /**************** Commands processed by servers and clients ****************/
    140149    if ( b == NET_REQUEST_ENTITY_LIST )
    141150    {
     
    143152      continue;
    144153    }
    145 
    146     if ( b == NET_REQUEST_SYNC )
     154    else if ( b == NET_REQUEST_SYNC )
    147155    {
    148156      if ( !handleRequestSync( i, data, length, sender ) )
     
    151159    }
    152160
    153     //if we get her something with data is wrong
     161
     162    PRINTF(1)("Network is asynchronous: couldn't decode the command sent by %i\n", sender);
     163    PRINTF(1)("Probably this is because the network protocol has different \n");
     164    PRINTF(1)("versions or there occured an error in the sending algorithm\n");
    154165    PRINTF(1)("Data is not in the right format! i=%d\n", i);
    155166    return i;
     
    869880
    870881
     882/**
     883 *  handles the network signal NET_REQUEST_PNODE_PATH
     884 * @param i byte offset in the buffer
     885 * @param data data array
     886 * @param length length of the data arary
     887 * @param sender the sender id
     888 * @return true if process terminated sucessfully
     889 */
    871890bool NetworkGameManager::handleRequestPNodePath(int& i, const byte* data, int length, int sender)
    872 {}
     891{
     892  if( INTSIZE > length-i )
     893  {
     894    PRINTF(1)("Cannot read n from buffer! Not enough data left!\n");
     895    return false;
     896  }
     897  PRINTF(0)("HandleRequestPNodePath:  data[i..i+3] = %d %d %d %d\n", data[i], data[i+1], data[i+2], data[i+3]);
     898
     899  int uniqueID1, uniqueID2;
     900  if( INTSIZE > length-i )
     901  {
     902    PRINTF(1)("Cannot read uniqueID from buffer! Not enough data left!\n");
     903    return false;
     904  }
     905  i += Converter::byteArrayToInt( &data[i], &uniqueID1 );
     906
     907  if( INTSIZE > length-i )
     908  {
     909    PRINTF(1)("Cannot read uniqueID from buffer! Not enough data left!\n");
     910    return false;
     911  }
     912  i += Converter::byteArrayToInt( &data[i], &uniqueID2 );
     913
     914
     915  PRINTF(0)("HandleRequestPNodePath: got a request for path from uid %i to uid %i\n", uniqueID1, uniqueID2);
     916
     917  return true;
     918}
    873919
    874920
  • branches/network/src/lib/network/network_game_manager.h

    r6667 r6668  
    4444 *                       << UNIQUE_ID_1   UNIQUE_ID_2   UNIQUE_ID_3 ...   UNIQUE_ID_N
    4545 *
     46 *  SEND_PNODE_PATH      >> UNIQUE_ID_START   UNIQUE_ID_STOP NUMBER [UNIQUE_ID][0..NUMBER]
    4647 */
    4748
     
    5758  NET_REQUEST_ENTITY_LIST,
    5859  NET_REQUEST_PNODE_PATH,
     60  NET_SEND_PNODE_PATH,
    5961
    6062  NET_NUMBER
     
    108110    bool handleRequestSync( int& i, const byte* data, int length, int sender );
    109111    bool handleRequestPNodePath(int& i, const byte* data, int length, int sender);
     112    bool handleSendPNodePath(int& i, const byte* data, int length, int sender);
    110113
    111114
     
    125128
    126129    void requestPNodePath(const PNode* node1, const PNode* node2);
    127     void executePNodePath(const PNode* node2, const PNode* node2);
     130    void executeRequestPNodePath(const PNode* node2, const PNode* node2);
    128131    void doRequestPNodePath(const PNode* node1, const PNode* node2);
    129132
Note: See TracChangeset for help on using the changeset viewer.