Changeset 6498 in orxonox.OLD for trunk/src/world_entities/space_ships
- Timestamp:
- Jan 11, 2006, 9:58:22 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/space_ships/space_ship.cc
r6444 r6498 510 510 } 511 511 512 #define MASK_bUp 1 513 #define MASK_bDown 2 514 #define MASK_bLeft 4 515 #define MASK_bRight 8 516 #define MASK_bAscend 16 517 #define MASK_bDescend 32 518 #define MASK_bFire 64 519 #define MASK_bRollL 128 520 #define MASK_bRollR 256 521 522 #define DATA_state 1 523 #define DATA_flags 2 524 #define DATA_mouse 3 512 525 513 526 int SpaceShip::writeBytes( const byte * data, int length, int sender ) 514 527 { 515 setRequestedSync( false );516 setIsOutOfSync( false );517 518 528 SYNCHELP_READ_BEGIN(); 519 529 520 SYNCHELP_READ_FKT( WorldEntity::writeState ); 530 byte b; 531 SYNCHELP_READ_BYTE( b ); 532 533 if ( b == DATA_state && this->getHostID()!=this->getOwner() ) 534 { 535 setRequestedSync( false ); 536 setIsOutOfSync( false ); 537 SYNCHELP_READ_FKT( WorldEntity::writeState ); 538 SYNCHELP_READ_FLOAT( cycle ); 539 } 540 541 if ( b == DATA_flags && this->getHostID()!=this->getOwner() ) 542 { 543 int flags; 544 SYNCHELP_READ_INT( flags ); 545 546 bUp = flags & MASK_bUp != 0; 547 bDown = flags & MASK_bDown != 0; 548 bLeft = flags & MASK_bLeft != 0; 549 bRight = flags & MASK_bRight != 0; 550 bAscend = flags & MASK_bAscend != 0; 551 bDescend = flags & MASK_bDescend != 0; 552 bFire = flags & MASK_bFire != 0; 553 bRollL = flags & MASK_bRollL != 0; 554 bRollR = flags & MASK_bRollR != 0; 555 } 556 557 if ( b == DATA_mouse && this->getHostID()!=this->getOwner() ) 558 { 559 SYNCHELP_READ_FLOAT( xMouse ); 560 SYNCHELP_READ_FLOAT( yMouse ); 561 SYNCHELP_READ_FLOAT( mouseSensitivity ); 562 SYNCHELP_READ_FLOAT( cycle ); 563 } 521 564 522 565 return SYNCHELP_READ_N; 523 566 } 524 567 568 569 525 570 int SpaceShip::readBytes( byte * data, int maxLength, int * reciever ) 526 571 { 572 SYNCHELP_WRITE_BEGIN(); 573 527 574 if ( isOutOfSync() && !requestedSync() && this->getHostID()!=this->getOwner() ) 528 575 { … … 536 583 *reciever = rec; 537 584 538 SYNCHELP_WRITE_B EGIN();585 SYNCHELP_WRITE_BYTE( (byte)DATA_state ); 539 586 540 587 SYNCHELP_WRITE_FKT( WorldEntity::readState ); 588 SYNCHELP_WRITE_FLOAT( cycle ); 541 589 542 590 return SYNCHELP_WRITE_N; 543 591 } 544 592 593 545 594 *reciever = 0; 546 return 0; 547 } 595 596 if ( this->getHostID()==this->getOwner() ) 597 { 598 int mask = 0; 599 600 if ( bUp ) 601 mask |= MASK_bUp; 602 if ( bDown ) 603 mask |= MASK_bDown; 604 if ( bLeft ) 605 mask |= MASK_bLeft; 606 if ( bRight ) 607 mask |= MASK_bRight; 608 if ( bAscend ) 609 mask |= MASK_bAscend; 610 if ( bFire ) 611 mask |= MASK_bFire; 612 if ( bRollL ) 613 mask |= MASK_bRollL; 614 if ( bRollR ) 615 mask |= MASK_bRollR; 616 617 static int oldMask = mask+1; //so it is different the first time! 618 static float oldxMouse = xMouse + 1.0; 619 static float oldyMouse = yMouse + 1.0; 620 621 if ( mask != oldMask ) 622 { 623 oldMask = mask; 624 SYNCHELP_WRITE_BYTE( DATA_flags ); 625 SYNCHELP_WRITE_INT( mask ); 626 } 627 628 if ( oldxMouse != xMouse || oldyMouse != yMouse ) 629 { 630 oldxMouse = xMouse; 631 oldyMouse = yMouse; 632 SYNCHELP_WRITE_BYTE( DATA_mouse ); 633 SYNCHELP_WRITE_FLOAT( xMouse ); 634 SYNCHELP_WRITE_FLOAT( yMouse ); 635 SYNCHELP_WRITE_FLOAT( mouseSensitivity ); 636 SYNCHELP_WRITE_FLOAT( cycle ); 637 } 638 } 639 640 return SYNCHELP_WRITE_N; 641 }
Note: See TracChangeset
for help on using the changeset viewer.