From 46aa6fc907c7c0fc1fea7963e55caed6245f2574 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Tue, 27 Dec 2016 23:38:57 +0100 Subject: [PATCH] Some CRobotMain cleanup * improved documentation * renamed cheat variables to include the word "cheat" to make it clearer what they do * removed some useless members --- Doxyfile.in | 2 +- src/common/error.h | 168 ++++++------- src/level/robotmain.cpp | 159 ++++--------- src/level/robotmain.h | 177 +++++++++++--- src/object/auto/autofactory.cpp | 6 +- src/object/motion/motiontoto.cpp | 67 +++--- src/object/motion/motiontoto.h | 2 - src/object/object_type.h | 392 +++++++++++++++---------------- src/ui/mainshort.cpp | 4 +- 9 files changed, 499 insertions(+), 478 deletions(-) diff --git a/Doxyfile.in b/Doxyfile.in index c621ae33..5b0d31f7 100644 --- a/Doxyfile.in +++ b/Doxyfile.in @@ -351,7 +351,7 @@ IDL_PROPERTY_SUPPORT = YES # all members of a group must be documented explicitly. # The default value is: NO. -DISTRIBUTE_GROUP_DOC = NO +DISTRIBUTE_GROUP_DOC = YES # Set the SUBGROUPING tag to YES to allow class member groups of the same type # (for instance a group of public functions) to be put as a subgroup of that diff --git a/src/common/error.h b/src/common/error.h index 1ba77b1d..d3ae49f7 100644 --- a/src/common/error.h +++ b/src/common/error.h @@ -19,6 +19,10 @@ #pragma once +/** + * \file common/error.h + * \brief Definition of the Error enum + */ /** * \enum Error @@ -26,88 +30,88 @@ */ enum Error { - ERR_OK = 0, //! < ok - ERR_UNKNOWN = 1, //! < any error - ERR_CONTINUE = 2, //! < continues - ERR_STOP = 3, //! < stops - ERR_CMD = 4, //! < unknown command - ERR_OBJ_BUSY = 5, //! < object is busy - ERR_MANIP_FLY = 101, //! < impossible in flight - ERR_MANIP_BUSY = 102, //! < taking: hands already occupied - ERR_MANIP_NIL = 103, //! < taking: nothing has to take - ERR_MANIP_MOTOR = 105, //! < busy: impossible to move - ERR_MANIP_OCC = 106, //! < busy: location already occupied - ERR_MANIP_RADIO = 108, //! < impossible because radioactive - ERR_MANIP_WATER = 109, //! < not possible under water - ERR_MANIP_EMPTY = 110, //! < nothing to deposit - ERR_BUILD_FLY = 120, //! < not possible in flight - ERR_BUILD_WATER = 121, //! < not possible under water - ERR_BUILD_METALAWAY = 123, //! < lack of metal (too far) - ERR_BUILD_METALNEAR = 124, //! < lack of metal (too close) - ERR_BUILD_METALINEX = 125, //! < lack of metal - ERR_BUILD_FLAT = 126, //! < not enough flat ground - ERR_BUILD_FLATLIT = 127, //! < not enough flat ground space - ERR_BUILD_BUSY = 128, //! < location occupied - ERR_BUILD_BASE = 129, //! < too close to the rocket - ERR_BUILD_NARROW = 130, //! < buildings too close - ERR_BUILD_MOTOR = 131, //! < built: not possible in movement - ERR_BUILD_DISABLED = 132, //! < built: can not produce this object in this mission - ERR_BUILD_RESEARCH = 133, //! < built: can not produce not researched object - ERR_SEARCH_FLY = 140, //! < not possible in flight - ERR_SEARCH_MOTOR = 142, //! < impossible in movement - ERR_TERRA_ENERGY = 151, //! < not enough energy - ERR_FIRE_ENERGY = 161, //! < not enough energy - ERR_RECOVER_ENERGY = 171, //! < not enough energy - ERR_RECOVER_NULL = 172, //! < lack of ruin - ERR_CONVERT_EMPTY = 180, //! < no stone was transformed - ERR_SHIELD_ENERGY = 191, //! < not enough energy - ERR_MOVE_IMPOSSIBLE = 200, //! < move impossible - ERR_GOTO_IMPOSSIBLE = 210, //! < goto impossible - ERR_GOTO_ITER = 211, //! < goto too complicated - ERR_GOTO_BUSY = 212, //! < goto destination occupied - ERR_DERRICK_NULL = 300, //! < no ore underground - ERR_STATION_NULL = 301, //! < no energy underground - ERR_TOWER_POWER = 310, //! < no battery - ERR_TOWER_ENERGY = 311, //! < more energy - ERR_RESEARCH_POWER = 320, //! < no battery - ERR_RESEARCH_ENERGY = 321, //! < more energy - ERR_RESEARCH_TYPE = 322, //! < the wrong type of battery - ERR_RESEARCH_ALREADY = 323, //! < research already done - ERR_ENERGY_NULL = 330, //! < no energy underground - ERR_ENERGY_LOW = 331, //! < not enough energy - ERR_ENERGY_EMPTY = 332, //! < lack of metal - ERR_ENERGY_BAD = 333, //! < transforms only the metal - ERR_BASE_DLOCK = 340, //! < doors locked - ERR_BASE_DHUMAN = 341, //! < you must be on spaceship - ERR_LABO_NULL = 350, //! < nothing to analyze - ERR_LABO_BAD = 351, //! < analyzes only organic ball - ERR_LABO_ALREADY = 352, //! < analysis already made - ERR_NUCLEAR_EMPTY = 362, //! < lack of uranium - ERR_NUCLEAR_BAD = 363, //! < transforms only uranium - ERR_FACTORY_NULL = 370, //! < no metal - ERR_FACTORY_NEAR = 371, //! < vehicle too close - ERR_INFO_NULL = 390, //! < no information terminal - ERR_VEH_VIRUS = 400, //! < vehicle infected by a virus - ERR_BAT_VIRUS = 401, //! < building infected by a virus - ERR_DESTROY_NOTFOUND = 410, //! < not found anything to destroy - ERR_WRONG_OBJ = 420, //! < inappropriate vehicle - ERR_VEH_POWER = 500, //! < no battery - ERR_VEH_ENERGY = 501, //! < more energy - ERR_FLAG_FLY = 510, //! < impossible in flight - ERR_FLAG_WATER = 511, //! < impossible during swimming - ERR_FLAG_MOTOR = 512, //! < impossible in movement - ERR_FLAG_BUSY = 513, //! < taking: already creating flag - ERR_FLAG_CREATE = 514, //! < too many flags - ERR_FLAG_PROXY = 515, //! < too close - ERR_FLAG_DELETE = 516, //! < nothing to remove - ERR_MISSION_NOTERM = 600, //! < Mission not completed - ERR_DELETEMOBILE = 700, //! < vehicle destroyed - ERR_DELETEBUILDING = 701, //! < building destroyed - ERR_ENEMY_OBJECT = 703, //! < can't control enemy object - ERR_OBLIGATORYTOKEN = 800, //! < compulsory instruction missing - ERR_PROHIBITEDTOKEN = 801, //! < instruction prohibited - ERR_AIM_IMPOSSIBLE = 900, //! < cannot aim at specified angle(s) - ERR_WRONG_BOT = 910, //! < inappropriate bot + ERR_OK = 0, //!< ok + ERR_UNKNOWN = 1, //!< any error + ERR_CONTINUE = 2, //!< continues + ERR_STOP = 3, //!< stops + ERR_CMD = 4, //!< unknown command + ERR_OBJ_BUSY = 5, //!< object is busy + ERR_MANIP_FLY = 101, //!< impossible in flight + ERR_MANIP_BUSY = 102, //!< taking: hands already occupied + ERR_MANIP_NIL = 103, //!< taking: nothing has to take + ERR_MANIP_MOTOR = 105, //!< busy: impossible to move + ERR_MANIP_OCC = 106, //!< busy: location already occupied + ERR_MANIP_RADIO = 108, //!< impossible because radioactive + ERR_MANIP_WATER = 109, //!< not possible under water + ERR_MANIP_EMPTY = 110, //!< nothing to deposit + ERR_BUILD_FLY = 120, //!< not possible in flight + ERR_BUILD_WATER = 121, //!< not possible under water + ERR_BUILD_METALAWAY = 123, //!< lack of metal (too far) + ERR_BUILD_METALNEAR = 124, //!< lack of metal (too close) + ERR_BUILD_METALINEX = 125, //!< lack of metal + ERR_BUILD_FLAT = 126, //!< not enough flat ground + ERR_BUILD_FLATLIT = 127, //!< not enough flat ground space + ERR_BUILD_BUSY = 128, //!< location occupied + ERR_BUILD_BASE = 129, //!< too close to the rocket + ERR_BUILD_NARROW = 130, //!< buildings too close + ERR_BUILD_MOTOR = 131, //!< built: not possible in movement + ERR_BUILD_DISABLED = 132, //!< built: can not produce this object in this mission + ERR_BUILD_RESEARCH = 133, //!< built: can not produce not researched object + ERR_SEARCH_FLY = 140, //!< not possible in flight + ERR_SEARCH_MOTOR = 142, //!< impossible in movement + ERR_TERRA_ENERGY = 151, //!< not enough energy + ERR_FIRE_ENERGY = 161, //!< not enough energy + ERR_RECOVER_ENERGY = 171, //!< not enough energy + ERR_RECOVER_NULL = 172, //!< lack of ruin + ERR_CONVERT_EMPTY = 180, //!< no stone was transformed + ERR_SHIELD_ENERGY = 191, //!< not enough energy + ERR_MOVE_IMPOSSIBLE = 200, //!< move impossible + ERR_GOTO_IMPOSSIBLE = 210, //!< goto impossible + ERR_GOTO_ITER = 211, //!< goto too complicated + ERR_GOTO_BUSY = 212, //!< goto destination occupied + ERR_DERRICK_NULL = 300, //!< no ore underground + ERR_STATION_NULL = 301, //!< no energy underground + ERR_TOWER_POWER = 310, //!< no battery + ERR_TOWER_ENERGY = 311, //!< more energy + ERR_RESEARCH_POWER = 320, //!< no battery + ERR_RESEARCH_ENERGY = 321, //!< more energy + ERR_RESEARCH_TYPE = 322, //!< the wrong type of battery + ERR_RESEARCH_ALREADY = 323, //!< research already done + ERR_ENERGY_NULL = 330, //!< no energy underground + ERR_ENERGY_LOW = 331, //!< not enough energy + ERR_ENERGY_EMPTY = 332, //!< lack of metal + ERR_ENERGY_BAD = 333, //!< transforms only the metal + ERR_BASE_DLOCK = 340, //!< doors locked + ERR_BASE_DHUMAN = 341, //!< you must be on spaceship + ERR_LABO_NULL = 350, //!< nothing to analyze + ERR_LABO_BAD = 351, //!< analyzes only organic ball + ERR_LABO_ALREADY = 352, //!< analysis already made + ERR_NUCLEAR_EMPTY = 362, //!< lack of uranium + ERR_NUCLEAR_BAD = 363, //!< transforms only uranium + ERR_FACTORY_NULL = 370, //!< no metal + ERR_FACTORY_NEAR = 371, //!< vehicle too close + ERR_INFO_NULL = 390, //!< no information terminal + ERR_VEH_VIRUS = 400, //!< vehicle infected by a virus + ERR_BAT_VIRUS = 401, //!< building infected by a virus + ERR_DESTROY_NOTFOUND = 410, //!< not found anything to destroy + ERR_WRONG_OBJ = 420, //!< inappropriate vehicle + ERR_VEH_POWER = 500, //!< no battery + ERR_VEH_ENERGY = 501, //!< more energy + ERR_FLAG_FLY = 510, //!< impossible in flight + ERR_FLAG_WATER = 511, //!< impossible during swimming + ERR_FLAG_MOTOR = 512, //!< impossible in movement + ERR_FLAG_BUSY = 513, //!< taking: already creating flag + ERR_FLAG_CREATE = 514, //!< too many flags + ERR_FLAG_PROXY = 515, //!< too close + ERR_FLAG_DELETE = 516, //!< nothing to remove + ERR_MISSION_NOTERM = 600, //!< Mission not completed + ERR_DELETEMOBILE = 700, //!< vehicle destroyed + ERR_DELETEBUILDING = 701, //!< building destroyed + ERR_ENEMY_OBJECT = 703, //!< can't control enemy object + ERR_OBLIGATORYTOKEN = 800, //!< compulsory instruction missing + ERR_PROHIBITEDTOKEN = 801, //!< instruction prohibited + ERR_AIM_IMPOSSIBLE = 900, //!< cannot aim at specified angle(s) + ERR_WRONG_BOT = 910, //!< inappropriate bot INFO_FIRST = 10000, //! < first information INFO_BUILD = 10001, //! < construction builded diff --git a/src/level/robotmain.cpp b/src/level/robotmain.cpp index aa8ae91a..80e9ce06 100644 --- a/src/level/robotmain.cpp +++ b/src/level/robotmain.cpp @@ -202,8 +202,8 @@ CRobotMain::CRobotMain() m_editLock = false; m_editFull = false; m_hilite = false; - m_selectInsect = false; - m_showSoluce = false; + m_cheatSelectInsect = false; + m_cheatShowSoluce = false; m_codeBattleInit = false; m_codeBattleStarted = false; @@ -211,14 +211,14 @@ CRobotMain::CRobotMain() m_teamNames.clear(); #if DEV_BUILD - m_showAll = true; // for development + m_cheatAllMission = true; // for development #else - m_showAll = false; + m_cheatAllMission = false; #endif m_cheatRadar = false; m_fixScene = false; - m_trainerPilot = false; + m_cheatTrainerPilot = false; m_friendAim = false; m_resetCreate = false; m_shortCut = true; @@ -451,7 +451,7 @@ void CRobotMain::ChangePhase(Phase phase) m_lightning->Flush(); m_planet->Flush(); m_interface->Flush(); - FlushNewScriptName(); + m_newScriptName.clear(); m_sound->SetListener(Math::Vector(0.0f, 0.0f, 0.0f), Math::Vector(0.0f, 0.0f, 1.0f)); m_sound->StopAll(); m_camera->SetType(Gfx::CAM_TYPE_NULL); @@ -922,7 +922,7 @@ bool CRobotMain::ProcessEvent(Event &event) } if (data->slot == INPUT_SLOT_HUMAN) { - SelectHuman(); + SelectObject(SearchHuman()); } if (data->slot == INPUT_SLOT_NEXT && ((event.kmodState & KEY_MOD(CTRL)) != 0)) { @@ -1159,7 +1159,7 @@ void CRobotMain::ExecuteCmd(const std::string& cmd) if (cmd == "trainerpilot") { - m_trainerPilot = !m_trainerPilot; + m_cheatTrainerPilot = !m_cheatTrainerPilot; return; } @@ -1410,20 +1410,20 @@ void CRobotMain::ExecuteCmd(const std::string& cmd) if (cmd == "selectinsect") { - m_selectInsect = !m_selectInsect; + m_cheatSelectInsect = !m_cheatSelectInsect; return; } if (cmd == "showsoluce") { - m_showSoluce = !m_showSoluce; + m_cheatShowSoluce = !m_cheatShowSoluce; m_ui->ShowSoluceUpdate(); return; } if (cmd == "allmission") { - m_showAll = !m_showAll; + m_cheatAllMission = !m_cheatAllMission; m_ui->AllMissionUpdate(); return; } @@ -1763,20 +1763,17 @@ void CRobotMain::StopDisplayVisit() -//! Updates all the shortcuts void CRobotMain::UpdateShortcuts() { m_short->UpdateShortcuts(); } -//! Returns the object that default was select after the creation of a scene CObject* CRobotMain::GetSelectObject() { if (m_selectObject != nullptr) return m_selectObject; return SearchHuman(); } -//! Deselects everything, and returns the object that was selected CObject* CRobotMain::DeselectAll() { CObject* prev = nullptr; @@ -1833,17 +1830,8 @@ void CRobotMain::SelectOneObject(CObject* obj, bool displayError) { m_camera->SetType(Gfx::CAM_TYPE_BACK); } - - CObject* toto = SearchToto(); - if (toto != nullptr) - { - assert(toto->Implements(ObjectInterfaceType::Movable)); - CMotionToto* mt = static_cast(dynamic_cast(toto)->GetMotion()); - mt->SetLinkType(type); - } } -//! Selects the object aimed by the mouse bool CRobotMain::SelectObject(CObject* obj, bool displayError) { if (m_camera->GetType() == Gfx::CAM_TYPE_VISIT) @@ -1852,7 +1840,7 @@ bool CRobotMain::SelectObject(CObject* obj, bool displayError) if (m_movieLock || m_editLock) return false; if (m_movie->IsExist()) return false; if (obj != nullptr && - (!obj->Implements(ObjectInterfaceType::Controllable) || !(dynamic_cast(obj)->GetSelectable() || m_selectInsect))) return false; + (!obj->Implements(ObjectInterfaceType::Controllable) || !(dynamic_cast(obj)->GetSelectable() || m_cheatSelectInsect))) return false; if (m_missionType == MISSION_CODE_BATTLE && m_codeBattleStarted && m_codeBattleSpectator) { @@ -1883,7 +1871,6 @@ bool CRobotMain::SelectObject(CObject* obj, bool displayError) return true; } -//! Deselects the selected object bool CRobotMain::DeselectObject() { DeselectAll(); @@ -1919,49 +1906,11 @@ void CRobotMain::DeleteAllObjects() m_objMan->DeleteAllObjects(); } -//! Selects the human -void CRobotMain::SelectHuman() -{ - SelectObject(SearchHuman()); -} - -//! Returns the object human CObject* CRobotMain::SearchHuman() { return m_objMan->FindNearest(nullptr, OBJECT_HUMAN); } -//! Returns the object toto -CObject* CRobotMain::SearchToto() -{ - return m_objMan->FindNearest(nullptr, OBJECT_TOTO); -} - -//! Returns the nearest selectable object from a given position -CObject* CRobotMain::SearchNearest(Math::Vector pos, CObject* exclu) -{ - float min = 100000.0f; - CObject* best = nullptr; - for (CObject* obj : m_objMan->GetAllObjects()) - { - if (obj == exclu) continue; - if (!obj->Implements(ObjectInterfaceType::Controllable) || !(dynamic_cast(obj)->GetSelectable() || m_selectInsect)) continue; - - ObjectType type = obj->GetType(); - if (type == OBJECT_TOTO) continue; - - Math::Vector oPos = obj->GetPosition(); - float dist = Math::DistanceProjected(oPos, pos); - if (dist < min) - { - min = dist; - best = obj; - } - } - return best; -} - -//! Returns the selected object CObject* CRobotMain::GetSelect() { for (CObject* obj : m_objMan->GetAllObjects()) @@ -2113,7 +2062,7 @@ void CRobotMain::HiliteObject(Math::Point pos) } } - if (obj->Implements(ObjectInterfaceType::Controllable) && (dynamic_cast(obj)->GetSelectable() || m_selectInsect)) + if (obj->Implements(ObjectInterfaceType::Controllable) && (dynamic_cast(obj)->GetSelectable() || m_cheatSelectInsect)) { if (dynamic_cast(obj)->GetSelectable()) { @@ -2652,7 +2601,6 @@ bool CRobotMain::EventObject(const Event &event) -//! Load the scene for the character void CRobotMain::ScenePerso() { DeleteAllObjects(); // removes all the current 3D Scene @@ -3629,7 +3577,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) if (line->GetCommand() == "NewScript" && !resetObject) { - AddNewScriptName(line->GetParam("type")->AsObjectType(OBJECT_NULL), const_cast(line->GetParam("name")->AsPath("ai").c_str())); + m_newScriptName.push_back(NewScriptName(line->GetParam("type")->AsObjectType(OBJECT_NULL), const_cast(line->GetParam("name")->AsPath("ai").c_str()))); continue; } @@ -3950,15 +3898,17 @@ void CRobotMain::ChangeColor() } //! Calculates the distance to the nearest object -float CRobotMain::SearchNearestObject(Math::Vector center, CObject *exclu) +namespace +{ +float SearchNearestObject(CObjectManager* objMan, Math::Vector center, CObject* exclu) { float min = 100000.0f; - for (CObject* obj : m_objMan->GetAllObjects()) + for (CObject* obj : objMan->GetAllObjects()) { if (!obj->GetDetectable()) continue; // inactive? if (IsObjectBeingTransported(obj)) continue; - if (obj == exclu) continue; + if (obj == exclu) continue; ObjectType type = obj->GetType(); @@ -3968,35 +3918,36 @@ float CRobotMain::SearchNearestObject(Math::Vector center, CObject *exclu) if (oPos.x != center.x || oPos.z != center.z) { - float dist = Math::Distance(center, oPos)-80.0f; + float dist = Math::Distance(center, oPos) - 80.0f; if (dist < 0.0f) dist = 0.0f; min = Math::Min(min, dist); continue; } } - if (type == OBJECT_STATION || - type == OBJECT_REPAIR || + if (type == OBJECT_STATION || + type == OBJECT_REPAIR || type == OBJECT_DESTROYER) { Math::Vector oPos = obj->GetPosition(); - float dist = Math::Distance(center, oPos)-8.0f; + float dist = Math::Distance(center, oPos) - 8.0f; if (dist < 0.0f) dist = 0.0f; min = Math::Min(min, dist); } - for (const auto& crashSphere : obj->GetAllCrashSpheres()) + for (const auto &crashSphere : obj->GetAllCrashSpheres()) { Math::Vector oPos = crashSphere.sphere.pos; float oRadius = crashSphere.sphere.radius; - float dist = Math::Distance(center, oPos)-oRadius; + float dist = Math::Distance(center, oPos) - oRadius; if (dist < 0.0f) dist = 0.0f; min = Math::Min(min, dist); } } return min; } +} //! Calculates a free space bool CRobotMain::FreeSpace(Math::Vector ¢er, float minRadius, float maxRadius, @@ -4018,7 +3969,7 @@ bool CRobotMain::FreeSpace(Math::Vector ¢er, float minRadius, float maxRadiu pos.z = p.y; pos.y = 0.0f; m_terrain->AdjustToFloor(pos, true); - float dist = SearchNearestObject(pos, exclu); + float dist = SearchNearestObject(m_objMan.get(), pos, exclu); if (dist >= space) { float flat = m_terrain->GetFlatZoneRadius(pos, dist/2.0f); @@ -4047,7 +3998,7 @@ bool CRobotMain::FreeSpace(Math::Vector ¢er, float minRadius, float maxRadiu pos.z = p.y; pos.y = 0.0f; m_terrain->AdjustToFloor(pos, true); - float dist = SearchNearestObject(pos, exclu); + float dist = SearchNearestObject(m_objMan.get(), pos, exclu); if (dist >= space) { float flat = m_terrain->GetFlatZoneRadius(pos, dist/2.0f); @@ -4083,7 +4034,7 @@ bool CRobotMain::FlatFreeSpace(Math::Vector ¢er, float minFlat, float minRad pos.z = p.y; pos.y = 0.0f; m_terrain->AdjustToFloor(pos, true); - float dist = SearchNearestObject(pos, exclu); + float dist = SearchNearestObject(m_objMan.get(), pos, exclu); if (dist >= space) { float flat = m_terrain->GetFlatZoneRadius(pos, dist/2.0f); @@ -4116,7 +4067,7 @@ bool CRobotMain::FlatFreeSpace(Math::Vector ¢er, float minFlat, float minRad pos.z = p.y; pos.y = 0.0f; m_terrain->AdjustToFloor(pos, true); - float dist = SearchNearestObject(pos, exclu); + float dist = SearchNearestObject(m_objMan.get(), pos, exclu); if (dist >= space) { float flat = m_terrain->GetFlatZoneRadius(pos, dist/2.0f); @@ -4140,7 +4091,7 @@ bool CRobotMain::FlatFreeSpace(Math::Vector ¢er, float minFlat, float minRad float CRobotMain::GetFlatZoneRadius(Math::Vector center, float maxRadius, CObject *exclu) { - float dist = SearchNearestObject(center, exclu); + float dist = SearchNearestObject(m_objMan.get(), center, exclu); if (dist == 0.0f) return 0.0f; if (dist < maxRadius) maxRadius = dist; @@ -4412,36 +4363,19 @@ bool CRobotMain::ReadFileStack(CObject *obj, FILE *file, int objRank) return programmable->ReadStack(file); } - -//! Empty the list -void CRobotMain::FlushNewScriptName() +std::vector CRobotMain::GetNewScriptNames(ObjectType type) { - m_newScriptName.clear(); -} - -//! Adds a script name -void CRobotMain::AddNewScriptName(ObjectType type, const std::string& name) -{ - NewScriptName newscript; - newscript.type = type; - newscript.name = name; - m_newScriptName.push_back(newscript); -} - -//! Seeks a script name for a given type -std::string CRobotMain::GetNewScriptName(ObjectType type, int rank) -{ - for (unsigned int i = 0; i < m_newScriptName.size(); i++) + std::vector names; + for (const auto& newScript : m_newScriptName) { - if (m_newScriptName[i].type == type || - m_newScriptName[i].type == OBJECT_NULL ) + if (newScript.type == type || + newScript.type == OBJECT_NULL ) { - if (rank == 0) return m_newScriptName[i].name; - else rank --; + names.push_back(newScript.name); } } - return ""; + return names; } @@ -5114,7 +5048,7 @@ const std::map& CRobotMain::GetObligatoryTokenList() //! Indicates whether it is possible to control a driving robot bool CRobotMain::GetTrainerPilot() { - return m_trainerPilot; + return m_cheatTrainerPilot; } //! Indicates whether the scene is fixed, without interaction @@ -5137,7 +5071,7 @@ const std::string& CRobotMain::GetScriptFile() bool CRobotMain::GetShowSoluce() { - return m_showSoluce; + return m_cheatShowSoluce; } bool CRobotMain::GetSceneSoluce() @@ -5148,7 +5082,7 @@ bool CRobotMain::GetSceneSoluce() bool CRobotMain::GetShowAll() { - return m_showAll; + return m_cheatAllMission; } bool CRobotMain::GetRadar() @@ -5272,7 +5206,6 @@ void CRobotMain::UpdateSpeedLabel() } -//! Creates interface shortcuts to the units bool CRobotMain::CreateShortcuts() { if (m_phase != PHASE_SIMUL) return false; @@ -5662,11 +5595,6 @@ Error CRobotMain::CanBuildError(ObjectType type, int team) return ERR_OK; } -bool CRobotMain::CanBuild(ObjectType type, int team) -{ - return CanBuildError(type, team) == ERR_OK; -} - Error CRobotMain::CanFactoryError(ObjectType type, int team) { ToolType tool = GetToolFromObject(type); @@ -5690,11 +5618,6 @@ Error CRobotMain::CanFactoryError(ObjectType type, int team) return ERR_OK; } -bool CRobotMain::CanFactory(ObjectType type, int team) -{ - return CanFactoryError(type, team) == ERR_OK; -} - void CRobotMain::PushToSelectionHistory(CObject* obj) { if (!m_selectionHistory.empty() && m_selectionHistory.back() == obj) diff --git a/src/level/robotmain.h b/src/level/robotmain.h index 54d15abc..346e8fc4 100644 --- a/src/level/robotmain.h +++ b/src/level/robotmain.h @@ -120,6 +120,8 @@ struct NewScriptName { ObjectType type = OBJECT_NULL; std::string name = ""; + + NewScriptName(ObjectType type, const std::string& name) : type(type), name(name) {} }; @@ -156,6 +158,17 @@ const int SATCOM_PROG = 4; const int SATCOM_SOLUCE = 5; const int SATCOM_MAX = 6; +/** + * \brief Main class managing the game world + * + * This is the main class of the whole game engine. It's main job is to manage main parts of the gameplay, + * like loading levels and checking for win conditions, but it's also a place where all things that don't fit + * elsewhere have landed. + * + * \todo In the future, it would be nice to refactor this class to remove as much unrelated stuff as possible + * + * \nosubgrouping + */ class CRobotMain : public CSingleton { public: @@ -168,11 +181,16 @@ public: Ui::CDisplayText* GetDisplayText(); CPauseManager* GetPauseManager(); + /** + * \name Phase management + */ + //@{ void ChangePhase(Phase phase); bool ProcessEvent(Event &event); Phase GetPhase(); + //@} - bool CreateShortcuts(); + //! Load the scene for apperance customization void ScenePerso(); void SetMovieLock(bool lock); @@ -187,16 +205,32 @@ public: void SetFriendAim(bool friendAim); bool GetFriendAim(); + //! \name Simulation speed management + //@{ void SetSpeed(float speed); float GetSpeed(); + //@} + //! \brief Create the shortcuts at the top of the screen, if they should be visible + //! \see CMainShort::CreateShortcuts + bool CreateShortcuts(); + //! \brief Update the shortcuts at the top of the screen + //! \see CMainShort::UpdateShortcuts void UpdateShortcuts(); - void SelectHuman(); + //! Find the astronaut (::OBJECT_HUMAN) object CObject* SearchHuman(); - CObject* SearchToto(); - CObject* SearchNearest(Math::Vector pos, CObject* exclu); + /** + * \brief Select an object + * \param obj Object to select + * \param displayError If true and the object is currently in error state, automatically display the error message + * + * \note This function automatically adds objects to selection history (see PushToSelectionHistory()) + */ bool SelectObject(CObject* obj, bool displayError=true); + //! Return the object that was selected at the start of the scene CObject* GetSelectObject(); + //! Deselect currently selected object + //! \return Object that was deselected CObject* DeselectAll(); void ResetObject(); @@ -251,9 +285,10 @@ public: void ClearInterface(); void ChangeColor(); - float SearchNearestObject(Math::Vector center, CObject *exclu); bool FreeSpace(Math::Vector ¢er, float minRadius, float maxRadius, float space, CObject *exclu); bool FlatFreeSpace(Math::Vector ¢er, float minFlat, float minRadius, float maxRadius, float space, CObject *exclu); + //! \name In-world indicators + //@{ float GetFlatZoneRadius(Math::Vector center, float maxRadius, CObject *exclu); void HideDropZone(CObject* metal); void ShowDropZone(CObject* metal, CObject* transporter); @@ -262,28 +297,34 @@ public: float radius, float duration=SHOWLIMITTIME); void StartShowLimit(); void FrameShowLimit(float rTime); + //@} void SaveAllScript(); void SaveOneScript(CObject *obj); bool SaveFileStack(CObject *obj, FILE *file, int objRank); bool ReadFileStack(CObject *obj, FILE *file, int objRank); - void FlushNewScriptName(); - void AddNewScriptName(ObjectType type, const std::string& name); - std::string GetNewScriptName(ObjectType type, int rank); + //! Return list of scripts to load to robot created in BotFactory + std::vector GetNewScriptNames(ObjectType type); void SelectPlayer(std::string playerName); CPlayerProfile* GetPlayerProfile(); + /** + * \name Saved game read/write + */ + //@{ bool IOIsBusy(); bool IOWriteScene(std::string filename, std::string filecbot, std::string filescreenshot, const std::string& info, bool emergencySave = false); void IOWriteSceneFinished(); CObject* IOReadScene(std::string filename, std::string filecbot); void IOWriteObject(CLevelParserLine *line, CObject* obj, const std::string& programDir, int objRank); CObject* IOReadObject(CLevelParserLine *line, const std::string& programDir, const std::string& objCounterText, float objectProgress, int objRank = -1); + //@} int CreateSpot(Math::Vector pos, Gfx::Color color); + //! Find the currently selected object CObject* GetSelect(); void DisplayError(Error err, CObject* pObj, float time=10.0f); @@ -298,12 +339,17 @@ public: void StartMissionTimer(); + /** + * \name Autosave management + */ + //@{ 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); @@ -311,49 +357,97 @@ public: //! Returns true if player can interact with things manually bool CanPlayerInteract(); + /** + * \name Team definition management + */ + //@{ //! Returns team name for the given team id const std::string& GetTeamName(int id); //! Returns true if team-specific colored texture is available bool IsTeamColorDefined(int id); + //@} - //! Get/set enabled buildings + /** + * \name EnableBuild/EnableResearch/DoneResearch + * Management of enabled buildings, enabled researches, and completed researches + */ //@{ + /** + * \brief Get enabled buildings + * \return Bitmask of BuildType values + */ int GetEnableBuild(); + /** + * \brief Set enabled buildings + * \param enableBuild Bitmask of BuildType values + */ void SetEnableBuild(int enableBuild); - //@} - //! Get/set enabled researches - //@{ - int GetEnableResearch(); - void SetEnableResearch(int enableResearch); - //@} - //! Get/set done researches - //@{ - int GetDoneResearch(int team); - void SetDoneResearch(int doneResearch, int team); - //@} - //! Returns true if the given building is enabled - //@{ + /** + * \brief Get enabled researches + * \return Bitmask of ResearchType values + */ + int GetEnableResearch(); + /** + * \brief Set enabled researches + * \param enableResearch Bitmask of ResearchType values + */ + void SetEnableResearch(int enableResearch); + /** + * \brief Get done researches + * \param team Team to get researches for + * \return Bitmask of ResearchType values + */ + int GetDoneResearch(int team = 0); + /** + * \brief Set done researches + * \param doneResearch Bitmask of ResearchType values + * \param team Team to set researches for + */ + void SetDoneResearch(int doneResearch, int team = 0); + + //! \brief Check if the given building is enabled bool IsBuildingEnabled(BuildType type); + //! \brief Check if the given building is enabled bool IsBuildingEnabled(ObjectType type); - //@} - //! Returns true if the given research is enabled + //! \brief Check if the given research is enabled bool IsResearchEnabled(ResearchType type); - //! Returns true if the given research is done + //! \brief Check if the given research is done bool IsResearchDone(ResearchType type, int team); - //! Marks research as done + //! \brief Mark given research as done void MarkResearchDone(ResearchType type, int team); - //! Retruns true if all requirements to build this object are met (EnableBuild + DoneResearch) - //@{ - bool CanBuild(ObjectType type, int team); + /** + * \brief Check if all requirements to build this object are met (EnableBuild + DoneResearch) + * \return true if the building can be built, false otherwise + * \see CanBuildError() for a version which returns a specific reason for the build being denied + */ + inline bool CanBuild(ObjectType type, int team) + { + return CanBuildError(type, team) == ERR_OK; + } + /** + * \brief Check if all requirements to build this object are met (EnableBuild + DoneResearch) + * \return One of Error values - ::ERR_OK if the building can be built, ::ERR_BUILD_DISABLED or ::ERR_BUILD_RESEARCH otherwise + * \see CanBuild() for a version which returns a boolean + */ Error CanBuildError(ObjectType type, int team); - //@} - //! Retruns true if all requirements to create this object in BotFactory are met (DoneResearch) - //@{ - bool CanFactory(ObjectType type, int team); + /** + * \brief Check if all requirements to build this object in BotFactory are met (DoneResearch) + * \return true if the robot can be built, false otherwise + * \see CanFactoryError() for a version which returns a specific reason for the build being denied + */ + inline bool CanFactory(ObjectType type, int team) + { + return CanFactoryError(type, team) == ERR_OK; + } + /** + * \brief Check if all requirements to build this object in BotFactory are met (DoneResearch) + * \return One of Error values - ::ERR_OK if the robot can be built, ::ERR_BUILD_DISABLED or ::ERR_BUILD_RESEARCH otherwise + * \see CanFactory() for a version which returns a boolean + */ Error CanFactoryError(ObjectType type, int team); //@} @@ -364,7 +458,9 @@ public: void StartDetectEffect(COldObject* object, CObject* target); + //! Enable crash sphere debug rendering void SetDebugCrashSpheres(bool draw); + //! Check if crash sphere debug rendering is enabled bool GetDebugCrashSpheres(); protected: @@ -388,8 +484,11 @@ protected: CObject* DetectObject(Math::Point pos); void ChangeCamera(); void AbortMovie(); + //! \brief Select an object, without deselecting the previous one void SelectOneObject(CObject* obj, bool displayError=true); void HelpObject(); + //! \brief Switch to previous object + //! \see PopFromSelectionHistory() bool DeselectObject(); void DeleteAllObjects(); void UpdateInfoText(); @@ -405,9 +504,13 @@ protected: void PushToSelectionHistory(CObject* obj); CObject* PopFromSelectionHistory(); + //! \name Code battle interface + //@{ void CreateCodeBattleInterface(); void DestroyCodeBattleInterface(); void SetCodeBattleSpectatorMode(bool mode); + //@} + void UpdateDebugCrashSpheres(); @@ -469,9 +572,9 @@ protected: ActivePause* m_freePhotoPause = nullptr; bool m_cmdEdit = false; ActivePause* m_cmdEditPause = nullptr; - bool m_selectInsect = false; - bool m_showSoluce = false; - bool m_showAll = false; + bool m_cheatSelectInsect = false; + bool m_cheatShowSoluce = false; + bool m_cheatAllMission = false; bool m_cheatRadar = false; bool m_shortCut = false; std::string m_audioTrack; @@ -493,7 +596,7 @@ protected: bool m_editLock = false; // edition in progress? bool m_editFull = false; // edition in full screen? bool m_hilite = false; - bool m_trainerPilot = false; // remote trainer? + bool m_cheatTrainerPilot = false; // remote trainer? bool m_friendAim = false; bool m_resetCreate = false; bool m_mapShow = false; diff --git a/src/object/auto/autofactory.cpp b/src/object/auto/autofactory.cpp index b48e7cf6..7dfc280d 100644 --- a/src/object/auto/autofactory.cpp +++ b/src/object/auto/autofactory.cpp @@ -664,11 +664,9 @@ bool CAutoFactory::CreateVehicle() if (vehicle->Implements(ObjectInterfaceType::ProgramStorage)) { CProgramStorageObject* programStorage = dynamic_cast(vehicle); - for ( int i=0 ; ; i++ ) + for (const std::string& name : m_main->GetNewScriptNames(m_type)) { - std::string name = m_main->GetNewScriptName(m_type, i); - if (name.empty()) break; - Program* prog = programStorage->GetOrAddProgram(i); + Program* prog = programStorage->AddProgram(); programStorage->ReadProgram(prog, InjectLevelPathsForCurrentLevel(name)); prog->readOnly = true; prog->filename = name; diff --git a/src/object/motion/motiontoto.cpp b/src/object/motion/motiontoto.cpp index 18db7471..7f1a608b 100644 --- a/src/object/motion/motiontoto.cpp +++ b/src/object/motion/motiontoto.cpp @@ -57,7 +57,6 @@ CMotionToto::CMotionToto(COldObject* object) : CMotion(object) m_blinkTime = 0.0f; m_blinkProgress = -1.0f; m_lastMotorParticle = 0.0f; - m_type = OBJECT_NULL; m_mousePos = Math::Point(0.0f, 0.0f); } @@ -325,36 +324,39 @@ bool CMotionToto::EventFrame(const Event &event) distance = 30.0f-progress*18.0f; // remoteness shift = 18.0f-progress*11.0f; // shift is left verti = 10.0f-progress* 8.0f; // shift at the top + + CObject* selected = m_main->GetSelect(); + ObjectType type = selected != nullptr ? selected->GetType() : OBJECT_NULL; if ( m_actionType == -1 && - (m_type == OBJECT_HUMAN || - m_type == OBJECT_TECH || - m_type == OBJECT_MOBILEwa || - m_type == OBJECT_MOBILEta || - m_type == OBJECT_MOBILEfa || - m_type == OBJECT_MOBILEia || - m_type == OBJECT_MOBILEwc || - m_type == OBJECT_MOBILEtc || - m_type == OBJECT_MOBILEfc || - m_type == OBJECT_MOBILEic || - m_type == OBJECT_MOBILEwi || - m_type == OBJECT_MOBILEti || - m_type == OBJECT_MOBILEfi || - m_type == OBJECT_MOBILEii || - m_type == OBJECT_MOBILEws || - m_type == OBJECT_MOBILEts || - m_type == OBJECT_MOBILEfs || - m_type == OBJECT_MOBILEis || - m_type == OBJECT_MOBILErt || - m_type == OBJECT_MOBILErc || - m_type == OBJECT_MOBILErr || - m_type == OBJECT_MOBILErs || - m_type == OBJECT_MOBILEsa || - m_type == OBJECT_MOBILEwt || - m_type == OBJECT_MOBILEtt || - m_type == OBJECT_MOBILEft || - m_type == OBJECT_MOBILEit || - m_type == OBJECT_MOBILEdr ) ) // vehicle? + (type == OBJECT_HUMAN || + type == OBJECT_TECH || + type == OBJECT_MOBILEwa || + type == OBJECT_MOBILEta || + type == OBJECT_MOBILEfa || + type == OBJECT_MOBILEia || + type == OBJECT_MOBILEwc || + type == OBJECT_MOBILEtc || + type == OBJECT_MOBILEfc || + type == OBJECT_MOBILEic || + type == OBJECT_MOBILEwi || + type == OBJECT_MOBILEti || + type == OBJECT_MOBILEfi || + type == OBJECT_MOBILEii || + type == OBJECT_MOBILEws || + type == OBJECT_MOBILEts || + type == OBJECT_MOBILEfs || + type == OBJECT_MOBILEis || + type == OBJECT_MOBILErt || + type == OBJECT_MOBILErc || + type == OBJECT_MOBILErr || + type == OBJECT_MOBILErs || + type == OBJECT_MOBILEsa || + type == OBJECT_MOBILEwt || + type == OBJECT_MOBILEtt || + type == OBJECT_MOBILEft || + type == OBJECT_MOBILEit || + type == OBJECT_MOBILEdr ) ) // vehicle? { m_clownTime += event.rTime; if ( m_clownTime >= m_clownDelay ) @@ -832,10 +834,3 @@ Error CMotionToto::SetAction(int action, float time) return ERR_OK; } - -// Specifies the type of the object is attached to toto. - -void CMotionToto::SetLinkType(ObjectType type) -{ - m_type = type; -} diff --git a/src/object/motion/motiontoto.h b/src/object/motion/motiontoto.h index 1e97c03a..fe907308 100644 --- a/src/object/motion/motiontoto.h +++ b/src/object/motion/motiontoto.h @@ -43,7 +43,6 @@ public: void Create(Math::Vector pos, float angle, ObjectType type, float power, Gfx::COldModelManager* modelManager) override; bool EventProcess(const Event &event) override; Error SetAction(int action, float time=0.2f) override; - void SetLinkType(ObjectType type); void StartDisplayInfo(); void StopDisplayInfo(); @@ -65,6 +64,5 @@ protected: float m_blinkTime; float m_blinkProgress; int m_soundChannel; - ObjectType m_type; Math::Point m_mousePos; }; diff --git a/src/object/object_type.h b/src/object/object_type.h index 7467ff3e..11d5763d 100644 --- a/src/object/object_type.h +++ b/src/object/object_type.h @@ -33,203 +33,203 @@ enum ObjectType { OBJECT_NULL = 0, - OBJECT_PORTICO = 2, //! < Portico - OBJECT_BASE = 3, //! < SpaceShip - OBJECT_DERRICK = 4, //! < Derrick - OBJECT_FACTORY = 5, //! < BotFactory - OBJECT_STATION = 6, //! < PowerStation - OBJECT_CONVERT = 7, //! < Converter - OBJECT_REPAIR = 8, //! < RepairStation - OBJECT_TOWER = 9, //! < DefenseTower - OBJECT_NEST = 10, //! < AlienNest - OBJECT_RESEARCH = 11, //! < ResearchCenter - OBJECT_RADAR = 12, //! < RadarStation - OBJECT_ENERGY = 13, //! < PowerPlant - OBJECT_LABO = 14, //! < AutoLab - OBJECT_NUCLEAR = 15, //! < NuclearPlant - OBJECT_START = 16, //! < StartArea - OBJECT_END = 17, //! < EndArea - OBJECT_INFO = 18, //! < ExchangePost - OBJECT_PARA = 19, //! < PowerCaptor - OBJECT_TARGET1 = 20, //! < Target1 (gate) - OBJECT_TARGET2 = 21, //! < Target2 (center) - OBJECT_SAFE = 22, //! < Vault - OBJECT_HUSTON = 23, //! < Houston - OBJECT_DESTROYER = 24, //! < Destroyer - OBJECT_STONE = 31, //! < TitaniumOre - OBJECT_URANIUM = 32, //! < UraniumOre - OBJECT_METAL = 33, //! < Titanium - OBJECT_POWER = 34, //! < PowerCell - OBJECT_ATOMIC = 35, //! < NuclearCell - OBJECT_BULLET = 36, //! < OrgaMatter - OBJECT_BBOX = 37, //! < BlackBox - OBJECT_TNT = 38, //! < TNT - OBJECT_MARKPOWER = 50, //! < PowerSpot - OBJECT_MARKSTONE = 51, //! < TitaniumSpot - OBJECT_MARKURANIUM = 52, //! < UraniumSpot - OBJECT_MARKKEYa = 53, //! < KeyASpot - OBJECT_MARKKEYb = 54, //! < KeyBSpot - OBJECT_MARKKEYc = 55, //! < KeyCSpot - OBJECT_MARKKEYd = 56, //! < KeyDSpot - OBJECT_BOMB = 60, //! < Mine - OBJECT_WINFIRE = 61, //! < Firework - OBJECT_SHOW = 62, //! < arrow above object (Visit) - OBJECT_BAG = 63, //! < Bag - OBJECT_PLANT0 = 70, //! < Greenery0 - OBJECT_PLANT1 = 71, //! < Greenery1 - OBJECT_PLANT2 = 72, //! < Greenery2 - OBJECT_PLANT3 = 73, //! < Greenery3 - OBJECT_PLANT4 = 74, //! < Greenery4 - OBJECT_PLANT5 = 75, //! < Greenery5 - OBJECT_PLANT6 = 76, //! < Greenery6 - OBJECT_PLANT7 = 77, //! < Greenery7 - OBJECT_PLANT8 = 78, //! < Greenery8 - OBJECT_PLANT9 = 79, //! < Greenery9 - OBJECT_PLANT10 = 80, //! < Greenery10 - OBJECT_PLANT11 = 81, //! < Greenery11 - OBJECT_PLANT12 = 82, //! < Greenery12 - OBJECT_PLANT13 = 83, //! < Greenery13 - OBJECT_PLANT14 = 84, //! < Greenery14 - OBJECT_PLANT15 = 85, //! < Greenery15 - OBJECT_PLANT16 = 86, //! < Greenery16 - OBJECT_PLANT17 = 87, //! < Greenery17 - OBJECT_PLANT18 = 88, //! < Greenery18 - OBJECT_PLANT19 = 89, //! < Greenery19 - OBJECT_TREE0 = 90, //! < Tree0 - OBJECT_TREE1 = 91, //! < Tree1 - OBJECT_TREE2 = 92, //! < Tree2 - OBJECT_TREE3 = 93, //! < Tree3 - OBJECT_TREE4 = 94, //! < Tree4 - OBJECT_TREE5 = 95, //! < Tree5 - OBJECT_MOBILEwt = 100, //! < PracticeBot - OBJECT_MOBILEtt = 101, //! < track-trainer (unused) - OBJECT_MOBILEft = 102, //! < fly-trainer (unused) - OBJECT_MOBILEit = 103, //! < insect-trainer (unused) - OBJECT_MOBILEwa = 110, //! < WheeledGrabber - OBJECT_MOBILEta = 111, //! < TrackedGrabber - OBJECT_MOBILEfa = 112, //! < WingedGrabber - OBJECT_MOBILEia = 113, //! < LeggedGrabber - OBJECT_MOBILEwc = 120, //! < WheeledShooter - OBJECT_MOBILEtc = 121, //! < TrackedShooter - OBJECT_MOBILEfc = 122, //! < WingedShooter - OBJECT_MOBILEic = 123, //! < LeggedShooter - OBJECT_MOBILEwi = 130, //! < WheeledOrgaShooter - OBJECT_MOBILEti = 131, //! < TrackedOrgaShooter - OBJECT_MOBILEfi = 132, //! < WingedOrgaShooter - OBJECT_MOBILEii = 133, //! < LeggedOrgaShooter - OBJECT_MOBILEws = 140, //! < WheeledSniffer - OBJECT_MOBILEts = 141, //! < TrackedSniffer - OBJECT_MOBILEfs = 142, //! < WingedSniffer - OBJECT_MOBILEis = 143, //! < LeggedSniffer - OBJECT_MOBILErt = 200, //! < Thumper - OBJECT_MOBILErc = 201, //! < PhazerShooter - OBJECT_MOBILErr = 202, //! < Recycler - OBJECT_MOBILErs = 203, //! < Shielder - OBJECT_MOBILEsa = 210, //! < Subber - OBJECT_MOBILEtg = 211, //! < TargetBot - OBJECT_MOBILEdr = 212, //! < Scribbler - OBJECT_CONTROLLER = 213, //! < MissionController - OBJECT_WAYPOINT = 250, //! < WayPoint - OBJECT_FLAGb = 260, //! < BlueFlag - OBJECT_FLAGr = 261, //! < RedFlag - OBJECT_FLAGg = 262, //! < GreenFlag - OBJECT_FLAGy = 263, //! < YellowFlag - OBJECT_FLAGv = 264, //! < VioletFlag - OBJECT_KEYa = 270, //! < KeyA - OBJECT_KEYb = 271, //! < KeyB - OBJECT_KEYc = 272, //! < KeyC - OBJECT_KEYd = 273, //! < KeyD - OBJECT_HUMAN = 300, //! < Me - OBJECT_TOTO = 301, //! < Robby (toto) - OBJECT_TECH = 302, //! < Tech - OBJECT_BARRIER0 = 400, //! < Barrier0 - OBJECT_BARRIER1 = 401, //! < Barrier1 - OBJECT_BARRIER2 = 402, //! < Barrier2 - OBJECT_BARRIER3 = 403, //! < Barrier3 - OBJECT_MOTHER = 500, //! < AlienQueen - OBJECT_EGG = 501, //! < AlienEgg - OBJECT_ANT = 502, //! < AlienAnt - OBJECT_SPIDER = 503, //! < AlienSpider - OBJECT_BEE = 504, //! < AlienWasp - OBJECT_WORM = 505, //! < AlienWorm - OBJECT_RUINmobilew1 = 600, //! < WreckBotw1 - OBJECT_RUINmobilew2 = 601, //! < WreckBotw2 - OBJECT_RUINmobilet1 = 602, //! < WreckBott1 - OBJECT_RUINmobilet2 = 603, //! < WreckBott2 - OBJECT_RUINmobiler1 = 604, //! < WreckBotr1 - OBJECT_RUINmobiler2 = 605, //! < WreckBotr2 - OBJECT_RUINfactory = 606, //! < RuinBotFactory - OBJECT_RUINdoor = 607, //! < RuinDoor - OBJECT_RUINsupport = 608, //! < RuinSupport - OBJECT_RUINradar = 609, //! < RuinRadar - OBJECT_RUINconvert = 610, //! < RuinConvert - OBJECT_RUINbase = 611, //! < RuinBaseCamp - OBJECT_RUINhead = 612, //! < RuinHeadCamp - OBJECT_TEEN0 = 620, //! < Teen0 - OBJECT_TEEN1 = 621, //! < Teen1 - OBJECT_TEEN2 = 622, //! < Teen2 - OBJECT_TEEN3 = 623, //! < Teen3 - OBJECT_TEEN4 = 624, //! < Teen4 - OBJECT_TEEN5 = 625, //! < Teen5 - OBJECT_TEEN6 = 626, //! < Teen6 - OBJECT_TEEN7 = 627, //! < Teen7 - OBJECT_TEEN8 = 628, //! < Teen8 - OBJECT_TEEN9 = 629, //! < Teen9 - OBJECT_TEEN10 = 630, //! < Teen10 - OBJECT_TEEN11 = 631, //! < Teen11 - OBJECT_TEEN12 = 632, //! < Teen12 - OBJECT_TEEN13 = 633, //! < Teen13 - OBJECT_TEEN14 = 634, //! < Teen14 - OBJECT_TEEN15 = 635, //! < Teen15 - OBJECT_TEEN16 = 636, //! < Teen16 - OBJECT_TEEN17 = 637, //! < Teen17 - OBJECT_TEEN18 = 638, //! < Teen18 - OBJECT_TEEN19 = 639, //! < Teen19 - OBJECT_TEEN20 = 640, //! < Teen20 - OBJECT_TEEN21 = 641, //! < Teen21 - OBJECT_TEEN22 = 642, //! < Teen22 - OBJECT_TEEN23 = 643, //! < Teen23 - OBJECT_TEEN24 = 644, //! < Teen24 - OBJECT_TEEN25 = 645, //! < Teen25 - OBJECT_TEEN26 = 646, //! < Teen26 - OBJECT_TEEN27 = 647, //! < Teen27 - OBJECT_TEEN28 = 648, //! < Teen28 - OBJECT_TEEN29 = 649, //! < Teen29 - OBJECT_TEEN30 = 650, //! < Teen30 - OBJECT_TEEN31 = 651, //! < Teen31 - OBJECT_TEEN32 = 652, //! < Teen32 - OBJECT_TEEN33 = 653, //! < Teen33 - OBJECT_TEEN34 = 654, //! < Stone (Teen34) - OBJECT_TEEN35 = 655, //! < Teen35 - OBJECT_TEEN36 = 656, //! < Teen36 - OBJECT_TEEN37 = 657, //! < Teen37 - OBJECT_TEEN38 = 658, //! < Teen38 - OBJECT_TEEN39 = 659, //! < Teen39 - OBJECT_TEEN40 = 660, //! < Teen40 - OBJECT_TEEN41 = 661, //! < Teen41 - OBJECT_TEEN42 = 662, //! < Teen42 - OBJECT_TEEN43 = 663, //! < Teen43 - OBJECT_TEEN44 = 664, //! < Teen44 - OBJECT_QUARTZ0 = 700, //! < Quartz0 - OBJECT_QUARTZ1 = 701, //! < Quartz1 - OBJECT_QUARTZ2 = 702, //! < Quartz2 - OBJECT_QUARTZ3 = 703, //! < Quartz3 - OBJECT_ROOT0 = 710, //! < MegaStalk0 - OBJECT_ROOT1 = 711, //! < MegaStalk1 - OBJECT_ROOT2 = 712, //! < MegaStalk2 - OBJECT_ROOT3 = 713, //! < MegaStalk3 - OBJECT_ROOT4 = 714, //! < MegaStalk4 - OBJECT_ROOT5 = 715, //! < MegaStalk5 - OBJECT_MUSHROOM1 = 731, //! < Mushroom1 - OBJECT_MUSHROOM2 = 732, //! < Mushroom2 - OBJECT_APOLLO1 = 900, //! < ApolloLEM - OBJECT_APOLLO2 = 901, //! < ApolloJeep - OBJECT_APOLLO3 = 902, //! < ApolloFlag - OBJECT_APOLLO4 = 903, //! < ApolloModule - OBJECT_APOLLO5 = 904, //! < ApolloAntenna - OBJECT_HOME1 = 910, //! < Home + OBJECT_PORTICO = 2, //!< Portico + OBJECT_BASE = 3, //!< SpaceShip + OBJECT_DERRICK = 4, //!< Derrick + OBJECT_FACTORY = 5, //!< BotFactory + OBJECT_STATION = 6, //!< PowerStation + OBJECT_CONVERT = 7, //!< Converter + OBJECT_REPAIR = 8, //!< RepairStation + OBJECT_TOWER = 9, //!< DefenseTower + OBJECT_NEST = 10, //!< AlienNest + OBJECT_RESEARCH = 11, //!< ResearchCenter + OBJECT_RADAR = 12, //!< RadarStation + OBJECT_ENERGY = 13, //!< PowerPlant + OBJECT_LABO = 14, //!< AutoLab + OBJECT_NUCLEAR = 15, //!< NuclearPlant + OBJECT_START = 16, //!< StartArea + OBJECT_END = 17, //!< EndArea + OBJECT_INFO = 18, //!< ExchangePost + OBJECT_PARA = 19, //!< PowerCaptor + OBJECT_TARGET1 = 20, //!< Target1 (gate) + OBJECT_TARGET2 = 21, //!< Target2 (center) + OBJECT_SAFE = 22, //!< Vault + OBJECT_HUSTON = 23, //!< Houston + OBJECT_DESTROYER = 24, //!< Destroyer + OBJECT_STONE = 31, //!< TitaniumOre + OBJECT_URANIUM = 32, //!< UraniumOre + OBJECT_METAL = 33, //!< Titanium + OBJECT_POWER = 34, //!< PowerCell + OBJECT_ATOMIC = 35, //!< NuclearCell + OBJECT_BULLET = 36, //!< OrgaMatter + OBJECT_BBOX = 37, //!< BlackBox + OBJECT_TNT = 38, //!< TNT + OBJECT_MARKPOWER = 50, //!< PowerSpot + OBJECT_MARKSTONE = 51, //!< TitaniumSpot + OBJECT_MARKURANIUM = 52, //!< UraniumSpot + OBJECT_MARKKEYa = 53, //!< KeyASpot + OBJECT_MARKKEYb = 54, //!< KeyBSpot + OBJECT_MARKKEYc = 55, //!< KeyCSpot + OBJECT_MARKKEYd = 56, //!< KeyDSpot + OBJECT_BOMB = 60, //!< Mine + OBJECT_WINFIRE = 61, //!< Firework + OBJECT_SHOW = 62, //!< arrow above object (Visit) + OBJECT_BAG = 63, //!< Bag + OBJECT_PLANT0 = 70, //!< Greenery0 + OBJECT_PLANT1 = 71, //!< Greenery1 + OBJECT_PLANT2 = 72, //!< Greenery2 + OBJECT_PLANT3 = 73, //!< Greenery3 + OBJECT_PLANT4 = 74, //!< Greenery4 + OBJECT_PLANT5 = 75, //!< Greenery5 + OBJECT_PLANT6 = 76, //!< Greenery6 + OBJECT_PLANT7 = 77, //!< Greenery7 + OBJECT_PLANT8 = 78, //!< Greenery8 + OBJECT_PLANT9 = 79, //!< Greenery9 + OBJECT_PLANT10 = 80, //!< Greenery10 + OBJECT_PLANT11 = 81, //!< Greenery11 + OBJECT_PLANT12 = 82, //!< Greenery12 + OBJECT_PLANT13 = 83, //!< Greenery13 + OBJECT_PLANT14 = 84, //!< Greenery14 + OBJECT_PLANT15 = 85, //!< Greenery15 + OBJECT_PLANT16 = 86, //!< Greenery16 + OBJECT_PLANT17 = 87, //!< Greenery17 + OBJECT_PLANT18 = 88, //!< Greenery18 + OBJECT_PLANT19 = 89, //!< Greenery19 + OBJECT_TREE0 = 90, //!< Tree0 + OBJECT_TREE1 = 91, //!< Tree1 + OBJECT_TREE2 = 92, //!< Tree2 + OBJECT_TREE3 = 93, //!< Tree3 + OBJECT_TREE4 = 94, //!< Tree4 + OBJECT_TREE5 = 95, //!< Tree5 + OBJECT_MOBILEwt = 100, //!< PracticeBot + OBJECT_MOBILEtt = 101, //!< track-trainer (unused) + OBJECT_MOBILEft = 102, //!< fly-trainer (unused) + OBJECT_MOBILEit = 103, //!< insect-trainer (unused) + OBJECT_MOBILEwa = 110, //!< WheeledGrabber + OBJECT_MOBILEta = 111, //!< TrackedGrabber + OBJECT_MOBILEfa = 112, //!< WingedGrabber + OBJECT_MOBILEia = 113, //!< LeggedGrabber + OBJECT_MOBILEwc = 120, //!< WheeledShooter + OBJECT_MOBILEtc = 121, //!< TrackedShooter + OBJECT_MOBILEfc = 122, //!< WingedShooter + OBJECT_MOBILEic = 123, //!< LeggedShooter + OBJECT_MOBILEwi = 130, //!< WheeledOrgaShooter + OBJECT_MOBILEti = 131, //!< TrackedOrgaShooter + OBJECT_MOBILEfi = 132, //!< WingedOrgaShooter + OBJECT_MOBILEii = 133, //!< LeggedOrgaShooter + OBJECT_MOBILEws = 140, //!< WheeledSniffer + OBJECT_MOBILEts = 141, //!< TrackedSniffer + OBJECT_MOBILEfs = 142, //!< WingedSniffer + OBJECT_MOBILEis = 143, //!< LeggedSniffer + OBJECT_MOBILErt = 200, //!< Thumper + OBJECT_MOBILErc = 201, //!< PhazerShooter + OBJECT_MOBILErr = 202, //!< Recycler + OBJECT_MOBILErs = 203, //!< Shielder + OBJECT_MOBILEsa = 210, //!< Subber + OBJECT_MOBILEtg = 211, //!< TargetBot + OBJECT_MOBILEdr = 212, //!< Scribbler + OBJECT_CONTROLLER = 213, //!< MissionController + OBJECT_WAYPOINT = 250, //!< WayPoint + OBJECT_FLAGb = 260, //!< BlueFlag + OBJECT_FLAGr = 261, //!< RedFlag + OBJECT_FLAGg = 262, //!< GreenFlag + OBJECT_FLAGy = 263, //!< YellowFlag + OBJECT_FLAGv = 264, //!< VioletFlag + OBJECT_KEYa = 270, //!< KeyA + OBJECT_KEYb = 271, //!< KeyB + OBJECT_KEYc = 272, //!< KeyC + OBJECT_KEYd = 273, //!< KeyD + OBJECT_HUMAN = 300, //!< Me + OBJECT_TOTO = 301, //!< Robby (toto) + OBJECT_TECH = 302, //!< Tech + OBJECT_BARRIER0 = 400, //!< Barrier0 + OBJECT_BARRIER1 = 401, //!< Barrier1 + OBJECT_BARRIER2 = 402, //!< Barrier2 + OBJECT_BARRIER3 = 403, //!< Barrier3 + OBJECT_MOTHER = 500, //!< AlienQueen + OBJECT_EGG = 501, //!< AlienEgg + OBJECT_ANT = 502, //!< AlienAnt + OBJECT_SPIDER = 503, //!< AlienSpider + OBJECT_BEE = 504, //!< AlienWasp + OBJECT_WORM = 505, //!< AlienWorm + OBJECT_RUINmobilew1 = 600, //!< WreckBotw1 + OBJECT_RUINmobilew2 = 601, //!< WreckBotw2 + OBJECT_RUINmobilet1 = 602, //!< WreckBott1 + OBJECT_RUINmobilet2 = 603, //!< WreckBott2 + OBJECT_RUINmobiler1 = 604, //!< WreckBotr1 + OBJECT_RUINmobiler2 = 605, //!< WreckBotr2 + OBJECT_RUINfactory = 606, //!< RuinBotFactory + OBJECT_RUINdoor = 607, //!< RuinDoor + OBJECT_RUINsupport = 608, //!< RuinSupport + OBJECT_RUINradar = 609, //!< RuinRadar + OBJECT_RUINconvert = 610, //!< RuinConvert + OBJECT_RUINbase = 611, //!< RuinBaseCamp + OBJECT_RUINhead = 612, //!< RuinHeadCamp + OBJECT_TEEN0 = 620, //!< Teen0 + OBJECT_TEEN1 = 621, //!< Teen1 + OBJECT_TEEN2 = 622, //!< Teen2 + OBJECT_TEEN3 = 623, //!< Teen3 + OBJECT_TEEN4 = 624, //!< Teen4 + OBJECT_TEEN5 = 625, //!< Teen5 + OBJECT_TEEN6 = 626, //!< Teen6 + OBJECT_TEEN7 = 627, //!< Teen7 + OBJECT_TEEN8 = 628, //!< Teen8 + OBJECT_TEEN9 = 629, //!< Teen9 + OBJECT_TEEN10 = 630, //!< Teen10 + OBJECT_TEEN11 = 631, //!< Teen11 + OBJECT_TEEN12 = 632, //!< Teen12 + OBJECT_TEEN13 = 633, //!< Teen13 + OBJECT_TEEN14 = 634, //!< Teen14 + OBJECT_TEEN15 = 635, //!< Teen15 + OBJECT_TEEN16 = 636, //!< Teen16 + OBJECT_TEEN17 = 637, //!< Teen17 + OBJECT_TEEN18 = 638, //!< Teen18 + OBJECT_TEEN19 = 639, //!< Teen19 + OBJECT_TEEN20 = 640, //!< Teen20 + OBJECT_TEEN21 = 641, //!< Teen21 + OBJECT_TEEN22 = 642, //!< Teen22 + OBJECT_TEEN23 = 643, //!< Teen23 + OBJECT_TEEN24 = 644, //!< Teen24 + OBJECT_TEEN25 = 645, //!< Teen25 + OBJECT_TEEN26 = 646, //!< Teen26 + OBJECT_TEEN27 = 647, //!< Teen27 + OBJECT_TEEN28 = 648, //!< Teen28 + OBJECT_TEEN29 = 649, //!< Teen29 + OBJECT_TEEN30 = 650, //!< Teen30 + OBJECT_TEEN31 = 651, //!< Teen31 + OBJECT_TEEN32 = 652, //!< Teen32 + OBJECT_TEEN33 = 653, //!< Teen33 + OBJECT_TEEN34 = 654, //!< Stone (Teen34) + OBJECT_TEEN35 = 655, //!< Teen35 + OBJECT_TEEN36 = 656, //!< Teen36 + OBJECT_TEEN37 = 657, //!< Teen37 + OBJECT_TEEN38 = 658, //!< Teen38 + OBJECT_TEEN39 = 659, //!< Teen39 + OBJECT_TEEN40 = 660, //!< Teen40 + OBJECT_TEEN41 = 661, //!< Teen41 + OBJECT_TEEN42 = 662, //!< Teen42 + OBJECT_TEEN43 = 663, //!< Teen43 + OBJECT_TEEN44 = 664, //!< Teen44 + OBJECT_QUARTZ0 = 700, //!< Quartz0 + OBJECT_QUARTZ1 = 701, //!< Quartz1 + OBJECT_QUARTZ2 = 702, //!< Quartz2 + OBJECT_QUARTZ3 = 703, //!< Quartz3 + OBJECT_ROOT0 = 710, //!< MegaStalk0 + OBJECT_ROOT1 = 711, //!< MegaStalk1 + OBJECT_ROOT2 = 712, //!< MegaStalk2 + OBJECT_ROOT3 = 713, //!< MegaStalk3 + OBJECT_ROOT4 = 714, //!< MegaStalk4 + OBJECT_ROOT5 = 715, //!< MegaStalk5 + OBJECT_MUSHROOM1 = 731, //!< Mushroom1 + OBJECT_MUSHROOM2 = 732, //!< Mushroom2 + OBJECT_APOLLO1 = 900, //!< ApolloLEM + OBJECT_APOLLO2 = 901, //!< ApolloJeep + OBJECT_APOLLO3 = 902, //!< ApolloFlag + OBJECT_APOLLO4 = 903, //!< ApolloModule + OBJECT_APOLLO5 = 904, //!< ApolloAntenna + OBJECT_HOME1 = 910, //!< Home - OBJECT_MAX = 1000 //! < number of values + OBJECT_MAX = 1000 //!< number of values }; struct ObjectTypeHash diff --git a/src/ui/mainshort.cpp b/src/ui/mainshort.cpp index 0ec5f8a5..d9fffa26 100644 --- a/src/ui/mainshort.cpp +++ b/src/ui/mainshort.cpp @@ -280,9 +280,9 @@ void CMainShort::SelectNext() CObject* pPrev = m_main->DeselectAll(); - if(m_shortcuts.size() == 0) + if (m_shortcuts.size() == 0) { - m_main->SelectHuman(); + m_main->SelectObject(m_main->SearchHuman()); return; }