Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

some functions for clientID↔objectID mapping added

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.