- Timestamp:
- Jan 27, 2006, 12:21:33 PM (19 years ago)
- Location:
- branches/network/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/lib/coord/p_node.cc
r6784 r6788 1250 1250 int PNode::readSync( byte * data, int maxLength ) 1251 1251 { 1252 //WARNING: if you change this file make sure you also change needsReadSync 1252 1253 SYNCHELP_WRITE_BEGIN(); 1253 1254 … … 1276 1277 { 1277 1278 1278 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); 1279 1280 1280 1281 SYNCHELP_WRITE_FLOAT( this->relCoordinate.x, NWT_PN_SCOORX ); … … 1290 1291 { 1291 1292 1292 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); 1293 1294 1294 1295 SYNCHELP_WRITE_FLOAT( this->absDirection.w, NWT_PN_SROTV ); … … 1305 1306 return SYNCHELP_WRITE_N; 1306 1307 } 1308 1309 bool PNode::needsReadSync( ) 1310 { 1311 if ( fabs( coorx - relCoordinate.x ) > __OFFSET_POS || 1312 fabs( coory - relCoordinate.y ) > __OFFSET_POS || 1313 fabs( coorz - relCoordinate.z ) > __OFFSET_POS ) 1314 return true; 1315 1316 if ( fabs( rotw - absDirection.w ) > __OFFSET_ROT || 1317 fabs( rotx - absDirection.v.x ) > __OFFSET_ROT || 1318 fabs( roty - absDirection.v.y ) > __OFFSET_ROT || 1319 fabs( rotz - absDirection.v.z ) > __OFFSET_ROT ) 1320 return true; 1321 1322 return false; 1323 } -
branches/network/src/lib/coord/p_node.h
r6695 r6788 190 190 int writeSync(const byte* data, int length, int sender); 191 191 int readSync(byte* data, int maxLength ); 192 bool needsReadSync(); 192 193 193 194 private: -
branches/network/src/lib/network/synchronizeable.h
r6784 r6788 195 195 } 196 196 #define SYNCHELP_WRITE_N __synchelp_write_i 197 #define SYNCHELP_WRITE_FKT(f,n) { \197 #define SYNCHELP_WRITE_FKT(f,n) { SYNCHELP_WRITE_DEBUG(n); \ 198 198 __synchelp_write_i += \ 199 199 f( data+__synchelp_write_i, maxLength-__synchelp_write_i ); \ -
branches/network/src/world_entities/space_ships/space_ship.cc
r6784 r6788 133 133 this->getWeaponManager()->changeWeaponConfig(1); 134 134 135 EventHandler::getInstance()->grabEvents(true);135 //EventHandler::getInstance()->grabEvents(true); 136 136 137 137 bUp = bDown = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = false; … … 551 551 #define DATA_flags 2 552 552 #define DATA_mouse 3 553 #define DATA_sync 4 553 554 554 555 int SpaceShip::writeBytes( const byte * data, int length, int sender ) … … 558 559 byte b; 559 560 560 if ( SYNCHELP_READ_REMAINING()>0 && SYNCHELP_READ_NEXTBYTE() == DATA_state /*&& (this->getHostID()!=this->getOwner() || sender==0)*/ )561 {562 PRINTF(0)("GOT STATE %d\n", this->getUniqueID());563 setRequestedSync( false );564 setIsOutOfSync( false );565 SYNCHELP_READ_FKT( WorldEntity::writeState, NWT_SS_WE_STATE );566 //SYNCHELP_READ_FLOAT( cycle );567 568 return SYNCHELP_READ_N;569 }570 571 if ( this->getOwner() != this->getHostID() )572 SYNCHELP_READ_FKT( PNode::writeSync, NWT_SS_PN_SYNC );573 574 561 while ( SYNCHELP_READ_REMAINING()>0 ) 575 562 { 576 563 SYNCHELP_READ_BYTE( b, NWT_SS_B ); 577 578 //TODO: do not recieve data if you are the owner 579 if ( b == DATA_flags /*&& this->getHostID()!=this->getOwner()*/ ) 564 565 if ( b == DATA_state ) 566 { 567 setRequestedSync( false ); 568 setIsOutOfSync( false ); 569 SYNCHELP_READ_FKT( WorldEntity::writeState, NWT_SS_WE_STATE ); 570 571 continue; 572 } 573 574 if ( b == DATA_flags ) 580 575 { 581 576 int flags = 0; … … 591 586 bRollL = (flags & MASK_bRollL) != 0; 592 587 bRollR = (flags & MASK_bRollR) != 0; 593 594 }595 596 //TODO: do not recieve data if you are the owner597 if ( b == DATA_mouse /*&& this->getHostID()!=this->getOwner()*/)588 589 continue; 590 } 591 592 if ( b == DATA_mouse ) 598 593 { 599 594 SYNCHELP_READ_FLOAT( mouseDir.w, NWT_SS_MOUSEDIRW ); … … 601 596 SYNCHELP_READ_FLOAT( mouseDir.v.y, NWT_SS_MOUSEDIRY ); 602 597 SYNCHELP_READ_FLOAT( mouseDir.v.z, NWT_SS_MOUSEDIRZ ); 598 599 continue; 600 } 601 602 if ( b == DATA_sync ) 603 { 604 if ( this->getOwner() != this->getHostID() ) 605 SYNCHELP_READ_FKT( PNode::writeSync, NWT_SS_PN_SYNC ); 606 607 continue; 608 } 609 } 610 611 #if 0 612 if ( SYNCHELP_READ_REMAINING()>0 && SYNCHELP_READ_NEXTBYTE() == DATA_state /*&& (this->getHostID()!=this->getOwner() || sender==0)*/ ) 613 { 614 PRINTF(0)("GOT STATE %d\n", this->getUniqueID()); 615 setRequestedSync( false ); 616 setIsOutOfSync( false ); 617 SYNCHELP_READ_FKT( WorldEntity::writeState, NWT_SS_WE_STATE ); 618 //SYNCHELP_READ_FLOAT( cycle ); 619 620 return SYNCHELP_READ_N; 621 } 622 623 if ( this->getOwner() != this->getHostID() ) 624 SYNCHELP_READ_FKT( PNode::writeSync, NWT_SS_PN_SYNC ); 625 626 while ( SYNCHELP_READ_REMAINING()>0 ) 627 { 628 SYNCHELP_READ_BYTE( b, NWT_SS_B ); 629 630 //TODO: do not recieve data if you are the owner 631 if ( b == DATA_flags /*&& this->getHostID()!=this->getOwner()*/ ) 632 { 633 int flags = 0; 634 SYNCHELP_READ_INT( flags, NWT_SS_FLAGS ); 635 636 bUp = (flags & MASK_bUp) != 0; 637 bDown = (flags & MASK_bDown) != 0; 638 bLeft = (flags & MASK_bLeft) != 0; 639 bRight = (flags & MASK_bRight) != 0; 640 bAscend = (flags & MASK_bAscend) != 0; 641 bDescend = (flags & MASK_bDescend) != 0; 642 bFire = (flags & MASK_bFire) != 0; 643 bRollL = (flags & MASK_bRollL) != 0; 644 bRollR = (flags & MASK_bRollR) != 0; 645 646 } 647 648 //TODO: do not recieve data if you are the owner 649 if ( b == DATA_mouse /*&& this->getHostID()!=this->getOwner()*/ ) 650 { 651 SYNCHELP_READ_FLOAT( mouseDir.w, NWT_SS_MOUSEDIRW ); 652 SYNCHELP_READ_FLOAT( mouseDir.v.x, NWT_SS_MOUSEDIRX ); 653 SYNCHELP_READ_FLOAT( mouseDir.v.y, NWT_SS_MOUSEDIRY ); 654 SYNCHELP_READ_FLOAT( mouseDir.v.z, NWT_SS_MOUSEDIRZ ); 603 655 } 604 656 }; 605 606 /*if ( b == DATA_mouse && this->getHostID()!=this->getOwner() ) 607 { 608 SYNCHELP_READ_FLOAT( xMouse ); 609 SYNCHELP_READ_FLOAT( yMouse ); 610 SYNCHELP_READ_FLOAT( mouseSensitivity ); 611 SYNCHELP_READ_FLOAT( cycle ); 612 }*/ 613 657 #endif 614 658 return SYNCHELP_READ_N; 615 659 } … … 645 689 *reciever = 0; 646 690 647 if ( this->getOwner() == this->getHostID() ) 691 if ( this->getOwner() == this->getHostID() && PNode::needsReadSync() ) 692 { 693 SYNCHELP_WRITE_BYTE( DATA_sync, NWT_SS_B ); 648 694 SYNCHELP_WRITE_FKT( PNode::readSync, NWT_SS_PN_SYNC ); 695 } 649 696 650 697 if ( this->getHostID()==this->getOwner() ) … … 699 746 } 700 747 701 int SpaceShip::writeState(const byte* data, int length, int sender) 702 { 703 SYNCHELP_READ_BEGIN(); 704 705 return SYNCHELP_READ_N; 706 } 707 708 int SpaceShip::readState(byte* data, int maxLength ) 709 { 710 SYNCHELP_WRITE_BEGIN(); 711 712 return SYNCHELP_WRITE_N; 713 } 714 715 int SpaceShip::writeSync(const byte* data, int length, int sender) 716 { 717 SYNCHELP_READ_BEGIN(); 718 719 return SYNCHELP_READ_N; 720 } 721 722 int SpaceShip::readSync(byte* data, int maxLength ) 723 { 724 SYNCHELP_WRITE_BEGIN(); 725 726 return SYNCHELP_WRITE_N; 727 } 748 -
branches/network/src/world_entities/space_ships/space_ship.h
r6784 r6788 44 44 virtual int writeBytes(const byte* data, int length, int sender); 45 45 virtual int readBytes(byte* data, int maxLength, int * reciever); 46 47 int writeState(const byte* data, int length, int sender);48 int readState(byte* data, int maxLength );49 int writeSync(const byte* data, int length, int sender);50 int readSync(byte* data, int maxLength );51 52 46 53 47 private:
Note: See TracChangeset
for help on using the changeset viewer.