Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9279


Ignore:
Timestamp:
Jun 4, 2012, 10:50:28 PM (12 years ago)
Author:
landauf
Message:

use orxonox_cast instead of dynamic_cast wherever possible

Location:
code/branches/presentation2012merge/src
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2012merge/src/libraries/core/Super.h

    r8866 r9279  
    398398                    inline void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) \
    399399                    { \
    400                         (dynamic_cast<T*>(object))->T:: functionname
     400                        (orxonox_cast<T*>(object))->T:: functionname
    401401
    402402        /*
     
    508508                inline void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) )
    509509                {
    510                     (dynamic_cast<T*>(object))->T:: functionname ( Call the function with it's arguments );
     510                    (orxonox_cast<T*>(object))->T:: functionname ( Call the function with it's arguments );
    511511                }
    512512
  • code/branches/presentation2012merge/src/libraries/core/XMLPort.h

    r8858 r9279  
    197197        ClassIdentifier<classname>::getIdentifier()->addXMLPortParamContainer(paramname, containername); \
    198198    } \
    199     containername->port(dynamic_cast<BaseObject*>(this), object, xmlelement, mode)
     199    containername->port(orxonox_cast<BaseObject*>(this), object, xmlelement, mode)
    200200
    201201// --------------------
  • code/branches/presentation2012merge/src/modules/overlays/hud/HUDNavigation.cc

    r9257 r9279  
    427427bool HUDNavigation::showObject(RadarViewable* rv)
    428428{
    429     if ( rv == dynamic_cast<RadarViewable*> ( this->getOwner() ) )
     429    if ( rv == orxonox_cast<RadarViewable*> ( this->getOwner() ) )
    430430        return false;
    431431    assert( rv->getWorldEntity() );
  • code/branches/presentation2012merge/src/modules/overlays/hud/HUDRadar.cc

    r8891 r9279  
    9292    void HUDRadar::addObject(RadarViewable* object)
    9393    {
    94         if (object == dynamic_cast<RadarViewable*>(this->owner_))
     94        if (object == orxonox_cast<RadarViewable*>(this->owner_))
    9595            return;
    9696        if( showObject(object) == false ) //do not show objects that are "invisible" or "radar invisible"
     
    189189    bool HUDRadar::showObject(RadarViewable* rv)
    190190    {
    191         if ( rv == dynamic_cast<RadarViewable*> ( this->getOwner() ) )
     191        if ( rv == orxonox_cast<RadarViewable*> ( this->getOwner() ) )
    192192            return false;
    193193        assert( rv->getWorldEntity() );
  • code/branches/presentation2012merge/src/modules/pickup/Pickup.cc

    r8864 r9279  
    210210        SUPER(Pickup, clone, item);
    211211
    212         Pickup* pickup = dynamic_cast<Pickup*>(item);
     212        Pickup* pickup = orxonox_cast<Pickup*>(item);
    213213        pickup->setActivationTypeDirect(this->getActivationTypeDirect());
    214214        pickup->setDurationTypeDirect(this->getDurationTypeDirect());
  • code/branches/presentation2012merge/src/modules/pickup/PickupCollection.cc

    r8305 r9279  
    7979        }
    8080        this->pickups_.clear();
    81        
     81
    8282        if(this->pickupCollectionIdentifier_ != NULL)
    8383            delete this->pickupCollectionIdentifier_;
     
    195195            return;
    196196
    197         // If at least all the enabled pickups of this PickupCollection are no longer picked up. 
     197        // If at least all the enabled pickups of this PickupCollection are no longer picked up.
    198198        if(this->pickedUpCounter_ <= this->disabledCounter_ && this->isPickedUp())
    199199            this->Pickupable::destroy();
     
    218218        SUPER(PickupCollection, clone, item);
    219219
    220         PickupCollection* pickup = dynamic_cast<PickupCollection*>(item);
     220        PickupCollection* pickup = orxonox_cast<PickupCollection*>(item);
    221221        // Clone all Pickupables this PickupCollection consist of.
    222222        for(std::vector<CollectiblePickup*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
     
    297297        This is used internally by the CollectiblePickup class.
    298298    @param changed
    299         The value the used status has changed to. 
     299        The value the used status has changed to.
    300300    */
    301301    void PickupCollection::pickupChangedUsed(bool changed)
  • code/branches/presentation2012merge/src/modules/pickup/PickupSpawner.cc

    r8891 r9279  
    199199
    200200                Vector3 distance = it->getWorldPosition() - this->getWorldPosition();
    201                 PickupCarrier* carrier = dynamic_cast<PickupCarrier*>(*it);
     201                PickupCarrier* carrier = orxonox_cast<PickupCarrier*>(*it);
    202202                // If a PickupCarrier, that fits the target-range of the Pickupable spawned by this PickupSpawner, is in trigger-distance and the carrier is not blocked.
    203203                if(distance.length() < this->triggerDistance_ && carrier != NULL && this->blocked_.find(carrier) == this->blocked_.end())
     
    303303            orxout(verbose, context::pickups) << "PickupSpawner (&" << this << ") triggered and active." << endl;
    304304
    305             PickupCarrier* carrier = dynamic_cast<PickupCarrier*>(pawn);
     305            PickupCarrier* carrier = orxonox_cast<PickupCarrier*>(pawn);
    306306            assert(carrier);
    307307
  • code/branches/presentation2012merge/src/modules/pickup/items/DamageBoostPickup.cc

    r9272 r9279  
    180180    {
    181181        PickupCarrier* carrier = this->getCarrier();
    182         SpaceShip* ship = dynamic_cast<SpaceShip*>(carrier);
     182        SpaceShip* ship = orxonox_cast<SpaceShip*>(carrier);
    183183
    184184        if(ship == NULL)
     
    203203        SUPER(DamageBoostPickup, clone, item);
    204204
    205         DamageBoostPickup* pickup = dynamic_cast<DamageBoostPickup*>(item);
     205        DamageBoostPickup* pickup = orxonox_cast<DamageBoostPickup*>(item);
    206206        pickup->setDuration(this->getDuration());
    207207        pickup->setDamageMultiplier(this->getDamageMultiplier());
  • code/branches/presentation2012merge/src/modules/pickup/items/DronePickup.cc

    r8858 r9279  
    144144
    145145                Controller* controller = drone->getController();
    146                 DroneController* droneController = dynamic_cast<DroneController*>(controller);
     146                DroneController* droneController = orxonox_cast<DroneController*>(controller);
    147147                if(droneController != NULL)
    148148                {
     
    175175    {
    176176        PickupCarrier* carrier = this->getCarrier();
    177         Pawn* pawn = dynamic_cast<Pawn*>(carrier);
     177        Pawn* pawn = orxonox_cast<Pawn*>(carrier);
    178178
    179179        if(pawn == NULL)
     
    198198        SUPER(DronePickup, clone, item);
    199199
    200         DronePickup* pickup = dynamic_cast<DronePickup*>(item);
     200        DronePickup* pickup = orxonox_cast<DronePickup*>(item);
    201201        pickup->setDroneTemplate(this->getDroneTemplate());
    202202
  • code/branches/presentation2012merge/src/modules/pickup/items/HealthPickup.cc

    r8864 r9279  
    230230            {
    231231                PickupCarrier* carrier = this->getCarrier();
    232                 Pawn* pawn = dynamic_cast<Pawn*>(carrier);
     232                Pawn* pawn = orxonox_cast<Pawn*>(carrier);
    233233
    234234                if(pawn == NULL)
     
    264264    {
    265265        PickupCarrier* carrier = this->getCarrier();
    266         Pawn* pawn = dynamic_cast<Pawn*>(carrier);
     266        Pawn* pawn = orxonox_cast<Pawn*>(carrier);
    267267
    268268        if(pawn == NULL)
     
    285285        SUPER(HealthPickup, clone, item);
    286286
    287         HealthPickup* pickup = dynamic_cast<HealthPickup*>(item);
     287        HealthPickup* pickup = orxonox_cast<HealthPickup*>(item);
    288288        pickup->setHealth(this->getHealth());
    289289        pickup->setHealthRate(this->getHealthRate());
  • code/branches/presentation2012merge/src/modules/pickup/items/InvisiblePickup.cc

    r8858 r9279  
    159159        SUPER(InvisiblePickup, clone, item);
    160160
    161         InvisiblePickup* pickup = dynamic_cast<InvisiblePickup*>(item);
     161        InvisiblePickup* pickup = orxonox_cast<InvisiblePickup*>(item);
    162162        pickup->setDuration(this->getDuration());
    163163        pickup->initializeIdentifier();
     
    202202    {
    203203        PickupCarrier* carrier = this->getCarrier();
    204         Pawn* pawn = dynamic_cast<Pawn*>(carrier);
     204        Pawn* pawn = orxonox_cast<Pawn*>(carrier);
    205205
    206206        if(pawn == NULL)
  • code/branches/presentation2012merge/src/modules/pickup/items/MetaPickup.cc

    r8858 r9279  
    172172        SUPER(MetaPickup, clone, item);
    173173
    174         MetaPickup* pickup = dynamic_cast<MetaPickup*>(item);
     174        MetaPickup* pickup = orxonox_cast<MetaPickup*>(item);
    175175        pickup->setMetaTypeDirect(this->getMetaTypeDirect());
    176176
  • code/branches/presentation2012merge/src/modules/pickup/items/ShieldPickup.cc

    r8858 r9279  
    177177    {
    178178        PickupCarrier* carrier = this->getCarrier();
    179         Pawn* pawn = dynamic_cast<Pawn*>(carrier);
     179        Pawn* pawn = orxonox_cast<Pawn*>(carrier);
    180180
    181181        if(pawn == NULL)
     
    199199        SUPER(ShieldPickup, clone, item);
    200200
    201         ShieldPickup* pickup = dynamic_cast<ShieldPickup*>(item);
     201        ShieldPickup* pickup = orxonox_cast<ShieldPickup*>(item);
    202202        pickup->setDuration(this->getDuration());
    203203        pickup->setShieldAbsorption(this->getShieldAbsorption());
  • code/branches/presentation2012merge/src/modules/pickup/items/ShrinkPickup.cc

    r8713 r9279  
    148148    {
    149149        SUPER(ShrinkPickup, changedPickedUp);
    150        
     150
    151151        if(!this->isPickedUp() && this->isActive_)
    152152        {
     
    271271
    272272                bool destroy = false;
    273                
     273
    274274                // Stop shrinking if the desired size is reached.
    275275                if(this->timeRemainig_ <= 0.0f)
     
    314314    {
    315315        PickupCarrier* carrier = this->getCarrier();
    316         Pawn* pawn = dynamic_cast<Pawn*>(carrier);
     316        Pawn* pawn = orxonox_cast<Pawn*>(carrier);
    317317
    318318        return pawn;
     
    331331
    332332        SUPER(ShrinkPickup, clone, item);
    333         ShrinkPickup* pickup = dynamic_cast<ShrinkPickup*>(item);
     333        ShrinkPickup* pickup = orxonox_cast<ShrinkPickup*>(item);
    334334        pickup->setShrinkFactor(this->getShrinkFactor());
    335335        pickup->setDuration(this->getDuration());
  • code/branches/presentation2012merge/src/modules/pickup/items/SpeedPickup.cc

    r8858 r9279  
    176176    {
    177177        PickupCarrier* carrier = this->getCarrier();
    178         SpaceShip* ship = dynamic_cast<SpaceShip*>(carrier);
     178        SpaceShip* ship = orxonox_cast<SpaceShip*>(carrier);
    179179
    180180        if(ship == NULL)
     
    199199        SUPER(SpeedPickup, clone, item);
    200200
    201         SpeedPickup* pickup = dynamic_cast<SpeedPickup*>(item);
     201        SpeedPickup* pickup = orxonox_cast<SpeedPickup*>(item);
    202202        pickup->setDuration(this->getDuration());
    203203        pickup->setSpeedAdd(this->getSpeedAdd());
  • code/branches/presentation2012merge/src/modules/weapons/RocketController.cc

    r8858 r9279  
    5353        this->rocket_ = new SimpleRocket(this);
    5454        this->rocket_->setController(this);
    55         this->setControllableEntity(dynamic_cast<ControllableEntity*> (this->rocket_));
     55        this->setControllableEntity(orxonox_cast<ControllableEntity*>(this->rocket_));
    5656    }
    5757
  • code/branches/presentation2012merge/src/orxonox/controllers/NewHumanController.cc

    r9016 r9279  
    298298        //Used in HumanController for formationFlight
    299299        HumanController::hit(originator,contactpoint,damage);
    300        
     300
    301301        if (this->showDamageOverlay_ && !this->controlPaused_ && this->controllableEntity_ && !this->controllableEntity_->isInMouseLook())
    302302        {
     
    397397                try
    398398                {
    399                     wePtr = dynamic_cast<WorldEntity*>(Ogre::any_cast<OrxonoxClass*>(itr->movable->getUserAny()));
     399                    wePtr = orxonox_cast<WorldEntity*>(Ogre::any_cast<OrxonoxClass*>(itr->movable->getUserAny()));
    400400                }
    401401                catch (...)
  • code/branches/presentation2012merge/src/orxonox/gamestates/GSRoot.cc

    r8858 r9279  
    7676        for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it; ++it)
    7777        {
    78             if (dynamic_cast<Synchronisable*>(*it))
    79                 orxout(debug_output) << "object: " << it->getIdentifier()->getName() << " id: " << dynamic_cast<Synchronisable*>(*it)->getObjectID() << endl;
     78            Synchronisable* synchronisable = orxonox_cast<Synchronisable*>(*it);
     79            if (synchronisable)
     80                orxout(debug_output) << "object: " << it->getIdentifier()->getName() << " id: " << synchronisable->getObjectID() << endl;
    8081            else
    8182                orxout(debug_output) << "object: " << it->getIdentifier()->getName() << endl;
  • code/branches/presentation2012merge/src/orxonox/gametypes/Dynamicmatch.cc

    r8858 r9279  
    151151
    152152                //Give new pig boost
    153                 SpaceShip* spaceship = dynamic_cast<SpaceShip*>(victim);
     153                SpaceShip* spaceship = orxonox_cast<SpaceShip*>(victim);
    154154                this->grantPigBoost(spaceship);
    155155            }
     
    245245                }
    246246                //Give new pig boost
    247                 SpaceShip* spaceship = dynamic_cast<SpaceShip*>(victim);
     247                SpaceShip* spaceship = orxonox_cast<SpaceShip*>(victim);
    248248                this->grantPigBoost(spaceship);
    249249            }
     
    426426    {
    427427        std::map<PlayerInfo*, int>::const_iterator it_player = this->playerParty_.find(player);
    428         Pawn* pawn = dynamic_cast<Pawn*>(player->getControllableEntity());
     428        Pawn* pawn = orxonox_cast<Pawn*>(player->getControllableEntity());
    429429            if (pawn)
    430430            {
  • code/branches/presentation2012merge/src/orxonox/gametypes/LastManStanding.cc

    r8858 r9279  
    211211            if(!player->getControllableEntity())
    212212                return;
    213             Pawn* pawn = dynamic_cast<Pawn*>(player->getControllableEntity());
     213            Pawn* pawn = orxonox_cast<Pawn*>(player->getControllableEntity());
    214214            if(!pawn)
    215215                return;
  • code/branches/presentation2012merge/src/orxonox/gametypes/LastTeamStanding.cc

    r8858 r9279  
    283283            if(!player->getControllableEntity())
    284284                return;
    285             Pawn* pawn = dynamic_cast<Pawn*>(player->getControllableEntity());
     285            Pawn* pawn = orxonox_cast<Pawn*>(player->getControllableEntity());
    286286            if(!pawn)
    287287                return;
  • code/branches/presentation2012merge/src/orxonox/interfaces/Pickupable.cc

    r8866 r9279  
    338338        this->clone(item);
    339339
    340         Pickupable* pickup = dynamic_cast<Pickupable*>(item);
     340        Pickupable* pickup = orxonox_cast<Pickupable*>(item);
    341341
    342342        orxout(verbose, context::pickups) << "Pickupable (&" << this << ") cloned. Clone is new Pickupable (&" << pickup << ")." << endl;
  • code/branches/presentation2012merge/src/orxonox/worldentities/ControllableEntity.cc

    r9272 r9279  
    266266                this->cameraPositionRootNode_->_update(true, false); // update the camera node because otherwise the camera will drag back in position which looks strange
    267267
    268                 NewHumanController* controller = dynamic_cast<NewHumanController*>(this->getController());
     268                NewHumanController* controller = orxonox_cast<NewHumanController*>(this->getController());
    269269                if (controller)
    270270                    controller->centerCursor();
Note: See TracChangeset for help on using the changeset viewer.