Changeset 6788 in orxonox.OLD for branches/network/src/world_entities/space_ships
- Timestamp:
- Jan 27, 2006, 12:21:33 PM (19 years ago)
- Location:
- branches/network/src/world_entities/space_ships
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
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.