Changeset 7954 in orxonox.OLD for trunk/src/lib/network/network_manager.cc
- Timestamp:
- May 29, 2006, 3:28:41 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/network/network_manager.cc
r7256 r7954 28 28 #include "shared_network_data.h" 29 29 #include "network_stream.h" 30 #include "preferences.h" 31 #include "network_log.h" 30 32 31 33 … … 52 54 this->defaultSyncStream = NULL; 53 55 this->sharedNetworkData = SharedNetworkData::getInstance(); 56 this->elapsedTime = 0.0f; 57 58 59 int port = Preferences::getInstance()->getInt( "network", "telnetport", 0 ); 60 61 if ( port > 0 ) 62 NetworkLog::getInstance()->listen( port ); 54 63 55 64 PRINTF(0)("NetworkManager created\n"); … … 72 81 this->netStreamList = ClassList::getList(CL_SYNCHRONIZEABLE); 73 82 PRINTF(0)("NetworkManager initzalized\n"); 83 74 84 } 75 85 … … 90 100 int NetworkManager::establishConnection(const std::string & name, unsigned int port) 91 101 { 92 IPaddress ipAddress; 93 int error = SDLNet_ResolveHost(&ipAddress, name.c_str(), port); 94 if( error == -1) { 95 printf("\n\nerror on address resolution, program inconsistency\n\n"); 96 return -1; 97 } 98 99 this->defaultSyncStream = new NetworkStream(ipAddress); 102 this->defaultSyncStream = new NetworkStream( name, port ); 100 103 this->sharedNetworkData->setDefaultSyncStream(this->defaultSyncStream); 101 104 this->defaultSyncStream->startHandshake(); … … 130 133 /** 131 134 * sync the network 135 * @param dtS: the seceonds elapsed since the last synchronize call 132 136 */ 133 void NetworkManager::synchronize( )137 void NetworkManager::synchronize( float dtS) 134 138 { 139 this->elapsedTime += dtS; 140 if( likely(this->elapsedTime < 1.0f / NETWORK_FREQUENCY)) 141 return; 142 this->elapsedTime = 0.0f; 143 135 144 if (this->netStreamList != NULL || (this->netStreamList = ClassList::getList(CL_NETWORK_STREAM)) != NULL) 136 145 {
Note: See TracChangeset
for help on using the changeset viewer.