Changeset 6937 in orxonox.OLD for branches/network/src/world_entities
- Timestamp:
- Feb 1, 2006, 2:32:16 PM (19 years ago)
- Location:
- branches/network/src/world_entities
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/world_entities/playable.cc
r6868 r6937 101 101 void Playable::collidesWith(WorldEntity* entity, const Vector& location) 102 102 { 103 if (entity->isA(CL_PROJECTILE) )103 if (entity->isA(CL_PROJECTILE) && !State::isOnline() ) 104 104 this->decreaseHealth(entity->getHealth()); 105 105 … … 253 253 { 254 254 SYNCHELP_READ_BEGIN(); 255 255 256 256 byte flags; 257 257 258 258 SYNCHELP_READ_BYTE( flags, NWT_PL_FLAGS ); 259 259 260 260 bFire = (flags & FLAGS_bFire) != 0; 261 261 262 262 return SYNCHELP_READ_N; 263 263 } … … 267 267 SYNCHELP_WRITE_BEGIN(); 268 268 byte flags = 0; 269 269 270 270 if ( bFire ) 271 271 flags |= FLAGS_bFire; 272 272 273 273 274 274 SYNCHELP_WRITE_BYTE( flags, NWT_PL_FLAGS ); 275 275 oldFlags = flags; 276 276 277 277 278 278 return SYNCHELP_WRITE_N; 279 279 } … … 282 282 { 283 283 byte flags = 0; 284 284 285 285 if ( bFire ) 286 286 flags |= FLAGS_bFire; 287 287 288 288 return flags!=oldFlags; 289 289 } -
branches/network/src/world_entities/space_ships/space_ship.cc
r6930 r6937 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 } … … 323 344 this->calculateVelocity(time); 324 345 325 346 326 347 Vector move = velocity*time; 327 348 … … 528 549 #define DATA_velocity 5 529 550 #define DATA_playables 6 551 #define DATA_collision 7 530 552 531 553 int SpaceShip::writeBytes( const byte * data, int length, int sender ) … … 563 585 bRollL = (flags & MASK_bRollL) != 0; 564 586 bRollR = (flags & MASK_bRollR) != 0; 565 587 566 588 } 567 589 else … … 605 627 SYNCHELP_READ_FLOAT( velocity.y, NWT_SS_VELY ); 606 628 SYNCHELP_READ_FLOAT( velocity.z, NWT_SS_VELZ ); 607 } 629 } 608 630 else 609 631 assert(false); 610 632 611 633 continue; 612 634 } 613 635 614 636 if ( b == DATA_playables ) 615 637 { … … 620 642 else 621 643 assert(false); 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 } 622 657 } 623 658 } … … 725 760 SYNCHELP_WRITE_FLOAT( velocity.z, NWT_SS_VELZ ); 726 761 } 727 762 728 763 if ( Playable::needsReadSync() ) 729 764 { … … 735 770 736 771 } 737 772 738 773 if ( !sentSomething ) 774 { 739 775 *reciever = 0; 740 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 } 791 741 792 return SYNCHELP_WRITE_N; 742 793 } 743 794 744 795 void SpaceShip::doCollideNetwork( float energy ) 796 { 797 this->decreaseHealth( energy ); 798 } 799 800 801 -
branches/network/src/world_entities/space_ships/space_ship.h
r6868 r6937 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 -
branches/network/src/world_entities/world_entity.cc
r6815 r6937 280 280 281 281 /** 282 * this method is called by the world if the WorldEntity leaves valid gamespace 283 * 284 * For free entities this means it left the Track boundaries. With bound entities it means its Location adresses a 285 * place that is not in the world anymore. In both cases you might have to take extreme measures (a.k.a. call destroy). 286 * 287 * NOT YET IMPLEMENTED 288 */ 289 void WorldEntity::leftWorld () 282 * this method is called by the world if the WorldEntity leaves the game 283 */ 284 void WorldEntity::leaveWorld () 290 285 {} 291 286 -
branches/network/src/world_entities/world_entity.h
r6700 r6937 54 54 55 55 virtual void postSpawn (); 56 virtual void le ftWorld ();56 virtual void leaveWorld (); 57 57 58 58 virtual void tick (float time);
Note: See TracChangeset
for help on using the changeset viewer.