- Timestamp:
- Dec 21, 2005, 7:26:49 PM (19 years ago)
- Location:
- branches/network/src/lib/network
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/lib/network/network_game_manager.cc
r6250 r6256 73 73 byte b; 74 74 75 while ( i<length )75 while ( i<length-1 ) 76 76 { 77 77 b = data[i++]; 78 79 PRINTF(0)("WriteBytes: b = %d\n", b); 78 80 79 81 if ( isServer() ) … … 92 94 } 93 95 } 94 95 if ( !isServer() ) 96 else 96 97 { 97 98 if ( b == CREATE_ENTITY ) … … 362 363 return; 363 364 365 PRINTF(0)("SendEntityList: n = %d\n", networkStream->getSyncCount()); 366 364 367 while ( it != e ) 365 368 { 366 369 if ( !writeToClientBuffer( outBuffer[userID], (*it)->getClassID() ) ) 367 370 return; 371 372 PRINTF(0)("SendEntityList: ClassID = %x\n", (*it)->getClassID()); 368 373 369 374 if ( !writeToClientBuffer( outBuffer[userID], (*it)->getUniqueID() ) ) … … 409 414 if ( !b ) 410 415 { 411 PRINTF(1)("Could not fabricate Object with classID %d\n", classID); 412 return; 416 PRINTF(1)("Could not fabricate Object with classID %x\n", classID); 417 return; 418 } 419 else 420 { 421 PRINTF(0)("Fabricated entity: %s\n", b->getClassName()); 413 422 } 414 423 … … 422 431 else 423 432 { 424 PRINTF(1)("Class with ID % dis not a synchronizeable!", (int)classID);433 PRINTF(1)("Class with ID %x is not a synchronizeable!", (int)classID); 425 434 delete b; 426 435 } … … 549 558 } 550 559 int classID; 551 i += Converter::byteArrayToInt( data, &classID );560 i += Converter::byteArrayToInt( &data[i], &classID ); 552 561 553 562 createEntity( (ClassID)classID ); … … 564 573 } 565 574 int uniqueID; 566 i += Converter::byteArrayToInt( data, &uniqueID );575 i += Converter::byteArrayToInt( &data[i], &uniqueID ); 567 576 568 577 removeEntity( uniqueID ); … … 579 588 } 580 589 int classID; 581 i += Converter::byteArrayToInt( data, &classID );590 i += Converter::byteArrayToInt( &data[i], &classID ); 582 591 583 592 if ( INTSIZE > length-i ) … … 587 596 } 588 597 int uniqueID; 589 i += Converter::byteArrayToInt( data, &uniqueID );598 i += Converter::byteArrayToInt( &data[i], &uniqueID ); 590 599 591 600 if ( INTSIZE > length-i ) … … 595 604 } 596 605 int owner; 597 i += Converter::byteArrayToInt( data, &owner );606 i += Converter::byteArrayToInt( &data[i], &owner ); 598 607 599 608 doCreateEntity( (ClassID)classID, uniqueID, owner ); … … 610 619 } 611 620 int uniqueID; 612 i += Converter::byteArrayToInt( data, &uniqueID );621 i += Converter::byteArrayToInt( &data[i], &uniqueID ); 613 622 614 623 doRemoveEntity( uniqueID ); … … 624 633 return false; 625 634 } 635 636 PRINTF(0)("HandleCreateEntityList: data[i..i+3] = %d %d %d %d\n", data[i], data[i+1], data[i+2], data[i+3]); 637 626 638 int n; 627 i += Converter::byteArrayToInt( data, &n ); 639 i += Converter::byteArrayToInt( &data[i], &n ); 640 641 642 PRINTF(0)("HandleCreateEntityList: n = %d\n", n); 628 643 629 644 int classID, uniqueID, owner; … … 637 652 return false; 638 653 } 639 i += Converter::byteArrayToInt( data, &classID );654 i += Converter::byteArrayToInt( &data[i], &classID ); 640 655 641 656 if ( INTSIZE > length-i ) … … 644 659 return false; 645 660 } 646 i += Converter::byteArrayToInt( data, &uniqueID );661 i += Converter::byteArrayToInt( &data[i], &uniqueID ); 647 662 648 663 if ( INTSIZE > length-i ) … … 651 666 return false; 652 667 } 653 i += Converter::byteArrayToInt( data, &owner );668 i += Converter::byteArrayToInt( &data[i], &owner ); 654 669 655 670 doCreateEntity( (ClassID)classID, uniqueID, owner ); … … 667 682 } 668 683 int n; 669 i += Converter::byteArrayToInt( data, &n );684 i += Converter::byteArrayToInt( &data[i], &n ); 670 685 671 686 int uniqueID; … … 679 694 return false; 680 695 } 681 i += Converter::byteArrayToInt( data, &uniqueID );696 i += Converter::byteArrayToInt( &data[i], &uniqueID ); 682 697 683 698 doRemoveEntity( uniqueID ); … … 696 711 697 712 int uniqueID; 698 i += Converter::byteArrayToInt( data, &uniqueID );713 i += Converter::byteArrayToInt( &data[i], &uniqueID ); 699 714 700 715 doYouAre( uniqueID ); … … 711 726 } 712 727 int uniqueID; 713 i += Converter::byteArrayToInt( data, &uniqueID );728 i += Converter::byteArrayToInt( &data[i], &uniqueID ); 714 729 715 730 doRequestSync( uniqueID, sender ); … … 733 748 bool NetworkGameManager::writeToClientBuffer( clientBuffer & cb, int i ) 734 749 { 735 int n = Converter::intToByteArray( i, cb.buffer , cb.maxLength-cb.length );750 int n = Converter::intToByteArray( i, cb.buffer+cb.length, cb.maxLength-cb.length ); 736 751 cb.length += n; 737 752 -
branches/network/src/lib/network/network_socket.cc
r6139 r6256 21 21 #define DEBUG_MODULE_NETWORK 22 22 23 #include "converter.h" 23 24 24 25 /* include your own header */ … … 398 399 { 399 400 PRINTF(5)("NetworkSocket::writePacket()\n"); 400 if (length>255) 401 { 402 PRINTF(1)("Packet length > 255!\n"); 403 return false; 404 } 405 406 byte blen = length; 407 408 writeBytes(&blen, 1); 401 402 byte blen[INTSIZE]; 403 404 Converter::intToByteArray( length, blen, INTSIZE ); 405 406 writeBytes(blen, INTSIZE); 409 407 writeBytes(data, length); 410 408 } … … 413 411 { 414 412 PRINTF(5)("NetworkSocket::readPacket()\n"); 415 if (incomingBufferLength<1) 416 { 417 return 0; 418 } 419 420 byte blen = incomingBuffer[0]; 413 if (incomingBufferLength<INTSIZE) 414 { 415 return 0; 416 } 417 418 int blen; 419 Converter::byteArrayToInt( incomingBuffer, &blen ); 421 420 422 421 if (blen>maxLength) … … 431 430 } 432 431 433 readBytes(&blen, 1); 432 byte t[INTSIZE]; 433 readBytes(t, INTSIZE); 434 434 int res = readBytes(data, blen); 435 435 -
branches/network/src/lib/network/network_stream.cc
r6230 r6256 262 262 } while( reciever!=0 ); 263 263 } 264 else265 {266 PRINTF(0)("synchronizeables == NULL");267 }268 264 } 269 265
Note: See TracChangeset
for help on using the changeset viewer.