Changeset 6469 in orxonox.OLD for branches/network/src/world_entities/space_ships
- Timestamp:
- Jan 11, 2006, 12:20:56 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/world_entities/space_ships/space_ship.cc
r6463 r6469 525 525 } 526 526 527 #define MASK_bUp 1 528 #define MASK_bDown 2 529 #define MASK_bLeft 4 530 #define MASK_bRight 8 531 #define MASK_bAscend 16 532 #define MASK_bDescend 32 533 #define MASK_bFire 64 534 #define MASK_bRollL 128 535 #define MASK_bRollR 256 536 537 #define DATA_state 1 538 #define DATA_flags 2 539 #define DATA_mouse 3 527 540 528 541 int SpaceShip::writeBytes( const byte * data, int length, int sender ) 529 542 { 530 setRequestedSync( false );531 setIsOutOfSync( false );532 533 543 SYNCHELP_READ_BEGIN(); 534 544 535 SYNCHELP_READ_FKT( WorldEntity::writeState ); 545 byte b; 546 SYNCHELP_READ_BYTE( b ); 547 548 if ( b == DATA_state && this->getHostID()!=this->getOwner() ) 549 { 550 setRequestedSync( false ); 551 setIsOutOfSync( false ); 552 SYNCHELP_READ_FKT( WorldEntity::writeState ); 553 SYNCHELP_READ_FLOAT( cycle ); 554 } 555 556 if ( b == DATA_flags && this->getHostID()!=this->getOwner() ) 557 { 558 int flags; 559 SYNCHELP_READ_INT( flags ); 560 561 bUp = flags & MASK_bUp != 0; 562 bDown = flags & MASK_bDown != 0; 563 bLeft = flags & MASK_bLeft != 0; 564 bRight = flags & MASK_bRight != 0; 565 bAscend = flags & MASK_bAscend != 0; 566 bDescend = flags & MASK_bDescend != 0; 567 bFire = flags & MASK_bFire != 0; 568 bRollL = flags & MASK_bRollL != 0; 569 bRollR = flags & MASK_bRollR != 0; 570 } 571 572 if ( b == DATA_mouse && this->getHostID()!=this->getOwner() ) 573 { 574 SYNCHELP_READ_FLOAT( xMouse ); 575 SYNCHELP_READ_FLOAT( yMouse ); 576 SYNCHELP_READ_FLOAT( mouseSensitivity ); //TODO: remove this two lines 577 SYNCHELP_READ_FLOAT( cycle ); 578 } 536 579 537 580 return SYNCHELP_READ_N; 538 581 } 539 582 583 584 540 585 int SpaceShip::readBytes( byte * data, int maxLength, int * reciever ) 541 586 { 587 SYNCHELP_WRITE_BEGIN(); 588 542 589 if ( isOutOfSync() && !requestedSync() && this->getHostID()!=this->getOwner() ) 543 590 { … … 551 598 *reciever = rec; 552 599 553 SYNCHELP_WRITE_B EGIN();600 SYNCHELP_WRITE_BYTE( (byte)DATA_state ); 554 601 555 602 SYNCHELP_WRITE_FKT( WorldEntity::readState ); 603 SYNCHELP_WRITE_FLOAT( cycle ); 556 604 557 605 return SYNCHELP_WRITE_N; 558 606 } 559 607 608 560 609 *reciever = 0; 561 return 0; 562 } 610 611 if ( this->getHostID()!=this->getOwner() ) 612 { 613 int mask = 0; 614 615 if ( bUp ) 616 mask |= MASK_bUp; 617 if ( bDown ) 618 mask |= MASK_bDown; 619 if ( bLeft ) 620 mask |= MASK_bLeft; 621 if ( bRight ) 622 mask |= MASK_bRight; 623 if ( bAscend ) 624 mask |= MASK_bAscend; 625 if ( bFire ) 626 mask |= MASK_bFire; 627 if ( bRollL ) 628 mask |= MASK_bRollL; 629 if ( bRollR ) 630 mask |= MASK_bRollR; 631 632 static int oldMask = mask+1; //so it it different the first time! 633 static float oldxMouse = xMouse + 1.0; 634 static float oldyMouse = yMouse + 1.0; 635 636 if ( mask != oldMask ) 637 { 638 oldMask = mask; 639 SYNCHELP_WRITE_BYTE( DATA_flags ); 640 SYNCHELP_WRITE_INT( mask ); 641 } 642 643 if ( oldxMouse != xMouse || oldyMouse != yMouse ) 644 { 645 oldxMouse = xMouse; 646 oldyMouse = yMouse; 647 SYNCHELP_WRITE_BYTE( DATA_mouse ); 648 SYNCHELP_WRITE_FLOAT( xMouse ); 649 SYNCHELP_WRITE_FLOAT( yMouse ); 650 SYNCHELP_WRITE_FLOAT( mouseSensitivity ); 651 SYNCHELP_WRITE_FLOAT( cycle ); //TODO: remove this two lines 652 } 653 } 654 655 return SYNCHELP_WRITE_N; 656 }
Note: See TracChangeset
for help on using the changeset viewer.