Blame colobot-gcc11.patch

1b541e3
diff --git a/src/graphics/engine/camera.cpp b/src/graphics/engine/camera.cpp
1b541e3
index 461f46a..1244f7d 100644
1b541e3
--- a/src/graphics/engine/camera.cpp
1b541e3
+++ b/src/graphics/engine/camera.cpp
1b541e3
@@ -59,14 +59,14 @@ static void SetTransparency(CObject* obj, float value)
1b541e3
 
1b541e3
     if (obj->Implements(ObjectInterfaceType::Carrier))
1b541e3
     {
1b541e3
-        CObject* cargo = dynamic_cast<CCarrierObject*>(obj)->GetCargo();
1b541e3
+        CObject* cargo = dynamic_cast<CCarrierObject&>(*obj).GetCargo();
1b541e3
         if (cargo != nullptr)
1b541e3
             cargo->SetTransparency(value);
1b541e3
     }
1b541e3
 
1b541e3
     if (obj->Implements(ObjectInterfaceType::Powered))
1b541e3
     {
1b541e3
-        CObject* power = dynamic_cast<CPoweredObject*>(obj)->GetPower();
1b541e3
+        CObject* power = dynamic_cast<CPoweredObject&>(*obj).GetPower();
1b541e3
         if (power != nullptr)
1b541e3
             power->SetTransparency(value);
1b541e3
     }
1b541e3
@@ -1233,7 +1233,7 @@ bool CCamera::EventFrameBack(const Event &event)
1b541e3
 
1b541e3
         bool ground = true;
1b541e3
         if (m_cameraObj->Implements(ObjectInterfaceType::Movable))
1b541e3
-            ground = dynamic_cast<CMovableObject*>(m_cameraObj)->GetPhysics()->GetLand();
1b541e3
+            ground = dynamic_cast<CMovableObject&>(*m_cameraObj).GetPhysics()->GetLand();
1b541e3
         if ( ground )  // ground?
