Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9705 in orxonox.OLD for branches/new_class_id/src/util


Ignore:
Timestamp:
Aug 25, 2006, 9:44:53 PM (18 years ago)
Author:
bensch
Message:

adapted many more classes

Location:
branches/new_class_id/src/util
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/util/animation/animation.cc

    r5777 r9705  
    2020#include "animation_player.h"
    2121
     22NewObjectListDefinition(Animation);
    2223/**
    2324 *  creates a new Animation
     
    2728Animation::Animation()
    2829{
    29   this->setClassID(CL_ANIMATION, "Animation");
     30  this->registerObject(this, Animation::_objectList);
    3031
    3132  // initialize a beginning KeyFrame, that will be deleted afterwards
  • branches/new_class_id/src/util/animation/animation.h

    r6222 r9705  
    7373class Animation : public BaseObject
    7474{
    75  public:
     75  NewObjectListDeclaration(Animation);
     76public:
    7677  virtual ~Animation();
    7778
     
    9596  inline bool ifDelete() { return bDelete; };
    9697
    97  protected:
     98protected:
    9899  Animation();
    99100
    100101  void handleInfinity();
    101102
    102  protected:
     103protected:
    103104  // variables
    104105  float                 localTime;              //!< The Time passed since the beginning of the currentKeyFrame.
     
    119120class aTest
    120121{
    121  public:
     122public:
    122123  inline aTest() { last = 0.0;}
    123124  /** a little debug information to show the results of this class @param f new value */
    124125  inline void littleDebug(float f) {  diff = f - last; printf("f=%f, diff=%f\n", f,diff); last = f;}
    125  private:
     126private:
    126127  float     diff;           //!< difference from the last value
    127128  float     last;           //!< the last calculated value
  • branches/new_class_id/src/util/animation/animation_player.cc

    r9406 r9705  
    2222
    2323
    24 
     24NewObjectListDefinition(AnimationPlayer);
    2525/**
    2626 *  standard constructor
     
    2828AnimationPlayer::AnimationPlayer ()
    2929{
    30   this->setClassID(CL_ANIMATION_PLAYER, "AnimationPlayer");
     30  this->registerObject(this, AnimationPlayer::_objectList);
    3131  this->setName("AnimationPlayer");
    3232
  • branches/new_class_id/src/util/animation/animation_player.h

    r5777 r9705  
    2828   eveything else will be done by the AnimationPlayer itself.\n
    2929*/
    30 class AnimationPlayer : public BaseObject {
     30class AnimationPlayer : public BaseObject
     31{
     32  NewObjectListDeclaration(AnimationPlayer);
    3133
    32  public:
     34public:
    3335  /** @returns a Pointer to the only object of this Class */
    3436  inline static AnimationPlayer* getInstance() { if (!singletonRef) singletonRef = new AnimationPlayer();  return singletonRef; };
     
    5052  void debug();
    5153
    52  private:
     54private:
    5355  /* singleton */
    5456  AnimationPlayer();
  • branches/new_class_id/src/util/kill_target.cc

    r9406 r9705  
    2222
    2323
    24 
     24#include "class_id.h"
    2525CREATE_FACTORY(KillTarget, CL_KILL_TARGET);
     26NewObjectListDefinitionID(KillTarget, CL_KILL_TARGET);
    2627
    2728
     
    3233KillTarget::KillTarget (const TiXmlElement* root)
    3334        : MissionGoal(root) {
    34     this->setClassID(CL_KILL_TARGET, "KillTarget");
     35  this->registerObject(this, KillTarget::_objectList);
    3536
    3637    if( root != NULL)
  • branches/new_class_id/src/util/kill_target.h

    r7464 r9705  
    1717class KillTarget : public MissionGoal
    1818{
     19  NewObjectListDeclaration(KillTarget);
    1920
    2021  public:
  • branches/new_class_id/src/util/mission_goal.cc

    r9406 r9705  
    2424
    2525
    26 
     26NewObjectListDefinition(MissionGoal);
    2727/**
    2828 * standard constructor
     
    3131MissionGoal::MissionGoal (const TiXmlElement* root)
    3232{
    33    this->setClassID(CL_MISSION_GOAL, "MissionGoal");
     33  this->registerObject(this, MissionGoal::_objectList);
    3434
    3535   this->missionState = MS_PASSIVE;
  • branches/new_class_id/src/util/mission_goal.h

    r7464 r9705  
    2626//! A class representing a mission goal
    2727class MissionGoal : public BaseObject {
     28  NewObjectListDeclaration(MissionGoal);
    2829
    2930 public:
  • branches/new_class_id/src/util/multiplayer_team_deathmatch.cc

    r9704 r9705  
    5656 */
    5757MultiplayerTeamDeathmatch::MultiplayerTeamDeathmatch(const TiXmlElement* root)
    58   : NetworkGameRules(root)
     58    : NetworkGameRules(root)
    5959{
    6060  this->registerObject(this, MultiplayerTeamDeathmatch::_objectList);
     
    111111
    112112  LoadParam(root, "death-penalty-timeout", this, MultiplayerTeamDeathmatch, setDeathPenaltyTimeout)
    113       .describe("sets the time in seconds a player has to wait for respawn");
     113  .describe("sets the time in seconds a player has to wait for respawn");
    114114
    115115  LoadParam(root, "max-kills", this, MultiplayerTeamDeathmatch, setMaxKills)
    116       .describe("sets the maximal kills for winning condition");
     116  .describe("sets the maximal kills for winning condition");
    117117
    118118  LoadParam(root, "num-teams", this, MultiplayerTeamDeathmatch, setNumTeams)
    119       .describe("sets number of teams");
     119  .describe("sets number of teams");
    120120
    121121}
     
    189189  }
    190190
    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  //   }
    195195
    196196  // check if the menu should be removed and the game state should be entered
     
    270270  if( unlikely( this->bLocalPlayerDead))
    271271  {
    272 
    273272  }
    274273}
     
    305304{
    306305  if ( team == TEAM_NOTEAM || team == TEAM_SPECTATOR )
    307     return CL_SPECTATOR;
     306    return NewObjectListBase::retrieveIdentity("Spectator");
    308307
    309308  if ( team == 0 || team == 1 )
    310     return CL_TURBINE_HOVER;
     309    return NewObjectListBase::retrieveIdentity("TurbineHover");
    311310
    312311  assert( false );
     
    314313
    315314
    316 std::string MultiplayerTeamDeathmatch::getPlayableModelFileName( int userId, int team, ClassID classId )
     315std::string MultiplayerTeamDeathmatch::getPlayableModelFileName( int userId, int team, const NewClassID& classId )
    317316{
    318317  if (classId == CL_TURBINE_HOVER)
    319    return "models/ships/hoverglider_mainbody.obj";
     318    return "models/ships/hoverglider_mainbody.obj";
    320319  if ( team == 0 )
    321320    return "models/creatures/doom_guy.md2";
     
    326325}
    327326
    328 std::string MultiplayerTeamDeathmatch::getPlayableModelTextureFileName( int userId, int team, ClassID classId )
     327std::string MultiplayerTeamDeathmatch::getPlayableModelTextureFileName( int userId, int team, const NewClassID& classId )
    329328{
    330329  if ( classId == CL_FPS_PLAYER )
     
    339338}
    340339
    341 float MultiplayerTeamDeathmatch::getPlayableScale( int userId, int team, ClassID classId )
    342 {
    343   if ( classId == CL_FPS_PLAYER )
     340float MultiplayerTeamDeathmatch::getPlayableScale( int userId, int team, const NewClassID& classId )
     341{
     342  if ( classId == NewObjectListBase::retrieveIdentity(CL_FPS_PLAYER))
    344343  {
    345344    return 10.0f;
     
    359358    teamScore[i] = 0;
    360359
    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);
    370365
    371366    if ( stats.getTeamId() >= 0 )
     
    387382    playersInTeam[i] = 0;
    388383
    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);
    397389
    398390    if ( stats.getTeamId() >= 0 )
     
    450442void MultiplayerTeamDeathmatch::handleTeamChanges( )
    451443{
    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);
    461449
    462450    if ( stats.getTeamId() != stats.getPreferedTeamId() )
     
    470458
    471459  //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);
    475465
    476466    if ( stats.getTeamId() != stats.getPreferedTeamId() )
     
    501491
    502492
    503   ClassID       playableClassId  = getPlayableClassId( userId, stats.getPreferedTeamId() );
     493  NewClassID       playableClassId  = getPlayableClassId( userId, stats.getPreferedTeamId() );
    504494  std::string   playableModel    = getPlayableModelFileName( userId, stats.getPreferedTeamId(), playableClassId );
    505495  std::string   playableTexture  = getPlayableModelTextureFileName( userId, stats.getPreferedTeamId(), playableClassId );
     
    584574    if ( event.bPressed )
    585575      this->bShowTeamChange = true;
    586   } else if ( event.type == SDLK_F1 )
     576  }
     577  else if ( event.type == SDLK_F1 )
    587578  {
    588579    if ( this->statsBox && !this->bLocalPlayerDead && event.bPressed )
     
    680671void MultiplayerTeamDeathmatch::hideStats( )
    681672{
    682     if ( statsBox )
    683     {
    684       delete statsBox;
    685       statsBox = NULL;
    686     }
     673  if ( statsBox )
     674  {
     675    delete statsBox;
     676    statsBox = NULL;
     677  }
    687678}
    688679
     
    819810void MultiplayerTeamDeathmatch::respawnPlayable( Playable * playable, int teamId, float delay )
    820811{
    821   const std::list<BaseObject*> * list = ClassList::getList( CL_SPAWNING_POINT );
    822 
    823   assert( list );
    824812
    825813  std::vector<SpawningPoint*> spList;
    826814
    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);
    830820
    831821    if ( sp->getTeamId() == teamId )
     
    835825  if ( spList.size() == 0 )
    836826  {
    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);
    840832
    841833      if ( sp->getTeamId() < 0 )
  • branches/new_class_id/src/util/singleplayer_shootemup.cc

    r9406 r9705  
    2525
    2626
    27 
     27#include "class_id.h"
    2828CREATE_FACTORY(SingleplayerShootemup, CL_SINGLEPLAYER_SHOOTEMUP);
    29 
    30 
     29NewObjectListDefinitionID(SingleplayerShootemup, CL_SINGLEPLAYER_SHOOTEMUP);
    3130
    3231/**
     
    3635  : GameRules(root)
    3736{
    38   this->setClassID(CL_SINGLEPLAYER_SHOOTEMUP, "SingleplayerShootemup");
     37  this->registerObject(this, SingleplayerShootemup::_objectList);
    3938
    4039  if( root != NULL)
  • branches/new_class_id/src/util/singleplayer_shootemup.h

    r7464 r9705  
    1818class SingleplayerShootemup : public GameRules
    1919{
    20 
     20  NewObjectListDeclaration(SingleplayerShootemup);
    2121  public:
    2222    SingleplayerShootemup(const TiXmlElement* root = NULL);
  • branches/new_class_id/src/util/track/pilot_node.cc

    r7868 r9705  
    2424
    2525
     26NewObjectListDefinition(PilotNode);
    2627/**
    2728 *  standard constructor
     
    2930PilotNode::PilotNode ()
    3031{
    31    this->setClassID(CL_PILOT_PARENT, "PilotNode");
     32  this->registerObject(this, PilotNode::_objectList);
    3233   this->setName("PilotNode");
    3334
  • branches/new_class_id/src/util/track/pilot_node.h

    r5039 r9705  
    1515//! The PilotNode is a node that enables the is driven by the Mouse
    1616class PilotNode : public WorldEntity, public EventListener {
     17  NewObjectListDeclaration(PilotNode);
    1718
    1819 public:
Note: See TracChangeset for help on using the changeset viewer.