- Timestamp:
- Jul 2, 2006, 2:22:19 PM (18 years ago)
- Location:
- trunk/src
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/collision_detection/bounding_volume.h
r7711 r9008 38 38 const int* triangleIndexes; //!< Array with the triangle indexes in modelInfo 39 39 int triangleIndexesLength; //!< length of the indexes array 40 41 float radius; //!< the radius of the box (longest axis) 40 42 }; 41 43 -
trunk/src/lib/collision_detection/obb_tree_node.cc
r8776 r9008 364 364 } 365 365 } 366 this->bvElement->radius = longestAxis; 366 367 PRINTF(4)("\nLongest Axis is: Nr %i with a half-length of:%11.2f\n", longestAxisIndex, longestAxis); 367 368 … … 454 455 return; 455 456 457 float distanceMax = this->bvElement->radius + ((OBBTreeNode*)treeNode)->bvElement->radius; 458 float distance = fabs((nodeA->getAbsCoor() - nodeB->getAbsCoor()).len()); 459 460 461 // if( distance < distanceMax) 462 // PRINTF(0)(" %s (%s: group %i) vs %s (%s: group %i): distanceMax: %f, distance: %f\n", nodeA->getClassName(), nodeA->getName(), nodeA->getOMListNumber(), nodeB->getClassName(), nodeB->getName(), nodeB->getOMListNumber(), distanceMax, distance); 463 464 456 465 PRINTF(4)("collideWith\n"); 457 466 PRINTF(5)("Checking OBB %i vs %i: ", this->getIndex(), treeNode->getIndex()); … … 482 491 if( this->overlapTest(this->nodeLeft->bvElement, treeNode->bvElement, nodeA, nodeB)) 483 492 { 493 bool bAdvance = false; 484 494 if( treeNode->nodeLeft != NULL) 485 495 this->nodeLeft->collideWith(treeNode->nodeLeft, nodeA, nodeB); 496 else 497 bAdvance = true; 498 486 499 if( treeNode->nodeRight != NULL) 487 500 this->nodeLeft->collideWith(treeNode->nodeRight, nodeA, nodeB); 501 else 502 bAdvance = true; 503 504 if( bAdvance) 505 this->nodeLeft->collideWith(treeNode, nodeA, nodeB); // go down the other tree also 488 506 } 489 507 } … … 494 512 if( this->overlapTest(this->nodeRight->bvElement, treeNode->bvElement, nodeA, nodeB)) 495 513 { 514 bool bAdvance = false; 515 496 516 if( treeNode->nodeLeft != NULL) 497 517 this->nodeRight->collideWith(treeNode->nodeLeft, nodeA, nodeB); 518 else 519 bAdvance = true; 520 498 521 if( treeNode->nodeRight != NULL) 499 522 this->nodeRight->collideWith(treeNode->nodeRight, nodeA, nodeB); 523 else 524 bAdvance = true; 525 526 if( bAdvance) 527 this->nodeRight->collideWith(treeNode, nodeA, nodeB); // go down the other tree also 500 528 } 501 529 } … … 516 544 (treeNode->nodeRight == NULL && treeNode->nodeLeft == NULL)) ) 517 545 { 546 // PRINTF(0)("----------------------------------------------\n\n\n\n\n\n--------------------------------\n\n\n"); 518 547 nodeA->registerCollision(nodeA, nodeB, (BoundingVolume*)this->bvElement, (BoundingVolume*)treeNode->bvElement); 519 548 } -
trunk/src/lib/collision_reaction/cr_object_damage.cc
r8779 r9008 56 56 float damage = 0.0f; 57 57 58 PRINTF( 4)("Dealing damage - Handling collision: %s vs %s\n",58 PRINTF(0)("Dealing damage - Handling collision: %s vs %s\n", 59 59 collision->getEntityA()->getClassName(), 60 60 collision->getEntityB()->getClassName()); … … 63 63 if( collision->isEntityACollide()) { 64 64 damage = collision->getEntityB()->getDamage(); 65 collision->getEntityA()->hit(damage );65 collision->getEntityA()->hit(damage, collision->getEntityB()); 66 66 } 67 67 PRINTF(4)("Dealing damage - %f damage to %s \n", damage, collision->getEntityA()->getClassName()); … … 69 69 if( collision->isEntityBCollide()) { 70 70 damage = collision->getEntityA()->getDamage(); 71 collision->getEntityB()->hit(damage );71 collision->getEntityB()->hit(damage, collision->getEntityA()); 72 72 } 73 73 PRINTF(4)("Dealing damage - %f damage to %s \n", damage, collision->getEntityB()->getClassName()); -
trunk/src/lib/network/message_manager.h
r8708 r9008 32 32 MSGID_PREFEREDTEAM, 33 33 MSGID_CHANGENICKNAME, 34 MSGID_CHATMESSAGE 34 MSGID_CHATMESSAGE, 35 MSGID_RESPAWN 35 36 }; 36 37 -
trunk/src/lib/network/network_game_manager.cc
r8708 r9008 39 39 40 40 #include "network_game_manager.h" 41 42 #include "multiplayer_team_deathmatch.h" 41 43 42 44 … … 118 120 stats->setPlayableUniqueId( playable.getUniqueID() ); 119 121 stats->setModelFileName( playableModel ); 122 123 if ( rules.isA( CL_MULTIPLAYER_TEAM_DEATHMATCH ) ) 124 dynamic_cast<MultiplayerTeamDeathmatch*>(&rules)->respawnPlayable( &playable, team, 0.0f ); 120 125 121 126 return true; -
trunk/src/story_entities/multi_player_world.cc
r8894 r9008 93 93 void MultiPlayerWorld::collisionDetection() 94 94 { 95 //CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_PLAYERS), this->dataTank->objectManager->getObjectList(OM_PLAYERS)); 96 97 PRINTF(5)("\n-----------------------------------------\nchecking OM_PLAYERS vs OM_PLAYERS_PROJ\n\n"); 98 CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_PLAYERS_PROJ), 99 this->dataTank->objectManager->getObjectList(OM_PLAYERS)); 100 PRINTF(5)("\n-----------------------------------------\nchecking OM_PLAYERS vs OM_GROUP_01_PROJ\n\n"); 95 101 CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_PLAYERS), 96 this->dataTank->objectManager->getObjectList(OM_PLAYERS)); 102 this->dataTank->objectManager->getObjectList(OM_GROUP_00_PROJ)); 103 PRINTF(5)("\n-----------------------------------------\nchecking OM_PLAYERS vs OM_GROUP_01_PROJ\n\n"); 97 104 CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_PLAYERS), 105 this->dataTank->objectManager->getObjectList(OM_GROUP_01_PROJ)); 106 CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_PLAYERS), 107 this->dataTank->objectManager->getObjectList(OM_GROUP_00)); 108 CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_PLAYERS), 109 this->dataTank->objectManager->getObjectList(OM_GROUP_01)); 110 111 112 113 PRINTF(5)("\n-----------------------------------------\nchecking OM_GROUP_00 vs OM_GROUP_01_PROJ\n\n"); 114 CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_00), 115 this->dataTank->objectManager->getObjectList(OM_GROUP_01_PROJ)); 116 PRINTF(5)("\n-----------------------------------------\nchecking OM_GROUP_00 vs OM_GROUP_01\n\n"); 117 CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_00), 118 this->dataTank->objectManager->getObjectList(OM_GROUP_01)); 119 CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_00), 98 120 this->dataTank->objectManager->getObjectList(OM_PLAYERS_PROJ)); 99 121 100 CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_PLAYERS), 101 this->dataTank->objectManager->getObjectList(OM_GROUP_00_PROJ)); 102 CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_PLAYERS), 103 this->dataTank->objectManager->getObjectList(OM_GROUP_01_PROJ)); 104 105 CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_00), 106 this->dataTank->objectManager->getObjectList(OM_GROUP_01_PROJ)); 122 PRINTF(5)("\n-----------------------------------------\nchecking OM_GROUP_01 vs OM_GROUP_00_PROJ\n\n"); 107 123 CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_01), 108 124 this->dataTank->objectManager->getObjectList(OM_GROUP_00_PROJ)); 109 CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_00),110 this->dataTank->objectManager->getObjectList(OM_GROUP_01));111 112 CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_00),113 this->dataTank->objectManager->getObjectList(OM_COMMON));114 125 CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_01), 115 this->dataTank->objectManager->getObjectList(OM_COMMON)); 116 126 this->dataTank->objectManager->getObjectList(OM_GROUP_00)); 127 CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_01), 128 this->dataTank->objectManager->getObjectList(OM_PLAYERS_PROJ)); 117 129 } 118 130 -
trunk/src/story_entities/multi_player_world_data.cc
r8717 r9008 233 233 this->tickLists.push_back(OM_ENVIRON); 234 234 this->tickLists.push_back(OM_COMMON); 235 this->tickLists.push_back(OM_PLAYERS); 236 this->tickLists.push_back(OM_PLAYERS_PROJ); 235 237 this->tickLists.push_back(OM_GROUP_00); 236 238 this->tickLists.push_back(OM_GROUP_00_PROJ); … … 241 243 this->drawLists.push_back(OM_ENVIRON); 242 244 this->drawLists.push_back(OM_COMMON); 245 this->drawLists.push_back(OM_PLAYERS); 246 this->drawLists.push_back(OM_PLAYERS_PROJ); 243 247 this->drawLists.push_back(OM_GROUP_00); 244 248 this->drawLists.push_back(OM_GROUP_00_PROJ); -
trunk/src/util/game_rules.cc
r8802 r9008 90 90 if ( !SharedNetworkData::getInstance()->isGameServer() ) 91 91 return; 92 92 93 PRINTF(0)("Received Event: Kill\n"); 93 this->killList.push_back(kill); 94 95 this->killList.push_back( kill ); 94 96 } 95 97 -
trunk/src/util/game_rules.h
r8802 r9008 9 9 10 10 #include "base_object.h" 11 #include <list> 11 12 #include <vector> 12 13 … … 54 55 std::vector<MissionGoal*> missionList; //!< list of mission goals 55 56 56 std:: vector<Kill>killList; //!< list of kills in the world57 std::list<Kill> killList; //!< list of kills in the world 57 58 }; 58 59 -
trunk/src/util/multiplayer_team_deathmatch.cc
r8802 r9008 68 68 this->numTeams = 2; 69 69 this->currentGameState = GAMESTATE_PRE_GAME; 70 this->gameStateTimer = 10.0f;70 this->gameStateTimer = 3.0f; 71 71 this->bShowTeamChange = false; 72 72 … … 85 85 subscribeEvent( ES_MENU, SDLK_F1 ); 86 86 subscribeEvent( ES_MENU, KeyMapper::PEV_FIRE1 ); 87 87 88 88 this->notifier = new OrxGui::GLGuiNotifier(); 89 89 this->notifier->show(); … … 106 106 unsubscribeEvent( ES_MENU, SDLK_F1 ); 107 107 unsubscribeEvent( ES_MENU, KeyMapper::PEV_FIRE1 ); 108 108 109 109 if ( this->notifier ) 110 110 { … … 219 219 if ( !SharedNetworkData::getInstance()->isGameServer() ) 220 220 return; 221 221 222 222 //handle kills 223 for ( std::vector<Kill>::iterator it = this->killList.begin(); it != this->killList.end(); ) 224 { 225 std::vector<Kill>::iterator delit = it; 226 227 onKill( it->getKiller()->getOwner(), it->getVictim()->getOwner() ); 228 229 it++; 230 killList.erase( delit ); 223 while ( this->killList.begin() != this->killList.end() ) 224 { 225 onKill( this->killList.begin()->getVictim(), this->killList.begin()->getKiller() ); 226 this->killList.erase( this->killList.begin() ); 231 227 } 232 228 229 230 233 231 gameStateTimer -= dt; 234 232 //PRINTF(0)("TICK %f\n", gameStateTimer); … … 488 486 stats.setModelFileName( playableModel ); 489 487 488 this->respawnPlayable( &playable, stats.getPreferedTeamId(), 0.0f ); 489 490 490 if ( oldPlayable ) 491 491 { … … 558 558 else if ( event.type == SDLK_TAB ) 559 559 { 560 if ( !event.bPressed)560 if ( currentGameState == GAMESTATE_GAME && event.bPressed && !EventHandler::getInstance()->isPressed( SDLK_RALT ) && !EventHandler::getInstance()->isPressed( SDLK_LALT ) ) 561 561 { 562 562 EventHandler::getInstance()->pushState( ES_MENU ); … … 627 627 statsBox = new OrxGui::GLGuiBox(); 628 628 statsBox->setAbsCoor2D( 300, 100 ); 629 629 630 630 this->table = new OrxGui::GLGuiTable(0,0); 631 631 … … 645 645 statsBox = NULL; 646 646 } 647 647 648 648 EventHandler::getInstance()->popState(); 649 649 } … … 664 664 headers.push_back(""); 665 665 this->table->setHeader(headers); 666 666 667 667 std::map<int,std::string> fragsTeam0; 668 668 std::map<int,std::string> fragsTeam1; 669 669 670 670 const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS ); 671 671 672 672 if ( !list ) 673 673 return; 674 674 675 675 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 676 676 { 677 677 PlayerStats & stats = *dynamic_cast<PlayerStats*>(*it); 678 678 679 679 if ( stats.getTeamId() == 0 || stats.getTeamId() == 1 ) 680 680 { … … 685 685 } 686 686 } 687 687 688 688 char st[10]; 689 689 int i = 0; 690 691 690 691 692 692 i = 2; 693 693 for ( std::map<int,std::string>::const_iterator it = fragsTeam0.begin(); it != fragsTeam0.end(); it++ ) … … 699 699 i++; 700 700 } 701 701 702 702 i = 2; 703 703 for ( std::map<int,std::string>::const_iterator it = fragsTeam1.begin(); it != fragsTeam1.end(); it++ ) … … 712 712 /** 713 713 * this function is called when a player kills another one or himself 714 * @param killedUserId 715 * @param userId 716 */ 717 void MultiplayerTeamDeathmatch::onKill( int killedUserId, int userId ) 718 { 719 assert( PlayerStats::getStats( killedUserId ) ); 720 assert( PlayerStats::getStats( userId ) ); 714 * @param killedUserId 715 * @param userId 716 */ 717 void MultiplayerTeamDeathmatch::onKill( WorldEntity * victim, WorldEntity * killer ) 718 { 719 if ( !victim ) 720 return; 721 if ( !killer ) 722 return; 721 723 722 PlayerStats & killedStats = *PlayerStats::getStats( killedUserId ); 723 PlayerStats & stats = *PlayerStats::getStats( userId ); 724 int killerUserId = killer->getOwner(); 725 int victimUserId = victim->getOwner(); 726 727 PlayerStats & victimStats = *PlayerStats::getStats( victimUserId ); 728 PlayerStats & killerStats = *PlayerStats::getStats( killerUserId ); 724 729 725 if ( killedUserId != userId ) 726 stats.setScore( stats.getScore() + 1 ); 730 if ( killerStats.getPlayable() != killer || victimStats.getPlayable() != victim ) 731 return; 732 733 //check for suicide 734 if ( killerUserId != victimUserId ) 735 { 736 //check for teamkill 737 if ( victimStats.getTeamId() != killerStats.getTeamId() ) 738 { 739 killerStats.setScore( killerStats.getScore() + 1 ); 740 } 741 else 742 { 743 killerStats.setScore( killerStats.getScore() - 1 ); 744 } 745 } 727 746 else 728 stats.setScore( stats.getScore() - 1 );729 730 if ( killedUserId == SharedNetworkData::getInstance()->getHostID() )747 killerStats.setScore( killerStats.getScore() - 1 ); 748 749 if ( victimUserId == SharedNetworkData::getInstance()->getHostID() ) 731 750 { 732 751 this->bLocalPlayerDead = true; 733 752 this->showStats(); 734 753 } 735 736 const std::list<BaseObject*> * list = ClassList::getList( CL_SPAWNING_POINT ); 737 738 assert( list ); 739 740 std::vector<SpawningPoint*> spList; 741 742 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 743 { 744 SpawningPoint * sp = dynamic_cast<SpawningPoint*>(*it); 745 746 if ( sp->getTeamId() < 0 || sp->getTeamId() == killedStats.getTeamId() ) 747 spList.push_back( sp ); 748 } 749 750 int n = spList.size()*rand(); 751 752 spList[n]->pushEntity( killedStats.getPlayable(), 3 ); 754 755 this->respawnPlayable( victimStats.getPlayable(), victimStats.getTeamId(), 3.0f ); 753 756 } 754 757 755 758 /** 756 759 * this function is called on player respawn 757 * @param userId 760 * @param userId 758 761 */ 759 762 void MultiplayerTeamDeathmatch::onRespawn( int userId ) … … 768 771 /** 769 772 * this function is called on player respawn 770 * @param we 773 * @param we 771 774 */ 772 775 void MultiplayerTeamDeathmatch::registerSpawn( WorldEntity * we ) … … 775 778 } 776 779 780 781 void MultiplayerTeamDeathmatch::respawnPlayable( Playable * playable, int teamId, float delay ) 782 { 783 const std::list<BaseObject*> * list = ClassList::getList( CL_SPAWNING_POINT ); 784 785 assert( list ); 786 787 std::vector<SpawningPoint*> spList; 788 789 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 790 { 791 SpawningPoint * sp = dynamic_cast<SpawningPoint*>(*it); 792 793 if ( sp->getTeamId() == teamId ) 794 spList.push_back( sp ); 795 } 796 797 if ( spList.size() == 0 ) 798 { 799 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 800 { 801 SpawningPoint * sp = dynamic_cast<SpawningPoint*>(*it); 802 803 if ( sp->getTeamId() < 0 ) 804 spList.push_back( sp ); 805 } 806 } 807 808 assert( spList.size() != 0 ); 809 810 int n = (int)((float)spList.size() * (float)rand()/(float)RAND_MAX); 811 812 spList[n]->pushEntity( playable, delay ); 813 } 814 -
trunk/src/util/multiplayer_team_deathmatch.h
r8802 r9008 56 56 virtual void process(const Event &event); 57 57 58 void onKill( int killedUserId, int userId);58 void onKill( WorldEntity * victim, WorldEntity * killer ); 59 59 void onRespawn( int userId ); 60 60 61 61 virtual void handleChatMessage( int userId, const std::string & message, int messageType ); 62 63 void respawnPlayable( Playable * playable, int teamId, float delay ); 62 64 63 65 protected: -
trunk/src/util/object_manager.cc
r8362 r9008 212 212 "background", 213 213 "common", 214 215 "players", 216 "players-proj", 214 217 215 218 "group00", -
trunk/src/world_entities/playable.cc
r8724 r9008 65 65 66 66 this->bDead = false; 67 67 68 68 this->subscribeReaction(CREngine::CR_PHYSICS_GROUND_WALK, CL_BSP_ENTITY); 69 69 … … 392 392 State::getGameRules()->onPlayerSpawn(); 393 393 394 395 if( this->getOwner() % 2 == 0)396 {397 // this->toList(OM_GROUP_00);398 this->setAbsCoor(213.37, 57.71, -47.98);399 this->setAbsDir(0, 0, 1, 0);400 }401 else402 { // red team403 // this->toList(OM_GROUP_01);404 this->setAbsCoor(-314.450, 40.701, 83.554);405 this->setAbsDir(1.0, -0.015, -0.012, 0.011);406 }407 394 this->reset(); 408 395 this->bDead = false; -
trunk/src/world_entities/space_ships/space_ship.cc
r8708 r9008 220 220 this->burstSystem->setColor(0.5, .5,.5,.8,.8); 221 221 this->burstSystem->setColor(1.0, .8,.8,.8,.0); 222 222 223 223 registerVar( new SynchronizeableVector( &velocity, &velocity, "velocity" ) ); 224 224 registerVar( new SynchronizeableQuaternion( &mouseDir, &mouseDir, "mousedir", PERMISSION_OWNER ) ); … … 384 384 this->shiftCoor(move); 385 385 386 // PRINTF(0)("id of %s is: %i\n", this->getName(), this->getOMListNumber()); 386 387 387 388 } … … 504 505 } 505 506 506 507 508 507 void SpaceShip::destroy( ) 508 { 509 PRINTF(0)("spaceship destroy\n"); 510 } 511 512 void SpaceShip::respawn( ) 513 { 514 toList( OM_PLAYERS ); 515 } 516 517 518 519 -
trunk/src/world_entities/space_ships/space_ship.h
r7954 r9008 36 36 virtual void postSpawn(); 37 37 virtual void leftWorld(); 38 39 virtual void destroy(); 40 virtual void respawn(); 38 41 39 42 virtual void collidesWith(WorldEntity* entity, const Vector& location); -
trunk/src/world_entities/spawning_point.cc
r8802 r9008 22 22 #include "world_entity.h" 23 23 24 #include "class_list.h" 25 24 26 #include "compiler.h" 25 27 … … 27 29 #include "game_rules.h" 28 30 31 #include "shared_network_data.h" 32 33 CREATE_FACTORY( SpawningPoint, CL_SPAWNING_POINT ); 29 34 30 35 /** 31 36 * constructor 32 37 */ 33 SpawningPoint::SpawningPoint (ClassID classid, const Vector& position) 34 { 35 this->setAbsCoor(position); 36 this->classid = classid; 37 this->mode = SPT_ALL_AT_ONCE; 38 this->delay = 0; 38 SpawningPoint::SpawningPoint( const TiXmlElement * root ) 39 { 40 this->setAbsCoor( 0, 0, 0 ); 39 41 40 42 this->init(); 41 } 42 43 44 /** 45 * standard constructor 46 */ 47 SpawningPoint::SpawningPoint (const Vector& position, ClassID classid, SpawningPointMode mode, float delay) 48 { 49 this->setAbsCoor(position); 50 this->classid = classid; 51 this->mode = mode; 52 this->delay = delay; 53 54 this->init(); 55 } 56 57 43 44 if (root != NULL) 45 this->loadParams(root); 46 } 58 47 59 48 void SpawningPoint::init() 60 49 { 61 50 this->setClassID(CL_SPAWNING_POINT, "SpawningPoint"); 51 PRINTF(0)("Created SpawningPoint\n"); 62 52 63 53 this->teamId = -1; 54 this->localTimer = 0.0f; 55 56 this->toList( OM_DEAD_TICK ); 57 58 MessageManager::getInstance()->registerMessageHandler( MSGID_RESPAWN, respawnMessageHandler, NULL ); 64 59 } 65 60 … … 81 76 WorldEntity::loadParams(root); 82 77 83 /* now load the frequency */84 LoadParam(root, "delay", this, SpawningPoint, setSpawningDelay)85 .describe("sets the delay of the spawning point");86 87 78 /* load teamId */ 88 79 LoadParam(root, "teamId", this, SpawningPoint, setTeamId) 89 80 .describe("sets teamId"); 90 91 92 /* now load the seed */93 // LoadParam(root, "entity", this, SpawningPoint, setSpawningEntity)94 // .describe("sets the spawning entity");95 96 /* now load the seed */97 /* LoadParam(root, "classid", this, SpawningPoint, setSpawningEntity)98 .describe("sets the class id of the entity to spawn")99 .defaultValues(CL_WORLD_ENTITY);*/100 81 } 101 82 … … 106 87 * @param entity WorldEntity to be added 107 88 */ 108 void SpawningPoint::pushEntity( WorldEntity* entity, float delay)89 void SpawningPoint::pushEntity(Playable* entity, float delay) 109 90 { 110 91 QueueEntry qe; 111 92 qe.entity = entity; 112 qe.list = entity->getOMListNumber();113 93 qe.respawnTime = this->localTimer + delay; 114 94 … … 120 100 * spawn the entity 121 101 */ 122 void SpawningPoint::spawn( WorldEntity* entity)123 { 124 PRINTF( 1)("Spawningpoint spawns newEntity (%s)\n", entity->getClassName());102 void SpawningPoint::spawn(Playable* entity) 103 { 104 PRINTF(0)("Spawningpoint spawns Entity (%s)\n", entity->getClassName()); 125 105 126 106 … … 129 109 130 110 //TODO set camera (not smooth) 111 112 if ( State::getGameRules() ) 113 { 114 (State::getGameRules())->registerSpawn( entity ); 115 } 116 117 entity->respawn(); 131 118 } 132 119 … … 141 128 { 142 129 this->localTimer += dt; 143 144 130 std::list<QueueEntry>::iterator it = this->queue.begin(); 145 131 for( ; it != this->queue.end(); ) 146 132 { 147 133 //PRINTF(0)("%f <= %f\n", it->respawnTime, this->localTimer); 148 134 if( it->respawnTime <= this->localTimer) 149 135 { … … 151 137 this->spawn(it->entity); 152 138 153 it->entity->toList( it->list ); 154 155 if ( State::getGameRules() ) 156 { 157 (State::getGameRules())->registerSpawn( it->entity ); 158 } 159 139 if ( SharedNetworkData::getInstance()->isGameServer() ) 140 this->sendRespawnMessage( it->entity->getUniqueID() ); 141 160 142 std::list<QueueEntry>::iterator delit = it; 161 143 it++; … … 179 161 */ 180 162 void SpawningPoint::draw() 181 {} 163 { 164 } 165 166 void SpawningPoint::sendRespawnMessage( int uniqueId ) 167 { 168 byte * buf = new byte[2*INTSIZE]; 169 170 assert( Converter::intToByteArray( this->getUniqueID(), buf, INTSIZE ) == INTSIZE ); 171 assert( Converter::intToByteArray( uniqueId, buf + INTSIZE, INTSIZE ) == INTSIZE ); 172 173 MessageManager::getInstance()->sendMessage( MSGID_RESPAWN, buf, 2*INTSIZE, RT_ALL_NOT_ME, 0, MP_HIGHBANDWIDTH ); 174 } 175 176 bool SpawningPoint::respawnMessageHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId ) 177 { 178 if ( SharedNetworkData::getInstance()->isGameServer() ) 179 { 180 PRINTF(2)("server received spawn message!\n"); 181 return true; 182 } 183 184 int spUniqueId; 185 int uniqueId; 186 187 if ( dataLength != 2*INTSIZE ) 188 { 189 PRINTF(2)("spawn message has wrong size: %d\n", dataLength ); 190 return true; 191 } 192 193 assert( Converter::byteArrayToInt( data, &spUniqueId ) == INTSIZE ); 194 assert( Converter::byteArrayToInt( data+INTSIZE, &uniqueId ) == INTSIZE ); 195 196 SpawningPoint * sp = NULL; 197 Playable * playable = NULL; 198 199 const std::list<BaseObject*> * list = ClassList::getList( CL_SPAWNING_POINT ); 200 201 if ( list ) 202 { 203 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 204 { 205 if ( dynamic_cast<SpawningPoint*>(*it)->getUniqueID() == uniqueId ) 206 { 207 sp = dynamic_cast<SpawningPoint*>(*it); 208 break; 209 } 210 } 211 } 212 213 if ( !sp ) 214 { 215 PRINTF(2)("could not find spawning point\n"); 216 return false; 217 } 218 219 list = ClassList::getList( CL_PLAYABLE ); 220 221 if ( list ) 222 { 223 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 224 { 225 if ( dynamic_cast<Playable*>(*it)->getUniqueID() == uniqueId ) 226 { 227 playable = dynamic_cast<Playable*>(*it); 228 break; 229 } 230 } 231 } 232 233 if ( !playable ) 234 { 235 PRINTF(2)("could not find playable\n"); 236 return false; 237 } 238 239 sp->spawn( playable ); 240 241 return true; 242 } 243 -
trunk/src/world_entities/spawning_point.h
r8802 r9008 10 10 #include "playable.h" 11 11 12 #include "message_manager.h" 13 12 14 #include <list> 13 15 … … 18 20 { 19 21 float respawnTime; 20 WorldEntity * entity; 21 OM_LIST list; 22 Playable * entity; 22 23 }; 23 24 … … 43 44 44 45 public: 45 SpawningPoint (ClassID classID, const Vector& position = Vector(0.0, 0.0, 0.0)); 46 SpawningPoint (const Vector& position, ClassID classID, SpawningPointMode type, float delay); 46 SpawningPoint(const TiXmlElement* root = NULL); 47 47 virtual ~SpawningPoint (); 48 48 void init(); … … 50 50 virtual void loadParams(const TiXmlElement* root); 51 51 52 /** sets the entity that is going to be spawned by this point @param classID: the id from the class_id.h file */53 void SpawningPoint::setSpawningEntity(ClassID classid) { this->classid = classid; }54 /** sets the frequency with which the point is going to spawn entities (1/sec) @param frequency: the frequency */55 void SpawningPoint::setSpawningDelay(float delay) { this->delay = delay; }56 /** sets the spawning point mode @param mode: the mode */57 void SpawningPoint::setSpawningMode(int mode) { this->mode = (SpawningPointMode)mode; }58 59 52 inline int getTeamId(){ return this->teamId; } 60 53 inline void setTeamId( int teamId ){ this->teamId = teamId; } 61 54 62 void pushEntity( WorldEntity* entity, float delay = 0);55 void pushEntity(Playable* entity, float delay = 0); 63 56 64 57 /** activates the spawning point */ … … 74 67 75 68 private: 76 void spawn(WorldEntity* entity); 69 void spawn(Playable* entity); 70 71 void sendRespawnMessage( int uniqueId ); 72 static bool respawnMessageHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId ); 77 73 78 74 79 75 private: 80 float delay; //!< the timer that counts down until the next spawn81 76 float localTimer; //!< the local timer 82 float seed; //!< the random seed of the position83 77 int teamId; //!< only spawn players of this team 84 ClassID classid; //!< the classid of the entity to spawn85 SpawningPointMode mode; //!< the mode of the spawning point86 78 std::list<QueueEntry> queue; //!< queue of waiting WorldEntities to be spawned 87 79 bool bSpawning; //!< flag to indicate if this spawning point is active or not -
trunk/src/world_entities/world_entity.cc
r9003 r9008 88 88 modelFileName_handle = registerVarId( new SynchronizeableString( &modelFileName, &modelFileName, "modelFileName" ) ); 89 89 scaling_handle = registerVarId( new SynchronizeableFloat( &scaling, &scaling, "scaling" ) ); 90 list_handle = registerVarId( new SynchronizeableInt( (int*)&objectListNumber, &list_write, "list" ) ); 90 91 } 91 92 … … 733 734 * @param damage damage to be dealt 734 735 */ 735 void WorldEntity::hit(float damage )736 void WorldEntity::hit(float damage, WorldEntity* killer) 736 737 { 737 738 this->decreaseHealth(damage); … … 748 749 749 750 if( State::getGameRules() != NULL) 750 State::getGameRules()->registerKill(Kill( NULL, this));751 State::getGameRules()->registerKill(Kill(killer, this)); 751 752 } 752 753 } … … 832 833 } 833 834 835 if ( std::find( id.begin(), id.end(), list_handle ) != id.end() ) 836 { 837 this->toList( (OM_LIST)list_write ); 838 } 839 834 840 PNode::varChangeHandler( id ); 835 841 } -
trunk/src/world_entities/world_entity.h
r9003 r9008 99 99 void setOnGround(bool flag) { this->bOnGround = flag; } 100 100 101 virtual void hit(float damage); 101 virtual void hit(float damage, WorldEntity* killer); 102 102 103 virtual void destroy(); 103 104 … … 195 196 int modelFileName_handle; //!< handle for syncing var 196 197 198 int list_write; //!< entity's list 199 int list_handle; //!< handle for list changes 200 197 201 CollisionHandle* collisionHandles[CREngine::CR_NUMBER]; //!< the list of the collision reactions 198 202 bool bReactive; //!< true if there is at least one collision reaction subscibed
Note: See TracChangeset
for help on using the changeset viewer.