Changeset 6959 in orxonox.OLD for trunk/src/world_entities/space_ships
- Timestamp:
- Feb 1, 2006, 4:40:34 PM (19 years ago)
- Location:
- trunk/src/world_entities/space_ships
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/space_ships/space_ship.cc
r6947 r6959 96 96 { 97 97 //this->loadModel("models/ships/reap_#.obj"); 98 this->loadModel( "models/ships/fighter.obj" ); 98 ///HACK this is only for network multiplayer games. 99 if( this->getOwner()%2 == 0) 100 { 101 this->loadModel("models/ships/reap_#.obj"); 102 this->toList(OM_GROUP_00); 103 } 104 else 105 { 106 this->loadModel( "models/ships/fighter.obj" ); 107 this->toList(OM_GROUP_01); 108 } 99 109 } 100 110 … … 275 285 { 276 286 Playable::collidesWith(entity, location); 287 288 277 289 if (entity->isA(CL_TURRET_POWER_UP) && entity != ref) 278 290 { 279 291 this->ADDWEAPON(); 280 292 ref = entity; 281 } 293 } 294 295 if( entity->isA(CL_PROJECTILE) && entity != ref) 296 { 297 if ( isServer() ) 298 { 299 networkCollisionList.push_back( entity->getHealth() ); 300 doCollideNetwork( entity->getHealth() ); 301 } 302 } 282 303 // PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getClassName(), entity->getClassName(), location.x, location.y, location.z); 283 304 } … … 320 341 321 342 // spaceship controlled movement 322 this->calculateVelocity(time); 343 if (this->getOwner() == this->getHostID()) 344 this->calculateVelocity(time); 345 323 346 324 347 Vector move = velocity*time; … … 450 473 } 451 474 452 velocity += accel ;475 velocity += accel*time*10; 453 476 //rot.normalize(); 454 477 //this->setRelDirSoft(Quaternion(rotVal, rot), 5); … … 526 549 #define DATA_velocity 5 527 550 #define DATA_playables 6 551 #define DATA_collision 7 528 552 529 553 int SpaceShip::writeBytes( const byte * data, int length, int sender ) … … 561 585 bRollL = (flags & MASK_bRollL) != 0; 562 586 bRollR = (flags & MASK_bRollR) != 0; 563 587 564 588 } 565 589 else … … 603 627 SYNCHELP_READ_FLOAT( velocity.y, NWT_SS_VELY ); 604 628 SYNCHELP_READ_FLOAT( velocity.z, NWT_SS_VELZ ); 605 } 629 } 606 630 else 607 631 assert(false); 608 632 609 633 continue; 610 634 } 611 635 612 636 if ( b == DATA_playables ) 613 637 { … … 619 643 assert(false); 620 644 } 645 646 if ( b == DATA_collision ) 647 { 648 int n; 649 float energy; 650 SYNCHELP_READ_INT( n, NWT_SS_CO_N ); 651 652 for ( int i = 0; i<n; i++ ) 653 { 654 SYNCHELP_READ_FLOAT( energy, NWT_SS_CO_CLID ); 655 doCollideNetwork( energy ); 656 } 657 } 621 658 } 622 659 … … 651 688 } 652 689 653 *reciever = -this->getOwner(); 690 *reciever = 0 - this->getOwner(); 691 //TODO: implement with SYNCHELP_WRITE_SENT() 654 692 bool sentSomething = false; 655 693 656 if ( ( this->getHostID()==0 || this->getOwner() == this->getHostID() ) && PNode::needsReadSync() ) 657 { 694 if ( PNode::needsReadSync() && ( this->getHostID()==0 || this->getOwner() == this->getHostID() ) ) 695 { 696 PRINTF(0)("sending PNode::readSync\n"); 658 697 SYNCHELP_WRITE_BYTE( DATA_sync, NWT_SS_B ); 659 698 SYNCHELP_WRITE_FKT( PNode::readSync, NWT_SS_PN_SYNC ); 699 sentSomething = true; 660 700 } 661 701 … … 683 723 { 684 724 oldMask = mask; 725 PRINTF(0)("sending mask\n"); 685 726 sentSomething = true; 686 727 SYNCHELP_WRITE_BYTE( DATA_flags, NWT_SS_B ); … … 705 746 } 706 747 #define __OFFSET_VEL 0.05 707 if ( fabs( oldVelocity.x - velocity.x ) > __OFFSET_VEL*velocity.x || 708 fabs( oldVelocity.y - velocity.y ) > __OFFSET_VEL*velocity.y || 709 fabs( oldVelocity.z - velocity.z ) > __OFFSET_VEL*velocity.z ) 710 { 711 oldVelocity = velocity; 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 748 if ( fabs( oldVelocity.x - velocity.x ) > __OFFSET_VEL*fabs(oldVelocity.x)+0.1 || 749 fabs( oldVelocity.y - velocity.y ) > __OFFSET_VEL*fabs(oldVelocity.y)+0.1 || 750 fabs( oldVelocity.z - velocity.z ) > __OFFSET_VEL*fabs(oldVelocity.z)+0.1 ) 751 { 752 oldVelocity.x = velocity.x; 753 oldVelocity.y = velocity.y; 754 oldVelocity.z = velocity.z; 755 PRINTF(0)("SENDING velocity\n"); 756 sentSomething = true; 757 SYNCHELP_WRITE_BYTE( DATA_velocity, NWT_SS_B ); 758 SYNCHELP_WRITE_FLOAT( velocity.x, NWT_SS_VELX ); 759 SYNCHELP_WRITE_FLOAT( velocity.y, NWT_SS_VELY ); 760 SYNCHELP_WRITE_FLOAT( velocity.z, NWT_SS_VELZ ); 761 } 762 719 763 if ( Playable::needsReadSync() ) 720 764 { 721 765 sentSomething = true; 766 PRINTF(0)("SYNCHELP_WRITE_FKT( Playable::readSync, NWT_SS_PL_SYNC )\n"); 722 767 SYNCHELP_WRITE_BYTE( DATA_playables, NWT_SS_B ); 723 768 SYNCHELP_WRITE_FKT( Playable::readSync, NWT_SS_PL_SYNC ); … … 725 770 726 771 } 727 772 728 773 if ( !sentSomething ) 729 reciever = 0; 774 { 775 *reciever = 0; 776 777 if ( networkCollisionList.size()>0 ) 778 { 779 SYNCHELP_WRITE_BYTE( DATA_collision, NWT_SS_B ); 780 781 SYNCHELP_WRITE_INT( networkCollisionList.size(), NWT_SS_CO_N ); 782 783 for ( std::list<float>::iterator it = networkCollisionList.begin(); it!=networkCollisionList.end(); it++ ) 784 { 785 SYNCHELP_WRITE_FLOAT( *it, NWT_SS_CO_CLID ); 786 } 787 788 networkCollisionList.clear(); 789 } 790 } 730 791 731 792 return SYNCHELP_WRITE_N; 732 793 } 733 794 734 795 void SpaceShip::doCollideNetwork( float energy ) 796 { 797 this->decreaseHealth( energy ); 798 } 799 800 801 -
trunk/src/world_entities/space_ships/space_ship.h
r6868 r6959 47 47 void calculateVelocity(float time); 48 48 49 void doCollideNetwork( float energy ); 50 49 51 // !! temporary !! 50 52 void ADDWEAPON(); … … 84 86 ParticleEmitter* burstEmitter; 85 87 ParticleSystem* burstSystem; 88 89 std::list<float> networkCollisionList; 86 90 }; 87 91
Note: See TracChangeset
for help on using the changeset viewer.