Changeset 9705 in orxonox.OLD for branches/new_class_id
- Timestamp:
- Aug 25, 2006, 9:44:53 PM (18 years ago)
- Location:
- branches/new_class_id/src
- Files:
-
- 46 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/lib/Makefile.am
r9700 r9705 16 16 data/data_tank.h 17 17 18 SUBDIRS = \19 . \18 SUBDIRS = 19 # . \ 20 20 math \ 21 21 lang \ -
branches/new_class_id/src/lib/lang/base_object.h
r9691 r9705 48 48 inline const std::string& getClassName() const { return _classes.front()._objectList->name(); } 49 49 50 inline const NewClassID& getClassID() const { return *_leafClassID; } 50 51 /** @returns the ID of the Topmost object of the ClassStack */ 51 52 inline const int& getLeafClassID() const { return _leafClassID->id(); } -
branches/new_class_id/src/lib/lang/new_object_list.cc
r9701 r9705 104 104 105 105 /** 106 * @brief searches for a NewClassID in the list of all NewObjectLists, and returns its Identity 107 * @param id: The Id to search for 108 * @returns the ClassID if found and NullClass' identity if not. 109 */ 110 const NewClassID& NewObejctListBase::retrieveIdentity(int id) 111 { 112 const NewObjectListBase* const base = NewObjectListBase::getObjectList(id); 113 114 if (base != NULL) 115 return base->_identity; 116 else 117 return NullClass::classID(); 118 } 119 120 /** 121 * @brief searches for a NewClassID in the list of all NewObjectLists, and returns its Identity 122 * @param name: The Name to search for 123 * @returns the ClassID if found and NullClass' identity if not. 124 */ 125 const NewClassID& NewObjectListBase::retrieveIdentity(const std::string& name) 126 { 127 const NewObjectListBase* const base = NewObjectListBase::getObjectList(name); 128 129 if (base != NULL) 130 return base->_identity; 131 else 132 return NullObject::classID(); 133 } 134 135 136 /** 106 137 * @brief Checks if a Class with name already exists. 107 138 * @param name The Name of the Class to check. -
branches/new_class_id/src/lib/lang/new_object_list.h
r9702 r9705 44 44 //! A fast iterator Base-Class, for iterator-casting and storing. 45 45 /** 46 * @note This Iterator is explicitely used only for storage purposes 46 * @note This Iterator is explicitely used only for storage purposes in the BaseObject 47 47 */ 48 48 class IteratorBase { }; 49 49 50 typedef std::list<BaseObject*> base_list; 51 typedef base_list::iterator base_iterator; 52 50 53 public: 54 /** @returns The Identity of the Class stored within. */ 51 55 inline const NewClassID& identity() const { return _identity; } 56 /** @returns the ID of the Identity of the ObjectList */ 52 57 inline int id() const { return _id; }; 58 /** @returns The Name of the Class stored in this ObjectList */ 53 59 inline const std::string& name() const { return _name; }; 54 bool operator==(int id) const { return _id == id; }; 55 bool operator==(const NewClassID& id) const { return id == _id; }; 56 bool operator==(const std::string& name) const { return _name == name; }; 57 58 void acquireID(const int*& id, const std::string*& name) const { id = &_id; name = &_name; }; 59 60 virtual void debug() const = 0; 60 /** @param id The id to compare @returns true on match, false otherwise */ 61 inline bool operator==(int id) const { return _id == id; }; 62 /** @param id The id to compare @returns true on match, false otherwise */ 63 inline bool operator==(const NewClassID& id) const { return id == _id; }; 64 /** @param name The name to compare @returns true on match, false otherwise */ 65 inline bool operator==(const std::string& name) const { return _name == name; }; 66 /** @param id The id to check @returns true on match, false otherwise */ 67 inline void acquireID(const int*& id, const std::string*& name) const { id = &_id; name = &_name; }; 68 /** @brief fills a list of Objects into a BaseObject*-List. @param list the list to fill */ 69 virtual void getBaseObjectList(base_list* list) const = 0; 70 71 static const NewClassID& retrieveIdentity(int id); 72 static const NewClassID& retrieveIdentity(const std::string& name); 73 74 static const NewObjectListBase* const getObjectList(int classID); 75 static const NewObjectListBase* const getObjectList(const std::string& className); 76 static const NewObjectListBase* const getObjectList(const NewClassID& classID); 77 78 static BaseObject* getBaseObject(int classID, const std::string& objectName); 79 static BaseObject* getBaseObject(const std::string& className, const std::string& objectName); 80 static BaseObject* getBaseObject(const NewClassID& classID, const std::string& objectName); 81 82 /** @returns an Object with Name name out of this List @param name the name of the Object. */ 83 virtual BaseObject* getBaseObject(const std::string& name) const = 0; 84 85 static const std::list<std::string>& getClassNames(); 61 86 62 87 static unsigned int classCount(); … … 64 89 static int StringToID(const std::string& className); 65 90 66 static const std::list<std::string>& getClassNames(); 67 91 virtual void debug() const = 0; 92 93 //! Only uset to unsubscribe a BaseObject. 68 94 virtual void unregisterObject(IteratorBase* _iterators) = 0; 69 70 public:71 typedef std::list<BaseObject*> base_list;72 typedef std::list<BaseObject*>::iterator base_iterator;73 74 virtual void getBaseObjectList(base_list* list) const = 0;75 76 static const NewObjectListBase* const getObjectList(int classID);77 static const NewObjectListBase* const getObjectList(const std::string& className);78 static const NewObjectListBase* const getObjectList(const NewClassID& classID);79 80 static BaseObject* getBaseObject(int classID, const std::string& objectName);81 static BaseObject* getBaseObject(const std::string& className, const std::string& objectName);82 static BaseObject* getBaseObject(const NewClassID& classID, const std::string& objectName);83 84 virtual BaseObject* getBaseObject(const std::string& name) const = 0;85 95 86 96 protected: … … 99 109 typedef std::map<std::string, NewObjectListBase*> classNameMap; //!< The Generic Map. 100 110 111 private: 101 112 int _id; 102 113 const std::string _name; //!< The Name of the Class. … … 146 157 T* getObject(const std::string& name) const; 147 158 inline const list& objects() const { return _objects; }; 159 bool exists(const T* const object) const; 148 160 149 161 inline iterator begin() { return _objects.begin(); }; … … 157 169 inline T* back() const { return _objects.back(); }; 158 170 171 159 172 NewObjectListBase::IteratorBase* registerObject(T* object); 160 v oid unregisterObject(IteratorBase* iterator);173 virtual void unregisterObject(IteratorBase* iterator); 161 174 162 175 virtual void debug() const; … … 233 246 234 247 /** 248 * @brief checks if Object object exists in this ClassList. 249 * @param object the Object to check for 250 * @returns True if the object is found within the List, false otherwise 251 */ 252 template <class T> 253 bool NewObjectList<T>::exists(const T* const object) const 254 { 255 return (std::find(_objects.begin(), _objects.end(), object) != _objects.end()); 256 } 257 258 259 /** 235 260 * @brief retrieves a List of BaseObjects 236 261 * @param list the list to push the ObjectList into. -
branches/new_class_id/src/util/animation/animation.cc
r5777 r9705 20 20 #include "animation_player.h" 21 21 22 NewObjectListDefinition(Animation); 22 23 /** 23 24 * creates a new Animation … … 27 28 Animation::Animation() 28 29 { 29 this-> setClassID(CL_ANIMATION, "Animation");30 this->registerObject(this, Animation::_objectList); 30 31 31 32 // initialize a beginning KeyFrame, that will be deleted afterwards -
branches/new_class_id/src/util/animation/animation.h
r6222 r9705 73 73 class Animation : public BaseObject 74 74 { 75 public: 75 NewObjectListDeclaration(Animation); 76 public: 76 77 virtual ~Animation(); 77 78 … … 95 96 inline bool ifDelete() { return bDelete; }; 96 97 97 98 protected: 98 99 Animation(); 99 100 100 101 void handleInfinity(); 101 102 102 103 protected: 103 104 // variables 104 105 float localTime; //!< The Time passed since the beginning of the currentKeyFrame. … … 119 120 class aTest 120 121 { 121 122 public: 122 123 inline aTest() { last = 0.0;} 123 124 /** a little debug information to show the results of this class @param f new value */ 124 125 inline void littleDebug(float f) { diff = f - last; printf("f=%f, diff=%f\n", f,diff); last = f;} 125 126 private: 126 127 float diff; //!< difference from the last value 127 128 float last; //!< the last calculated value -
branches/new_class_id/src/util/animation/animation_player.cc
r9406 r9705 22 22 23 23 24 24 NewObjectListDefinition(AnimationPlayer); 25 25 /** 26 26 * standard constructor … … 28 28 AnimationPlayer::AnimationPlayer () 29 29 { 30 this-> setClassID(CL_ANIMATION_PLAYER, "AnimationPlayer");30 this->registerObject(this, AnimationPlayer::_objectList); 31 31 this->setName("AnimationPlayer"); 32 32 -
branches/new_class_id/src/util/animation/animation_player.h
r5777 r9705 28 28 eveything else will be done by the AnimationPlayer itself.\n 29 29 */ 30 class AnimationPlayer : public BaseObject { 30 class AnimationPlayer : public BaseObject 31 { 32 NewObjectListDeclaration(AnimationPlayer); 31 33 32 34 public: 33 35 /** @returns a Pointer to the only object of this Class */ 34 36 inline static AnimationPlayer* getInstance() { if (!singletonRef) singletonRef = new AnimationPlayer(); return singletonRef; }; … … 50 52 void debug(); 51 53 52 54 private: 53 55 /* singleton */ 54 56 AnimationPlayer(); -
branches/new_class_id/src/util/kill_target.cc
r9406 r9705 22 22 23 23 24 24 #include "class_id.h" 25 25 CREATE_FACTORY(KillTarget, CL_KILL_TARGET); 26 NewObjectListDefinitionID(KillTarget, CL_KILL_TARGET); 26 27 27 28 … … 32 33 KillTarget::KillTarget (const TiXmlElement* root) 33 34 : MissionGoal(root) { 34 this->setClassID(CL_KILL_TARGET, "KillTarget");35 this->registerObject(this, KillTarget::_objectList); 35 36 36 37 if( root != NULL) -
branches/new_class_id/src/util/kill_target.h
r7464 r9705 17 17 class KillTarget : public MissionGoal 18 18 { 19 NewObjectListDeclaration(KillTarget); 19 20 20 21 public: -
branches/new_class_id/src/util/mission_goal.cc
r9406 r9705 24 24 25 25 26 26 NewObjectListDefinition(MissionGoal); 27 27 /** 28 28 * standard constructor … … 31 31 MissionGoal::MissionGoal (const TiXmlElement* root) 32 32 { 33 this->setClassID(CL_MISSION_GOAL, "MissionGoal");33 this->registerObject(this, MissionGoal::_objectList); 34 34 35 35 this->missionState = MS_PASSIVE; -
branches/new_class_id/src/util/mission_goal.h
r7464 r9705 26 26 //! A class representing a mission goal 27 27 class MissionGoal : public BaseObject { 28 NewObjectListDeclaration(MissionGoal); 28 29 29 30 public: -
branches/new_class_id/src/util/multiplayer_team_deathmatch.cc
r9704 r9705 56 56 */ 57 57 MultiplayerTeamDeathmatch::MultiplayerTeamDeathmatch(const TiXmlElement* root) 58 : NetworkGameRules(root)58 : NetworkGameRules(root) 59 59 { 60 60 this->registerObject(this, MultiplayerTeamDeathmatch::_objectList); … … 111 111 112 112 LoadParam(root, "death-penalty-timeout", this, MultiplayerTeamDeathmatch, setDeathPenaltyTimeout) 113 113 .describe("sets the time in seconds a player has to wait for respawn"); 114 114 115 115 LoadParam(root, "max-kills", this, MultiplayerTeamDeathmatch, setMaxKills) 116 116 .describe("sets the maximal kills for winning condition"); 117 117 118 118 LoadParam(root, "num-teams", this, MultiplayerTeamDeathmatch, setNumTeams) 119 119 .describe("sets number of teams"); 120 120 121 121 } … … 189 189 } 190 190 191 // if( PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() ) )192 // {193 // PRINTF(0)("prefered team id: %i, noteam: %i\n", PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )->getPreferedTeamId(), TEAM_NOTEAM);194 // }191 // if( PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() ) ) 192 // { 193 // PRINTF(0)("prefered team id: %i, noteam: %i\n", PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )->getPreferedTeamId(), TEAM_NOTEAM); 194 // } 195 195 196 196 // check if the menu should be removed and the game state should be entered … … 270 270 if( unlikely( this->bLocalPlayerDead)) 271 271 { 272 273 272 } 274 273 } … … 305 304 { 306 305 if ( team == TEAM_NOTEAM || team == TEAM_SPECTATOR ) 307 return CL_SPECTATOR;306 return NewObjectListBase::retrieveIdentity("Spectator"); 308 307 309 308 if ( team == 0 || team == 1 ) 310 return CL_TURBINE_HOVER;309 return NewObjectListBase::retrieveIdentity("TurbineHover"); 311 310 312 311 assert( false ); … … 314 313 315 314 316 std::string MultiplayerTeamDeathmatch::getPlayableModelFileName( int userId, int team, ClassIDclassId )315 std::string MultiplayerTeamDeathmatch::getPlayableModelFileName( int userId, int team, const NewClassID& classId ) 317 316 { 318 317 if (classId == CL_TURBINE_HOVER) 319 return "models/ships/hoverglider_mainbody.obj";318 return "models/ships/hoverglider_mainbody.obj"; 320 319 if ( team == 0 ) 321 320 return "models/creatures/doom_guy.md2"; … … 326 325 } 327 326 328 std::string MultiplayerTeamDeathmatch::getPlayableModelTextureFileName( int userId, int team, ClassIDclassId )327 std::string MultiplayerTeamDeathmatch::getPlayableModelTextureFileName( int userId, int team, const NewClassID& classId ) 329 328 { 330 329 if ( classId == CL_FPS_PLAYER ) … … 339 338 } 340 339 341 float MultiplayerTeamDeathmatch::getPlayableScale( int userId, int team, ClassIDclassId )342 { 343 if ( classId == CL_FPS_PLAYER)340 float MultiplayerTeamDeathmatch::getPlayableScale( int userId, int team, const NewClassID& classId ) 341 { 342 if ( classId == NewObjectListBase::retrieveIdentity(CL_FPS_PLAYER)) 344 343 { 345 344 return 10.0f; … … 359 358 teamScore[i] = 0; 360 359 361 362 const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS ); 363 364 if ( !list ) 365 return; 366 367 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 368 { 369 PlayerStats & stats = *dynamic_cast<PlayerStats*>(*it); 360 for (NewObjectList<PlayerStats>::const_iterator it = PlayerStats::objectList().begin(); 361 it != PlayerStats::objectList().end(); 362 ++it) 363 { 364 PlayerStats & stats = *(*it); 370 365 371 366 if ( stats.getTeamId() >= 0 ) … … 387 382 playersInTeam[i] = 0; 388 383 389 const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS ); 390 391 if ( !list ) 392 return 0; 393 394 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 395 { 396 PlayerStats & stats = *dynamic_cast<PlayerStats*>(*it); 384 for (NewObjectList<PlayerStats>::const_iterator it = PlayerStats::objectList().begin(); 385 it != PlayerStats::objectList().end(); 386 ++it) 387 { 388 PlayerStats & stats = *(*it); 397 389 398 390 if ( stats.getTeamId() >= 0 ) … … 450 442 void MultiplayerTeamDeathmatch::handleTeamChanges( ) 451 443 { 452 const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS ); 453 454 if ( !list ) 455 return; 456 457 //first server players with choices 458 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 459 { 460 PlayerStats & stats = *dynamic_cast<PlayerStats*>(*it); 444 for (NewObjectList<PlayerStats>::const_iterator it = PlayerStats::objectList().begin(); 445 it != PlayerStats::objectList().end(); 446 ++it) 447 { 448 PlayerStats & stats = *(*it); 461 449 462 450 if ( stats.getTeamId() != stats.getPreferedTeamId() ) … … 470 458 471 459 //now serve player who want join a random team 472 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 473 { 474 PlayerStats & stats = *dynamic_cast<PlayerStats*>(*it); 460 for (NewObjectList<PlayerStats>::const_iterator it = PlayerStats::objectList().begin(); 461 it != PlayerStats::objectList().end(); 462 ++it) 463 { 464 PlayerStats & stats = *(*it); 475 465 476 466 if ( stats.getTeamId() != stats.getPreferedTeamId() ) … … 501 491 502 492 503 ClassID playableClassId = getPlayableClassId( userId, stats.getPreferedTeamId() );493 NewClassID playableClassId = getPlayableClassId( userId, stats.getPreferedTeamId() ); 504 494 std::string playableModel = getPlayableModelFileName( userId, stats.getPreferedTeamId(), playableClassId ); 505 495 std::string playableTexture = getPlayableModelTextureFileName( userId, stats.getPreferedTeamId(), playableClassId ); … … 584 574 if ( event.bPressed ) 585 575 this->bShowTeamChange = true; 586 } else if ( event.type == SDLK_F1 ) 576 } 577 else if ( event.type == SDLK_F1 ) 587 578 { 588 579 if ( this->statsBox && !this->bLocalPlayerDead && event.bPressed ) … … 680 671 void MultiplayerTeamDeathmatch::hideStats( ) 681 672 { 682 683 684 685 686 673 if ( statsBox ) 674 { 675 delete statsBox; 676 statsBox = NULL; 677 } 687 678 } 688 679 … … 819 810 void MultiplayerTeamDeathmatch::respawnPlayable( Playable * playable, int teamId, float delay ) 820 811 { 821 const std::list<BaseObject*> * list = ClassList::getList( CL_SPAWNING_POINT );822 823 assert( list );824 812 825 813 std::vector<SpawningPoint*> spList; 826 814 827 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 828 { 829 SpawningPoint * sp = dynamic_cast<SpawningPoint*>(*it); 815 for (NewObjectList<SpawningPoint>::const_iterator it = SpawningPoint::objectList().begin(); 816 it != SpawningPoint::objectList().end(); 817 ++it) 818 { 819 SpawningPoint * sp = (*it); 830 820 831 821 if ( sp->getTeamId() == teamId ) … … 835 825 if ( spList.size() == 0 ) 836 826 { 837 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 838 { 839 SpawningPoint * sp = dynamic_cast<SpawningPoint*>(*it); 827 for (NewObjectList<SpawningPoint>::const_iterator it = SpawningPoint::objectList().begin(); 828 it != SpawningPoint::objectList().end(); 829 ++it) 830 { 831 SpawningPoint * sp = (*it); 840 832 841 833 if ( sp->getTeamId() < 0 ) -
branches/new_class_id/src/util/singleplayer_shootemup.cc
r9406 r9705 25 25 26 26 27 27 #include "class_id.h" 28 28 CREATE_FACTORY(SingleplayerShootemup, CL_SINGLEPLAYER_SHOOTEMUP); 29 30 29 NewObjectListDefinitionID(SingleplayerShootemup, CL_SINGLEPLAYER_SHOOTEMUP); 31 30 32 31 /** … … 36 35 : GameRules(root) 37 36 { 38 this-> setClassID(CL_SINGLEPLAYER_SHOOTEMUP, "SingleplayerShootemup");37 this->registerObject(this, SingleplayerShootemup::_objectList); 39 38 40 39 if( root != NULL) -
branches/new_class_id/src/util/singleplayer_shootemup.h
r7464 r9705 18 18 class SingleplayerShootemup : public GameRules 19 19 { 20 20 NewObjectListDeclaration(SingleplayerShootemup); 21 21 public: 22 22 SingleplayerShootemup(const TiXmlElement* root = NULL); -
branches/new_class_id/src/util/track/pilot_node.cc
r7868 r9705 24 24 25 25 26 NewObjectListDefinition(PilotNode); 26 27 /** 27 28 * standard constructor … … 29 30 PilotNode::PilotNode () 30 31 { 31 this->setClassID(CL_PILOT_PARENT, "PilotNode");32 this->registerObject(this, PilotNode::_objectList); 32 33 this->setName("PilotNode"); 33 34 -
branches/new_class_id/src/util/track/pilot_node.h
r5039 r9705 15 15 //! The PilotNode is a node that enables the is driven by the Mouse 16 16 class PilotNode : public WorldEntity, public EventListener { 17 NewObjectListDeclaration(PilotNode); 17 18 18 19 public: -
branches/new_class_id/src/world_entities/camera.cc
r9406 r9705 19 19 #include "glincl.h" 20 20 21 NewObjectListDefinition(Camera); 22 21 23 /** 22 24 * creates a Camera … … 24 26 Camera::Camera() 25 27 { 26 this-> setClassID(CL_CAMERA, "Camera");28 this->registerObject(this, Camera::_objectList); 27 29 this->setName("camera"); 28 30 this->target = new CameraTarget(); … … 221 223 /////////////////// 222 224 223 225 NewObjectListDefinition(CameraTarget); 224 226 CameraTarget::CameraTarget() 225 227 { 226 this-> setClassID(CL_CAMERA_TARGET, "CameraTarget");228 this->registerObject(this, CameraTarget::_objectList); 227 229 // this->setParentMode(PNODE_MOVEMENT); 228 230 } -
branches/new_class_id/src/world_entities/camera.h
r7347 r9705 22 22 class Camera : public PNode, public EventListener 23 23 { 24 NewObjectListDeclaration(Camera); 24 25 public: 25 26 //! an enumerator for different types of view … … 84 85 { 85 86 friend class Camera; //! The CameraTarget is a friend of Camera. noone else needs a CameraTarget, so noone else can create it. 87 NewObjectListDeclaration(CameraTarget); 86 88 87 89 private: -
branches/new_class_id/src/world_entities/npcs/npc.cc
r9235 r9705 20 20 #include "npc.h" 21 21 22 NewObjectListDefinition(NPC); 22 23 23 24 NPC::NPC(const TiXmlElement* root) 24 25 { 25 this-> setClassID(CL_NPC, "NPC");26 this->registerObject(this, NPC::_objectList); 26 27 27 28 this->toList(OM_GROUP_00); -
branches/new_class_id/src/world_entities/npcs/npc.h
r8724 r9705 8 8 9 9 class NPC : public WorldEntity { 10 10 NewObjectListDeclaration(NPC); 11 11 public: 12 12 NPC (const TiXmlElement* root); -
branches/new_class_id/src/world_entities/npcs/npc_test1.cc
r9235 r9705 25 25 #include "power_ups/laser_power_up.h" 26 26 27 NewObjectListDefinition(NPCTest1); 27 28 28 29 NPCTest1::NPCTest1() 29 30 : NPC(NULL) 30 31 { 31 this-> setClassID(CL_NPC_TEST1, "NPCTest1");32 this->registerObject(this, NPCTest1::_objectList); 32 33 33 34 if ((float)rand()/RAND_MAX > .5f) -
branches/new_class_id/src/world_entities/npcs/npc_test1.h
r6981 r9705 8 8 9 9 class NPCTest1 : public NPC { 10 10 NewObjectListDeclaration(NPCTest1); 11 11 public: 12 12 NPCTest1 (); -
branches/new_class_id/src/world_entities/playable.cc
r9691 r9705 41 41 SHELL_COMMAND_STATIC(orxoWeapon, Playable, Playable::addSomeWeapons_CHEAT) 42 42 ->setAlias("orxoWeapon"); 43 NewObjectListDefinition(Playable) 43 NewObjectListDefinition(Playable); 44 44 45 45 Playable::Playable() … … 48 48 playmode(Playable::Full3D) 49 49 { 50 this->registerObject(this, Playable::_ classID);50 this->registerObject(this, Playable::_objectList); 51 51 PRINTF(4)("PLAYABLE INIT\n"); 52 52 … … 109 109 bool Playable::pickup(PowerUp* powerUp) 110 110 { 111 if(powerUp->isA(CL_WEAPON_POWER_UP)) 112 { 113 return dynamic_cast<WeaponPowerUp*>(powerUp)->process(&this->getWeaponManager()); 114 } 115 else if(powerUp->isA(CL_PARAM_POWER_UP)) 116 { 117 ParamPowerUp* ppu = dynamic_cast<ParamPowerUp*>(powerUp); 111 /// FIXME TOTALLY 112 if(powerUp->isA(WeaponPowerUp::classID())) 113 { 114 return static_cast<WeaponPowerUp*>(powerUp)->process(&this->getWeaponManager()); 115 } 116 else if(powerUp->isA(ParamPowerUp::classID())) 117 { 118 ParamPowerUp* ppu = static_cast<ParamPowerUp*>(powerUp); 118 119 switch(ppu->getType()) 119 120 { … … 213 214 { 214 215 PRINTF(2)("ADDING WEAPONS - you cheater\n"); 215 playable->addWeapon(Weapon::createWeapon( CL_HYPERBLASTER));216 playable->addWeapon(Weapon::createWeapon( CL_TURRET));217 playable->addWeapon(Weapon::createWeapon( CL_AIMING_TURRET));218 playable->addWeapon(Weapon::createWeapon( CL_CANNON));219 playable->addWeapon(Weapon::createWeapon( CL_TARGETING_TURRET));216 playable->addWeapon(Weapon::createWeapon("Hyperblaster")); 217 playable->addWeapon(Weapon::createWeapon("Turret")); 218 playable->addWeapon(Weapon::createWeapon("AimingTurret")); 219 playable->addWeapon(Weapon::createWeapon("Cannon")); 220 playable->addWeapon(Weapon::createWeapon("TargetingTurret")); 220 221 PRINTF(2)("ADDING WEAPONS FINISHED\n"); 221 222 } -
branches/new_class_id/src/world_entities/player.cc
r9062 r9705 19 19 #include "event_handler.h" 20 20 21 22 #include "class_list.h"23 21 #include "state.h" 24 22 #include "util/hud.h" … … 26 24 #include "debug.h" 27 25 28 26 NewObjectListDefinition(Player); 29 27 /** 30 28 * creates a new Player … … 33 31 { 34 32 // this->setRelDir(Quaternion(M_PI, Vector(1,0,0))); 35 this-> setClassID(CL_PLAYER, "Player");33 this->registerObject(this, Player::_objectList); 36 34 37 35 PRINTF(4)("PLAYER INIT\n"); … … 94 92 95 93 96 97 98 99 94 void Player::weaponConfigChanged() 95 { 96 this->_hud.updateWeaponManager(); 97 } 100 98 101 99 … … 103 101 { 104 102 /// FIXME this should be in the ObjectManager 105 const std::list<BaseObject*>* objectList = ClassList::getList(CL_PLAYABLE); 106 if (objectList != NULL) 103 for (NewObjectList<Playable>::const_iterator node = Playable::objectList().begin(); 104 node != Playable::objectList().end(); 105 ++node) 107 106 { 108 std::list<BaseObject*>::const_iterator node; 109 for (node = objectList->begin(); node != objectList->end(); node++) 110 if (this->playable != (*node) && 111 (dynamic_cast<PNode*>(*node)->getAbsCoor() - this->playable->getAbsCoor()).len() < (dynamic_cast<Playable*>(*node)->getEnterRadius())) 112 { 107 if (this->playable != (*node) && 108 ((*node)->getAbsCoor() - this->playable->getAbsCoor()).len() < ((*node)->getEnterRadius())) 109 { 113 110 114 this->setPlayable(dynamic_cast<Playable*>(*node));111 this->setPlayable(*(node)); 115 112 116 117 113 break; 114 } 118 115 } 119 116 } -
branches/new_class_id/src/world_entities/player.h
r9061 r9705 23 23 class Player : public EventListener 24 24 { 25 NewObjectListDeclaration(Player); 25 26 26 27 public: … … 31 32 bool eject(); 32 33 inline Playable* getPlayable() const { return this->playable; }; 33 34 34 35 35 36 inline Hud& hud() { return this->_hud; }; -
branches/new_class_id/src/world_entities/power_ups/param_power_up.cc
r9656 r9705 27 27 28 28 29 29 #include "class_id.h" 30 30 CREATE_FACTORY(ParamPowerUp, CL_PARAM_POWER_UP); 31 NewObjectListDefinitionID(ParamPowerUp, CL_PARAM_POWER_UP); 31 32 32 33 const char* ParamPowerUp::paramTypes[] = { … … 58 59 void ParamPowerUp::init() 59 60 { 60 this-> setClassID(CL_PARAM_POWER_UP, "ParamPowerUp");61 this->registerObject(this, ParamPowerUp::_objectList); 61 62 this->value = 0; 62 63 this->max_value = 0; -
branches/new_class_id/src/world_entities/power_ups/param_power_up.h
r7954 r9705 20 20 21 21 class ParamPowerUp : public PowerUp { 22 NewObjectListDeclaration(ParamPowerUp); 22 23 23 24 public: -
branches/new_class_id/src/world_entities/power_ups/power_up.cc
r9406 r9705 25 25 26 26 27 NewObjectListDefinition(PowerUp); 27 28 28 29 PowerUp::PowerUp(float r, float g, float b) 29 30 { 30 this-> setClassID(CL_POWER_UP, "PowerUp");31 this->registerObject(this, PowerUp::_objectList); 31 32 32 33 this->respawnType = RESPAWN_TIME; … … 120 121 void PowerUp::collidesWith (WorldEntity* entity, const Vector& location) 121 122 { 122 if(this->collider != entity && entity->isA( CL_EXTENDABLE))123 if(this->collider != entity && entity->isA(Extendable::classID())) 123 124 { 124 125 this->collider = entity; -
branches/new_class_id/src/world_entities/power_ups/power_up.h
r7954 r9705 21 21 22 22 class PowerUp : public WorldEntity { 23 NewObjectListDeclaration(PowerUp); 23 24 24 25 public: -
branches/new_class_id/src/world_entities/power_ups/weapon_power_up.cc
r9406 r9705 27 27 28 28 29 29 #include "class_id.h" 30 30 CREATE_FACTORY(WeaponPowerUp, CL_WEAPON_POWER_UP); 31 NewObjectListDefinitionID(WeaponPowerUp, CL_WEAPON_POWER_UP); 31 32 32 33 WeaponPowerUp::WeaponPowerUp(const TiXmlElement* root) : PowerUp(1.0, 1.0, 0.0) … … 45 46 void WeaponPowerUp::init() 46 47 { 47 this-> setClassID(CL_WEAPON_POWER_UP, "WeaponPowerUp");48 this->registerObject(this, WeaponPowerUp::_objectList); 48 49 this->loadPickupSound("sound/powerups/whats this2.wav"); 49 50 -
branches/new_class_id/src/world_entities/power_ups/weapon_power_up.h
r7954 r9705 14 14 15 15 class WeaponPowerUp : public PowerUp { 16 16 NewObjectListDeclaration(WeaponPowerUp); 17 17 public: 18 18 WeaponPowerUp(const TiXmlElement* root = NULL); -
branches/new_class_id/src/world_entities/projectiles/projectile.cc
r9656 r9705 26 26 #include "debug.h" 27 27 28 NewObjectListDefinition(Projectile); 28 29 29 30 /** … … 32 33 Projectile::Projectile () : WorldEntity() 33 34 { 34 this-> setClassID(CL_PROJECTILE, "Projectile");35 this->registerObject(this, Projectile::_objectList); 35 36 36 37 this->lifeCycle = 0.0; -
branches/new_class_id/src/world_entities/projectiles/projectile.h
r9235 r9705 18 18 class Projectile : public WorldEntity 19 19 { 20 NewObjectListDeclaration(Projectile); 20 21 public: 21 22 Projectile (); -
branches/new_class_id/src/world_entities/spawning_point.cc
r9656 r9705 21 21 22 22 #include "world_entity.h" 23 24 #include "class_list.h"25 23 26 24 #include "compiler.h" -
branches/new_class_id/src/world_entities/spawning_point.h
r9656 r9705 42 42 */ 43 43 class SpawningPoint : public WorldEntity { 44 44 NewObjectListDeclaration(SpawningPoint); 45 45 public: 46 46 SpawningPoint(const TiXmlElement* root = NULL); -
branches/new_class_id/src/world_entities/weapons/ammo_container.cc
r9406 r9705 23 23 24 24 25 25 NewObjectListDefinition(AmmoContainer); 26 26 /** 27 27 * standard constructor 28 28 * @todo this constructor is not jet implemented - do it 29 29 */ 30 AmmoContainer::AmmoContainer ( ClassIDprojectileType, float maxEnergy)30 AmmoContainer::AmmoContainer (const NewClassID& projectileType, float maxEnergy) 31 31 { 32 this->setClassID(CL_AMMO_CONTAINER, "AmmoContainer");32 this->registerObject(this, AmmoContainer::_objectList); 33 33 34 35 34 this->projectileType = projectileType; 35 this->maxEnergy = maxEnergy; 36 36 37 37 this->energy = 0.0; 38 38 } 39 39 -
branches/new_class_id/src/world_entities/weapons/ammo_container.h
r9685 r9705 17 17 //! A class for Storing energy of Projectiles. 18 18 class AmmoContainer : public BaseObject { 19 NewObjectListDeclaration(AmmoContainer); 19 20 20 21 public: 21 AmmoContainer( NewClassIDid, float maxEnergy = DEFAULT_MAX_ENERGY);22 AmmoContainer(const NewClassID& id, float maxEnergy = DEFAULT_MAX_ENERGY); 22 23 virtual ~AmmoContainer(); 23 24 -
branches/new_class_id/src/world_entities/weapons/crosshair.cc
r9406 r9705 26 26 27 27 28 28 NewObjectListDefinition(Crosshair); 29 29 /** 30 30 * standart constructor … … 54 54 void Crosshair::init() 55 55 { 56 this-> setClassID(CL_CROSSHAIR, "Crosshair");56 this->registerObject(this, Crosshair::_objectList); 57 57 this->setName("Crosshair"); 58 58 -
branches/new_class_id/src/world_entities/weapons/crosshair.h
r7221 r9705 22 22 //! A class that enables the 23 23 class Crosshair : public PNode, public Element2D, public EventListener { 24 24 NewObjectListDeclaration(Crosshair); 25 25 public: 26 26 Crosshair(const TiXmlElement* root = NULL); -
branches/new_class_id/src/world_entities/weapons/weapon.cc
r9406 r9705 25 25 26 26 #include "util/loading/resource_manager.h" 27 #include "class_list.h"28 27 #include "util/loading/factory.h" 29 28 #include "util/loading/load_param.h" … … 36 35 #include "elements/glgui_energywidget.h" 37 36 38 37 NewObjectListDefinition(Weapon); 39 38 40 39 //////////////////// … … 58 57 { 59 58 for (int i = 0; i < WS_STATE_COUNT; i++) 60 if (this->animation[i] && ClassList::exists(animation[i], CL_ANIMATION)) //!< @todo this should check animation3D59 if (this->animation[i] && Animation::objectList().exists(animation[i])) //!< @todo this should check animation3D 61 60 delete this->animation[i]; 62 61 for (int i = 0; i < WA_ACTION_COUNT; i++) 63 if (this->soundBuffers[i] != NULL && ClassList::exists(this->soundBuffers[i], CL_SOUND_BUFFER))62 if (this->soundBuffers[i] != NULL && OrxSound::SoundBuffer::objectList().exists(this->soundBuffers[i])) 64 63 ResourceManager::getInstance()->unload(this->soundBuffers[i]); 65 64 66 if ( ClassList::exists(this->soundSource, CL_SOUND_SOURCE))65 if (OrxSound::SoundSource::objectList().exists(this->soundSource)) 67 66 delete this->soundSource; 68 67 } … … 73 72 * @returns the newly created Weapon. 74 73 */ 75 Weapon* Weapon::createWeapon( ClassIDweaponID)74 Weapon* Weapon::createWeapon(const NewClassID& weaponID) 76 75 { 77 76 BaseObject* createdObject = Factory::fabricate(weaponID); 78 77 if (createdObject != NULL) 79 78 { 80 if (createdObject->isA( CL_WEAPON))79 if (createdObject->isA(Weapon::classID())) 81 80 return dynamic_cast<Weapon*>(createdObject); 82 81 else … … 89 88 } 90 89 90 Weapon* Weapon::createWeapon(const std::string& weaponName) 91 { 92 BaseObject* createdObject = Factory::fabricate(weaponName); 93 if (createdObject != NULL) 94 { 95 if (createdObject->isA(Weapon::classID())) 96 return dynamic_cast<Weapon*>(createdObject); 97 else 98 { 99 delete createdObject; 100 return NULL; 101 } 102 } 103 return NULL; 104 } 105 106 91 107 /** 92 108 * initializes the Weapon with ALL default values … … 96 112 void Weapon::init() 97 113 { 98 this-> setClassID(CL_WEAPON, "Weapon");114 this->registerObject(this, Weapon::_objectList); 99 115 this->currentState = WS_INACTIVE; //< Normaly the Weapon is Inactive 100 116 this->requestedAction = WA_NONE; //< No action is requested by default … … 115 131 this->defaultTarget = NULL; //< Nothing is Targeted by default. 116 132 117 this->projectile = CL_NULL;//< No Projectile Class is Connected to this weapon133 this->projectile = NullClass::classID(); //< No Projectile Class is Connected to this weapon 118 134 this->projectileFactory = NULL; //< No Factory generating Projectiles is selected. 119 135 … … 163 179 * What it does, is telling the Weapon what Projectiles it can Emit. 164 180 */ 165 void Weapon::setProjectileType(ClassID projectile) 166 { 167 if (projectile == CL_NULL) 168 return; 181 void Weapon::setProjectileType(const NewClassID& projectile) 182 { 169 183 this->projectile = projectile; 170 184 this->projectileFactory = FastFactory::searchFastFactory(projectile); -
branches/new_class_id/src/world_entities/weapons/weapon.h
r9685 r9705 83 83 class Weapon : public WorldEntity 84 84 { 85 NewObjectListDeclaration(Weapon); 86 85 87 public: 86 88 // INITIALISATION // 87 89 Weapon (); 88 90 virtual ~Weapon (); 89 static Weapon* createWeapon(NewClassID weaponID); 91 static Weapon* createWeapon(const NewClassID& weaponID); 92 static Weapon* createWeapon(const std::string& weaponName); 90 93 91 94 void init(); … … 110 113 /** @returns the Capabilities of this Weapon */ 111 114 inline long getCapability() const { return this->capability; }; 112 void setProjectileType( NewClassIDprojectile);115 void setProjectileType(const NewClassID& projectile); 113 116 void setProjectileTypeC(const std::string& projectile); 114 117 /** @returns The projectile's classID */ -
branches/new_class_id/src/world_entities/weapons/weapon_manager.cc
r9406 r9705 22 22 #include "weapon.h" 23 23 #include "crosshair.h" 24 #include "class_list.h"25 24 26 25 #include "playable.h" … … 32 31 33 32 33 NewObjectListDefinition(WeaponManager); 34 34 /** 35 35 * @brief this initializes the weaponManager for a given nnumber of weapon slots … … 57 57 // crosshair being a PNode it must not be deleted (this is because PNodes delete themselves.) 58 58 // rennerc: crosshair seems not to delete itselve 59 if (C lassList::exists(this->crosshair, CL_CROSSHAIR))59 if (Crosshair::objectList().exists(this->crosshair)) 60 60 delete this->crosshair; 61 61 } … … 66 66 void WeaponManager::init() 67 67 { 68 this-> setClassID(CL_WEAPON_MANAGER, "WeaponManager");68 this->registerObject(this, WeaponManager::_objectList); 69 69 70 70 this->parentNode = NULL; … … 298 298 { 299 299 this->parentNode->addChild(weapon); 300 if (this->parentEntity->isA( CL_PLAYABLE))300 if (this->parentEntity->isA(Playable::classID())) 301 301 dynamic_cast<Playable*>(this->parentEntity)->weaponConfigChanged(); 302 302 weapon->setDefaultTarget(this->crosshair); … … 311 311 * @param ammo the ammo to increase 312 312 */ 313 float WeaponManager::increaseAmmunition( ClassIDprojectileType, float ammo)313 float WeaponManager::increaseAmmunition(const NewClassID& projectileType, float ammo) 314 314 { 315 315 return this->getAmmoContainer(projectileType)->increaseEnergy(ammo); … … 324 324 { 325 325 assert (weapon != NULL); 326 return this->increaseAmmunition(weapon->get LeafClassID(), ammo);326 return this->increaseAmmunition(weapon->getClassID(), ammo); 327 327 328 328 } … … 468 468 else 469 469 this->currentSlotConfig[i].position.deactivateNode(); 470 if (this->parentEntity != NULL && this->parentEntity->isA( CL_PLAYABLE))470 if (this->parentEntity != NULL && this->parentEntity->isA(Playable::classID())) 471 471 dynamic_cast<Playable*>(this->parentEntity)->weaponConfigChanged(); 472 472 } … … 523 523 } 524 524 525 CountPointer<AmmoContainer>& WeaponManager::getAmmoContainer( ClassIDprojectileType)525 CountPointer<AmmoContainer>& WeaponManager::getAmmoContainer(const NewClassID& projectileType) 526 526 { 527 527 for (unsigned int i = 0; i < this->ammo.size(); i++) … … 537 537 { 538 538 assert (weapon != NULL); 539 return (this->getAmmoContainer(weapon->get LeafClassID()));539 return (this->getAmmoContainer(weapon->getClassID())); 540 540 } 541 541 -
branches/new_class_id/src/world_entities/weapons/weapon_manager.h
r9685 r9705 39 39 */ 40 40 class WeaponManager : public BaseObject { 41 NewObjectListDeclaration(WeaponManager); 41 42 42 43 //! an enumerator defining a Slot, where a Weapon can be stored inside. … … 89 90 void changeWeaponConfig(int weaponConfig); 90 91 91 float increaseAmmunition( NewClassIDprojectileType, float ammo);92 float increaseAmmunition(const NewClassID& projectileType, float ammo); 92 93 float inclreaseAmmunition(const Weapon* weapon, float ammo); 93 94 … … 106 107 // private: 107 108 int getNextFreeSlot(int configID, long capability = WTYPE_ALL); 108 CountPointer<AmmoContainer>& getAmmoContainer( NewClassIDprojectileType);109 CountPointer<AmmoContainer>& getAmmoContainer(const NewClassID& projectileType); 109 110 CountPointer<AmmoContainer>& getAmmoContainer(const Weapon* weapon); 110 111 -
branches/new_class_id/src/world_entities/world_entity.cc
r9656 r9705 47 47 SHELL_COMMAND(debugEntity, WorldEntity, debugWE); 48 48 49 50 NewObjectListDefinition(WorldEntity); 49 51 /** 50 52 * Loads the WordEntity-specific Part of any derived Class … … 56 58 : Synchronizeable() 57 59 { 58 this-> setClassID(CL_WORLD_ENTITY, "WorldEntity");60 this->registerObject(this, WorldEntity::_objectList); 59 61 60 62 this->obbTree = NULL; … … 81 83 82 84 // registering default reactions: 83 this->subscribeReaction(CREngine::CR_OBJECT_DAMAGE, /*CL_WORLD_ENTITY*/ CL_PROJECTILE);85 /// FIXME this->subscribeReaction(CREngine::CR_OBJECT_DAMAGE, /*CL_WORLD_ENTITY*/ CL_PROJECTILE); 84 86 85 87 this->toList(OM_NULL); … … 197 199 PRINTF(1)("OBJ-File %s not found.\n", fileName.c_str()); 198 200 199 if( modelNumber == 0 && !this->isA(CL_WEAPON))201 if( modelNumber == 0 /* FIXME && !this->isA(CL_WEAPON) */) 200 202 this->buildObbTree(obbTreeDepth); 201 203 } … … 300 302 * @param target1 a filter target (classID) 301 303 */ 302 void WorldEntity::subscribeReaction(CREngine::CRType type, longtarget1)304 void WorldEntity::subscribeReaction(CREngine::CRType type, const NewClassID& target1) 303 305 { 304 306 this->subscribeReaction(type); … … 314 316 * @param target1 a filter target (classID) 315 317 */ 316 void WorldEntity::subscribeReaction(CREngine::CRType type, long target1, longtarget2)318 void WorldEntity::subscribeReaction(CREngine::CRType type, const NewClassID& target1, const NewClassID& target2) 317 319 { 318 320 this->subscribeReaction(type); … … 329 331 * @param target1 a filter target (classID) 330 332 */ 331 void WorldEntity::subscribeReaction(CREngine::CRType type, long target1, long target2, longtarget3)333 void WorldEntity::subscribeReaction(CREngine::CRType type, const NewClassID& target1, const NewClassID& target2, const NewClassID& target3) 332 334 { 333 335 this->subscribeReaction(type); … … 345 347 * @param target1 a filter target (classID) 346 348 */ 347 void WorldEntity::subscribeReaction(CREngine::CRType type, long target1, long target2, long target3, longtarget4)349 void WorldEntity::subscribeReaction(CREngine::CRType type, const NewClassID& target1, const NewClassID& target2, const NewClassID& target3, const NewClassID& target4) 348 350 { 349 351 this->subscribeReaction(type); -
branches/new_class_id/src/world_entities/world_entity.h
r9656 r9705 37 37 38 38 39 39 40 //! Basis-class all interactive stuff in the world is derived from 40 41 class WorldEntity : public PNode 41 42 { 43 NewObjectListDeclaration(WorldEntity); 42 44 public: 43 45 WorldEntity(); … … 49 51 void loadModel2(const std::string& fileN, float scal = 1.0f){this->loadModel(fileN,scal,0,4);} 50 52 void setModel(Model* model, unsigned int modelNumber = 0); 51 53 Model* getModel(unsigned int modelNumber = 0) const { return (this->models.size() > modelNumber)? this->models[modelNumber] : NULL; }; 52 54 53 55 inline void loadMD2Texture(const std::string& fileName) { this->md2TextureFileName = fileName; } … … 73 75 74 76 75 /** @returns a reference to the obb tree of this worldentity */77 /** @returns a reference to the obb tree of this worldentity */ 76 78 inline BVTree* getOBBTree() const { return this->obbTree; }; 77 79 inline void setOBBTree(OBBTree* tree) { /*if( this->obbTree != NULL) delete this->obbTree;*/ this->obbTree = (BVTree*)tree; } … … 81 83 /* --- Collision Reaction Block --- */ 82 84 void subscribeReaction(CREngine::CRType type); 83 void subscribeReaction(CREngine::CRType type, longtarget1);84 void subscribeReaction(CREngine::CRType type, long target1, longtarget2);85 void subscribeReaction(CREngine::CRType type, long target1, long target2, longtarget3);86 void subscribeReaction(CREngine::CRType type, long target1, long target2, long target3, longtarget4);85 void subscribeReaction(CREngine::CRType type, const NewClassID& target1); 86 void subscribeReaction(CREngine::CRType type, const NewClassID& target1, const NewClassID& target2); 87 void subscribeReaction(CREngine::CRType type, const NewClassID& target1, const NewClassID& target2, const NewClassID& target3); 88 void subscribeReaction(CREngine::CRType type, const NewClassID& target1, const NewClassID& target2, const NewClassID& target3, const NewClassID& target4); 87 89 88 90 void unsubscribeReaction(CREngine::CRType type); … … 126 128 127 129 void hide() { if( this->objectListNumber != OM_DEAD) this->lastObjectListNumber = this->objectListNumber; this->toList(OM_DEAD); } 128 130 void unhide() { if( this->objectListNumber != this->lastObjectListNumber) this->toList(this->lastObjectListNumber); } 129 131 130 132 131 133 /* --- Character Attribute Block --- */ 132 134 /** @returns the scaling of the model */ 133 135 float getScaling(){return this->scaling;} 134 136 /** @returns the damage dealt by this world entity */ 135 137 float getDamage() const { return this->damage; } … … 216 218 bool bOnGround; //!< true if this entity is standing on the ground 217 219 218 220 protected: 219 221 Vector velocity; //!< speed of the entity 220 222
Note: See TracChangeset
for help on using the changeset viewer.