From 2c7deea6a9d3c3ec629213b31e568bc4ff9c8807 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Thu, 1 Oct 2015 19:37:31 +0200 Subject: [PATCH] Removed some unused functions from CRobotMain --- src/level/robotmain.cpp | 42 +++++++------------------------------ src/level/robotmain.h | 15 ++++--------- src/script/script.cpp | 8 +++---- src/ui/object_interface.cpp | 5 ++--- src/ui/object_interface.h | 2 +- 5 files changed, 18 insertions(+), 54 deletions(-) diff --git a/src/level/robotmain.cpp b/src/level/robotmain.cpp index de186d8c..0fd4439c 100644 --- a/src/level/robotmain.cpp +++ b/src/level/robotmain.cpp @@ -2842,12 +2842,8 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) m_engine->SetSecondTexture(""); m_engine->SetForegroundName(""); - sprintf(m_title, "%s %d.%d", GetLevelCategoryDir(m_levelCategory).c_str(), m_levelChap, m_levelRank); - sprintf(m_resume, "%s %d.%d", GetLevelCategoryDir(m_levelCategory).c_str(), m_levelChap, m_levelRank); - std::string scriptNameStr; - GetResource(RES_TEXT, RT_SCRIPT_NEW, scriptNameStr); - strcpy(m_scriptName, scriptNameStr.c_str()); - m_scriptFile[0] = 0; + GetResource(RES_TEXT, RT_SCRIPT_NEW, m_scriptName); + m_scriptFile = ""; m_missionType = MISSION_NORMAL; m_codeBattleInit = false; @@ -2890,25 +2886,25 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) { if (line->GetCommand() == "Title" && !resetObject) { - strcpy(m_title, line->GetParam("text")->AsString().c_str()); + //strcpy(m_title, line->GetParam("text")->AsString().c_str()); continue; } if (line->GetCommand() == "Resume" && !resetObject) { - strcpy(m_resume, line->GetParam("text")->AsString().c_str()); + //strcpy(m_resume, line->GetParam("text")->AsString().c_str()); continue; } if (line->GetCommand() == "ScriptName" && !resetObject) { - strcpy(m_scriptName, line->GetParam("text")->AsString().c_str()); + m_scriptName = line->GetParam("text")->AsString(); continue; } if (line->GetCommand() == "ScriptFile" && !resetObject) { - strcpy(m_scriptFile, line->GetParam("name")->AsString().c_str()); + m_scriptFile = line->GetParam("name")->AsString(); continue; } @@ -5258,22 +5254,12 @@ bool CRobotMain::GetFixScene() } -char* CRobotMain::GetTitle() -{ - return m_title; -} - -char* CRobotMain::GetResume() -{ - return m_resume; -} - -char* CRobotMain::GetScriptName() +const std::string& CRobotMain::GetScriptName() { return m_scriptName; } -char* CRobotMain::GetScriptFile() +const std::string& CRobotMain::GetScriptFile() { return m_scriptFile; } @@ -5516,18 +5502,6 @@ bool CRobotMain::GetFriendAim() } -//! Management of the precision of drawing the ground -void CRobotMain::SetTracePrecision(float factor) -{ - m_engine->SetTracePrecision(factor); -} - -float CRobotMain::GetTracePrecision() -{ - return m_engine->GetTracePrecision(); -} - - //! Starts music with a mission void CRobotMain::StartMusic() { diff --git a/src/level/robotmain.h b/src/level/robotmain.h index a78ca4fa..5baf78d1 100644 --- a/src/level/robotmain.h +++ b/src/level/robotmain.h @@ -186,9 +186,6 @@ public: void SetFriendAim(bool friendAim); bool GetFriendAim(); - void SetTracePrecision(float factor); - float GetTracePrecision(); - void SetSpeed(float speed); float GetSpeed(); @@ -228,10 +225,8 @@ public: float GetGameTime(); - char* GetTitle(); - char* GetResume(); - char* GetScriptName(); - char* GetScriptFile(); + const std::string& GetScriptName(); + const std::string& GetScriptFile(); bool GetTrainerPilot(); bool GetFixScene(); bool GetShowSoluce(); @@ -523,10 +518,8 @@ protected: int m_infoUsed = 0; ActivePause* m_satcomMoviePause = nullptr; - char m_title[100] = {}; - char m_resume[500] = {}; - char m_scriptName[100] = {}; - char m_scriptFile[100] = {}; + std::string m_scriptName = ""; + std::string m_scriptFile = ""; int m_endingWinRank = 0; int m_endingLostRank = 0; bool m_winTerminate = false; diff --git a/src/script/script.cpp b/src/script/script.cpp index 8d01412d..c44746b8 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -848,7 +848,6 @@ void CScript::New(Ui::CEdit* edit, const char* name) char text[100]; char script[500]; char buffer[500]; - char *sf; int cursor1, cursor2, len, i, j; std::string resStr; @@ -883,12 +882,11 @@ void CScript::New(Ui::CEdit* edit, const char* name) edit->ShowSelect(); m_interface->SetFocus(edit); - sf = m_main->GetScriptFile(); - if ( sf[0] != 0 ) // Load an empty program specific? + std::string sf = m_main->GetScriptFile(); + if ( !sf.empty() ) // Load an empty program specific? { - std::string filename = sf; CInputStream stream; - stream.open(filename); + stream.open(sf); if (stream.is_open()) { diff --git a/src/ui/object_interface.cpp b/src/ui/object_interface.cpp index 4a29ac5d..0b045a82 100644 --- a/src/ui/object_interface.cpp +++ b/src/ui/object_interface.cpp @@ -288,8 +288,7 @@ bool CObjectInterface::EventProcess(const Event &event) } SetSelScript(m_selScript); - char text[] = ""; - StartEditScript(newProgram, text); + StartEditScript(newProgram, ""); std::string res; GetResource(RES_TEXT, RT_STUDIO_CLONED, res); @@ -729,7 +728,7 @@ bool CObjectInterface::EventFrame(const Event &event) // Start editing a program. -void CObjectInterface::StartEditScript(Program* program, char* name) +void CObjectInterface::StartEditScript(Program* program, std::string name) { CreateInterface(false); // removes the control buttons diff --git a/src/ui/object_interface.h b/src/ui/object_interface.h index 2e991d76..7d892592 100644 --- a/src/ui/object_interface.h +++ b/src/ui/object_interface.h @@ -64,7 +64,7 @@ public: protected: bool EventFrame(const Event &event); - void StartEditScript(Program* program, char* name); + void StartEditScript(Program* program, std::string name); void StopEditScript(bool bCancel); void GroundFlat();