From 1bb1eb7b8790d52fea2296b06c1d46730946fc53 Mon Sep 17 00:00:00 2001 From: Zaba999 Date: Tue, 11 Sep 2012 23:11:34 +0200 Subject: half of task compile. --- src/object/task/taskadvance.cpp | 19 +- src/object/task/taskbuild.cpp | 210 +++++++++---------- src/object/task/taskbuild.h | 36 ++-- src/object/task/taskfire.cpp | 77 ++++--- src/object/task/taskfire.h | 2 +- src/object/task/taskfireant.cpp | 35 ++-- src/object/task/taskfireant.h | 2 +- src/object/task/taskflag.cpp | 80 ++++--- src/object/task/taskgoto.cpp | 452 +++++++++++++++------------------------- src/object/task/taskgungoal.cpp | 19 +- src/object/task/taskinfo.cpp | 55 +++-- src/object/task/taskinfo.h | 2 +- src/object/task/taskmanager.cpp | 42 ++-- src/object/task/taskmanip.cpp | 255 +++++++++++------------ src/object/task/taskpen.cpp | 49 ++--- src/object/task/taskpen.h | 4 +- src/object/task/taskrecover.cpp | 74 +++---- src/object/task/taskrecover.h | 4 +- src/object/task/taskreset.cpp | 57 +++-- src/object/task/taskreset.h | 2 +- src/object/task/tasktake.cpp | 7 +- src/object/task/tasktake.h | 3 +- 22 files changed, 670 insertions(+), 816 deletions(-) (limited to 'src/object/task') diff --git a/src/object/task/taskadvance.cpp b/src/object/task/taskadvance.cpp index e50cb08..0d159d2 100644 --- a/src/object/task/taskadvance.cpp +++ b/src/object/task/taskadvance.cpp @@ -16,9 +16,6 @@ // taskadvance.cpp - -#include - #include "object/task/taskadvance.h" #include "math/geometry.h" @@ -45,13 +42,13 @@ CTaskAdvance::~CTaskAdvance() bool CTaskAdvance::EventProcess(const Event &event) { - if ( m_engine->RetPause() ) return true; - if ( event.event != EVENT_FRAME ) return true; + if ( m_engine->GetPause() ) return true; + if ( event.type != EVENT_FRAME ) return true; m_fixTime += event.rTime; // Momentarily stationary object (ant on the back)? - if ( m_object->RetFixed() ) + if ( m_object->GetFixed() ) { m_physics->SetMotorSpeedX(0.0f); // stops the advance m_physics->SetMotorSpeedZ(0.0f); // stops the rotation @@ -70,12 +67,12 @@ Error CTaskAdvance::Start(float length) { m_direction = (length>=0.0f)?1.0f:-1.0f; m_totalLength = fabs(length); - m_advanceLength = m_physics->RetLinLength(length); - m_startPos = m_object->RetPosition(0); + m_advanceLength = m_physics->GetLinLength(length); + m_startPos = m_object->GetPosition(0); m_lastDist = 0.0f; m_fixTime = 0.0f; - m_timeLimit = m_physics->RetLinTimeLength(m_totalLength, m_direction)*3.0f; + m_timeLimit = m_physics->GetLinTimeLength(m_totalLength, m_direction)*3.0f; if ( m_timeLimit < 2.0f ) m_timeLimit = 2.0f; m_physics->SetMotorSpeedX(m_direction*1.0f); // forward/backward @@ -93,7 +90,7 @@ Error CTaskAdvance::IsEnded() Math::Vector pos; float length; - if ( m_engine->RetPause() ) return ERR_CONTINUE; + if ( m_engine->GetPause() ) return ERR_CONTINUE; if ( m_bError ) { @@ -106,7 +103,7 @@ Error CTaskAdvance::IsEnded() return ERR_MOVE_IMPOSSIBLE; } - pos = m_object->RetPosition(0); + pos = m_object->GetPosition(0); length = Math::DistanceProjected(pos, m_startPos); if ( length > m_lastDist ) // forward? diff --git a/src/object/task/taskbuild.cpp b/src/object/task/taskbuild.cpp index ecbf898..6aa0ed2 100644 --- a/src/object/task/taskbuild.cpp +++ b/src/object/task/taskbuild.cpp @@ -16,15 +16,14 @@ // taskbuild.cpp - -#include - #include "object/task/taskbuild.h" #include "common/iman.h" -#include "old/light.h" -#include "old/terrain.h" -#include "old/water.h" +#include "graphics/core/color.h" +#include "graphics/core/light.h" +#include "graphics/engine/lightman.h" +#include "graphics/engine/terrain.h" +#include "graphics/engine/water.h" #include "math/geometry.h" #include "object/auto/auto.h" #include "object/motion/motionhuman.h" @@ -32,9 +31,6 @@ #include "physics/physics.h" #include "ui/displaytext.h" - - - // Object's constructor. CTaskBuild::CTaskBuild(CInstanceManager* iMan, CObject* object) @@ -68,7 +64,7 @@ CTaskBuild::~CTaskBuild() for ( i=0 ; iDeleteLight(m_lightRank[i]); + m_lightMan->DeleteLight(m_lightRank[i]); } } @@ -102,7 +98,7 @@ bool CTaskBuild::CreateBuilding(Math::Vector pos, float angle) if ( m_type == OBJECT_INFO ) m_buildingHeight = 19.0f; m_buildingHeight *= 0.25f; - m_buildingPos = m_building->RetPosition(0); + m_buildingPos = m_building->GetPosition(0); m_buildingPos.y -= m_buildingHeight; m_building->SetPosition(0, m_buildingPos); return true; @@ -112,21 +108,21 @@ bool CTaskBuild::CreateBuilding(Math::Vector pos, float angle) void CTaskBuild::CreateLight() { - D3DLIGHT7 light; - D3DCOLORVALUE color; - Math::Vector center, pos, dir; - Math::Point c, p; - float angle; - int i; + Gfx::Light light; + Gfx::Color color; + Math::Vector center, pos, dir; + Math::Point c, p; + float angle; + int i; - if ( !m_engine->RetLightMode() ) return; + if ( !m_engine->GetLightMode() ) return; - center = m_metal->RetPosition(0); + center = m_metal->GetPosition(0); angle = 0; for ( i=0 ; iCreateLight(); + m_lightRank[i] = m_lightMan->CreateLight(); if ( m_lightRank[i] == -1 ) continue; c.x = center.x; @@ -139,32 +135,32 @@ void CTaskBuild::CreateLight() pos.y = center.y+40.0f; dir = center-pos; - ZeroMemory( &light, sizeof(light) ); - light.dltType = D3DLIGHT_SPOT; - light.dcvDiffuse.r = 0.0f; - light.dcvDiffuse.g = 0.0f; - light.dcvDiffuse.b = 0.0f; // white (invisible) - light.dvPosition.x = pos.x; - light.dvPosition.y = pos.y; - light.dvPosition.z = pos.z; - light.dvDirection.x = dir.x; - light.dvDirection.y = dir.y; - light.dvDirection.z = dir.z; - light.dvRange = D3DLIGHT_RANGE_MAX; - light.dvFalloff = 1.0f; - light.dvAttenuation0 = 1.0f; - light.dvAttenuation1 = 0.0f; - light.dvAttenuation2 = 0.0f; - light.dvTheta = 0.0f; - light.dvPhi = Math::PI/4.0f; - m_light->SetLight(m_lightRank[i], light); + memset(&light, 0, sizeof(light)); + light.type = Gfx::LIGHT_SPOT; + light.diffuse.r = 0.0f; + light.diffuse.g = 0.0f; + light.diffuse.b = 0.0f; // white (invisible) + light.position.x = pos.x; + light.position.y = pos.y; + light.position.z = pos.z; + light.direction.x = dir.x; + light.direction.y = dir.y; + light.direction.z = dir.z; + //TODO Is this value correct + light.spotIntensity = 128; + light.attenuation0 = 1.0f; + light.attenuation1 = 0.0f; + light.attenuation2 = 0.0f; + //TODO Is this value correct + light.spotAngle = 90; + m_lightMan->SetLight(m_lightRank[i], light); color.r = -1.0f; color.g = -1.0f; color.b = -0.5f; // violet color.a = 0.0f; - m_light->SetLightColor(m_lightRank[i], color); - m_light->SetLightColorSpeed(m_lightRank[i], 1.0f/((1.0f/m_speed)*0.25f)); + m_lightMan->SetLightColor(m_lightRank[i], color); + m_lightMan->SetLightColorSpeed(m_lightRank[i], 1.0f/((1.0f/m_speed)*0.25f)); angle += (Math::PI*2.0f)/TBMAXLIGHT; } @@ -176,8 +172,8 @@ void CTaskBuild::CreateLight() void CTaskBuild::BlackLight() { - D3DCOLORVALUE color; - int i; + Gfx::Color color; + int i; for ( i=0 ; iSetLightColor(m_lightRank[i], color); - m_light->SetLightColorSpeed(m_lightRank[i], 1.0f/((1.0f/m_speed)*0.75f)); + m_lightMan->SetLightColor(m_lightRank[i], color); + m_lightMan->SetLightColorSpeed(m_lightRank[i], 1.0f/((1.0f/m_speed)*0.75f)); } m_bBlack = true; @@ -203,8 +199,8 @@ bool CTaskBuild::EventProcess(const Event &event) Math::Point dim; float a, g, cirSpeed, dist, linSpeed; - if ( m_engine->RetPause() ) return true; - if ( event.event != EVENT_FRAME ) return true; + if ( m_engine->GetPause() ) return true; + if ( event.type != EVENT_FRAME ) return true; if ( m_bError ) return false; m_time += event.rTime; @@ -213,7 +209,7 @@ bool CTaskBuild::EventProcess(const Event &event) if ( m_phase == TBP_TURN ) // preliminary rotation? { - a = m_object->RetAngleY(0); + a = m_object->GetAngleY(0); g = m_angleY; cirSpeed = Math::Direction(a, g)*1.0f; if ( cirSpeed > 1.0f ) cirSpeed = 1.0f; @@ -225,7 +221,7 @@ bool CTaskBuild::EventProcess(const Event &event) if ( m_phase == TBP_MOVE ) // preliminary forward/backward? { - dist = Math::Distance(m_object->RetPosition(0), m_metal->RetPosition(0)); + dist = Math::Distance(m_object->GetPosition(0), m_metal->GetPosition(0)); linSpeed = 0.0f; if ( dist > 30.0f ) linSpeed = 1.0f; if ( dist < 30.0f ) linSpeed = -1.0f; @@ -258,8 +254,8 @@ bool CTaskBuild::EventProcess(const Event &event) { m_bBuild = true; - pos = m_metal->RetPosition(0); - a = m_object->RetAngleY(0); + pos = m_metal->GetPosition(0); + a = m_object->GetAngleY(0); if ( !CreateBuilding(pos, a+Math::PI) ) { m_metal->SetLock(false); // usable again @@ -270,7 +266,7 @@ bool CTaskBuild::EventProcess(const Event &event) m_camera->FlushEffect(); Abort(); m_bError = true; - m_displayText->DisplayError(ERR_TOOMANY, m_object->RetPosition(0)); + m_displayText->DisplayError(ERR_TOOMANY, m_object->GetPosition(0)); return false; } CreateLight(); @@ -295,32 +291,32 @@ bool CTaskBuild::EventProcess(const Event &event) BlackLight(); } - if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time ) + if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time ) { - m_lastParticule = m_time; + m_lastParticle = m_time; - pos = m_metal->RetPosition(0); + pos = m_metal->GetPosition(0); speed.x = (Math::Rand()-0.5f)*20.0f; speed.z = (Math::Rand()-0.5f)*20.0f; speed.y = Math::Rand()*10.0f; dim.x = Math::Rand()*6.0f+4.0f; dim.y = dim.x; - m_particule->CreateParticule(pos, speed, dim, PARTIFIRE); + m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIFIRE); pos = Math::Vector(0.0f, 0.5f, 0.0f); - mat = m_object->RetWorldMatrix(14); + mat = m_object->GetWorldMatrix(14); pos = Transform(*mat, pos); - speed = m_metal->RetPosition(0); + speed = m_metal->GetPosition(0); speed.x += (Math::Rand()-0.5f)*5.0f; speed.z += (Math::Rand()-0.5f)*5.0f; speed -= pos; dim.x = 2.0f; dim.y = dim.x; - m_particule->CreateParticule(pos, speed, dim, PARTIFIREZ); + m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIFIREZ); if ( Math::Rand() < 0.3f ) { - m_sound->Play(SOUND_BUILD, m_object->RetPosition(0), 0.5f, 1.0f*Math::Rand()*1.5f); + m_sound->Play(SOUND_BUILD, m_object->GetPosition(0), 0.5f, 1.0f*Math::Rand()*1.5f); } } @@ -337,25 +333,25 @@ Error CTaskBuild::Start(ObjectType type) float iAngle, oAngle; m_type = type; - m_lastParticule = 0.0f; + m_lastParticle = 0.0f; m_progress = 0.0f; - iAngle = m_object->RetAngleY(0); + iAngle = m_object->GetAngleY(0); iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI oAngle = iAngle; m_bError = true; // operation impossible - pos = m_object->RetPosition(0); - if ( pos.y < m_water->RetLevel() ) return ERR_BUILD_WATER; + pos = m_object->GetPosition(0); + if ( pos.y < m_water->GetLevel() ) return ERR_BUILD_WATER; - if ( !m_physics->RetLand() ) return ERR_BUILD_FLY; + if ( !m_physics->GetLand() ) return ERR_BUILD_FLY; - speed = m_physics->RetMotorSpeed(); + speed = m_physics->GetMotorSpeed(); if ( speed.x != 0.0f || speed.z != 0.0f ) return ERR_BUILD_MOTOR; - if ( m_object->RetFret() != 0 ) return ERR_MANIP_BUSY; + if ( m_object->GetFret() != 0 ) return ERR_MANIP_BUSY; m_metal = SearchMetalObject(oAngle, 2.0f, 100.0f, Math::PI*0.25f, err); if ( err == ERR_BUILD_METALNEAR && m_metal != 0 ) @@ -375,9 +371,9 @@ Error CTaskBuild::Start(ObjectType type) m_phase = TBP_TURN; // rotation necessary preliminary m_angleY = oAngle; // angle was reached - pv = m_object->RetPosition(0); + pv = m_object->GetPosition(0); pv.y += 8.3f; - pm = m_metal->RetPosition(0); + pm = m_metal->GetPosition(0); m_angleZ = Math::RotateAngle(Math::DistanceProjected(pv, pm), fabs(pv.y-pm.y)); m_physics->SetFreeze(true); // it does not move @@ -394,27 +390,27 @@ Error CTaskBuild::IsEnded() CAuto* automat; float angle, dist, time; - if ( m_engine->RetPause() ) return ERR_CONTINUE; + if ( m_engine->GetPause() ) return ERR_CONTINUE; if ( m_bError ) return ERR_STOP; if ( m_phase == TBP_TURN ) // preliminary rotation? { - angle = m_object->RetAngleY(0); + angle = m_object->GetAngleY(0); angle = Math::NormAngle(angle); // 0..2*Math::PI if ( Math::TestAngle(angle, m_angleY-Math::PI*0.01f, m_angleY+Math::PI*0.01f) ) { m_physics->SetMotorSpeedZ(0.0f); - dist = Math::Distance(m_object->RetPosition(0), m_metal->RetPosition(0)); + dist = Math::Distance(m_object->GetPosition(0), m_metal->GetPosition(0)); if ( dist > 30.0f ) { - time = m_physics->RetLinTimeLength(dist-30.0f, 1.0f); + time = m_physics->GetLinTimeLength(dist-30.0f, 1.0f); m_speed = 1.0f/time; } else { - time = m_physics->RetLinTimeLength(30.0f-dist, -1.0f); + time = m_physics->GetLinTimeLength(30.0f-dist, -1.0f); m_speed = 1.0f/time; } m_phase = TBP_MOVE; @@ -425,7 +421,7 @@ Error CTaskBuild::IsEnded() if ( m_phase == TBP_MOVE ) // preliminary forward/backward? { - dist = Math::Distance(m_object->RetPosition(0), m_metal->RetPosition(0)); + dist = Math::Distance(m_object->GetPosition(0), m_metal->GetPosition(0)); if ( dist >= 25.0f && dist <= 35.0f ) { @@ -466,12 +462,12 @@ Error CTaskBuild::IsEnded() { if ( m_progress < 1.0f ) return ERR_CONTINUE; - m_soundChannel = m_sound->Play(SOUND_TREMBLE, m_object->RetPosition(0), 0.0f, 1.0f, true); + m_soundChannel = m_sound->Play(SOUND_TREMBLE, m_object->GetPosition(0), 0.0f, 1.0f, true); m_sound->AddEnvelope(m_soundChannel, 0.7f, 1.0f, 1.0f, SOPER_CONTINUE); m_sound->AddEnvelope(m_soundChannel, 0.7f, 1.5f, 7.0f, SOPER_CONTINUE); m_sound->AddEnvelope(m_soundChannel, 0.0f, 1.5f, 2.0f, SOPER_STOP); - m_camera->StartEffect(CE_VIBRATION, m_metal->RetPosition(0), 1.0f); + m_camera->StartEffect(Gfx::CAM_EFFECT_VIBRATION, m_metal->GetPosition(0), 1.0f); m_phase = TBP_BUILD; m_speed = 1.0f/10.f; // duration of 10s @@ -482,7 +478,7 @@ Error CTaskBuild::IsEnded() { if ( m_progress < 1.0f ) return ERR_CONTINUE; - DeleteMark(m_metal->RetPosition(0), 20.0f); + DeleteMark(m_metal->GetPosition(0), 20.0f); m_metal->DeleteObject(); // removes the metal delete m_metal; @@ -494,7 +490,7 @@ Error CTaskBuild::IsEnded() m_main->CreateShortcuts(); m_displayText->DisplayError(INFO_BUILD, m_buildingPos, 10.0f, 50.0f); - automat = m_building->RetAuto(); + automat = m_building->GetAuto(); if ( automat != 0 ) { automat->Init(); @@ -583,16 +579,16 @@ Error CTaskBuild::FlatFloor() if ( m_type == OBJECT_INFO ) radius = 5.0f; if ( radius == 0.0f ) return ERR_GENERIC; - center = m_metal->RetPosition(0); - angle = m_terrain->RetFineSlope(center); - bLittleFlat = ( angle < FLATLIMIT ); + center = m_metal->GetPosition(0); + angle = m_terrain->GetFineSlope(center); + bLittleFlat = ( angle < Gfx::TERRAIN_FLATLIMIT); - max = m_terrain->RetFlatZoneRadius(center, radius); + max = m_terrain->GetFlatZoneRadius(center, radius); if ( max < radius ) // area too small? { if ( bLittleFlat ) { - m_main->SetShowLimit(1, PARTILIMIT3, m_metal, center, max, 10.0f); + m_main->SetShowLimit(1, Gfx::PARTILIMIT3, m_metal, center, max, 10.0f); } return bLittleFlat?ERR_BUILD_FLATLIT:ERR_BUILD_FLAT; } @@ -601,18 +597,18 @@ Error CTaskBuild::FlatFloor() bBase = false; for ( i=0 ; i<1000000 ; i++ ) { - pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i); + pObj = static_cast(m_iMan->SearchInstance(CLASS_OBJECT, i)); if ( pObj == 0 ) break; - if ( !pObj->RetActif() ) continue; // inactive? - if ( pObj->RetTruck() != 0 ) continue; // object transported? + if ( !pObj->GetActif() ) continue; // inactive? + if ( pObj->GetTruck() != 0 ) continue; // object transported? if ( pObj == m_metal ) continue; if ( pObj == m_object ) continue; - type = pObj->RetType(); + type = pObj->GetType(); if ( type == OBJECT_BASE ) { - oPos = pObj->RetPosition(0); + oPos = pObj->GetPosition(0); dist = Math::Distance(center, oPos)-80.0f; if ( dist < max ) { @@ -640,24 +636,24 @@ Error CTaskBuild::FlatFloor() } if ( max < radius ) { - m_main->SetShowLimit(1, PARTILIMIT2, m_metal, center, max, 10.0f); + m_main->SetShowLimit(1, Gfx::PARTILIMIT2, m_metal, center, max, 10.0f); if ( bRadius < 2.0f ) bRadius = 2.0f; - m_main->SetShowLimit(2, PARTILIMIT3, m_metal, bPos, bRadius, 10.0f); + m_main->SetShowLimit(2, Gfx::PARTILIMIT3, m_metal, bPos, bRadius, 10.0f); return bBase?ERR_BUILD_BASE:ERR_BUILD_BUSY; } max = 100000.0f; for ( i=0 ; i<1000000 ; i++ ) { - pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i); + pObj = static_cast(m_iMan->SearchInstance(CLASS_OBJECT, i)); if ( pObj == 0 ) break; - if ( !pObj->RetActif() ) continue; // inactive? - if ( pObj->RetTruck() != 0 ) continue; // object transported? + if ( !pObj->GetActif() ) continue; // inactive? + if ( pObj->GetTruck() != 0 ) continue; // object transported? if ( pObj == m_metal ) continue; if ( pObj == m_object ) continue; - type = pObj->RetType(); + type = pObj->GetType(); if ( type == OBJECT_DERRICK || type == OBJECT_FACTORY || type == OBJECT_STATION || @@ -691,8 +687,8 @@ Error CTaskBuild::FlatFloor() } if ( max-BUILDMARGIN < radius ) { - m_main->SetShowLimit(1, PARTILIMIT2, m_metal, center, max-BUILDMARGIN, 10.0f); - m_main->SetShowLimit(2, PARTILIMIT3, m_metal, bPos, bRadius+BUILDMARGIN, 10.0f); + m_main->SetShowLimit(1, Gfx::PARTILIMIT2, m_metal, center, max-BUILDMARGIN, 10.0f); + m_main->SetShowLimit(2, Gfx::PARTILIMIT3, m_metal, bPos, bRadius+BUILDMARGIN, 10.0f); return bBase?ERR_BUILD_BASE:ERR_BUILD_NARROW; } @@ -711,8 +707,8 @@ CObject* CTaskBuild::SearchMetalObject(float &angle, float dMin, float dMax, int i; bool bMetal; - iPos = m_object->RetPosition(0); - iAngle = m_object->RetAngleY(0); + iPos = m_object->GetPosition(0); + iAngle = m_object->GetAngleY(0); iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI min = 1000000.0f; @@ -720,18 +716,18 @@ CObject* CTaskBuild::SearchMetalObject(float &angle, float dMin, float dMax, bMetal = false; for ( i=0 ; i<1000000 ; i++ ) { - pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i); + pObj = static_cast(m_iMan->SearchInstance(CLASS_OBJECT, i)); if ( pObj == 0 ) break; - if ( !pObj->RetActif() ) continue; // objet inactive? - if ( pObj->RetTruck() != 0 ) continue; // object transported? + if ( !pObj->GetActif() ) continue; // objet inactive? + if ( pObj->GetTruck() != 0 ) continue; // object transported? - type = pObj->RetType(); + type = pObj->GetType(); if ( type != OBJECT_METAL ) continue; bMetal = true; // metal exists - oPos = pObj->RetPosition(0); + oPos = pObj->GetPosition(0); distance = Math::Distance(oPos, iPos); a = Math::RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW! @@ -781,10 +777,10 @@ void CTaskBuild::DeleteMark(Math::Vector pos, float radius) for ( i=0 ; i<1000000 ; i++ ) { - pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i); + pObj = static_cast(m_iMan->SearchInstance(CLASS_OBJECT, i)); if ( pObj == 0 ) break; - type = pObj->RetType(); + type = pObj->GetType(); if ( type != OBJECT_MARKSTONE && type != OBJECT_MARKURANIUM && type != OBJECT_MARKKEYa && @@ -793,7 +789,7 @@ void CTaskBuild::DeleteMark(Math::Vector pos, float radius) type != OBJECT_MARKKEYd && type != OBJECT_MARKPOWER ) continue; - oPos = pObj->RetPosition(0); + oPos = pObj->GetPosition(0); distance = Math::Distance(oPos, pos); if ( distance <= radius ) { diff --git a/src/object/task/taskbuild.h b/src/object/task/taskbuild.h index 682086d..25300b3 100644 --- a/src/object/task/taskbuild.h +++ b/src/object/task/taskbuild.h @@ -63,23 +63,23 @@ protected: void DeleteMark(Math::Vector pos, float radius); protected: - ObjectType m_type; // type of construction - CObject* m_metal; // transforms metal object - CObject* m_power; // the vehicle battery - CObject* m_building; // building built - TaskBuildPhase m_phase; // phase of the operation - bool m_bError; // true -> operation impossible - bool m_bBuild; // true -> building built - bool m_bBlack; // true -> lights black -> white - float m_time; // absolute time - float m_lastParticule; // time of generation last particle - float m_progress; // progression (0..1) - float m_speed; // speed of progression - float m_angleY; // rotation angle of the vehicle - float m_angleZ; // angle of rotation of the gun - Math::Vector m_buildingPos; // initial position of the building - float m_buildingHeight; // height of the building - int m_lightRank[TBMAXLIGHT];// lights for the effects - int m_soundChannel; + ObjectType m_type; // type of construction + CObject* m_metal; // transforms metal object + CObject* m_power; // the vehicle battery + CObject* m_building; // building built + TaskBuildPhase m_phase; // phase of the operation + bool m_bError; // true -> operation impossible + bool m_bBuild; // true -> building built + bool m_bBlack; // true -> lights black -> white + float m_time; // absolute time + float m_lastParticle; // time of generation last particle + float m_progress; // progression (0..1) + float m_speed; // speed of progression + float m_angleY; // rotation angle of the vehicle + float m_angleZ; // angle of rotation of the gun + Math::Vector m_buildingPos; // initial position of the building + float m_buildingHeight; // height of the building + int m_lightRank[TBMAXLIGHT]; // lights for the effects + int m_soundChannel; }; diff --git a/src/object/task/taskfire.cpp b/src/object/task/taskfire.cpp index 92c51da..99a88b8 100644 --- a/src/object/task/taskfire.cpp +++ b/src/object/task/taskfire.cpp @@ -16,12 +16,9 @@ // taskfire.cpp - -#include - #include "object/task/taskfire.h" -#include "old/particule.h" +#include "graphics/engine/particle.h" #include "math/geometry.h" #include "physics/physics.h" @@ -66,32 +63,32 @@ bool CTaskFire::EventProcess(const Event &event) float energy, fire; int i, channel; - if ( m_engine->RetPause() ) return true; - if ( event.event != EVENT_FRAME ) return true; + if ( m_engine->GetPause() ) return true; + if ( event.type != EVENT_FRAME ) return true; if ( m_bError ) return false; m_time += event.rTime; m_lastSound -= event.rTime; m_progress += event.rTime*m_speed; - power = m_object->RetPower(); + power = m_object->GetPower(); if ( power != 0 ) { - energy = power->RetEnergy(); + energy = power->GetEnergy(); if ( m_bOrganic ) fire = ENERGY_FIREi; else if ( m_bRay ) fire = ENERGY_FIREr; else fire = ENERGY_FIRE; - energy -= event.rTime*fire/power->RetCapacity(); + energy -= event.rTime*fire/power->GetCapacity(); power->SetEnergy(energy); } - if ( m_lastParticule+0.05f <= m_time ) + if ( m_lastParticle+0.05f <= m_time ) { - m_lastParticule = m_time; + m_lastParticle = m_time; if ( m_bOrganic ) { - mat = m_object->RetWorldMatrix(1); // insect-cannon + mat = m_object->GetWorldMatrix(1); // insect-cannon for ( i=0 ; i<6 ; i++ ) { @@ -100,10 +97,10 @@ bool CTaskFire::EventProcess(const Event &event) speed = Math::Vector(200.0f, 0.0f, 0.0f); - physics = m_object->RetPhysics(); + physics = m_object->GetPhysics(); if ( physics != 0 ) { - speed += physics->RetLinMotion(MO_REASPEED); + speed += physics->GetLinMotion(MO_REASPEED); } speed.x += (Math::Rand()-0.5f)*10.0f; @@ -115,13 +112,13 @@ bool CTaskFire::EventProcess(const Event &event) dim.x = Math::Rand()*0.5f+0.5f; dim.y = dim.x; - channel = m_particule->CreateParticule(pos, speed, dim, PARTIGUN4, 0.8f, 0.0f, 0.0f); - m_particule->SetObjectFather(channel, m_object); + channel = m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGUN4, 0.8f, 0.0f, 0.0f); + m_particle->SetObjectFather(channel, m_object); } } else if ( m_bRay ) { - mat = m_object->RetWorldMatrix(2); // cannon + mat = m_object->GetWorldMatrix(2); // cannon for ( i=0 ; i<4 ; i++ ) { @@ -139,9 +136,9 @@ bool CTaskFire::EventProcess(const Event &event) dim.x = 1.0f; dim.y = dim.x; - channel = m_particule->CreateTrack(pos, speed, dim, PARTITRACK11, + channel = m_particle->CreateTrack(pos, speed, dim, Gfx::PARTITRACK11, 2.0f, 200.0f, 0.5f, 1.0f); - m_particule->SetObjectFather(channel, m_object); + m_particle->SetObjectFather(channel, m_object); speed = Math::Vector(5.0f, 0.0f, 0.0f); speed.x += (Math::Rand()-0.5f)*1.0f; @@ -153,20 +150,20 @@ bool CTaskFire::EventProcess(const Event &event) dim.x = 2.0f; dim.y = dim.x; - m_particule->CreateParticule(pos, speed, dim, PARTISMOKE2, 2.0f, 0.0f, 0.5f); + m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISMOKE2, 2.0f, 0.0f, 0.5f); } } else { - type = m_object->RetType(); + type = m_object->GetType(); if ( type == OBJECT_MOBILErc ) { - mat = m_object->RetWorldMatrix(2); // cannon + mat = m_object->GetWorldMatrix(2); // cannon } else { - mat = m_object->RetWorldMatrix(1); // cannon + mat = m_object->GetWorldMatrix(1); // cannon } for ( i=0 ; i<3 ; i++ ) @@ -185,10 +182,10 @@ bool CTaskFire::EventProcess(const Event &event) speed = Math::Vector(200.0f, 0.0f, 0.0f); - physics = m_object->RetPhysics(); + physics = m_object->GetPhysics(); if ( physics != 0 ) { - speed += physics->RetLinMotion(MO_REASPEED); + speed += physics->GetLinMotion(MO_REASPEED); } speed.x += (Math::Rand()-0.5f)*3.0f; @@ -200,8 +197,8 @@ bool CTaskFire::EventProcess(const Event &event) dim.x = Math::Rand()*0.7f+0.7f; dim.y = dim.x; - channel = m_particule->CreateParticule(pos, speed, dim, PARTIGUN1, 0.8f, 0.0f, 0.0f); - m_particule->SetObjectFather(channel, m_object); + channel = m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGUN1, 0.8f, 0.0f, 0.0f); + m_particle->SetObjectFather(channel, m_object); } if ( type != OBJECT_MOBILErc && @@ -222,8 +219,8 @@ bool CTaskFire::EventProcess(const Event &event) dim.x = Math::Rand()*1.2f+1.2f; dim.y = dim.x; - m_particule->CreateParticule(pos, speed, dim, PARTICRASH, 2.0f, 0.0f, 0.0f); -//? m_particule->CreateParticule(pos, speed, dim, PARTISMOKE2, 4.0f, 0.0f, 0.0f); + m_particle->CreateParticle(pos, speed, dim, Gfx::PARTICRASH, 2.0f, 0.0f, 0.0f); +//? m_particle->CreateParticle(pos, speed, dim, PARTISMOKE2, 4.0f, 0.0f, 0.0f); } } @@ -256,7 +253,7 @@ bool CTaskFire::EventProcess(const Event &event) if ( m_bRay && m_lastSound <= 0.0f ) { m_lastSound = Math::Rand()*0.4f+0.4f; - m_sound->Play(SOUND_FIREp, m_object->RetPosition(0)); + m_sound->Play(SOUND_FIREp, m_object->GetPosition(0)); } return true; @@ -274,7 +271,7 @@ Error CTaskFire::Start(float delay) m_bError = true; // operation impossible - type = m_object->RetType(); + type = m_object->GetType(); if ( type != OBJECT_MOBILEfc && type != OBJECT_MOBILEtc && type != OBJECT_MOBILEwc && @@ -285,9 +282,9 @@ Error CTaskFire::Start(float delay) type != OBJECT_MOBILEii && type != OBJECT_MOBILErc ) return ERR_FIRE_VEH; -//? if ( !m_physics->RetLand() ) return ERR_FIRE_FLY; +//? if ( !m_physics->GetLand() ) return ERR_FIRE_FLY; - speed = m_physics->RetMotorSpeed(); + speed = m_physics->GetMotorSpeed(); //? if ( speed.x != 0.0f || //? speed.z != 0.0f ) return ERR_FIRE_MOTOR; @@ -309,18 +306,18 @@ Error CTaskFire::Start(float delay) } m_delay = delay; - power = m_object->RetPower(); + power = m_object->GetPower(); if ( power == 0 ) return ERR_FIRE_ENERGY; - energy = power->RetEnergy(); + energy = power->GetEnergy(); if ( m_bOrganic ) fire = m_delay*ENERGY_FIREi; else if ( m_bRay ) fire = m_delay*ENERGY_FIREr; else fire = m_delay*ENERGY_FIRE; - if ( energy < fire/power->RetCapacity()+0.05f ) return ERR_FIRE_ENERGY; + if ( energy < fire/power->GetCapacity()+0.05f ) return ERR_FIRE_ENERGY; m_speed = 1.0f/m_delay; m_progress = 0.0f; m_time = 0.0f; - m_lastParticule = 0.0f; + m_lastParticle = 0.0f; m_lastSound = 0.0f; m_bError = false; // ok @@ -328,7 +325,7 @@ Error CTaskFire::Start(float delay) if ( m_bOrganic ) { - m_soundChannel = m_sound->Play(SOUND_FIREi, m_object->RetPosition(0), 1.0f, 1.0f, true); + m_soundChannel = m_sound->Play(SOUND_FIREi, m_object->GetPosition(0), 1.0f, 1.0f, true); if ( m_soundChannel != -1 ) { m_sound->AddEnvelope(m_soundChannel, 1.0f, 1.0f, m_delay, SOPER_CONTINUE); @@ -340,7 +337,7 @@ Error CTaskFire::Start(float delay) } else { - m_soundChannel = m_sound->Play(SOUND_FIRE, m_object->RetPosition(0), 1.0f, 1.0f, true); + m_soundChannel = m_sound->Play(SOUND_FIRE, m_object->GetPosition(0), 1.0f, 1.0f, true); if ( m_soundChannel != -1 ) { m_sound->AddEnvelope(m_soundChannel, 1.0f, 1.0f, m_delay, SOPER_CONTINUE); @@ -355,7 +352,7 @@ Error CTaskFire::Start(float delay) Error CTaskFire::IsEnded() { - if ( m_engine->RetPause() ) return ERR_CONTINUE; + if ( m_engine->GetPause() ) return ERR_CONTINUE; if ( m_bError ) return ERR_STOP; if ( m_progress < 1.0f ) return ERR_CONTINUE; diff --git a/src/object/task/taskfire.h b/src/object/task/taskfire.h index f06b9f6..5cf4f0c 100644 --- a/src/object/task/taskfire.h +++ b/src/object/task/taskfire.h @@ -45,7 +45,7 @@ protected: bool m_bOrganic; float m_time; float m_speed; - float m_lastParticule; + float m_lastParticle; float m_lastSound; int m_soundChannel; }; diff --git a/src/object/task/taskfireant.cpp b/src/object/task/taskfireant.cpp index 8eb2217..2044685 100644 --- a/src/object/task/taskfireant.cpp +++ b/src/object/task/taskfireant.cpp @@ -16,12 +16,9 @@ // taskfireant.cpp - -#include - #include "object/task/taskfireant.h" -#include "old/particule.h" +#include "graphics/engine/particle.h" #include "math/geometry.h" #include "object/motion/motionant.h" #include "physics/physics.h" @@ -51,11 +48,11 @@ bool CTaskFireAnt::EventProcess(const Event &event) Math::Vector dir, vib; float a, g, cirSpeed; - if ( m_engine->RetPause() ) return true; - if ( event.event != EVENT_FRAME ) return true; + if ( m_engine->GetPause() ) return true; + if ( event.type != EVENT_FRAME ) return true; if ( m_bError ) return false; - if ( m_object->RetFixed() ) // insect on its back? + if ( m_object->GetFixed() ) // insect on its back? { m_bError = true; return false; @@ -66,7 +63,7 @@ bool CTaskFireAnt::EventProcess(const Event &event) if ( m_phase == TFA_TURN ) // preliminary rotation? { - a = m_object->RetAngleY(0); + a = m_object->GetAngleY(0); g = m_angle; cirSpeed = Math::Direction(a, g)*2.0f; if ( cirSpeed > 2.0f ) cirSpeed = 2.0f; @@ -89,24 +86,24 @@ Error CTaskFireAnt::Start(Math::Vector impact) m_impact = impact; m_bError = true; // operation impossible - if ( !m_physics->RetLand() ) return ERR_FIRE_VEH; + if ( !m_physics->GetLand() ) return ERR_FIRE_VEH; - type = m_object->RetType(); + type = m_object->GetType(); if ( type != OBJECT_ANT ) return ERR_FIRE_VEH; // Insect on its back? - if ( m_object->RetFixed() ) return ERR_FIRE_VEH; + if ( m_object->GetFixed() ) return ERR_FIRE_VEH; m_physics->SetMotorSpeed(Math::Vector(0.0f, 0.0f, 0.0f)); - pos = m_object->RetPosition(0); + pos = m_object->GetPosition(0); m_angle = Math::RotateAngle(m_impact.x-pos.x, pos.z-m_impact.z); // CW ! m_phase = TFA_TURN; m_speed = 1.0f/1.0f; m_progress = 0.0f; m_time = 0.0f; - m_lastParticule = 0.0f; + m_lastParticle = 0.0f; m_bError = false; // ok m_bFire = false; // once! @@ -123,13 +120,13 @@ Error CTaskFireAnt::IsEnded() float angle, dist; int i, channel; - if ( m_engine->RetPause() ) return ERR_CONTINUE; + if ( m_engine->GetPause() ) return ERR_CONTINUE; if ( m_bError ) return ERR_STOP; - if ( m_object->RetFixed() ) return ERR_STOP; // insect on its back? + if ( m_object->GetFixed() ) return ERR_STOP; // insect on its back? if ( m_phase == TFA_TURN ) // rotation ? { - angle = m_object->RetAngleY(0); + angle = m_object->GetAngleY(0); angle = Math::NormAngle(angle); // 0..2*Math::PI if ( !Math::TestAngle(angle, m_angle-Math::PI*0.05f, m_angle+Math::PI*0.05f) ) return ERR_CONTINUE; @@ -164,7 +161,7 @@ Error CTaskFireAnt::IsEnded() for ( i=0 ; i<20 ; i++ ) { pos = Math::Vector(-2.5f, -0.7f, 0.0f); - mat = m_object->RetWorldMatrix(2); + mat = m_object->GetWorldMatrix(2); pos = Math::Transform(*mat, pos); dist = Math::Distance(pos, m_impact); speed = m_impact-pos; @@ -173,8 +170,8 @@ Error CTaskFireAnt::IsEnded() speed.z += (Math::Rand()-0.5f)*dist*1.2f; dim.x = 1.0f; dim.y = dim.x; - channel = m_particule->CreateParticule(pos, speed, dim, PARTIGUN2, 2.0f, 100.0f, 0.0f); - m_particule->SetObjectFather(channel, m_object); + channel = m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGUN2, 2.0f, 100.0f, 0.0f); + m_particle->SetObjectFather(channel, m_object); } } diff --git a/src/object/task/taskfireant.h b/src/object/task/taskfireant.h index 1d8ef62..4fa77b8 100644 --- a/src/object/task/taskfireant.h +++ b/src/object/task/taskfireant.h @@ -58,6 +58,6 @@ protected: bool m_bError; bool m_bFire; float m_time; - float m_lastParticule; + float m_lastParticle; }; diff --git a/src/object/task/taskflag.cpp b/src/object/task/taskflag.cpp index 7fba689..d45fff4 100644 --- a/src/object/task/taskflag.cpp +++ b/src/object/task/taskflag.cpp @@ -16,15 +16,13 @@ // taskflag.cpp - -#include - #include "object/task/taskflag.h" #include "math/geometry.h" #include "common/iman.h" -#include "old/water.h" -#include "old/pyro.h" +#include "graphics/engine/particle.h" +#include "graphics/engine/pyro.h" +#include "graphics/engine/water.h" #include "physics/physics.h" #include "object/motion/motionhuman.h" @@ -51,8 +49,8 @@ CTaskFlag::~CTaskFlag() bool CTaskFlag::EventProcess(const Event &event) { if ( m_bError ) return true; - if ( m_engine->RetPause() ) return true; - if ( event.event != EVENT_FRAME ) return true; + if ( m_engine->GetPause() ) return true; + if ( event.type != EVENT_FRAME ) return true; m_time += event.rTime; @@ -72,18 +70,18 @@ Error CTaskFlag::Start(TaskFlagOrder order, int rank) m_time = 0.0f; m_bError = true; // operation impossible - if ( !m_physics->RetLand() ) + if ( !m_physics->GetLand() ) { - pos = m_object->RetPosition(0); - if ( pos.y < m_water->RetLevel() ) return ERR_FLAG_WATER; + pos = m_object->GetPosition(0); + if ( pos.y < m_water->GetLevel() ) return ERR_FLAG_WATER; return ERR_FLAG_FLY; } - speed = m_physics->RetMotorSpeed(); + speed = m_physics->GetMotorSpeed(); if ( speed.x != 0.0f || speed.z != 0.0f ) return ERR_FLAG_MOTOR; - if ( m_object->RetFret() != 0 ) return ERR_FLAG_BUSY; + if ( m_object->GetFret() != 0 ) return ERR_FLAG_BUSY; if ( order == TFL_CREATE ) { @@ -109,7 +107,7 @@ Error CTaskFlag::Start(TaskFlagOrder order, int rank) Error CTaskFlag::IsEnded() { - if ( m_engine->RetPause() ) return ERR_CONTINUE; + if ( m_engine->GetPause() ) return ERR_CONTINUE; if ( m_bError ) return ERR_STOP; if ( m_time < 2.0f ) return ERR_CONTINUE; @@ -143,12 +141,12 @@ CObject* CTaskFlag::SearchNearest(Math::Vector pos, ObjectType type) pBest = 0; for ( i=0 ; i<1000000 ; i++ ) { - pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i); + pObj = static_cast(m_iMan->SearchInstance(CLASS_OBJECT, i)); if ( pObj == 0 ) break; - if ( !pObj->RetEnable() ) continue; + if ( !pObj->GetEnable() ) continue; - oType = pObj->RetType(); + oType = pObj->GetType(); if ( type == OBJECT_NULL ) { if ( oType != OBJECT_FLAGb && @@ -162,7 +160,7 @@ CObject* CTaskFlag::SearchNearest(Math::Vector pos, ObjectType type) if ( oType != type ) continue; } - oPos = pObj->RetPosition(0); + oPos = pObj->GetPosition(0); dist = Math::DistanceProjected(oPos, pos); if ( dist < min ) { @@ -185,12 +183,12 @@ int CTaskFlag::CountObject(ObjectType type) count = 0; for ( i=0 ; i<1000000 ; i++ ) { - pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i); + pObj = static_cast(m_iMan->SearchInstance(CLASS_OBJECT, i)); if ( pObj == 0 ) break; - if ( !pObj->RetEnable() ) continue; + if ( !pObj->GetEnable() ) continue; - oType = pObj->RetType(); + oType = pObj->GetType(); if ( type == OBJECT_NULL ) { if ( oType != OBJECT_FLAGb && @@ -213,13 +211,13 @@ int CTaskFlag::CountObject(ObjectType type) Error CTaskFlag::CreateFlag(int rank) { - CObject* pObj; - CObject* pNew; - CPyro* pyro; - Math::Matrix* mat; - Math::Vector pos; - float dist; - int i; + CObject* pObj; + CObject* pNew; + Gfx::CPyro* pyro; + Math::Matrix* mat; + Math::Vector pos; + float dist; + int i; ObjectType table[5] = { @@ -230,13 +228,13 @@ Error CTaskFlag::CreateFlag(int rank) OBJECT_FLAGv, }; - mat = m_object->RetWorldMatrix(0); + mat = m_object->GetWorldMatrix(0); pos = Transform(*mat, Math::Vector(4.0f, 0.0f, 0.0f)); pObj = SearchNearest(pos, OBJECT_NULL); if ( pObj != 0 ) { - dist = Math::Distance(pos, pObj->RetPosition(0)); + dist = Math::Distance(pos, pObj->GetPosition(0)); if ( dist < 10.0f ) { return ERR_FLAG_PROXY; @@ -258,8 +256,8 @@ Error CTaskFlag::CreateFlag(int rank) pNew->SetZoom(0, 0.0f); m_sound->Play(SOUND_WAYPOINT, pos); - pyro = new CPyro(m_iMan); - pyro->Create(PT_FLCREATE, pNew); + pyro = new Gfx::CPyro(m_iMan); + pyro->Create(Gfx::PT_FLCREATE, pNew); return ERR_OK; } @@ -268,13 +266,13 @@ Error CTaskFlag::CreateFlag(int rank) Error CTaskFlag::DeleteFlag() { - CObject* pObj; - CPyro* pyro; - Math::Vector iPos, oPos; - float iAngle, angle, aLimit, dist; + CObject* pObj; + Gfx::CPyro* pyro; + Math::Vector iPos, oPos; + float iAngle, angle, aLimit, dist; - iPos = m_object->RetPosition(0); - iAngle = m_object->RetAngleY(0); + iPos = m_object->GetPosition(0); + iAngle = m_object->GetAngleY(0); iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI pObj = SearchNearest(iPos, OBJECT_NULL); @@ -282,13 +280,13 @@ Error CTaskFlag::DeleteFlag() { return ERR_FLAG_DELETE; } - dist = Math::Distance(iPos, pObj->RetPosition(0)); + dist = Math::Distance(iPos, pObj->GetPosition(0)); if ( dist > 10.0f ) { return ERR_FLAG_DELETE; } - oPos = pObj->RetPosition(0); + oPos = pObj->GetPosition(0); angle = Math::RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW ! aLimit = 45.0f*Math::PI/180.0f; if ( !Math::TestAngle(angle, iAngle-aLimit, iAngle+aLimit) ) @@ -297,8 +295,8 @@ Error CTaskFlag::DeleteFlag() } m_sound->Play(SOUND_WAYPOINT, iPos); - pyro = new CPyro(m_iMan); - pyro->Create(PT_FLDELETE, pObj); + pyro = new Gfx::CPyro(m_iMan); + pyro->Create(Gfx::PT_FLDELETE, pObj); return ERR_OK; } diff --git a/src/object/task/taskgoto.cpp b/src/object/task/taskgoto.cpp index 5fd6cbe..fb3c9a2 100644 --- a/src/object/task/taskgoto.cpp +++ b/src/object/task/taskgoto.cpp @@ -23,8 +23,8 @@ #include "common/event.h" #include "common/iman.h" -#include "old/terrain.h" -#include "old/water.h" +#include "graphics/engine/terrain.h" +#include "graphics/engine/water.h" #include "math/geometry.h" #include "physics/physics.h" @@ -59,14 +59,14 @@ bool CTaskGoto::EventProcess(const Event &event) { Math::Vector pos, goal; Math::Point rot, repulse; - float a, g, dist, linSpeed, cirSpeed, h, hh, factor, dir; - Error ret; + float a, g, dist, linSpeed, cirSpeed, h, hh, factor, dir; + Error ret; - if ( m_engine->RetPause() ) return true; - if ( event.event != EVENT_FRAME ) return true; + if ( m_engine->GetPause() ) return true; + if ( event.type != EVENT_FRAME ) return true; // Momentarily stationary object (ant on the back)? - if ( m_object->RetFixed() ) + if ( m_object->GetFixed() ) { m_physics->SetMotorSpeedX(0.0f); // stops the advance m_physics->SetMotorSpeedZ(0.0f); // stops the rotation @@ -84,7 +84,7 @@ bool CTaskGoto::EventProcess(const Event &event) { m_leakTime += event.rTime; - pos = m_object->RetPosition(0); + pos = m_object->GetPosition(0); rot.x = m_leakPos.x-pos.x; rot.y = m_leakPos.z-pos.z; @@ -92,7 +92,7 @@ bool CTaskGoto::EventProcess(const Event &event) rot.x /= dist; rot.y /= dist; - a = m_object->RetAngleY(0); + a = m_object->GetAngleY(0); g = Math::RotateAngle(rot.x, -rot.y); // CW ! a = Math::Direction(a, g)*1.0f; cirSpeed = a; @@ -126,10 +126,10 @@ bool CTaskGoto::EventProcess(const Event &event) if ( m_bmStep == 0 ) { // Frees the area around the departure. - BitmapClearCircle(m_object->RetPosition(0), BM_DIM_STEP*1.8f); + BitmapClearCircle(m_object->GetPosition(0), BM_DIM_STEP*1.8f); } - pos = m_object->RetPosition(0); + pos = m_object->GetPosition(0); if ( m_bmFretObject == 0 ) { @@ -140,44 +140,20 @@ bool CTaskGoto::EventProcess(const Event &event) { goal = m_goalObject; dist = TAKE_DIST+2.0f; - if ( m_bmFretObject->RetType() == OBJECT_BASE ) dist = 12.0f; + if ( m_bmFretObject->GetType() == OBJECT_BASE ) dist = 12.0f; } ret = BeamSearch(pos, goal, dist); if ( ret == ERR_OK ) { -#if 0 - Math::Vector min, max; - min = pos; - max = m_goal; - if ( min.x > max.x ) Math::Swap(min.x, max.x); - if ( min.z > max.z ) Math::Swap(min.z, max.z); - min.x -= 50.0f; - min.z -= 50.0f; - max.x += 50.0f; - max.z += 50.0f; - BitmapDebug(min, max, m_object->RetPosition(0), m_goal); -#endif - if ( m_physics->RetLand() ) m_phase = TGP_BEAMWCOLD; + if ( m_physics->GetLand() ) m_phase = TGP_BEAMWCOLD; else m_phase = TGP_BEAMGOTO; m_bmIndex = 0; - m_bmWatchDogPos = m_object->RetPosition(0); + m_bmWatchDogPos = m_object->GetPosition(0); m_bmWatchDogTime = 0.0f; } if ( ret == ERR_GOTO_IMPOSSIBLE || ret == ERR_GOTO_ITER ) { -#if 0 - Math::Vector min, max; - min = pos; - max = m_goal; - if ( min.x > max.x ) Math::Swap(min.x, max.x); - if ( min.z > max.z ) Math::Swap(min.z, max.z); - min.x -= 50.0f; - min.z -= 50.0f; - max.x += 50.0f; - max.z += 50.0f; - BitmapDebug(min, max, m_object->RetPosition(0), m_goal); -#endif m_error = ret; return false; } @@ -197,16 +173,16 @@ bool CTaskGoto::EventProcess(const Event &event) if ( m_phase == TGP_BEAMGOTO ) // goto dot list? (?) { - if ( m_physics->RetCollision() ) // collision? + if ( m_physics->GetCollision() ) // collision? { m_physics->SetCollision(false); // there's more } - pos = m_object->RetPosition(0); + pos = m_object->GetPosition(0); - if ( m_physics->RetType() == TYPE_FLYING && m_altitude == 0.0f ) + if ( m_physics->GetType() == TYPE_FLYING && m_altitude == 0.0f ) { - if ( m_physics->RetLand() ) + if ( m_physics->GetLand() ) { m_physics->SetMotorSpeedY(0.0f); } @@ -216,21 +192,21 @@ bool CTaskGoto::EventProcess(const Event &event) } } - if ( m_physics->RetType() == TYPE_FLYING && m_altitude > 0.0f ) + if ( m_physics->GetType() == TYPE_FLYING && m_altitude > 0.0f ) { goal = m_bmPoints[m_bmIndex]; goal.y = pos.y; - h = m_terrain->RetFloorHeight(goal, true, true); + h = m_terrain->GetHeightToFloor(goal, true, true); dist = Math::DistanceProjected(pos, goal); if ( dist != 0.0f ) // anticipates? { - linSpeed = m_physics->RetLinMotionX(MO_REASPEED); - linSpeed /= m_physics->RetLinMotionX(MO_ADVSPEED); + linSpeed = m_physics->GetLinMotionX(MO_REASPEED); + linSpeed /= m_physics->GetLinMotionX(MO_ADVSPEED); goal.x = pos.x + (goal.x-pos.x)*linSpeed*20.0f/dist; goal.z = pos.z + (goal.z-pos.z)*linSpeed*20.0f/dist; } goal.y = pos.y; - hh = m_terrain->RetFloorHeight(goal, true, true); + hh = m_terrain->GetHeightToFloor(goal, true, true); h = Math::Min(h, hh); linSpeed = 0.0f; if ( h < m_altitude-1.0f ) @@ -251,7 +227,7 @@ bool CTaskGoto::EventProcess(const Event &event) rot.x /= dist; rot.y /= dist; - a = m_object->RetAngleY(0); + a = m_object->GetAngleY(0); g = Math::RotateAngle(rot.x, -rot.y); // CW ! cirSpeed = Math::Direction(a, g)*2.0f; if ( cirSpeed > 1.0f ) cirSpeed = 1.0f; @@ -260,7 +236,7 @@ bool CTaskGoto::EventProcess(const Event &event) if ( m_bmIndex == m_bmTotal ) // last point? { - linSpeed = dist/(m_physics->RetLinStopLength()*1.5f); + linSpeed = dist/(m_physics->GetLinStopLength()*1.5f); if ( linSpeed > 1.0f ) linSpeed = 1.0f; } else @@ -316,7 +292,7 @@ bool CTaskGoto::EventProcess(const Event &event) { if ( m_crashMode == TGC_HALT ) { - if ( m_physics->RetCollision() ) // collision? + if ( m_physics->GetCollision() ) // collision? { m_physics->SetCollision(false); // there's more m_error = ERR_STOP; @@ -324,11 +300,11 @@ bool CTaskGoto::EventProcess(const Event &event) } } - pos = m_object->RetPosition(0); + pos = m_object->GetPosition(0); if ( m_altitude > 0.0f ) { - h = m_terrain->RetFloorHeight(pos, true, true); + h = m_terrain->GetHeightToFloor(pos, true, true); linSpeed = 0.0f; if ( h < m_altitude ) { @@ -343,7 +319,7 @@ bool CTaskGoto::EventProcess(const Event &event) rot.x = m_goal.x-pos.x; rot.y = m_goal.z-pos.z; - a = m_object->RetAngleY(0); + a = m_object->GetAngleY(0); g = Math::RotateAngle(rot.x, -rot.y); // CW ! cirSpeed = Math::Direction(a, g)*1.0f; if ( cirSpeed > 1.0f ) cirSpeed = 1.0f; @@ -355,16 +331,16 @@ bool CTaskGoto::EventProcess(const Event &event) } if ( m_phase != TGP_TURN && - m_physics->RetType() == TYPE_FLYING && + m_physics->GetType() == TYPE_FLYING && m_altitude > 0.0f ) { - pos = m_object->RetPosition(0); + pos = m_object->GetPosition(0); dist = Math::DistanceProjected(m_goal, pos); factor = (dist-20.0f)/20.0f; if ( factor < 0.0f ) factor = 0.0f; if ( factor > 1.0f ) factor = 1.0f; - h = m_terrain->RetFloorHeight(m_object->RetPosition(0), true, true); + h = m_terrain->GetHeightToFloor(m_object->GetPosition(0), true, true); linSpeed = 0.0f; if ( h < (m_altitude-0.5f)*factor && factor == 1.0f ) { @@ -382,7 +358,7 @@ bool CTaskGoto::EventProcess(const Event &event) if ( m_phase == TGP_ADVANCE ) // going towards the goal? { - if ( m_physics->RetCollision() ) // collision? + if ( m_physics->GetCollision() ) // collision? { m_physics->SetCollision(false); // there's more m_time = 0.0f; @@ -391,15 +367,15 @@ bool CTaskGoto::EventProcess(const Event &event) } #if 0 - pos = m_object->RetPosition(0); - a = m_object->RetAngleY(0); + pos = m_object->GetPosition(0); + a = m_object->GetAngleY(0); g = Math::RotateAngle(m_goal.x-pos.x, pos.z-m_goal.z); // CW ! cirSpeed = Math::Direction(a, g)*1.0f; if ( cirSpeed > 1.0f ) cirSpeed = 1.0f; if ( cirSpeed < -1.0f ) cirSpeed = -1.0f; dist = Math::DistanceProjected(m_goal, pos); - linSpeed = dist/(m_physics->RetLinStopLength()*1.5f); + linSpeed = dist/(m_physics->GetLinStopLength()*1.5f); if ( linSpeed > 1.0f ) linSpeed = 1.0f; if ( dist < 20.0f && fabs(cirSpeed) >= 0.5f ) @@ -407,7 +383,7 @@ bool CTaskGoto::EventProcess(const Event &event) linSpeed = 0.0f; // turns first, then advance } #else - pos = m_object->RetPosition(0); + pos = m_object->GetPosition(0); rot.x = m_goal.x-pos.x; rot.y = m_goal.z-pos.z; @@ -419,11 +395,11 @@ bool CTaskGoto::EventProcess(const Event &event) rot.x += repulse.x*2.0f; rot.y += repulse.y*2.0f; - a = m_object->RetAngleY(0); + a = m_object->GetAngleY(0); g = Math::RotateAngle(rot.x, -rot.y); // CW ! cirSpeed = Math::Direction(a, g)*1.0f; -//? if ( m_physics->RetType() == TYPE_FLYING && -//? m_physics->RetLand() ) // flying on the ground? +//? if ( m_physics->GetType() == TYPE_FLYING && +//? m_physics->GetLand() ) // flying on the ground? //? { //? cirSpeed *= 4.0f; // more fishing //? } @@ -431,9 +407,9 @@ bool CTaskGoto::EventProcess(const Event &event) if ( cirSpeed < -1.0f ) cirSpeed = -1.0f; dist = Math::DistanceProjected(m_goal, pos); - linSpeed = dist/(m_physics->RetLinStopLength()*1.5f); -//? if ( m_physics->RetType() == TYPE_FLYING && -//? m_physics->RetLand() ) // flying on the ground? + linSpeed = dist/(m_physics->GetLinStopLength()*1.5f); +//? if ( m_physics->GetType() == TYPE_FLYING && +//? m_physics->GetLand() ) // flying on the ground? //? { //? linSpeed *= 8.0f; // more fishing //? } @@ -455,7 +431,7 @@ bool CTaskGoto::EventProcess(const Event &event) m_phase == TGP_CRTURN || // turns after collision? m_phase == TGP_CLTURN ) // turns after collision? { - a = m_object->RetAngleY(0); + a = m_object->GetAngleY(0); g = m_angle; cirSpeed = Math::Direction(a, g)*1.0f; if ( cirSpeed > 1.0f ) cirSpeed = 1.0f; @@ -474,7 +450,7 @@ bool CTaskGoto::EventProcess(const Event &event) if ( m_phase == TGP_CRADVANCE ) // advance after collision? { - if ( m_physics->RetCollision() ) // collision? + if ( m_physics->GetCollision() ) // collision? { m_physics->SetCollision(false); // there's more m_time = 0.0f; @@ -486,7 +462,7 @@ bool CTaskGoto::EventProcess(const Event &event) if ( m_phase == TGP_CLADVANCE ) // advance after collision? { - if ( m_physics->RetCollision() ) // collision? + if ( m_physics->GetCollision() ) // collision? { m_physics->SetCollision(false); // there's more m_time = 0.0f; @@ -517,15 +493,15 @@ CObject* CTaskGoto::WormSearch(Math::Vector &impact) float distance, min, radius; int i; - iPos = m_object->RetPosition(0); + iPos = m_object->GetPosition(0); min = 1000000.0f; for ( i=0 ; i<1000000 ; i++ ) { - pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i); + pObj = static_cast(m_iMan->SearchInstance(CLASS_OBJECT, i)); if ( pObj == 0 ) break; - oType = pObj->RetType(); + oType = pObj->GetType(); if ( oType != OBJECT_MOBILEfa && oType != OBJECT_MOBILEta && oType != OBJECT_MOBILEwa && @@ -570,7 +546,7 @@ CObject* CTaskGoto::WormSearch(Math::Vector &impact) oType != OBJECT_SAFE && oType != OBJECT_HUSTON ) continue; - if ( pObj->RetVirusMode() ) continue; // object infected? + if ( pObj->GetVirusMode() ) continue; // object infected? if ( !pObj->GetCrashSphere(0, oPos, radius) ) continue; distance = Math::DistanceProjected(oPos, iPos); @@ -582,7 +558,7 @@ CObject* CTaskGoto::WormSearch(Math::Vector &impact) } if ( pBest == 0 ) return 0; - impact = pBest->RetPosition(0); + impact = pBest->GetPosition(0); return pBest; } @@ -603,7 +579,7 @@ void CTaskGoto::WormFrame(float rTime) pObj = WormSearch(impact); if ( pObj != 0 ) { - pos = m_object->RetPosition(0); + pos = m_object->GetPosition(0); dist = Math::Distance(pos, impact); if ( dist <= 15.0f ) { @@ -627,7 +603,7 @@ Error CTaskGoto::Start(Math::Vector goal, float altitude, float dist; int x, y; - type = m_object->RetType(); + type = m_object->GetType(); if ( goalMode == TGG_DEFAULT ) { @@ -668,7 +644,7 @@ Error CTaskGoto::Start(Math::Vector goal, float altitude, m_bmFretObject = 0; m_bmFinalMove = 0.0f; - pos = m_object->RetPosition(0); + pos = m_object->GetPosition(0); dist = Math::DistanceProjected(pos, m_goal); if ( dist < 10.0f && m_crashMode == TGC_BEAM ) { @@ -703,7 +679,7 @@ Error CTaskGoto::Start(Math::Vector goal, float altitude, target = SearchTarget(goal, 1.0f); if ( target != 0 ) { - m_goal = target->RetPosition(0); + m_goal = target->GetPosition(0); dist = 0.0f; if ( !AdjustBuilding(m_goal, 1.0f, dist) ) { @@ -722,7 +698,7 @@ Error CTaskGoto::Start(Math::Vector goal, float altitude, target = SearchTarget(goal, 1.0f); if ( target != 0 ) { - m_goal = target->RetPosition(0); + m_goal = target->GetPosition(0); dist = 4.0f; if ( AdjustBuilding(m_goal, 1.0f, dist) ) { @@ -743,9 +719,9 @@ Error CTaskGoto::Start(Math::Vector goal, float altitude, m_bTake = true; // object was taken on arrival (final rotation) } - if ( m_physics->RetType() == TYPE_FLYING && m_altitude == 0.0f ) + if ( m_physics->GetType() == TYPE_FLYING && m_altitude == 0.0f ) { - pos = m_object->RetPosition(0); + pos = m_object->GetPosition(0); dist = Math::DistanceProjected(pos, m_goal); if ( dist > FLY_DIST_GROUND ) // over 20 meters? { @@ -757,22 +733,10 @@ Error CTaskGoto::Start(Math::Vector goal, float altitude, if ( m_bmFretObject == 0 ) { - x = (int)((m_goal.x+1600.0f)/BM_DIM_STEP); - y = (int)((m_goal.z+1600.0f)/BM_DIM_STEP); + x = static_cast((m_goal.x+1600.0f)/BM_DIM_STEP); + y = static_cast((m_goal.z+1600.0f)/BM_DIM_STEP); if ( BitmapTestDot(0, x, y) ) // arrival occupied? { -#if 0 - Math::Vector min, max; - min = m_object->RetPosition(0); - max = m_goal; - if ( min.x > max.x ) Math::Swap(min.x, max.x); - if ( min.z > max.z ) Math::Swap(min.z, max.z); - min.x -= 50.0f; - min.z -= 50.0f; - max.x += 50.0f; - max.z += 50.0f; - BitmapDebug(min, max, m_object->RetPosition(0), m_goal); -#endif m_error = ERR_GOTO_BUSY; return m_error; } @@ -789,10 +753,10 @@ Error CTaskGoto::IsEnded() Math::Vector pos; float limit, angle, dist, h, level; - if ( m_engine->RetPause() ) return ERR_CONTINUE; + if ( m_engine->GetPause() ) return ERR_CONTINUE; if ( m_error != ERR_OK ) return m_error; - pos = m_object->RetPosition(0); + pos = m_object->GetPosition(0); if ( m_phase == TGP_BEAMLEAK ) // leak? { @@ -814,17 +778,17 @@ Error CTaskGoto::IsEnded() if ( m_phase == TGP_BEAMWCOLD ) // expects cool reactor? { if ( m_altitude != 0.0f && - m_physics->RetReactorRange() < 1.0f ) return ERR_CONTINUE; + m_physics->GetReactorRange() < 1.0f ) return ERR_CONTINUE; m_phase = TGP_BEAMUP; } if ( m_phase == TGP_BEAMUP ) // off? { - if ( m_physics->RetType() == TYPE_FLYING && m_altitude > 0.0f ) + if ( m_physics->GetType() == TYPE_FLYING && m_altitude > 0.0f ) { - level = m_terrain->RetFloorLevel(pos, true, true); + level = m_terrain->GetFloorLevel(pos, true, true); h = level+m_altitude-20.0f; - limit = m_terrain->RetFlyingMaxHeight(); + limit = m_terrain->GetFlyingMaxHeight(); if ( h > limit ) h = limit; if ( pos.y < h-1.0f ) return ERR_CONTINUE; @@ -836,7 +800,7 @@ Error CTaskGoto::IsEnded() if ( m_phase == TGP_BEAMGOTO ) // goto dot list ? { if ( m_altitude != 0.0f && - m_physics->RetReactorRange() < 0.1f ) // overheating? + m_physics->GetReactorRange() < 0.1f ) // overheating? { m_physics->SetMotorSpeedX(0.0f); // stops the advance m_physics->SetMotorSpeedZ(0.0f); // stops the rotation @@ -845,7 +809,7 @@ Error CTaskGoto::IsEnded() return ERR_CONTINUE; } - if ( m_physics->RetLand() ) // on the ground? + if ( m_physics->GetLand() ) // on the ground? { limit = 1.0f; } @@ -873,9 +837,9 @@ Error CTaskGoto::IsEnded() if ( m_phase == TGP_BEAMDOWN ) // landed? { - if ( m_physics->RetType() == TYPE_FLYING && m_altitude > 0.0f ) + if ( m_physics->GetType() == TYPE_FLYING && m_altitude > 0.0f ) { - if ( !m_physics->RetLand() ) return ERR_CONTINUE; + if ( !m_physics->GetLand() ) return ERR_CONTINUE; m_physics->SetMotorSpeedY(0.0f); // stops the descent m_altitude = 0.0f; @@ -909,7 +873,7 @@ Error CTaskGoto::IsEnded() if ( m_phase == TGP_ADVANCE ) // going towards the goal? { - if ( m_physics->RetLand() ) limit = 0.1f; // on the ground + if ( m_physics->GetLand() ) limit = 0.1f; // on the ground else limit = 1.0f; // flying if ( m_bApprox ) limit = 2.0f; @@ -924,9 +888,9 @@ Error CTaskGoto::IsEnded() if ( m_phase == TGP_LAND ) // landed? { - if ( m_physics->RetType() == TYPE_FLYING && m_altitude > 0.0f ) + if ( m_physics->GetType() == TYPE_FLYING && m_altitude > 0.0f ) { - if ( !m_physics->RetLand() ) return ERR_CONTINUE; + if ( !m_physics->GetLand() ) return ERR_CONTINUE; m_physics->SetMotorSpeedY(0.0f); } @@ -943,7 +907,7 @@ Error CTaskGoto::IsEnded() if ( m_phase == TGP_TURN ) // turns to the object? { - angle = Math::NormAngle(m_object->RetAngleY(0)); + angle = Math::NormAngle(m_object->GetAngleY(0)); limit = 0.02f; if ( m_bApprox ) limit = 0.10f; if ( fabs(angle-m_angle) < limit ) @@ -951,9 +915,9 @@ Error CTaskGoto::IsEnded() m_physics->SetMotorSpeedZ(0.0f); // stops the rotation if ( m_bmFinalMove == 0.0f ) return ERR_STOP; - m_bmFinalPos = m_object->RetPosition(0); - m_bmFinalDist = m_physics->RetLinLength(m_bmFinalMove); - m_bmTimeLimit = m_physics->RetLinTimeLength(fabs(m_bmFinalMove))*1.5f; + m_bmFinalPos = m_object->GetPosition(0); + m_bmFinalDist = m_physics->GetLinLength(m_bmFinalMove); + m_bmTimeLimit = m_physics->GetLinTimeLength(fabs(m_bmFinalMove))*1.5f; if ( m_bmTimeLimit < 0.5f ) m_bmTimeLimit = 0.5f; m_phase = TGP_MOVE; } @@ -973,7 +937,7 @@ Error CTaskGoto::IsEnded() if ( m_crashMode == TGC_RIGHTLEFT || m_crashMode == TGC_RIGHT ) angle = Math::PI/2.0f; // 90 deegres to the right else angle = -Math::PI/2.0f; // 90 deegres to the left - m_angle = Math::NormAngle(m_object->RetAngleY(0)+angle); + m_angle = Math::NormAngle(m_object->GetAngleY(0)+angle); m_phase = TGP_CRTURN; //? m_phase = TGP_ADVANCE; } @@ -981,7 +945,7 @@ Error CTaskGoto::IsEnded() if ( m_phase == TGP_CRTURN ) // turns after collision? { - angle = Math::NormAngle(m_object->RetAngleY(0)); + angle = Math::NormAngle(m_object->GetAngleY(0)); limit = 0.1f; if ( fabs(angle-m_angle) < limit ) { @@ -1007,14 +971,14 @@ Error CTaskGoto::IsEnded() if ( m_crashMode == TGC_LEFTRIGHT ) angle = Math::PI; if ( m_crashMode == TGC_RIGHT ) angle = Math::PI/2.0f; if ( m_crashMode == TGC_LEFT ) angle = -Math::PI/2.0f; - m_angle = Math::NormAngle(m_object->RetAngleY(0)+angle); + m_angle = Math::NormAngle(m_object->GetAngleY(0)+angle); m_phase = TGP_CLTURN; } } if ( m_phase == TGP_CLTURN ) // turns after collision? { - angle = Math::NormAngle(m_object->RetAngleY(0)); + angle = Math::NormAngle(m_object->GetAngleY(0)); limit = 0.1f; if ( fabs(angle-m_angle) < limit ) { @@ -1042,7 +1006,7 @@ Error CTaskGoto::IsEnded() return ERR_STOP; } - dist = Math::Distance(m_bmFinalPos, m_object->RetPosition(0)); + dist = Math::Distance(m_bmFinalPos, m_object->GetPosition(0)); if ( dist < m_bmFinalDist ) return ERR_CONTINUE; m_physics->SetMotorSpeedX(0.0f); // stops the advance return ERR_STOP; @@ -1065,13 +1029,13 @@ CObject* CTaskGoto::SearchTarget(Math::Vector pos, float margin) min = 1000000.0f; for ( i=0 ; i<1000000 ; i++ ) { - pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i); + pObj = static_cast(m_iMan->SearchInstance(CLASS_OBJECT, i)); if ( pObj == 0 ) break; - if ( !pObj->RetActif() ) continue; - if ( pObj->RetTruck() != 0 ) continue; // object transtorted? + if ( !pObj->GetActif() ) continue; + if ( pObj->GetTruck() != 0 ) continue; // object transtorted? - oPos = pObj->RetPosition(0); + oPos = pObj->GetPosition(0); dist = Math::DistanceProjected(pos, oPos); if ( dist <= margin && dist <= min ) @@ -1095,15 +1059,15 @@ bool CTaskGoto::AdjustTarget(CObject* pObj, Math::Vector &pos, float &distance) Math::Vector goal; float dist, suppl; - type = m_object->RetType(); + type = m_object->GetType(); if ( type == OBJECT_BEE || type == OBJECT_WORM ) { - pos = pObj->RetPosition(0); + pos = pObj->GetPosition(0); return false; // single approach } - type = pObj->RetType(); + type = pObj->GetType(); if ( type == OBJECT_FRET || type == OBJECT_STONE || @@ -1131,8 +1095,8 @@ bool CTaskGoto::AdjustTarget(CObject* pObj, Math::Vector &pos, float &distance) type == OBJECT_RUINmobiler1 || type == OBJECT_RUINmobiler2 ) { - pos = m_object->RetPosition(0); - goal = pObj->RetPosition(0); + pos = m_object->GetPosition(0); + goal = pObj->GetPosition(0); dist = Math::Distance(goal, pos); pos = (pos-goal)*(TAKE_DIST+distance)/dist + goal; return true; // approach from all sites @@ -1140,8 +1104,8 @@ bool CTaskGoto::AdjustTarget(CObject* pObj, Math::Vector &pos, float &distance) if ( type == OBJECT_BASE ) { - pos = m_object->RetPosition(0); - goal = pObj->RetPosition(0); + pos = m_object->GetPosition(0); + goal = pObj->GetPosition(0); dist = Math::Distance(goal, pos); pos = (pos-goal)*(TAKE_DIST+distance)/dist + goal; return true; // approach from all sites @@ -1175,10 +1139,10 @@ bool CTaskGoto::AdjustTarget(CObject* pObj, Math::Vector &pos, float &distance) type == OBJECT_MOBILEit || type == OBJECT_MOBILEdr ) { - character = pObj->RetCharacter(); + character = pObj->GetCharacter(); pos = character->posPower; pos.x -= TAKE_DIST+TAKE_DIST_OTHER+distance; - mat = pObj->RetWorldMatrix(0); + mat = pObj->GetWorldMatrix(0); pos = Transform(*mat, pos); return false; // single approach } @@ -1190,7 +1154,7 @@ bool CTaskGoto::AdjustTarget(CObject* pObj, Math::Vector &pos, float &distance) return false; // single approach } - pos = pObj->RetPosition(0); + pos = pObj->GetPosition(0); distance = 0.0f; return false; // single approach } @@ -1207,11 +1171,11 @@ bool CTaskGoto::AdjustBuilding(Math::Vector &pos, float margin, float &distance) for ( i=0 ; i<1000000 ; i++ ) { - pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i); + pObj = static_cast(m_iMan->SearchInstance(CLASS_OBJECT, i)); if ( pObj == 0 ) break; - if ( !pObj->RetActif() ) continue; - if ( pObj->RetTruck() != 0 ) continue; // object transported? + if ( !pObj->GetActif() ) continue; + if ( pObj->GetTruck() != 0 ) continue; // object transported? if ( !GetHotPoint(pObj, oPos, false, 0.0f, suppl) ) continue; dist = Math::DistanceProjected(pos, oPos); @@ -1235,11 +1199,11 @@ bool CTaskGoto::GetHotPoint(CObject *pObj, Math::Vector &pos, pos = Math::Vector(0.0f, 0.0f, 0.0f); suppl = 0.0f; - type = pObj->RetType(); + type = pObj->GetType(); if ( type == OBJECT_DERRICK ) { - mat = pObj->RetWorldMatrix(0); + mat = pObj->GetWorldMatrix(0); pos.x += 8.0f; if ( bTake && distance != 0.0f ) suppl = 4.0f; if ( bTake ) pos.x += TAKE_DIST+distance+suppl; @@ -1249,7 +1213,7 @@ bool CTaskGoto::GetHotPoint(CObject *pObj, Math::Vector &pos, if ( type == OBJECT_CONVERT ) { - mat = pObj->RetWorldMatrix(0); + mat = pObj->GetWorldMatrix(0); pos.x += 0.0f; if ( bTake && distance != 0.0f ) suppl = 4.0f; if ( bTake ) pos.x += TAKE_DIST+distance+suppl; @@ -1259,7 +1223,7 @@ bool CTaskGoto::GetHotPoint(CObject *pObj, Math::Vector &pos, if ( type == OBJECT_RESEARCH ) { - mat = pObj->RetWorldMatrix(0); + mat = pObj->GetWorldMatrix(0); pos.x += 10.0f; if ( bTake && distance != 0.0f ) suppl = 2.5f; if ( bTake ) pos.x += TAKE_DIST+TAKE_DIST_OTHER+distance+suppl; @@ -1269,7 +1233,7 @@ bool CTaskGoto::GetHotPoint(CObject *pObj, Math::Vector &pos, if ( type == OBJECT_ENERGY ) { - mat = pObj->RetWorldMatrix(0); + mat = pObj->GetWorldMatrix(0); pos.x += 6.0f; if ( bTake && distance != 0.0f ) suppl = 6.0f; if ( bTake ) pos.x += TAKE_DIST+TAKE_DIST_OTHER+distance; @@ -1279,7 +1243,7 @@ bool CTaskGoto::GetHotPoint(CObject *pObj, Math::Vector &pos, if ( type == OBJECT_TOWER ) { - mat = pObj->RetWorldMatrix(0); + mat = pObj->GetWorldMatrix(0); pos.x += 5.0f; if ( bTake && distance != 0.0f ) suppl = 4.0f; if ( bTake ) pos.x += TAKE_DIST+TAKE_DIST_OTHER+distance+suppl; @@ -1289,7 +1253,7 @@ bool CTaskGoto::GetHotPoint(CObject *pObj, Math::Vector &pos, if ( type == OBJECT_LABO ) { - mat = pObj->RetWorldMatrix(0); + mat = pObj->GetWorldMatrix(0); pos.x += 6.0f; if ( bTake && distance != 0.0f ) suppl = 6.0f; if ( bTake ) pos.x += TAKE_DIST+TAKE_DIST_OTHER+distance; @@ -1299,7 +1263,7 @@ bool CTaskGoto::GetHotPoint(CObject *pObj, Math::Vector &pos, if ( type == OBJECT_NUCLEAR ) { - mat = pObj->RetWorldMatrix(0); + mat = pObj->GetWorldMatrix(0); pos.x += 22.0f; if ( bTake && distance != 0.0f ) suppl = 4.0f; if ( bTake ) pos.x += TAKE_DIST+TAKE_DIST_OTHER+distance+suppl; @@ -1309,7 +1273,7 @@ bool CTaskGoto::GetHotPoint(CObject *pObj, Math::Vector &pos, if ( type == OBJECT_FACTORY ) { - mat = pObj->RetWorldMatrix(0); + mat = pObj->GetWorldMatrix(0); pos.x += 4.0f; if ( bTake && distance != 0.0f ) suppl = 6.0f; if ( bTake ) pos.x += TAKE_DIST+distance+suppl; @@ -1319,7 +1283,7 @@ bool CTaskGoto::GetHotPoint(CObject *pObj, Math::Vector &pos, if ( type == OBJECT_STATION ) { - mat = pObj->RetWorldMatrix(0); + mat = pObj->GetWorldMatrix(0); pos.x += 4.0f; if ( bTake && distance != 0.0f ) suppl = 4.0f; if ( bTake ) pos.x += distance; @@ -1329,7 +1293,7 @@ bool CTaskGoto::GetHotPoint(CObject *pObj, Math::Vector &pos, if ( type == OBJECT_REPAIR ) { - mat = pObj->RetWorldMatrix(0); + mat = pObj->GetWorldMatrix(0); pos.x += 4.0f; if ( bTake && distance != 0.0f ) suppl = 4.0f; if ( bTake ) pos.x += distance; @@ -1339,7 +1303,7 @@ bool CTaskGoto::GetHotPoint(CObject *pObj, Math::Vector &pos, if ( type == OBJECT_DESTROYER ) { - mat = pObj->RetWorldMatrix(0); + mat = pObj->GetWorldMatrix(0); pos.x += 0.0f; if ( bTake && distance != 0.0f ) suppl = 4.0f; if ( bTake ) pos.x += TAKE_DIST+distance+suppl; @@ -1347,9 +1311,9 @@ bool CTaskGoto::GetHotPoint(CObject *pObj, Math::Vector &pos, return true; } - if ( type == OBJECT_PARA && m_physics->RetType() == TYPE_FLYING ) + if ( type == OBJECT_PARA && m_physics->GetType() == TYPE_FLYING ) { - mat = pObj->RetWorldMatrix(0); + mat = pObj->GetWorldMatrix(0); if ( bTake && distance != 0.0f ) suppl = 20.0f; if ( bTake ) pos.x += distance+suppl; pos = Transform(*mat, pos); @@ -1370,7 +1334,7 @@ bool CTaskGoto::LeakSearch(Math::Vector &pos, float &delay) float iRadius, oRadius, bRadius, dist, min, dir; int i, j; - if ( !m_physics->RetLand() ) return false; // in flight? + if ( !m_physics->GetLand() ) return false; // in flight? m_object->GetCrashSphere(0, iPos, iRadius); @@ -1378,12 +1342,12 @@ bool CTaskGoto::LeakSearch(Math::Vector &pos, float &delay) bRadius = 0.0f; for ( i=0 ; i<1000000 ; i++ ) { - pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i); + pObj = static_cast(m_iMan->SearchInstance(CLASS_OBJECT, i)); if ( pObj == 0 ) break; if ( pObj == m_object ) continue; - if ( !pObj->RetActif() ) continue; - if ( pObj->RetTruck() != 0 ) continue; // object transported? + if ( !pObj->GetActif() ) continue; + if ( pObj->GetTruck() != 0 ) continue; // object transported? j = 0; while ( pObj->GetCrashSphere(j++, oPos, oRadius) ) @@ -1404,7 +1368,7 @@ bool CTaskGoto::LeakSearch(Math::Vector &pos, float &delay) dist = 4.0f; dir = 1.0f; - if ( pObstacle->RetType() == OBJECT_FACTORY ) + if ( pObstacle->GetType() == OBJECT_FACTORY ) { dist = 16.0f; dir = -1.0f; @@ -1412,7 +1376,7 @@ bool CTaskGoto::LeakSearch(Math::Vector &pos, float &delay) } pos = bPos; - delay = m_physics->RetLinTimeLength(dist, dir); + delay = m_physics->GetLinTimeLength(dist, dir); return true; } @@ -1436,18 +1400,18 @@ void CTaskGoto::ComputeRepulse(Math::Point &dir) for ( i=0 ; i<1000000 ; i++ ) { - pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i); + pObj = static_cast(m_iMan->SearchInstance(CLASS_OBJECT, i)); if ( pObj == 0 ) break; if ( pObj == m_object ) continue; - if ( pObj->RetTruck() != 0 ) continue; + if ( pObj->GetTruck() != 0 ) continue; - oPos = pObj->RetPosition(0); + oPos = pObj->GetPosition(0); dist = Math::Distance(oPos, m_goalObject); if ( dist <= 1.0f ) continue; pObj->GetGlobalSphere(oPos, oRadius); - oRadius += iRadius+m_physics->RetLinStopLength()*1.1f; + oRadius += iRadius+m_physics->GetLinStopLength()*1.1f; dist = Math::DistanceProjected(oPos, iPos); if ( dist <= oRadius ) { @@ -1479,13 +1443,13 @@ void CTaskGoto::ComputeRepulse(Math::Point &dir) dir.y = 0.0f; // The worm goes everywhere and through everything! - iType = m_object->RetType(); + iType = m_object->GetType(); if ( iType == OBJECT_WORM ) return; m_object->GetCrashSphere(0, iPos, iRadius); gDist = Math::Distance(iPos, m_goal); - add = m_physics->RetLinStopLength()*1.1f; // braking distance + add = m_physics->GetLinStopLength()*1.1f; // braking distance fac = 2.0f; if ( iType == OBJECT_MOBILEwa || @@ -1513,7 +1477,7 @@ void CTaskGoto::ComputeRepulse(Math::Point &dir) iType == OBJECT_MOBILEfs || iType == OBJECT_MOBILEft ) // flying? { - if ( m_physics->RetLand() ) + if ( m_physics->GetLand() ) { add = 5.0f; fac = 1.5f; @@ -1535,7 +1499,7 @@ void CTaskGoto::ComputeRepulse(Math::Point &dir) } if ( iType == OBJECT_BEE ) // wasp? { - if ( m_physics->RetLand() ) + if ( m_physics->GetLand() ) { add = 3.0f; fac = 1.5f; @@ -1559,13 +1523,13 @@ void CTaskGoto::ComputeRepulse(Math::Point &dir) for ( i=0 ; i<1000000 ; i++ ) { - pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i); + pObj = static_cast(m_iMan->SearchInstance(CLASS_OBJECT, i)); if ( pObj == 0 ) break; if ( pObj == m_object ) continue; - if ( pObj->RetTruck() != 0 ) continue; + if ( pObj->GetTruck() != 0 ) continue; - oType = pObj->RetType(); + oType = pObj->GetType(); if ( oType == OBJECT_WORM ) continue; @@ -1651,13 +1615,13 @@ void CTaskGoto::ComputeFlyingRepulse(float &dir) for ( i=0 ; i<1000000 ; i++ ) { - pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i); + pObj = static_cast(m_iMan->SearchInstance(CLASS_OBJECT, i)); if ( pObj == 0 ) break; if ( pObj == m_object ) continue; - if ( pObj->RetTruck() != 0 ) continue; + if ( pObj->GetTruck() != 0 ) continue; - oType = pObj->RetType(); + oType = pObj->GetType(); if ( oType == OBJECT_WORM ) continue; @@ -1712,7 +1676,7 @@ void CTaskGoto::BeamStart() BitmapOpen(); BitmapObject(); - min = m_object->RetPosition(0); + min = m_object->GetPosition(0); max = m_goal; if ( min.x > max.x ) Math::Swap(min.x, max.x); if ( min.z > max.z ) Math::Swap(min.z, max.z); @@ -1890,84 +1854,6 @@ Math::Vector CTaskGoto::BeamPoint(const Math::Vector &startPoint, return resPoint; } -// Displays a bitmap part. - -void CTaskGoto::BitmapDebug(const Math::Vector &min, const Math::Vector &max, - const Math::Vector &start, const Math::Vector &goal) -{ - int minx, miny, maxx, maxy, x, y, i ,n; - char s[2000]; - - minx = (int)((min.x+1600.0f)/BM_DIM_STEP); - miny = (int)((min.z+1600.0f)/BM_DIM_STEP); - maxx = (int)((max.x+1600.0f)/BM_DIM_STEP); - maxy = (int)((max.z+1600.0f)/BM_DIM_STEP); - - if ( minx > maxx ) Math::Swap(minx, maxx); - if ( miny > maxy ) Math::Swap(miny, maxy); - - OutputDebugString("Bitmap :\n"); - for ( y=miny ; y<=maxy ; y++ ) - { - s[0] = 0; - for ( x=minx ; x<=maxx ; x++ ) - { - n = -1; - for ( i=0 ; i<=m_bmTotal ; i++ ) - { - if ( x == (int)((m_bmPoints[i].x+1600.0f)/BM_DIM_STEP) && - y == (int)((m_bmPoints[i].z+1600.0f)/BM_DIM_STEP) ) - { - n = i; - break; - } - } - - if ( BitmapTestDot(0, x,y) ) - { - strcat(s, "o"); - } - else - { - if ( BitmapTestDot(1, x,y) ) - { - strcat(s, "-"); - } - else - { - strcat(s, "."); - } - } - - if ( x == (int)((start.x+1600.0f)/BM_DIM_STEP) && - y == (int)((start.z+1600.0f)/BM_DIM_STEP) ) - { - strcat(s, "s"); - } - else - if ( x == (int)((goal.x+1600.0f)/BM_DIM_STEP) && - y == (int)((goal.z+1600.0f)/BM_DIM_STEP) ) - { - strcat(s, "g"); - } - else - if ( n != -1 ) - { - char ss[2]; - ss[0] = 'A'+n; - ss[1] = 0; - strcat(s, ss); - } - else - { - strcat(s, " "); - } - } - strcat(s, "\n"); - OutputDebugString(s); - } -} - // Tests if a path along a straight line is possible. bool CTaskGoto::BitmapTestLine(const Math::Vector &start, const Math::Vector &goal, @@ -1991,12 +1877,12 @@ bool CTaskGoto::BitmapTestLine(const Math::Vector &start, const Math::Vector &go if ( bSecond ) { - x = (int)((pos.x+1600.0f)/BM_DIM_STEP); - y = (int)((pos.z+1600.0f)/BM_DIM_STEP); + x = static_cast((pos.x+1600.0f)/BM_DIM_STEP); + y = static_cast((pos.z+1600.0f)/BM_DIM_STEP); BitmapSetDot(1, x, y); // puts the flag as the starting point } - max = (int)(dist/step); + max = static_cast(dist/step); if ( max == 0 ) max = 1; distNoB2 = BM_DIM_STEP*sqrtf(2.0f)/sinf(stepAngle); for ( i=0 ; i((pos.x+1600.0f)/BM_DIM_STEP); + y = static_cast((pos.z+1600.0f)/BM_DIM_STEP); if ( bSecond ) { @@ -2043,17 +1929,17 @@ void CTaskGoto::BitmapObject() for ( i=0 ; i<1000000 ; i++ ) { - pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i); + pObj = static_cast(m_iMan->SearchInstance(CLASS_OBJECT, i)); if ( pObj == 0 ) break; - type = pObj->RetType(); + type = pObj->GetType(); if ( pObj == m_object ) continue; if ( pObj == m_bmFretObject ) continue; - if ( pObj->RetTruck() != 0 ) continue; + if ( pObj->GetTruck() != 0 ) continue; - h = m_terrain->RetFloorLevel(pObj->RetPosition(0), false); - if ( m_physics->RetType() == TYPE_FLYING && m_altitude > 0.0f ) + h = m_terrain->GetFloorLevel(pObj->GetPosition(0), false); + if ( m_physics->GetType() == TYPE_FLYING && m_altitude > 0.0f ) { h += m_altitude; } @@ -2061,7 +1947,7 @@ void CTaskGoto::BitmapObject() j = 0; while ( pObj->GetCrashSphere(j++, oPos, oRadius) ) { - if ( m_physics->RetType() == TYPE_FLYING && m_altitude > 0.0f ) // flying? + if ( m_physics->GetType() == TYPE_FLYING && m_altitude > 0.0f ) // flying? { if ( oPos.y-oRadius > h+8.0f || oPos.y+oRadius < h-8.0f ) continue; @@ -2083,10 +1969,10 @@ void CTaskGoto::BitmapTerrain(const Math::Vector &min, const Math::Vector &max) { int minx, miny, maxx, maxy; - minx = (int)((min.x+1600.0f)/BM_DIM_STEP); - miny = (int)((min.z+1600.0f)/BM_DIM_STEP); - maxx = (int)((max.x+1600.0f)/BM_DIM_STEP); - maxy = (int)((max.z+1600.0f)/BM_DIM_STEP); + minx = static_cast((min.x+1600.0f)/BM_DIM_STEP); + miny = static_cast((min.z+1600.0f)/BM_DIM_STEP); + maxx = static_cast((max.x+1600.0f)/BM_DIM_STEP); + maxy = static_cast((max.z+1600.0f)/BM_DIM_STEP); BitmapTerrain(minx, miny, maxx, maxy); } @@ -2121,7 +2007,7 @@ void CTaskGoto::BitmapTerrain(int minx, int miny, int maxx, int maxy) bAcceptWater = false; bFly = false; - type = m_object->RetType(); + type = m_object->GetType(); if ( type == OBJECT_MOBILEwa || type == OBJECT_MOBILEwc || @@ -2190,8 +2076,8 @@ void CTaskGoto::BitmapTerrain(int minx, int miny, int maxx, int maxy) if ( bFly ) // flying robot? { - h = m_terrain->RetFloorLevel(p, true); - if ( h >= m_terrain->RetFlyingMaxHeight()-5.0f ) + h = m_terrain->GetFloorLevel(p, true); + if ( h >= m_terrain->GetFlyingMaxHeight()-5.0f ) { BitmapSetDot(0, x, y); } @@ -2200,8 +2086,8 @@ void CTaskGoto::BitmapTerrain(int minx, int miny, int maxx, int maxy) if ( !bAcceptWater ) // not going underwater? { - h = m_terrain->RetFloorLevel(p, true); - if ( h < m_water->RetLevel()-2.0f ) // under water (*)? + h = m_terrain->GetFloorLevel(p, true); + if ( h < m_water->GetLevel()-2.0f ) // under water (*)? { //? BitmapSetDot(0, x, y); BitmapSetCircle(p, BM_DIM_STEP*1.0f); @@ -2209,7 +2095,7 @@ void CTaskGoto::BitmapTerrain(int minx, int miny, int maxx, int maxy) } } - angle = m_terrain->RetFineSlope(p); + angle = m_terrain->GetFineSlope(p); if ( angle > aLimit ) { BitmapSetDot(0, x, y); @@ -2231,9 +2117,9 @@ bool CTaskGoto::BitmapOpen() { BitmapClose(); - m_bmSize = (int)(3200.0f/BM_DIM_STEP); - m_bmArray = (unsigned char*)malloc(m_bmSize*m_bmSize/8*2); - ZeroMemory(m_bmArray, m_bmSize*m_bmSize/8*2); + m_bmSize = static_cast(3200.0f/BM_DIM_STEP); + m_bmArray = static_cast(malloc(m_bmSize*m_bmSize/8*2)); + memset(m_bmArray, 0, m_bmSize*m_bmSize/8*2); m_bmOffset = m_bmSize/2; m_bmLine = m_bmSize/8; @@ -2262,15 +2148,15 @@ void CTaskGoto::BitmapSetCircle(const Math::Vector &pos, float radius) float d, r; int cx, cy, ix, iy; - cx = (int)((pos.x+1600.0f)/BM_DIM_STEP); - cy = (int)((pos.z+1600.0f)/BM_DIM_STEP); + cx = static_cast((pos.x+1600.0f)/BM_DIM_STEP); + cy = static_cast((pos.z+1600.0f)/BM_DIM_STEP); r = radius/BM_DIM_STEP; - for ( iy=cy-(int)r ; iy<=cy+(int)r ; iy++ ) + for ( iy=cy-static_cast(r) ; iy<=cy+static_cast(r) ; iy++ ) { - for ( ix=cx-(int)r ; ix<=cx+(int)r ; ix++ ) + for ( ix=cx-static_cast(r) ; ix<=cx+static_cast(r) ; ix++ ) { - d = Math::Point((float)(ix-cx), (float)(iy-cy)).Length(); + d = Math::Point(static_cast(ix-cx), static_cast(iy-cy)).Length(); if ( d > r ) continue; BitmapSetDot(0, ix, iy); } @@ -2278,21 +2164,21 @@ void CTaskGoto::BitmapSetCircle(const Math::Vector &pos, float radius) } // Removes a circle in the bitmap. - +//TODO this method is almost same as above one void CTaskGoto::BitmapClearCircle(const Math::Vector &pos, float radius) { float d, r; int cx, cy, ix, iy; - cx = (int)((pos.x+1600.0f)/BM_DIM_STEP); - cy = (int)((pos.z+1600.0f)/BM_DIM_STEP); + cx = static_cast((pos.x+1600.0f)/BM_DIM_STEP); + cy = static_cast((pos.z+1600.0f)/BM_DIM_STEP); r = radius/BM_DIM_STEP; - for ( iy=cy-(int)r ; iy<=cy+(int)r ; iy++ ) + for ( iy=cy-static_cast(r) ; iy<=cy+static_cast(r) ; iy++ ) { - for ( ix=cx-(int)r ; ix<=cx+(int)r ; ix++ ) + for ( ix=cx-static_cast(r) ; ix<=cx+static_cast(r) ; ix++ ) { - d = Math::Point((float)(ix-cx), (float)(iy-cy)).Length(); + d = Math::Point(static_cast(ix-cx), static_cast(iy-cy)).Length(); if ( d > r ) continue; BitmapClearDot(0, ix, iy); } diff --git a/src/object/task/taskgungoal.cpp b/src/object/task/taskgungoal.cpp index e259ca8..aed3355 100644 --- a/src/object/task/taskgungoal.cpp +++ b/src/object/task/taskgungoal.cpp @@ -16,9 +16,6 @@ // taskgungoal.cpp - -#include - #include "object/task/taskgungoal.h" #include "object/object.h" @@ -46,8 +43,8 @@ bool CTaskGunGoal::EventProcess(const Event &event) { float dir; - if ( m_engine->RetPause() ) return true; - if ( event.event != EVENT_FRAME ) return true; + if ( m_engine->GetPause() ) return true; + if ( event.type != EVENT_FRAME ) return true; m_progress += event.rTime*m_speed; @@ -82,9 +79,9 @@ Error CTaskGunGoal::Start(float dirV, float dirH) float speedV, speedH; int i; - m_initialDirV = m_object->RetGunGoalV(); + m_initialDirV = m_object->GetGunGoalV(); m_object->SetGunGoalV(dirV); - m_finalDirV = m_object->RetGunGoalV(); // possible direction + m_finalDirV = m_object->GetGunGoalV(); // possible direction m_object->SetGunGoalV(m_initialDirV); // gives initial direction if ( m_finalDirV == m_initialDirV ) @@ -96,9 +93,9 @@ Error CTaskGunGoal::Start(float dirV, float dirH) speedV = 1.0f/(fabs(m_finalDirV-m_initialDirV)*1.0f); } - m_initialDirH = m_object->RetGunGoalH(); + m_initialDirH = m_object->GetGunGoalH(); m_object->SetGunGoalH(dirH); - m_finalDirH = m_object->RetGunGoalH(); // possible direction + m_finalDirH = m_object->GetGunGoalH(); // possible direction m_object->SetGunGoalH(m_initialDirH); // gives initial direction if ( m_finalDirH == m_initialDirH ) @@ -115,7 +112,7 @@ Error CTaskGunGoal::Start(float dirV, float dirH) if ( m_finalDirV != m_initialDirV || m_finalDirH != m_initialDirH ) { - i = m_sound->Play(SOUND_MANIP, m_object->RetPosition(0), 0.3f, 1.5f, true); + i = m_sound->Play(SOUND_MANIP, m_object->GetPosition(0), 0.3f, 1.5f, true); m_sound->AddEnvelope(i, 0.3f, 1.5f, 1.0f/m_speed, SOPER_STOP); } @@ -128,7 +125,7 @@ Error CTaskGunGoal::Start(float dirV, float dirH) Error CTaskGunGoal::IsEnded() { - if ( m_engine->RetPause() ) return ERR_CONTINUE; + if ( m_engine->GetPause() ) return ERR_CONTINUE; if ( m_initialDirV == m_finalDirV && m_initialDirH == m_finalDirH ) return ERR_STOP; diff --git a/src/object/task/taskinfo.cpp b/src/object/task/taskinfo.cpp index 6d1f486..ab81d23 100644 --- a/src/object/task/taskinfo.cpp +++ b/src/object/task/taskinfo.cpp @@ -16,13 +16,10 @@ // taskinfo.cpp - -#include - #include "object/task/taskinfo.h" #include "common/iman.h" -#include "old/particule.h" +#include "graphics/engine/particle.h" #include "object/auto/autoinfo.h" @@ -47,8 +44,8 @@ CTaskInfo::~CTaskInfo() bool CTaskInfo::EventProcess(const Event &event) { - if ( m_engine->RetPause() ) return true; - if ( event.event != EVENT_FRAME ) return true; + if ( m_engine->GetPause() ) return true; + if ( event.type != EVENT_FRAME ) return true; if ( m_bError ) return false; m_progress += event.rTime*m_speed; // other advance @@ -60,7 +57,7 @@ bool CTaskInfo::EventProcess(const Event &event) // Assigns the goal was achieved. -Error CTaskInfo::Start(char *name, float value, float power, bool bSend) +Error CTaskInfo::Start(const char *name, float value, float power, bool bSend) { CObject* pInfo; CAutoInfo* pAuto; @@ -77,7 +74,7 @@ Error CTaskInfo::Start(char *name, float value, float power, bool bSend) return ERR_INFO_NULL; } - pAuto = (CAutoInfo*)pInfo->RetAuto(); + pAuto = static_cast(pInfo->GetAuto()); if ( pAuto == 0 ) { return ERR_INFO_NULL; @@ -86,10 +83,10 @@ Error CTaskInfo::Start(char *name, float value, float power, bool bSend) op = 1; // transmission impossible if ( bSend ) // send? { - total = pInfo->RetInfoTotal(); + total = pInfo->GetInfoTotal(); for ( i=0 ; iRetInfo(i); + info = pInfo->GetInfo(i); if ( strcmp(info.name, name) == 0 ) { info.value = value; @@ -114,10 +111,10 @@ Error CTaskInfo::Start(char *name, float value, float power, bool bSend) } else // receive? { - total = pInfo->RetInfoTotal(); + total = pInfo->GetInfoTotal(); for ( i=0 ; iRetInfo(i); + info = pInfo->GetInfo(i); if ( strcmp(info.name, name) == 0 ) { m_object->SetInfoReturn(info.value); @@ -134,19 +131,19 @@ Error CTaskInfo::Start(char *name, float value, float power, bool bSend) if ( op == 0 ) // transmission? { - pos = pInfo->RetPosition(0); + pos = pInfo->GetPosition(0); pos.y += 9.5f; - goal = m_object->RetPosition(0); + goal = m_object->GetPosition(0); goal.y += 4.0f; - m_particule->CreateRay(pos, goal, PARTIRAY3, Math::Point(2.0f, 2.0f), 1.0f); + m_particle->CreateRay(pos, goal, Gfx::PARTIRAY3, Math::Point(2.0f, 2.0f), 1.0f); } if ( op == 2 ) // reception? { - goal = pInfo->RetPosition(0); + goal = pInfo->GetPosition(0); goal.y += 9.5f; - pos = m_object->RetPosition(0); + pos = m_object->GetPosition(0); pos.y += 4.0f; - m_particule->CreateRay(pos, goal, PARTIRAY3, Math::Point(2.0f, 2.0f), 1.0f); + m_particle->CreateRay(pos, goal, Gfx::PARTIRAY3, Math::Point(2.0f, 2.0f), 1.0f); } m_progress = 0.0f; @@ -162,7 +159,7 @@ Error CTaskInfo::Start(char *name, float value, float power, bool bSend) Error CTaskInfo::IsEnded() { - if ( m_engine->RetPause() ) return ERR_CONTINUE; + if ( m_engine->GetPause() ) return ERR_CONTINUE; if ( m_bError ) return ERR_STOP; if ( m_progress < 1.0f ) return ERR_CONTINUE; @@ -184,27 +181,27 @@ bool CTaskInfo::Abort() CObject* CTaskInfo::SearchInfo(float power) { - CObject *pObj, *pBest; - Math::Vector iPos, oPos; - ObjectType type; - float dist, min; - int i; + CObject *pObj, *pBest; + Math::Vector iPos, oPos; + ObjectType type; + float dist, min; + int i; - iPos = m_object->RetPosition(0); + iPos = m_object->GetPosition(0); min = 100000.0f; pBest = 0; for ( i=0 ; i<1000000 ; i++ ) { - pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i); + pObj = static_cast(m_iMan->SearchInstance(CLASS_OBJECT, i)); if ( pObj == 0 ) break; - type = pObj->RetType(); + type = pObj->GetType(); if ( type != OBJECT_INFO ) continue; - if ( !pObj->RetActif() ) continue; + if ( !pObj->GetActif() ) continue; - oPos = pObj->RetPosition(0); + oPos = pObj->GetPosition(0); dist = Math::Distance(oPos, iPos); if ( dist > power ) continue; // too far? if ( dist < min ) diff --git a/src/object/task/taskinfo.h b/src/object/task/taskinfo.h index 21a4392..036b57d 100644 --- a/src/object/task/taskinfo.h +++ b/src/object/task/taskinfo.h @@ -31,7 +31,7 @@ public: bool EventProcess(const Event &event); - Error Start(char *name, float value, float power, bool bSend); + Error Start(const char *name, float value, float power, bool bSend); Error IsEnded(); bool Abort(); diff --git a/src/object/task/taskmanager.cpp b/src/object/task/taskmanager.cpp index 171be1d..26e389d 100644 --- a/src/object/task/taskmanager.cpp +++ b/src/object/task/taskmanager.cpp @@ -67,7 +67,7 @@ CTaskManager::~CTaskManager() Error CTaskManager::StartTaskWait(float time) { m_task = new CTaskWait(m_iMan, m_object); - return ((CTaskWait*)m_task)->Start(time); + return (static_cast(m_task))->Start(time); } // Advance straight ahead a certain distance. @@ -75,7 +75,7 @@ Error CTaskManager::StartTaskWait(float time) Error CTaskManager::StartTaskAdvance(float length) { m_task = new CTaskAdvance(m_iMan, m_object); - return ((CTaskAdvance*)m_task)->Start(length); + return (static_cast(m_task))->Start(length); } // Turns through an certain angle. @@ -83,7 +83,7 @@ Error CTaskManager::StartTaskAdvance(float length) Error CTaskManager::StartTaskTurn(float angle) { m_task = new CTaskTurn(m_iMan, m_object); - return ((CTaskTurn*)m_task)->Start(angle); + return (static_cast(m_task))->Start(angle); } // Reaches a given position. @@ -91,7 +91,7 @@ Error CTaskManager::StartTaskTurn(float angle) Error CTaskManager::StartTaskGoto(Math::Vector pos, float altitude, TaskGotoGoal goalMode, TaskGotoCrash crashMode) { m_task = new CTaskGoto(m_iMan, m_object); - return ((CTaskGoto*)m_task)->Start(pos, altitude, goalMode, crashMode); + return (static_cast(m_task))->Start(pos, altitude, goalMode, crashMode); } // Move the manipulator arm. @@ -99,7 +99,7 @@ Error CTaskManager::StartTaskGoto(Math::Vector pos, float altitude, TaskGotoGoal Error CTaskManager::StartTaskTake() { m_task = new CTaskTake(m_iMan, m_object); - return ((CTaskTake*)m_task)->Start(); + return (static_cast(m_task))->Start(); } // Move the manipulator arm. @@ -107,7 +107,7 @@ Error CTaskManager::StartTaskTake() Error CTaskManager::StartTaskManip(TaskManipOrder order, TaskManipArm arm) { m_task = new CTaskManip(m_iMan, m_object); - return ((CTaskManip*)m_task)->Start(order, arm); + return (static_cast(m_task))->Start(order, arm); } // Puts or removes a flag. @@ -115,7 +115,7 @@ Error CTaskManager::StartTaskManip(TaskManipOrder order, TaskManipArm arm) Error CTaskManager::StartTaskFlag(TaskFlagOrder order, int rank) { m_task = new CTaskFlag(m_iMan, m_object); - return ((CTaskFlag*)m_task)->Start(order, rank); + return (static_cast(m_task))->Start(order, rank); } // Builds a building. @@ -123,7 +123,7 @@ Error CTaskManager::StartTaskFlag(TaskFlagOrder order, int rank) Error CTaskManager::StartTaskBuild(ObjectType type) { m_task = new CTaskBuild(m_iMan, m_object); - return ((CTaskBuild*)m_task)->Start(type); + return (static_cast(m_task))->Start(type); } // Probe the ground. @@ -131,7 +131,7 @@ Error CTaskManager::StartTaskBuild(ObjectType type) Error CTaskManager::StartTaskSearch() { m_task = new CTaskSearch(m_iMan, m_object); - return ((CTaskSearch*)m_task)->Start(); + return (static_cast(m_task))->Start(); } // Reads an information terminal. @@ -139,7 +139,7 @@ Error CTaskManager::StartTaskSearch() Error CTaskManager::StartTaskInfo(const char *name, float value, float power, bool bSend) { m_task = new CTaskInfo(m_iMan, m_object); - return ((CTaskInfo*)m_task)->Start(name, value, power, bSend); + return (static_cast(m_task))->Start(name, value, power, bSend); } // Terraforms the ground. @@ -147,7 +147,7 @@ Error CTaskManager::StartTaskInfo(const char *name, float value, float power, bo Error CTaskManager::StartTaskTerraform() { m_task = new CTaskTerraform(m_iMan, m_object); - return ((CTaskTerraform*)m_task)->Start(); + return (static_cast(m_task))->Start(); } // Changes the pencil. @@ -155,7 +155,7 @@ Error CTaskManager::StartTaskTerraform() Error CTaskManager::StartTaskPen(bool bDown, int color) { m_task = new CTaskPen(m_iMan, m_object); - return ((CTaskPen*)m_task)->Start(bDown, color); + return (static_cast(m_task))->Start(bDown, color); } // Recovers a ruin. @@ -163,7 +163,7 @@ Error CTaskManager::StartTaskPen(bool bDown, int color) Error CTaskManager::StartTaskRecover() { m_task = new CTaskRecover(m_iMan, m_object); - return ((CTaskRecover*)m_task)->Start(); + return (static_cast(m_task))->Start(); } // Deploys the shield. @@ -173,15 +173,15 @@ Error CTaskManager::StartTaskShield(TaskShieldMode mode, float delay) if ( mode == TSM_UP ) { m_task = new CTaskShield(m_iMan, m_object); - return ((CTaskShield*)m_task)->Start(mode, delay); + return (static_cast(m_task))->Start(mode, delay); } if ( mode == TSM_DOWN && m_task != 0 ) { - return ((CTaskShield*)m_task)->Start(mode, delay); + return (static_cast(m_task))->Start(mode, delay); } if ( mode == TSM_UPDATE && m_task != 0 ) { - return ((CTaskShield*)m_task)->Start(mode, delay); + return (static_cast(m_task))->Start(mode, delay); } return ERR_GENERIC; } @@ -192,7 +192,7 @@ Error CTaskManager::StartTaskFire(float delay) { m_bPilot = true; m_task = new CTaskFire(m_iMan, m_object); - return ((CTaskFire*)m_task)->Start(delay); + return (static_cast(m_task))->Start(delay); } // Shoots with the ant. @@ -200,7 +200,7 @@ Error CTaskManager::StartTaskFire(float delay) Error CTaskManager::StartTaskFireAnt(Math::Vector impact) { m_task = new CTaskFireAnt(m_iMan, m_object); - return ((CTaskFireAnt*)m_task)->Start(impact); + return (static_cast(m_task))->Start(impact); } // Adjusts higher. @@ -208,7 +208,7 @@ Error CTaskManager::StartTaskFireAnt(Math::Vector impact) Error CTaskManager::StartTaskGunGoal(float dirV, float dirH) { m_task = new CTaskGunGoal(m_iMan, m_object); - return ((CTaskGunGoal*)m_task)->Start(dirV, dirH); + return (static_cast(m_task))->Start(dirV, dirH); } // Suicide of the spider. @@ -216,7 +216,7 @@ Error CTaskManager::StartTaskGunGoal(float dirV, float dirH) Error CTaskManager::StartTaskSpiderExplo() { m_task = new CTaskSpiderExplo(m_iMan, m_object); - return ((CTaskSpiderExplo*)m_task)->Start(); + return (static_cast(m_task))->Start(); } // Reset. @@ -224,7 +224,7 @@ Error CTaskManager::StartTaskSpiderExplo() Error CTaskManager::StartTaskReset(Math::Vector goal, Math::Vector angle) { m_task = new CTaskReset(m_iMan, m_object); - return ((CTaskReset*)m_task)->Start(goal, angle); + return (static_cast(m_task))->Start(goal, angle); } diff --git a/src/object/task/taskmanip.cpp b/src/object/task/taskmanip.cpp index 456f274..b0b146c 100644 --- a/src/object/task/taskmanip.cpp +++ b/src/object/task/taskmanip.cpp @@ -16,14 +16,11 @@ // taskmanip.cpp - -#include - #include "object/task/taskmanip.h" #include "common/iman.h" -#include "old/terrain.h" -#include "old/pyro.h" +#include "graphics/engine/terrain.h" +#include "graphics/engine/pyro.h" #include "math/geometry.h" #include "object/robotmain.h" #include "physics/physics.h" @@ -65,8 +62,8 @@ bool CTaskManip::EventProcess(const Event &event) float angle, a, g, cirSpeed, progress; int i; - if ( m_engine->RetPause() ) return true; - if ( event.event != EVENT_FRAME ) return true; + if ( m_engine->GetPause() ) return true; + if ( event.type != EVENT_FRAME ) return true; if ( m_bError ) return false; if ( m_bBee ) // bee? @@ -76,10 +73,10 @@ bool CTaskManip::EventProcess(const Event &event) if ( m_bTurn ) // preliminary rotation? { - a = m_object->RetAngleY(0); + a = m_object->GetAngleY(0); g = m_angle; cirSpeed = Math::Direction(a, g)*1.0f; - if ( m_physics->RetType() == TYPE_FLYING ) // flying on the ground? + if ( m_physics->GetType() == TYPE_FLYING ) // flying on the ground? { cirSpeed *= 4.0f; // more fishing } @@ -107,23 +104,23 @@ bool CTaskManip::EventProcess(const Event &event) { if ( m_step == 0 ) // fall? { - pos = m_object->RetPosition(1); + pos = m_object->GetPosition(1); pos.y = 3.0f-progress*2.0f; m_object->SetPosition(1, pos); } if ( m_step == 1 ) // farm? { - pos = m_object->RetPosition(2); + pos = m_object->GetPosition(2); pos.z = -1.5f+progress*0.5f; m_object->SetPosition(2, pos); - pos = m_object->RetPosition(3); + pos = m_object->GetPosition(3); pos.z = 1.5f-progress*0.5f; m_object->SetPosition(3, pos); } if ( m_step == 2 ) // up? { - pos = m_object->RetPosition(1); + pos = m_object->GetPosition(1); pos.y = 3.0f-(1.0f-progress)*2.0f; m_object->SetPosition(1, pos); } @@ -132,23 +129,23 @@ bool CTaskManip::EventProcess(const Event &event) { if ( m_step == 0 ) // fall? { - pos = m_object->RetPosition(1); + pos = m_object->GetPosition(1); pos.y = 3.0f-progress*2.0f; m_object->SetPosition(1, pos); } if ( m_step == 1 ) // farm? { - pos = m_object->RetPosition(2); + pos = m_object->GetPosition(2); pos.z = -1.5f+(1.0f-progress)*0.5f; m_object->SetPosition(2, pos); - pos = m_object->RetPosition(3); + pos = m_object->GetPosition(3); pos.z = 1.5f-(1.0f-progress)*0.5f; m_object->SetPosition(3, pos); } if ( m_step == 2 ) // up? { - pos = m_object->RetPosition(1); + pos = m_object->GetPosition(1); pos.y = 3.0f-(1.0f-progress)*2.0f; m_object->SetPosition(1, pos); } @@ -238,7 +235,7 @@ void CTaskManip::InitAngle() for ( i=0 ; i<5 ; i++ ) { - m_initialAngle[i] = m_object->RetAngleZ(i+1); + m_initialAngle[i] = m_object->GetAngleZ(i+1); } max = 0.0f; @@ -250,10 +247,10 @@ void CTaskManip::InitAngle() if ( m_speed > 3.0f ) m_speed = 3.0f; // piano, ma non troppo (?) energy = 0.0f; - power = m_object->RetPower(); + power = m_object->GetPower(); if ( power != 0 ) { - energy = power->RetEnergy(); + energy = power->GetEnergy(); } if ( energy == 0.0f ) @@ -288,12 +285,12 @@ bool TestFriend(ObjectType oType, ObjectType fType) Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm) { - ObjectType type; - CObject *front, *other, *power; - CPyro *pyro; - float iAngle, dist, len; - float fDist, fAngle, oDist, oAngle, oHeight; - Math::Vector pos, fPos, oPos; + ObjectType type; + CObject *front, *other, *power; + Gfx::CPyro *pyro; + float iAngle, dist, len; + float fDist, fAngle, oDist, oAngle, oHeight; + Math::Vector pos, fPos, oPos; m_arm = arm; m_height = 0.0f; @@ -301,7 +298,7 @@ Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm) m_progress = 0.0f; m_speed = 1.0f/1.5f; - iAngle = m_object->RetAngleY(0); + iAngle = m_object->GetAngleY(0); iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI oAngle = iAngle; @@ -314,12 +311,12 @@ Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm) m_physics->SetMotorSpeed(Math::Vector(0.0f, 0.0f, 0.0f)); - type = m_object->RetType(); + type = m_object->GetType(); if ( type == OBJECT_BEE ) // bee? { - if ( m_object->RetFret() == 0 ) + if ( m_object->GetFret() == 0 ) { - if ( !m_physics->RetLand() ) return ERR_MANIP_FLY; + if ( !m_physics->GetLand() ) return ERR_MANIP_FLY; other = SearchTakeUnderObject(m_targetPos, MARGIN_BEE); if ( other == 0 ) return ERR_MANIP_NIL; @@ -330,19 +327,19 @@ Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm) } else { - other = m_object->RetFret(); // other = ball + other = m_object->GetFret(); // other = ball m_object->SetFret(0); // lick the ball other->SetTruck(0); - pos = m_object->RetPosition(0); + pos = m_object->GetPosition(0); pos.y -= 3.0f; other->SetPosition(0, pos); - pos = m_object->RetPosition(0); + pos = m_object->GetPosition(0); pos.y += 2.0f; m_object->SetPosition(0, pos); // against the top of jump - pyro = new CPyro(m_iMan); - pyro->Create(PT_FALL, other); // the ball falls + pyro = new Gfx::CPyro(m_iMan); + pyro->Create(Gfx::PT_FALL, other); // the ball falls } m_bBee = true; @@ -361,13 +358,13 @@ Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm) } m_energy = 0.0f; - power = m_object->RetPower(); + power = m_object->GetPower(); if ( power != 0 ) { - m_energy = power->RetEnergy(); + m_energy = power->GetEnergy(); } - if ( !m_physics->RetLand() ) return ERR_MANIP_FLY; + if ( !m_physics->GetLand() ) return ERR_MANIP_FLY; if ( type != OBJECT_MOBILEfa && type != OBJECT_MOBILEta && @@ -385,7 +382,7 @@ Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm) if ( order == TMO_AUTO ) { - if ( m_object->RetFret() == 0 ) + if ( m_object->GetFret() == 0 ) { m_order = TMO_GRAB; } @@ -399,16 +396,16 @@ Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm) m_order = order; } - if ( m_order == TMO_GRAB && m_object->RetFret() != 0 ) + if ( m_order == TMO_GRAB && m_object->GetFret() != 0 ) { return ERR_MANIP_BUSY; } - if ( m_order == TMO_DROP && m_object->RetFret() == 0 ) + if ( m_order == TMO_DROP && m_object->GetFret() == 0 ) { return ERR_MANIP_EMPTY; } -//? speed = m_physics->RetMotorSpeed(); +//? speed = m_physics->GetMotorSpeed(); //? if ( speed.x != 0.0f || //? speed.z != 0.0f ) return ERR_MANIP_MOTOR; @@ -427,7 +424,7 @@ Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm) } else if ( other != 0 && oDist < fDist ) { - if ( other->RetPower() == 0 ) return ERR_MANIP_NIL; + if ( other->GetPower() == 0 ) return ERR_MANIP_NIL; m_targetPos = oPos; m_angle = oAngle; m_height = oHeight; @@ -451,7 +448,7 @@ Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm) } if ( m_arm == TMA_POWER ) { - if ( m_object->RetPower() == 0 ) return ERR_MANIP_NIL; + if ( m_object->GetPower() == 0 ) return ERR_MANIP_NIL; } } @@ -460,7 +457,7 @@ Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm) if ( m_arm == TMA_FFRONT ) { other = SearchOtherObject(true, oPos, oDist, oAngle, oHeight); - if ( other != 0 && other->RetPower() == 0 ) + if ( other != 0 && other->GetPower() == 0 ) { m_targetPos = oPos; m_angle = oAngle; @@ -479,27 +476,27 @@ Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm) } if ( m_arm == TMA_POWER ) { - if ( m_object->RetPower() != 0 ) return ERR_MANIP_OCC; + if ( m_object->GetPower() != 0 ) return ERR_MANIP_OCC; } } - dist = Math::Distance(m_object->RetPosition(0), m_targetPos); + dist = Math::Distance(m_object->GetPosition(0), m_targetPos); len = dist-TAKE_DIST; if ( m_arm == TMA_OTHER ) len -= TAKE_DIST_OTHER; if ( len < 0.0f ) len = 0.0f; if ( m_arm == TMA_FBACK ) len = -len; - m_advanceLength = dist-m_physics->RetLinLength(len); + m_advanceLength = dist-m_physics->GetLinLength(len); if ( dist <= m_advanceLength+0.2f ) m_move = 0.0f; // not necessary to advance if ( m_energy == 0.0f ) m_move = 0.0f; if ( m_move != 0.0f ) // forward or backward? { - m_timeLimit = m_physics->RetLinTimeLength(fabs(len))*1.5f; + m_timeLimit = m_physics->GetLinTimeLength(fabs(len))*1.5f; if ( m_timeLimit < 0.5f ) m_timeLimit = 0.5f; } - if ( m_object->RetFret() == 0 ) // not carrying anything? + if ( m_object->GetFret() == 0 ) // not carrying anything? { m_hand = TMH_OPEN; // open clamp } @@ -540,7 +537,7 @@ Error CTaskManip::IsEnded() float angle, dist; int i; - if ( m_engine->RetPause() ) return ERR_CONTINUE; + if ( m_engine->GetPause() ) return ERR_CONTINUE; if ( m_bError ) return ERR_STOP; if ( m_bBee ) // bee? @@ -550,7 +547,7 @@ Error CTaskManip::IsEnded() if ( m_bTurn ) // preliminary rotation? { - angle = m_object->RetAngleY(0); + angle = m_object->GetAngleY(0); angle = Math::NormAngle(angle); // 0..2*Math::PI if ( Math::TestAngle(angle, m_angle-Math::PI*0.01f, m_angle+Math::PI*0.01f) ) @@ -570,7 +567,7 @@ Error CTaskManip::IsEnded() if ( m_timeLimit <= 0.0f ) { //OK 1.9 - dist = Math::Distance(m_object->RetPosition(0), m_targetPos); + dist = Math::Distance(m_object->GetPosition(0), m_targetPos); if ( dist <= m_advanceLength + 2.0f ) { m_move = 0.0f; // advance ended @@ -588,7 +585,7 @@ Error CTaskManip::IsEnded() } } - dist = Math::Distance(m_object->RetPosition(0), m_targetPos); + dist = Math::Distance(m_object->GetPosition(0), m_targetPos); if ( dist <= m_advanceLength ) { m_move = 0.0f; // advance ended @@ -624,7 +621,7 @@ Error CTaskManip::IsEnded() { if ( m_bSubm ) m_speed = 1.0f/1.5f; if ( !TruckTakeObject() && - m_object->RetFret() == 0 ) + m_object->GetFret() == 0 ) { m_hand = TMH_OPEN; // reopens the clamp m_arm = TMA_NEUTRAL; @@ -638,7 +635,7 @@ Error CTaskManip::IsEnded() (m_fretType == OBJECT_POWER || m_fretType == OBJECT_ATOMIC ) ) { - m_sound->Play(SOUND_POWEROFF, m_object->RetPosition(0)); + m_sound->Play(SOUND_POWEROFF, m_object->GetPosition(0)); } m_arm = TMA_STOCK; InitAngle(); @@ -653,7 +650,7 @@ Error CTaskManip::IsEnded() if ( m_step == 1 ) { if ( m_bSubm ) m_speed = 1.0f/0.7f; - fret = m_object->RetFret(); + fret = m_object->GetFret(); if ( TruckDeposeObject() ) { if ( (m_arm == TMA_OTHER || @@ -661,7 +658,7 @@ Error CTaskManip::IsEnded() (m_fretType == OBJECT_POWER || m_fretType == OBJECT_ATOMIC ) ) { - m_sound->Play(SOUND_POWERON, m_object->RetPosition(0)); + m_sound->Play(SOUND_POWERON, m_object->GetPosition(0)); } if ( fret != 0 && m_fretType == OBJECT_METAL && m_arm == TMA_FFRONT ) { @@ -693,7 +690,7 @@ bool CTaskManip::Abort() { int i; - if ( m_object->RetFret() == 0 ) // not carrying anything? + if ( m_object->GetFret() == 0 ) // not carrying anything? { m_hand = TMH_OPEN; // open clamp m_arm = TMA_NEUTRAL; @@ -729,16 +726,16 @@ CObject* CTaskManip::SearchTakeUnderObject(Math::Vector &pos, float dLimit) float min, distance; int i; - iPos = m_object->RetPosition(0); + iPos = m_object->GetPosition(0); min = 1000000.0f; pBest = 0; for ( i=0 ; i<1000000 ; i++ ) { - pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i); + pObj = static_cast(m_iMan->SearchInstance(CLASS_OBJECT, i)); if ( pObj == 0 ) break; - type = pObj->RetType(); + type = pObj->GetType(); if ( type != OBJECT_FRET && type != OBJECT_STONE && @@ -754,11 +751,11 @@ CObject* CTaskManip::SearchTakeUnderObject(Math::Vector &pos, float dLimit) type != OBJECT_KEYd && type != OBJECT_TNT ) continue; - if ( pObj->RetTruck() != 0 ) continue; // object transported? - if ( pObj->RetLock() ) continue; - if ( pObj->RetZoomY(0) != 1.0f ) continue; + if ( pObj->GetTruck() != 0 ) continue; // object transported? + if ( pObj->GetLock() ) continue; + if ( pObj->GetZoomY(0) != 1.0f ) continue; - oPos = pObj->RetPosition(0); + oPos = pObj->GetPosition(0); distance = Math::Distance(oPos, iPos); if ( distance <= dLimit && distance < min ) @@ -769,7 +766,7 @@ CObject* CTaskManip::SearchTakeUnderObject(Math::Vector &pos, float dLimit) } if ( pBest != 0 ) { - pos = pBest->RetPosition(0); + pos = pBest->GetPosition(0); } return pBest; } @@ -785,8 +782,8 @@ CObject* CTaskManip::SearchTakeFrontObject(bool bAdvance, Math::Vector &pos, float min, iAngle, bAngle, aLimit, dLimit, f; int i; - iPos = m_object->RetPosition(0); - iAngle = m_object->RetAngleY(0); + iPos = m_object->GetPosition(0); + iAngle = m_object->GetAngleY(0); iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI if ( bAdvance && m_energy > 0.0f ) @@ -806,10 +803,10 @@ CObject* CTaskManip::SearchTakeFrontObject(bool bAdvance, Math::Vector &pos, bAngle = 0.0f; for ( i=0 ; i<1000000 ; i++ ) { - pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i); + pObj = static_cast(m_iMan->SearchInstance(CLASS_OBJECT, i)); if ( pObj == 0 ) break; - type = pObj->RetType(); + type = pObj->GetType(); if ( type != OBJECT_FRET && type != OBJECT_STONE && @@ -830,11 +827,11 @@ CObject* CTaskManip::SearchTakeFrontObject(bool bAdvance, Math::Vector &pos, type != OBJECT_SCRAP4 && type != OBJECT_SCRAP5 ) continue; - if ( pObj->RetTruck() != 0 ) continue; // object transported? - if ( pObj->RetLock() ) continue; - if ( pObj->RetZoomY(0) != 1.0f ) continue; + if ( pObj->GetTruck() != 0 ) continue; // object transported? + if ( pObj->GetLock() ) continue; + if ( pObj->GetZoomY(0) != 1.0f ) continue; - oPos = pObj->RetPosition(0); + oPos = pObj->GetPosition(0); distance = fabs(Math::Distance(oPos, iPos)-TAKE_DIST); f = 1.0f-distance/50.0f; if ( f < 0.5f ) f = 0.5f; @@ -859,7 +856,7 @@ CObject* CTaskManip::SearchTakeFrontObject(bool bAdvance, Math::Vector &pos, } else { - pos = pBest->RetPosition(0); + pos = pBest->GetPosition(0); distance = min; angle = bAngle; } @@ -877,8 +874,8 @@ CObject* CTaskManip::SearchTakeBackObject(bool bAdvance, Math::Vector &pos, float min, iAngle, bAngle, aLimit, dLimit, f; int i; - iPos = m_object->RetPosition(0); - iAngle = m_object->RetAngleY(0)+Math::PI; + iPos = m_object->GetPosition(0); + iAngle = m_object->GetAngleY(0)+Math::PI; iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI if ( bAdvance && m_energy > 0.0f ) @@ -897,10 +894,10 @@ CObject* CTaskManip::SearchTakeBackObject(bool bAdvance, Math::Vector &pos, bAngle = 0.0f; for ( i=0 ; i<1000000 ; i++ ) { - pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i); + pObj = static_cast(m_iMan->SearchInstance(CLASS_OBJECT, i)); if ( pObj == 0 ) break; - type = pObj->RetType(); + type = pObj->GetType(); if ( type != OBJECT_FRET && type != OBJECT_STONE && @@ -921,11 +918,11 @@ CObject* CTaskManip::SearchTakeBackObject(bool bAdvance, Math::Vector &pos, type != OBJECT_SCRAP4 && type != OBJECT_SCRAP5 ) continue; - if ( pObj->RetTruck() != 0 ) continue; // object transported? - if ( pObj->RetLock() ) continue; - if ( pObj->RetZoomY(0) != 1.0f ) continue; + if ( pObj->GetTruck() != 0 ) continue; // object transported? + if ( pObj->GetLock() ) continue; + if ( pObj->GetZoomY(0) != 1.0f ) continue; - oPos = pObj->RetPosition(0); + oPos = pObj->GetPosition(0); distance = fabs(Math::Distance(oPos, iPos)-TAKE_DIST); f = 1.0f-distance/50.0f; if ( f < 0.5f ) f = 0.5f; @@ -950,7 +947,7 @@ CObject* CTaskManip::SearchTakeBackObject(bool bAdvance, Math::Vector &pos, } else { - pos = pBest->RetPosition(0); + pos = pBest->GetPosition(0); distance = min; angle = bAngle; } @@ -978,7 +975,7 @@ CObject* CTaskManip::SearchOtherObject(bool bAdvance, Math::Vector &pos, if ( m_bSubm ) return 0; // impossible with the submarine if ( !m_object->GetCrashSphere(0, iPos, iRad) ) return 0; - iAngle = m_object->RetAngleY(0); + iAngle = m_object->GetAngleY(0); iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI if ( bAdvance && m_energy > 0.0f ) @@ -994,12 +991,12 @@ CObject* CTaskManip::SearchOtherObject(bool bAdvance, Math::Vector &pos, for ( i=0 ; i<1000000 ; i++ ) { - pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i); + pObj = static_cast(m_iMan->SearchInstance(CLASS_OBJECT, i)); if ( pObj == 0 ) break; if ( pObj == m_object ) continue; // yourself? - type = pObj->RetType(); + type = pObj->GetType(); if ( type != OBJECT_MOBILEfa && type != OBJECT_MOBILEta && type != OBJECT_MOBILEwa && @@ -1032,22 +1029,22 @@ CObject* CTaskManip::SearchOtherObject(bool bAdvance, Math::Vector &pos, type != OBJECT_LABO && type != OBJECT_NUCLEAR ) continue; - pPower = pObj->RetPower(); + pPower = pObj->GetPower(); if ( pPower != 0 ) { - if ( pPower->RetLock() ) continue; - if ( pPower->RetZoomY(0) != 1.0f ) continue; + if ( pPower->GetLock() ) continue; + if ( pPower->GetZoomY(0) != 1.0f ) continue; - powerType = pPower->RetType(); + powerType = pPower->GetType(); if ( powerType == OBJECT_NULL || powerType == OBJECT_FIX ) continue; } - mat = pObj->RetWorldMatrix(0); - character = pObj->RetCharacter(); + mat = pObj->GetWorldMatrix(0); + character = pObj->GetCharacter(); oPos = Transform(*mat, character->posPower); - oAngle = pObj->RetAngleY(0); + oAngle = pObj->GetAngleY(0); if ( type == OBJECT_TOWER || type == OBJECT_RESEARCH ) { @@ -1080,7 +1077,7 @@ CObject* CTaskManip::SearchOtherObject(bool bAdvance, Math::Vector &pos, angle = Math::RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW ! if ( Math::TestAngle(angle, iAngle-aLimit, iAngle+aLimit) ) { - character = pObj->RetCharacter(); + character = pObj->GetCharacter(); height = character->posPower.y; pos = oPos; return pObj; @@ -1105,12 +1102,12 @@ bool CTaskManip::TruckTakeObject() if ( m_arm == TMA_GRAB ) // takes immediately? { - fret = m_object->RetFret(); + fret = m_object->GetFret(); if ( fret == 0 ) return false; // nothing to take? - m_fretType = fret->RetType(); + m_fretType = fret->GetType(); - if ( m_object->RetType() == OBJECT_HUMAN || - m_object->RetType() == OBJECT_TECH ) + if ( m_object->GetType() == OBJECT_HUMAN || + m_object->GetType() == OBJECT_TECH ) { fret->SetTruck(m_object); fret->SetTruckPart(4); // takes with the hand @@ -1150,7 +1147,7 @@ bool CTaskManip::TruckTakeObject() { fret = SearchTakeFrontObject(false, pos, dist, angle); if ( fret == 0 ) return false; // nothing to take? - m_fretType = fret->RetType(); + m_fretType = fret->GetType(); if ( m_bSubm ) { @@ -1182,7 +1179,7 @@ bool CTaskManip::TruckTakeObject() { fret = SearchTakeBackObject(false, pos, dist, angle); if ( fret == 0 ) return false; // nothing to take? - m_fretType = fret->RetType(); + m_fretType = fret->GetType(); fret->SetTruck(m_object); fret->SetTruckPart(3); // takes with the hand @@ -1198,9 +1195,9 @@ bool CTaskManip::TruckTakeObject() if ( m_arm == TMA_POWER ) // takes battery in the back? { - fret = m_object->RetPower(); + fret = m_object->GetPower(); if ( fret == 0 ) return false; // no battery? - m_fretType = fret->RetType(); + m_fretType = fret->GetType(); pos = Math::Vector(4.7f, 0.0f, 0.0f); // relative to the hand (lem4) fret->SetPosition(0, pos); @@ -1218,9 +1215,9 @@ bool CTaskManip::TruckTakeObject() other = SearchOtherObject(false, pos, dist, angle, m_height); if ( other == 0 ) return false; - fret = other->RetPower(); + fret = other->GetPower(); if ( fret == 0 ) return false; // the other does not have a battery? - m_fretType = fret->RetType(); + m_fretType = fret->GetType(); other->SetPower(0); fret->SetTruck(m_object); @@ -1251,15 +1248,15 @@ bool CTaskManip::TruckDeposeObject() if ( m_arm == TMA_FFRONT ) // deposits on the ground in front? { - fret = m_object->RetFret(); + fret = m_object->GetFret(); if ( fret == 0 ) return false; // nothing transported? - m_fretType = fret->RetType(); + m_fretType = fret->GetType(); - mat = fret->RetWorldMatrix(0); + mat = fret->GetWorldMatrix(0); pos = Transform(*mat, Math::Vector(0.0f, 1.0f, 0.0f)); - m_terrain->MoveOnFloor(pos); + m_terrain->AdjustToFloor(pos); fret->SetPosition(0, pos); - fret->SetAngleY(0, m_object->RetAngleY(0)+Math::PI/2.0f); + fret->SetAngleY(0, m_object->GetAngleY(0)+Math::PI/2.0f); fret->SetAngleX(0, 0.0f); fret->SetAngleZ(0, 0.0f); fret->FloorAdjust(); // plate well on the ground @@ -1270,15 +1267,15 @@ bool CTaskManip::TruckDeposeObject() if ( m_arm == TMA_FBACK ) // deposited on the ground behind? { - fret = m_object->RetFret(); + fret = m_object->GetFret(); if ( fret == 0 ) return false; // nothing transported? - m_fretType = fret->RetType(); + m_fretType = fret->GetType(); - mat = fret->RetWorldMatrix(0); + mat = fret->GetWorldMatrix(0); pos = Transform(*mat, Math::Vector(0.0f, 1.0f, 0.0f)); - m_terrain->MoveOnFloor(pos); + m_terrain->AdjustToFloor(pos); fret->SetPosition(0, pos); - fret->SetAngleY(0, m_object->RetAngleY(0)+Math::PI/2.0f); + fret->SetAngleY(0, m_object->GetAngleY(0)+Math::PI/2.0f); fret->SetAngleX(0, 0.0f); fret->SetAngleZ(0, 0.0f); @@ -1288,16 +1285,16 @@ bool CTaskManip::TruckDeposeObject() if ( m_arm == TMA_POWER ) // deposits battery in the back? { - fret = m_object->RetFret(); + fret = m_object->GetFret(); if ( fret == 0 ) return false; // nothing transported? - m_fretType = fret->RetType(); + m_fretType = fret->GetType(); - if ( m_object->RetPower() != 0 ) return false; + if ( m_object->GetPower() != 0 ) return false; fret->SetTruck(m_object); fret->SetTruckPart(0); // carried by the base - character = m_object->RetCharacter(); + character = m_object->GetCharacter(); fret->SetPosition(0, character->posPower); fret->SetAngleY(0, 0.0f); fret->SetAngleX(0, 0.0f); @@ -1312,17 +1309,17 @@ bool CTaskManip::TruckDeposeObject() other = SearchOtherObject(false, pos, dist, angle, m_height); if ( other == 0 ) return false; - fret = other->RetPower(); + fret = other->GetPower(); if ( fret != 0 ) return false; // the other already has a battery? - fret = m_object->RetFret(); + fret = m_object->GetFret(); if ( fret == 0 ) return false; - m_fretType = fret->RetType(); + m_fretType = fret->GetType(); other->SetPower(fret); fret->SetTruck(other); - character = other->RetCharacter(); + character = other->GetCharacter(); fret->SetPosition(0, character->posPower); fret->SetAngleY(0, 0.0f); fret->SetAngleX(0, 0.0f); @@ -1345,17 +1342,17 @@ bool CTaskManip::IsFreeDeposeObject(Math::Vector pos) float oRadius; int i, j; - mat = m_object->RetWorldMatrix(0); + mat = m_object->GetWorldMatrix(0); iPos = Transform(*mat, pos); for ( i=0 ; i<1000000 ; i++ ) { - pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i); + pObj = static_cast(m_iMan->SearchInstance(CLASS_OBJECT, i)); if ( pObj == 0 ) break; if ( pObj == m_object ) continue; - if ( !pObj->RetActif() ) continue; // inactive? - if ( pObj->RetTruck() != 0 ) continue; // object transported? + if ( !pObj->GetActif() ) continue; // inactive? + if ( pObj->GetTruck() != 0 ) continue; // object transported? j = 0; while ( pObj->GetCrashSphere(j++, oPos, oRadius) ) @@ -1375,7 +1372,7 @@ void CTaskManip::SoundManip(float time, float amplitude, float frequency) { int i; - i = m_sound->Play(SOUND_MANIP, m_object->RetPosition(0), 0.0f, 0.3f*frequency, true); + i = m_sound->Play(SOUND_MANIP, m_object->GetPosition(0), 0.0f, 0.3f*frequency, true); m_sound->AddEnvelope(i, 0.5f*amplitude, 1.0f*frequency, 0.1f, SOPER_CONTINUE); m_sound->AddEnvelope(i, 0.5f*amplitude, 1.0f*frequency, time-0.1f, SOPER_CONTINUE); m_sound->AddEnvelope(i, 0.0f, 0.3f*frequency, 0.1f, SOPER_STOP); diff --git a/src/object/task/taskpen.cpp b/src/object/task/taskpen.cpp index c3a9aef..6e04233 100644 --- a/src/object/task/taskpen.cpp +++ b/src/object/task/taskpen.cpp @@ -16,12 +16,9 @@ // taskpen.cpp - -#include - #include "object/task/taskpen.h" -#include "old/particule.h" +#include "graphics/engine/particle.h" #include "math/geometry.h" #include "object/object.h" @@ -49,8 +46,8 @@ bool CTaskPen::EventProcess(const Event &event) Math::Point dim; int i; - if ( m_engine->RetPause() ) return true; - if ( event.event != EVENT_FRAME ) return true; + if ( m_engine->GetPause() ) return true; + if ( event.type != EVENT_FRAME ) return true; if ( m_bError ) return false; if ( m_delay == 0.0f ) @@ -67,17 +64,17 @@ bool CTaskPen::EventProcess(const Event &event) if ( m_phase == TPP_UP ) // back the pencil { - i = AngleToRank(m_object->RetAngleY(1)); - pos = m_object->RetPosition(10+i); + i = AngleToRank(m_object->GetAngleY(1)); + pos = m_object->GetPosition(10+i); pos.y = -3.2f*(1.0f-m_progress); m_object->SetPosition(10+i, pos); } if ( m_phase == TPP_TURN ) // turns the carousel? { - if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time ) + if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time ) { - m_lastParticule = m_time; + m_lastParticle = m_time; pos = m_supportPos; pos.x += (Math::Rand()-0.5f)*5.0f; @@ -87,7 +84,7 @@ bool CTaskPen::EventProcess(const Event &event) speed.y = Math::Rand()*2.0f; dim.x = Math::Rand()*1.5f+2.0f; dim.y = dim.x; - m_particule->CreateParticule(pos, speed, dim, PARTISMOKE3, 4.0f); + m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISMOKE3, 4.0f); } m_object->SetAngleY(1, m_oldAngle+(m_newAngle-m_oldAngle)*m_progress); @@ -95,9 +92,9 @@ bool CTaskPen::EventProcess(const Event &event) if ( m_phase == TPP_DOWN ) // down the pencil? { - if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time ) + if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time ) { - m_lastParticule = m_time; + m_lastParticle = m_time; pos = m_supportPos; pos.x += (Math::Rand()-0.5f)*5.0f; @@ -107,11 +104,11 @@ bool CTaskPen::EventProcess(const Event &event) speed.y = Math::Rand()*5.0f; dim.x = Math::Rand()*1.0f+1.0f; dim.y = dim.x; - m_particule->CreateParticule(pos, speed, dim, PARTIVAPOR, 4.0f); + m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIVAPOR, 4.0f); } - i = AngleToRank(m_object->RetAngleY(1)); - pos = m_object->RetPosition(10+i); + i = AngleToRank(m_object->GetAngleY(1)); + pos = m_object->GetPosition(10+i); if ( m_timeDown == 0.0f ) { pos.y = 0.0f; @@ -138,16 +135,16 @@ Error CTaskPen::Start(bool bDown, int color) m_bError = true; // operation impossible - type = m_object->RetType(); + type = m_object->GetType(); if ( type != OBJECT_MOBILEdr ) return ERR_FIRE_VEH; m_bError = false; // ok - m_oldAngle = m_object->RetAngleY(1); + m_oldAngle = m_object->GetAngleY(1); m_newAngle = ColorToAngle(color); i = AngleToRank(m_oldAngle); - pos = m_object->RetPosition(10+i); + pos = m_object->GetPosition(10+i); if ( pos.y == 0.0f ) // pencil at the top? { @@ -167,7 +164,7 @@ Error CTaskPen::Start(bool bDown, int color) m_timeDown = 0.0f; } - mat = m_object->RetWorldMatrix(0); + mat = m_object->GetWorldMatrix(0); pos = Math::Vector(-3.0f, 7.0f, 0.0f); pos = Math::Transform(*mat, pos); // position of carousel m_supportPos = pos; @@ -182,7 +179,7 @@ Error CTaskPen::Start(bool bDown, int color) SoundManip(m_timeUp, 1.0f, 0.5f); } - m_lastParticule = 0.0f; + m_lastParticle = 0.0f; //? m_camera->StartCentering(m_object, Math::PI*0.60f, 99.9f, 5.0f, 0.5f); @@ -193,7 +190,7 @@ Error CTaskPen::Start(bool bDown, int color) Error CTaskPen::IsEnded() { - if ( m_engine->RetPause() ) return ERR_CONTINUE; + if ( m_engine->GetPause() ) return ERR_CONTINUE; if ( m_bError ) return ERR_STOP; if ( m_progress < 1.0f ) return ERR_CONTINUE; @@ -205,7 +202,7 @@ Error CTaskPen::IsEnded() m_progress = 0.0f; m_delay = fabs(m_oldAngle-m_newAngle)/Math::PI; m_time = 0.0f; - m_lastParticule = 0.0f; + m_lastParticle = 0.0f; if ( m_delay > 0.0f ) { SoundManip(m_delay, 1.0f, 1.0f); @@ -220,7 +217,7 @@ Error CTaskPen::IsEnded() m_progress = 0.0f; m_delay = m_timeDown; m_time = 0.0f; - m_lastParticule = 0.0f; + m_lastParticle = 0.0f; return ERR_CONTINUE; } @@ -243,7 +240,7 @@ void CTaskPen::SoundManip(float time, float amplitude, float frequency) { int i; - i = m_sound->Play(SOUND_MANIP, m_object->RetPosition(0), 0.0f, 0.3f*frequency, true); + i = m_sound->Play(SOUND_MANIP, m_object->GetPosition(0), 0.0f, 0.3f*frequency, true); m_sound->AddEnvelope(i, 0.5f*amplitude, 1.0f*frequency, 0.1f, SOPER_CONTINUE); m_sound->AddEnvelope(i, 0.5f*amplitude, 1.0f*frequency, time-0.1f, SOPER_CONTINUE); m_sound->AddEnvelope(i, 0.0f, 0.3f*frequency, 0.1f, SOPER_STOP); @@ -257,7 +254,7 @@ int CTaskPen::AngleToRank(float angle) //? return (int)(angle/(-45.0f*Math::PI/180.0f)); angle = -angle; angle += (45.0f*Math::PI/180.0f)/2.0f; - return (int)(angle/(45.0f*Math::PI/180.0f)); + return static_cast(angle/(45.0f*Math::PI/180.0f)); } // Converting a color to the angle of carousel of pencils. diff --git a/src/object/task/taskpen.h b/src/object/task/taskpen.h index b41c513..0974322 100644 --- a/src/object/task/taskpen.h +++ b/src/object/task/taskpen.h @@ -57,8 +57,8 @@ protected: float m_progress; float m_delay; float m_time; - float m_lastParticule; - Math::Vector m_supportPos; + float m_lastParticle; + Math::Vector m_supportPos; float m_timeUp; float m_oldAngle; diff --git a/src/object/task/taskrecover.cpp b/src/object/task/taskrecover.cpp index 02cefb8..4c8ead8 100644 --- a/src/object/task/taskrecover.cpp +++ b/src/object/task/taskrecover.cpp @@ -23,7 +23,7 @@ #include "math/geometry.h" #include "common/iman.h" -#include "old/particule.h" +#include "graphics/engine/particle.h" #include "physics/physics.h" #include "ui/displaytext.h" @@ -58,13 +58,13 @@ bool CTaskRecover::EventProcess(const Event &event) Math::Point dim; float a, g, cirSpeed, angle, energy, dist, linSpeed; - if ( m_engine->RetPause() ) return true; - if ( event.event != EVENT_FRAME ) return true; + if ( m_engine->GetPause() ) return true; + if ( event.type != EVENT_FRAME ) return true; if ( m_bError ) return false; if ( m_phase == TRP_TURN ) // preliminary rotation? { - a = m_object->RetAngleY(0); + a = m_object->GetAngleY(0); g = m_angle; cirSpeed = Math::Direction(a, g)*1.0f; if ( cirSpeed > 1.0f ) cirSpeed = 1.0f; @@ -90,7 +90,7 @@ bool CTaskRecover::EventProcess(const Event &event) if ( m_phase == TRP_MOVE ) // preliminary forward/backward? { - dist = Math::Distance(m_object->RetPosition(0), m_ruin->RetPosition(0)); + dist = Math::Distance(m_object->GetPosition(0), m_ruin->GetPosition(0)); linSpeed = 0.0f; if ( dist > RECOVER_DIST ) linSpeed = 1.0f; if ( dist < RECOVER_DIST ) linSpeed = -1.0f; @@ -100,10 +100,10 @@ bool CTaskRecover::EventProcess(const Event &event) if ( m_phase == TRP_OPER ) { - power = m_object->RetPower(); + power = m_object->GetPower(); if ( power != 0 ) { - energy = power->RetEnergy(); + energy = power->GetEnergy(); power->SetEnergy(energy-ENERGY_RECOVER*event.rTime*m_speed); } @@ -122,9 +122,9 @@ bool CTaskRecover::EventProcess(const Event &event) m_metal->SetZoom(0, (m_progress-0.5f)/0.3f); } - if ( m_lastParticule+m_engine->ParticuleAdapt(0.02f) <= m_time ) + if ( m_lastParticle+m_engine->ParticleAdapt(0.02f) <= m_time ) { - m_lastParticule = m_time; + m_lastParticle = m_time; pos = m_recoverPos; pos.x += (Math::Rand()-0.5f)*8.0f*(1.0f-m_progress); @@ -135,7 +135,7 @@ bool CTaskRecover::EventProcess(const Event &event) speed.y = Math::Rand()*15.0f; dim.x = Math::Rand()*2.0f+1.5f; dim.y = dim.x; - m_particule->CreateParticule(pos, speed, dim, PARTIRECOVER, 1.0f, 0.0f, 0.0f); + m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIRECOVER, 1.0f, 0.0f, 0.0f); } } @@ -149,9 +149,9 @@ bool CTaskRecover::EventProcess(const Event &event) m_object->SetAngleZ(3, angle); m_object->SetAngleZ(5, angle); - if ( m_lastParticule+m_engine->ParticuleAdapt(0.02f) <= m_time ) + if ( m_lastParticle+m_engine->ParticleAdapt(0.02f) <= m_time ) { - m_lastParticule = m_time; + m_lastParticle = m_time; pos = m_recoverPos; pos.y -= 4.0f; @@ -160,7 +160,7 @@ bool CTaskRecover::EventProcess(const Event &event) speed.y = Math::Rand()*15.0f; dim.x = Math::Rand()*2.0f+1.5f; dim.y = dim.x; - m_particule->CreateParticule(pos, speed, dim, PARTIRECOVER, 1.0f, 0.0f, 0.0f); + m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIRECOVER, 1.0f, 0.0f, 0.0f); } } @@ -180,17 +180,17 @@ Error CTaskRecover::Start() ObjectType type; m_bError = true; // operation impossible - if ( !m_physics->RetLand() ) return ERR_RECOVER_VEH; + if ( !m_physics->GetLand() ) return ERR_RECOVER_VEH; - type = m_object->RetType(); + type = m_object->GetType(); if ( type != OBJECT_MOBILErr ) return ERR_RECOVER_VEH; - power = m_object->RetPower(); + power = m_object->GetPower(); if ( power == 0 ) return ERR_RECOVER_ENERGY; - energy = power->RetEnergy(); - if ( energy < ENERGY_RECOVER/power->RetCapacity()+0.05f ) return ERR_RECOVER_ENERGY; + energy = power->GetEnergy(); + if ( energy < ENERGY_RECOVER/power->GetCapacity()+0.05f ) return ERR_RECOVER_ENERGY; - mat = m_object->RetWorldMatrix(0); + mat = m_object->GetWorldMatrix(0); pos = Math::Vector(RECOVER_DIST, 3.3f, 0.0f); pos = Transform(*mat, pos); // position in front m_recoverPos = pos; @@ -199,8 +199,8 @@ Error CTaskRecover::Start() if ( m_ruin == 0 ) return ERR_RECOVER_NULL; m_ruin->SetLock(true); // ruin no longer usable - iPos = m_object->RetPosition(0); - oPos = m_ruin->RetPosition(0); + iPos = m_object->GetPosition(0); + oPos = m_ruin->GetPosition(0); m_angle = Math::RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW ! m_metal = 0; @@ -209,7 +209,7 @@ Error CTaskRecover::Start() m_progress = 0.0f; m_speed = 1.0f/1.0f; m_time = 0.0f; - m_lastParticule = 0.0f; + m_lastParticle = 0.0f; m_bError = false; // ok @@ -227,27 +227,27 @@ Error CTaskRecover::IsEnded() float angle, dist, time; int i; - if ( m_engine->RetPause() ) return ERR_CONTINUE; + if ( m_engine->GetPause() ) return ERR_CONTINUE; if ( m_bError ) return ERR_STOP; if ( m_phase == TRP_TURN ) // preliminary rotation? { - angle = m_object->RetAngleY(0); + angle = m_object->GetAngleY(0); angle = Math::NormAngle(angle); // 0..2*Math::PI if ( Math::TestAngle(angle, m_angle-Math::PI*0.01f, m_angle+Math::PI*0.01f) ) { m_physics->SetMotorSpeedZ(0.0f); - dist = Math::Distance(m_object->RetPosition(0), m_ruin->RetPosition(0)); + dist = Math::Distance(m_object->GetPosition(0), m_ruin->GetPosition(0)); if ( dist > RECOVER_DIST ) { - time = m_physics->RetLinTimeLength(dist-RECOVER_DIST, 1.0f); + time = m_physics->GetLinTimeLength(dist-RECOVER_DIST, 1.0f); m_speed = 1.0f/time; } else { - time = m_physics->RetLinTimeLength(RECOVER_DIST-dist, -1.0f); + time = m_physics->GetLinTimeLength(RECOVER_DIST-dist, -1.0f); m_speed = 1.0f/time; } m_phase = TRP_MOVE; @@ -258,19 +258,19 @@ Error CTaskRecover::IsEnded() if ( m_phase == TRP_MOVE ) // preliminary advance? { - dist = Math::Distance(m_object->RetPosition(0), m_ruin->RetPosition(0)); + dist = Math::Distance(m_object->GetPosition(0), m_ruin->GetPosition(0)); if ( dist >= RECOVER_DIST-1.0f && dist <= RECOVER_DIST+1.0f ) { m_physics->SetMotorSpeedX(0.0f); - mat = m_object->RetWorldMatrix(0); + mat = m_object->GetWorldMatrix(0); pos = Math::Vector(RECOVER_DIST, 3.3f, 0.0f); pos = Transform(*mat, pos); // position in front m_recoverPos = pos; - i = m_sound->Play(SOUND_MANIP, m_object->RetPosition(0), 0.0f, 0.9f, true); + i = m_sound->Play(SOUND_MANIP, m_object->GetPosition(0), 0.0f, 0.9f, true); m_sound->AddEnvelope(i, 1.0f, 1.5f, 0.3f, SOPER_CONTINUE); m_sound->AddEnvelope(i, 1.0f, 1.5f, 1.0f, SOPER_CONTINUE); m_sound->AddEnvelope(i, 0.0f, 0.9f, 0.3f, SOPER_STOP); @@ -310,15 +310,15 @@ Error CTaskRecover::IsEnded() m_metal->SetLock(true); // metal not yet usable m_metal->SetZoom(0, 0.0f); - mat = m_object->RetWorldMatrix(0); + mat = m_object->GetWorldMatrix(0); pos = Math::Vector(RECOVER_DIST, 3.1f, 3.9f); pos = Transform(*mat, pos); goal = Math::Vector(RECOVER_DIST, 3.1f, -3.9f); goal = Transform(*mat, goal); - m_particule->CreateRay(pos, goal, PARTIRAY2, + m_particle->CreateRay(pos, goal, Gfx::PARTIRAY2, Math::Point(2.0f, 2.0f), 8.0f); - m_soundChannel = m_sound->Play(SOUND_RECOVER, m_ruin->RetPosition(0), 0.0f, 1.0f, true); + m_soundChannel = m_sound->Play(SOUND_RECOVER, m_ruin->GetPosition(0), 0.0f, 1.0f, true); m_sound->AddEnvelope(m_soundChannel, 0.6f, 1.0f, 2.0f, SOPER_CONTINUE); m_sound->AddEnvelope(m_soundChannel, 0.6f, 1.0f, 4.0f, SOPER_CONTINUE); m_sound->AddEnvelope(m_soundChannel, 0.0f, 0.7f, 2.0f, SOPER_STOP); @@ -338,7 +338,7 @@ Error CTaskRecover::IsEnded() m_soundChannel = -1; - i = m_sound->Play(SOUND_MANIP, m_object->RetPosition(0), 0.0f, 0.9f, true); + i = m_sound->Play(SOUND_MANIP, m_object->GetPosition(0), 0.0f, 0.9f, true); m_sound->AddEnvelope(i, 1.0f, 1.5f, 0.3f, SOPER_CONTINUE); m_sound->AddEnvelope(i, 1.0f, 1.5f, 1.0f, SOPER_CONTINUE); m_sound->AddEnvelope(i, 0.0f, 0.9f, 0.3f, SOPER_STOP); @@ -389,10 +389,10 @@ CObject* CTaskRecover::SearchRuin() min = 100000.0f; for ( i=0 ; i<1000000 ; i++ ) { - pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i); + pObj = static_cast(m_iMan->SearchInstance(CLASS_OBJECT, i)); if ( pObj == 0 ) break; - type = pObj->RetType(); + type = pObj->GetType(); if ( type == OBJECT_RUINmobilew1 || type == OBJECT_RUINmobilew2 || type == OBJECT_RUINmobilet1 || @@ -400,7 +400,7 @@ CObject* CTaskRecover::SearchRuin() type == OBJECT_RUINmobiler1 || type == OBJECT_RUINmobiler2 ) // vehicle in ruin? { - oPos = pObj->RetPosition(0); + oPos = pObj->GetPosition(0); dist = Math::Distance(oPos, m_recoverPos); if ( dist > 40.0f ) continue; diff --git a/src/object/task/taskrecover.h b/src/object/task/taskrecover.h index 8af6353..151ab6b 100644 --- a/src/object/task/taskrecover.h +++ b/src/object/task/taskrecover.h @@ -56,11 +56,11 @@ protected: float m_speed; float m_time; float m_angle; - float m_lastParticule; + float m_lastParticle; bool m_bError; CObject* m_ruin; CObject* m_metal; - Math::Vector m_recoverPos; + Math::Vector m_recoverPos; int m_soundChannel; }; diff --git a/src/object/task/taskreset.cpp b/src/object/task/taskreset.cpp index 2366fea..7e097bf 100644 --- a/src/object/task/taskreset.cpp +++ b/src/object/task/taskreset.cpp @@ -16,9 +16,6 @@ // taskreset.cpp - -#include - #include "object/task/taskreset.h" #include "common/iman.h" @@ -55,8 +52,8 @@ bool CTaskReset::EventProcess(const Event &event) Math::Point dim; float angle, duration; - if ( m_engine->RetPause() ) return true; - if ( event.event != EVENT_FRAME ) return true; + if ( m_engine->GetPause() ) return true; + if ( event.type != EVENT_FRAME ) return true; if ( m_bError ) return false; m_time += event.rTime; @@ -69,9 +66,9 @@ bool CTaskReset::EventProcess(const Event &event) m_object->SetAngleY(0, angle); m_object->SetZoom(0, 1.0f-m_progress); - if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time ) + if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time ) { - m_lastParticule = m_time; + m_lastParticle = m_time; pos = m_begin; pos.x += (Math::Rand()-0.5f)*5.0f; @@ -81,7 +78,7 @@ bool CTaskReset::EventProcess(const Event &event) speed.y = 5.0f+Math::Rand()*5.0f; dim.x = Math::Rand()*2.0f+2.0f; dim.y = dim.x; - m_particule->CreateParticule(pos, speed, dim, PARTIGLINTb, 2.0f); + m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGLINTb, 2.0f); pos = m_begin; speed.x = (Math::Rand()-0.5f)*20.0f; @@ -94,7 +91,7 @@ bool CTaskReset::EventProcess(const Event &event) dim.y = dim.x; pos.y += dim.y; duration = Math::Rand()*1.5f+1.5f; - m_particule->CreateTrack(pos, speed, dim, PARTITRACK6, + m_particle->CreateTrack(pos, speed, dim, Gfx::PARTITRACK6, duration, 0.0f, duration*0.9f, 0.7f); } @@ -105,9 +102,9 @@ bool CTaskReset::EventProcess(const Event &event) pos = m_begin+(m_goal-m_begin)*m_progress; m_object->SetPosition(0, pos); - if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time ) + if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time ) { - m_lastParticule = m_time; + m_lastParticle = m_time; pos.x += (Math::Rand()-0.5f)*5.0f; pos.z += (Math::Rand()-0.5f)*5.0f; @@ -116,7 +113,7 @@ bool CTaskReset::EventProcess(const Event &event) speed.y = 2.0f+Math::Rand()*2.0f; dim.x = Math::Rand()*2.0f+2.0f; dim.y = dim.x; - m_particule->CreateParticule(pos, speed, dim, PARTIGLINTb, 2.0f); + m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGLINTb, 2.0f); } } @@ -127,9 +124,9 @@ bool CTaskReset::EventProcess(const Event &event) m_object->SetAngleY(0, angle); m_object->SetZoom(0, m_progress); - if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time ) + if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time ) { - m_lastParticule = m_time; + m_lastParticle = m_time; pos = m_goal; pos.x += (Math::Rand()-0.5f)*5.0f; @@ -139,7 +136,7 @@ bool CTaskReset::EventProcess(const Event &event) speed.y = 5.0f+Math::Rand()*5.0f; dim.x = Math::Rand()*2.0f+2.0f; dim.y = dim.x; - m_particule->CreateParticule(pos, speed, dim, PARTIGLINTb, 2.0f); + m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGLINTb, 2.0f); pos = m_goal; speed.x = (Math::Rand()-0.5f)*20.0f; @@ -150,7 +147,7 @@ bool CTaskReset::EventProcess(const Event &event) dim.y = dim.x; pos.y += dim.y; duration = Math::Rand()*1.5f+1.5f; - m_particule->CreateTrack(pos, speed, dim, PARTITRACK6, + m_particle->CreateTrack(pos, speed, dim, Gfx::PARTITRACK6, duration, 0.0f, duration*0.9f, 0.7f); } @@ -168,24 +165,24 @@ Error CTaskReset::Start(Math::Vector goal, Math::Vector angle) CObject* fret; int i; - fret = m_object->RetFret(); - if ( fret != 0 && fret->RetResetCap() == RESET_MOVE ) + fret = m_object->GetFret(); + if ( fret != 0 && fret->GetResetCap() == RESET_MOVE ) { fret->SetTruck(0); m_object->SetFret(0); // does nothing } - if ( !m_main->RetNiceReset() ) // quick return? + if ( !m_main->GetNiceReset() ) // quick return? { m_object->SetPosition(0, goal); m_object->SetAngle(0, angle); - m_brain->RunProgram(m_object->RetResetRun()); + m_brain->RunProgram(m_object->GetResetRun()); m_bError = false; return ERR_OK; } - m_begin = m_object->RetPosition(0); + m_begin = m_object->GetPosition(0); m_goal = goal; m_angle = angle; @@ -195,12 +192,12 @@ Error CTaskReset::Start(Math::Vector goal, Math::Vector angle) return ERR_RESET_NEAR; } - m_iAngle = m_object->RetAngleY(0); + m_iAngle = m_object->GetAngleY(0); m_time = 0.0f; m_phase = TRSP_ZOUT; m_speed = 1.0f/RESET_DELAY_ZOOM; m_progress = 0.0f; - m_lastParticule = 0.0f; + m_lastParticle = 0.0f; m_object->SetResetBusy(true); @@ -219,12 +216,12 @@ Error CTaskReset::IsEnded() float dist; int i; - if ( !m_main->RetNiceReset() ) // quick return? + if ( !m_main->GetNiceReset() ) // quick return? { return ERR_STOP; } - if ( m_engine->RetPause() ) return ERR_CONTINUE; + if ( m_engine->GetPause() ) return ERR_CONTINUE; if ( m_bError ) return ERR_STOP; if ( m_progress < 1.0f ) return ERR_CONTINUE; @@ -254,13 +251,13 @@ Error CTaskReset::IsEnded() m_object->SetAngle(0, m_angle); m_object->SetZoom(0, 1.0f); - power = m_object->RetPower(); + power = m_object->GetPower(); if ( power != 0 ) { - power->SetEnergy(power->RetCapacity()); // refueling + power->SetEnergy(power->GetCapacity()); // refueling } - m_brain->RunProgram(m_object->RetResetRun()); + m_brain->RunProgram(m_object->GetResetRun()); m_object->SetResetBusy(false); return ERR_STOP; } @@ -278,12 +275,12 @@ bool CTaskReset::SearchVehicle() for ( i=0 ; i<1000000 ; i++ ) { - pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i); + pObj = static_cast(m_iMan->SearchInstance(CLASS_OBJECT, i)); if ( pObj == 0 ) break; if ( pObj == m_object ) continue; - type = pObj->RetType(); + type = pObj->GetType(); if ( type != OBJECT_HUMAN && type != OBJECT_TECH && type != OBJECT_MOBILEfa && diff --git a/src/object/task/taskreset.h b/src/object/task/taskreset.h index 17a4441..e3dacf7 100644 --- a/src/object/task/taskreset.h +++ b/src/object/task/taskreset.h @@ -57,7 +57,7 @@ protected: float m_time; float m_speed; float m_progress; - float m_lastParticule; // time of generation last particle + float m_lastParticle; // time of generation last particle float m_iAngle; }; diff --git a/src/object/task/tasktake.cpp b/src/object/task/tasktake.cpp index 1a50f06..f9f957f 100644 --- a/src/object/task/tasktake.cpp +++ b/src/object/task/tasktake.cpp @@ -16,14 +16,11 @@ // tasktake.cpp - -#include - #include "object/task/tasktake.h" #include "common/iman.h" -#include "old/terrain.h" -#include "old/water.h" +#include "graphics/engine/terrain.h" +#include "graphics/engine/water.h" #include "math/geometry.h" #include "object/motion/motionhuman.h" #include "object/robotmain.h" diff --git a/src/object/task/tasktake.h b/src/object/task/tasktake.h index b0553a0..c7950fe 100644 --- a/src/object/task/tasktake.h +++ b/src/object/task/tasktake.h @@ -59,7 +59,8 @@ protected: bool IsFreeDeposeObject(Math::Vector pos); protected: - CTerrain* m_terrain; + //TODO this is same member as in base class, probable should be deleted + Gfx::CTerrain* m_terrain; TaskTakeOrder m_order; TaskTakeArm m_arm; -- cgit v1.2.3-1-g7c22