Changeset 6959 in orxonox.OLD for trunk/src/lib
- Timestamp:
- Feb 1, 2006, 4:40:34 PM (19 years ago)
- Location:
- trunk/src/lib
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/coord/p_node.cc
r6873 r6959 1253 1253 SYNCHELP_WRITE_BEGIN(); 1254 1254 1255 if ( this->getHostID()!= this->getOwner() )1255 if ( this->getHostID()!=0 && this->getHostID()!=this->getOwner() ) 1256 1256 { 1257 1257 return SYNCHELP_WRITE_N; … … 1259 1259 1260 1260 byte flags = 0; 1261 if ( fabs( coorx - relCoordinate.x ) > __OFFSET_POS ||1262 fabs( coory - relCoordinate.y ) > __OFFSET_POS ||1263 fabs( coorz - relCoordinate.z ) > __OFFSET_POS )1261 if ( fabs( coorx - relCoordinate.x ) > __OFFSET_POS*0.05*this->velocity.len() || 1262 fabs( coory - relCoordinate.y ) > __OFFSET_POS*0.05*this->velocity.len() || 1263 fabs( coorz - relCoordinate.z ) > __OFFSET_POS*0.05*this->velocity.len() ) 1264 1264 flags |= __FLAG_COOR; 1265 1265 … … 1272 1272 1273 1273 SYNCHELP_WRITE_BYTE( flags, NWT_PN_FLAGS ); 1274 //PRINTF(0)("FLAGS = %d\n", flags);1274 PRINTF(0)("FLAGS = %d\n", flags); 1275 1275 1276 1276 if ( flags & __FLAG_COOR ) 1277 1277 { 1278 1278 1279 //PRINTF(0)("SEND COOR: %f %f %f\n", this->relCoordinate.x, this->relCoordinate.y, this->relCoordinate.z);1279 PRINTF(0)("SEND COOR: %f %f %f\n", this->relCoordinate.x, this->relCoordinate.y, this->relCoordinate.z); 1280 1280 1281 1281 SYNCHELP_WRITE_FLOAT( this->relCoordinate.x, NWT_PN_SCOORX ); … … 1291 1291 { 1292 1292 1293 //PRINTF(0)("SEND QUAT: %f %f %f %f\n", this->absDirection.w, this->absDirection.v.x, this->absDirection.v.y, this->absDirection.v.z);1293 PRINTF(0)("SEND QUAT: %f %f %f %f\n", this->absDirection.w, this->absDirection.v.x, this->absDirection.v.y, this->absDirection.v.z); 1294 1294 1295 1295 SYNCHELP_WRITE_FLOAT( this->absDirection.w, NWT_PN_SROTV ); … … 1309 1309 bool PNode::needsReadSync( ) 1310 1310 { 1311 if ( fabs( coorx - relCoordinate.x ) > __OFFSET_POS ||1312 fabs( coory - relCoordinate.y ) > __OFFSET_POS ||1313 fabs( coorz - relCoordinate.z ) > __OFFSET_POS )1311 if ( fabs( coorx - relCoordinate.x ) > __OFFSET_POS*0.05*this->velocity.len() || 1312 fabs( coory - relCoordinate.y ) > __OFFSET_POS*0.05*this->velocity.len() || 1313 fabs( coorz - relCoordinate.z ) > __OFFSET_POS*0.05*this->velocity.len() ) 1314 1314 return true; 1315 1315 -
trunk/src/lib/network/converter.cc
r6753 r6959 90 90 * @return: The number of written bytes 91 91 */ 92 int Converter:: intToByteArray(int x, byte* a, int length)92 int Converter::_intToByteArray(int x, byte* a, int length) 93 93 { 94 94 if (length < INTSIZE) … … 127 127 * @return: The number of read bytes 128 128 */ 129 int Converter:: byteArrayToInt(const byte* a, int* x)129 int Converter::_byteArrayToInt(const byte* a, int* x) 130 130 { 131 131 int mult = 1; … … 146 146 *x += a[INTSIZE - 1] * mult; 147 147 148 return INTSIZE; 149 } 150 151 int Converter::byteArrayToInt(const byte* a, int* x) 152 { 153 memcpy( x, a, INTSIZE ); 154 return INTSIZE; 155 } 156 157 int Converter::intToByteArray(int x, byte* a, int length) 158 { 159 if ( length< INTSIZE ) 160 { 161 PRINTF(1)("Byte Array to small\n"); 162 return 0; 163 } 164 memcpy(a, &x, INTSIZE); 148 165 return INTSIZE; 149 166 } -
trunk/src/lib/network/converter.h
r6753 r6959 30 30 static int intToByteArray(int x, byte* a, int length); 31 31 static int byteArrayToInt(const byte* a, int* x); 32 33 static int _intToByteArray(int x, byte* a, int length); 34 static int _byteArrayToInt(const byte* a, int* x); 32 35 33 36 static int stringToByteArray(const char* s, byte* a, int length, int maxLength); -
trunk/src/lib/network/network_game_manager.cc
r6868 r6959 29 29 #include "world_entity.h" 30 30 #include "playable.h" 31 #include "space_ships/space_ship.h" 31 32 #include "player.h" 32 #include " network_manager.h"33 #include "shared_network_data.h" 33 34 34 35 #include "class_list.h" … … 541 542 if ( b->isA(CL_WORLD_ENTITY) && !b->isA(CL_PLAYABLE) ) 542 543 { 543 if ( NetworkManager::getInstance()->getHostID()!=0 )544 if ( SharedNetworkData::getInstance()->getHostID()!=0 ) 544 545 { 545 546 static Vector pos = Vector(1000.0, 1000.0, 1000.0); … … 550 551 } 551 552 } 553 ///HACK this is only for network multiplayer games. 554 if( b->isA(CL_SPACE_SHIP)) 555 { 556 SpaceShip* ss = dynamic_cast<SpaceShip*>(b); 557 if( owner%2 == 0) 558 { 559 560 ss->loadModel("models/ships/reap_#.obj"); 561 ss->toList(OM_GROUP_00); 562 } 563 else 564 { 565 ss->loadModel( "models/ships/fighter.obj" ); 566 ss->toList(OM_GROUP_01); 567 } 568 } 552 569 553 570 return b; … … 576 593 { 577 594 assert((*it)->isA(CL_WORLD_ENTITY)); 595 dynamic_cast<WorldEntity*>(*it)->leaveWorld(); 578 596 dynamic_cast<WorldEntity*>(*it)->toList(OM_DEAD); 579 597 break; … … 895 913 i += Converter::byteArrayToInt( &data[i], &uniqueID ); 896 914 915 PRINTF(0)("handleRequestSync %d %d\n", uniqueID, sender); 897 916 doRequestSync( uniqueID, sender ); 898 917 … … 980 999 void NetworkGameManager::executeRequestSync( int uniqueID, int user ) 981 1000 { 1001 PRINTF(0)("executeRequestSync %d %d\n", uniqueID, user); 982 1002 if ( user >= outBuffer.size() ) 983 1003 resizeBufferVector( user ); -
trunk/src/lib/network/network_socket.cc
r6695 r6959 172 172 173 173 if (!tcpSocket || data==NULL || nbytes<=0) 174 return 0; 174 { 175 assert(_OUTGOING_BUFFER_SIZE - outgoingBufferLength > 0); 176 return 0; 177 } 175 178 176 179 SDL_mutexP(outgoingBufferMutex); … … 324 327 325 328 329 #ifdef DONTEXITTHREADS 330 while ( true ) 331 { 332 SDL_Delay(1000); 333 } 334 #endif 335 326 336 PRINTF(0)("QUIT READ THREAD\n"); 337 327 338 return 0; 328 339 } … … 392 403 } 393 404 405 #ifdef DONTEXITTHREADS 406 while ( true ) 407 { 408 SDL_Delay(1000); 409 } 410 #endif 394 411 395 412 PRINTF(0)("QUIT WRITE THREAD\n"); 413 396 414 return 0; 415 397 416 } 398 417 … … 426 445 { 427 446 PRINTF(1)("Buffersize is too small (%d) for packet (%d)\n", maxLength, blen); 447 assert(false); 428 448 return 0; 429 449 } -
trunk/src/lib/network/network_socket.h
r6695 r6959 8 8 #define _NETWORK_SOCKET 9 9 10 //HACK else gdb will not work on server 11 #define DONTEXITTHREADS 12 10 13 //if you want to use outgoing buffer define _USE_OUTGOING_BUFFER 11 14 #define _USE_OUTGOING_BUFFER 12 15 13 #define _INCOMING_BUFFER_SIZE 1024016 #define _INCOMING_BUFFER_SIZE 2024000 14 17 #define _OUTGOING_BUFFER_SIZE 2024000 15 18 #define _LOCAL_BUFFER_SIZE 1024 -
trunk/src/lib/network/network_stream.cc
r6868 r6959 26 26 #include "connection_monitor.h" 27 27 #include "synchronizeable.h" 28 #include "network_manager.h"29 28 #include "network_game_manager.h" 29 #include "shared_network_data.h" 30 30 31 31 #include "debug.h" … … 195 195 { 196 196 SharedNetworkData::getInstance()->setHostID( handshakes[i]->getHostId() ); 197 myHostId = NetworkManager::getInstance()->getHostID();197 myHostId = SharedNetworkData::getInstance()->getHostID(); 198 198 199 199 this->networkGameManager = NetworkGameManager::getInstance(); … … 231 231 int reciever; 232 232 Header header; 233 int counter; 234 233 235 for (SynchronizeableList::iterator it = synchronizeables.begin(); it!=synchronizeables.end(); it++) 234 236 { 237 counter = 0; 238 235 239 if ( (*it)!=NULL && (*it)->beSynchronized() /*&& (*it)->getOwner() == myHostId*/ ) 236 240 { 237 241 do { 242 counter++; 243 244 //check for endless loop 245 if ( counter > 50 ) 246 { 247 PRINTF(1)("there seems to be an error in readBytes of %s\n", (*it)->getClassName()); 248 assert(false); 249 } 250 238 251 reciever = 0; 239 252 dataLength = (*it)->readBytes(downBuffer, DATA_STREAM_BUFFER_SIZE, &reciever); 240 241 253 242 254 if ( dataLength<=0 ){ … … 267 279 for ( int i = 0; i<networkSockets.size(); i++) 268 280 { 269 if ( i!= -reciever&& networkSockets[i] != NULL )281 if ( i!=abs(reciever) && networkSockets[i] != NULL ) 270 282 { 271 PRINTF( 5)("write %d bytes to socket %d\n", dataLength, i);283 PRINTF(0)("write %d bytes to socket %d uniqueid %d reciever %d\n", dataLength, i, (*it)->getUniqueID(), reciever); 272 284 networkSockets[i]->writePacket(downBuffer, dataLength); 273 285 } -
trunk/src/lib/network/synchronizeable.h
r6868 r6959 34 34 NWT_SS_VELZ, 35 35 NWT_SS_PL_SYNC, 36 36 NWT_SS_CO_N, 37 NWT_SS_CO_CLID, 38 37 39 NWT_HS_HOST_ID, 38 40 NWT_HS_NGM_ID, 39 41 42 NWT_PL_B, 40 43 NWT_PL_FLAGS, 41 44 NWT_PL_SCORE, 45 42 46 NWT_PN_BO_WRITESTATE, 43 47 NWT_PN_PARENTMODE, … … 49 53 NWT_PN_ROTZ, 50 54 NWT_PN_ROTV, 51 55 52 56 NWT_PN_FLAGS, 53 57 NWT_PN_SCOORX, … … 58 62 NWT_PN_SROTZ, 59 63 NWT_PN_SROTV, 60 64 61 65 NWT_BO_NAME, 62 66 63 67 NWT_WE_PN_WRITESTATE, 64 68 NWT_WE_PN_MODELFILENAME, 65 69 NWT_WE_PN_SCALING, 66 70 67 71 NWT_GT_WE_STATE, 68 72 69 73 NWT_SB_WE_STATE, 70 74 NWT_SB_SIZE, 71 75 NWT_SB_TEXTURENAME, 72 76 73 77 NWT_TER_WE_STATE, 74 78 75 79 NWT_PU_WE_STATE, 76 80 77 81 NWT_TPU_WE_STATE, 78 82 79 83 NWT_LPU_WE_STATE, 80 84 81 85 NWT_WPU_WE_STATE, 82 86 83 87 NWT_PPU_WE_STATE, 84 88 NWT_PPU_TYPE, … … 133 137 * delete[] textureName; 134 138 * textureName = NULL; 135 * SYNCHELP_READ_STRINGM( texturename ); //this will call new char[strlen()+1] 139 * SYNCHELP_READ_STRINGM( texturename ); //this will call new char[strlen()+1] 136 140 * 137 141 * Example 2: … … 142 146 * 143 147 */ 144 148 145 149 #define SYNCHELP_WRITE_DEBUG(n) {\ 146 150 __synchelp_write_n = Converter::intToByteArray( n, data+__synchelp_write_i, maxLength-__synchelp_write_i ); \
Note: See TracChangeset
for help on using the changeset viewer.