Some CRobotMain cleanup

* improved documentation
* renamed cheat variables to include the word "cheat" to make it clearer what they do
* removed some useless members
dev-buzzingcars
krzys-h 2016-12-27 23:38:57 +01:00
parent 6a382830a9
commit 46aa6fc907
9 changed files with 499 additions and 478 deletions

View File

@ -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

View File

@ -19,6 +19,10 @@
#pragma once
/**
* \file common/error.h
* \brief Definition of the Error enum
*/
/**
* \enum Error

View File

@ -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<CMotionToto*>(dynamic_cast<CMovableObject*>(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<CControllableObject*>(obj)->GetSelectable() || m_selectInsect))) return false;
(!obj->Implements(ObjectInterfaceType::Controllable) || !(dynamic_cast<CControllableObject*>(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<CControllableObject*>(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<CControllableObject*>(obj)->GetSelectable() || m_selectInsect))
if (obj->Implements(ObjectInterfaceType::Controllable) && (dynamic_cast<CControllableObject*>(obj)->GetSelectable() || m_cheatSelectInsect))
{
if (dynamic_cast<CControllableObject*>(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<char*>(line->GetParam("name")->AsPath("ai").c_str()));
m_newScriptName.push_back(NewScriptName(line->GetParam("type")->AsObjectType(OBJECT_NULL), const_cast<char*>(line->GetParam("name")->AsPath("ai").c_str())));
continue;
}
@ -3950,10 +3898,12 @@ 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;
@ -3997,6 +3947,7 @@ float CRobotMain::SearchNearestObject(Math::Vector center, CObject *exclu)
}
return min;
}
}
//! Calculates a free space
bool CRobotMain::FreeSpace(Math::Vector &center, float minRadius, float maxRadius,
@ -4018,7 +3969,7 @@ bool CRobotMain::FreeSpace(Math::Vector &center, 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 &center, 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 &center, 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 &center, 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 &center, 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<std::string> CRobotMain::GetNewScriptNames(ObjectType type)
{
m_newScriptName.clear();
}
//! Adds a script name
void CRobotMain::AddNewScriptName(ObjectType type, const std::string& name)
std::vector<std::string> names;
for (const auto& newScript : m_newScriptName)
{
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)
if (newScript.type == type ||
newScript.type == OBJECT_NULL )
{
for (unsigned int i = 0; i < m_newScriptName.size(); i++)
{
if (m_newScriptName[i].type == type ||
m_newScriptName[i].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<std::string, MinMax>& 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)

View File

@ -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<CRobotMain>
{
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 &center, float minRadius, float maxRadius, float space, CObject *exclu);
bool FlatFreeSpace(Math::Vector &center, 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<std::string> 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;

View File

@ -664,11 +664,9 @@ bool CAutoFactory::CreateVehicle()
if (vehicle->Implements(ObjectInterfaceType::ProgramStorage))
{
CProgramStorageObject* programStorage = dynamic_cast<CProgramStorageObject*>(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;

View File

@ -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);
}
@ -326,35 +325,38 @@ bool CMotionToto::EventFrame(const Event &event)
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;
}

View File

@ -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;
};

View File

@ -282,7 +282,7 @@ void CMainShort::SelectNext()
if (m_shortcuts.size() == 0)
{
m_main->SelectHuman();
m_main->SelectObject(m_main->SearchHuman());
return;
}