Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 880 for code


Ignore:
Timestamp:
Mar 12, 2008, 1:37:39 PM (17 years ago)
Author:
dumenim
Message:

some functions for clientID↔objectID mapping added

Location:
code/branches/network
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network/bin/plugins.cfg-init

    r790 r880  
    22
    33# Define plugin folder
    4 PluginFolder=/usr/lib/OGRE
     4PluginFolder=/usr/local/lib/OGRE
    55
    66# Define plugins
  • code/branches/network/src/network/ConnectionManager.cc

    r790 r880  
    281281  }
    282282
     283  void ConnectionManager::regClientsObjectID( int clientID, std::string objectID ) {
     284    COUT(4) << "ship of client: " << clientID << ": " << objectID << " mapped" << std::endl;
     285    clientsShip.insert( make_pair( clientID, objectID ) );
     286  }
     287
     288  std::string ConnectionManager::getClientsShipID( int clientID ) {
     289    return clientsShip[clientID];
     290  }
     291
     292  int ConnectionManager::getObjectsClientID( std::string objectID ) {
     293    std::map<int, std::string>::iterator iter = clientsShip.begin();
     294    while( iter != clientsShip.end() ) {
     295      if( iter->second.compare( objectID ) == 1 ) return iter->first;
     296    }
     297    return -99;
     298  }
     299
     300  void ConnectionManager::deleteClientIDReg( int clientID ) {
     301    clientsShip.erase( clientID );
     302  }
     303
     304  void ConnectionManager::deleteObjectIDReg( std::string objectID ) {
     305    std::map<int, std::string>::iterator iter = clientsShip.begin();
     306    while( iter != clientsShip.end() ) {
     307      if( iter->second.compare( objectID ) == 1 ) break;
     308    }
     309    clientsShip.erase( iter->first );
     310  }
    283311}
  • code/branches/network/src/network/ConnectionManager.h

    r790 r880  
    2020#include "PacketBuffer.h"
    2121#include "PacketManager.h"
     22#include "map"
    2223
    2324namespace std
     
    7374    bool quit; // quit-variable (communication with threads)
    7475    ClientInformation *head_;
     76   
     77    //functions to map what object every clients uses
     78    std::map<int, std::string> clientsShip;
     79    void regClientsObjectID( int clientID, std::string objectID );
     80    std::string getClientsShipID( int clientID );
     81    int getObjectsClientID( std::string objectID );
     82    void deleteClientIDReg( int clientID );
     83    void deleteObjectIDReg( std::string objectID );
    7584  };
    76 
    77 
    78 
    79 
    80 
    81 
    82 
    83 
    8485}
    8586
Note: See TracChangeset for help on using the changeset viewer.