1b541e3
         {
1b541e3
             Math::Vector pos = lookatPt + (lookatPt - m_eyePt);
1b541e3
@@ -1326,7 +1326,7 @@ bool CCamera::EventFrameOnBoard(const Event &event)
1b541e3
     {
1b541e3
         assert(m_cameraObj->Implements(ObjectInterfaceType::Controllable));
1b541e3
         Math::Vector lookatPt, upVec;
1b541e3
-        dynamic_cast<CControllableObject*>(m_cameraObj)->AdjustCamera(m_eyePt, m_directionH, m_directionV, lookatPt, upVec, m_type);
1b541e3
+        dynamic_cast<CControllableObject&>(*m_cameraObj).AdjustCamera(m_eyePt, m_directionH, m_directionV, lookatPt, upVec, m_type);
1b541e3
         Math::Vector eye    = m_effectOffset * 0.3f + m_eyePt;
1b541e3
         Math::Vector lookat = m_effectOffset * 0.3f + lookatPt;
1b541e3
 
1b541e3
diff --git a/src/object/interface/carrier_object.h b/src/object/interface/carrier_object.h
1b541e3
index b534fd4..a8510b6 100644
1b541e3
--- a/src/object/interface/carrier_object.h
1b541e3
+++ b/src/object/interface/carrier_object.h
1b541e3
@@ -51,5 +51,5 @@ public:
1b541e3
 inline bool IsObjectCarryingCargo(CObject* obj)
1b541e3
 {
1b541e3
     return obj->Implements(ObjectInterfaceType::Carrier) &&
1b541e3
-           dynamic_cast<CCarrierObject*>(obj)->IsCarryingCargo();
1b541e3
+           dynamic_cast<CCarrierObject&>(*obj).IsCarryingCargo();
1b541e3
 }
1b541e3
diff --git a/src/object/interface/powered_object.h b/src/object/interface/powered_object.h
1b541e3
index 54b6dd1..1216eda 100644
1b541e3
--- a/src/object/interface/powered_object.h
1b541e3
+++ b/src/object/interface/powered_object.h
1b541e3
@@ -61,10 +61,10 @@ inline float GetObjectEnergy(CObject* object)
1b541e3
 
1b541e3
     if (object->Implements(ObjectInterfaceType::Powered))
1b541e3
     {
1b541e3
-        CObject* power = dynamic_cast<CPoweredObject*>(object)->GetPower();
1b541e3
+        CObject* power = dynamic_cast<CPoweredObject&>(*object).GetPower();
1b541e3
         if (power != nullptr && power->Implements(ObjectInterfaceType::PowerContainer))
1b541e3
         {
1b541e3
-            energy = dynamic_cast<CPowerContainerObject*>(power)->GetEnergy();
1b541e3
+            energy = dynamic_cast<CPowerContainerObject&>(*power).GetEnergy();
1b541e3
         }
1b541e3
     }
1b541e3
 
1b541e3
@@ -77,10 +77,10 @@ inline float GetObjectEnergyLevel(CObject* object)
1b541e3
 
1b541e3
     if (object->Implements(ObjectInterfaceType::Powered))
1b541e3
     {
1b541e3
-        CObject* power = dynamic_cast<CPoweredObject*>(object)->GetPower();
1b541e3
+        CObject* power = dynamic_cast<CPoweredObject&>(*object).GetPower();
1b541e3
         if (power != nullptr && power->Implements(ObjectInterfaceType::PowerContainer))
1b541e3
         {
1b541e3
-            energy = dynamic_cast<CPowerContainerObject*>(power)->GetEnergyLevel();
1b541e3
+            energy = dynamic_cast<CPowerContainerObject&>(*power).GetEnergyLevel();
1b541e3
         }
1b541e3
     }
1b541e3
 
1b541e3
@@ -90,5 +90,5 @@ inline float GetObjectEnergyLevel(CObject* object)
1b541e3
 inline bool ObjectHasPowerCell(CObject* object)
1b541e3
 {
1b541e3
     return object->Implements(ObjectInterfaceType::Powered) &&
1b541e3
-           dynamic_cast<CPoweredObject*>(object)->GetPower() != nullptr;
1b541e3
+           dynamic_cast<CPoweredObject&>(*object).GetPower() != nullptr;
1b541e3
 }
1b541e3
diff --git a/src/object/interface/transportable_object.h b/src/object/interface/transportable_object.h
1b541e3
index 2d0f90f..1ad95d0 100644
1b541e3
--- a/src/object/interface/transportable_object.h
1b541e3
+++ b/src/object/interface/transportable_object.h
1b541e3
@@ -54,5 +54,5 @@ public:
1b541e3
 inline bool IsObjectBeingTransported(CObject* obj)
1b541e3
 {
1b541e3
     return obj->Implements(ObjectInterfaceType::Transportable) &&
1b541e3
-           dynamic_cast<CTransportableObject*>(obj)->IsBeingTransported();
1b541e3
+           dynamic_cast<CTransportableObject&>(*obj).IsBeingTransported();
1b541e3
 }
3ec1fca
diff --git a/src/graphics/engine/lightning.cpp b/src/graphics/engine/lightning.cpp
3ec1fca
index 9c1a64b..eab99a4 100644
3ec1fca
--- a/src/graphics/engine/lightning.cpp
3ec1fca
+++ b/src/graphics/engine/lightning.cpp
3ec1fca
@@ -323,7 +323,7 @@ CObject* CLightning::SearchObject(Math::Vector pos)
3ec1fca
 
3ec1fca
         if (!obj->Implements(ObjectInterfaceType::Destroyable)) continue;
3ec1fca
 
3ec1fca
-        float detect = m_magnetic * dynamic_cast<CDestroyableObject*>(obj)->GetLightningHitProbability();
3ec1fca
+        float detect = m_magnetic * dynamic_cast<CDestroyableObject&>(*obj).GetLightningHitProbability();
3ec1fca
         if (detect == 0.0f) continue;
3ec1fca
 
3ec1fca
         Math::Vector oPos = obj->GetPosition();
3ec1fca
diff --git a/src/graphics/engine/particle.cpp b/src/graphics/engine/particle.cpp
3ec1fca
index 5c6d169..0a7fa9b 100644
3ec1fca
--- a/src/graphics/engine/particle.cpp
3ec1fca
+++ b/src/graphics/engine/particle.cpp
3ec1fca
@@ -954,7 +954,7 @@ void CParticle::FrameParticle(float rTime)
3ec1fca
             m_particle[i].goal = m_particle[i].pos;
3ec1fca
             if (object != nullptr && object->Implements(ObjectInterfaceType::Damageable))
3ec1fca
             {
3ec1fca
-                dynamic_cast<CDamageableObject*>(object)->DamageObject(DamageType::Phazer, 0.002f, m_particle[i].objFather);
3ec1fca
+                dynamic_cast<CDamageableObject&>(*object).DamageObject(DamageType::Phazer, 0.002f, m_particle[i].objFather);
3ec1fca
             }
3ec1fca
 
3ec1fca
             m_particle[i].zoom = 1.0f-(m_particle[i].time-m_particle[i].duration);
3ec1fca
@@ -1157,7 +1157,7 @@ void CParticle::FrameParticle(float rTime)
3ec1fca
                 {
3ec1fca
                     if (object->Implements(ObjectInterfaceType::Damageable))
3ec1fca
                     {
3ec1fca
-                        dynamic_cast<CDamageableObject*>(object)->DamageObject(DamageType::Fire, 0.001f, m_particle[i].objFather);
3ec1fca
+                        dynamic_cast<CDamageableObject&>(*object).DamageObject(DamageType::Fire, 0.001f, m_particle[i].objFather);
3ec1fca
                     }
3ec1fca
 
3ec1fca
                     m_exploGunCounter++;
3ec1fca
@@ -1223,7 +1223,7 @@ void CParticle::FrameParticle(float rTime)
3ec1fca
                 m_particle[i].goal = m_particle[i].pos;
3ec1fca
                 if (object != nullptr)
3ec1fca
                 {
3ec1fca
-                    if (object->GetType() == OBJECT_MOBILErs && dynamic_cast<CShielder*>(object)->GetActiveShieldRadius() > 0.0f)  // protected by shield?
3ec1fca
+                    if (object->GetType() == OBJECT_MOBILErs && dynamic_cast<CShielder&>(*object).GetActiveShieldRadius() > 0.0f)  // protected by shield?
3ec1fca
                     {
3ec1fca
                         CreateParticle(m_particle[i].pos, Math::Vector(0.0f, 0.0f, 0.0f), Math::Point(6.0f, 6.0f), PARTIGUNDEL, 2.0f);
3ec1fca
                         if (m_lastTimeGunDel > 0.2f)
3ec1fca
@@ -1241,7 +1241,7 @@ void CParticle::FrameParticle(float rTime)
3ec1fca
 
3ec1fca
                         if (object->Implements(ObjectInterfaceType::Damageable))
3ec1fca
                         {
3ec1fca
-                            dynamic_cast<CDamageableObject*>(object)->DamageObject(DamageType::Organic, 0.1f, m_particle[i].objFather);  // starts explosion
3ec1fca
+                            dynamic_cast<CDamageableObject&>(*object).DamageObject(DamageType::Organic, 0.1f, m_particle[i].objFather);  // starts explosion
3ec1fca
                         }
3ec1fca
                     }
3ec1fca
                 }
3ec1fca
@@ -1271,7 +1271,7 @@ void CParticle::FrameParticle(float rTime)
3ec1fca
                 m_particle[i].goal = m_particle[i].pos;
3ec1fca
                 if (object != nullptr)
3ec1fca
                 {
3ec1fca
-                    if (object->GetType() == OBJECT_MOBILErs && dynamic_cast<CShielder*>(object)->GetActiveShieldRadius() > 0.0f)
3ec1fca
+                    if (object->GetType() == OBJECT_MOBILErs && dynamic_cast<CShielder&>(*object).GetActiveShieldRadius() > 0.0f)
3ec1fca
                     {
3ec1fca
                         CreateParticle(m_particle[i].pos, Math::Vector(0.0f, 0.0f, 0.0f), Math::Point(6.0f, 6.0f), PARTIGUNDEL, 2.0f);
3ec1fca
                         if (m_lastTimeGunDel > 0.2f)
3ec1fca
@@ -1286,7 +1286,7 @@ void CParticle::FrameParticle(float rTime)
3ec1fca
                     {
3ec1fca
                         if (object->Implements(ObjectInterfaceType::Damageable))
3ec1fca
                         {
3ec1fca
-                            dynamic_cast<CDamageableObject*>(object)->DamageObject(DamageType::Fire, std::numeric_limits<float>::infinity(), m_particle[i].objFather);  // starts explosion
3ec1fca
+                            dynamic_cast<CDamageableObject&>(*object).DamageObject(DamageType::Fire, std::numeric_limits<float>::infinity(), m_particle[i].objFather);  // starts explosion
3ec1fca
                         }
3ec1fca
                     }
3ec1fca
                 }
3ec1fca
@@ -1345,7 +1345,7 @@ void CParticle::FrameParticle(float rTime)
3ec1fca
                 {
3ec1fca
                     if (object->Implements(ObjectInterfaceType::Damageable))
3ec1fca
                     {
3ec1fca
-                        dynamic_cast<CDamageableObject*>(object)->DamageObject(DamageType::Organic, 0.001f, m_particle[i].objFather);
3ec1fca
+                        dynamic_cast<CDamageableObject&>(*object).DamageObject(DamageType::Organic, 0.001f, m_particle[i].objFather);
3ec1fca
                     }
3ec1fca
 
3ec1fca
                     m_exploGunCounter ++;
3ec1fca
@@ -2423,7 +2423,7 @@ void CParticle::FrameParticle(float rTime)
3ec1fca
                 if (object != nullptr)
3ec1fca
                 {
3ec1fca
                     assert(object->Implements(ObjectInterfaceType::Damageable));
3ec1fca
-                    dynamic_cast<CDamageableObject*>(object)->DamageObject(DamageType::Tower, std::numeric_limits<float>::infinity(), m_particle[i].objFather);
3ec1fca
+                    dynamic_cast<CDamageableObject&>(*object).DamageObject(DamageType::Tower, std::numeric_limits<float>::infinity(), m_particle[i].objFather);
3ec1fca
                 }
3ec1fca
             }
3ec1fca
 
3ec1fca
diff --git a/src/graphics/engine/pyro.cpp b/src/graphics/engine/pyro.cpp
3ec1fca
index 6eedf85..2fab0b1 100644
3ec1fca
--- a/src/graphics/engine/pyro.cpp
3ec1fca
+++ b/src/graphics/engine/pyro.cpp
3ec1fca
@@ -129,7 +129,7 @@ bool CPyro::Create(PyroType type, CObject* obj, float force)
3ec1fca
 
3ec1fca
     CObject* power = nullptr;
3ec1fca
     if (obj->Implements(ObjectInterfaceType::Powered))
3ec1fca
-        power = dynamic_cast<CPoweredObject*>(obj)->GetPower();
3ec1fca
+        power = dynamic_cast<CPoweredObject&>(*obj).GetPower();
3ec1fca
 
3ec1fca
     if (power == nullptr)
3ec1fca
     {
3ec1fca
@@ -256,7 +256,7 @@ bool CPyro::Create(PyroType type, CObject* obj, float force)
3ec1fca
             m_sound->Play(SOUND_DEADw, m_pos);
3ec1fca
         }
3ec1fca
         assert(m_object->Implements(ObjectInterfaceType::Controllable));
3ec1fca
-        if ( type == PT_SHOTH && dynamic_cast<CControllableObject*>(m_object)->GetSelect() )
3ec1fca
+        if ( type == PT_SHOTH && dynamic_cast<CControllableObject&>(*m_object).GetSelect() )
3ec1fca
         {
3ec1fca
             m_sound->Play(SOUND_AIE, m_pos);
3ec1fca
             m_sound->Play(SOUND_AIE, m_engine->GetEyePt());
3ec1fca
@@ -273,10 +273,10 @@ bool CPyro::Create(PyroType type, CObject* obj, float force)
3ec1fca
     if ( m_type == PT_DEADG )
3ec1fca
     {
3ec1fca
         assert(m_object->Implements(ObjectInterfaceType::Destroyable));
3ec1fca
-        dynamic_cast<CDestroyableObject*>(m_object)->SetDying(DeathType::Dead);
3ec1fca
+        dynamic_cast<CDestroyableObject&>(*m_object).SetDying(DeathType::Dead);
3ec1fca
 
3ec1fca
         assert(obj->Implements(ObjectInterfaceType::Movable));
3ec1fca
-        dynamic_cast<CMovableObject*>(obj)->GetMotion()->SetAction(MHS_DEADg, 1.0f);
3ec1fca
+        dynamic_cast<CMovableObject&>(*obj).GetMotion()->SetAction(MHS_DEADg, 1.0f);
3ec1fca
 
3ec1fca
         m_camera->StartCentering(m_object, Math::PI*0.5f, 99.9f, 0.0f, 1.5f);
3ec1fca
         m_camera->StartOver(CAM_OVER_EFFECT_FADEOUT_WHITE, m_pos, 1.0f);
3ec1fca
@@ -286,10 +286,10 @@ bool CPyro::Create(PyroType type, CObject* obj, float force)
3ec1fca
     if ( m_type == PT_DEADW )
3ec1fca
     {
3ec1fca
         assert(m_object->Implements(ObjectInterfaceType::Destroyable));
3ec1fca
-        dynamic_cast<CDestroyableObject*>(m_object)->SetDying(DeathType::Dead);
3ec1fca
+        dynamic_cast<CDestroyableObject&>(*m_object).SetDying(DeathType::Dead);
3ec1fca
 
3ec1fca
         assert(obj->Implements(ObjectInterfaceType::Movable));
3ec1fca
-        dynamic_cast<CMovableObject*>(obj)->GetMotion()->SetAction(MHS_DEADw, 1.0f);
3ec1fca
+        dynamic_cast<CMovableObject&>(*obj).GetMotion()->SetAction(MHS_DEADw, 1.0f);
3ec1fca
 
3ec1fca
         m_camera->StartCentering(m_object, Math::PI*0.5f, 99.9f, 0.0f, 3.0f);
3ec1fca
         m_camera->StartOver(CAM_OVER_EFFECT_FADEOUT_BLACK, m_pos, 1.0f);
3ec1fca
@@ -307,7 +307,7 @@ bool CPyro::Create(PyroType type, CObject* obj, float force)
3ec1fca
     if ( m_type == PT_SHOTH )
3ec1fca
     {
3ec1fca
         assert(m_object->Implements(ObjectInterfaceType::Controllable));
3ec1fca
-        if ( m_camera->GetBlood() && dynamic_cast<CControllableObject*>(m_object)->GetSelect() )
3ec1fca
+        if ( m_camera->GetBlood() && dynamic_cast<CControllableObject&>(*m_object).GetSelect() )
3ec1fca
         {
3ec1fca
             m_camera->StartOver(CAM_OVER_EFFECT_BLOOD, m_pos, force);
3ec1fca
         }
3ec1fca
@@ -1381,7 +1381,7 @@ void CPyro::DeleteObject(bool primary, bool secondary)
3ec1fca
         if (m_object->Implements(ObjectInterfaceType::Transportable))
3ec1fca
         {
3ec1fca
             // TODO: this should be handled in the object's destructor
3ec1fca
-            CObject* transporter = dynamic_cast<CTransportableObject*>(m_object)->GetTransporter();
3ec1fca
+            CObject* transporter = dynamic_cast<CTransportableObject&>(*m_object).GetTransporter();
3ec1fca
             if (transporter != nullptr)
3ec1fca
             {
3ec1fca
                 if (transporter->Implements(ObjectInterfaceType::Powered))
3ec1fca
@@ -1546,12 +1546,12 @@ void CPyro::ExploStart()
3ec1fca
     m_object->Simplify();
3ec1fca
     m_object->SetLock(true);  // ruin not usable yet
3ec1fca
     assert(m_object->Implements(ObjectInterfaceType::Destroyable));
3ec1fca
-    dynamic_cast<CDestroyableObject*>(m_object)->SetDying(DeathType::Exploding);  // being destroyed
3ec1fca
+    dynamic_cast<CDestroyableObject&>(*m_object).SetDying(DeathType::Exploding);  // being destroyed
3ec1fca
     m_object->FlatParent();
3ec1fca
 
3ec1fca
-    if ( m_object->Implements(ObjectInterfaceType::Controllable) && dynamic_cast<CControllableObject*>(m_object)->GetSelect() )
3ec1fca
+    if ( m_object->Implements(ObjectInterfaceType::Controllable) && dynamic_cast<CControllableObject&>(*m_object).GetSelect() )
3ec1fca
     {
3ec1fca
-        dynamic_cast<CControllableObject*>(m_object)->SetSelect(false);  // deselects the object
3ec1fca
+        dynamic_cast<CControllableObject&>(*m_object).SetSelect(false);  // deselects the object
3ec1fca
         m_camera->SetType(CAM_TYPE_EXPLO);
3ec1fca
         m_main->DeselectAll();
3ec1fca
     }
3ec1fca
@@ -1575,7 +1575,7 @@ void CPyro::ExploStart()
3ec1fca
 
3ec1fca
         // TODO: temporary hack (hopefully)
3ec1fca
         assert(m_object->Implements(ObjectInterfaceType::Old));
3ec1fca
-        Math::Vector pos = dynamic_cast<COldObject*>(m_object)->GetPartPosition(i);
3ec1fca
+        Math::Vector pos = dynamic_cast<COldObject&>(*m_object).GetPartPosition(i);
3ec1fca
 
3ec1fca
         Math::Vector speed;
3ec1fca
         float weight;
3ec1fca
@@ -1622,9 +1622,9 @@ void CPyro::BurnStart()
3ec1fca
     m_object->Simplify();
3ec1fca
     m_object->SetLock(true);  // ruin not usable yet
3ec1fca
 
3ec1fca
-    if ( m_object->Implements(ObjectInterfaceType::Controllable) && dynamic_cast<CControllableObject*>(m_object)->GetSelect() )
3ec1fca
+    if ( m_object->Implements(ObjectInterfaceType::Controllable) && dynamic_cast<CControllableObject&>(*m_object).GetSelect() )
3ec1fca
     {
3ec1fca
-        dynamic_cast<CControllableObject*>(m_object)->SetSelect(false);  // deselects the object
3ec1fca
+        dynamic_cast<CControllableObject&>(*m_object).SetSelect(false);  // deselects the object
3ec1fca
         m_camera->SetType(CAM_TYPE_EXPLO);
3ec1fca
         m_main->DeselectAll();
3ec1fca
     }
3ec1fca
@@ -2139,7 +2139,7 @@ void CPyro::BurnProgress()
3ec1fca
 
3ec1fca
     if (m_object->Implements(ObjectInterfaceType::Powered))
3ec1fca
     {
3ec1fca
-        CObject* sub = dynamic_cast<CPoweredObject*>(m_object)->GetPower();
3ec1fca
+        CObject* sub = dynamic_cast<CPoweredObject&>(*m_object).GetPower();
3ec1fca
         if (sub != nullptr)  // is there a battery?
3ec1fca
             sub->SetScaleY(1.0f - m_progress);  // complete flattening
3ec1fca
     }
3ec1fca
@@ -2232,7 +2232,7 @@ CObject* CPyro::FallSearchBeeExplo()
3ec1fca
 
3ec1fca
         if (obj->GetType() == OBJECT_MOBILErs)
3ec1fca
         {
3ec1fca
-            float shieldRadius = dynamic_cast<CShielder*>(obj)->GetActiveShieldRadius();
3ec1fca
+            float shieldRadius = dynamic_cast<CShielder&>(*obj).GetActiveShieldRadius();
3ec1fca
             if ( shieldRadius > 0.0f )
3ec1fca
             {
3ec1fca
                 float distance = Math::Distance(oPos, bulletCrashSphere.sphere.pos);
3ec1fca
@@ -2300,12 +2300,12 @@ void CPyro::FallProgress(float rTime)
3ec1fca
                 {
3ec1fca
                     assert(m_object->Implements(ObjectInterfaceType::Destroyable));
3ec1fca
                     // TODO: implement "killer"?
3ec1fca
-                    dynamic_cast<CDestroyableObject*>(m_object)->DestroyObject(DestructionType::Explosion);
3ec1fca
+                    dynamic_cast<CDestroyableObject&>(*m_object).DestroyObject(DestructionType::Explosion);
3ec1fca
                 }
3ec1fca
             }
3ec1fca
             else
3ec1fca
             {
3ec1fca
-                if (obj->GetType() == OBJECT_MOBILErs && dynamic_cast<CShielder*>(obj)->GetActiveShieldRadius() > 0.0f)  // protected by shield?
3ec1fca
+                if (obj->GetType() == OBJECT_MOBILErs && dynamic_cast<CShielder&>(*obj).GetActiveShieldRadius() > 0.0f)  // protected by shield?
3ec1fca
                 {
3ec1fca
                     m_particle->CreateParticle(pos, Math::Vector(0.0f, 0.0f, 0.0f),
3ec1fca
                                                 Math::Point(6.0f, 6.0f), PARTIGUNDEL, 2.0f, 0.0f, 0.0f);
3ec1fca
@@ -2316,7 +2316,7 @@ void CPyro::FallProgress(float rTime)
3ec1fca
                 else
3ec1fca
                 {
3ec1fca
                     assert(obj->Implements(ObjectInterfaceType::Damageable));
3ec1fca
-                    if (dynamic_cast<CDamageableObject*>(obj)->DamageObject(DamageType::FallingObject))
3ec1fca
+                    if (dynamic_cast<CDamageableObject&>(*obj).DamageObject(DamageType::FallingObject))
3ec1fca
                     {
3ec1fca
                         DeleteObject(true, true);  // removes the ball
3ec1fca
                     }
3ec1fca
@@ -2324,7 +2324,7 @@ void CPyro::FallProgress(float rTime)
3ec1fca
                     {
3ec1fca
                         assert(m_object->Implements(ObjectInterfaceType::Destroyable));
3ec1fca
                         // TODO: implement "killer"?
3ec1fca
-                        dynamic_cast<CDestroyableObject*>(m_object)->DestroyObject(DestructionType::Explosion);
3ec1fca
+                        dynamic_cast<CDestroyableObject&>(*m_object).DestroyObject(DestructionType::Explosion);
3ec1fca
                     }
3ec1fca
                 }
3ec1fca
             }
3ec1fca
diff --git a/src/level/mainmovie.cpp b/src/level/mainmovie.cpp
3ec1fca
index 4aa4245..52df226 100644
3ec1fca
--- a/src/level/mainmovie.cpp
3ec1fca
+++ b/src/level/mainmovie.cpp
3ec1fca
@@ -90,7 +90,7 @@ bool CMainMovie::Start(MainMovieType type, float time)
3ec1fca
         }
3ec1fca
 
3ec1fca
         assert(pObj->Implements(ObjectInterfaceType::Movable));
3ec1fca
-        dynamic_cast<CMovableObject*>(pObj)->GetMotion()->SetAction(MHS_SATCOM, 0.5f);  // reads the SatCom
3ec1fca
+        dynamic_cast<CMovableObject&>(*pObj).GetMotion()->SetAction(MHS_SATCOM, 0.5f);  // reads the SatCom
3ec1fca
 
3ec1fca
         m_camera->GetCamera(m_initialEye, m_initialLookat);
3ec1fca
         m_camera->SetType(Gfx::CAM_TYPE_SCRIPT);
3ec1fca
@@ -110,7 +110,7 @@ bool CMainMovie::Start(MainMovieType type, float time)
3ec1fca
         if ( pObj != nullptr )
3ec1fca
         {
3ec1fca
             assert(pObj->Implements(ObjectInterfaceType::Movable));
3ec1fca
-            dynamic_cast<CMovableObject*>(pObj)->GetMotion()->SetAction(-1);  // finishes reading SatCom
3ec1fca
+            dynamic_cast<CMovableObject&>(*pObj).GetMotion()->SetAction(-1);  // finishes reading SatCom
3ec1fca
         }
3ec1fca
 
3ec1fca
         m_camera->SetType(Gfx::CAM_TYPE_BACK);
3ec1fca
@@ -132,7 +132,7 @@ bool CMainMovie::Stop()
3ec1fca
         if ( pObj != nullptr )
3ec1fca
         {
3ec1fca
             assert(pObj->Implements(ObjectInterfaceType::Movable));
3ec1fca
-            dynamic_cast<CMovableObject*>(pObj)->GetMotion()->SetAction(-1);  // finishes reading SatCom
3ec1fca
+            dynamic_cast<CMovableObject&>(*pObj).GetMotion()->SetAction(-1);  // finishes reading SatCom
3ec1fca
         }
3ec1fca
     }
3ec1fca
 
3ec1fca
diff --git a/src/level/robotmain.cpp b/src/level/robotmain.cpp
3ec1fca
index 58d9054..3da33d1 100644
3ec1fca
--- a/src/level/robotmain.cpp
3ec1fca
+++ b/src/level/robotmain.cpp
3ec1fca
@@ -1330,7 +1330,7 @@ void CRobotMain::ExecuteCmd(const std::string& cmd)
3ec1fca
         {
3ec1fca
             CObject* object = GetSelect();
3ec1fca
             if (object != nullptr && object->Implements(ObjectInterfaceType::Shielded))
3ec1fca
-                dynamic_cast<CShieldedObject*>(object)->SetMagnifyDamage(dynamic_cast<CShieldedObject*>(object)->GetMagnifyDamage()*0.1f);
3ec1fca
+                dynamic_cast<CShieldedObject&>(*object).SetMagnifyDamage(dynamic_cast<CShieldedObject&>(*object).GetMagnifyDamage()*0.1f);
3ec1fca
             return;
3ec1fca
         }
3ec1fca
 
3ec1fca
@@ -1338,7 +1338,7 @@ void CRobotMain::ExecuteCmd(const std::string& cmd)
3ec1fca
         {
3ec1fca
             CObject* object = GetSelect();
3ec1fca
             if (object != nullptr && object->Implements(ObjectInterfaceType::JetFlying))
3ec1fca
-                dynamic_cast<CJetFlyingObject*>(object)->SetRange(dynamic_cast<CJetFlyingObject*>(object)->GetRange()*10.0f);
3ec1fca
+                dynamic_cast<CJetFlyingObject&>(*object).SetRange(dynamic_cast<CJetFlyingObject&>(*object).GetRange()*10.0f);
3ec1fca
             return;
3ec1fca
         }
3ec1fca
 
3ec1fca
@@ -1363,16 +1363,16 @@ void CRobotMain::ExecuteCmd(const std::string& cmd)
3ec1fca
             {
3ec1fca
                 if (object->Implements(ObjectInterfaceType::Powered))
3ec1fca
                 {
3ec1fca
-                    CObject* power = dynamic_cast<CPoweredObject*>(object)->GetPower();
3ec1fca
+                    CObject* power = dynamic_cast<CPoweredObject&>(*object).GetPower();
3ec1fca
                     if (power != nullptr && power->Implements(ObjectInterfaceType::PowerContainer))
3ec1fca
-                        dynamic_cast<CPowerContainerObject*>(power)->SetEnergyLevel(1.0f);
3ec1fca
+                        dynamic_cast<CPowerContainerObject&>(*power).SetEnergyLevel(1.0f);
3ec1fca
                 }
3ec1fca
 
3ec1fca
                 if (object->Implements(ObjectInterfaceType::Shielded))
3ec1fca
-                    dynamic_cast<CShieldedObject*>(object)->SetShield(1.0f);
3ec1fca
+                    dynamic_cast<CShieldedObject&>(*object).SetShield(1.0f);
3ec1fca
 
3ec1fca
                 if (object->Implements(ObjectInterfaceType::JetFlying))
3ec1fca
-                    dynamic_cast<CJetFlyingObject*>(object)->SetReactorRange(1.0f);
3ec1fca
+                    dynamic_cast<CJetFlyingObject&>(*object).SetReactorRange(1.0f);
3ec1fca
             }
3ec1fca
             return;
3ec1fca
         }
3ec1fca
@@ -1385,9 +1385,9 @@ void CRobotMain::ExecuteCmd(const std::string& cmd)
3ec1fca
             {
3ec1fca
                 if (object->Implements(ObjectInterfaceType::Powered))
3ec1fca
                 {
3ec1fca
-                    CObject* power = dynamic_cast<CPoweredObject*>(object)->GetPower();
3ec1fca
+                    CObject* power = dynamic_cast<CPoweredObject&>(*object).GetPower();
3ec1fca
                     if (power != nullptr && power->Implements(ObjectInterfaceType::PowerContainer))
3ec1fca
-                        dynamic_cast<CPowerContainerObject*>(power)->SetEnergyLevel(1.0f);
3ec1fca
+                        dynamic_cast<CPowerContainerObject&>(*power).SetEnergyLevel(1.0f);
3ec1fca
                 }
3ec1fca
             }
3ec1fca
             return;
3ec1fca
@@ -1397,7 +1397,7 @@ void CRobotMain::ExecuteCmd(const std::string& cmd)
3ec1fca
         {
3ec1fca
             CObject* object = GetSelect();
3ec1fca
             if (object != nullptr && object->Implements(ObjectInterfaceType::Shielded))
3ec1fca
-                dynamic_cast<CShieldedObject*>(object)->SetShield(1.0f);
3ec1fca
+                dynamic_cast<CShieldedObject&>(*object).SetShield(1.0f);
3ec1fca
             return;
3ec1fca
         }
3ec1fca
 
3ec1fca
@@ -1407,7 +1407,7 @@ void CRobotMain::ExecuteCmd(const std::string& cmd)
3ec1fca
             if (object != nullptr)
3ec1fca
             {
3ec1fca
                 if (object->Implements(ObjectInterfaceType::JetFlying))
3ec1fca
-                    dynamic_cast<CJetFlyingObject*>(object)->SetReactorRange(1.0f);
3ec1fca
+                    dynamic_cast<CJetFlyingObject&>(*object).SetReactorRange(1.0f);
3ec1fca
             }
3ec1fca
             return;
3ec1fca
         }
3ec1fca
@@ -1507,7 +1507,7 @@ void CRobotMain::StartDisplayInfo(int index, bool movie)
3ec1fca
     if (!m_editLock && movie && !m_movie->IsExist() && human)
3ec1fca
     {
3ec1fca
         assert(obj->Implements(ObjectInterfaceType::Movable));
3ec1fca
-        if (dynamic_cast<CMovableObject*>(obj)->GetMotion()->GetAction() == -1)
3ec1fca
+        if (dynamic_cast<CMovableObject&>(*obj).GetMotion()->GetAction() == -1)
3ec1fca
         {
3ec1fca
             m_movieInfoIndex = index;
3ec1fca
             m_movie->Start(MM_SATCOMopen, 2.5f);
3ec1fca
@@ -1821,7 +1821,7 @@ CObject* CRobotMain::DeselectAll()
3ec1fca
 void CRobotMain::SelectOneObject(CObject* obj, bool displayError)
3ec1fca
 {
3ec1fca
     assert(obj->Implements(ObjectInterfaceType::Controllable));
3ec1fca
-    dynamic_cast<CControllableObject*>(obj)->SetSelect(true, displayError);
3ec1fca
+    dynamic_cast<CControllableObject&>(*obj).SetSelect(true, displayError);
3ec1fca
     m_camera->SetControllingObject(obj);
3ec1fca
 
3ec1fca
     ObjectType type = obj->GetType();
3ec1fca
@@ -1854,7 +1854,7 @@ void CRobotMain::SelectOneObject(CObject* obj, bool displayError)
3ec1fca
          type == OBJECT_MOBILEdr ||
3ec1fca
          type == OBJECT_APOLLO2  )
3ec1fca
     {
3ec1fca
-        m_camera->SetType(dynamic_cast<CControllableObject*>(obj)->GetCameraType());
3ec1fca
+        m_camera->SetType(dynamic_cast<CControllableObject&>(*obj).GetCameraType());
3ec1fca
     }
3ec1fca
     else
3ec1fca
     {
3ec1fca
@@ -1870,7 +1870,7 @@ bool CRobotMain::SelectObject(CObject* obj, bool displayError)
3ec1fca
     if (m_movieLock || m_editLock) return false;
3ec1fca
     if (m_movie->IsExist()) return false;
3ec1fca
     if (obj != nullptr &&
3ec1fca
-        (!obj->Implements(ObjectInterfaceType::Controllable) || !(dynamic_cast<CControllableObject*>(obj)->GetSelectable() || m_cheatSelectInsect))) return false;
3ec1fca
+        (!obj->Implements(ObjectInterfaceType::Controllable) || !(dynamic_cast<CControllableObject&>(*obj).GetSelectable() || m_cheatSelectInsect))) return false;
3ec1fca
 
3ec1fca
     if (m_missionType == MISSION_CODE_BATTLE && m_codeBattleStarted && m_codeBattleSpectator)
3ec1fca
     {
3ec1fca
@@ -1946,7 +1946,7 @@ CObject* CRobotMain::GetSelect()
3ec1fca
     for (CObject* obj : m_objMan->GetAllObjects())
3ec1fca
     {
3ec1fca
         if (!obj->Implements(ObjectInterfaceType::Controllable)) continue;
3ec1fca
-        if (dynamic_cast<CControllableObject*>(obj)->GetSelect())
3ec1fca
+        if (dynamic_cast<CControllableObject&>(*obj).GetSelect())
3ec1fca
             return obj;
3ec1fca
     }
3ec1fca
     return nullptr;
3ec1fca
@@ -1964,7 +1964,7 @@ CObject* CRobotMain::DetectObject(Math::Point pos)
3ec1fca
 
3ec1fca
         CObject* transporter = nullptr;
3ec1fca
         if (obj->Implements(ObjectInterfaceType::Transportable))
3ec1fca
-            transporter = dynamic_cast<CTransportableObject*>(obj)->GetTransporter();
3ec1fca
+            transporter = dynamic_cast<CTransportableObject&>(*obj).GetTransporter();
3ec1fca
 
3ec1fca
         if (transporter != nullptr && !transporter->GetDetectable()) continue;
3ec1fca
         if (obj->GetProxyActivate()) continue;
3ec1fca
@@ -1972,14 +1972,14 @@ CObject* CRobotMain::DetectObject(Math::Point pos)
3ec1fca
         CObject* target = obj;
3ec1fca
         if (obj->Implements(ObjectInterfaceType::PowerContainer) && obj->Implements(ObjectInterfaceType::Transportable))
3ec1fca
         {
3ec1fca
-            target = dynamic_cast<CTransportableObject*>(obj)->GetTransporter();  // battery connected
3ec1fca
+            target = dynamic_cast<CTransportableObject&>(*obj).GetTransporter();  // battery connected
3ec1fca
             if (target == nullptr)
3ec1fca
             {
3ec1fca
                 target = obj; // standalone battery
3ec1fca
             }
3ec1fca
             else
3ec1fca
             {
3ec1fca
-                if (!target->Implements(ObjectInterfaceType::Powered) || dynamic_cast<CPoweredObject*>(target)->GetPower() != obj)
3ec1fca
+                if (!target->Implements(ObjectInterfaceType::Powered) || dynamic_cast<CPoweredObject&>(*target).GetPower() != obj)
3ec1fca
                 {
3ec1fca
                     // transported, but not in the power slot
3ec1fca
                     target = obj;
3ec1fca
@@ -2009,7 +2009,7 @@ bool CRobotMain::DestroySelectedObject()
3ec1fca
 
3ec1fca
     m_engine->GetPyroManager()->Create(Gfx::PT_FRAGT, obj);
3ec1fca
 
3ec1fca
-    dynamic_cast<CControllableObject*>(obj)->SetSelect(false);  // deselects the object
3ec1fca
+    dynamic_cast<CControllableObject&>(*obj).SetSelect(false);  // deselects the object
3ec1fca
     m_camera->SetType(Gfx::CAM_TYPE_EXPLO);
3ec1fca
     DeselectAll();
3ec1fca
     RemoveFromSelectionHistory(obj);
3ec1fca
@@ -2032,7 +2032,7 @@ void CRobotMain::HiliteClear()
3ec1fca
     for (CObject* obj : m_objMan->GetAllObjects())
3ec1fca
     {
3ec1fca
         if (!obj->Implements(ObjectInterfaceType::Controllable)) continue;
3ec1fca
-        dynamic_cast<CControllableObject*>(obj)->SetHighlight(false);
3ec1fca
+        dynamic_cast<CControllableObject&>(*obj).SetHighlight(false);
3ec1fca
     }
3ec1fca
     m_map->SetHighlight(nullptr);
3ec1fca
     m_short->SetHighlight(nullptr);
3ec1fca
@@ -2092,12 +2092,12 @@ void CRobotMain::HiliteObject(Math::Point pos)
3ec1fca
             }
3ec1fca
         }
3ec1fca
 
3ec1fca
-        if (obj->Implements(ObjectInterfaceType::Controllable) && (dynamic_cast<CControllableObject*>(obj)->GetSelectable() || m_cheatSelectInsect))
3ec1fca
+        if (obj->Implements(ObjectInterfaceType::Controllable) && (dynamic_cast<CControllableObject&>(*obj).GetSelectable() || m_cheatSelectInsect))
3ec1fca
         {
3ec1fca
-            if (dynamic_cast<CControllableObject*>(obj)->GetSelectable())
3ec1fca
+            if (dynamic_cast<CControllableObject&>(*obj).GetSelectable())
3ec1fca
             {
3ec1fca
                 // Don't highlight objects that would not be selectable without selectinsect
3ec1fca
-                dynamic_cast<CControllableObject*>(obj)->SetHighlight(true);
3ec1fca
+                dynamic_cast<CControllableObject&>(*obj).SetHighlight(true);
3ec1fca
             }
3ec1fca
             m_map->SetHighlight(obj);
3ec1fca
             m_short->SetHighlight(obj);
3ec1fca
@@ -2348,7 +2348,7 @@ bool CRobotMain::EventFrame(const Event &event)
3ec1fca
             if (obj->GetType() == OBJECT_TOTO)
3ec1fca
                 toto = obj;
3ec1fca
             else if (obj->Implements(ObjectInterfaceType::Interactive))
3ec1fca
-                dynamic_cast<CInteractiveObject*>(obj)->EventProcess(event);
3ec1fca
+                dynamic_cast<CInteractiveObject&>(*obj).EventProcess(event);
3ec1fca
 
3ec1fca
             if ( obj->GetProxyActivate() )  // active if it is near?
3ec1fca
             {
3ec1fca
@@ -2371,7 +2371,7 @@ bool CRobotMain::EventFrame(const Event &event)
3ec1fca
                 continue;
3ec1fca
 
3ec1fca
             if (obj->Implements(ObjectInterfaceType::Interactive))
3ec1fca
-                dynamic_cast<CInteractiveObject*>(obj)->EventProcess(event);
3ec1fca
+                dynamic_cast<CInteractiveObject&>(*obj).EventProcess(event);
3ec1fca
         }
3ec1fca
 
3ec1fca
         m_engine->GetPyroManager()->EventProcess(event);
3ec1fca
@@ -2395,7 +2395,7 @@ bool CRobotMain::EventFrame(const Event &event)
3ec1fca
 
3ec1fca
     // Advances toto following the camera, because its position depends on the camera.
3ec1fca
     if (toto != nullptr)
3ec1fca
-        dynamic_cast<CInteractiveObject*>(toto)->EventProcess(event);
3ec1fca
+        dynamic_cast<CInteractiveObject&>(*toto).EventProcess(event);
3ec1fca
 
3ec1fca
     // NOTE: m_movieLock is set only after the first update of CAutoBase finishes
3ec1fca
 
3ec1fca
@@ -2628,7 +2628,7 @@ bool CRobotMain::EventObject(const Event &event)
3ec1fca
     {
3ec1fca
         if (obj->Implements(ObjectInterfaceType::Interactive))
3ec1fca
         {
3ec1fca
-            dynamic_cast<CInteractiveObject*>(obj)->EventProcess(event);
3ec1fca
+            dynamic_cast<CInteractiveObject&>(*obj).EventProcess(event);
3ec1fca
         }
3ec1fca
     }
3ec1fca
 
3ec1fca
@@ -2669,7 +2669,7 @@ void CRobotMain::ScenePerso()
3ec1fca
         obj->SetDrawFront(true);  // draws the interface
3ec1fca
 
3ec1fca
         assert(obj->Implements(ObjectInterfaceType::Movable));
3ec1fca
-        CMotionHuman* mh = static_cast<CMotionHuman*>(dynamic_cast<CMovableObject*>(obj)->GetMotion());
3ec1fca
+        CMotionHuman* mh = static_cast<CMotionHuman*>(dynamic_cast<CMovableObject&>(*obj).GetMotion());
3ec1fca
         mh->StartDisplayPerso();
3ec1fca
     }
3ec1fca
 }
3ec1fca
@@ -3337,7 +3337,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
3ec1fca
                 assert(m_controller->Implements(ObjectInterfaceType::ProgramStorage));
3ec1fca
 
3ec1fca
                 assert(m_controller->Implements(ObjectInterfaceType::Old));
3ec1fca
-                dynamic_cast<COldObject*>(m_controller)->SetCheckToken(false);
3ec1fca
+                dynamic_cast<COldObject&>(*m_controller).SetCheckToken(false);
3ec1fca
 
3ec1fca
                 if (line->GetParam("script")->IsDefined())
3ec1fca
                 {
3ec1fca
@@ -3345,7 +3345,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
3ec1fca
                     Program* program = programStorage->AddProgram();
3ec1fca
                     programStorage->ReadProgram(program, line->GetParam("script")->AsPath("ai"));
3ec1fca
                     program->readOnly = true;
3ec1fca
-                    dynamic_cast<CProgrammableObject*>(m_controller)->RunProgram(program);
3ec1fca
+                    dynamic_cast<CProgrammableObject&>(*m_controller).RunProgram(program);
3ec1fca
                 }
3ec1fca
                 continue;
3ec1fca
             }
3ec1fca
@@ -3370,7 +3370,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
3ec1fca
                     if (m_fixScene && obj->GetType() == OBJECT_HUMAN)
3ec1fca
                     {
3ec1fca
                         assert(obj->Implements(ObjectInterfaceType::Movable));
3ec1fca
-                        CMotion* motion = dynamic_cast<CMovableObject*>(obj)->GetMotion();
3ec1fca
+                        CMotion* motion = dynamic_cast<CMovableObject&>(*obj).GetMotion();
3ec1fca
                         if (m_phase == PHASE_WIN ) motion->SetAction(MHS_WIN,  0.4f);
3ec1fca
                         if (m_phase == PHASE_LOST) motion->SetAction(MHS_LOST, 0.5f);
3ec1fca
                     }
3ec1fca
@@ -3385,7 +3385,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
3ec1fca
                     {
3ec1fca
                         CProgramStorageObject* programStorage = dynamic_cast<CProgramStorageObject*>(obj);
3ec1fca
 
3ec1fca
-                        if (obj->Implements(ObjectInterfaceType::Controllable) && dynamic_cast<CControllableObject*>(obj)->GetSelectable() && obj->GetType() != OBJECT_HUMAN)
3ec1fca
+                        if (obj->Implements(ObjectInterfaceType::Controllable) && dynamic_cast<CControllableObject&>(*obj).GetSelectable() && obj->GetType() != OBJECT_HUMAN)
3ec1fca
                         {
3ec1fca
                             programStorage->SetProgramStorageIndex(rankObj);
3ec1fca
                         }
3ec1fca
@@ -3768,7 +3768,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
3ec1fca
                 assert(obj->Implements(ObjectInterfaceType::Controllable));
3ec1fca
                 SelectObject(obj);
3ec1fca
                 m_camera->SetControllingObject(obj);
3ec1fca
-                m_camera->SetType(dynamic_cast<CControllableObject*>(obj)->GetCameraType());
3ec1fca
+                m_camera->SetType(dynamic_cast<CControllableObject&>(*obj).GetCameraType());
3ec1fca
             }
3ec1fca
         }
3ec1fca
 
3ec1fca
@@ -4363,7 +4363,7 @@ void CRobotMain::StartShowLimit()
3ec1fca
     CObject* obj = GetSelect();
3ec1fca
     if (obj == nullptr) return;
3ec1fca
     if (!obj->Implements(ObjectInterfaceType::Ranged)) return;
3ec1fca
-    float range = dynamic_cast<CRangedObject*>(obj)->GetShowLimitRadius();
3ec1fca
+    float range = dynamic_cast<CRangedObject&>(*obj).GetShowLimitRadius();
3ec1fca
     if (range == 0.0f) return;
3ec1fca
     SetShowLimit(0, Gfx::PARTILIMIT1, obj, obj->GetPosition(), range);
3ec1fca
 }
3ec1fca
@@ -4503,8 +4503,8 @@ bool CRobotMain::IOIsBusy()
3ec1fca
     {
3ec1fca
         if (! obj->Implements(ObjectInterfaceType::TaskExecutor)) continue;
3ec1fca
 
3ec1fca
-        if (obj->Implements(ObjectInterfaceType::Programmable) && dynamic_cast<CProgrammableObject*>(obj)->IsProgram()) continue; // TODO: I'm not sure if this is correct but this is how it worked earlier
3ec1fca
-        if (dynamic_cast<CTaskExecutorObject*>(obj)->IsForegroundTask()) return true;
3ec1fca
+        if (obj->Implements(ObjectInterfaceType::Programmable) && dynamic_cast<CProgrammableObject&>(*obj).IsProgram()) continue; // TODO: I'm not sure if this is correct but this is how it worked earlier
3ec1fca
+        if (dynamic_cast<CTaskExecutorObject&>(*obj).IsForegroundTask()) return true;
3ec1fca
     }
3ec1fca
     return false;
3ec1fca
 }
3ec1fca
@@ -4555,7 +4555,7 @@ void CRobotMain::IOWriteObject(CLevelParserLine* line, CObject* obj, const std::
3ec1fca
 
3ec1fca
         if (obj->Implements(ObjectInterfaceType::Programmable))
3ec1fca
         {
3ec1fca
-            int run = dynamic_cast<CProgramStorageObject*>(obj)->GetProgramIndex(dynamic_cast<CProgrammableObject*>(obj)->GetCurrentProgram());
3ec1fca
+            int run = dynamic_cast<CProgramStorageObject&>(*obj).GetProgramIndex(dynamic_cast<CProgrammableObject&>(*obj).GetCurrentProgram());
3ec1fca
             if (run != -1)
3ec1fca
             {
3ec1fca
                 line->AddParam("run", MakeUnique<CLevelParserParam>(run+1));
3ec1fca
@@ -4630,11 +4630,11 @@ bool CRobotMain::IOWriteScene(std::string filename, std::string filecbot, std::s
3ec1fca
     {
3ec1fca
         if (obj->GetType() == OBJECT_TOTO) continue;
3ec1fca
         if (IsObjectBeingTransported(obj)) continue;
3ec1fca
-        if (obj->Implements(ObjectInterfaceType::Destroyable) && dynamic_cast<CDestroyableObject*>(obj)->IsDying()) continue;
3ec1fca
+        if (obj->Implements(ObjectInterfaceType::Destroyable) && dynamic_cast<CDestroyableObject&>(*obj).IsDying()) continue;
3ec1fca
 
3ec1fca
         if (obj->Implements(ObjectInterfaceType::Carrier))
3ec1fca
         {
3ec1fca
-            CObject* cargo = dynamic_cast<CCarrierObject*>(obj)->GetCargo();
3ec1fca
+            CObject* cargo = dynamic_cast<CCarrierObject&>(*obj).GetCargo();
3ec1fca
             if (cargo != nullptr)  // object transported?
3ec1fca
             {
3ec1fca
                 line = MakeUnique<CLevelParserLine>("CreateFret");
3ec1fca
@@ -4645,7 +4645,7 @@ bool CRobotMain::IOWriteScene(std::string filename, std::string filecbot, std::s
3ec1fca
 
3ec1fca
         if (obj->Implements(ObjectInterfaceType::Powered))
3ec1fca
         {
3ec1fca
-            CObject* power = dynamic_cast<CPoweredObject*>(obj)->GetPower();
3ec1fca
+            CObject* power = dynamic_cast<CPoweredObject&>(*obj).GetPower();
3ec1fca
             if (power != nullptr) // battery transported?
3ec1fca
             {
3ec1fca
                 line = MakeUnique<CLevelParserLine>("CreatePower");
3ec1fca
@@ -4683,7 +4683,7 @@ bool CRobotMain::IOWriteScene(std::string filename, std::string filecbot, std::s
3ec1fca
     {
3ec1fca
         if (obj->GetType() == OBJECT_TOTO) continue;
3ec1fca
         if (IsObjectBeingTransported(obj)) continue;
3ec1fca
-        if (obj->Implements(ObjectInterfaceType::Destroyable) && dynamic_cast<CDestroyableObject*>(obj)->IsDying()) continue;
3ec1fca
+        if (obj->Implements(ObjectInterfaceType::Destroyable) && dynamic_cast<CDestroyableObject&>(*obj).IsDying()) continue;
3ec1fca
 
3ec1fca
         if (!SaveFileStack(obj, file, objRank++))  break;
3ec1fca
     }
3ec1fca
@@ -4824,7 +4824,7 @@ CObject* CRobotMain::IOReadScene(std::string filename, std::string filecbot)
3ec1fca
             {
3ec1fca
                 assert(obj->Implements(ObjectInterfaceType::Carrier)); // TODO: exception?
3ec1fca
                 assert(obj->Implements(ObjectInterfaceType::Old));
3ec1fca
-                dynamic_cast<CCarrierObject*>(obj)->SetCargo(cargo);
3ec1fca
+                dynamic_cast<CCarrierObject&>(*obj).SetCargo(cargo);
3ec1fca
                 auto task = MakeUnique<CTaskManip>(dynamic_cast<COldObject*>(obj));
3ec1fca
                 task->Start(TMO_AUTO, TMA_GRAB);  // holds the object!
3ec1fca
             }
3ec1fca
@@ -4832,9 +4832,9 @@ CObject* CRobotMain::IOReadScene(std::string filename, std::string filecbot)
3ec1fca
             if (power != nullptr)
3ec1fca
             {
3ec1fca
                 assert(obj->Implements(ObjectInterfaceType::Powered));
3ec1fca
-                dynamic_cast<CPoweredObject*>(obj)->SetPower(power);
3ec1fca
+                dynamic_cast<CPoweredObject&>(*obj).SetPower(power);
3ec1fca
                 assert(power->Implements(ObjectInterfaceType::Transportable));
3ec1fca
-                dynamic_cast<CTransportableObject*>(power)->SetTransporter(obj);
3ec1fca
+                dynamic_cast<CTransportableObject&>(*power).SetTransporter(obj);
3ec1fca
             }
3ec1fca
             cargo = nullptr;
3ec1fca
             power = nullptr;
3ec1fca
@@ -4861,7 +4861,7 @@ CObject* CRobotMain::IOReadScene(std::string filename, std::string filecbot)
3ec1fca
                 {
3ec1fca
                     if (obj->GetType() == OBJECT_TOTO) continue;
3ec1fca
                     if (IsObjectBeingTransported(obj)) continue;
3ec1fca
-                    if (obj->Implements(ObjectInterfaceType::Destroyable) && dynamic_cast<CDestroyableObject*>(obj)->IsDying()) continue;
3ec1fca
+                    if (obj->Implements(ObjectInterfaceType::Destroyable) && dynamic_cast<CDestroyableObject&>(*obj).IsDying()) continue;
3ec1fca
 
3ec1fca
                     if (!ReadFileStack(obj, file, objRank++)) break;
3ec1fca
                 }
3ec1fca
@@ -5204,7 +5204,7 @@ Error CRobotMain::CheckEndMission(bool frame)
3ec1fca
             if (m_base != nullptr && !m_endTakeImmediat)
3ec1fca
             {
3ec1fca
                 assert(m_base->Implements(ObjectInterfaceType::Controllable));
3ec1fca
-                if(dynamic_cast<CControllableObject*>(m_base)->GetSelectable())
3ec1fca
+                if(dynamic_cast<CControllableObject&>(*m_base).GetSelectable())
3ec1fca
                     return ERR_MISSION_NOTERM;
3ec1fca
             }
3ec1fca
         }
3ec1fca
diff --git a/src/level/scene_conditions.cpp b/src/level/scene_conditions.cpp
3ec1fca
index 263ee39..1a98e53 100644
3ec1fca
--- a/src/level/scene_conditions.cpp
3ec1fca
+++ b/src/level/scene_conditions.cpp
3ec1fca
@@ -82,7 +82,7 @@ bool CObjectCondition::CheckForObject(CObject* obj)
3ec1fca
     }
3ec1fca
     else if (obj->Implements(ObjectInterfaceType::Powered))
3ec1fca
     {
3ec1fca
-        CObject* powerObj = dynamic_cast<CPoweredObject*>(obj)->GetPower();
3ec1fca
+        CObject* powerObj = dynamic_cast<CPoweredObject&>(*obj).GetPower();
3ec1fca
         if(powerObj != nullptr && powerObj->Implements(ObjectInterfaceType::PowerContainer))
3ec1fca
         {
3ec1fca
             power = dynamic_cast<CPowerContainerObject*>(powerObj);
3ec1fca
@@ -98,7 +98,7 @@ bool CObjectCondition::CheckForObject(CObject* obj)
3ec1fca
 
3ec1fca
     Math::Vector oPos;
3ec1fca
     if (IsObjectBeingTransported(obj))
3ec1fca
-        oPos = dynamic_cast<CTransportableObject*>(obj)->GetTransporter()->GetPosition();
3ec1fca
+        oPos = dynamic_cast<CTransportableObject&>(*obj).GetTransporter()->GetPosition();
3ec1fca
     else
3ec1fca
         oPos = obj->GetPosition();
3ec1fca
     oPos.y = 0.0f;
3ec1fca
diff --git a/src/object/auto/autobase.cpp b/src/object/auto/autobase.cpp
3ec1fca
index 32b2428..da35ace 100644
3ec1fca
--- a/src/object/auto/autobase.cpp
3ec1fca
+++ b/src/object/auto/autobase.cpp
3ec1fca
@@ -169,7 +169,7 @@ begin:
3ec1fca
             else
3ec1fca
             {
3ec1fca
                 assert(pObj->Implements(ObjectInterfaceType::Controllable));
3ec1fca
-                m_camera->SetType(dynamic_cast<CControllableObject*>(pObj)->GetCameraType());
3ec1fca
+                m_camera->SetType(dynamic_cast<CControllableObject&>(*pObj).GetCameraType());
3ec1fca
             }
3ec1fca
 
3ec1fca
             m_main->StartMusic();
3ec1fca
@@ -594,7 +594,7 @@ begin:
3ec1fca
                 else
3ec1fca
                 {
3ec1fca
                     assert(pObj->Implements(ObjectInterfaceType::Controllable));
3ec1fca
-                    m_camera->SetType(dynamic_cast<CControllableObject*>(pObj)->GetCameraType());
3ec1fca
+                    m_camera->SetType(dynamic_cast<CControllableObject&>(*pObj).GetCameraType());
3ec1fca
                 }
3ec1fca
                 m_sound->Play(SOUND_BOUM, m_object->GetPosition());
3ec1fca
                 m_soundChannel = -1;
3ec1fca
@@ -1124,7 +1124,7 @@ bool CAutoBase::Abort()
3ec1fca
             else
3ec1fca
             {
3ec1fca
                 assert(pObj->Implements(ObjectInterfaceType::Controllable));
3ec1fca
-                m_camera->SetType(dynamic_cast<CControllableObject*>(pObj)->GetCameraType());
3ec1fca
+                m_camera->SetType(dynamic_cast<CControllableObject&>(*pObj).GetCameraType());
3ec1fca
             }
3ec1fca
 
3ec1fca
             m_engine->SetFogStart(m_fogStart);
3ec1fca
@@ -1246,7 +1246,7 @@ void CAutoBase::FreezeCargo(bool freeze)
3ec1fca
             m_cargoObjects.insert(obj);
3ec1fca
             if ( obj->Implements(ObjectInterfaceType::Movable) )
3ec1fca
             {
3ec1fca
-                CPhysics* physics = dynamic_cast<CMovableObject*>(obj)->GetPhysics();
3ec1fca
+                CPhysics* physics = dynamic_cast<CMovableObject&>(*obj).GetPhysics();
3ec1fca
                 physics->SetFreeze(freeze);
3ec1fca
             }
3ec1fca
         }
3ec1fca
diff --git a/src/object/auto/autodestroyer.cpp b/src/object/auto/autodestroyer.cpp
3ec1fca
index ccb3cbd..4a778a8 100644
3ec1fca
--- a/src/object/auto/autodestroyer.cpp
3ec1fca
+++ b/src/object/auto/autodestroyer.cpp
3ec1fca
@@ -176,7 +176,7 @@ bool CAutoDestroyer::EventProcess(const Event &event)
3ec1fca
             if ( scrap != nullptr )
3ec1fca
             {
3ec1fca
                 assert(scrap->Implements(ObjectInterfaceType::Destroyable));
3ec1fca
-                dynamic_cast<CDestroyableObject*>(scrap)->DestroyObject(DestructionType::Explosion);
3ec1fca
+                dynamic_cast<CDestroyableObject&>(*scrap).DestroyObject(DestructionType::Explosion);
3ec1fca
             }
3ec1fca
             m_bExplo = true;
3ec1fca
         }
3ec1fca
diff --git a/src/object/auto/autoegg.cpp b/src/object/auto/autoegg.cpp
3ec1fca
index 7ea3e75..a92d43a 100644
3ec1fca
--- a/src/object/auto/autoegg.cpp
3ec1fca
+++ b/src/object/auto/autoegg.cpp
3ec1fca
@@ -74,7 +74,7 @@ void CAutoEgg::DeleteObject(bool all)
3ec1fca
                 alien->SetLock(false);
3ec1fca
                 if (alien->Implements(ObjectInterfaceType::Programmable))
3ec1fca
                 {
3ec1fca
-                    dynamic_cast<CProgrammableObject*>(alien)->SetActivity(true);  // the insect is active
3ec1fca
+                    dynamic_cast<CProgrammableObject&>(*alien).SetActivity(true);  // the insect is active
3ec1fca
                 }
3ec1fca
             }
3ec1fca
             else
3ec1fca
@@ -123,7 +123,7 @@ void CAutoEgg::Init()
3ec1fca
 
3ec1fca
     if (alien->Implements(ObjectInterfaceType::Programmable))
3ec1fca
     {
3ec1fca
-        dynamic_cast<CProgrammableObject*>(alien)->SetActivity(false);
3ec1fca
+        dynamic_cast<CProgrammableObject&>(*alien).SetActivity(false);
3ec1fca
     }
3ec1fca
 }
3ec1fca
 
3ec1fca
@@ -204,7 +204,7 @@ bool CAutoEgg::EventProcess(const Event &event)
3ec1fca
     if ( alien == nullptr )  return true;
3ec1fca
     if (alien->Implements(ObjectInterfaceType::Programmable))
3ec1fca
     {
3ec1fca
-        dynamic_cast<CProgrammableObject*>(alien)->SetActivity(false);
3ec1fca
+        dynamic_cast<CProgrammableObject&>(*alien).SetActivity(false);
3ec1fca
     }
3ec1fca
 
3ec1fca
     m_progress += event.rTime*m_speed;
3ec1fca
@@ -265,7 +265,7 @@ Error CAutoEgg::IsEnded()
3ec1fca
         alien->SetLock(false);
3ec1fca
         if(alien->Implements(ObjectInterfaceType::Programmable))
3ec1fca
         {
3ec1fca
-            dynamic_cast<CProgrammableObject*>(alien)->SetActivity(true);  // the insect is active
3ec1fca
+            dynamic_cast<CProgrammableObject&>(*alien).SetActivity(true);  // the insect is active
3ec1fca
         }
3ec1fca
     }
3ec1fca
 
3ec1fca
diff --git a/src/object/auto/autofactory.cpp b/src/object/auto/autofactory.cpp
3ec1fca
index 343d57b..c66e431 100644
3ec1fca
--- a/src/object/auto/autofactory.cpp
3ec1fca
+++ b/src/object/auto/autofactory.cpp
3ec1fca
@@ -392,7 +392,7 @@ bool CAutoFactory::EventProcess(const Event &event)
3ec1fca
             if ( vehicle != nullptr )
3ec1fca
             {
3ec1fca
                 assert(vehicle->Implements(ObjectInterfaceType::Movable));
3ec1fca
-                physics = dynamic_cast<CMovableObject*>(vehicle)->GetPhysics();
3ec1fca
+                physics = dynamic_cast<CMovableObject&>(*vehicle).GetPhysics();
3ec1fca
                 physics->SetFreeze(false);  // can move
3ec1fca
 
3ec1fca
                 vehicle->SetLock(false);  // vehicle useable
3ec1fca
@@ -403,7 +403,7 @@ bool CAutoFactory::EventProcess(const Event &event)
3ec1fca
                 {
3ec1fca
                     if (vehicle->Implements(ObjectInterfaceType::Programmable) && vehicle->Implements(ObjectInterfaceType::ProgramStorage))
3ec1fca
                     {
3ec1fca
-                        Program* program = dynamic_cast<CProgramStorageObject*>(vehicle)->AddProgram();
3ec1fca
+                        Program* program = dynamic_cast<CProgramStorageObject&>(*vehicle).AddProgram();
3ec1fca
 
3ec1fca
                         if (boost::regex_match(m_program, boost::regex("[A-Za-z0-9_]+"))) // Public function name?
3ec1fca
                         {
3ec1fca
@@ -419,7 +419,7 @@ bool CAutoFactory::EventProcess(const Event &event)
3ec1fca
                             program->script->SendScript(m_program.c_str());
3ec1fca
                         }
3ec1fca
 
3ec1fca
-                        dynamic_cast<CProgrammableObject*>(vehicle)->RunProgram(program);
3ec1fca
+                        dynamic_cast<CProgrammableObject&>(*vehicle).RunProgram(program);
3ec1fca
                     }
3ec1fca
                 }
3ec1fca
             }
3ec1fca
@@ -658,7 +658,7 @@ bool CAutoFactory::CreateVehicle()
3ec1fca
     vehicle->SetLock(true);  // not usable
3ec1fca
 
3ec1fca
     assert(vehicle->Implements(ObjectInterfaceType::Movable));
3ec1fca
-    CPhysics* physics = dynamic_cast<CMovableObject*>(vehicle)->GetPhysics();
3ec1fca
+    CPhysics* physics = dynamic_cast<CMovableObject&>(*vehicle).GetPhysics();
3ec1fca
     physics->SetFreeze(true);  // it doesn't move
3ec1fca
 
3ec1fca
     if (vehicle->Implements(ObjectInterfaceType::ProgramStorage))
3ec1fca
diff --git a/src/object/auto/autonuclearplant.cpp b/src/object/auto/autonuclearplant.cpp
3ec1fca
index a341c45..2974fcf 100644
3ec1fca
--- a/src/object/auto/autonuclearplant.cpp
3ec1fca
+++ b/src/object/auto/autonuclearplant.cpp
3ec1fca
@@ -394,7 +394,7 @@ void CAutoNuclearPlant::CreatePower()
3ec1fca
     float powerLevel = 1.0f;
3ec1fca
     CObject* power = CObjectManager::GetInstancePointer()->CreateObject(pos, angle, OBJECT_ATOMIC, powerLevel);
3ec1fca
 
3ec1fca
-    dynamic_cast<CTransportableObject*>(power)->SetTransporter(m_object);
3ec1fca
+    dynamic_cast<CTransportableObject&>(*power).SetTransporter(m_object);
3ec1fca
     power->SetPosition(Math::Vector(22.0f, 3.0f, 0.0f));
3ec1fca
     m_object->SetPower(power);
3ec1fca
 }
3ec1fca
diff --git a/src/object/auto/autopowercaptor.cpp b/src/object/auto/autopowercaptor.cpp
3ec1fca
index fea4586..34f9fe0 100644
3ec1fca
--- a/src/object/auto/autopowercaptor.cpp
3ec1fca
+++ b/src/object/auto/autopowercaptor.cpp
3ec1fca
@@ -269,7 +269,7 @@ void CAutoPowerCaptor::ChargeObject(float rTime)
3ec1fca
 
3ec1fca
         if (obj->Implements(ObjectInterfaceType::Powered))
3ec1fca
         {
3ec1fca
-            CObject* power = dynamic_cast<CPoweredObject*>(obj)->GetPower();
3ec1fca
+            CObject* power = dynamic_cast<CPoweredObject&>(*obj).GetPower();
3ec1fca
             if ( power != nullptr && power->Implements(ObjectInterfaceType::PowerContainer) )
3ec1fca
             {
3ec1fca
                 CPowerContainerObject* powerContainer = dynamic_cast<CPowerContainerObject*>(power);
3ec1fca
@@ -285,7 +285,7 @@ void CAutoPowerCaptor::ChargeObject(float rTime)
3ec1fca
 
3ec1fca
         if (obj->Implements(ObjectInterfaceType::Carrier))
3ec1fca
         {
3ec1fca
-            CObject* power = dynamic_cast<CCarrierObject*>(obj)->GetCargo();
3ec1fca
+            CObject* power = dynamic_cast<CCarrierObject&>(*obj).GetCargo();
3ec1fca
             if ( power != nullptr && power->Implements(ObjectInterfaceType::PowerContainer) )
3ec1fca
             {
3ec1fca
                 CPowerContainerObject* powerContainer = dynamic_cast<CPowerContainerObject*>(power);
3ec1fca
diff --git a/src/object/auto/autopowerplant.cpp b/src/object/auto/autopowerplant.cpp
3ec1fca
index d7294b9..690e20a 100644
3ec1fca
--- a/src/object/auto/autopowerplant.cpp
3ec1fca
+++ b/src/object/auto/autopowerplant.cpp
3ec1fca
@@ -331,7 +331,7 @@ bool CAutoPowerPlant::EventProcess(const Event &event)
3ec1fca
 
3ec1fca
                 cargo->SetScale(1.0f);
3ec1fca
                 cargo->SetLock(false);  // usable battery
3ec1fca
-                dynamic_cast<CTransportableObject*>(cargo)->SetTransporter(m_object);
3ec1fca
+                dynamic_cast<CTransportableObject&>(*cargo).SetTransporter(m_object);
3ec1fca
                 cargo->SetPosition(Math::Vector(0.0f, 3.0f, 0.0f));
3ec1fca
                 m_object->SetPower(cargo);
3ec1fca
 
3ec1fca
diff --git a/src/object/auto/autopowerstation.cpp b/src/object/auto/autopowerstation.cpp
3ec1fca
index 5b90b6f..9271013 100644
3ec1fca
--- a/src/object/auto/autopowerstation.cpp
3ec1fca
+++ b/src/object/auto/autopowerstation.cpp
3ec1fca
@@ -138,7 +138,7 @@ bool CAutoPowerStation::EventProcess(const Event &event)
3ec1fca
         {
3ec1fca
             if (vehicle->Implements(ObjectInterfaceType::Powered))
3ec1fca
             {
3ec1fca
-                CObject* power = dynamic_cast<CPoweredObject*>(vehicle)->GetPower();
3ec1fca
+                CObject* power = dynamic_cast<CPoweredObject&>(*vehicle).GetPower();
3ec1fca
                 if ( power != nullptr && power->Implements(ObjectInterfaceType::PowerContainer) )
3ec1fca
                 {
3ec1fca
                     CPowerContainerObject* powerContainer = dynamic_cast<CPowerContainerObject*>(power);
3ec1fca
@@ -158,7 +158,7 @@ bool CAutoPowerStation::EventProcess(const Event &event)
3ec1fca
 
3ec1fca
             if (vehicle->Implements(ObjectInterfaceType::Carrier))
3ec1fca
             {
3ec1fca
-                CObject* power = dynamic_cast<CCarrierObject*>(vehicle)->GetCargo();
3ec1fca
+                CObject* power = dynamic_cast<CCarrierObject&>(*vehicle).GetCargo();
3ec1fca
                 if ( power != nullptr && power->Implements(ObjectInterfaceType::PowerContainer) )
3ec1fca
                 {
3ec1fca
                     CPowerContainerObject* powerContainer = dynamic_cast<CPowerContainerObject*>(power);
3ec1fca
diff --git a/src/object/auto/autorepair.cpp b/src/object/auto/autorepair.cpp
3ec1fca
index d580ce8..2ff6eaa 100644
3ec1fca
--- a/src/object/auto/autorepair.cpp
3ec1fca
+++ b/src/object/auto/autorepair.cpp
3ec1fca
@@ -148,7 +148,7 @@ bool CAutoRepair::EventProcess(const Event &event)
3ec1fca
             assert(vehicle->Implements(ObjectInterfaceType::Shielded));
3ec1fca
 
3ec1fca
         if ( m_progress < 1.0f ||
3ec1fca
-             (vehicle != nullptr && dynamic_cast<CShieldedObject*>(vehicle)->GetShield() < 1.0f) )
3ec1fca
+             (vehicle != nullptr && dynamic_cast<CShieldedObject&>(*vehicle).GetShield() < 1.0f) )
3ec1fca
         {
3ec1fca
             if ( vehicle != nullptr )
3ec1fca
             {
3ec1fca
@@ -243,9 +243,9 @@ CObject* CAutoRepair::SearchVehicle()
3ec1fca
     {
3ec1fca
         if (obj == m_object) continue;
3ec1fca
         if ( !obj->Implements(ObjectInterfaceType::Shielded) ) continue;
3ec1fca
-        if ( !dynamic_cast<CShieldedObject*>(obj)->IsRepairable() )  continue;
3ec1fca
+        if ( !dynamic_cast<CShieldedObject&>(*obj).IsRepairable() )  continue;
3ec1fca
 
3ec1fca
-        if ( obj->Implements(ObjectInterfaceType::Movable) && !dynamic_cast<CMovableObject*>(obj)->GetPhysics()->GetLand() )  continue;  // in flight?
3ec1fca
+        if ( obj->Implements(ObjectInterfaceType::Movable) && !dynamic_cast<CMovableObject&>(*obj).GetPhysics()->GetLand() )  continue;  // in flight?
3ec1fca
 
3ec1fca
         Math::Vector oPos = obj->GetPosition();
3ec1fca
         float dist = Math::Distance(oPos, sPos);
3ec1fca
diff --git a/src/object/auto/autotower.cpp b/src/object/auto/autotower.cpp
3ec1fca
index 053d29d..6ab241e 100644
3ec1fca
--- a/src/object/auto/autotower.cpp
3ec1fca
+++ b/src/object/auto/autotower.cpp
3ec1fca
@@ -289,7 +289,7 @@ CObject* CAutoTower::SearchTarget(Math::Vector &impact)
3ec1fca
         {
3ec1fca
             if ( obj->Implements(ObjectInterfaceType::Movable) )
3ec1fca
             {
3ec1fca
-                CPhysics* physics = dynamic_cast<CMovableObject*>(obj)->GetPhysics();
3ec1fca
+                CPhysics* physics = dynamic_cast<CMovableObject&>(*obj).GetPhysics();
3ec1fca
                 float speed = fabs(physics->GetLinMotionX(MO_REASPEED));
3ec1fca
                 if ( speed > 20.0f )  continue;  // moving too fast?
3ec1fca
             }
3ec1fca
@@ -302,8 +302,7 @@ CObject* CAutoTower::SearchTarget(Math::Vector &impact)
3ec1fca
         if ( distance > TOWER_SCOPE )  continue;  // too far
3ec1fca
         if ( distance < min )
3ec1fca
         {
3ec1fca
-            min = distance;
3ec1fca
-            best = obj;
3ec1fca
+            min = distance; best = obj;
3ec1fca
         }
3ec1fca
     }
3ec1fca
     if ( best == nullptr )  return nullptr;
3ec1fca
@@ -327,7 +326,7 @@ Error CAutoTower::GetError()
3ec1fca
         return ERR_TOWER_POWER;  // no battery
3ec1fca
     }
3ec1fca
 
3ec1fca
-    if ( dynamic_cast<CPowerContainerObject*>(m_object->GetPower())->GetEnergy() < ENERGY_FIRE )
3ec1fca
+    if ( dynamic_cast<CPowerContainerObject&>(*m_object->GetPower()).GetEnergy() < ENERGY_FIRE )
3ec1fca
     {
3ec1fca
         return ERR_TOWER_ENERGY;  // not enough energy
3ec1fca
     }
3ec1fca
diff --git a/src/object/implementation/program_storage_impl.cpp b/src/object/implementation/program_storage_impl.cpp
3ec1fca
index 8d59a86..c82adc9 100644
3ec1fca
--- a/src/object/implementation/program_storage_impl.cpp
3ec1fca
+++ b/src/object/implementation/program_storage_impl.cpp
3ec1fca
@@ -270,7 +270,7 @@ void CProgramStorageObjectImpl::LoadAllProgramsForLevel(CLevelParserLine* levelS
3ec1fca
 
3ec1fca
             if (m_object->Implements(ObjectInterfaceType::Programmable) && i == run)
3ec1fca
             {
3ec1fca
-                dynamic_cast<CProgrammableObject*>(m_object)->RunProgram(program);
3ec1fca
+                dynamic_cast<CProgrammableObject&>(*m_object).RunProgram(program);
3ec1fca
             }
3ec1fca
         }
3ec1fca
         else
3ec1fca
@@ -327,7 +327,7 @@ void CProgramStorageObjectImpl::SaveAllProgramsForSavedScene(CLevelParserLine* l
3ec1fca
     }
3ec1fca
 
3ec1fca
     if (m_programStorageIndex < 0) return;
3ec1fca
-    if (!m_object->Implements(ObjectInterfaceType::Controllable) || !dynamic_cast<CControllableObject*>(m_object)->GetSelectable() || m_object->GetType() == OBJECT_HUMAN) return;
3ec1fca
+    if (!m_object->Implements(ObjectInterfaceType::Controllable) || !dynamic_cast<CControllableObject&>(*m_object).GetSelectable() || m_object->GetType() == OBJECT_HUMAN) return;
3ec1fca
 
3ec1fca
     GetLogger()->Debug("Saving saved scene programs to '%s/prog%.3d___.txt'\n", levelSource.c_str(), m_programStorageIndex);
3ec1fca
     for (unsigned int i = 0; i < m_program.size(); i++)
3ec1fca
@@ -379,7 +379,7 @@ void CProgramStorageObjectImpl::LoadAllProgramsForSavedScene(CLevelParserLine* l
3ec1fca
 
3ec1fca
             if (m_object->Implements(ObjectInterfaceType::Programmable) && i == run)
3ec1fca
             {
3ec1fca
-                dynamic_cast<CProgrammableObject*>(m_object)->RunProgram(program);
3ec1fca
+                dynamic_cast<CProgrammableObject&>(*m_object).RunProgram(program);
3ec1fca
             }
3ec1fca
         }
3ec1fca
     }
3ec1fca
@@ -403,7 +403,7 @@ void CProgramStorageObjectImpl::LoadAllProgramsForSavedScene(CLevelParserLine* l
3ec1fca
 
3ec1fca
             if (m_object->Implements(ObjectInterfaceType::Programmable) && i == run)
3ec1fca
             {
3ec1fca
-                dynamic_cast<CProgrammableObject*>(m_object)->RunProgram(program);
3ec1fca
+                dynamic_cast<CProgrammableObject&>(*m_object).RunProgram(program);
3ec1fca
             }
3ec1fca
         }
3ec1fca
     }
3ec1fca
diff --git a/src/object/implementation/programmable_impl.cpp b/src/object/implementation/programmable_impl.cpp
3ec1fca
index 5e370bd..b4db83f 100644
3ec1fca
--- a/src/object/implementation/programmable_impl.cpp
3ec1fca
+++ b/src/object/implementation/programmable_impl.cpp
3ec1fca
@@ -68,7 +68,7 @@ bool CProgrammableObjectImpl::EventProcess(const Event &event)
3ec1fca
 {
3ec1fca
     if (event.type == EVENT_FRAME)
3ec1fca
     {
3ec1fca
-        if ( m_object->Implements(ObjectInterfaceType::Destroyable) && dynamic_cast<CDestroyableObject*>(m_object)->IsDying() && IsProgram() )
3ec1fca
+        if ( m_object->Implements(ObjectInterfaceType::Destroyable) && dynamic_cast<CDestroyableObject&>(*m_object).IsDying() && IsProgram() )
3ec1fca
         {
3ec1fca
             StopProgram();
3ec1fca
         }
3ec1fca
@@ -113,7 +113,7 @@ void CProgrammableObjectImpl::RunProgram(Program* program)
3ec1fca
     {
3ec1fca
         m_currentProgram = program;  // start new program
3ec1fca
         m_object->UpdateInterface();
3ec1fca
-        if (m_object->Implements(ObjectInterfaceType::Controllable) && dynamic_cast<CControllableObject*>(m_object)->GetTrainer())
3ec1fca
+        if (m_object->Implements(ObjectInterfaceType::Controllable) && dynamic_cast<CControllableObject&>(*m_object).GetTrainer())
3ec1fca
             CRobotMain::GetInstancePointer()->StartMissionTimer();
3ec1fca
     }
3ec1fca
 }
3ec1fca
@@ -155,8 +155,8 @@ bool CProgrammableObjectImpl::ReadStack(FILE *file)
3ec1fca
         {
3ec1fca
             if (m_object->Implements(ObjectInterfaceType::ProgramStorage))
3ec1fca
             {
3ec1fca
-                assert(op < static_cast<int>(dynamic_cast<CProgramStorageObject*>(m_object)->GetProgramCount()));
3ec1fca
-                m_currentProgram = dynamic_cast<CProgramStorageObject*>(m_object)->GetProgram(op);
3ec1fca
+                assert(op < static_cast<int>(dynamic_cast<CProgramStorageObject&>(*m_object).GetProgramCount()));
3ec1fca
+                m_currentProgram = dynamic_cast<CProgramStorageObject&>(*m_object).GetProgram(op);
3ec1fca
                 if ( !m_currentProgram->script->ReadStack(file) )  return false;
3ec1fca
             }
3ec1fca
             else
3ec1fca
@@ -184,7 +184,7 @@ bool CProgrammableObjectImpl::WriteStack(FILE *file)
3ec1fca
         op = -1;
3ec1fca
         if (m_object->Implements(ObjectInterfaceType::ProgramStorage))
3ec1fca
         {
3ec1fca
-            op = dynamic_cast<CProgramStorageObject*>(m_object)->GetProgramIndex(m_currentProgram);
3ec1fca
+            op = dynamic_cast<CProgramStorageObject&>(*m_object).GetProgramIndex(m_currentProgram);
3ec1fca
         }
3ec1fca
         CBot::fWrite(&op, sizeof(short), 1, file);
3ec1fca
 
3ec1fca
@@ -243,7 +243,7 @@ void CProgrammableObjectImpl::TraceRecordFrame()
3ec1fca
     assert(m_object->Implements(ObjectInterfaceType::TraceDrawing));
3ec1fca
     CTraceDrawingObject* traceDrawing = dynamic_cast<CTraceDrawingObject*>(m_object);
3ec1fca
 
3ec1fca
-    CPhysics* physics = dynamic_cast<CMovableObject*>(m_object)->GetPhysics();
3ec1fca
+    CPhysics* physics = dynamic_cast<CMovableObject&>(*m_object).GetPhysics();
3ec1fca
 
3ec1fca
     speed = physics->GetLinMotionX(MO_REASPEED);
3ec1fca
     if ( speed > 0.0f )  oper = TO_ADVANCE;
3ec1fca
@@ -330,7 +330,7 @@ void CProgrammableObjectImpl::TraceRecordStop()
3ec1fca
     buffer << "}\n";
3ec1fca
 
3ec1fca
     assert(m_object->Implements(ObjectInterfaceType::ProgramStorage));
3ec1fca
-    Program* prog = dynamic_cast<CProgramStorageObject*>(m_object)->AddProgram();
3ec1fca
+    Program* prog = dynamic_cast<CProgramStorageObject&>(*m_object).AddProgram();
3ec1fca
     prog->script->SendScript(buffer.str().c_str());
3ec1fca
 }
3ec1fca
 
3ec1fca
diff --git a/src/object/motion/motionant.cpp b/src/object/motion/motionant.cpp
3ec1fca
index bee3114..85b46b1 100644
3ec1fca
--- a/src/object/motion/motionant.cpp
3ec1fca
+++ b/src/object/motion/motionant.cpp
3ec1fca
@@ -429,7 +429,7 @@ bool CMotionAnt::EventFrame(const Event &event)
3ec1fca
     assert(m_object->Implements(ObjectInterfaceType::Destroyable));
3ec1fca
     if ( dynamic_cast<CDestroyableObject*>(m_object)->GetDying() == DeathType::Burning )  // burning?
3ec1fca
     {
3ec1fca
-        if ( dynamic_cast<CBaseAlien*>(m_object)->GetFixed() )
3ec1fca
+        if ( dynamic_cast<CBaseAlien&>(*m_object).GetFixed() )
3ec1fca
         {
3ec1fca
             m_actionType = MAS_BURN;
3ec1fca
         }
3ec1fca
@@ -724,7 +724,7 @@ bool CMotionAnt::EventFrame(const Event &event)
3ec1fca
         if ( m_progress >= 1.0f )
3ec1fca
         {
3ec1fca
             SetAction(-1);
3ec1fca
-            dynamic_cast<CBaseAlien*>(m_object)->SetFixed(false);  // moving again
3ec1fca
+            dynamic_cast<CBaseAlien&>(*m_object).SetFixed(false);  // moving again
3ec1fca
         }
3ec1fca
     }
3ec1fca
     else
3ec1fca
diff --git a/src/object/motion/motionspider.cpp b/src/object/motion/motionspider.cpp
3ec1fca
index 4aa046a..aa195f4 100644
3ec1fca
--- a/src/object/motion/motionspider.cpp
3ec1fca
+++ b/src/object/motion/motionspider.cpp
3ec1fca
@@ -364,7 +364,7 @@ bool CMotionSpider::EventFrame(const Event &event)
3ec1fca
     assert(m_object->Implements(ObjectInterfaceType::Destroyable));
3ec1fca
     if (dynamic_cast<CDestroyableObject*>(m_object)->GetDying() == DeathType::Burning )  // burning?
3ec1fca
     {
3ec1fca
-        if ( dynamic_cast<CBaseAlien*>(m_object)->GetFixed() )
3ec1fca
+        if ( dynamic_cast<CBaseAlien&>(*m_object).GetFixed() )
3ec1fca
         {
3ec1fca
             m_actionType = MSS_BURN;
3ec1fca
         }
3ec1fca
@@ -648,7 +648,7 @@ bool CMotionSpider::EventFrame(const Event &event)
3ec1fca
         if ( m_progress >= 1.0f )
3ec1fca
         {
3ec1fca
             SetAction(-1);
3ec1fca
-            dynamic_cast<CBaseAlien*>(m_object)->SetFixed(false);  // moving again
3ec1fca
+            dynamic_cast<CBaseAlien&>(*m_object).SetFixed(false);  // moving again
3ec1fca
         }
3ec1fca
     }
3ec1fca
     else
3ec1fca
diff --git a/src/object/motion/motionvehicle.cpp b/src/object/motion/motionvehicle.cpp
3ec1fca
index fa631fd..cc15f25 100644
3ec1fca
--- a/src/object/motion/motionvehicle.cpp
3ec1fca
+++ b/src/object/motion/motionvehicle.cpp
3ec1fca
@@ -928,7 +928,7 @@ void CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
3ec1fca
 
3ec1fca
         powerCell->SetPosition(powerCellPos);
3ec1fca
         powerCell->SetRotation(Math::Vector(0.0f, powerCellAngle, 0.0f));
3ec1fca
-        dynamic_cast<CTransportableObject*>(powerCell)->SetTransporter(m_object);
3ec1fca
+        dynamic_cast<CTransportableObject&>(*powerCell).SetTransporter(m_object);
3ec1fca
         assert(m_object->Implements(ObjectInterfaceType::Powered));
3ec1fca
         m_object->SetPower(powerCell);
3ec1fca
     }
3ec1fca
diff --git a/src/object/object_manager.cpp b/src/object/object_manager.cpp
3ec1fca
index 0b4daed..2651a5e 100644
3ec1fca
--- a/src/object/object_manager.cpp
3ec1fca
+++ b/src/object/object_manager.cpp
3ec1fca
@@ -205,7 +205,7 @@ void CObjectManager::DestroyTeam(int team, DestructionType destructionType)
3ec1fca
         {
3ec1fca
             if (object->Implements(ObjectInterfaceType::Destroyable))
3ec1fca
             {
3ec1fca
-                dynamic_cast<CDestroyableObject*>(object)->DestroyObject(destructionType);
3ec1fca
+                dynamic_cast<CDestroyableObject&>(*object).DestroyObject(destructionType);
3ec1fca
             }
3ec1fca
             else
3ec1fca
             {
3ec1fca
@@ -324,7 +324,7 @@ std::vector<CObject*> CObjectManager::RadarAll(CObject* pThis, Math::Vector this
3ec1fca
         {
3ec1fca
             if ( pObj->Implements(ObjectInterfaceType::Movable) )
3ec1fca
             {
3ec1fca
-                CPhysics* physics = dynamic_cast<CMovableObject*>(pObj)->GetPhysics();
3ec1fca
+                CPhysics* physics = dynamic_cast<CMovableObject&>(*pObj).GetPhysics();
3ec1fca
                 if ( physics != nullptr )
3ec1fca
                 {
3ec1fca
                     if ( !physics->GetLand() )  continue;
3ec1fca
@@ -334,7 +334,7 @@ std::vector<CObject*> CObjectManager::RadarAll(CObject* pThis, Math::Vector this
3ec1fca
         if ( filter_flying == FILTER_ONLYFLYING )
3ec1fca
         {
3ec1fca
             if ( !pObj->Implements(ObjectInterfaceType::Movable) ) continue;
3ec1fca
-            CPhysics* physics = dynamic_cast<CMovableObject*>(pObj)->GetPhysics();
3ec1fca
+            CPhysics* physics = dynamic_cast<CMovableObject&>(*pObj).GetPhysics();
3ec1fca
             if ( physics == nullptr ) continue;
3ec1fca
             if ( physics->GetLand() ) continue;
3ec1fca
         }
3ec1fca
diff --git a/src/object/old_object.cpp b/src/object/old_object.cpp
3ec1fca
index 3ecbb0e..f5d80b5 100644
3ec1fca
--- a/src/object/old_object.cpp
3ec1fca
+++ b/src/object/old_object.cpp
3ec1fca
@@ -285,8 +285,8 @@ void COldObject::DeleteObject(bool bAll)
3ec1fca
         {
3ec1fca
             if (m_power->Implements(ObjectInterfaceType::Old))
3ec1fca
             {
3ec1fca
-                dynamic_cast<COldObject*>(m_power)->SetTransporter(nullptr);
3ec1fca
-                dynamic_cast<COldObject*>(m_power)->DeleteObject(bAll);
3ec1fca
+                dynamic_cast<COldObject&>(*m_power).SetTransporter(nullptr);
3ec1fca
+                dynamic_cast<COldObject&>(*m_power).DeleteObject(bAll);
3ec1fca
             }
3ec1fca
             m_power = nullptr;
3ec1fca
         }
3ec1fca
@@ -294,8 +294,8 @@ void COldObject::DeleteObject(bool bAll)
3ec1fca
         {
3ec1fca
             if (m_cargo->Implements(ObjectInterfaceType::Old))
3ec1fca
             {
3ec1fca
-                dynamic_cast<COldObject*>(m_cargo)->SetTransporter(nullptr);
3ec1fca
-                dynamic_cast<COldObject*>(m_cargo)->DeleteObject(bAll);
3ec1fca
+                dynamic_cast<COldObject&>(*m_cargo).SetTransporter(nullptr);
3ec1fca
+                dynamic_cast<COldObject&>(*m_cargo).DeleteObject(bAll);
3ec1fca
             }
3ec1fca
             m_cargo = nullptr;
3ec1fca
         }
3ec1fca
diff --git a/src/object/task/taskfire.cpp b/src/object/task/taskfire.cpp
3ec1fca
index 590ce94..65ad8ee 100644
3ec1fca
--- a/src/object/task/taskfire.cpp
3ec1fca
+++ b/src/object/task/taskfire.cpp
3ec1fca
@@ -317,7 +317,7 @@ Error CTaskFire::Start(float delay)
3ec1fca
     CObject* power = dynamic_cast<CPoweredObject*>(m_object)->GetPower();
3ec1fca
     if (power == nullptr || !power->Implements(ObjectInterfaceType::PowerContainer))  return ERR_FIRE_ENERGY;
3ec1fca
 
3ec1fca
-    energy = dynamic_cast<CPowerContainerObject*>(power)->GetEnergy();
3ec1fca
+    energy = dynamic_cast<CPowerContainerObject&>(*power).GetEnergy();
3ec1fca
          if ( m_bOrganic )  fire = m_delay*ENERGY_FIREi;
3ec1fca
     else if ( m_bRay     )  fire = m_delay*ENERGY_FIREr;
3ec1fca
     else                    fire = m_delay*ENERGY_FIRE;
3ec1fca
diff --git a/src/object/task/taskfireant.cpp b/src/object/task/taskfireant.cpp
3ec1fca
index 35ddac7..57f5d2a 100644
3ec1fca
--- a/src/object/task/taskfireant.cpp
3ec1fca
+++ b/src/object/task/taskfireant.cpp
3ec1fca
@@ -60,7 +60,7 @@ bool CTaskFireAnt::EventProcess(const Event &event)
3ec1fca
     if ( event.type != EVENT_FRAME )  return true;
3ec1fca
     if ( m_bError )  return false;
3ec1fca
 
3ec1fca
-    if ( dynamic_cast<CBaseAlien*>(m_object)->GetFixed() )  // insect on its back?
3ec1fca
+    if ( dynamic_cast<CBaseAlien&>(*m_object).GetFixed() )  // insect on its back?
3ec1fca
     {
3ec1fca
         m_bError = true;
3ec1fca
         return false;
3ec1fca
@@ -100,7 +100,7 @@ Error CTaskFireAnt::Start(Math::Vector impact)
3ec1fca
     if ( type != OBJECT_ANT )  return ERR_WRONG_BOT;
3ec1fca
 
3ec1fca
     // Insect on its back?
3ec1fca
-    if ( dynamic_cast<CBaseAlien*>(m_object)->GetFixed() )  return ERR_WRONG_BOT;
3ec1fca
+    if ( dynamic_cast<CBaseAlien&>(*m_object).GetFixed() )  return ERR_WRONG_BOT;
3ec1fca
 
3ec1fca
     m_physics->SetMotorSpeed(Math::Vector(0.0f, 0.0f, 0.0f));
3ec1fca
 
3ec1fca
@@ -130,7 +130,7 @@ Error CTaskFireAnt::IsEnded()
3ec1fca
 
3ec1fca
     if ( m_engine->GetPause() )  return ERR_CONTINUE;
3ec1fca
     if ( m_bError )  return ERR_STOP;
3ec1fca
-    if ( dynamic_cast<CBaseAlien*>(m_object)->GetFixed() )  return ERR_STOP;  // insect on its back?
3ec1fca
+    if ( dynamic_cast<CBaseAlien&>(*m_object).GetFixed() )  return ERR_STOP;  // insect on its back?
3ec1fca
 
3ec1fca
     if ( m_phase == TFA_TURN )  // rotation ?
3ec1fca
     {
3ec1fca
diff --git a/src/object/task/taskgoto.cpp b/src/object/task/taskgoto.cpp
3ec1fca
index e1b3954..b334ed8 100644
3ec1fca
--- a/src/object/task/taskgoto.cpp
3ec1fca
+++ b/src/object/task/taskgoto.cpp
3ec1fca
@@ -1189,7 +1189,7 @@ bool CTaskGoto::AdjustTarget(CObject* pObj, Math::Vector &pos, float &distance)
3ec1fca
          type == OBJECT_MOBILEdr )
3ec1fca
     {
3ec1fca
         assert(pObj->Implements(ObjectInterfaceType::Powered));
3ec1fca
-        pos = dynamic_cast<CPoweredObject*>(pObj)->GetPowerPosition();
3ec1fca
+        pos = dynamic_cast<CPoweredObject&>(*pObj).GetPowerPosition();
3ec1fca
         pos.x -= TAKE_DIST+TAKE_DIST_OTHER+distance;
3ec1fca
         mat = pObj->GetWorldMatrix(0);
3ec1fca
         pos = Transform(*mat, pos);
3ec1fca
diff --git a/src/object/task/taskmanip.cpp b/src/object/task/taskmanip.cpp
3ec1fca
index 16615eb..c697ec1 100644
3ec1fca
--- a/src/object/task/taskmanip.cpp
3ec1fca
+++ b/src/object/task/taskmanip.cpp
3ec1fca
@@ -304,8 +304,8 @@ Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm)
3ec1fca
             assert(other->Implements(ObjectInterfaceType::Transportable));
3ec1fca
 
3ec1fca
             m_object->SetCargo(other);  // takes the ball
3ec1fca
-            dynamic_cast<CTransportableObject*>(other)->SetTransporter(m_object);
3ec1fca
-            dynamic_cast<CTransportableObject*>(other)->SetTransporterPart(0);  // taken with the base
3ec1fca
+            dynamic_cast<CTransportableObject&>(*other).SetTransporter(m_object);
3ec1fca
+            dynamic_cast<CTransportableObject&>(*other).SetTransporterPart(0);  // taken with the base
3ec1fca
             other->SetPosition(Math::Vector(0.0f, -3.0f, 0.0f));
3ec1fca
         }
3ec1fca
         else
3ec1fca
@@ -314,7 +314,7 @@ Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm)
3ec1fca
             assert(other->Implements(ObjectInterfaceType::Transportable));
3ec1fca
 
3ec1fca
             m_object->SetCargo(nullptr);  // lick the ball
3ec1fca
-            dynamic_cast<CTransportableObject*>(other)->SetTransporter(nullptr);
3ec1fca
+            dynamic_cast<CTransportableObject&>(*other).SetTransporter(nullptr);
3ec1fca
             pos = m_object->GetPosition();
3ec1fca
             pos.y -= 3.0f;
3ec1fca
             other->SetPosition(pos);
3ec1fca
@@ -903,7 +903,7 @@ CObject* CTaskManip::SearchOtherObject(bool bAdvance, Math::Vector &pos,
3ec1fca
         ObjectType type = pObj->GetType();
3ec1fca
         if ( !pObj->Implements(ObjectInterfaceType::Powered) )  continue;
3ec1fca
 
3ec1fca
-        CObject* power = dynamic_cast<CPoweredObject*>(pObj)->GetPower();
3ec1fca
+        CObject* power = dynamic_cast<CPoweredObject&>(*pObj).GetPower();
3ec1fca
         if (power != nullptr)
3ec1fca
         {
3ec1fca
             if (power->GetLock())  continue;
3ec1fca
@@ -911,7 +911,7 @@ CObject* CTaskManip::SearchOtherObject(bool bAdvance, Math::Vector &pos,
3ec1fca
         }
3ec1fca
 
3ec1fca
         mat = pObj->GetWorldMatrix(0);
3ec1fca
-        Math::Vector oPos = Transform(*mat, dynamic_cast<CPoweredObject*>(pObj)->GetPowerPosition());
3ec1fca
+        Math::Vector oPos = Transform(*mat, dynamic_cast<CPoweredObject&>(*pObj).GetPowerPosition());
3ec1fca
 
3ec1fca
         oAngle = pObj->GetRotationY();
3ec1fca
         if ( type == OBJECT_TOWER    ||
3ec1fca
@@ -946,7 +946,7 @@ CObject* CTaskManip::SearchOtherObject(bool bAdvance, Math::Vector &pos,
3ec1fca
             angle = Math::RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z);  // CW !
3ec1fca
             if ( Math::TestAngle(angle, iAngle-aLimit, iAngle+aLimit) )
3ec1fca
             {
3ec1fca
-                Math::Vector powerPos = dynamic_cast<CPoweredObject*>(pObj)->GetPowerPosition();
3ec1fca
+                Math::Vector powerPos = dynamic_cast<CPoweredObject&>(*pObj).GetPowerPosition();
3ec1fca
                 height = powerPos.y;
3ec1fca
                 pos = oPos;
3ec1fca
                 return pObj;
3ec1fca
@@ -974,8 +974,8 @@ bool CTaskManip::TransporterTakeObject()
3ec1fca
         if ( m_object->GetType() == OBJECT_HUMAN ||
3ec1fca
              m_object->GetType() == OBJECT_TECH  )
3ec1fca
         {
3ec1fca
-            dynamic_cast<CTransportableObject*>(cargo)->SetTransporter(m_object);
3ec1fca
-            dynamic_cast<CTransportableObject*>(cargo)->SetTransporterPart(4);  // takes with the hand
3ec1fca
+            dynamic_cast<CTransportableObject&>(*cargo).SetTransporter(m_object);
3ec1fca
+            dynamic_cast<CTransportableObject&>(*cargo).SetTransporterPart(4);  // takes with the hand
3ec1fca
 
3ec1fca
             cargo->SetPosition(Math::Vector(1.7f, -0.5f, 1.1f));
3ec1fca
             cargo->SetRotationY(0.1f);
3ec1fca
@@ -984,8 +984,8 @@ bool CTaskManip::TransporterTakeObject()
3ec1fca
         }
3ec1fca
         else if ( m_bSubm )
3ec1fca
         {
3ec1fca
-            dynamic_cast<CTransportableObject*>(cargo)->SetTransporter(m_object);
3ec1fca
-            dynamic_cast<CTransportableObject*>(cargo)->SetTransporterPart(2);  // takes with the right claw
3ec1fca
+            dynamic_cast<CTransportableObject&>(*cargo).SetTransporter(m_object);
3ec1fca
+            dynamic_cast<CTransportableObject&>(*cargo).SetTransporterPart(2);  // takes with the right claw
3ec1fca
 
3ec1fca
             Math::Vector pos = Math::Vector(1.1f, -1.0f, 1.0f);  // relative
3ec1fca
             cargo->SetPosition(pos);
3ec1fca
@@ -995,8 +995,8 @@ bool CTaskManip::TransporterTakeObject()
3ec1fca
         }
3ec1fca
         else
3ec1fca
         {
3ec1fca
-            dynamic_cast<CTransportableObject*>(cargo)->SetTransporter(m_object);
3ec1fca
-            dynamic_cast<CTransportableObject*>(cargo)->SetTransporterPart(3);  // takes with the hand
3ec1fca
+            dynamic_cast<CTransportableObject&>(*cargo).SetTransporter(m_object);
3ec1fca
+            dynamic_cast<CTransportableObject&>(*cargo).SetTransporterPart(3);  // takes with the hand
3ec1fca
 
3ec1fca
             Math::Vector pos = Math::Vector(4.7f, 0.0f, 0.0f);  // relative to the hand (lem4)
3ec1fca
             cargo->SetPosition(pos);
3ec1fca
@@ -1020,8 +1020,8 @@ bool CTaskManip::TransporterTakeObject()
3ec1fca
 
3ec1fca
         if ( m_bSubm )
3ec1fca
         {
3ec1fca
-            dynamic_cast<CTransportableObject*>(cargo)->SetTransporter(m_object);
3ec1fca
-            dynamic_cast<CTransportableObject*>(cargo)->SetTransporterPart(2);  // takes with the right claw
3ec1fca
+            dynamic_cast<CTransportableObject&>(*cargo).SetTransporter(m_object);
3ec1fca
+            dynamic_cast<CTransportableObject&>(*cargo).SetTransporterPart(2);  // takes with the right claw
3ec1fca
 
3ec1fca
             pos = Math::Vector(1.1f, -1.0f, 1.0f);  // relative
3ec1fca
             cargo->SetPosition(pos);
3ec1fca
@@ -1031,8 +1031,8 @@ bool CTaskManip::TransporterTakeObject()
3ec1fca
         }
3ec1fca
         else
3ec1fca
         {
3ec1fca
-            dynamic_cast<CTransportableObject*>(cargo)->SetTransporter(m_object);
3ec1fca
-            dynamic_cast<CTransportableObject*>(cargo)->SetTransporterPart(3);  // takes with the hand
3ec1fca
+            dynamic_cast<CTransportableObject&>(*cargo).SetTransporter(m_object);
3ec1fca
+            dynamic_cast<CTransportableObject&>(*cargo).SetTransporterPart(3);  // takes with the hand
3ec1fca
 
3ec1fca
             pos = Math::Vector(4.7f, 0.0f, 0.0f);  // relative to the hand (lem4)
3ec1fca
             cargo->SetPosition(pos);
3ec1fca
@@ -1054,8 +1054,8 @@ bool CTaskManip::TransporterTakeObject()
3ec1fca
 
3ec1fca
         m_cargoType = cargo->GetType();
3ec1fca
 
3ec1fca
-        dynamic_cast<CTransportableObject*>(cargo)->SetTransporter(m_object);
3ec1fca
-        dynamic_cast<CTransportableObject*>(cargo)->SetTransporterPart(3);  // takes with the hand
3ec1fca
+        dynamic_cast<CTransportableObject&>(*cargo).SetTransporter(m_object);
3ec1fca
+        dynamic_cast<CTransportableObject&>(*cargo).SetTransporterPart(3);  // takes with the hand
3ec1fca
 
3ec1fca
         pos = Math::Vector(4.7f, 0.0f, 0.0f);  // relative to the hand (lem4)
3ec1fca
         cargo->SetPosition(pos);
3ec1fca
@@ -1080,7 +1080,7 @@ bool CTaskManip::TransporterTakeObject()
3ec1fca
         cargo->SetRotationX(0.0f);
3ec1fca
         cargo->SetRotationZ(Math::PI/2.0f);
3ec1fca
         cargo->SetRotationY(0.0f);
3ec1fca
-        dynamic_cast<CTransportableObject*>(cargo)->SetTransporterPart(3);  // takes with the hand
3ec1fca
+        dynamic_cast<CTransportableObject&>(*cargo).SetTransporterPart(3);  // takes with the hand
3ec1fca
 
3ec1fca
         m_object->SetPower(nullptr);
3ec1fca
         m_object->SetCargo(cargo);  // takes
3ec1fca
@@ -1094,15 +1094,15 @@ bool CTaskManip::TransporterTakeObject()
3ec1fca
         if (other == nullptr)  return false;
3ec1fca
         assert(other->Implements(ObjectInterfaceType::Powered));
3ec1fca
 
3ec1fca
-        CObject* cargo = dynamic_cast<CPoweredObject*>(other)->GetPower();
3ec1fca
+        CObject* cargo = dynamic_cast<CPoweredObject&>(*other).GetPower();
3ec1fca
         if (cargo == nullptr)  return false;  // the other does not have a battery?
3ec1fca
         assert(cargo->Implements(ObjectInterfaceType::Transportable));
3ec1fca
 
3ec1fca
         m_cargoType = cargo->GetType();
3ec1fca
 
3ec1fca
-        dynamic_cast<CPoweredObject*>(other)->SetPower(nullptr);
3ec1fca
-        dynamic_cast<CTransportableObject*>(cargo)->SetTransporter(m_object);
3ec1fca
-        dynamic_cast<CTransportableObject*>(cargo)->SetTransporterPart(3);  // takes with the hand
3ec1fca
+        dynamic_cast<CPoweredObject&>(*other).SetPower(nullptr);
3ec1fca
+        dynamic_cast<CTransportableObject&>(*cargo).SetTransporter(m_object);
3ec1fca
+        dynamic_cast<CTransportableObject&>(*cargo).SetTransporterPart(3);  // takes with the hand
3ec1fca
 
3ec1fca
         pos = Math::Vector(4.7f, 0.0f, 0.0f);  // relative to the hand (lem4)
3ec1fca
         cargo->SetPosition(pos);
3ec1fca
@@ -1137,7 +1137,7 @@ bool CTaskManip::TransporterDeposeObject()
3ec1fca
         cargo->SetRotationZ(0.0f);
3ec1fca
         cargo->FloorAdjust();  // plate well on the ground
3ec1fca
 
3ec1fca
-        dynamic_cast<CTransportableObject*>(cargo)->SetTransporter(nullptr);
3ec1fca
+        dynamic_cast<CTransportableObject&>(*cargo).SetTransporter(nullptr);
3ec1fca
         m_object->SetCargo(nullptr);  // deposit
3ec1fca
     }
3ec1fca
 
3ec1fca
@@ -1157,7 +1157,7 @@ bool CTaskManip::TransporterDeposeObject()
3ec1fca
         cargo->SetRotationX(0.0f);
3ec1fca
         cargo->SetRotationZ(0.0f);
3ec1fca
 
3ec1fca
-        dynamic_cast<CTransportableObject*>(cargo)->SetTransporter(nullptr);
3ec1fca
+        dynamic_cast<CTransportableObject&>(*cargo).SetTransporter(nullptr);
3ec1fca
         m_object->SetCargo(nullptr);  // deposit
3ec1fca
     }
3ec1fca
 
3ec1fca
@@ -1172,8 +1172,8 @@ bool CTaskManip::TransporterDeposeObject()
3ec1fca
 
3ec1fca
         if (m_object->GetPower() != nullptr)  return false;
3ec1fca
 
3ec1fca
-        dynamic_cast<CTransportableObject*>(cargo)->SetTransporter(m_object);
3ec1fca
-        dynamic_cast<CTransportableObject*>(cargo)->SetTransporterPart(0);  // carried by the base
3ec1fca
+        dynamic_cast<CTransportableObject&>(*cargo).SetTransporter(m_object);
3ec1fca
+        dynamic_cast<CTransportableObject&>(*cargo).SetTransporterPart(0);  // carried by the base
3ec1fca
 
3ec1fca
         cargo->SetPosition(m_object->GetPowerPosition());
3ec1fca
         cargo->SetRotationY(0.0f);
3ec1fca
@@ -1193,7 +1193,7 @@ bool CTaskManip::TransporterDeposeObject()
3ec1fca
         if (other == nullptr)  return false;
3ec1fca
         assert(other->Implements(ObjectInterfaceType::Powered));
3ec1fca
 
3ec1fca
-        CObject* cargo = dynamic_cast<CPoweredObject*>(other)->GetPower();
3ec1fca
+        CObject* cargo = dynamic_cast<CPoweredObject&>(*other).GetPower();
3ec1fca
         if (cargo != nullptr)  return false;  // the other already has a battery?
3ec1fca
 
3ec1fca
         cargo = m_object->GetCargo();
3ec1fca
@@ -1202,14 +1202,14 @@ bool CTaskManip::TransporterDeposeObject()
3ec1fca
 
3ec1fca
         m_cargoType = cargo->GetType();
3ec1fca
 
3ec1fca
-        dynamic_cast<CPoweredObject*>(other)->SetPower(cargo);
3ec1fca
-        dynamic_cast<CTransportableObject*>(cargo)->SetTransporter(other);
3ec1fca
+        dynamic_cast<CPoweredObject&>(*other).SetPower(cargo);
3ec1fca
+        dynamic_cast<CTransportableObject&>(*cargo).SetTransporter(other);
3ec1fca
 
3ec1fca
-        cargo->SetPosition(dynamic_cast<CPoweredObject*>(other)->GetPowerPosition());
3ec1fca
+        cargo->SetPosition(dynamic_cast<CPoweredObject&>(*other).GetPowerPosition());
3ec1fca
         cargo->SetRotationY(0.0f);
3ec1fca
         cargo->SetRotationX(0.0f);
3ec1fca
         cargo->SetRotationZ(0.0f);
3ec1fca
-        dynamic_cast<CTransportableObject*>(cargo)->SetTransporterPart(0);  // carried by the base
3ec1fca
+        dynamic_cast<CTransportableObject&>(*cargo).SetTransporterPart(0);  // carried by the base
3ec1fca
 
3ec1fca
         m_object->SetCargo(nullptr);  // deposit
3ec1fca
     }
3ec1fca
diff --git a/src/object/task/taskrecover.cpp b/src/object/task/taskrecover.cpp
3ec1fca
index 872632e..5f2cda5 100644
3ec1fca
--- a/src/object/task/taskrecover.cpp
3ec1fca
+++ b/src/object/task/taskrecover.cpp
3ec1fca
@@ -194,7 +194,7 @@ Error CTaskRecover::Start()
3ec1fca
     CObject* power = dynamic_cast<CPoweredObject*>(m_object)->GetPower();
3ec1fca
     if (power == nullptr || !power->Implements(ObjectInterfaceType::PowerContainer))  return ERR_RECOVER_ENERGY;
3ec1fca
 
3ec1fca
-    float energy = dynamic_cast<CPowerContainerObject*>(power)->GetEnergy();
3ec1fca
+    float energy = dynamic_cast<CPowerContainerObject&>(*power).GetEnergy();
3ec1fca
     if ( energy < ENERGY_RECOVER+0.05f )  return ERR_RECOVER_ENERGY;
3ec1fca
 
3ec1fca
     Math::Matrix* mat = m_object->GetWorldMatrix(0);
3ec1fca
diff --git a/src/object/task/taskshield.cpp b/src/object/task/taskshield.cpp
3ec1fca
index 5408941..948163a 100644
3ec1fca
--- a/src/object/task/taskshield.cpp
3ec1fca
+++ b/src/object/task/taskshield.cpp
3ec1fca
@@ -309,7 +309,7 @@ Error CTaskShield::Start(TaskShieldMode mode, float delay)
3ec1fca
 
3ec1fca
     CObject* power = m_object->GetPower();
3ec1fca
     if (power == nullptr || !power->Implements(ObjectInterfaceType::PowerContainer))  return ERR_SHIELD_ENERGY;
3ec1fca
-    float energy = dynamic_cast<CPowerContainerObject*>(power)->GetEnergy();
3ec1fca
+    float energy = dynamic_cast<CPowerContainerObject&>(*power).GetEnergy();
3ec1fca
     if ( energy == 0.0f )  return ERR_SHIELD_ENERGY;
3ec1fca
 
3ec1fca
     Math::Matrix* mat = m_object->GetWorldMatrix(0);
3ec1fca
diff --git a/src/object/task/taskspiderexplo.cpp b/src/object/task/taskspiderexplo.cpp
3ec1fca
index 03abddb..b988922 100644
3ec1fca
--- a/src/object/task/taskspiderexplo.cpp
3ec1fca
+++ b/src/object/task/taskspiderexplo.cpp
3ec1fca
@@ -57,7 +57,7 @@ bool CTaskSpiderExplo::EventProcess(const Event &event)
3ec1fca
     if ( event.type != EVENT_FRAME )  return true;
3ec1fca
 
3ec1fca
     // Momentarily stationary object (ant on the back)?
3ec1fca
-    if ( dynamic_cast<CBaseAlien*>(m_object)->GetFixed() )
3ec1fca
+    if ( dynamic_cast<CBaseAlien&>(*m_object).GetFixed() )
3ec1fca
     {
3ec1fca
         m_bError = true;
3ec1fca
         return true;
3ec1fca
diff --git a/src/object/task/tasktake.cpp b/src/object/task/tasktake.cpp
3ec1fca
index c67a7e5..13bd7cd 100644
3ec1fca
--- a/src/object/task/tasktake.cpp
3ec1fca
+++ b/src/object/task/tasktake.cpp
3ec1fca
@@ -131,9 +131,9 @@ Error CTaskTake::Start()
3ec1fca
         CObject* other = SearchFriendObject(oAngle, 1.5f, Math::PI*0.50f);
3ec1fca
         if (other != nullptr) assert(other->Implements(ObjectInterfaceType::Powered));
3ec1fca
 
3ec1fca
-        if (other != nullptr && dynamic_cast<CPoweredObject*>(other)->GetPower() != nullptr)
3ec1fca
+        if (other != nullptr && dynamic_cast<CPoweredObject&>(*other).GetPower() != nullptr)
3ec1fca
         {
3ec1fca
-            CObject* power = dynamic_cast<CPoweredObject*>(other)->GetPower();
3ec1fca
+            CObject* power = dynamic_cast<CPoweredObject&>(*other).GetPower();
3ec1fca
             type = power->GetType();
3ec1fca
             if ( type == OBJECT_URANIUM )  return ERR_MANIP_RADIO;
3ec1fca
             assert(power->Implements(ObjectInterfaceType::Transportable));
3ec1fca
@@ -161,7 +161,7 @@ Error CTaskTake::Start()
3ec1fca
         CObject* other = SearchFriendObject(oAngle, 1.5f, Math::PI*0.50f);
3ec1fca
         if (other != nullptr) assert(other->Implements(ObjectInterfaceType::Powered));
3ec1fca
 
3ec1fca
-        if (other != nullptr && dynamic_cast<CPoweredObject*>(other)->GetPower() == nullptr )
3ec1fca
+        if (other != nullptr && dynamic_cast<CPoweredObject&>(*other).GetPower() == nullptr )
3ec1fca
         {
3ec1fca
 //?         m_camera->StartCentering(m_object, Math::PI*0.3f, -Math::PI*0.1f, 0.0f, 0.8f);
3ec1fca
             m_arm = TTA_FRIEND;
3ec1fca
@@ -384,7 +384,7 @@ CObject* CTaskTake::SearchFriendObject(float &angle,
3ec1fca
 
3ec1fca
         assert(pObj->Implements(ObjectInterfaceType::Powered));
3ec1fca
 
3ec1fca
-        CObject* power = dynamic_cast<CPoweredObject*>(pObj)->GetPower();
3ec1fca
+        CObject* power = dynamic_cast<CPoweredObject&>(*pObj).GetPower();
3ec1fca
         if (power != nullptr)
3ec1fca
         {
3ec1fca
             if ( power->GetLock() )  continue;
3ec1fca
@@ -392,7 +392,7 @@ CObject* CTaskTake::SearchFriendObject(float &angle,
3ec1fca
         }
3ec1fca
 
3ec1fca
         Math::Matrix* mat = pObj->GetWorldMatrix(0);
3ec1fca
-        Math::Vector oPos = Math::Transform(*mat, dynamic_cast<CPoweredObject*>(pObj)->GetPowerPosition());
3ec1fca
+        Math::Vector oPos = Math::Transform(*mat, dynamic_cast<CPoweredObject&>(*pObj).GetPowerPosition());
3ec1fca
 
3ec1fca
         float distance = fabs(Math::Distance(oPos, iPos) - (iRad+1.0f));
3ec1fca
         if ( distance <= dLimit )
3ec1fca
@@ -400,7 +400,7 @@ CObject* CTaskTake::SearchFriendObject(float &angle,
3ec1fca
             angle = Math::RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z);  // CW !
3ec1fca
             if ( Math::TestAngle(angle, iAngle-aLimit, iAngle+aLimit) )
3ec1fca
             {
3ec1fca
-                Math::Vector powerPos = dynamic_cast<CPoweredObject*>(pObj)->GetPowerPosition();
3ec1fca
+                Math::Vector powerPos = dynamic_cast<CPoweredObject&>(*pObj).GetPowerPosition();
3ec1fca
                 m_height = powerPos.y;
3ec1fca
                 return pObj;
3ec1fca
             }
3ec1fca
@@ -424,8 +424,8 @@ bool CTaskTake::TransporterTakeObject()
3ec1fca
 
3ec1fca
         m_cargoType = cargo->GetType();
3ec1fca
 
3ec1fca
-        dynamic_cast<CTransportableObject*>(cargo)->SetTransporter(m_object);
3ec1fca
-        dynamic_cast<CTransportableObject*>(cargo)->SetTransporterPart(4);  // takes with the hand
3ec1fca
+        dynamic_cast<CTransportableObject&>(*cargo).SetTransporter(m_object);
3ec1fca
+        dynamic_cast<CTransportableObject&>(*cargo).SetTransporterPart(4);  // takes with the hand
3ec1fca
 
3ec1fca
 //?     cargo->SetPosition(Math::Vector(2.2f, -1.0f, 1.1f));
3ec1fca
         cargo->SetPosition(Math::Vector(1.7f, -0.5f, 1.1f));
3ec1fca
@@ -443,15 +443,15 @@ bool CTaskTake::TransporterTakeObject()
3ec1fca
         if (other == nullptr)  return false;
3ec1fca
         assert(other->Implements(ObjectInterfaceType::Powered));
3ec1fca
 
3ec1fca
-        CObject* cargo = dynamic_cast<CPoweredObject*>(other)->GetPower();
3ec1fca
+        CObject* cargo = dynamic_cast<CPoweredObject&>(*other).GetPower();
3ec1fca
         if (cargo == nullptr)  return false;  // the other does not have a battery?
3ec1fca
         assert(cargo->Implements(ObjectInterfaceType::Transportable));
3ec1fca
 
3ec1fca
         m_cargoType = cargo->GetType();
3ec1fca
 
3ec1fca
-        dynamic_cast<CPoweredObject*>(other)->SetPower(nullptr);
3ec1fca
-        dynamic_cast<CTransportableObject*>(cargo)->SetTransporter(m_object);
3ec1fca
-        dynamic_cast<CTransportableObject*>(cargo)->SetTransporterPart(4);  // takes with the hand
3ec1fca
+        dynamic_cast<CPoweredObject&>(*other).SetPower(nullptr);
3ec1fca
+        dynamic_cast<CTransportableObject&>(*cargo).SetTransporter(m_object);
3ec1fca
+        dynamic_cast<CTransportableObject&>(*cargo).SetTransporterPart(4);  // takes with the hand
3ec1fca
 
3ec1fca
 //?     cargo->SetPosition(Math::Vector(2.2f, -1.0f, 1.1f));
3ec1fca
         cargo->SetPosition(Math::Vector(1.7f, -0.5f, 1.1f));
3ec1fca
@@ -486,7 +486,7 @@ bool CTaskTake::TransporterDeposeObject()
3ec1fca
         cargo->SetRotationZ(0.0f);
3ec1fca
         cargo->FloorAdjust();  // plate well on the ground
3ec1fca
 
3ec1fca
-        dynamic_cast<CTransportableObject*>(cargo)->SetTransporter(nullptr);
3ec1fca
+        dynamic_cast<CTransportableObject&>(*cargo).SetTransporter(nullptr);
3ec1fca
         m_object->SetCargo(nullptr);  // deposit
3ec1fca
     }
3ec1fca
 
3ec1fca
@@ -497,7 +497,7 @@ bool CTaskTake::TransporterDeposeObject()
3ec1fca
         if (other == nullptr)  return false;
3ec1fca
         assert(other->Implements(ObjectInterfaceType::Powered));
3ec1fca
 
3ec1fca
-        CObject* cargo = dynamic_cast<CPoweredObject*>(other)->GetPower();
3ec1fca
+        CObject* cargo = dynamic_cast<CPoweredObject&>(*other).GetPower();
3ec1fca
         if (cargo != nullptr)  return false;  // the other already has a battery?
3ec1fca
 
3ec1fca
         cargo = m_object->GetCargo();
3ec1fca
@@ -505,14 +505,14 @@ bool CTaskTake::TransporterDeposeObject()
3ec1fca
         assert(cargo->Implements(ObjectInterfaceType::Transportable));
3ec1fca
         m_cargoType = cargo->GetType();
3ec1fca
 
3ec1fca
-        dynamic_cast<CPoweredObject*>(other)->SetPower(cargo);
3ec1fca
-        dynamic_cast<CTransportableObject*>(cargo)->SetTransporter(other);
3ec1fca
+        dynamic_cast<CPoweredObject&>(*other).SetPower(cargo);
3ec1fca
+        dynamic_cast<CTransportableObject&>(*cargo).SetTransporter(other);
3ec1fca
 
3ec1fca
-        cargo->SetPosition(dynamic_cast<CPoweredObject*>(other)->GetPowerPosition());
3ec1fca
+        cargo->SetPosition(dynamic_cast<CPoweredObject&>(*other).GetPowerPosition());
3ec1fca
         cargo->SetRotationY(0.0f);
3ec1fca
         cargo->SetRotationX(0.0f);
3ec1fca
         cargo->SetRotationZ(0.0f);
3ec1fca
-        dynamic_cast<CTransportableObject*>(cargo)->SetTransporterPart(0);  // carried by the base
3ec1fca
+        dynamic_cast<CTransportableObject&>(*cargo).SetTransporterPart(0);  // carried by the base
3ec1fca
 
3ec1fca
         m_object->SetCargo(nullptr);  // deposit
3ec1fca
     }
3ec1fca
diff --git a/src/object/task/taskterraform.cpp b/src/object/task/taskterraform.cpp
3ec1fca
index 6718bb7..8bb25d6 100644
3ec1fca
--- a/src/object/task/taskterraform.cpp
3ec1fca
+++ b/src/object/task/taskterraform.cpp
3ec1fca
@@ -215,7 +215,7 @@ Error CTaskTerraform::Start()
3ec1fca
 
3ec1fca
     power = m_object->GetPower();
3ec1fca
     if ( power == nullptr || !power->Implements(ObjectInterfaceType::PowerContainer) )  return ERR_TERRA_ENERGY;
3ec1fca
-    energy = dynamic_cast<CPowerContainerObject*>(power)->GetEnergy();
3ec1fca
+    energy = dynamic_cast<CPowerContainerObject&>(*power).GetEnergy();
3ec1fca
     if ( energy < ENERGY_TERRA+0.05f )  return ERR_TERRA_ENERGY;
3ec1fca
 
3ec1fca
     speed = m_physics->GetMotorSpeed();
3ec1fca
@@ -459,7 +459,7 @@ bool CTaskTerraform::Terraform()
3ec1fca
                      type == OBJECT_PARA) // Buildings?
3ec1fca
             {
3ec1fca
                 if ( dist > 15.0f )  continue;
3ec1fca
-                dynamic_cast<CDamageableObject*>(pObj)->DamageObject(DamageType::Explosive, 0.2f);
3ec1fca
+                dynamic_cast<CDamageableObject&>(*pObj).DamageObject(DamageType::Explosive, 0.2f);
3ec1fca
             }
3ec1fca
             else // Other?
3ec1fca
             {
3ec1fca
@@ -470,7 +470,7 @@ bool CTaskTerraform::Terraform()
3ec1fca
         else
3ec1fca
         {
3ec1fca
             if ( !pObj->Implements(ObjectInterfaceType::Movable) )  continue;
3ec1fca
-            motion = dynamic_cast<CMovableObject*>(pObj)->GetMotion();
3ec1fca
+            motion = dynamic_cast<CMovableObject&>(*pObj).GetMotion();
3ec1fca
 
3ec1fca
             dist = Math::Distance(m_terraPos, pObj->GetPosition());
3ec1fca
             if ( dist > ACTION_RADIUS )  continue;
3ec1fca
@@ -478,13 +478,13 @@ bool CTaskTerraform::Terraform()
3ec1fca
             if ( type == OBJECT_ANT || type == OBJECT_SPIDER )
3ec1fca
             {
3ec1fca
                 assert(pObj->Implements(ObjectInterfaceType::TaskExecutor));
3ec1fca
-                dynamic_cast<CTaskExecutorObject*>(pObj)->StopForegroundTask();
3ec1fca
+                dynamic_cast<CTaskExecutorObject&>(*pObj).StopForegroundTask();
3ec1fca
 
3ec1fca
                 int actionType = -1;
3ec1fca
                 if (type == OBJECT_ANT)    actionType = MAS_BACK1;
3ec1fca
                 if (type == OBJECT_SPIDER) actionType = MSS_BACK1;
3ec1fca
                 motion->SetAction(actionType, 0.8f+Math::Rand()*0.3f);
3ec1fca
-                dynamic_cast<CBaseAlien*>(pObj)->SetFixed(true);  // not moving
3ec1fca
+                dynamic_cast<CBaseAlien&>(*pObj).SetFixed(true);  // not moving
3ec1fca
 
3ec1fca
                 if ( dist > 5.0f ) continue;
3ec1fca
                 m_engine->GetPyroManager()->Create(Gfx::PT_EXPLOO, pObj);
3ec1fca
diff --git a/src/physics/physics.cpp b/src/physics/physics.cpp
3ec1fca
index b97742c..112b982 100644
3ec1fca
--- a/src/physics/physics.cpp
3ec1fca
+++ b/src/physics/physics.cpp
3ec1fca
@@ -804,7 +804,7 @@ void CPhysics::MotorUpdate(float aTime, float rTime)
3ec1fca
 
3ec1fca
     if (m_object->Implements(ObjectInterfaceType::Powered))
3ec1fca
     {
3ec1fca
-        power = dynamic_cast<CPowerContainerObject*>(dynamic_cast<CPoweredObject*>(m_object)->GetPower());  // searches for the object battery uses
3ec1fca
+        power = dynamic_cast<CPowerContainerObject*>(dynamic_cast<CPoweredObject&>(*m_object).GetPower());  // searches for the object battery uses
3ec1fca
         if ( GetObjectEnergy(m_object) == 0.0f )  // no battery or flat?
3ec1fca
         {
3ec1fca
             motorSpeed.x =  0.0f;
3ec1fca
@@ -822,7 +822,7 @@ void CPhysics::MotorUpdate(float aTime, float rTime)
3ec1fca
         }
3ec1fca
     }
3ec1fca
 
3ec1fca
-    if ( m_object->GetType() == OBJECT_HUMAN && dynamic_cast<CDestroyableObject*>(m_object)->GetDying() == DeathType::Dead )  // dead man?
3ec1fca
+    if ( m_object->GetType() == OBJECT_HUMAN && dynamic_cast<CDestroyableObject&>(*m_object).GetDying() == DeathType::Dead )  // dead man?
3ec1fca
     {
3ec1fca
         motorSpeed.x = 0.0f;
3ec1fca
         motorSpeed.z = 0.0f;
3ec1fca
@@ -852,7 +852,7 @@ void CPhysics::MotorUpdate(float aTime, float rTime)
3ec1fca
     }
3ec1fca
 
3ec1fca
     if ( m_object->Implements(ObjectInterfaceType::JetFlying) &&
3ec1fca
-         dynamic_cast<CJetFlyingObject*>(m_object)->GetRange() > 0.0f )  // limited flight range?
3ec1fca
+         dynamic_cast<CJetFlyingObject&>(*m_object).GetRange() > 0.0f )  // limited flight range?
3ec1fca
     {
3ec1fca
         CJetFlyingObject* jetFlying = dynamic_cast<CJetFlyingObject*>(m_object);
3ec1fca
         if ( m_bLand || m_bSwim || m_bObstacle )  // on the ground or in the water?
3ec1fca
@@ -960,7 +960,7 @@ void CPhysics::MotorUpdate(float aTime, float rTime)
3ec1fca
         bool reactorCool = true;
3ec1fca
         if ( m_object->Implements(ObjectInterfaceType::JetFlying) )
3ec1fca
         {
3ec1fca
-            reactorCool = dynamic_cast<CJetFlyingObject*>(m_object)->GetReactorRange() > 0.1f;
3ec1fca
+            reactorCool = dynamic_cast<CJetFlyingObject&>(*m_object).GetReactorRange() > 0.1f;
3ec1fca
         }
3ec1fca
         if ( motorSpeed.y > 0.0f && reactorCool && pos.y < h )
3ec1fca
         {
3ec1fca
@@ -1459,7 +1459,7 @@ bool CPhysics::EventFrame(const Event &event)
3ec1fca
     iAngle = angle = m_object->GetRotation();
3ec1fca
 
3ec1fca
     // Accelerate is the descent, brake is the ascent.
3ec1fca
-    if ( m_bFreeze || (m_object->Implements(ObjectInterfaceType::Destroyable) && dynamic_cast<CDestroyableObject*>(m_object)->IsDying()) )
3ec1fca
+    if ( m_bFreeze || (m_object->Implements(ObjectInterfaceType::Destroyable) && dynamic_cast<CDestroyableObject&>(*m_object).IsDying()) )
3ec1fca
     {
3ec1fca
         m_linMotion.terrainSpeed.x = 0.0f;
3ec1fca
         m_linMotion.terrainSpeed.z = 0.0f;
3ec1fca
@@ -1614,8 +1614,8 @@ void CPhysics::SoundMotor(float rTime)
3ec1fca
     else if ( type == OBJECT_ANT )
3ec1fca
     {
3ec1fca
         assert(m_object->Implements(ObjectInterfaceType::Destroyable));
3ec1fca
-        if ( dynamic_cast<CDestroyableObject*>(m_object)->GetDying() == DeathType::Burning ||
3ec1fca
-             dynamic_cast<CBaseAlien*>(m_object)->GetFixed() )
3ec1fca
+        if ( dynamic_cast<CDestroyableObject&>(*m_object).GetDying() == DeathType::Burning ||
3ec1fca
+             dynamic_cast<CBaseAlien&>(*m_object).GetFixed() )
3ec1fca
         {
3ec1fca
             if ( m_lastSoundInsect <= 0.0f )
3ec1fca
             {
3ec1fca
@@ -1678,8 +1678,8 @@ void CPhysics::SoundMotor(float rTime)
3ec1fca
     else if ( type == OBJECT_SPIDER )
3ec1fca
     {
3ec1fca
         assert(m_object->Implements(ObjectInterfaceType::Destroyable));
3ec1fca
-        if ( dynamic_cast<CDestroyableObject*>(m_object)->GetDying() == DeathType::Burning ||
3ec1fca
-             dynamic_cast<CBaseAlien*>(m_object)->GetFixed() )
3ec1fca
+        if ( dynamic_cast<CDestroyableObject&>(*m_object).GetDying() == DeathType::Burning ||
3ec1fca
+             dynamic_cast<CBaseAlien&>(*m_object).GetFixed() )
3ec1fca
         {
3ec1fca
             if ( m_lastSoundInsect <= 0.0f )
3ec1fca
             {
3ec1fca
@@ -2501,7 +2501,7 @@ int CPhysics::ObjectAdapt(const Math::Vector &pos, const Math::Vector &angle)
3ec1fca
     {
3ec1fca
         if ( pObj == m_object )  continue;  // yourself?
3ec1fca
         if (IsObjectBeingTransported(pObj))  continue;
3ec1fca
-        if ( pObj->Implements(ObjectInterfaceType::Destroyable) && dynamic_cast<CDestroyableObject*>(pObj)->IsDying() )  continue;  // is burning or exploding?
3ec1fca
+        if ( pObj->Implements(ObjectInterfaceType::Destroyable) && dynamic_cast<CDestroyableObject&>(*pObj).IsDying() )  continue;  // is burning or exploding?
3ec1fca
 
3ec1fca
         oType = pObj->GetType();
3ec1fca
         if ( oType == OBJECT_TOTO            )  continue;
3ec1fca
@@ -2603,7 +2603,7 @@ int CPhysics::ObjectAdapt(const Math::Vector &pos, const Math::Vector &angle)
3ec1fca
 
3ec1fca
                     CPhysics* ph = nullptr;
3ec1fca
                     if (pObj->Implements(ObjectInterfaceType::Movable))
3ec1fca
-                        ph = dynamic_cast<CMovableObject*>(pObj)->GetPhysics();
3ec1fca
+                        ph = dynamic_cast<CMovableObject&>(*pObj).GetPhysics();
3ec1fca
                     if ( ph != nullptr )
3ec1fca
                     {
3ec1fca
                         oAngle = pObj->GetRotation();
3ec1fca
@@ -2703,7 +2703,7 @@ bool CPhysics::ExploOther(ObjectType iType,
3ec1fca
         if ( force > destructionForce && destructionForce >= 0.0f )
3ec1fca
         {
3ec1fca
             // TODO: implement "killer"?
3ec1fca
-            dynamic_cast<CDamageableObject*>(pObj)->DamageObject(damageType);
3ec1fca
+            dynamic_cast<CDamageableObject&>(*pObj).DamageObject(damageType);
3ec1fca
         }
3ec1fca
     }
3ec1fca
 
3ec1fca
@@ -2729,7 +2729,7 @@ bool CPhysics::ExploOther(ObjectType iType,
3ec1fca
         {
3ec1fca
             assert(pObj->Implements(ObjectInterfaceType::Damageable));
3ec1fca
             // TODO: implement "killer"?
3ec1fca
-            dynamic_cast<CDamageableObject*>(pObj)->DamageObject(DamageType::Collision, force/400.0f);
3ec1fca
+            dynamic_cast<CDamageableObject&>(*pObj).DamageObject(DamageType::Collision, force/400.0f);
3ec1fca
         }
3ec1fca
 
3ec1fca
         if (oType == OBJECT_MOBILEwa ||
3ec1fca
@@ -2760,7 +2760,7 @@ bool CPhysics::ExploOther(ObjectType iType,
3ec1fca
         {
3ec1fca
             assert(pObj->Implements(ObjectInterfaceType::Damageable));
3ec1fca
             // TODO: implement "killer"?
3ec1fca
-            dynamic_cast<CDamageableObject*>(pObj)->DamageObject(DamageType::Collision, force/200.0f);
3ec1fca
+            dynamic_cast<CDamageableObject&>(*pObj).DamageObject(DamageType::Collision, force/200.0f);
3ec1fca
         }
3ec1fca
     }
3ec1fca
 
3ec1fca
@@ -2786,7 +2786,7 @@ int CPhysics::ExploHimself(ObjectType iType, ObjectType oType, float force)
3ec1fca
     if ( force > destructionForce && destructionForce >= 0.0f )
3ec1fca
     {
3ec1fca
         // TODO: implement "killer"?
3ec1fca
-        dynamic_cast<CDamageableObject*>(m_object)->DamageObject(DamageType::Explosive);
3ec1fca
+        dynamic_cast<CDamageableObject&>(*m_object).DamageObject(DamageType::Explosive);
3ec1fca
         return 2;
3ec1fca
     }
3ec1fca
 
3ec1fca
@@ -2867,7 +2867,7 @@ int CPhysics::ExploHimself(ObjectType iType, ObjectType oType, float force)
3ec1fca
             }
3ec1fca
 
3ec1fca
             // TODO: implement "killer"?
3ec1fca
-            if ( dynamic_cast<CDamageableObject*>(m_object)->DamageObject(DamageType::Collision, force) )  return 2;
3ec1fca
+            if ( dynamic_cast<CDamageableObject&>(*m_object).DamageObject(DamageType::Collision, force) )  return 2;
3ec1fca
         }
3ec1fca
     }
3ec1fca
 
3ec1fca
@@ -2919,9 +2919,9 @@ void CPhysics::PowerParticle(float factor, bool bBreak)
3ec1fca
     bCarryPower = false;
3ec1fca
     if (m_object->Implements(ObjectInterfaceType::Carrier))
3ec1fca
     {
3ec1fca
-        CObject* cargo = dynamic_cast<CCarrierObject*>(m_object)->GetCargo();
3ec1fca
+        CObject* cargo = dynamic_cast<CCarrierObject&>(*m_object).GetCargo();
3ec1fca
         if ( cargo != nullptr && cargo->Implements(ObjectInterfaceType::PowerContainer) &&
3ec1fca
-            dynamic_cast<CPowerContainerObject*>(cargo)->IsRechargeable() &&
3ec1fca
+            dynamic_cast<CPowerContainerObject&>(*cargo).IsRechargeable() &&
3ec1fca
             m_object->GetPartRotationZ(1) == ARM_STOCK_ANGLE1 )
3ec1fca
         {
3ec1fca
             bCarryPower = true;  // carries a battery
3ec1fca
@@ -3209,7 +3209,7 @@ void CPhysics::MotorParticle(float aTime, float rTime)
3ec1fca
         }
3ec1fca
         else    // in flight?
3ec1fca
         {
3ec1fca
-            if ( !m_bMotor || (m_object->Implements(ObjectInterfaceType::JetFlying) && dynamic_cast<CJetFlyingObject*>(m_object)->GetReactorRange() == 0.0f) )  return;
3ec1fca
+            if ( !m_bMotor || (m_object->Implements(ObjectInterfaceType::JetFlying) && dynamic_cast<CJetFlyingObject&>(*m_object).GetReactorRange() == 0.0f) )  return;
3ec1fca
 
3ec1fca
             if ( m_reactorTemperature < 1.0f )  // not too hot?
3ec1fca
             {
3ec1fca
@@ -3339,7 +3339,7 @@ void CPhysics::MotorParticle(float aTime, float rTime)
3ec1fca
         }
3ec1fca
         else    // in flight?
3ec1fca
         {
3ec1fca
-            if ( !m_bMotor || (m_object->Implements(ObjectInterfaceType::JetFlying) && dynamic_cast<CJetFlyingObject*>(m_object)->GetReactorRange() == 0.0f) )  return;
3ec1fca
+            if ( !m_bMotor || (m_object->Implements(ObjectInterfaceType::JetFlying) && dynamic_cast<CJetFlyingObject&>(*m_object).GetReactorRange() == 0.0f) )  return;
3ec1fca
 
3ec1fca
             if ( aTime-m_lastMotorParticle < m_engine->ParticleAdapt(0.02f) )  return;
3ec1fca
             m_lastMotorParticle = aTime;
3ec1fca
@@ -3400,7 +3400,7 @@ void CPhysics::MotorParticle(float aTime, float rTime)
3ec1fca
 
3ec1fca
     if ( (type == OBJECT_HUMAN || type == OBJECT_TECH) && m_bSwim )
3ec1fca
     {
3ec1fca
-        if ( !m_object->Implements(ObjectInterfaceType::Destroyable) || dynamic_cast<CDestroyableObject*>(m_object)->GetDying() != DeathType::Dead )
3ec1fca
+        if ( !m_object->Implements(ObjectInterfaceType::Destroyable) || dynamic_cast<CDestroyableObject&>(*m_object).GetDying() != DeathType::Dead )
3ec1fca
         {
3ec1fca
             h = Math::Mod(aTime, 5.0f);
3ec1fca
             if ( h < 3.5f && ( h < 1.5f || h > 1.6f ) )  return;
3ec1fca
@@ -3722,7 +3722,7 @@ Error CPhysics::GetError()
3ec1fca
 
3ec1fca
     if (m_object->Implements(ObjectInterfaceType::ProgramStorage))
3ec1fca
     {
3ec1fca
-        if ( dynamic_cast<CProgramStorageObject*>(m_object)->GetActiveVirus() )
3ec1fca
+        if ( dynamic_cast<CProgramStorageObject&>(*m_object).GetActiveVirus() )
3ec1fca
         {
3ec1fca
             return ERR_VEH_VIRUS;
3ec1fca
         }
3ec1fca
@@ -3730,14 +3730,14 @@ Error CPhysics::GetError()
3ec1fca
 
3ec1fca
     if (m_object->Implements(ObjectInterfaceType::Powered))
3ec1fca
     {
3ec1fca
-        CObject* power = dynamic_cast<CPoweredObject*>(m_object)->GetPower();  // searches for the object battery used
3ec1fca
+        CObject* power = dynamic_cast<CPoweredObject&>(*m_object).GetPower();  // searches for the object battery used
3ec1fca
         if (power == nullptr || !power->Implements(ObjectInterfaceType::PowerContainer))
3ec1fca
         {
3ec1fca
             return ERR_VEH_POWER;
3ec1fca
         }
3ec1fca
         else
3ec1fca
         {
3ec1fca
-            if ( dynamic_cast<CPowerContainerObject*>(power)->GetEnergy() == 0.0f )  return ERR_VEH_ENERGY;
3ec1fca
+            if ( dynamic_cast<CPowerContainerObject&>(*power).GetEnergy() == 0.0f )  return ERR_VEH_ENERGY;
3ec1fca
         }
3ec1fca
     }
3ec1fca
 
3ec1fca
diff --git a/src/script/scriptfunc.cpp b/src/script/scriptfunc.cpp
3ec1fca
index 0816cce..7bec6b5 100644
3ec1fca
--- a/src/script/scriptfunc.cpp
3ec1fca
+++ b/src/script/scriptfunc.cpp
3ec1fca
@@ -657,7 +657,7 @@ bool CScriptFunctions::rDelete(CBotVar* var, CBotVar* result, int& exception, vo
3ec1fca
     }
3ec1fca
 
3ec1fca
     CObject* obj = CObjectManager::GetInstancePointer()->GetObjectById(rank);
3ec1fca
-    if ( obj == nullptr || (obj->Implements(ObjectInterfaceType::Old) && dynamic_cast<COldObject*>(obj)->IsDying()) )
3ec1fca
+    if ( obj == nullptr || (obj->Implements(ObjectInterfaceType::Old) && dynamic_cast<COldObject&>(*obj).IsDying()) )
3ec1fca
     {
3ec1fca
         return true;
3ec1fca
     }
3ec1fca
@@ -665,7 +665,7 @@ bool CScriptFunctions::rDelete(CBotVar* var, CBotVar* result, int& exception, vo
3ec1fca
     {
3ec1fca
         if ( exploType != DestructionType::NoEffect && obj->Implements(ObjectInterfaceType::Destroyable) )
3ec1fca
         {
3ec1fca
-            dynamic_cast<CDestroyableObject*>(obj)->DestroyObject(static_cast<DestructionType>(exploType));
3ec1fca
+            dynamic_cast<CDestroyableObject&>(*obj).DestroyObject(static_cast<DestructionType>(exploType));
3ec1fca
         }
3ec1fca
         else
3ec1fca
         {
3ec1fca
@@ -1434,7 +1434,7 @@ bool CScriptFunctions::rProduce(CBotVar* var, CBotVar* result, int& exception, v
3ec1fca
         CObjectManager::GetInstancePointer()->CreateObject(pos, angle, OBJECT_EGG);
3ec1fca
         if (object->Implements(ObjectInterfaceType::Programmable))
3ec1fca
         {
3ec1fca
-            dynamic_cast<CProgrammableObject*>(object)->SetActivity(false);
3ec1fca
+            dynamic_cast<CProgrammableObject&>(*object).SetActivity(false);
3ec1fca
         }
3ec1fca
     }
3ec1fca
     else
3ec1fca
@@ -1452,7 +1452,7 @@ bool CScriptFunctions::rProduce(CBotVar* var, CBotVar* result, int& exception, v
3ec1fca
         if (type == OBJECT_MOBILEdr)
3ec1fca
         {
3ec1fca
             assert(object->Implements(ObjectInterfaceType::Old)); // TODO: temporary hack
3ec1fca
-            dynamic_cast<COldObject*>(object)->SetManual(true);
3ec1fca
+            dynamic_cast<COldObject&>(*object).SetManual(true);
3ec1fca
         }
3ec1fca
         script->m_main->CreateShortcuts();
3ec1fca
     }
3ec1fca
@@ -1467,7 +1467,7 @@ bool CScriptFunctions::rProduce(CBotVar* var, CBotVar* result, int& exception, v
3ec1fca
             programStorage->ReadProgram(program, name2.c_str());
3ec1fca
             program->readOnly = true;
3ec1fca
             program->filename = name;
3ec1fca
-            dynamic_cast<CProgrammableObject*>(object)->RunProgram(program);
3ec1fca
+            dynamic_cast<CProgrammableObject&>(*object).RunProgram(program);
3ec1fca
         }
3ec1fca
     }
3ec1fca
 
3ec1fca
@@ -2073,7 +2073,7 @@ bool CScriptFunctions::rReceive(CBotVar* var, CBotVar* result, int& exception, v
3ec1fca
             return true;
3ec1fca
         }
3ec1fca
 
3ec1fca
-        CExchangePost* exchangePost = dynamic_cast<CTaskInfo*>(script->m_taskExecutor->GetForegroundTask())->FindExchangePost(power);
3ec1fca
+        CExchangePost* exchangePost = dynamic_cast<CTaskInfo&>(*script->m_taskExecutor->GetForegroundTask()).FindExchangePost(power);
3ec1fca
         script->m_returnValue = exchangePost->GetInfoValue(p);
3ec1fca
     }
3ec1fca
     if ( !WaitForForegroundTask(script, result, exception) )  return false;  // not finished
3ec1fca
@@ -2358,7 +2358,7 @@ bool CScriptFunctions::rShield(CBotVar* var, CBotVar* result, int& exception, vo
3ec1fca
         }
3ec1fca
         else    // up ?
3ec1fca
         {
3ec1fca
-            dynamic_cast<CShielder*>(pThis)->SetShieldRadius(radius);
3ec1fca
+            dynamic_cast<CShielder&>(*pThis).SetShieldRadius(radius);
3ec1fca
             err = script->m_taskExecutor->StartTaskShield(TSM_UP, 1000.0f);
3ec1fca
             if ( err != ERR_OK )
3ec1fca
             {
3ec1fca
@@ -2376,7 +2376,7 @@ bool CScriptFunctions::rShield(CBotVar* var, CBotVar* result, int& exception, vo
3ec1fca
         else    // up?
3ec1fca
         {
3ec1fca
             //?         result->SetValInt(1);  // shows the error
3ec1fca
-            dynamic_cast<CShielder*>(pThis)->SetShieldRadius(radius);
3ec1fca
+            dynamic_cast<CShielder&>(*pThis).SetShieldRadius(radius);
3ec1fca
             script->m_taskExecutor->StartTaskShield(TSM_UPDATE, 0.0f);
3ec1fca
         }
3ec1fca
     }
3ec1fca
@@ -2550,7 +2550,7 @@ bool CScriptFunctions::rMotor(CBotVar* var, CBotVar* result, int& exception, voi