From 67be6fca2aeacdb5372e4ab0bff943f958ab17e6 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Thu, 25 Jun 2015 19:05:56 +0200 Subject: [PATCH] CObject interface cleanup * remove unused functions and members * make protected functions used only locally or in factory * rename some functions to be more meaningful * refactor some enums to enum classes --- src/CMakeLists.txt | 24 ++-- src/graphics/engine/lightning.cpp | 6 +- src/graphics/engine/particle.cpp | 18 +-- src/graphics/engine/pyro.cpp | 8 +- src/object/auto/autobase.cpp | 4 +- src/object/auto/autoradar.cpp | 2 +- src/object/auto/autotower.cpp | 2 +- src/object/brain.cpp | 6 +- src/object/brain.h | 2 +- src/object/drive_type.cpp | 57 +++++++++ src/object/drive_type.h | 33 +++++ src/object/level/parserparam.cpp | 32 ++--- src/object/level/parserparam.h | 5 +- src/object/motion/motion.cpp | 8 +- src/object/motion/motion.h | 4 +- src/object/motion/motionant.cpp | 18 +-- src/object/motion/motionbee.cpp | 4 +- src/object/motion/motionhuman.cpp | 48 ++++---- src/object/motion/motionmother.cpp | 4 +- src/object/motion/motionspider.cpp | 14 +-- src/object/motion/motionvehicle.cpp | 2 +- src/object/object.cpp | 181 +++++----------------------- src/object/object.h | 88 +++++--------- src/object/object_factory.cpp | 16 +-- src/object/object_manager.cpp | 47 ++++---- src/object/robotmain.cpp | 46 +++---- src/object/robotmain.h | 22 ++-- src/object/task/taskbuild.cpp | 6 +- src/object/task/taskfire.cpp | 4 +- src/object/task/taskgoto.cpp | 4 +- src/object/task/taskmanip.cpp | 2 +- src/object/task/tasktake.cpp | 2 +- src/object/task/taskterraform.cpp | 4 +- src/object/tool_type.cpp | 53 ++++++++ src/object/tool_type.h | 33 +++++ src/physics/physics.cpp | 46 +++---- src/script/cbottoken.h | 4 +- src/script/cmdtoken.cpp | 53 ++++---- src/script/cmdtoken.h | 4 +- src/script/scriptfunc.cpp | 71 ++++++----- src/ui/mainshort.cpp | 2 +- src/ui/map.cpp | 6 +- src/ui/target.cpp | 2 +- 43 files changed, 523 insertions(+), 474 deletions(-) create mode 100644 src/object/drive_type.cpp create mode 100644 src/object/drive_type.h create mode 100644 src/object/tool_type.cpp create mode 100644 src/object/tool_type.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b44db6aa..5eff4c1c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -87,17 +87,17 @@ set(BASE_SOURCES common/misc.cpp common/pathman.cpp common/profile.cpp + common/resources/inputstream.cpp + common/resources/inputstreambuffer.cpp + common/resources/outputstream.cpp + common/resources/outputstreambuffer.cpp + common/resources/resourcemanager.cpp + common/resources/sndfile.cpp common/restext.cpp common/stringutils.cpp - common/resources/resourcemanager.cpp - common/resources/inputstreambuffer.cpp - common/resources/outputstreambuffer.cpp - common/resources/inputstream.cpp - common/resources/outputstream.cpp - common/resources/sndfile.cpp graphics/core/color.cpp - graphics/core/nulldevice.cpp graphics/core/framebuffer.cpp + graphics/core/nulldevice.cpp graphics/engine/camera.cpp graphics/engine/cloud.cpp graphics/engine/engine.cpp @@ -112,11 +112,11 @@ set(BASE_SOURCES graphics/engine/terrain.cpp graphics/engine/text.cpp graphics/engine/water.cpp - graphics/opengl/gldevice.cpp graphics/opengl/gl21device.cpp graphics/opengl/gl33device.cpp - graphics/opengl/glutil.cpp + graphics/opengl/gldevice.cpp graphics/opengl/glframebuffer.cpp + graphics/opengl/glutil.cpp object/auto/auto.cpp object/auto/autobase.cpp object/auto/autoconvert.cpp @@ -144,10 +144,11 @@ set(BASE_SOURCES object/auto/autostation.cpp object/auto/autotower.cpp object/brain.cpp + object/drive_type.cpp object/level/parser.cpp + object/level/parserexceptions.cpp object/level/parserline.cpp object/level/parserparam.cpp - object/level/parserexceptions.cpp object/mainmovie.cpp object/motion/motion.cpp object/motion/motionant.cpp @@ -161,8 +162,8 @@ set(BASE_SOURCES object/motion/motionworm.cpp object/object.cpp object/object_factory.cpp - object/robotmain.cpp object/object_manager.cpp + object/robotmain.cpp object/task/task.cpp object/task/taskadvance.cpp object/task/taskbuild.cpp @@ -185,6 +186,7 @@ set(BASE_SOURCES object/task/taskterraform.cpp object/task/taskturn.cpp object/task/taskwait.cpp + object/tool_type.cpp physics/physics.cpp script/cbottoken.cpp script/cmdtoken.cpp diff --git a/src/graphics/engine/lightning.cpp b/src/graphics/engine/lightning.cpp index 25709842..0ce93d3c 100644 --- a/src/graphics/engine/lightning.cpp +++ b/src/graphics/engine/lightning.cpp @@ -31,8 +31,8 @@ #include "math/geometry.h" #include "object/object.h" -#include "object/robotmain.h" #include "object/object_manager.h" +#include "object/robotmain.h" #include "object/auto/autopara.h" @@ -118,7 +118,7 @@ bool CLightning::EventFrame(const Event &event) } else { - obj->ExploObject(EXPLO_BOUM, 1.0f); + obj->ExplodeObject(ExplosionType::Bang, 1.0f); } } @@ -319,7 +319,7 @@ CObject* CLightning::SearchObject(Math::Vector pos) float min = 100000.0f; for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects()) { - if (!obj->GetActif()) continue; // inactive object? + if (!obj->GetActive()) continue; // inactive object? if (obj->GetTruck() != nullptr) continue; // object transported? ObjectType type = obj->GetType(); diff --git a/src/graphics/engine/particle.cpp b/src/graphics/engine/particle.cpp index 1ae71221..31eea1c4 100644 --- a/src/graphics/engine/particle.cpp +++ b/src/graphics/engine/particle.cpp @@ -991,9 +991,9 @@ void CParticle::FrameParticle(float rTime) if (object != nullptr) { if (object->GetType() == OBJECT_MOTHER) - object->ExploObject(EXPLO_BOUM, 0.1f); + object->ExplodeObject(ExplosionType::Bang, 0.1f); else - object->ExploObject(EXPLO_BOUM, 0.0f, GetDecay(object->GetType())); + object->ExplodeObject(ExplosionType::Bang, 0.0f, GetDecay(object->GetType())); } m_particle[i].zoom = 1.0f-(m_particle[i].time-m_particle[i].duration); @@ -1194,7 +1194,7 @@ void CParticle::FrameParticle(float rTime) m_particle[i].goal = m_particle[i].pos; if (object != nullptr) { - object->ExploObject(EXPLO_BURN, 0.0f, GetDecay(object->GetType())); + object->ExplodeObject(ExplosionType::Burn, 0.0f, GetDecay(object->GetType())); m_exploGunCounter++; @@ -1275,7 +1275,7 @@ void CParticle::FrameParticle(float rTime) if (object->GetType() != OBJECT_HUMAN) Play(SOUND_TOUCH, m_particle[i].pos, 1.0f); - object->ExploObject(EXPLO_BOUM, 0.0f); // starts explosion + object->ExplodeObject(ExplosionType::Bang, 0.0f); // starts explosion } } } @@ -1317,7 +1317,7 @@ void CParticle::FrameParticle(float rTime) } else { - object->ExploObject(EXPLO_BURN, 1.0f); // starts explosion + object->ExplodeObject(ExplosionType::Burn, 1.0f); // starts explosion } } } @@ -1373,7 +1373,7 @@ void CParticle::FrameParticle(float rTime) m_particle[i].goal = m_particle[i].pos; if (object != nullptr) { - object->ExploObject(EXPLO_BOUM, 0.0f, GetDecay(object->GetType())); + object->ExplodeObject(ExplosionType::Bang, 0.0f, GetDecay(object->GetType())); m_exploGunCounter ++; @@ -2508,7 +2508,7 @@ void CParticle::FrameParticle(float rTime) CObject* object = SearchObjectRay(m_particle[i].pos, m_particle[i].goal, m_particle[i].type, m_particle[i].objFather); if (object != nullptr) - object->ExploObject(EXPLO_BOUM, 0.0f); + object->ExplodeObject(ExplosionType::Bang, 0.0f); } ts.x = 0.00f; @@ -3659,7 +3659,7 @@ CObject* CParticle::SearchObjectGun(Math::Vector old, Math::Vector pos, bool shield = false; for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects()) { - if (!obj->GetActif()) continue; // inactive? + if (!obj->GetActive()) continue; // inactive? if (obj == father) continue; ObjectType oType = obj->GetType(); @@ -3782,7 +3782,7 @@ CObject* CParticle::SearchObjectRay(Math::Vector pos, Math::Vector goal, for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects()) { - if (!obj->GetActif()) continue; // inactive? + if (!obj->GetActive()) continue; // inactive? if (obj == father) continue; ObjectType oType = obj->GetType(); diff --git a/src/graphics/engine/pyro.cpp b/src/graphics/engine/pyro.cpp index f1ace4fe..e13feea2 100644 --- a/src/graphics/engine/pyro.cpp +++ b/src/graphics/engine/pyro.cpp @@ -1548,7 +1548,7 @@ void CPyro::ExploStart() m_object->Simplify(); m_object->SetLock(true); // ruin not usable yet - m_object->SetExplo(true); // being destroyed + m_object->SetExploding(true); // being destroyed m_object->FlatParent(); if ( m_object->GetSelect() ) @@ -2335,7 +2335,7 @@ void CPyro::FallProgress(float rTime) { if (floor) // reaches the ground? { - m_object->ExploObject(EXPLO_BOUM, 0.0f); // start explosion + m_object->ExplodeObject(ExplosionType::Bang, 0.0f); // start explosion } } else @@ -2350,13 +2350,13 @@ void CPyro::FallProgress(float rTime) } else { - if (obj->ExploObject(EXPLO_BOUM, 1.0f)) // start explosion + if (obj->ExplodeObject(ExplosionType::Bang, 1.0f)) // start explosion { DeleteObject(true, true); // removes the ball } else { - m_object->ExploObject(EXPLO_BOUM, 0.0f); // start explosion + m_object->ExplodeObject(ExplosionType::Bang, 0.0f); // start explosion } } } diff --git a/src/object/auto/autobase.cpp b/src/object/auto/autobase.cpp index 5acc4de6..3aee6853 100644 --- a/src/object/auto/autobase.cpp +++ b/src/object/auto/autobase.cpp @@ -1293,7 +1293,7 @@ Error CAutoBase::CheckCloseDoor() for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects()) { if ( obj == m_object ) continue; // yourself? - if ( !obj->GetActif() ) continue; // inactive? + if ( !obj->GetActive() ) continue; // inactive? ObjectType type = obj->GetType(); if ( type == OBJECT_PORTICO ) continue; @@ -1381,7 +1381,7 @@ Error CAutoBase::TakeOff(bool printMsg) Event newEvent; Math::Vector pos; Error err; - + err = CheckCloseDoor(); if ( err != ERR_OK ) { diff --git a/src/object/auto/autoradar.cpp b/src/object/auto/autoradar.cpp index 66294540..b612ffe0 100644 --- a/src/object/auto/autoradar.cpp +++ b/src/object/auto/autoradar.cpp @@ -271,7 +271,7 @@ bool CAutoRadar::SearchEnemy(Math::Vector &pos) CObject* best = nullptr; for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects()) { - if ( !obj->GetActif() ) continue; + if ( !obj->GetActive() ) continue; ObjectType oType = obj->GetType(); if ( oType != OBJECT_ANT && diff --git a/src/object/auto/autotower.cpp b/src/object/auto/autotower.cpp index a133e8eb..e6a84330 100644 --- a/src/object/auto/autotower.cpp +++ b/src/object/auto/autotower.cpp @@ -280,7 +280,7 @@ CObject* CAutoTower::SearchTarget(Math::Vector &impact) oType != OBJECT_BEE && oType != OBJECT_WORM ) continue; - if ( !obj->GetActif() ) continue; // inactive? + if ( !obj->GetActive() ) continue; // inactive? //? if ( g_researchDone & RESEARCH_QUICK ) if ( false ) diff --git a/src/object/brain.cpp b/src/object/brain.cpp index cbc2d8f6..0731ce46 100644 --- a/src/object/brain.cpp +++ b/src/object/brain.cpp @@ -1663,14 +1663,14 @@ bool CBrain::CreateInterface(bool bSelect) pos.y = oy+sy*0.5f; pw->CreateButton(pos, dim, 40, EVENT_OBJECT_SEARCH); DefaultEnter(pw, EVENT_OBJECT_SEARCH); - + if ( g_build&BUILD_GFLAT ) { pos.x = ox+sx*9.0f; pos.y = oy+sy*0.5f; pw->CreateButton(pos, dim, 111, EVENT_OBJECT_GFLAT); } - + pos.x = ox+sx*10.1f; pos.y = oy+sy*0.5f; pw->CreateButton(pos, dim, 11, EVENT_OBJECT_DELSEARCH); @@ -2870,7 +2870,7 @@ bool CBrain::GetCompile(Program* program) // Saves a script in a text file. -bool CBrain::WriteProgram(Program* program, char* filename) +bool CBrain::WriteProgram(Program* program, const char* filename) { if ( program->script->WriteScript(filename) ) return true; diff --git a/src/object/brain.h b/src/object/brain.h index d8d897c0..cbfa66be 100644 --- a/src/object/brain.h +++ b/src/object/brain.h @@ -123,7 +123,7 @@ public: bool ReadSoluce(char* filename); bool ReadProgram(Program* program, const char* filename); bool GetCompile(Program* program); - bool WriteProgram(Program* program, char* filename); + bool WriteProgram(Program* program, const char* filename); bool ReadStack(FILE *file); bool WriteStack(FILE *file); const std::vector& GetPrograms(); diff --git a/src/object/drive_type.cpp b/src/object/drive_type.cpp new file mode 100644 index 00000000..4951450f --- /dev/null +++ b/src/object/drive_type.cpp @@ -0,0 +1,57 @@ +/* + * This file is part of the Colobot: Gold Edition source code + * Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam + * http://epsiteс.ch; http://colobot.info; http://github.com/colobot + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://gnu.org/licenses + */ + +#include "object/drive_type.h" + +DriveType GetDriveFromObject(ObjectType type) +{ + switch(type) + { + case OBJECT_MOBILEwt: + case OBJECT_MOBILEwa: + case OBJECT_MOBILEwc: + case OBJECT_MOBILEwi: + case OBJECT_MOBILEws: + return DriveType::Wheeled; + + case OBJECT_MOBILEtt: + case OBJECT_MOBILEta: + case OBJECT_MOBILEtc: + case OBJECT_MOBILEti: + case OBJECT_MOBILEts: + return DriveType::Tracked; + + case OBJECT_MOBILEft: + case OBJECT_MOBILEfa: + case OBJECT_MOBILEfc: + case OBJECT_MOBILEfi: + case OBJECT_MOBILEfs: + return DriveType::Winged; + + case OBJECT_MOBILEit: + case OBJECT_MOBILEia: + case OBJECT_MOBILEic: + case OBJECT_MOBILEii: + case OBJECT_MOBILEis: + return DriveType::Legged; + + default: + return DriveType::Other; + } +} diff --git a/src/object/drive_type.h b/src/object/drive_type.h new file mode 100644 index 00000000..d229ab1f --- /dev/null +++ b/src/object/drive_type.h @@ -0,0 +1,33 @@ +/* + * This file is part of the Colobot: Gold Edition source code + * Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam + * http://epsiteс.ch; http://colobot.info; http://github.com/colobot + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://gnu.org/licenses + */ + +#pragma once + +#include "object/object_type.h" + +enum class DriveType : unsigned int +{ + Other = 0, + Wheeled, + Tracked, + Winged, + Legged, +}; + +DriveType GetDriveFromObject(ObjectType type); diff --git a/src/object/level/parserparam.cpp b/src/object/level/parserparam.cpp index 58c1c98e..a8872062 100644 --- a/src/object/level/parserparam.cpp +++ b/src/object/level/parserparam.cpp @@ -250,10 +250,12 @@ Gfx::Color CLevelParserParam::AsColor() ParseArray(); - if (m_array.size() == 3) { //RGB + if (m_array.size() == 3) //RGB + { return Gfx::Color(m_array[0]->AsFloat(), m_array[1]->AsFloat(), m_array[2]->AsFloat()); } - else if (m_array.size() == 4) { //RGBA + else if (m_array.size() == 4) //RGBA + { return Gfx::Color(m_array[0]->AsFloat(), m_array[1]->AsFloat(), m_array[2]->AsFloat(), m_array[3]->AsFloat()); } else @@ -277,10 +279,12 @@ Math::Vector CLevelParserParam::AsPoint() ParseArray(); - if (m_array.size() == 2) { //XZ + if (m_array.size() == 2) //XZ + { return Math::Vector(m_array[0]->AsFloat(), 0.0f, m_array[1]->AsFloat()); } - else if (m_array.size() == 3) { //XYZ + else if (m_array.size() == 3) //XYZ + { return Math::Vector(m_array[0]->AsFloat(), m_array[1]->AsFloat(), m_array[2]->AsFloat()); } else @@ -719,11 +723,11 @@ ObjectType CLevelParserParam::AsObjectType(ObjectType def) DriveType CLevelParserParam::ToDriveType(std::string value) { - if (value == "Wheeled") return DRIVE_WHEELED; - if (value == "Tracked") return DRIVE_TRACKED; - if (value == "Winged" ) return DRIVE_WINGED; - if (value == "Legged" ) return DRIVE_LEGGED; - if (value == "Other" ) return DRIVE_OTHER; + if (value == "Wheeled") return DriveType::Wheeled; + if (value == "Tracked") return DriveType::Tracked; + if (value == "Winged" ) return DriveType::Winged; + if (value == "Legged" ) return DriveType::Legged; + if (value == "Other" ) return DriveType::Other; return static_cast(Cast(value, "drive")); } @@ -744,11 +748,11 @@ DriveType CLevelParserParam::AsDriveType(DriveType def) ToolType CLevelParserParam::ToToolType(std::string value) { - if (value == "Grabber" ) return TOOL_GRABBER; - if (value == "Shiffer" ) return TOOL_SNIFFER; - if (value == "Shooter" ) return TOOL_SHOOTER; - if (value == "OrgaShooter") return TOOL_ORGASHOOTER; - if (value == "Other" ) return TOOL_OTHER; + if (value == "Grabber" ) return ToolType::Grabber; + if (value == "Sniffer" ) return ToolType::Sniffer; + if (value == "Shooter" ) return ToolType::Shooter; + if (value == "OrgaShooter") return ToolType::OrganicShooter; + if (value == "Other" ) return ToolType::Other; return static_cast(Cast(value, "tool")); } diff --git a/src/object/level/parserparam.h b/src/object/level/parserparam.h index a4511c12..cd47f3c7 100644 --- a/src/object/level/parserparam.h +++ b/src/object/level/parserparam.h @@ -25,12 +25,15 @@ #pragma once #include "graphics/core/color.h" +#include "graphics/engine/camera.h" #include "graphics/engine/water.h" #include "graphics/engine/pyro_type.h" #include "math/point.h" -#include "object/object.h" +#include "object/drive_type.h" +#include "object/object_type.h" +#include "object/tool_type.h" #include #include diff --git a/src/object/motion/motion.cpp b/src/object/motion/motion.cpp index c5c43ec6..d7e76933 100644 --- a/src/object/motion/motion.cpp +++ b/src/object/motion/motion.cpp @@ -112,11 +112,11 @@ bool CMotion::EventProcess(const Event &event) dir.z = Math::Smooth(dir.z, m_cirVibration.z, time); m_object->SetCirVibration(dir); - dir = m_object->GetInclinaison(); + dir = m_object->GetTilt(); dir.x = Math::Smooth(dir.x, m_inclinaison.x, time); dir.y = Math::Smooth(dir.y, m_inclinaison.y, time); dir.z = Math::Smooth(dir.z, m_inclinaison.z, time); - m_object->SetInclinaison(dir); + m_object->SetTilt(dir); return true; } @@ -207,12 +207,12 @@ Math::Vector CMotion::GetCirVibration() // Getes the tilt. -void CMotion::SetInclinaison(Math::Vector dir) +void CMotion::SetTilt(Math::Vector dir) { m_inclinaison = dir; } -Math::Vector CMotion::GetInclinaison() +Math::Vector CMotion::GetTilt() { return m_inclinaison; } diff --git a/src/object/motion/motion.h b/src/object/motion/motion.h index d8447a80..55df1898 100644 --- a/src/object/motion/motion.h +++ b/src/object/motion/motion.h @@ -70,8 +70,8 @@ public: virtual Math::Vector GetLinVibration(); virtual void SetCirVibration(Math::Vector dir); virtual Math::Vector GetCirVibration(); - virtual void SetInclinaison(Math::Vector dir); - virtual Math::Vector GetInclinaison(); + virtual void SetTilt(Math::Vector dir); + virtual Math::Vector GetTilt(); protected: CApplication* m_app; diff --git a/src/object/motion/motionant.cpp b/src/object/motion/motionant.cpp index aea3ccf0..68b55024 100644 --- a/src/object/motion/motionant.cpp +++ b/src/object/motion/motionant.cpp @@ -589,7 +589,7 @@ bool CMotionAnt::EventFrame(const Event &event) dir.x = 0.0f; dir.y = 0.0f; dir.z = Math::PropAngle(0, -50, prog); - SetInclinaison(dir); + SetTilt(dir); m_object->SetAngleZ(1, Math::PropAngle(0, 65, prog)); // head m_object->SetAngleZ(2, Math::PropAngle(0, -95, prog)); // tail } @@ -613,7 +613,7 @@ bool CMotionAnt::EventFrame(const Event &event) dir.x = 0.0f; dir.y = 0.0f; dir.z = Math::PropAngle(0, -50, prog); - SetInclinaison(dir); + SetTilt(dir); m_object->SetAngleZ(1, Math::PropAngle(0, 65, prog)); // head m_object->SetAngleZ(2, Math::PropAngle(0, -95, prog)); // tail } @@ -624,7 +624,7 @@ bool CMotionAnt::EventFrame(const Event &event) dir = Math::Vector(0.0f, -1.5f, 0.0f); SetLinVibration(dir); dir = Math::Vector(0.0f, 0.0f, 0.0f); - SetInclinaison(dir); + SetTilt(dir); time = event.rTime*1.0f; m_object->SetAngleZ(1, Math::Smooth(m_object->GetAngleZ(1), 0.0f, time)); // head @@ -635,7 +635,7 @@ bool CMotionAnt::EventFrame(const Event &event) dir = Math::Vector(0.0f, 0.0f, 0.0f); SetLinVibration(dir); SetCirVibration(dir); - SetInclinaison(dir); + SetTilt(dir); } else if ( m_actionType == MAS_BACK1 ) // starts on the back? { @@ -672,7 +672,7 @@ bool CMotionAnt::EventFrame(const Event &event) SetCirVibration(dir); dir = Math::Vector(0.0f, 0.0f, 0.0f); - SetInclinaison(dir); + SetTilt(dir); if ( m_progress >= 1.0f ) { @@ -716,7 +716,7 @@ bool CMotionAnt::EventFrame(const Event &event) sinf(m_armTimeAbs*23.0f)*0.03f; SetCirVibration(dir); dir = Math::Vector(0.0f, 0.0f, 0.0f); - SetInclinaison(dir); + SetTilt(dir); m_object->SetAngleY(1, sinf(m_armTimeAbs*8.0f)*0.7f); // head m_object->SetAngleY(2, cosf(m_armTimeAbs*8.0f)*0.7f); // tail @@ -763,7 +763,7 @@ bool CMotionAnt::EventFrame(const Event &event) SetCirVibration(dir); dir = Math::Vector(0.0f, 0.0f, 0.0f); - SetInclinaison(dir); + SetTilt(dir); if ( m_progress >= 1.0f ) { @@ -783,7 +783,7 @@ bool CMotionAnt::EventFrame(const Event &event) dir = Math::Vector(0.0f, 0.0f, 0.0f); SetLinVibration(dir); - SetInclinaison(dir); + SetTilt(dir); } else { @@ -798,7 +798,7 @@ bool CMotionAnt::EventFrame(const Event &event) dir.z = sinf(s)*0.1f; dir.y = 0.0f; - SetInclinaison(dir); + SetTilt(dir); m_object->SetAngleZ(2, -sinf(a)*0.3f); // tail diff --git a/src/object/motion/motionbee.cpp b/src/object/motion/motionbee.cpp index c954bede..addec171 100644 --- a/src/object/motion/motionbee.cpp +++ b/src/object/motion/motionbee.cpp @@ -30,7 +30,7 @@ #include -#define ADJUST_ANGLE 0 // 1 -> adjusts the angles of the members +#define ADJUST_ANGLE 0 // 1 -> adjusts the angles of the members const float START_TIME = 1000.0f; // beginning of the relative time @@ -541,7 +541,7 @@ bool CMotionBee::EventFrame(const Event &event) dir.z = sinf(s)*0.1f; dir.y = 0.0f; - m_object->SetInclinaison(dir); + m_object->SetTilt(dir); m_object->SetAngleZ(2, -sinf(a)*0.3f); // tail diff --git a/src/object/motion/motionhuman.cpp b/src/object/motion/motionhuman.cpp index 60ade452..51e447f5 100644 --- a/src/object/motion/motionhuman.cpp +++ b/src/object/motion/motionhuman.cpp @@ -1178,11 +1178,11 @@ bool CMotionHuman::EventFrame(const Event &event) dir.x = 0.0f; dir.y = (Math::Rand()-0.5f)/3.0f; dir.z = -0.1f; // slightly leaning forward - actual = m_object->GetInclinaison(); + actual = m_object->GetTilt(); dir.x = Math::Smooth(actual.x, dir.x, time); dir.y = Math::Smooth(actual.y, dir.y, time); dir.z = Math::Smooth(actual.z, dir.z, time); - m_object->SetInclinaison(dir); + m_object->SetTilt(dir); } else if ( m_actionType == MHS_TAKE || // carrying? m_actionType == MHS_TAKEOTHER ) // flag? @@ -1202,11 +1202,11 @@ bool CMotionHuman::EventFrame(const Event &event) dir.x = 0.0f; dir.y = 0.0f; dir.z = -0.2f; - actual = m_object->GetInclinaison(); + actual = m_object->GetTilt(); dir.x = Math::Smooth(actual.x, dir.x, time); dir.y = Math::Smooth(actual.y, dir.y, time); dir.z = Math::Smooth(actual.z, dir.z, time); - m_object->SetInclinaison(dir); + m_object->SetTilt(dir); } else if ( m_actionType == MHS_TAKEHIGH ) // carrying? { @@ -1225,11 +1225,11 @@ bool CMotionHuman::EventFrame(const Event &event) dir.x = 0.0f; dir.y = 0.0f; dir.z = -0.2f; - actual = m_object->GetInclinaison(); + actual = m_object->GetTilt(); dir.x = Math::Smooth(actual.x, dir.x, time); dir.y = Math::Smooth(actual.y, dir.y, time); dir.z = Math::Smooth(actual.z, dir.z, time); - m_object->SetInclinaison(dir); + m_object->SetTilt(dir); } else if ( m_actionType == MHS_FLAG ) // flag? { @@ -1248,11 +1248,11 @@ bool CMotionHuman::EventFrame(const Event &event) dir.x = 0.0f; dir.y = 0.0f; dir.z = -0.4f; - actual = m_object->GetInclinaison(); + actual = m_object->GetTilt(); dir.x = Math::Smooth(actual.x, dir.x, time); dir.y = Math::Smooth(actual.y, dir.y, time); dir.z = Math::Smooth(actual.z, dir.z, time); - m_object->SetInclinaison(dir); + m_object->SetTilt(dir); } else if ( m_actionType == MHS_DEADg ) // shooting death (falls)? { @@ -1298,11 +1298,11 @@ bool CMotionHuman::EventFrame(const Event &event) dir.x = 0.0f; dir.y = 0.0f; dir.z = -(20.0f*Math::PI/180.0f)*prog; - actual = m_object->GetInclinaison(); + actual = m_object->GetTilt(); dir.x = Math::Smooth(actual.x, dir.x, time); dir.y = Math::Smooth(actual.y, dir.y, time); dir.z = Math::Smooth(actual.z, dir.z, time); - m_object->SetInclinaison(dir); + m_object->SetTilt(dir); } else if ( m_actionType == MHS_DEADg2 ) // shooting death (knees)? { @@ -1325,11 +1325,11 @@ bool CMotionHuman::EventFrame(const Event &event) dir.x = 0.0f; dir.y = 0.0f; dir.z = -(20.0f*Math::PI/180.0f); - actual = m_object->GetInclinaison(); + actual = m_object->GetTilt(); dir.x = Math::Smooth(actual.x, dir.x, time); dir.y = Math::Smooth(actual.y, dir.y, time); dir.z = Math::Smooth(actual.z, dir.z, time); - m_object->SetInclinaison(dir); + m_object->SetTilt(dir); } else if ( m_actionType == MHS_DEADg3 ) // shooting death (face down)? { @@ -1369,11 +1369,11 @@ bool CMotionHuman::EventFrame(const Event &event) dir.z = -((20.0f*Math::PI/180.0f)+(70.0f*Math::PI/180.0f)*prog); dir.x = 0.0f; dir.y = 0.0f; - actual = m_object->GetInclinaison(); + actual = m_object->GetTilt(); dir.x = Math::Smooth(actual.x, dir.x, time); dir.y = Math::Smooth(actual.y, dir.y, time); dir.z = Math::Smooth(actual.z, dir.z, time); - m_object->SetInclinaison(dir); + m_object->SetTilt(dir); } else if ( m_actionType == MHS_DEADg4 ) // shooting death (face down)? { @@ -1396,11 +1396,11 @@ bool CMotionHuman::EventFrame(const Event &event) dir.z = -((20.0f*Math::PI/180.0f)+(70.0f*Math::PI/180.0f)); dir.x = 0.0f; dir.y = 0.0f; - actual = m_object->GetInclinaison(); + actual = m_object->GetTilt(); dir.x = Math::Smooth(actual.x, dir.x, time); dir.y = Math::Smooth(actual.y, dir.y, time); dir.z = Math::Smooth(actual.z, dir.z, time); - m_object->SetInclinaison(dir); + m_object->SetTilt(dir); } else if ( m_actionType == MHS_DEADw ) // drowned? { @@ -1434,11 +1434,11 @@ bool CMotionHuman::EventFrame(const Event &event) dir.z = -(90.0f*Math::PI/180.0f)*prog; dir.x = Math::Rand()*0.3f*deadFactor; dir.y = Math::Rand()*0.3f*deadFactor; - actual = m_object->GetInclinaison(); + actual = m_object->GetTilt(); dir.x = Math::Smooth(actual.x, dir.x, time); dir.y = Math::Smooth(actual.y, dir.y, time); dir.z = Math::Smooth(actual.z, dir.z, time); - m_object->SetInclinaison(dir); + m_object->SetTilt(dir); m_object->SetCirVibration(Math::Vector(0.0f, 0.0f, 0.0f)); } @@ -1450,8 +1450,8 @@ bool CMotionHuman::EventFrame(const Event &event) dir.x = time*2.0f; dir.y = sinf(m_time*0.8f)*0.8f; dir.z = sinf(m_time*0.6f)*0.5f; - m_object->SetInclinaison(dir); - SetInclinaison(dir); + m_object->SetTilt(dir); + SetTilt(dir); //? dir.x = -(sinf(time*0.05f+Math::PI*1.5f)+1.0f)*100.0f; // original code: Math::Min(time/30.0f) (?) changed to time/30.0f @@ -1478,7 +1478,7 @@ bool CMotionHuman::EventFrame(const Event &event) { SetCirVibration(Math::Vector(0.0f, 0.0f, 0.0f)); SetLinVibration(Math::Vector(0.0f, 0.0f, 0.0f)); - SetInclinaison(Math::Vector(0.0f, 0.0f, 0.0f)); + SetTilt(Math::Vector(0.0f, 0.0f, 0.0f)); } else { @@ -1509,13 +1509,13 @@ bool CMotionHuman::EventFrame(const Event &event) if ( s < 0.0f ) s *= 0.5f; dir.z = -s*0.7f; - actual = m_object->GetInclinaison(); + actual = m_object->GetTilt(); dir.x = Math::Smooth(actual.x, dir.x, time); dir.y = Math::Smooth(actual.y, dir.y, time); dir.z = Math::Smooth(actual.z, dir.z, time); if ( bOnBoard ) dir *= 0.3f; - m_object->SetInclinaison(dir); - SetInclinaison(dir); + m_object->SetTilt(dir); + SetTilt(dir); if ( action == MH_MARCH ) // walking? { diff --git a/src/object/motion/motionmother.cpp b/src/object/motion/motionmother.cpp index 59772b3f..7372e858 100644 --- a/src/object/motion/motionmother.cpp +++ b/src/object/motion/motionmother.cpp @@ -30,7 +30,7 @@ #include -#define ADJUST_ANGLE 0 // 1 -> adjusts the angles of the members +#define ADJUST_ANGLE 0 // 1 -> adjusts the angles of the members const float START_TIME = 1000.0f; // beginning of the relative time @@ -454,7 +454,7 @@ bool CMotionMother::EventFrame(const Event &event) dir.z = sinf(s)*0.05f; dir.y = 0.0f; - m_object->SetInclinaison(dir); + m_object->SetTilt(dir); a = Math::Mod(m_armMember-0.1f, 1.0f); if ( a < 0.33f ) diff --git a/src/object/motion/motionspider.cpp b/src/object/motion/motionspider.cpp index a1d82bb5..d028a4b5 100644 --- a/src/object/motion/motionspider.cpp +++ b/src/object/motion/motionspider.cpp @@ -542,7 +542,7 @@ bool CMotionSpider::EventFrame(const Event &event) SetCirVibration(dir); dir = Math::Vector(0.0f, 0.0f, 0.0f); SetLinVibration(dir); - SetInclinaison(dir); + SetTilt(dir); time = event.rTime*1.0f; m_object->SetAngleZ(1, Math::Smooth(m_object->GetAngleZ(1), 0.0f, time)); // head @@ -552,7 +552,7 @@ bool CMotionSpider::EventFrame(const Event &event) dir = Math::Vector(0.0f, 0.0f, 0.0f); SetLinVibration(dir); SetCirVibration(dir); - SetInclinaison(dir); + SetTilt(dir); } else if ( m_actionType == MSS_EXPLO ) // exploded? { @@ -600,7 +600,7 @@ bool CMotionSpider::EventFrame(const Event &event) SetCirVibration(dir); dir = Math::Vector(0.0f, 0.0f, 0.0f); - SetInclinaison(dir); + SetTilt(dir); if ( m_progress >= 1.0f ) { @@ -644,7 +644,7 @@ bool CMotionSpider::EventFrame(const Event &event) sinf(m_armTimeAbs*15.0f)*0.03f; SetCirVibration(dir); dir = Math::Vector(0.0f, 0.0f, 0.0f); - SetInclinaison(dir); + SetTilt(dir); m_object->SetAngleY(1, sinf(m_armTimeAbs*5.0f)*0.05f); // tail m_object->SetAngleY(2, cosf(m_armTimeAbs*5.0f)*0.20f); // head @@ -691,7 +691,7 @@ bool CMotionSpider::EventFrame(const Event &event) SetCirVibration(dir); dir = Math::Vector(0.0f, 0.0f, 0.0f); - SetInclinaison(dir); + SetTilt(dir); if ( m_progress >= 1.0f ) { @@ -704,7 +704,7 @@ bool CMotionSpider::EventFrame(const Event &event) if ( bStop ) { dir = Math::Vector(0.0f, 0.0f, 0.0f); - SetInclinaison(dir); + SetTilt(dir); } else { @@ -719,7 +719,7 @@ bool CMotionSpider::EventFrame(const Event &event) dir.z = sinf(s)*0.1f; dir.y = 0.0f; - SetInclinaison(dir); + SetTilt(dir); } dir = Math::Vector(0.0f, 0.0f, 0.0f); diff --git a/src/object/motion/motionvehicle.cpp b/src/object/motion/motionvehicle.cpp index 7c5a8a20..14a69f54 100644 --- a/src/object/motion/motionvehicle.cpp +++ b/src/object/motion/motionvehicle.cpp @@ -1784,7 +1784,7 @@ bool CMotionVehicle::EventFrameInsect(const Event &event) dir.y = 0.0f; if ( bOnBoard ) dir *= 0.6f; - SetInclinaison(dir); + SetTilt(dir); } return true; diff --git a/src/object/object.cpp b/src/object/object.cpp index 6b8cf050..70f7ebf9 100644 --- a/src/object/object.cpp +++ b/src/object/object.cpp @@ -125,7 +125,7 @@ void uObject(CBotVar* botThis, void* user) // Updates the angle. pos = object->GetAngle(0); - pos += object->GetInclinaison(); + pos += object->GetTilt(); pVar = pVar->GetNext(); // "orientation" pVar->SetValFloat(360.0f-Math::Mod(pos.y*180.0f/Math::PI, 360.0f)); pVar = pVar->GetNext(); // "pitch" @@ -198,7 +198,7 @@ CObject::CObject(int id) m_type = OBJECT_FIX; m_option = 0; - m_name[0] = 0; + m_name = ""; m_partiReactor = -1; m_shadowLight = -1; m_effectLight = -1; @@ -223,7 +223,6 @@ CObject::CObject(int id) m_bCheckToken = true; m_bVisible = true; m_bEnable = true; - m_bGadget = false; m_bProxyActivate = false; m_bTrainer = false; m_bToy = false; @@ -292,8 +291,8 @@ CObject::CObject(int id) FlushCrashShere(); m_globalSpherePos = Math::Vector(0.0f, 0.0f, 0.0f); m_globalSphereRadius = 0.0f; - m_jotlerSpherePos = Math::Vector(0.0f, 0.0f, 0.0f); - m_jotlerSphereRadius = 0.0f; + m_jostlingSpherePos = Math::Vector(0.0f, 0.0f, 0.0f); + m_jostlingSphereRadius = 0.0f; CBotClass* bc = CBotClass::Find("object"); if ( bc != 0 ) @@ -500,12 +499,12 @@ void CObject::Simplify() // If false is returned, the object is still screwed. // If true is returned, the object is destroyed. -bool CObject::ExploObject(ExploType type, float force, float decay) +bool CObject::ExplodeObject(ExplosionType type, float force, float decay) { Gfx::PyroType pyroType; float loss, shield; - if ( type == EXPLO_BURN ) + if ( type == ExplosionType::Bang ) { if ( m_type == OBJECT_MOBILEtg || m_type == OBJECT_TEEN28 || // cylinder? @@ -521,13 +520,13 @@ bool CObject::ExploObject(ExploType type, float force, float decay) m_type == OBJECT_BULLET || m_type == OBJECT_EGG ) // object that isn't burning? { - type = EXPLO_BOUM; + type = ExplosionType::Bang; force = 1.0f; decay = 1.0f; } } - if ( type == EXPLO_BOUM ) + if ( type == ExplosionType::Bang ) { if ( m_shotTime < 0.5f ) return false; m_shotTime = 0.0f; @@ -566,7 +565,7 @@ bool CObject::ExploObject(ExploType type, float force, float decay) if ( shield > 0.0f ) // not dead yet? { - if ( type == EXPLO_WATER ) + if ( type == ExplosionType::Water ) { if ( m_type == OBJECT_HUMAN ) { @@ -595,7 +594,7 @@ bool CObject::ExploObject(ExploType type, float force, float decay) } else // completely dead? { - if ( type == EXPLO_BURN ) // burning? + if ( type == ExplosionType::Burn ) // burning? { if ( m_type == OBJECT_MOTHER || m_type == OBJECT_ANT || @@ -618,7 +617,7 @@ bool CObject::ExploObject(ExploType type, float force, float decay) } SetVirusMode(false); } - else if ( type == EXPLO_WATER ) + else if ( type == ExplosionType::Water ) { if ( m_type == OBJECT_HUMAN ) { @@ -845,7 +844,7 @@ void CObject::SetObjectParent(int part, int parent) void CObject::SetType(ObjectType type) { m_type = type; - strcpy(m_name, GetObjectName(m_type)); + m_name = GetObjectName(m_type); if ( m_type == OBJECT_MOBILErs ) { @@ -880,9 +879,9 @@ ObjectType CObject::GetType() return m_type; } -char* CObject::GetName() +const char* CObject::GetName() { - return m_name; + return m_name.c_str(); } @@ -1186,7 +1185,7 @@ bool CObject::GetCrashSphere(int rank, Math::Vector &pos, float &radius) // Returns to the sphere collisions, // which ignores the inclination of the vehicle. // This is necessary to collisions with vehicles, - // so as not to reflect SetInclinaison, for example. + // so as not to reflect SetTilt, for example. // The sphere must necessarily have a center (0, y, 0). if ( rank == 0 && m_crashSphereUsed == 1 && m_crashSpherePos[0].x == 0.0f && @@ -1259,18 +1258,18 @@ void CObject::GetGlobalSphere(Math::Vector &pos, float &radius) // Specifies the sphere of jostling, relative to the object. -void CObject::SetJotlerSphere(Math::Vector pos, float radius) +void CObject::SetJostlingSphere(Math::Vector pos, float radius) { - m_jotlerSpherePos = pos; - m_jotlerSphereRadius = radius; + m_jostlingSpherePos = pos; + m_jostlingSphereRadius = radius; } // Specifies the sphere of jostling, in the world. -void CObject::GetJotlerSphere(Math::Vector &pos, float &radius) +void CObject::GetJostlingSphere(Math::Vector &pos, float &radius) { - pos = Math::Transform(m_objectPart[0].matWorld, m_jotlerSpherePos); - radius = m_jotlerSphereRadius; + pos = Math::Transform(m_objectPart[0].matWorld, m_jostlingSpherePos); + radius = m_jostlingSphereRadius; } @@ -1371,7 +1370,7 @@ Math::Vector CObject::GetCirVibration() // Getes the inclination. -void CObject::SetInclinaison(Math::Vector dir) +void CObject::SetTilt(Math::Vector dir) { if ( m_inclinaison.x != dir.x || m_inclinaison.y != dir.y || @@ -1382,7 +1381,7 @@ void CObject::SetInclinaison(Math::Vector dir) } } -Math::Vector CObject::GetInclinaison() +Math::Vector CObject::GetTilt() { return m_inclinaison; } @@ -1805,20 +1804,8 @@ void CObject::SetTruckPart(int part) m_truckLink = part; } -int CObject::GetTruckPart() -{ - return m_truckLink; -} - - // Management of user information. -void CObject::InfoFlush() -{ - m_infoTotal = 0; - m_bInfoUpdate = true; -} - void CObject::DeleteInfo(int rank) { int i; @@ -1895,16 +1882,6 @@ Math::Matrix* CObject::GetRotateMatrix(int part) return &m_objectPart[part].matRotate; } -Math::Matrix* CObject::GetTranslateMatrix(int part) -{ - return &m_objectPart[part].matTranslate; -} - -Math::Matrix* CObject::GetTransformMatrix(int part) -{ - return &m_objectPart[part].matTransform; -} - Math::Matrix* CObject::GetWorldMatrix(int part) { if ( m_objectPart[0].bTranslate || @@ -2056,7 +2033,7 @@ bool CObject::ReadProgram(Program* program, const char* filename) // Writes a program. -bool CObject::WriteProgram(Program* program, char* filename) +bool CObject::WriteProgram(Program* program, const char* filename) { if ( m_brain != nullptr ) { @@ -2680,11 +2657,6 @@ void CObject::SetViewFromHere(Math::Vector &eye, float &dirH, float &dirV, // Management of features. -void CObject::SetCharacter(Character* character) -{ - memcpy(&m_character, character, sizeof(Character)); -} - void CObject::GetCharacter(Character* character) { memcpy(character, &m_character, sizeof(Character)); @@ -2817,25 +2789,6 @@ void CObject::SetTransparency(float value) } } -float CObject::GetTransparency() -{ - return m_transparency; -} - - -// Indicates whether the gadget is a nonessential. - -void CObject::SetGadget(bool bMode) -{ - m_bGadget = bMode; -} - -bool CObject::GetGadget() -{ - return m_bGadget; -} - - // Indicates whether an object is stationary (ant on the back). void CObject::SetFixed(bool bFixed) @@ -3017,11 +2970,6 @@ void CObject::SetHilite(bool bMode) } } -bool CObject::GetHilite() -{ - return m_bHilite; -} - // Indicates whether the object is selected or not. @@ -3132,11 +3080,6 @@ void CObject::SetVisible(bool bVisible) m_bVisible = bVisible; } -bool CObject::GetVisible() -{ - return m_bVisible; -} - // Management mode of operation of an object. // An inactive object is an object destroyed, nonexistent. @@ -3232,12 +3175,12 @@ bool CObject::GetIgnoreBuildCheck() // Management of the mode "current explosion" of an object. // An object in this mode is not saving. -void CObject::SetExplo(bool bExplo) +void CObject::SetExploding(bool bExplo) { m_bExplo = bExplo; } -bool CObject::GetExplo() +bool CObject::IsExploding() { return m_bExplo; } @@ -3300,7 +3243,7 @@ bool CObject::GetRuin() return m_bBurn|m_bFlat; } -bool CObject::GetActif() +bool CObject::GetActive() { return !m_bLock && !m_bBurn && !m_bFlat && m_bVisible && m_bEnable; } @@ -3843,73 +3786,3 @@ void CObject::SetTraceWidth(float width) } mv->SetTraceWidth(width); } - -DriveType CObject::GetDriveFromObject(ObjectType type) -{ - switch(type) - { - case OBJECT_MOBILEwt: - case OBJECT_MOBILEwa: - case OBJECT_MOBILEwc: - case OBJECT_MOBILEwi: - case OBJECT_MOBILEws: - return DRIVE_WHEELED; - - case OBJECT_MOBILEtt: - case OBJECT_MOBILEta: - case OBJECT_MOBILEtc: - case OBJECT_MOBILEti: - case OBJECT_MOBILEts: - return DRIVE_TRACKED; - - case OBJECT_MOBILEft: - case OBJECT_MOBILEfa: - case OBJECT_MOBILEfc: - case OBJECT_MOBILEfi: - case OBJECT_MOBILEfs: - return DRIVE_WINGED; - - case OBJECT_MOBILEit: - case OBJECT_MOBILEia: - case OBJECT_MOBILEic: - case OBJECT_MOBILEii: - case OBJECT_MOBILEis: - return DRIVE_LEGGED; - - default: - return DRIVE_OTHER; - } -} - -ToolType CObject::GetToolFromObject(ObjectType type) -{ - switch(type) - { - case OBJECT_MOBILEwa: - case OBJECT_MOBILEta: - case OBJECT_MOBILEfa: - case OBJECT_MOBILEia: - return TOOL_GRABBER; - - case OBJECT_MOBILEws: - case OBJECT_MOBILEts: - case OBJECT_MOBILEfs: - case OBJECT_MOBILEis: - return TOOL_SNIFFER; - - case OBJECT_MOBILEwc: - case OBJECT_MOBILEtc: - case OBJECT_MOBILEfc: - case OBJECT_MOBILEic: - return TOOL_SHOOTER; - - case OBJECT_MOBILEwi: - case OBJECT_MOBILEti: - case OBJECT_MOBILEfi: - case OBJECT_MOBILEii: - return TOOL_ORGASHOOTER; - - default: - return TOOL_OTHER; - } -} diff --git a/src/object/object.h b/src/object/object.h index c09e541d..008103f4 100644 --- a/src/object/object.h +++ b/src/object/object.h @@ -32,6 +32,7 @@ #include "sound/sound.h" +#include class CApplication; class CPhysics; @@ -46,43 +47,24 @@ class CLevelParserLine; struct Program; // The father of all parts must always be the part number zero! - const int OBJECTMAXPART = 40; const int MAXCRASHSPHERE = 40; const int OBJECTMAXDESELLIST = 10; const int OBJECTMAXINFO = 10; const int OBJECTMAXCMDLINE = 20; -enum DriveType -{ - DRIVE_OTHER = 0, - DRIVE_WHEELED, - DRIVE_TRACKED, - DRIVE_WINGED, - DRIVE_LEGGED, -}; - -enum ToolType -{ - TOOL_OTHER = 0, - TOOL_GRABBER, - TOOL_SNIFFER, - TOOL_SHOOTER, - TOOL_ORGASHOOTER, -}; - struct ObjectPart { - char bUsed; + bool bUsed; int object; // number of the object in CEngine int parentPart; // number of father part int masterParti; // master canal of the particle Math::Vector position; Math::Vector angle; Math::Vector zoom; - char bTranslate; - char bRotate; - char bZoom; + bool bTranslate; + bool bRotate; + bool bZoom; Math::Matrix matTranslate; Math::Matrix matRotate; Math::Matrix matTransform; @@ -105,11 +87,11 @@ struct Info float value; // value of the information }; -enum ExploType +enum class ExplosionType { - EXPLO_BOUM = 1, - EXPLO_BURN = 2, - EXPLO_WATER = 3, + Bang = 1, + Burn = 2, + Water = 3, }; enum ResetCap @@ -135,6 +117,11 @@ protected: void SetBrain(std::unique_ptr brain); void SetMotion(std::unique_ptr motion); void SetAuto(std::unique_ptr automat); + void SetShowLimitRadius(float radius); + void SetCapacity(float capacity); + float GetProxyDistance(); + void SetOption(int option); + void SetJostlingSphere(Math::Vector pos, float radius); public: CObject(const CObject&) = delete; @@ -143,7 +130,7 @@ public: ~CObject(); void Simplify(); - bool ExploObject(ExploType type, float force, float decay=1.0f); + bool ExplodeObject(ExplosionType type, float force, float decay=1.0f); bool EventProcess(const Event &event); void UpdateMapping(); @@ -153,10 +140,9 @@ public: void SetObjectRank(int part, int objRank); int GetObjectRank(int part); void SetObjectParent(int part, int parent); - void SetType(ObjectType type); ObjectType GetType(); - char* GetName(); - void SetOption(int option); + void SetType(ObjectType type); + const char* GetName(); int GetOption(); int GetID(); @@ -168,7 +154,7 @@ public: void SetDrawFront(bool bDraw); bool ReadProgram(Program* program, const char* filename); - bool WriteProgram(Program* program, char* filename); + bool WriteProgram(Program* program, const char* filename); int GetShadowLight(); int GetEffectLight(); @@ -182,8 +168,7 @@ public: void DeleteCrashSphere(int rank); void SetGlobalSphere(Math::Vector pos, float radius); void GetGlobalSphere(Math::Vector &pos, float &radius); - void SetJotlerSphere(Math::Vector pos, float radius); - void GetJotlerSphere(Math::Vector &pos, float &radius); + void GetJostlingSphere(Math::Vector &pos, float &radius); void SetShieldRadius(float radius); float GetShieldRadius(); @@ -194,8 +179,8 @@ public: Math::Vector GetLinVibration(); void SetCirVibration(Math::Vector dir); Math::Vector GetCirVibration(); - void SetInclinaison(Math::Vector dir); - Math::Vector GetInclinaison(); + void SetTilt(Math::Vector dir); + Math::Vector GetTilt(); void SetPosition(int part, const Math::Vector &pos); Math::Vector GetPosition(int part); @@ -249,9 +234,7 @@ public: void SetTruck(CObject* truck); CObject* GetTruck(); void SetTruckPart(int part); - int GetTruckPart(); - void InfoFlush(); void DeleteInfo(int rank); void SetInfo(int rank, Info info); Info GetInfo(int rank); @@ -265,15 +248,12 @@ public: float GetCmdLine(int rank); Math::Matrix* GetRotateMatrix(int part); - Math::Matrix* GetTranslateMatrix(int part); - Math::Matrix* GetTransformMatrix(int part); Math::Matrix* GetWorldMatrix(int part); void SetViewFromHere(Math::Vector &eye, float &dirH, float &dirV, Math::Vector &lookat, Math::Vector &upVec, Gfx::CameraType type); - void SetCharacter(Character* character); void GetCharacter(Character* character); Character* GetCharacter(); @@ -282,7 +262,6 @@ public: void SetEnergy(float level); float GetEnergy(); - void SetCapacity(float capacity); float GetCapacity(); void SetShield(float level); @@ -292,10 +271,6 @@ public: float GetRange(); void SetTransparency(float value); - float GetTransparency(); - - void SetGadget(bool bMode); - bool GetGadget(); void SetFixed(bool bFixed); bool GetFixed(); @@ -319,7 +294,6 @@ public: bool GetCameraLock(); void SetHilite(bool bMode); - bool GetHilite(); void SetSelect(bool bMode, bool bDisplayError=true); bool GetSelect(bool bReal=false); @@ -331,7 +305,6 @@ public: bool GetActivity(); void SetVisible(bool bVisible); - bool GetVisible(); void SetEnable(bool bEnable); bool GetEnable(); @@ -342,19 +315,18 @@ public: void SetProxyActivate(bool bActivate); bool GetProxyActivate(); void SetProxyDistance(float distance); - float GetProxyDistance(); void SetMagnifyDamage(float factor); float GetMagnifyDamage(); void SetParam(float value); float GetParam(); - + void SetIgnoreBuildCheck(bool bIgnoreBuildCheck); bool GetIgnoreBuildCheck(); - void SetExplo(bool bExplo); - bool GetExplo(); + void SetExploding(bool bExplo); + bool IsExploding(); void SetLock(bool bLock); bool GetLock(); void SetCargo(bool bCargo); @@ -364,7 +336,7 @@ public: void SetDead(bool bDead); bool GetDead(); bool GetRuin(); - bool GetActif(); + bool GetActive(); void SetGunGoalV(float gunGoal); void SetGunGoalH(float gunGoal); @@ -373,7 +345,6 @@ public: bool StartShowLimit(); void StopShowLimit(); - void SetShowLimitRadius(float radius); bool IsProgram(); void CreateSelectParticle(); @@ -408,9 +379,6 @@ public: float GetTraceWidth(); void SetTraceWidth(float width); - static DriveType GetDriveFromObject(ObjectType type); - static ToolType GetToolFromObject(ObjectType type); - protected: bool EventFrame(const Event &event); void VirusFrame(float rTime); @@ -442,7 +410,7 @@ protected: ObjectType m_type; // OBJECT_* const int m_id; // unique identifier - char m_name[50]; // name of the object + std::string m_name; // name of the object Character m_character; // characteristic int m_option; // option int m_partiReactor; // number of the particle of the reactor @@ -508,8 +476,8 @@ protected: Sound m_crashSphereSound[MAXCRASHSPHERE]; Math::Vector m_globalSpherePos; float m_globalSphereRadius; - Math::Vector m_jotlerSpherePos; - float m_jotlerSphereRadius; + Math::Vector m_jostlingSpherePos; + float m_jostlingSphereRadius; float m_shieldRadius; int m_totalPart; diff --git a/src/object/object_factory.cpp b/src/object/object_factory.cpp index 69474ed6..a72eb531 100644 --- a/src/object/object_factory.cpp +++ b/src/object/object_factory.cpp @@ -1312,7 +1312,7 @@ CObjectUPtr CObjectFactory::CreateFlag(const ObjectCreateParams& params) else obj->SetPosition(1+i, Math::Vector(0.79f, 0.0f, 0.0f)); } - obj->SetJotlerSphere(Math::Vector(0.0f, 4.0f, 0.0f), 1.0f); + obj->SetJostlingSphere(Math::Vector(0.0f, 4.0f, 0.0f), 1.0f); obj->CreateShadowCircle(2.0f, 0.3f); obj->SetFloorHeight(0.0f); @@ -1457,7 +1457,7 @@ CObjectUPtr CObjectFactory::CreatePlant(const ObjectCreateParams& params) obj->CreateCrashSphere(Math::Vector(0.0f, 0.0f, 0.0f), 4.0f, SOUND_BOUM, 0.10f); obj->SetGlobalSphere(Math::Vector(0.0f, 3.0f, 0.0f), 6.0f); - obj->SetJotlerSphere(Math::Vector(0.0f, 0.0f, 0.0f), 8.0f); + obj->SetJostlingSphere(Math::Vector(0.0f, 0.0f, 0.0f), 8.0f); obj->CreateShadowCircle(8.0f, 0.5f); } @@ -1476,7 +1476,7 @@ CObjectUPtr CObjectFactory::CreatePlant(const ObjectCreateParams& params) obj->SetAngleY(0, angle); //? obj->CreateCrashSphere(Math::Vector(0.0f, 0.0f, 0.0f), 3.0f, SOUND_BOUM, 0.10f); - obj->SetJotlerSphere(Math::Vector(0.0f, 0.0f, 0.0f), 4.0f); + obj->SetJostlingSphere(Math::Vector(0.0f, 0.0f, 0.0f), 4.0f); obj->CreateShadowCircle(5.0f, 0.3f); } @@ -1517,7 +1517,7 @@ CObjectUPtr CObjectFactory::CreatePlant(const ObjectCreateParams& params) obj->CreateCrashSphere(Math::Vector(0.0f, 12.0f, 0.0f), 5.0f, SOUND_BOUM, 0.10f); obj->SetGlobalSphere(Math::Vector(0.0f, 6.0f, 0.0f), 6.0f); - obj->SetJotlerSphere(Math::Vector(0.0f, 4.0f, 0.0f), 8.0f); + obj->SetJostlingSphere(Math::Vector(0.0f, 4.0f, 0.0f), 8.0f); obj->CreateShadowCircle(8.0f, 0.3f); } @@ -1544,7 +1544,7 @@ CObjectUPtr CObjectFactory::CreatePlant(const ObjectCreateParams& params) obj->CreateCrashSphere(Math::Vector(0.0f, 0.0f, 0.0f), 4.0f, SOUND_BOUM, 0.10f); obj->SetGlobalSphere(Math::Vector(0.0f, 3.0f, 0.0f), 6.0f); } - obj->SetJotlerSphere(Math::Vector(0.0f, 0.0f, 0.0f), 8.0f); + obj->SetJostlingSphere(Math::Vector(0.0f, 0.0f, 0.0f), 8.0f); obj->CreateShadowCircle(8.0f, 0.5f); } @@ -1688,7 +1688,7 @@ CObjectUPtr CObjectFactory::CreateMushroom(const ObjectCreateParams& params) obj->CreateCrashSphere(Math::Vector(0.0f, 4.0f, 0.0f), 3.0f, SOUND_BOUM, 0.10f); obj->SetGlobalSphere(Math::Vector(0.0f, 3.0f, 0.0f), 5.5f); - obj->SetJotlerSphere(Math::Vector(0.0f, 3.0f, 0.0f), 5.5f); + obj->SetJostlingSphere(Math::Vector(0.0f, 3.0f, 0.0f), 5.5f); obj->CreateShadowCircle(6.0f, 0.5f); } @@ -1704,7 +1704,7 @@ CObjectUPtr CObjectFactory::CreateMushroom(const ObjectCreateParams& params) obj->CreateCrashSphere(Math::Vector(0.0f, 5.0f, 0.0f), 3.0f, SOUND_BOUM, 0.10f); obj->SetGlobalSphere(Math::Vector(0.0f, 4.0f, 0.0f), 5.5f); - obj->SetJotlerSphere(Math::Vector(0.0f, 4.0f, 0.0f), 5.5f); + obj->SetJostlingSphere(Math::Vector(0.0f, 4.0f, 0.0f), 5.5f); obj->CreateShadowCircle(5.0f, 0.5f); } @@ -3413,7 +3413,7 @@ CObjectUPtr CObjectFactory::CreateApollo(const ObjectCreateParams& params) obj->SetAngleY(0, angle); obj->SetFloorHeight(0.0f); - obj->SetJotlerSphere(Math::Vector(0.0f, 4.0f, 0.0f), 1.0f); + obj->SetJostlingSphere(Math::Vector(0.0f, 4.0f, 0.0f), 1.0f); obj->CreateShadowCircle(2.0f, 0.3f); } diff --git a/src/object/object_manager.cpp b/src/object/object_manager.cpp index 92bcf233..1117e10b 100644 --- a/src/object/object_manager.cpp +++ b/src/object/object_manager.cpp @@ -79,15 +79,15 @@ void CObjectManager::DeleteAllObjects() CObject* CObjectManager::GetObjectById(unsigned int id) { - if(m_objects.count(id) == 0) return nullptr; + if (m_objects.count(id) == 0) return nullptr; return m_objects[id].get(); } CObject* CObjectManager::GetObjectByRank(unsigned int id) { - if(id >= m_objects.size()) return nullptr; + if (id >= m_objects.size()) return nullptr; auto it = m_objects.begin(); - for(unsigned int i = 0; i < id; i++, ++it); + for (unsigned int i = 0; i < id; i++, ++it); return it->second.get(); } @@ -133,7 +133,7 @@ CObject* CObjectManager::CreateObject(Math::Vector pos, CObject* CObjectManager::Radar(CObject* pThis, ObjectType type, float angle, float focus, float minDist, float maxDist, bool furthest, RadarFilter filter, bool cbotTypes) { std::vector types; - if(type != OBJECT_NULL) + if (type != OBJECT_NULL) types.push_back(type); return Radar(pThis, types, angle, focus, minDist, maxDist, furthest, filter, cbotTypes); } @@ -142,12 +142,14 @@ CObject* CObjectManager::Radar(CObject* pThis, std::vector type, flo { Math::Vector iPos; float iAngle; - if(pThis != nullptr) + if (pThis != nullptr) { iPos = pThis->GetPosition(0); iAngle = pThis->GetAngleY(0); iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI - } else { + } + else + { iPos = Math::Vector(); iAngle = 0.0f; } @@ -157,7 +159,7 @@ CObject* CObjectManager::Radar(CObject* pThis, std::vector type, flo CObject* CObjectManager::Radar(CObject* pThis, Math::Vector thisPosition, float thisAngle, ObjectType type, float angle, float focus, float minDist, float maxDist, bool furthest, RadarFilter filter, bool cbotTypes) { std::vector types; - if(type != OBJECT_NULL) + if (type != OBJECT_NULL) types.push_back(type); return Radar(pThis, thisPosition, thisAngle, types, angle, focus, minDist, maxDist, furthest, filter, cbotTypes); } @@ -169,14 +171,14 @@ CObject* CObjectManager::Radar(CObject* pThis, Math::Vector thisPosition, float Math::Vector iPos, oPos; float best, iAngle, d, a; ObjectType oType; - + minDist *= g_unit; maxDist *= g_unit; - + iPos = thisPosition; iAngle = thisAngle+angle; iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI - + if ( !furthest ) best = 100000.0f; else best = 0.0f; pBest = nullptr; @@ -184,15 +186,16 @@ CObject* CObjectManager::Radar(CObject* pThis, Math::Vector thisPosition, float { pObj = it->second.get(); if ( pObj == pThis ) continue; // pThis may be nullptr but it doesn't matter - + if ( pObj->GetTruck() != 0 ) continue; // object transported? - if ( !pObj->GetActif() ) continue; + if ( !pObj->GetActive() ) continue; if ( pObj->GetProxyActivate() ) continue; - + oType = pObj->GetType(); if ( oType == OBJECT_TOTO || oType == OBJECT_CONTROLLER ) continue; - - if(cbotTypes) { + + if (cbotTypes) + { // TODO: handle this differently (new class describing types? CObjectType::GetBaseType()?) if ( oType == OBJECT_RUINmobilew2 || oType == OBJECT_RUINmobilet1 || @@ -202,7 +205,7 @@ CObject* CObjectManager::Radar(CObject* pThis, Math::Vector thisPosition, float { oType = OBJECT_RUINmobilew1; // any ruin } - + if ( oType == OBJECT_SCRAP2 || oType == OBJECT_SCRAP3 || oType == OBJECT_SCRAP4 || @@ -210,7 +213,7 @@ CObject* CObjectManager::Radar(CObject* pThis, Math::Vector thisPosition, float { oType = OBJECT_SCRAP1; // any waste } - + if ( oType == OBJECT_BARRIER2 || oType == OBJECT_BARRIER3 ) // barriers? { @@ -218,7 +221,7 @@ CObject* CObjectManager::Radar(CObject* pThis, Math::Vector thisPosition, float } // END OF TODO } - + if ( filter == FILTER_ONLYLANDING ) { physics = pObj->GetPhysics(); @@ -229,13 +232,13 @@ CObject* CObjectManager::Radar(CObject* pThis, Math::Vector thisPosition, float physics = pObj->GetPhysics(); if ( physics != nullptr && physics->GetLand() ) continue; } - + if ( std::find(type.begin(), type.end(), oType) == type.end() && type.size() > 0 ) continue; - + oPos = pObj->GetPosition(0); d = Math::DistanceProjected(iPos, oPos); if ( d < minDist || d > maxDist ) continue; // too close or too far? - + a = Math::RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW ! if ( Math::TestAngle(a, iAngle-focus/2.0f, iAngle+focus/2.0f) || focus >= Math::PI*2.0f ) { @@ -247,7 +250,7 @@ CObject* CObjectManager::Radar(CObject* pThis, Math::Vector thisPosition, float } } } - + return pBest; } diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 069bc1b9..f5d1be4b 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -1991,9 +1991,9 @@ CObject* CRobotMain::DetectObject(Math::Point pos) for (CObject* obj : m_objMan->GetAllObjects()) { - if (!obj->GetActif()) continue; + if (!obj->GetActive()) continue; CObject* truck = obj->GetTruck(); - if (truck != nullptr && !truck->GetActif()) continue; + if (truck != nullptr && !truck->GetActive()) continue; if (obj->GetProxyActivate()) continue; CObject* target = nullptr; @@ -3045,8 +3045,8 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) m_audioChange[i].max = line->GetParam("max")->AsInt(9999); m_audioChange[i].powermin = line->GetParam("powermin")->AsFloat(-1); m_audioChange[i].powermax = line->GetParam("powermax")->AsFloat(100); - m_audioChange[i].tool = line->GetParam("tool")->AsToolType(TOOL_OTHER); - m_audioChange[i].drive = line->GetParam("drive")->AsDriveType(DRIVE_OTHER); + m_audioChange[i].tool = line->GetParam("tool")->AsToolType(ToolType::Other); + m_audioChange[i].drive = line->GetParam("drive")->AsDriveType(DriveType::Other); strcpy(m_audioChange[i].music, (std::string("../")+line->GetParam("filename")->AsPath("music")).c_str()); m_audioChange[i].repeat = line->GetParam("repeat")->AsBool(true); m_audioChange[i].changed = false; @@ -3812,8 +3812,8 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) m_endTake[i].max = line->GetParam("max")->AsInt(9999); m_endTake[i].powermin = line->GetParam("powermin")->AsFloat(-1); m_endTake[i].powermax = line->GetParam("powermax")->AsFloat(100); - m_endTake[i].tool = line->GetParam("tool")->AsToolType(TOOL_OTHER); - m_endTake[i].drive = line->GetParam("drive")->AsDriveType(DRIVE_OTHER); + m_endTake[i].tool = line->GetParam("tool")->AsToolType(ToolType::Other); + m_endTake[i].drive = line->GetParam("drive")->AsDriveType(DriveType::Other); m_endTake[i].lost = line->GetParam("lost")->AsInt(-1); m_endTake[i].immediat = line->GetParam("immediat")->AsBool(false); m_endTake[i].countTransported = line->GetParam("countTransported")->AsBool(true); @@ -4181,7 +4181,7 @@ float CRobotMain::SearchNearestObject(Math::Vector center, CObject *exclu) float min = 100000.0f; for (CObject* obj : m_objMan->GetAllObjects()) { - if (!obj->GetActif()) continue; // inactive? + if (!obj->GetActive()) continue; // inactive? if (obj->GetTruck() != nullptr) continue; // object carries? if (obj == exclu) continue; @@ -4329,7 +4329,7 @@ void CRobotMain::ShowDropZone(CObject* metal, CObject* truck) float tMax; for (CObject* obj : m_objMan->GetAllObjects()) { - if (!obj->GetActif()) continue; // inactive? + if (!obj->GetActive()) continue; // inactive? if (obj->GetTruck() != nullptr) continue; // object carried? if (obj == metal) continue; if (obj == truck) continue; @@ -4945,7 +4945,7 @@ bool CRobotMain::IOWriteScene(const char *filename, const char *filecbot, char * if (obj->GetTruck() != nullptr) continue; if (obj->GetBurn()) continue; if (obj->GetDead()) continue; - if (obj->GetExplo()) continue; + if (obj->IsExploding()) continue; CObject* power = obj->GetPower(); CObject* fret = obj->GetFret(); @@ -5417,7 +5417,7 @@ void CRobotMain::UpdateAudio(bool frame) int nb = 0; for (CObject* obj : m_objMan->GetAllObjects()) { - // Do not use GetActif () because an invisible worm (underground) + // Do not use GetActive () because an invisible worm (underground) // should be regarded as existing here! if (obj->GetLock()) continue; if (obj->GetRuin()) continue; @@ -5432,17 +5432,17 @@ void CRobotMain::UpdateAudio(bool frame) type = OBJECT_SCRAP1; } - ToolType tool = CObject::GetToolFromObject(type); - DriveType drive = CObject::GetDriveFromObject(type); - if (m_audioChange[t].tool != TOOL_OTHER && + ToolType tool = GetToolFromObject(type); + DriveType drive = GetDriveFromObject(type); + if (m_audioChange[t].tool != ToolType::Other && tool != m_audioChange[t].tool) continue; - if (m_audioChange[t].drive != DRIVE_OTHER && + if (m_audioChange[t].drive != DriveType::Other && drive != m_audioChange[t].drive) continue; - if (m_audioChange[t].tool == TOOL_OTHER && - m_audioChange[t].drive == DRIVE_OTHER && + if (m_audioChange[t].tool == ToolType::Other && + m_audioChange[t].drive == DriveType::Other && type != m_audioChange[t].type) continue; @@ -5551,7 +5551,7 @@ Error CRobotMain::CheckEndMission(bool frame) int nb = 0; for (CObject* obj : m_objMan->GetAllObjects()) { - // Do not use GetActif () because an invisible worm (underground) + // Do not use GetActive () because an invisible worm (underground) // should be regarded as existing here! if (obj->GetLock()) continue; if (obj->GetRuin()) continue; @@ -5571,18 +5571,18 @@ Error CRobotMain::CheckEndMission(bool frame) type = OBJECT_SCRAP1; } - ToolType tool = CObject::GetToolFromObject(type); - DriveType drive = CObject::GetDriveFromObject(type); - if (m_endTake[t].tool != TOOL_OTHER && + ToolType tool = GetToolFromObject(type); + DriveType drive = GetDriveFromObject(type); + if (m_endTake[t].tool != ToolType::Other && tool != m_endTake[t].tool) continue; - if (m_endTake[t].drive != DRIVE_OTHER && + if (m_endTake[t].drive != DriveType::Other && drive != m_endTake[t].drive) continue; - if (m_endTake[t].tool == TOOL_OTHER && - m_endTake[t].drive == DRIVE_OTHER && + if (m_endTake[t].tool == ToolType::Other && + m_endTake[t].drive == DriveType::Other && type != m_endTake[t].type) continue; diff --git a/src/object/robotmain.h b/src/object/robotmain.h index d083e4de..8e4fcd04 100644 --- a/src/object/robotmain.h +++ b/src/object/robotmain.h @@ -31,6 +31,8 @@ #include "graphics/engine/particle.h" #include "object/object.h" +#include "object/drive_type.h" +#include "object/tool_type.h" #include "object/mainmovie.h" #include "app/pausemanager.h" @@ -175,7 +177,7 @@ class CRobotMain : public CSingleton public: CRobotMain(CController* controller); virtual ~CRobotMain(); - + void Create(bool loadProfile = true); Gfx::CCamera* GetCamera(); @@ -185,7 +187,7 @@ public: void CreateIni(); void LoadIni(); - + void ResetAfterDeviceChanged(); void ChangePhase(Phase phase); @@ -341,18 +343,18 @@ public: void DisplayError(Error err, CObject* pObj, float time=10.0f); void DisplayError(Error err, Math::Vector goal, float height=15.0f, float dist=60.0f, float time=10.0f); - + std::string& GetUserLevelName(int id); - + void StartMissionTimer(); - + void SetAutosave(bool enable); bool GetAutosave(); void SetAutosaveInterval(int interval); int GetAutosaveInterval(); void SetAutosaveSlots(int slots); int GetAutosaveSlots(); - + //! Enable mode where completing mission closes the game void SetExitAfterMission(bool exit); @@ -388,7 +390,7 @@ protected: void ExecuteCmd(char *cmd); bool TestGadgetQuantity(int rank); void UpdateSpeedLabel(); - + int AutosaveRotate(bool freeOne); void Autosave(); @@ -484,7 +486,7 @@ protected: int m_endingWinRank; int m_endingLostRank; bool m_winTerminate; - + bool m_exitAfterMission; float m_fontSize; @@ -541,11 +543,11 @@ protected: Gfx::Color m_colorRefWater; Gfx::Color m_colorNewWater; float m_colorShiftWater; - + bool m_missionTimerEnabled; bool m_missionTimerStarted; float m_missionTimer; - + bool m_autosave; int m_autosaveInterval; int m_autosaveSlots; diff --git a/src/object/task/taskbuild.cpp b/src/object/task/taskbuild.cpp index 57a2f2c0..4363cef5 100644 --- a/src/object/task/taskbuild.cpp +++ b/src/object/task/taskbuild.cpp @@ -590,7 +590,7 @@ Error CTaskBuild::FlatFloor() bBase = false; for (CObject* pObj : CObjectManager::GetInstancePointer()->GetAllObjects()) { - if ( !pObj->GetActif() ) continue; // inactive? + if ( !pObj->GetActive() ) continue; // inactive? if ( pObj->GetTruck() != 0 ) continue; // object transported? if ( pObj == m_metal ) continue; if ( pObj == m_object ) continue; @@ -635,7 +635,7 @@ Error CTaskBuild::FlatFloor() max = 100000.0f; for (CObject* pObj : CObjectManager::GetInstancePointer()->GetAllObjects()) { - if ( !pObj->GetActif() ) continue; // inactive? + if ( !pObj->GetActive() ) continue; // inactive? if ( pObj->GetTruck() != 0 ) continue; // object transported? if ( pObj == m_metal ) continue; if ( pObj == m_object ) continue; @@ -703,7 +703,7 @@ CObject* CTaskBuild::SearchMetalObject(float &angle, float dMin, float dMax, bMetal = false; for (CObject* pObj : CObjectManager::GetInstancePointer()->GetAllObjects()) { - if ( !pObj->GetActif() ) continue; // objet inactive? + if ( !pObj->GetActive() ) continue; // objet inactive? if ( pObj->GetTruck() != 0 ) continue; // object transported? type = pObj->GetType(); diff --git a/src/object/task/taskfire.cpp b/src/object/task/taskfire.cpp index 010151f1..372294fc 100644 --- a/src/object/task/taskfire.cpp +++ b/src/object/task/taskfire.cpp @@ -240,7 +240,7 @@ bool CTaskFire::EventProcess(const Event &event) { dir.z = (Math::PI*0.04f)*(1.0f-(m_progress-0.9f)*10.0f); } - m_object->SetInclinaison(dir); + m_object->SetTilt(dir); vib.x = (Math::Rand()-0.5f)*0.01f; vib.y = (Math::Rand()-0.5f)*0.02f; @@ -367,7 +367,7 @@ Error CTaskFire::IsEnded() bool CTaskFire::Abort() { - m_object->SetInclinaison(Math::Vector(0.0f, 0.0f, 0.0f)); + m_object->SetTilt(Math::Vector(0.0f, 0.0f, 0.0f)); m_object->SetCirVibration(Math::Vector(0.0f, 0.0f, 0.0f)); m_object->SetLinVibration(Math::Vector(0.0f, 0.0f, 0.0f)); diff --git a/src/object/task/taskgoto.cpp b/src/object/task/taskgoto.cpp index 442e15a4..e734e016 100644 --- a/src/object/task/taskgoto.cpp +++ b/src/object/task/taskgoto.cpp @@ -1147,7 +1147,7 @@ bool CTaskGoto::AdjustBuilding(Math::Vector &pos, float margin, float &distance) { for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects()) { - if ( !obj->GetActif() ) continue; + if ( !obj->GetActive() ) continue; if ( obj->GetTruck() != nullptr ) continue; // object transported? Math::Vector oPos; @@ -1308,7 +1308,7 @@ bool CTaskGoto::LeakSearch(Math::Vector &pos, float &delay) for (CObject* pObj : CObjectManager::GetInstancePointer()->GetAllObjects()) { if ( pObj == m_object ) continue; - if ( !pObj->GetActif() ) continue; + if ( !pObj->GetActive() ) continue; if ( pObj->GetTruck() != 0 ) continue; // object transported? j = 0; diff --git a/src/object/task/taskmanip.cpp b/src/object/task/taskmanip.cpp index def9d4ec..78e89f56 100644 --- a/src/object/task/taskmanip.cpp +++ b/src/object/task/taskmanip.cpp @@ -1327,7 +1327,7 @@ bool CTaskManip::IsFreeDeposeObject(Math::Vector pos) for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects()) { if ( obj == m_object ) continue; - if ( !obj->GetActif() ) continue; // inactive? + if ( !obj->GetActive() ) continue; // inactive? if ( obj->GetTruck() != nullptr ) continue; // object transported? Math::Vector oPos; diff --git a/src/object/task/tasktake.cpp b/src/object/task/tasktake.cpp index cb3c93c8..ad3abd0b 100644 --- a/src/object/task/tasktake.cpp +++ b/src/object/task/tasktake.cpp @@ -566,7 +566,7 @@ bool CTaskTake::IsFreeDeposeObject(Math::Vector pos) for (CObject* pObj : CObjectManager::GetInstancePointer()->GetAllObjects()) { if ( pObj == m_object ) continue; - if ( !pObj->GetActif() ) continue; // inactive? + if ( !pObj->GetActive() ) continue; // inactive? if ( pObj->GetTruck() != 0 ) continue; // object transported? j = 0; diff --git a/src/object/task/taskterraform.cpp b/src/object/task/taskterraform.cpp index 3c3f2066..29f084ab 100644 --- a/src/object/task/taskterraform.cpp +++ b/src/object/task/taskterraform.cpp @@ -126,7 +126,7 @@ bool CTaskTerraform::EventProcess(const Event &event) { dir.z = -atanf((pos.y/2.0f)/9.0f); } - m_object->SetInclinaison(dir); + m_object->SetTilt(dir); if ( m_time-m_lastParticle >= m_engine->ParticleAdapt(0.05f) ) { @@ -320,7 +320,7 @@ bool CTaskTerraform::Abort() } m_object->SetPosition(2, Math::Vector(9.0f, 4.0f, 0.0f)); - m_object->SetInclinaison(Math::Vector(0.0f, 0.0f, 0.0f)); + m_object->SetTilt(Math::Vector(0.0f, 0.0f, 0.0f)); m_object->SetCirVibration(Math::Vector(0.0f, 0.0f, 0.0f)); m_object->SetZoom(0, 1.0f); diff --git a/src/object/tool_type.cpp b/src/object/tool_type.cpp new file mode 100644 index 00000000..b73af54f --- /dev/null +++ b/src/object/tool_type.cpp @@ -0,0 +1,53 @@ +/* + * This file is part of the Colobot: Gold Edition source code + * Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam + * http://epsiteс.ch; http://colobot.info; http://github.com/colobot + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://gnu.org/licenses + */ + +#include "object/tool_type.h" + +ToolType GetToolFromObject(ObjectType type) +{ + switch (type) + { + case OBJECT_MOBILEwa: + case OBJECT_MOBILEta: + case OBJECT_MOBILEfa: + case OBJECT_MOBILEia: + return ToolType::Grabber; + + case OBJECT_MOBILEws: + case OBJECT_MOBILEts: + case OBJECT_MOBILEfs: + case OBJECT_MOBILEis: + return ToolType::Sniffer; + + case OBJECT_MOBILEwc: + case OBJECT_MOBILEtc: + case OBJECT_MOBILEfc: + case OBJECT_MOBILEic: + return ToolType::Shooter; + + case OBJECT_MOBILEwi: + case OBJECT_MOBILEti: + case OBJECT_MOBILEfi: + case OBJECT_MOBILEii: + return ToolType::OrganicShooter; + + default: + return ToolType::Other; + } +} diff --git a/src/object/tool_type.h b/src/object/tool_type.h new file mode 100644 index 00000000..daba8a00 --- /dev/null +++ b/src/object/tool_type.h @@ -0,0 +1,33 @@ +/* + * This file is part of the Colobot: Gold Edition source code + * Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam + * http://epsiteс.ch; http://colobot.info; http://github.com/colobot + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://gnu.org/licenses + */ + +#pragma once + +#include "object/object_type.h" + +enum class ToolType : unsigned int +{ + Other = 0, + Grabber, + Sniffer, + Shooter, + OrganicShooter, +}; + +ToolType GetToolFromObject(ObjectType type); diff --git a/src/physics/physics.cpp b/src/physics/physics.cpp index 953909fa..f3b478b9 100644 --- a/src/physics/physics.cpp +++ b/src/physics/physics.cpp @@ -1065,7 +1065,7 @@ void CPhysics::EffectUpdate(float aTime, float rTime) vibLin = m_motion->GetLinVibration(); vibCir = m_motion->GetCirVibration(); - incl = m_motion->GetInclinaison(); + incl = m_motion->GetTilt(); if ( type == OBJECT_HUMAN || // human? type == OBJECT_TECH ) @@ -1114,7 +1114,7 @@ void CPhysics::EffectUpdate(float aTime, float rTime) m_motion->SetLinVibration(vibLin); m_motion->SetCirVibration(vibCir); - m_motion->SetInclinaison(incl); + m_motion->SetTilt(incl); } else if ( m_bSwim ) // swimming? { @@ -1171,14 +1171,14 @@ void CPhysics::EffectUpdate(float aTime, float rTime) m_motion->SetLinVibration(vibLin); m_motion->SetCirVibration(vibCir); - m_motion->SetInclinaison(incl); + m_motion->SetTilt(incl); } else { m_motion->SetLinVibration(Math::Vector(0.0f, 0.0f, 0.0f)); //? m_motion->SetCirVibration(Math::Vector(0.0f, 0.0f, 0.0f)); -//? m_motion->SetInclinaison(Math::Vector(0.0f, 0.0f, 0.0f)); +//? m_motion->SetTilt(Math::Vector(0.0f, 0.0f, 0.0f)); } } @@ -1218,7 +1218,7 @@ void CPhysics::EffectUpdate(float aTime, float rTime) } if ( bOnBoard ) incl.z *= 0.1f; if ( type == OBJECT_APOLLO2 ) incl.z *= 0.25f; - m_object->SetInclinaison(incl); + m_object->SetTilt(incl); vibLin.x = 0.0f; vibLin.z = 0.0f; @@ -1237,7 +1237,7 @@ void CPhysics::EffectUpdate(float aTime, float rTime) { m_motion->SetLinVibration(Math::Vector(0.0f, 0.0f, 0.0f)); m_motion->SetCirVibration(Math::Vector(0.0f, 0.0f, 0.0f)); - m_motion->SetInclinaison(Math::Vector(0.0f, 0.0f, 0.0f)); + m_motion->SetTilt(Math::Vector(0.0f, 0.0f, 0.0f)); } else // in flight? { @@ -1286,7 +1286,7 @@ void CPhysics::EffectUpdate(float aTime, float rTime) m_motion->SetLinVibration(vibLin); m_motion->SetCirVibration(vibCir); - m_motion->SetInclinaison(incl); + m_motion->SetTilt(incl); } } @@ -1338,7 +1338,7 @@ void CPhysics::EffectUpdate(float aTime, float rTime) m_motion->SetLinVibration(vibLin); m_motion->SetCirVibration(vibCir); - m_motion->SetInclinaison(incl); + m_motion->SetTilt(incl); } } } @@ -1613,7 +1613,7 @@ bool CPhysics::EventFrame(const Event &event) if ( m_bLand && m_fallingHeight != 0.0f ) // if fell { float force = (m_fallingHeight - m_object->GetPosition(0).y) * m_fallDamageFraction; - m_object->ExploObject(EXPLO_BOUM, force); + m_object->ExplodeObject(ExplosionType::Bang, force); m_fallingHeight = 0.0f; } @@ -1635,7 +1635,7 @@ void CPhysics::SoundMotor(float rTime) if ( type == OBJECT_MOTHER ) { - if ( m_lastSoundInsect <= 0.0f && m_object->GetActif() ) + if ( m_lastSoundInsect <= 0.0f && m_object->GetActive() ) { m_sound->Play(SOUND_INSECTm, m_object->GetPosition(0)); if ( m_bMotor ) m_lastSoundInsect = 0.4f+Math::Rand()*2.5f; @@ -1653,7 +1653,7 @@ void CPhysics::SoundMotor(float rTime) m_lastSoundInsect = 0.4f+Math::Rand()*0.6f; } } - else if ( m_object->GetActif() ) + else if ( m_object->GetActive() ) { if ( m_lastSoundInsect <= 0.0f ) { @@ -1665,7 +1665,7 @@ void CPhysics::SoundMotor(float rTime) } else if ( type == OBJECT_BEE ) { - if ( m_object->GetActif() ) + if ( m_object->GetActive() ) { if ( m_lastSoundInsect <= 0.0f ) { @@ -1685,7 +1685,7 @@ void CPhysics::SoundMotor(float rTime) } else if ( type == OBJECT_WORM ) { - if ( m_object->GetActif() ) + if ( m_object->GetActive() ) { if ( m_lastSoundInsect <= 0.0f ) { @@ -1714,7 +1714,7 @@ void CPhysics::SoundMotor(float rTime) m_lastSoundInsect = 0.4f+Math::Rand()*0.6f; } } - else if ( m_object->GetActif() ) + else if ( m_object->GetActive() ) { if ( m_lastSoundInsect <= 0.0f ) { @@ -1728,7 +1728,7 @@ void CPhysics::SoundMotor(float rTime) { if ( m_type == TYPE_ROLLING ) { - if ( m_bMotor && m_object->GetActif() ) + if ( m_bMotor && m_object->GetActive() ) { SoundMotorFull(rTime, type); // full diet } @@ -1756,7 +1756,7 @@ void CPhysics::SoundMotor(float rTime) if ( m_type == TYPE_FLYING ) { if ( m_bMotor && !m_bSwim && - m_object->GetActif() && !m_object->GetDead() ) + m_object->GetActive() && !m_object->GetDead() ) { SoundReactorFull(rTime, type); // full diet } @@ -1820,7 +1820,7 @@ void CPhysics::WaterFrame(float aTime, float rTime) if ( type == OBJECT_TOTO ) return; if ( type == OBJECT_NULL ) return; - if ( !m_object->GetActif() ) return; + if ( !m_object->GetActive() ) return; if ( m_object->GetResetBusy() ) return; // reset in progress? if ( m_water->GetLava() || @@ -1853,7 +1853,7 @@ void CPhysics::WaterFrame(float aTime, float rTime) type == OBJECT_MOBILEdr || type == OBJECT_APOLLO2 ) // vehicle not underwater? { - m_object->ExploObject(EXPLO_WATER, 1.0f); // starts explosion + m_object->ExplodeObject(ExplosionType::Water, 1.0f); // starts explosion } } @@ -2545,7 +2545,7 @@ int CPhysics::ObjectAdapt(const Math::Vector &pos, const Math::Vector &angle) if ( iType == OBJECT_MOTHER && oType == OBJECT_EGG ) continue; if ( iType == OBJECT_EGG && oType == OBJECT_MOTHER ) continue; - pObj->GetJotlerSphere(oPos, oRad); + pObj->GetJostlingSphere(oPos, oRad); if ( oRad > 0.0f ) { JostleObject(pObj, iPos, iRad, oPos, oRad); @@ -2727,7 +2727,7 @@ bool CPhysics::JostleObject(CObject* pObj, float force) Math::Vector oPos; float oRad; - pObj->GetJotlerSphere(oPos, oRad); + pObj->GetJostlingSphere(oPos, oRad); if ( oRad <= 0.0f ) return false; if ( m_soundTimeJostle >= 0.20f ) @@ -2788,7 +2788,7 @@ bool CPhysics::ExploOther(ObjectType iType, oType == OBJECT_SAFE || oType == OBJECT_HUSTON ) ) // building? { - pObj->ExploObject(EXPLO_BOUM, force/400.0f); + pObj->ExplodeObject(ExplosionType::Bang, force/400.0f); } if ( force > 25.0f && @@ -2820,7 +2820,7 @@ bool CPhysics::ExploOther(ObjectType iType, oType == OBJECT_MOBILEdr || oType == OBJECT_APOLLO2 ) ) // vehicle? { - pObj->ExploObject(EXPLO_BOUM, force/200.0f); + pObj->ExplodeObject(ExplosionType::Bang, force/200.0f); } if ( force > 10.0f && @@ -2957,7 +2957,7 @@ int CPhysics::ExploHimself(ObjectType iType, ObjectType oType, float force) force /= 200.0f; } - if ( m_object->ExploObject(EXPLO_BOUM, force) ) return 2; + if ( m_object->ExplodeObject(ExplosionType::Bang, force) ) return 2; } return 1; diff --git a/src/script/cbottoken.h b/src/script/cbottoken.h index c897726b..5ac12344 100644 --- a/src/script/cbottoken.h +++ b/src/script/cbottoken.h @@ -25,7 +25,9 @@ #pragma once -#include "object/object.h" +#include "object/object_type.h" + +#include diff --git a/src/script/cmdtoken.cpp b/src/script/cmdtoken.cpp index 317e881c..5eae7c04 100644 --- a/src/script/cmdtoken.cpp +++ b/src/script/cmdtoken.cpp @@ -22,6 +22,9 @@ #include "common/global.h" +#include "object/drive_type.h" +#include "object/tool_type.h" + #include #include @@ -57,14 +60,14 @@ bool Cmd(char *line, const char *token) char* p; line = SkipSpace(line); - + p = strstr(line, token); if(p != line) return false; // command at the beginning? - + unsigned int len = 0; for(char* x = p; *x != 0 && *x != ' ' && *x != '\t' && *x != '\n'; x++, len++); if(len != strlen(token)) return false; // ends with space? - + return true; } @@ -757,24 +760,24 @@ DriveType GetDrive(char *line, int rank) char* p; p = SearchArg(line, rank); - if ( *p == 0 ) return DRIVE_OTHER; + if ( *p == 0 ) return DriveType::Other; - if ( Cmd(p, "Wheeled" ) ) return DRIVE_WHEELED; - if ( Cmd(p, "Tracked" ) ) return DRIVE_TRACKED; - if ( Cmd(p, "Winged" ) ) return DRIVE_WINGED; - if ( Cmd(p, "Legged" ) ) return DRIVE_LEGGED; + if ( Cmd(p, "Wheeled" ) ) return DriveType::Wheeled; + if ( Cmd(p, "Tracked" ) ) return DriveType::Tracked; + if ( Cmd(p, "Winged" ) ) return DriveType::Winged; + if ( Cmd(p, "Legged" ) ) return DriveType::Legged; - return DRIVE_OTHER; + return DriveType::Other; } // Returns the name of a drive. const char* GetDrive(DriveType type) { - if ( type == DRIVE_WHEELED ) return "Wheeled"; - if ( type == DRIVE_TRACKED ) return "Tracked"; - if ( type == DRIVE_WINGED ) return "Winged"; - if ( type == DRIVE_LEGGED ) return "Legged"; + if ( type == DriveType::Wheeled ) return "Wheeled"; + if ( type == DriveType::Tracked ) return "Tracked"; + if ( type == DriveType::Winged ) return "Winged"; + if ( type == DriveType::Legged ) return "Legged"; return "Other"; } @@ -785,24 +788,24 @@ ToolType GetTool(char *line, int rank) char* p; p = SearchArg(line, rank); - if ( *p == 0 ) return TOOL_OTHER; + if ( *p == 0 ) return ToolType::Other; - if ( Cmd(p, "Grabber" ) ) return TOOL_GRABBER; - if ( Cmd(p, "Sniffer" ) ) return TOOL_SNIFFER; - if ( Cmd(p, "Shooter" ) ) return TOOL_SHOOTER; - if ( Cmd(p, "OrgaShooter" ) ) return TOOL_ORGASHOOTER; + if ( Cmd(p, "Grabber" ) ) return ToolType::Grabber; + if ( Cmd(p, "Sniffer" ) ) return ToolType::Sniffer; + if ( Cmd(p, "Shooter" ) ) return ToolType::Shooter; + if ( Cmd(p, "OrgaShooter" ) ) return ToolType::OrganicShooter; - return TOOL_OTHER; + return ToolType::Other; } // Returns the name of a tool. const char* GetTool(ToolType type) { - if ( type == TOOL_GRABBER ) return "Grabber"; - if ( type == TOOL_SNIFFER ) return "Sniffer"; - if ( type == TOOL_SHOOTER ) return "Shooter"; - if ( type == TOOL_ORGASHOOTER ) return "OrgaShooter"; + if ( type == ToolType::Grabber ) return "Grabber"; + if ( type == ToolType::Sniffer ) return "Sniffer"; + if ( type == ToolType::Shooter ) return "Shooter"; + if ( type == ToolType::OrganicShooter ) return "OrgaShooter"; return "Other"; } @@ -898,7 +901,7 @@ Gfx::CameraType OpCamera(char *line, const char *op) DriveType OpDrive(char *line, const char *op) { line = SearchOp(line, op); - if ( *line == 0 ) return DRIVE_OTHER; + if ( *line == 0 ) return DriveType::Other; return GetDrive(line, 0); } @@ -907,7 +910,7 @@ DriveType OpDrive(char *line, const char *op) ToolType OpTool(char *line, const char *op) { line = SearchOp(line, op); - if ( *line == 0 ) return TOOL_OTHER; + if ( *line == 0 ) return ToolType::Other; return GetTool(line, 0); } diff --git a/src/script/cmdtoken.h b/src/script/cmdtoken.h index c158844c..106826ea 100644 --- a/src/script/cmdtoken.h +++ b/src/script/cmdtoken.h @@ -30,7 +30,9 @@ #include "graphics/engine/engine.h" #include "graphics/engine/pyro_type.h" -#include "object/object.h" +#include "object/drive_type.h" +#include "object/object_type.h" +#include "object/tool_type.h" diff --git a/src/script/scriptfunc.cpp b/src/script/scriptfunc.cpp index d86a1928..e2478610 100644 --- a/src/script/scriptfunc.cpp +++ b/src/script/scriptfunc.cpp @@ -51,6 +51,7 @@ #include "ui/displaytext.h" + #if PLATFORM_WINDOWS #include "app/system_windows.h" #endif @@ -652,16 +653,15 @@ bool CScriptFunctions::rDestroy(CBotVar* thisclass, CBotVar* var, CBotVar* resul CAuto* automat = obj->GetAuto(); if ( thisType == OBJECT_DESTROYER ) - { err = automat->StartAction(0); - } else + else err = ERR_WRONG_OBJ; if ( err != ERR_OK ) { result->SetValInt(err); // return error //TODO: if ( script->m_errMode == ERM_STOP ) - if( true ) + if ( true ) { exception = err; return false; @@ -725,7 +725,8 @@ bool CScriptFunctions::rFactory(CBotVar* thisclass, CBotVar* var, CBotVar* resul classVars = classVars->GetNext(); // "id" int rank = classVars->GetValInt(); CObject* factory = CObjectManager::GetInstancePointer()->GetObjectById(rank); - if (factory == nullptr) { + if (factory == nullptr) + { exception = ERR_GENERIC; result->SetValInt(ERR_GENERIC); CLogger::GetInstancePointer()->Error("in object.factory() - factory is nullptr"); @@ -735,7 +736,8 @@ bool CScriptFunctions::rFactory(CBotVar* thisclass, CBotVar* var, CBotVar* resul if ( thisType == OBJECT_FACTORY ) { CAutoFactory* automat = static_cast(factory->GetAuto()); - if(automat == nullptr) { + if (automat == nullptr) + { exception = ERR_GENERIC; result->SetValInt(ERR_GENERIC); CLogger::GetInstancePointer()->Error("in object.factory() - automat is nullptr"); @@ -867,7 +869,7 @@ bool CScriptFunctions::rFactory(CBotVar* thisclass, CBotVar* var, CBotVar* resul { result->SetValInt(err); // return error //TODO: if ( script->m_errMode == ERM_STOP ) - if( true ) + if ( true ) { exception = err; return false; @@ -948,7 +950,7 @@ bool CScriptFunctions::rResearch(CBotVar* thisclass, CBotVar* var, CBotVar* resu { result->SetValInt(err); // return error //TODO: if ( script->m_errMode == ERM_STOP ) - if( true ) + if ( true ) { exception = err; return false; @@ -986,16 +988,15 @@ bool CScriptFunctions::rTakeOff(CBotVar* thisclass, CBotVar* var, CBotVar* resul CAuto* automat = center->GetAuto(); if ( thisType == OBJECT_BASE ) - { err = (static_cast(automat))->TakeOff(false); - } else + else err = ERR_WRONG_OBJ; if ( err != ERR_OK ) { result->SetValInt(err); // return error //TODO: if ( script->m_errMode == ERM_STOP ) - if( true ) + if ( true ) { exception = err; return false; @@ -1060,7 +1061,7 @@ bool CScriptFunctions::rDelete(CBotVar* var, CBotVar* result, int& exception, vo { if ( exploType ) { - obj->ExploObject(static_cast(exploType), force); + obj->ExplodeObject(static_cast(exploType), force); } else { @@ -1123,20 +1124,24 @@ bool CScriptFunctions::rSearch(CBotVar* var, CBotVar* result, int& exception, vo if ( var != 0 ) { if ( !GetPoint(var, exception, pos) ) return true; - } else { + } + else + { pos = pThis->GetPosition(0); } std::vector type_v; - if(bArray) + if (bArray) { while ( array != 0 ) { type_v.push_back(static_cast(array->GetValInt())); array = array->GetNext(); } - } else { - if(type != OBJECT_NULL) + } + else + { + if (type != OBJECT_NULL) { type_v.push_back(static_cast(type)); } @@ -1266,15 +1271,17 @@ bool CScriptFunctions::rRadar(CBotVar* var, CBotVar* result, int& exception, voi } std::vector type_v; - if(bArray) + if (bArray) { while ( array != 0 ) { type_v.push_back(static_cast(array->GetValInt())); array = array->GetNext(); } - } else { - if(type != OBJECT_NULL) + } + else + { + if (type != OBJECT_NULL) { type_v.push_back(static_cast(type)); } @@ -1384,15 +1391,17 @@ bool CScriptFunctions::rDetect(CBotVar* var, CBotVar* result, int& exception, vo } std::vector type_v; - if(bArray) + if (bArray) { while ( array != 0 ) { type_v.push_back(static_cast(array->GetValInt())); array = array->GetNext(); } - } else { - if(type != OBJECT_NULL) + } + else + { + if (type != OBJECT_NULL) { type_v.push_back(static_cast(type)); } @@ -1625,7 +1634,7 @@ CBotTypResult CScriptFunctions::cProduce(CBotVar* &var, void* user) if ( var->GetType() <= CBotTypDouble ) { var = var->GetNext(); - if( var != 0 ) + if ( var != 0 ) { if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum); var = var->GetNext(); @@ -1682,10 +1691,10 @@ bool CScriptFunctions::rProduce(CBotVar* var, CBotVar* result, int& exception, v pos = me->GetPosition(0); - Math::Vector rotation = me->GetAngle(0) + me->GetInclinaison(); + Math::Vector rotation = me->GetAngle(0) + me->GetTilt(); angle = rotation.y; - if( var != nullptr ) + if ( var != nullptr ) power = var->GetValFloat(); else power = -1.0f; @@ -1753,7 +1762,7 @@ bool CScriptFunctions::rProduce(CBotVar* var, CBotVar* result, int& exception, v { std::string name2 = CPathManager::InjectLevelDir(name, "ai"); CBrain* brain = object->GetBrain(); - if(brain != nullptr) + if (brain != nullptr) { Program* program = brain->AddProgram(); brain->ReadProgram(program, name2.c_str()); @@ -2393,11 +2402,11 @@ CObject* CScriptFunctions::SearchInfo(CScript* script, CObject* object, float po iPos = object->GetPosition(0); pBest = CObjectManager::GetInstancePointer()->Radar(object, OBJECT_INFO); - if(pBest == nullptr) + if (pBest == nullptr) return nullptr; oPos = object->GetPosition(0); - if(Math::DistanceProjected(iPos, oPos) > power) + if (Math::DistanceProjected(iPos, oPos) > power) return nullptr; return pBest; @@ -2857,7 +2866,7 @@ bool CScriptFunctions::rJet(CBotVar* var, CBotVar* result, int& exception, void* float value; value = var->GetValFloat(); - if( value > 1.0f ) value = 1.0f; + if ( value > 1.0f ) value = 1.0f; physics->SetMotorSpeedY(value); @@ -3822,9 +3831,9 @@ void CScriptFunctions::Init() CBotProgram::DefineNum("FilterOnlyFliying", FILTER_ONLYFLYING); CBotProgram::DefineNum("ExploNone", 0); - CBotProgram::DefineNum("ExploBoum", EXPLO_BOUM); - CBotProgram::DefineNum("ExploBurn", EXPLO_BURN); - CBotProgram::DefineNum("ExploWater", EXPLO_WATER); + CBotProgram::DefineNum("ExploBoum", static_cast(ExplosionType::Bang)); + CBotProgram::DefineNum("ExploBurn", static_cast(ExplosionType::Burn)); + CBotProgram::DefineNum("ExploWater", static_cast(ExplosionType::Water)); CBotProgram::DefineNum("ResultNotEnded", ERR_MISSION_NOTERM); CBotProgram::DefineNum("ResultLost", INFO_LOST); diff --git a/src/ui/mainshort.cpp b/src/ui/mainshort.cpp index 059b03d6..805f34ae 100644 --- a/src/ui/mainshort.cpp +++ b/src/ui/mainshort.cpp @@ -139,7 +139,7 @@ bool CMainShort::CreateShortcuts() for (CObject* pObj : CObjectManager::GetInstancePointer()->GetAllObjects()) { - if ( !pObj->GetActif() ) continue; + if ( !pObj->GetActive() ) continue; if ( !pObj->GetSelectable() ) continue; if ( pObj->GetProxyActivate() ) continue; diff --git a/src/ui/map.cpp b/src/ui/map.cpp index f3f569a9..39c75744 100644 --- a/src/ui/map.cpp +++ b/src/ui/map.cpp @@ -331,7 +331,9 @@ void CMap::Draw() uv2.x = 0.5f + (m_offset.x + (m_half / m_zoom)) / (m_half * 2.0f); uv2.y = 0.5f - (m_offset.y - (m_half / m_zoom)) / (m_half * 2.0f); DrawVertex(uv1, uv2, 0.97f); // drawing the map - } else { // still image? + } + else // still image? + { std::string texFilename = m_fixImage; texFilename = "textures/"+texFilename; m_engine->LoadTexture(texFilename.c_str()); @@ -1154,7 +1156,7 @@ void CMap::UpdateObject(CObject* pObj) if ( !m_bEnable ) return; if ( m_totalFix >= m_totalMove ) return; // full table? - if ( !pObj->GetActif() ) return; + if ( !pObj->GetActive() ) return; if ( !pObj->GetSelectable() ) return; if ( pObj->GetProxyActivate() ) return; if ( pObj->GetTruck() != 0 ) return; diff --git a/src/ui/target.cpp b/src/ui/target.cpp index e541c695..66230746 100644 --- a/src/ui/target.cpp +++ b/src/ui/target.cpp @@ -189,7 +189,7 @@ CObject* CTarget::DetectFriendObject(Math::Point pos) for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects()) { - if ( !obj->GetActif() ) continue; + if ( !obj->GetActive() ) continue; if ( obj->GetProxyActivate() ) continue; if ( obj->GetSelect() ) continue;