Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 2, 2012, 10:34:48 PM (12 years ago)
Author:
landauf
Message:

cleaned up new SpaceRace classes (no functional code-changes):

  • formatting
  • naming of variables, arguments, functions
  • unused and duplicate code
  • public member variables
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/modules/gametypes/RaceCheckPoint.cc

    r9016 r9260  
    4242{
    4343    CreateFactory(RaceCheckPoint);
    44    
    45      
    4644
    4745    RaceCheckPoint::RaceCheckPoint(BaseObject* creator): DistanceMultiTrigger(creator), RadarViewable(creator, static_cast<WorldEntity*>(this))
    4846    {
    4947        RegisterObject(RaceCheckPoint);
     48
    5049        this->setDistance(100);
    5150        this->setBeaconMode("off");
    5251        this->setBroadcast(false);
    5352        this->setSimultaneousTriggerers(100);
    54         this->bTimeLimit_ = 0;
    5553
    5654        this->setRadarObjectColour(ColourValue::Blue);
     
    5856        this->setRadarVisibility(false);
    5957        this->settingsChanged();
    60         this->reached_=NULL;
    61      
     58
     59        this->checkpointIndex_ = 0;
     60        this->nextcheckpoints_ = Vector3::ZERO;
     61        this->bIsLast_ = false;
     62        this->timeLimit_ = 0;
     63        this->player_ = NULL;
    6264    }
    63    
     65
    6466
    6567   RaceCheckPoint::~RaceCheckPoint()
    6668   {
    67    
    6869   }
    69 
    70     void RaceCheckPoint::tick(float dt)
    71     {
    72         SUPER(RaceCheckPoint, tick, dt);
    73 
    74         SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
    75         assert(gametype);
    76     }
    7770
    7871    void RaceCheckPoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    7972    {
    8073        SUPER(RaceCheckPoint, XMLPort, xmlelement, mode);
    81         Vector3 v= Vector3(0,0,0);
     74
    8275        XMLPortParam(RaceCheckPoint, "checkpointindex", setCheckpointIndex, getCheckpointIndex, xmlelement, mode).defaultValues(0);
    83         XMLPortParam(RaceCheckPoint, "islast", setLast, getLast, xmlelement, mode).defaultValues(false);
     76        XMLPortParam(RaceCheckPoint, "islast", setLast, isLast, xmlelement, mode).defaultValues(false);
    8477        XMLPortParam(RaceCheckPoint, "timelimit", setTimelimit, getTimeLimit, xmlelement, mode).defaultValues(0);
    85     XMLPortParamTemplate(RaceCheckPoint, "nextcheckpoints", setNextcheckpoint, getNextcheckpoint, xmlelement, mode,const Vector3&).defaultValues(v);
     78        XMLPortParamTemplate(RaceCheckPoint, "nextcheckpoints", setNextcheckpoint, getNextcheckpoint, xmlelement, mode, const Vector3&).defaultValues(Vector3::ZERO);
    8679    }
    8780
    88     void RaceCheckPoint::fire(bool bIsTriggered,BaseObject* player)
     81    void RaceCheckPoint::fire(bool bIsTriggered, BaseObject* originator)
    8982    {
    90         DistanceMultiTrigger::fire((bool)bIsTriggered,player);
    91        
    92         SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
    93         assert(gametype);
    94         ControllableEntity* entity = (ControllableEntity*) player;
    95      
    96         PlayerInfo* player2 = entity->getPlayer();
    97      
    98         if(bIsTriggered)
    99             this->reached_=player2;
     83        DistanceMultiTrigger::fire(bIsTriggered, originator);
     84
     85        if (bIsTriggered)
     86        {
     87            ControllableEntity* entity = orxonox_cast<ControllableEntity*>(originator);
     88            if (entity)
     89                this->player_ = entity->getPlayer();
     90        }
    10091    }
    10192
    10293    void RaceCheckPoint::setTimelimit(float timeLimit)
    10394    {
    104         this->bTimeLimit_ = timeLimit;
    105         if (this->bTimeLimit_ != 0)
     95        this->timeLimit_ = timeLimit;
     96        if (this->timeLimit_ != 0)
    10697        {
    107             SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
    108             assert(gametype);
    109             if (gametype)
    110             {
    111                 const std::string& message =  "You have " + multi_cast<std::string>(this->bTimeLimit_)
    112                             + " seconds to reach the check point " + multi_cast<std::string>(this->bCheckpointIndex_+1);
    113                 const_cast<GametypeInfo*>(gametype->getGametypeInfo())->sendAnnounceMessage(message);
    114                 ChatManager::message(message);
    115             }
     98            std::string message =  "You have " + multi_cast<std::string>(this->timeLimit_)
     99                        + " seconds to reach the check point " + multi_cast<std::string>(this->checkpointIndex_ + 1);
     100            const_cast<GametypeInfo*>(this->getGametype()->getGametypeInfo())->sendAnnounceMessage(message);
     101            ChatManager::message(message);
    116102        }
    117103    }
    118 
    119104}
Note: See TracChangeset for help on using the changeset viewer.