Changeset 6868 in orxonox.OLD for trunk/src/world_entities
- Timestamp:
- Jan 30, 2006, 4:41:19 PM (19 years ago)
- Location:
- trunk/src/world_entities
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/playable.cc
r6804 r6868 40 40 41 41 this->bFire = false; 42 this->oldFlags = 0; 42 43 43 44 this->setSynchronized(true); … … 246 247 { 247 248 } 249 250 #define FLAGS_bFire 1 251 252 int Playable::writeSync( const byte * data, int length, int sender ) 253 { 254 SYNCHELP_READ_BEGIN(); 255 256 byte flags; 257 258 SYNCHELP_READ_BYTE( flags, NWT_PL_FLAGS ); 259 260 bFire = (flags & FLAGS_bFire) != 0; 261 262 return SYNCHELP_READ_N; 263 } 264 265 int Playable::readSync( byte * data, int maxLength ) 266 { 267 SYNCHELP_WRITE_BEGIN(); 268 byte flags = 0; 269 270 if ( bFire ) 271 flags |= FLAGS_bFire; 272 273 274 SYNCHELP_WRITE_BYTE( flags, NWT_PL_FLAGS ); 275 oldFlags = flags; 276 277 278 return SYNCHELP_WRITE_N; 279 } 280 281 bool Playable::needsReadSync( ) 282 { 283 byte flags = 0; 284 285 if ( bFire ) 286 flags |= FLAGS_bFire; 287 288 return flags!=oldFlags; 289 } -
trunk/src/world_entities/playable.h
r6804 r6868 54 54 /** @return a List of Events in PEV_* sytle */ 55 55 inline const std::list<int>& getEventList() { return this->events; }; 56 57 int writeSync(const byte* data, int length, int sender); 58 int readSync(byte* data, int maxLength ); 59 bool needsReadSync(); 56 60 57 61 protected: … … 68 72 69 73 bool bFire; //!< If the Ship is firing. 74 int oldFlags; //!< Used for synchronisation 70 75 71 76 }; -
trunk/src/world_entities/space_ships/space_ship.cc
r6825 r6868 95 95 else 96 96 { 97 this->loadModel("models/ships/reap_#.obj"); 97 //this->loadModel("models/ships/reap_#.obj"); 98 this->loadModel( "models/ships/fighter.obj" ); 98 99 } 99 100 … … 127 128 128 129 bUp = bDown = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = false; 129 bFire = false; 130 130 131 xMouse = yMouse = 0; 131 132 yInvert = 1; … … 516 517 #define MASK_bAscend 16 517 518 #define MASK_bDescend 32 518 #define MASK_bFire 64 519 #define MASK_bRollL 128 520 #define MASK_bRollR 256 519 #define MASK_bRollL 64 520 #define MASK_bRollR 128 521 521 522 522 #define DATA_state 1 … … 525 525 #define DATA_sync 4 526 526 #define DATA_velocity 5 527 #define DATA_playables 6 527 528 528 529 int SpaceShip::writeBytes( const byte * data, int length, int sender ) … … 547 548 if ( b == DATA_flags ) 548 549 { 549 int flags = 0; 550 SYNCHELP_READ_INT( flags, NWT_SS_FLAGS ); 551 552 bUp = (flags & MASK_bUp) != 0; 553 bDown = (flags & MASK_bDown) != 0; 554 bLeft = (flags & MASK_bLeft) != 0; 555 bRight = (flags & MASK_bRight) != 0; 556 bAscend = (flags & MASK_bAscend) != 0; 557 bDescend = (flags & MASK_bDescend) != 0; 558 bFire = (flags & MASK_bFire) != 0; 559 bRollL = (flags & MASK_bRollL) != 0; 560 bRollR = (flags & MASK_bRollR) != 0; 550 if ( this->getOwner() != this->getHostID() ) 551 { 552 byte flags = 0; 553 SYNCHELP_READ_BYTE( flags, NWT_SS_FLAGS ); 554 555 bUp = (flags & MASK_bUp) != 0; 556 bDown = (flags & MASK_bDown) != 0; 557 bLeft = (flags & MASK_bLeft) != 0; 558 bRight = (flags & MASK_bRight) != 0; 559 bAscend = (flags & MASK_bAscend) != 0; 560 bDescend = (flags & MASK_bDescend) != 0; 561 bRollL = (flags & MASK_bRollL) != 0; 562 bRollR = (flags & MASK_bRollR) != 0; 563 564 } 565 else 566 assert(false); 561 567 562 568 continue; … … 565 571 if ( b == DATA_mouse ) 566 572 { 567 SYNCHELP_READ_FLOAT( mouseDir.w, NWT_SS_MOUSEDIRW ); 568 SYNCHELP_READ_FLOAT( mouseDir.v.x, NWT_SS_MOUSEDIRX ); 569 SYNCHELP_READ_FLOAT( mouseDir.v.y, NWT_SS_MOUSEDIRY ); 570 SYNCHELP_READ_FLOAT( mouseDir.v.z, NWT_SS_MOUSEDIRZ ); 573 if ( this->getOwner() != this->getHostID() ) 574 { 575 SYNCHELP_READ_FLOAT( mouseDir.w, NWT_SS_MOUSEDIRW ); 576 SYNCHELP_READ_FLOAT( mouseDir.v.x, NWT_SS_MOUSEDIRX ); 577 SYNCHELP_READ_FLOAT( mouseDir.v.y, NWT_SS_MOUSEDIRY ); 578 SYNCHELP_READ_FLOAT( mouseDir.v.z, NWT_SS_MOUSEDIRZ ); 579 } 580 else 581 assert(false); 571 582 572 583 continue; … … 576 587 { 577 588 if ( this->getOwner() != this->getHostID() ) 589 { 578 590 SYNCHELP_READ_FKT( PNode::writeSync, NWT_SS_PN_SYNC ); 591 } 592 else 593 assert(false); 579 594 580 595 continue; … … 583 598 if ( b == DATA_velocity ) 584 599 { 585 SYNCHELP_READ_FLOAT( velocity.x, NWT_SS_VELX ); 586 SYNCHELP_READ_FLOAT( velocity.y, NWT_SS_VELY ); 587 SYNCHELP_READ_FLOAT( velocity.z, NWT_SS_VELZ ); 600 if ( this->getOwner() != this->getHostID() ) 601 { 602 SYNCHELP_READ_FLOAT( velocity.x, NWT_SS_VELX ); 603 SYNCHELP_READ_FLOAT( velocity.y, NWT_SS_VELY ); 604 SYNCHELP_READ_FLOAT( velocity.z, NWT_SS_VELZ ); 605 } 606 else 607 assert(false); 608 609 continue; 610 } 611 612 if ( b == DATA_playables ) 613 { 614 if ( this->getOwner() != this->getHostID() ) 615 { 616 SYNCHELP_READ_FKT( Playable::writeSync, NWT_SS_PL_SYNC ); 617 } 618 else 619 assert(false); 588 620 } 589 621 } … … 615 647 616 648 SYNCHELP_WRITE_FKT( WorldEntity::readState, NWT_SS_WE_STATE ); 617 //SYNCHELP_WRITE_FLOAT( cycle );618 649 619 650 return SYNCHELP_WRITE_N; 620 651 } 621 652 622 *reciever = 0; 623 624 if ( this->getOwner() == this->getHostID() && PNode::needsReadSync() ) 653 *reciever = -this->getOwner(); 654 bool sentSomething = false; 655 656 if ( ( this->getHostID()==0 || this->getOwner() == this->getHostID() ) && PNode::needsReadSync() ) 625 657 { 626 658 SYNCHELP_WRITE_BYTE( DATA_sync, NWT_SS_B ); … … 628 660 } 629 661 630 if ( this->getHostID()== this->getOwner() )631 { 632 intmask = 0;662 if ( this->getHostID()==0 || this->getHostID()==this->getOwner() ) 663 { 664 byte mask = 0; 633 665 634 666 if ( bUp ) … … 642 674 if ( bAscend ) 643 675 mask |= MASK_bAscend; 644 if ( bFire )645 mask |= MASK_bFire;646 676 if ( bRollL ) 647 677 mask |= MASK_bRollL; … … 650 680 651 681 652 //static float oldxMouse = xMouse + 1.0;653 //static float oldyMouse = yMouse + 1.0;654 655 682 if ( mask != oldMask ) 656 683 { 657 684 oldMask = mask; 685 sentSomething = true; 658 686 SYNCHELP_WRITE_BYTE( DATA_flags, NWT_SS_B ); 659 SYNCHELP_WRITE_ INT( mask, NWT_SS_FLAGS );687 SYNCHELP_WRITE_BYTE( mask, NWT_SS_FLAGS ); 660 688 } 661 689 #define __OFFSET_MDIR_W 0.01 … … 670 698 SYNCHELP_WRITE_BYTE( DATA_mouse, NWT_SS_B ); 671 699 PRINTF(0)("SENDING mousedir\n"); 700 sentSomething = true; 672 701 SYNCHELP_WRITE_FLOAT( mouseDir.w, NWT_SS_MOUSEDIRW ); 673 702 SYNCHELP_WRITE_FLOAT( mouseDir.v.x, NWT_SS_MOUSEDIRX ); … … 681 710 { 682 711 oldVelocity = velocity; 683 PRINTF(0)("SENDING velocity\n"); 684 SYNCHELP_WRITE_BYTE( DATA_velocity, NWT_SS_B ); 685 SYNCHELP_WRITE_FLOAT( velocity.x, NWT_SS_VELX ); 686 SYNCHELP_WRITE_FLOAT( velocity.y, NWT_SS_VELY ); 687 SYNCHELP_WRITE_FLOAT( velocity.z, NWT_SS_VELZ ); 688 } 689 690 } 712 //PRINTF(0)("SENDING velocity\n"); 713 //SYNCHELP_WRITE_BYTE( DATA_velocity, NWT_SS_B ); 714 //SYNCHELP_WRITE_FLOAT( velocity.x, NWT_SS_VELX ); 715 //SYNCHELP_WRITE_FLOAT( velocity.y, NWT_SS_VELY ); 716 //SYNCHELP_WRITE_FLOAT( velocity.z, NWT_SS_VELZ ); 717 } 718 719 if ( Playable::needsReadSync() ) 720 { 721 sentSomething = true; 722 SYNCHELP_WRITE_BYTE( DATA_playables, NWT_SS_B ); 723 SYNCHELP_WRITE_FKT( Playable::readSync, NWT_SS_PL_SYNC ); 724 } 725 726 } 727 728 if ( !sentSomething ) 729 reciever = 0; 691 730 692 731 return SYNCHELP_WRITE_N; -
trunk/src/world_entities/space_ships/space_ship.h
r6815 r6868 56 56 bool bAscend; //!< ascend button pressed. 57 57 bool bDescend; //!< descend button presses. 58 bool bFire; //!< fire button pressed. 58 // bool bFire; //!< fire button pressed.(moved to playable) 59 59 bool bRollL; //!< rolling button pressed (left) 60 60 bool bRollR; //!< rolling button pressed (right) … … 80 80 float airViscosity; 81 81 82 int oldMask;82 byte oldMask; //!< used for synchronisation 83 83 84 84 ParticleEmitter* burstEmitter;
Note: See TracChangeset
for help on using the changeset viewer.