From 2260f6bf4feb62929e32a1bea9cd3f403aa034b1 Mon Sep 17 00:00:00 2001 From: Krzysztof Dermont Date: Fri, 20 Jun 2014 23:41:38 +0200 Subject: Big part of PhysFS support * removed -mod argument * removed -datadir argument * removed -lang argument * removed some dead ui code * added resource manager and file loaders (stream and SDL) * changed interface textures location to match new directory structure * removed CGameData for mod support * added PhysFS support --- src/object/robotmain.cpp | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'src/object/robotmain.cpp') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 2424938..1c75137 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -20,7 +20,6 @@ #include "CBot/CBotDll.h" #include "app/app.h" -#include "app/gamedata.h" #include "common/event.h" #include "common/global.h" @@ -4082,8 +4081,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) if (Cmd(line, "Instructions") && !resetObject) { OpString(line, "name", name); - std::string path = CGameData::GetInstancePointer()->GetFilePath(DIR_HELP, name); - strcpy(m_infoFilename[SATCOM_HUSTON], path.c_str()); + strcpy(m_infoFilename[SATCOM_HUSTON], name); m_immediatSatCom = OpInt(line, "immediat", 0); if (m_version >= 2) m_beginSatCom = m_lockedSatCom = OpInt(line, "lock", 0); @@ -4094,31 +4092,27 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) if (Cmd(line, "Satellite") && !resetObject) { OpString(line, "name", name); - std::string path = CGameData::GetInstancePointer()->GetFilePath(DIR_HELP, name); - strcpy(m_infoFilename[SATCOM_SAT], path.c_str()); + strcpy(m_infoFilename[SATCOM_SAT], name); continue; } if (Cmd(line, "Loading") && !resetObject) { OpString(line, "name", name); - std::string path = CGameData::GetInstancePointer()->GetFilePath(DIR_HELP, name); - strcpy(m_infoFilename[SATCOM_LOADING], path.c_str()); + strcpy(m_infoFilename[SATCOM_LOADING], name); continue; } if (Cmd(line, "HelpFile") && !resetObject) { OpString(line, "name", name); - std::string path = CGameData::GetInstancePointer()->GetFilePath(DIR_HELP, name); - strcpy(m_infoFilename[SATCOM_PROG], path.c_str()); + strcpy(m_infoFilename[SATCOM_PROG], name); continue; } if (Cmd(line, "SoluceFile") && !resetObject) { OpString(line, "name", name); - std::string path = CGameData::GetInstancePointer()->GetFilePath(DIR_HELP, name); - strcpy(m_infoFilename[SATCOM_SOLUCE], path.c_str()); + strcpy(m_infoFilename[SATCOM_SOLUCE], name); continue; } @@ -5308,12 +5302,12 @@ void CRobotMain::ChangeColor() // PARTIPLOUF0 and PARTIDROP : ts = Math::Point(0.500f, 0.500f); ti = Math::Point(0.875f, 0.750f); - m_engine->ChangeTextureColor("effect00.png", m_colorRefWater, m_colorNewWater, colorRef2, colorNew2, 0.20f, -1.0f, ts, ti, 0, m_colorShiftWater, true); + m_engine->ChangeTextureColor("textures/interface/effect00.png", m_colorRefWater, m_colorNewWater, colorRef2, colorNew2, 0.20f, -1.0f, ts, ti, 0, m_colorShiftWater, true); // PARTIFLIC : ts = Math::Point(0.00f, 0.75f); ti = Math::Point(0.25f, 1.00f); - m_engine->ChangeTextureColor("effect02.png", m_colorRefWater, m_colorNewWater, colorRef2, colorNew2, 0.20f, -1.0f, ts, ti, 0, m_colorShiftWater, true); + m_engine->ChangeTextureColor("textures/interface/effect02.png", m_colorRefWater, m_colorNewWater, colorRef2, colorNew2, 0.20f, -1.0f, ts, ti, 0, m_colorShiftWater, true); } //! Updates the number of unnecessary objects -- cgit v1.2.3-1-g7c22 From 3aca1de731fa7517db7d4dc00913542412150898 Mon Sep 17 00:00:00 2001 From: Krzysztof Dermont Date: Sun, 22 Jun 2014 21:30:23 +0200 Subject: More work on levels --- src/object/robotmain.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/object/robotmain.cpp') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 1c75137..87cd5fc 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -29,6 +29,8 @@ #include "common/profile.h" #include "common/restext.h" +#include "common/resources/inputstream.h" + #include "graphics/engine/camera.h" #include "graphics/engine/cloud.h" #include "graphics/engine/engine.h" @@ -4009,8 +4011,11 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) std::string tempLine; m_dialog->BuildSceneName(tempLine, base, rank); strcpy(filename, tempLine.c_str()); - FILE* file = fopen(filename, "r"); - if (file == NULL) return; + + CInputStream stream; + stream.open(filename); + + if (!stream.is_open()) return; int rankObj = 0; int rankGadget = 0; @@ -4023,7 +4028,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) * may speed up loading */ - while (fgets(line, 500, file) != NULL) + while (stream.getline(line, 500)) { lineNum++; for (int i = 0; i < 500; i++) @@ -5062,7 +5067,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) GetLogger()->Error("Syntax error in file '%s' (line %d): Unknown command: %s", filename, lineNum, line); // Don't add \n at the end of log message - it's included in line variable } - fclose(file); + stream.close(); if (read[0] == 0) CompileScript(soluce); // compiles all scripts -- cgit v1.2.3-1-g7c22 From 106ec014b812c6f5eb93ea30c04b3bba333542dd Mon Sep 17 00:00:00 2001 From: krzys-h Date: Thu, 10 Jul 2014 16:25:40 +0200 Subject: Fixed texture and script loading --- src/object/robotmain.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/object/robotmain.cpp') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 87cd5fc..dee52d7 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -4374,7 +4374,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) } OpString(line, "image", name); - m_terrain->LoadRelief(name, OpFloat(line, "factor", 1.0f), OpInt(line, "border", 1)); + m_terrain->LoadRelief(std::string("textures/")+name, OpFloat(line, "factor", 1.0f), OpInt(line, "border", 1)); continue; } @@ -4405,7 +4405,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) } OpString(line, "image", name); - m_terrain->LoadResources(name); + m_terrain->LoadResources(std::string("textures/")+name); continue; } @@ -5307,12 +5307,12 @@ void CRobotMain::ChangeColor() // PARTIPLOUF0 and PARTIDROP : ts = Math::Point(0.500f, 0.500f); ti = Math::Point(0.875f, 0.750f); - m_engine->ChangeTextureColor("textures/interface/effect00.png", m_colorRefWater, m_colorNewWater, colorRef2, colorNew2, 0.20f, -1.0f, ts, ti, 0, m_colorShiftWater, true); + m_engine->ChangeTextureColor("interface/effect00.png", m_colorRefWater, m_colorNewWater, colorRef2, colorNew2, 0.20f, -1.0f, ts, ti, 0, m_colorShiftWater, true); // PARTIFLIC : ts = Math::Point(0.00f, 0.75f); ti = Math::Point(0.25f, 1.00f); - m_engine->ChangeTextureColor("textures/interface/effect02.png", m_colorRefWater, m_colorNewWater, colorRef2, colorNew2, 0.20f, -1.0f, ts, ti, 0, m_colorShiftWater, true); + m_engine->ChangeTextureColor("interface/effect02.png", m_colorRefWater, m_colorNewWater, colorRef2, colorNew2, 0.20f, -1.0f, ts, ti, 0, m_colorShiftWater, true); } //! Updates the number of unnecessary objects @@ -5746,11 +5746,12 @@ void CRobotMain::CompileScript(bool soluce) { if (brain->GetCompile(j)) continue; - char* name = brain->GetScriptName(j); + std::string name = brain->GetScriptName(j); + name = "ai/"+name; if (name[0] != 0) { - if(! brain->ReadProgram(j, name)) { - CLogger::GetInstancePointer()->Error("Unable to read script from file \"%s\"\n", name); + if(! brain->ReadProgram(j, const_cast(name.c_str()))) { + CLogger::GetInstancePointer()->Error("Unable to read script from file \"%s\"\n", name.c_str()); } if (!brain->GetCompile(j)) nbError++; } -- cgit v1.2.3-1-g7c22 From c22e55b99a38d405fb79184106261229bd2d1855 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Thu, 10 Jul 2014 16:52:29 +0200 Subject: Removed some unused code related to Quit button The button itself has been removed a long time ago --- src/object/robotmain.cpp | 40 ---------------------------------------- 1 file changed, 40 deletions(-) (limited to 'src/object/robotmain.cpp') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 76c234d..83b9fc9 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -859,8 +859,6 @@ CRobotMain::CRobotMain(CApplication* app, bool loadProfile) CBotProgram::DefineNum("ResearchSubber", RESEARCH_SUBM); CBotProgram::DefineNum("ResearchSniffer", RESEARCH_SNIFFER); -//? CBotProgram:: - CBotProgram::DefineNum("PolskiPortalColobota", 1337); CBotClass* bc; @@ -1215,14 +1213,6 @@ void CRobotMain::ChangePhase(Phase phase) m_app->ResetTimeAfterLoading(); - /*Math::Point ddim; - - pos.x = 620.0f/640.0f; - pos.y = 460.0f/480.0f; - ddim.x = 20.0f/640.0f; - ddim.y = 20.0f/480.0f; - m_interface->CreateButton(pos, ddim, 11, EVENT_BUTTON_QUIT);*/ - if (m_immediatSatCom && !loading && m_infoFilename[SATCOM_HUSTON][0] != 0) StartDisplayInfo(SATCOM_HUSTON, false); // shows the instructions @@ -1638,18 +1628,6 @@ bool CRobotMain::ProcessEvent(Event &event) m_cameraZoom = 0.0f; break; - case EVENT_BUTTON_QUIT: - if (m_movie->IsExist()) - StartDisplayInfo(SATCOM_HUSTON, false); - else if (m_winDelay > 0.0f) - ChangePhase(PHASE_WIN); - else if (m_lostDelay > 0.0f) - - ChangePhase(PHASE_LOST); - else - m_dialog->StartAbort(); // do you want to leave? - break; - case EVENT_OBJECT_LIMIT: StartShowLimit(); break; @@ -2189,12 +2167,6 @@ void CRobotMain::StartDisplayInfo(const char *filename, int index) m_sound->MuteAll(true); } - Ui::CButton* pb = static_cast(m_interface->SearchControl(EVENT_BUTTON_QUIT)); - if (pb != nullptr) - { - pb->ClearState(Ui::STATE_VISIBLE); - } - bool soluce = m_dialog->GetSceneSoluce(); m_displayInfo = new Ui::CDisplayInfo(); @@ -2223,10 +2195,6 @@ void CRobotMain::StopDisplayInfo() if (!m_editLock) { - Ui::CButton* pb = static_cast(m_interface->SearchControl(EVENT_BUTTON_QUIT)); - if (pb != nullptr) - pb->SetState(Ui::STATE_VISIBLE); - SelectObject(m_infoObject, false); // gives the command buttons m_displayText->HideText(false); @@ -2264,20 +2232,12 @@ void CRobotMain::StartSuspend() m_infoObject = DeselectAll(); // removes the control buttons m_displayText->HideText(true); - Ui::CButton* pb = static_cast(m_interface->SearchControl(EVENT_BUTTON_QUIT)); - if (pb != nullptr) - pb->ClearState(Ui::STATE_VISIBLE); - m_suspend = true; } //! End of dialogue during the game void CRobotMain::StopSuspend() { - Ui::CButton* pb = static_cast(m_interface->SearchControl(EVENT_BUTTON_QUIT)); - if (pb != nullptr) - pb->SetState(Ui::STATE_VISIBLE); - SelectObject(m_infoObject, false); // gives the command buttons m_map->ShowMap(m_mapShow); m_displayText->HideText(false); -- cgit v1.2.3-1-g7c22 From 02ba358a892b9977250ea345c42f8226f89ba250 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Fri, 11 Jul 2014 16:40:07 +0200 Subject: Help file loading --- src/object/robotmain.cpp | 54 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 44 insertions(+), 10 deletions(-) (limited to 'src/object/robotmain.cpp') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 8108129..9860943 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -3843,11 +3843,6 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) const char* stack = m_dialog->GetStackRead().c_str(); m_dialog->SetUserDir(base, rank); - /* - * TODO: original code relying on UserDir() was removed. - * A new way of providing custom data file paths will need to be devised. - */ - m_fixScene = fixScene; g_id = 0; @@ -4020,7 +4015,9 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) if (Cmd(line, "Instructions") && !resetObject) { OpString(line, "name", name); - strcpy(m_infoFilename[SATCOM_HUSTON], name); + std::string path = name; + InjectLevelDir(path, "help/%lng%"); + strcpy(m_infoFilename[SATCOM_HUSTON], path.c_str()); m_immediatSatCom = OpInt(line, "immediat", 0); if (m_version >= 2) m_beginSatCom = m_lockedSatCom = OpInt(line, "lock", 0); @@ -4031,27 +4028,35 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) if (Cmd(line, "Satellite") && !resetObject) { OpString(line, "name", name); - strcpy(m_infoFilename[SATCOM_SAT], name); + std::string path = name; + InjectLevelDir(path, "help/%lng%"); + strcpy(m_infoFilename[SATCOM_SAT], path.c_str()); continue; } if (Cmd(line, "Loading") && !resetObject) { OpString(line, "name", name); - strcpy(m_infoFilename[SATCOM_LOADING], name); + std::string path = name; + InjectLevelDir(path, "help/%lng%"); + strcpy(m_infoFilename[SATCOM_LOADING], path.c_str()); continue; } if (Cmd(line, "HelpFile") && !resetObject) { OpString(line, "name", name); - strcpy(m_infoFilename[SATCOM_PROG], name); + std::string path = name; + InjectLevelDir(path, "help/%lng%"); + strcpy(m_infoFilename[SATCOM_PROG], path.c_str()); continue; } if (Cmd(line, "SoluceFile") && !resetObject) { OpString(line, "name", name); - strcpy(m_infoFilename[SATCOM_SOLUCE], name); + std::string path = name; + InjectLevelDir(path, "help/%lng%"); + strcpy(m_infoFilename[SATCOM_SOLUCE], path.c_str()); continue; } @@ -7001,6 +7006,21 @@ float CRobotMain::GetPersoAngle() return m_dialog->GetPersoAngle(); } +char* CRobotMain::GetSceneName() +{ + return m_dialog->GetSceneName(); +} + +int CRobotMain::GetSceneRank() +{ + return m_dialog->GetSceneRank(); +} + +void CRobotMain::BuildSceneName(std::string &filename, char *base, int rank, bool sceneFile) +{ + m_dialog->BuildSceneName(filename, base, rank, sceneFile); +} + //! Changes on the pause mode void CRobotMain::ChangePause(PauseType pause) @@ -7236,3 +7256,17 @@ void CRobotMain::DisplayError(Error err, Math::Vector goal, float height, float { m_displayText->DisplayError(err, goal, height, dist, time); } + +void CRobotMain::InjectLevelDir(std::string& path, const std::string defaultDir) +{ + std::string oldPath = path; + std::string lvlDir; + CRobotMain::GetInstancePointer()->BuildSceneName(lvlDir, CRobotMain::GetInstancePointer()->GetSceneName(), CRobotMain::GetInstancePointer()->GetSceneRank(), false); + boost::replace_all(path, "%lvl%", lvlDir); + if(path == oldPath) + { + path = defaultDir + "/" + path; + } + std::string langStr(1, CApplication::GetInstancePointer()->GetLanguageChar()); + boost::replace_all(path, "%lng%", langStr); +} -- cgit v1.2.3-1-g7c22 From 7131abd385bb370328e7c59e8a6b70d160b2effc Mon Sep 17 00:00:00 2001 From: krzys-h Date: Thu, 24 Jul 2014 22:17:49 +0200 Subject: Fixed SatCom image loading Now LoadTexture/SetTexture functions require full path with "textures/" directory --- src/object/robotmain.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'src/object/robotmain.cpp') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 9860943..407a1ec 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -5153,7 +5153,7 @@ void CRobotMain::ChangeColor() exclu[3] = Math::Point(256.0f/256.0f, 256.0f/256.0f); // SatCom screen exclu[4] = Math::Point(0.0f, 0.0f); exclu[5] = Math::Point(0.0f, 0.0f); // terminator - m_engine->ChangeTextureColor("human.png", colorRef1, colorNew1, colorRef2, colorNew2, 0.30f, 0.01f, ts, ti, exclu); + m_engine->ChangeTextureColor("textures/human.png", colorRef1, colorNew1, colorRef2, colorNew2, 0.30f, 0.01f, ts, ti, exclu); float tolerance; @@ -5195,7 +5195,7 @@ void CRobotMain::ChangeColor() colorNew2.b = 0.0f; char name[100]; - sprintf(name, "face%.2d.png", face+1); + sprintf(name, "textures/face%.2d.png", face+1); exclu[0] = Math::Point(105.0f/256.0f, 47.0f/166.0f); exclu[1] = Math::Point(153.0f/256.0f, 79.0f/166.0f); // blue canister exclu[2] = Math::Point(0.0f, 0.0f); @@ -5209,19 +5209,19 @@ void CRobotMain::ChangeColor() colorNew2.g = 0.0f; colorNew2.b = 0.0f; - m_engine->ChangeTextureColor("base1.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true); - m_engine->ChangeTextureColor("convert.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true); - m_engine->ChangeTextureColor("derrick.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true); - m_engine->ChangeTextureColor("factory.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true); - m_engine->ChangeTextureColor("lemt.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true); - m_engine->ChangeTextureColor("roller.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true); - m_engine->ChangeTextureColor("search.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true); + m_engine->ChangeTextureColor("textures/base1.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true); + m_engine->ChangeTextureColor("textures/convert.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true); + m_engine->ChangeTextureColor("textures/derrick.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true); + m_engine->ChangeTextureColor("textures/factory.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true); + m_engine->ChangeTextureColor("textures/lemt.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true); + m_engine->ChangeTextureColor("textures/roller.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true); + m_engine->ChangeTextureColor("textures/search.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true); exclu[0] = Math::Point( 0.0f/256.0f, 160.0f/256.0f); exclu[1] = Math::Point(256.0f/256.0f, 256.0f/256.0f); // pencils exclu[2] = Math::Point(0.0f, 0.0f); exclu[3] = Math::Point(0.0f, 0.0f); // terminator - m_engine->ChangeTextureColor("drawer.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, exclu, 0, true); + m_engine->ChangeTextureColor("textures/drawer.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, exclu, 0, true); exclu[0] = Math::Point(237.0f/256.0f, 176.0f/256.0f); exclu[1] = Math::Point(256.0f/256.0f, 220.0f/256.0f); // blue canister @@ -5229,26 +5229,26 @@ void CRobotMain::ChangeColor() exclu[3] = Math::Point(130.0f/256.0f, 214.0f/256.0f); // safe location exclu[4] = Math::Point(0.0f, 0.0f); exclu[5] = Math::Point(0.0f, 0.0f); // terminator - m_engine->ChangeTextureColor("subm.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, exclu, 0, true); + m_engine->ChangeTextureColor("textures/subm.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, exclu, 0, true); exclu[0] = Math::Point(128.0f/256.0f, 160.0f/256.0f); exclu[1] = Math::Point(256.0f/256.0f, 256.0f/256.0f); // SatCom exclu[2] = Math::Point(0.0f, 0.0f); exclu[3] = Math::Point(0.0f, 0.0f); // terminator - m_engine->ChangeTextureColor("ant.png", m_colorRefAlien, m_colorNewAlien, colorRef2, colorNew2, 0.50f, -1.0f, ts, ti, exclu); - m_engine->ChangeTextureColor("mother.png", m_colorRefAlien, m_colorNewAlien, colorRef2, colorNew2, 0.50f, -1.0f, ts, ti); + m_engine->ChangeTextureColor("textures/ant.png", m_colorRefAlien, m_colorNewAlien, colorRef2, colorNew2, 0.50f, -1.0f, ts, ti, exclu); + m_engine->ChangeTextureColor("textures/mother.png", m_colorRefAlien, m_colorNewAlien, colorRef2, colorNew2, 0.50f, -1.0f, ts, ti); - m_engine->ChangeTextureColor("plant.png", m_colorRefGreen, m_colorNewGreen, colorRef2, colorNew2, 0.50f, -1.0f, ts, ti); + m_engine->ChangeTextureColor("textures/plant.png", m_colorRefGreen, m_colorNewGreen, colorRef2, colorNew2, 0.50f, -1.0f, ts, ti); // PARTIPLOUF0 and PARTIDROP : ts = Math::Point(0.500f, 0.500f); ti = Math::Point(0.875f, 0.750f); - m_engine->ChangeTextureColor("interface/effect00.png", m_colorRefWater, m_colorNewWater, colorRef2, colorNew2, 0.20f, -1.0f, ts, ti, 0, m_colorShiftWater, true); + m_engine->ChangeTextureColor("textures/interface/effect00.png", m_colorRefWater, m_colorNewWater, colorRef2, colorNew2, 0.20f, -1.0f, ts, ti, 0, m_colorShiftWater, true); // PARTIFLIC : ts = Math::Point(0.00f, 0.75f); ti = Math::Point(0.25f, 1.00f); - m_engine->ChangeTextureColor("interface/effect02.png", m_colorRefWater, m_colorNewWater, colorRef2, colorNew2, 0.20f, -1.0f, ts, ti, 0, m_colorShiftWater, true); + m_engine->ChangeTextureColor("textures/interface/effect02.png", m_colorRefWater, m_colorNewWater, colorRef2, colorNew2, 0.20f, -1.0f, ts, ti, 0, m_colorShiftWater, true); } //! Updates the number of unnecessary objects -- cgit v1.2.3-1-g7c22 From a56e69883fe74618db71b18b1748f15c06eafc29 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Wed, 6 Aug 2014 16:57:59 +0200 Subject: Removed some unused code --- src/object/robotmain.cpp | 193 ----------------------------------------------- 1 file changed, 193 deletions(-) (limited to 'src/object/robotmain.cpp') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 83b9fc9..fc15b26 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -3603,199 +3603,6 @@ char* SkipNum(char *p) return p; } -//! Conversion of units -void CRobotMain::Convert() -{ - char* base = m_dialog->GetSceneName(); - int rank = m_dialog->GetSceneRank(); - - //TODO change line to string - char line[500]; - std::string tempLine; - - m_dialog->BuildSceneName(tempLine, base, rank); - strcpy(line, tempLine.c_str()); - FILE* file = fopen(line, "r"); - if (file == NULL) return; - - strcpy(line+strlen(line)-4, ".new"); - FILE* fileNew = fopen(line, "w"); - if (fileNew == NULL) return; - - char lineNew[500]; - char s[200]; - - while (fgets(line, 500, file) != NULL) - { - strcpy(lineNew, line); - - if (Cmd(line, "DeepView")) - { - char* p = strstr(line, "air="); - if (p != 0) - { - float value = OpFloat(line, "air", 500.0f); - value /= g_unit; - p[0] = 0; - p = SkipNum(p+4); - strcpy(lineNew, line); - strcat(lineNew, "air="); - sprintf(s, "%.2f", value); - strcat(lineNew, s); - strcat(lineNew, " "); - strcat(lineNew, p); - } - strcpy(line, lineNew); - - p = strstr(line, "water="); - if (p != 0) - { - float value = OpFloat(line, "water", 100.0f); - value /= g_unit; - p[0] = 0; - p = SkipNum(p+6); - strcpy(lineNew, line); - strcat(lineNew, "water="); - sprintf(s, "%.2f", value); - strcat(lineNew, s); - strcat(lineNew, " "); - strcat(lineNew, p); - } - strcpy(line, lineNew); - } - - if (Cmd(line, "TerrainGenerate")) - { - char* p = strstr(line, "vision="); - if (p != 0) - { - float value = OpFloat(line, "vision", 500.0f); - value /= g_unit; - p[0] = 0; - p = SkipNum(p+7); - strcpy(lineNew, line); - strcat(lineNew, "vision="); - sprintf(s, "%.2f", value); - strcat(lineNew, s); - strcat(lineNew, " "); - strcat(lineNew, p); - } - } - - if (Cmd(line, "CreateObject") || - Cmd(line, "CreateSpot")) - { - char* p = strstr(line, "pos="); - if (p != 0) - { - Math::Vector pos = OpPos(line, "pos"); - pos.x /= g_unit; - pos.y /= g_unit; - pos.z /= g_unit; - p[0] = 0; - p = SkipNum(p+4); - p = SkipNum(p+1); - strcpy(lineNew, line); - strcat(lineNew, "pos="); - sprintf(s, "%.2f", pos.x); - strcat(lineNew, s); - strcat(lineNew, ";"); - sprintf(s, "%.2f", pos.z); - strcat(lineNew, s); - strcat(lineNew, " "); - strcat(lineNew, p); - } - } - - if (Cmd(line, "EndMissionTake") || Cmd(line, "AudioChange")) - { - char* p = strstr(line, "pos="); - if (p != 0) - { - Math::Vector pos = OpPos(line, "pos"); - pos.x /= g_unit; - pos.y /= g_unit; - pos.z /= g_unit; - p[0] = 0; - p = SkipNum(p+4); - p = SkipNum(p+1); - strcpy(lineNew, line); - strcat(lineNew, "pos="); - sprintf(s, "%.2f", pos.x); - strcat(lineNew, s); - strcat(lineNew, ";"); - sprintf(s, "%.2f", pos.z); - strcat(lineNew, s); - strcat(lineNew, " "); - strcat(lineNew, p); - } - strcpy(line, lineNew); - - p = strstr(line, "dist="); - if (p != 0) - { - float value = OpFloat(line, "dist", 32.0f); - value /= g_unit; - p[0] = 0; - p = SkipNum(p+5); - strcpy(lineNew, line); - strcat(lineNew, "dist="); - sprintf(s, "%.2f", value); - strcat(lineNew, s); - strcat(lineNew, " "); - strcat(lineNew, p); - } - strcpy(line, lineNew); - } - - if (Cmd(line, "Camera")) - { - char* p = strstr(line, "pos="); - if (p != 0) - { - Math::Vector pos = OpPos(line, "pos"); - pos.x /= g_unit; - pos.y /= g_unit; - pos.z /= g_unit; - p[0] = 0; - p = SkipNum(p+4); - p = SkipNum(p+1); - strcpy(lineNew, line); - strcat(lineNew, "pos="); - sprintf(s, "%.2f", pos.x); - strcat(lineNew, s); - strcat(lineNew, ";"); - sprintf(s, "%.2f", pos.z); - strcat(lineNew, s); - strcat(lineNew, " "); - strcat(lineNew, p); - } - strcpy(line, lineNew); - - p = strstr(line, "h="); - if (p != 0) - { - float value = OpFloat(line, "h", 32.0f); - value /= g_unit; - p[0] = 0; - p = SkipNum(p+2); - strcpy(lineNew, line); - strcat(lineNew, "h="); - sprintf(s, "%.2f", value); - strcat(lineNew, s); - strcat(lineNew, " "); - strcat(lineNew, p); - } - strcpy(line, lineNew); - } - - fputs(lineNew, fileNew); - } - - fclose(fileNew); - fclose(file); -} - //! Load the scene for the character void CRobotMain::ScenePerso() { -- cgit v1.2.3-1-g7c22 From e4d52d9afbf6aeb090b225cc4852936dd3be5017 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Tue, 12 Aug 2014 21:24:33 +0200 Subject: CProfile refactoring --- src/object/robotmain.cpp | 64 ++++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 32 deletions(-) (limited to 'src/object/robotmain.cpp') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index fc15b26..d33ea27 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -721,11 +721,11 @@ CRobotMain::CRobotMain(CApplication* app, bool loadProfile) if (loadProfile) { - if (GetProfile().GetLocalProfileFloat("Edit", "FontSize", fValue)) m_fontSize = fValue; - if (GetProfile().GetLocalProfileFloat("Edit", "WindowPosX", fValue)) m_windowPos.x = fValue; - if (GetProfile().GetLocalProfileFloat("Edit", "WindowPosY", fValue)) m_windowPos.y = fValue; - if (GetProfile().GetLocalProfileFloat("Edit", "WindowDimX", fValue)) m_windowDim.x = fValue; - if (GetProfile().GetLocalProfileFloat("Edit", "WindowDimY", fValue)) m_windowDim.y = fValue; + if (GetProfile().GetFloatProperty("Edit", "FontSize", fValue)) m_fontSize = fValue; + if (GetProfile().GetFloatProperty("Edit", "WindowPosX", fValue)) m_windowPos.x = fValue; + if (GetProfile().GetFloatProperty("Edit", "WindowPosY", fValue)) m_windowPos.y = fValue; + if (GetProfile().GetFloatProperty("Edit", "WindowDimX", fValue)) m_windowDim.x = fValue; + if (GetProfile().GetFloatProperty("Edit", "WindowDimY", fValue)) m_windowDim.y = fValue; } m_IOPublic = false; @@ -735,11 +735,11 @@ CRobotMain::CRobotMain(CApplication* app, bool loadProfile) if (loadProfile) { - if (GetProfile().GetLocalProfileInt ("Edit", "IOPublic", iValue)) m_IOPublic = iValue; - if (GetProfile().GetLocalProfileFloat("Edit", "IOPosX", fValue)) m_IOPos.x = fValue; - if (GetProfile().GetLocalProfileFloat("Edit", "IOPosY", fValue)) m_IOPos.y = fValue; - if (GetProfile().GetLocalProfileFloat("Edit", "IODimX", fValue)) m_IODim.x = fValue; - if (GetProfile().GetLocalProfileFloat("Edit", "IODimY", fValue)) m_IODim.y = fValue; + if (GetProfile().GetIntProperty ("Edit", "IOPublic", iValue)) m_IOPublic = iValue; + if (GetProfile().GetFloatProperty("Edit", "IOPosX", fValue)) m_IOPos.x = fValue; + if (GetProfile().GetFloatProperty("Edit", "IOPosY", fValue)) m_IOPos.y = fValue; + if (GetProfile().GetFloatProperty("Edit", "IODimX", fValue)) m_IODim.x = fValue; + if (GetProfile().GetFloatProperty("Edit", "IODimY", fValue)) m_IODim.y = fValue; } m_short->FlushShortcuts(); @@ -757,7 +757,7 @@ CRobotMain::CRobotMain(CApplication* app, bool loadProfile) g_unit = UNIT; m_gamerName = ""; - if (loadProfile) GetProfile().GetLocalProfileString("Gamer", "LastName", m_gamerName); + if (loadProfile) GetProfile().GetStringProperty("Gamer", "LastName", m_gamerName); SetGlobalGamerName(m_gamerName); ReadFreeParam(); if (loadProfile) m_dialog->SetupRecall(); @@ -966,18 +966,18 @@ void CRobotMain::CreateIni() { m_dialog->SetupMemorize(); - GetProfile().SetLocalProfileFloat("Edit", "FontSize", m_fontSize); - GetProfile().SetLocalProfileFloat("Edit", "WindowPosX", m_windowPos.x); - GetProfile().SetLocalProfileFloat("Edit", "WindowPosY", m_windowPos.y); - GetProfile().SetLocalProfileFloat("Edit", "WindowDimX", m_windowDim.x); - GetProfile().SetLocalProfileFloat("Edit", "WindowDimY", m_windowDim.y); - GetProfile().SetLocalProfileInt("Edit", "IOPublic", m_IOPublic); - GetProfile().SetLocalProfileFloat("Edit", "IOPosX", m_IOPos.x); - GetProfile().SetLocalProfileFloat("Edit", "IOPosY", m_IOPos.y); - GetProfile().SetLocalProfileFloat("Edit", "IODimX", m_IODim.x); - GetProfile().SetLocalProfileFloat("Edit", "IODimY", m_IODim.y); + GetProfile().SetFloatProperty("Edit", "FontSize", m_fontSize); + GetProfile().SetFloatProperty("Edit", "WindowPosX", m_windowPos.x); + GetProfile().SetFloatProperty("Edit", "WindowPosY", m_windowPos.y); + GetProfile().SetFloatProperty("Edit", "WindowDimX", m_windowDim.x); + GetProfile().SetFloatProperty("Edit", "WindowDimY", m_windowDim.y); + GetProfile().SetIntProperty("Edit", "IOPublic", m_IOPublic); + GetProfile().SetFloatProperty("Edit", "IOPosX", m_IOPos.x); + GetProfile().SetFloatProperty("Edit", "IOPosY", m_IOPos.y); + GetProfile().SetFloatProperty("Edit", "IODimX", m_IODim.x); + GetProfile().SetFloatProperty("Edit", "IODimY", m_IODim.y); - GetProfile().SaveCurrentDirectory(); + GetProfile().Save(); } void CRobotMain::SetDefaultInputBindings() @@ -2258,7 +2258,7 @@ float CRobotMain::GetGameTime() void CRobotMain::SetFontSize(float size) { m_fontSize = size; - GetProfile().SetLocalProfileFloat("Edit", "FontSize", m_fontSize); + GetProfile().SetFloatProperty("Edit", "FontSize", m_fontSize); } float CRobotMain::GetFontSize() @@ -2270,8 +2270,8 @@ float CRobotMain::GetFontSize() void CRobotMain::SetWindowPos(Math::Point pos) { m_windowPos = pos; - GetProfile().SetLocalProfileFloat("Edit", "WindowPosX", m_windowPos.x); - GetProfile().SetLocalProfileFloat("Edit", "WindowPosY", m_windowPos.y); + GetProfile().SetFloatProperty("Edit", "WindowPosX", m_windowPos.x); + GetProfile().SetFloatProperty("Edit", "WindowPosY", m_windowPos.y); } Math::Point CRobotMain::GetWindowPos() @@ -2282,8 +2282,8 @@ Math::Point CRobotMain::GetWindowPos() void CRobotMain::SetWindowDim(Math::Point dim) { m_windowDim = dim; - GetProfile().SetLocalProfileFloat("Edit", "WindowDimX", m_windowDim.x); - GetProfile().SetLocalProfileFloat("Edit", "WindowDimY", m_windowDim.y); + GetProfile().SetFloatProperty("Edit", "WindowDimX", m_windowDim.x); + GetProfile().SetFloatProperty("Edit", "WindowDimY", m_windowDim.y); } Math::Point CRobotMain::GetWindowDim() @@ -2296,7 +2296,7 @@ Math::Point CRobotMain::GetWindowDim() void CRobotMain::SetIOPublic(bool mode) { m_IOPublic = mode; - GetProfile().SetLocalProfileInt("Edit", "IOPublic", m_IOPublic); + GetProfile().SetIntProperty("Edit", "IOPublic", m_IOPublic); } bool CRobotMain::GetIOPublic() @@ -2307,8 +2307,8 @@ bool CRobotMain::GetIOPublic() void CRobotMain::SetIOPos(Math::Point pos) { m_IOPos = pos; - GetProfile().SetLocalProfileFloat("Edit", "IOPosX", m_IOPos.x); - GetProfile().SetLocalProfileFloat("Edit", "IOPosY", m_IOPos.y); + GetProfile().SetFloatProperty("Edit", "IOPosX", m_IOPos.x); + GetProfile().SetFloatProperty("Edit", "IOPosY", m_IOPos.y); } Math::Point CRobotMain::GetIOPos() @@ -2319,8 +2319,8 @@ Math::Point CRobotMain::GetIOPos() void CRobotMain::SetIODim(Math::Point dim) { m_IODim = dim; - GetProfile().SetLocalProfileFloat("Edit", "IODimX", m_IODim.x); - GetProfile().SetLocalProfileFloat("Edit", "IODimY", m_IODim.y); + GetProfile().SetFloatProperty("Edit", "IODimX", m_IODim.x); + GetProfile().SetFloatProperty("Edit", "IODimY", m_IODim.y); } Math::Point CRobotMain::GetIODim() -- cgit v1.2.3-1-g7c22 From 740036e430d98afe487313bb5be8c5e72968eb94 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Wed, 24 Sep 2014 22:54:26 +0200 Subject: New level parser Known issues: * TerrainLevel for some reason doesn't work * %lvl% is not yet implemented everywhere because of hardcoded directories in functions --- src/object/robotmain.cpp | 1296 +++++++++++++++++++++------------------------- 1 file changed, 588 insertions(+), 708 deletions(-) (limited to 'src/object/robotmain.cpp') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 407a1ec..ce7f8d0 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -58,6 +58,7 @@ #include "object/task/task.h" #include "object/task/taskbuild.h" #include "object/task/taskmanip.h" +#include "object/level/parser.h" #include "physics/physics.h" @@ -83,7 +84,7 @@ #include -#include +#include template<> CRobotMain* CSingleton::m_instance = nullptr; @@ -1208,18 +1209,27 @@ void CRobotMain::ChangePhase(Phase phase) bool loading = (m_dialog->GetSceneRead()[0] != 0); m_map->CreateMap(); - CreateScene(m_dialog->GetSceneSoluce(), false, false); // interactive scene - if (m_mapImage) - m_map->SetFixImage(m_mapFilename); + + try { + CreateScene(m_dialog->GetSceneSoluce(), false, false); // interactive scene + if (m_mapImage) + m_map->SetFixImage(m_mapFilename); - m_app->ResetTimeAfterLoading(); + m_app->ResetTimeAfterLoading(); - if (m_immediatSatCom && !loading && - m_infoFilename[SATCOM_HUSTON][0] != 0) - StartDisplayInfo(SATCOM_HUSTON, false); // shows the instructions + if (m_immediatSatCom && !loading && + m_infoFilename[SATCOM_HUSTON][0] != 0) + StartDisplayInfo(SATCOM_HUSTON, false); // shows the instructions - m_sound->StopMusic(0.0f); - if (!m_base || loading) StartMusic(); + m_sound->StopMusic(0.0f); + if (!m_base || loading) StartMusic(); + } + catch(const CLevelParserException& e) + { + CLogger::GetInstancePointer()->Error("An error occured while trying to load a level\n"); + CLogger::GetInstancePointer()->Error("%s\n", e.what()); + ChangePhase(PHASE_INIT); + } } if (m_phase == PHASE_WIN) @@ -1235,29 +1245,37 @@ void CRobotMain::ChangePhase(Phase phase) m_dialog->SetSceneName("win"); m_dialog->SetSceneRank(m_endingWinRank); - CreateScene(false, true, false); // sets scene + try { + CreateScene(false, true, false); // sets scene - pos.x = ox+sx*1; pos.y = oy+sy*1; - Math::Point ddim; - ddim.x = dim.x*2; ddim.y = dim.y*2; - m_interface->CreateButton(pos, ddim, 16, EVENT_BUTTON_OK); + pos.x = ox+sx*1; pos.y = oy+sy*1; + Math::Point ddim; + ddim.x = dim.x*2; ddim.y = dim.y*2; + m_interface->CreateButton(pos, ddim, 16, EVENT_BUTTON_OK); - if (m_winTerminate) - { - pos.x = ox+sx*3; pos.y = oy+sy*0.2f; - ddim.x = dim.x*15; ddim.y = dim.y*3.0f; - pe = m_interface->CreateEdit(pos, ddim, 0, EVENT_EDIT0); - pe->SetGenericMode(true); - pe->SetFontType(Gfx::FONT_COLOBOT); - pe->SetEditCap(false); - pe->SetHighlightCap(false); - pe->ReadText(std::string("help/") + m_app->GetLanguageChar() + std::string("/win.txt")); + if (m_winTerminate) + { + pos.x = ox+sx*3; pos.y = oy+sy*0.2f; + ddim.x = dim.x*15; ddim.y = dim.y*3.0f; + pe = m_interface->CreateEdit(pos, ddim, 0, EVENT_EDIT0); + pe->SetGenericMode(true); + pe->SetFontType(Gfx::FONT_COLOBOT); + pe->SetEditCap(false); + pe->SetHighlightCap(false); + pe->ReadText(std::string("help/") + m_app->GetLanguageChar() + std::string("/win.txt")); + } + else + { + m_displayText->DisplayError(INFO_WIN, Math::Vector(0.0f,0.0f,0.0f), 15.0f, 60.0f, 1000.0f); + } + StartMusic(); } - else + catch(const CLevelParserException& e) { - m_displayText->DisplayError(INFO_WIN, Math::Vector(0.0f,0.0f,0.0f), 15.0f, 60.0f, 1000.0f); + CLogger::GetInstancePointer()->Error("An error occured while trying to load win scene\n"); + CLogger::GetInstancePointer()->Error("%s\n", e.what()); + ChangePhase(PHASE_TERM); } - StartMusic(); } } @@ -1273,15 +1291,23 @@ void CRobotMain::ChangePhase(Phase phase) m_winTerminate = false; m_dialog->SetSceneName("lost"); m_dialog->SetSceneRank(m_endingLostRank); - CreateScene(false, true, false); // sets scene + try { + CreateScene(false, true, false); // sets scene - pos.x = ox+sx*1; pos.y = oy+sy*1; - Math::Point ddim; - ddim.x = dim.x*2; ddim.y = dim.y*2; - m_interface->CreateButton(pos, ddim, 16, EVENT_BUTTON_OK); - m_displayText->DisplayError(INFO_LOST, Math::Vector(0.0f,0.0f,0.0f), 15.0f, 60.0f, 1000.0f); + pos.x = ox+sx*1; pos.y = oy+sy*1; + Math::Point ddim; + ddim.x = dim.x*2; ddim.y = dim.y*2; + m_interface->CreateButton(pos, ddim, 16, EVENT_BUTTON_OK); + m_displayText->DisplayError(INFO_LOST, Math::Vector(0.0f,0.0f,0.0f), 15.0f, 60.0f, 1000.0f); - StartMusic(); + StartMusic(); + } + catch(const CLevelParserException& e) + { + CLogger::GetInstancePointer()->Error("An error occured while trying to load lost scene\n"); + CLogger::GetInstancePointer()->Error("%s\n", e.what()); + ChangePhase(PHASE_TERM); + } } } @@ -3819,7 +3845,14 @@ void CRobotMain::ScenePerso() m_dialog->SetSceneName("perso"); m_dialog->SetSceneRank(0); - CreateScene(false, true, false); // sets scene + try { + CreateScene(false, true, false); // sets scene + } + catch(const CLevelParserException& e) + { + CLogger::GetInstancePointer()->Error("An error occured while trying to load apperance scene\n"); + CLogger::GetInstancePointer()->Error("%s\n", e.what()); + } m_engine->SetDrawWorld(false); // does not draw anything on the interface m_engine->SetDrawFront(true); // draws on the human interface @@ -3924,27 +3957,9 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) m_missionResult = ERR_MISSION_NOTERM; } - - char line[500]; - char name[200]; - char dir[100]; - char op[100]; - char filename[500]; - int lineNum = 0; - - memset(line, 0, 500); - memset(name, 0, 200); - memset(dir, 0, 100); - memset(op, 0, 100); - memset(filename, 0, 500); - std::string tempLine; - m_dialog->BuildSceneName(tempLine, base, rank); - strcpy(filename, tempLine.c_str()); - - CInputStream stream; - stream.open(filename); - if (!stream.is_open()) return; + CLevelParser* level = new CLevelParser(base, rank/100, rank%100); + level->Load(); int rankObj = 0; int rankGadget = 0; @@ -3957,584 +3972,445 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) * may speed up loading */ - while (stream.getline(line, 500)) + for(auto& line : level->GetLines()) { - lineNum++; - for (int i = 0; i < 500; i++) + if (line->GetCommand() == "MissionFile" && !resetObject) { - if (line[i] == '\t' ) line[i] = ' '; // replace tab by space - if (line[i] == '/' && line[i+1] == '/') - { - line[i] = 0; - break; - } - } - - if (Cmd(line, "MissionFile") && !resetObject) { - m_version = OpInt(line, "version", 1); - continue; + m_version = line->GetParam("version")->AsInt(1); + continue; } - - // TODO: Fallback to an non-localized entry - sprintf(op, "Title.%c", m_app->GetLanguageChar()); - if (Cmd(line, op) && !resetObject) + + if(line->GetCommand() == "Title" && !resetObject) { - OpString(line, "text", m_title); + strcpy(m_title, line->GetParam("text")->AsString().c_str()); continue; } - - sprintf(op, "Resume.%c", m_app->GetLanguageChar()); - if (Cmd(line, op) && !resetObject) + + if(line->GetCommand() == "Resume" && !resetObject) { - OpString(line, "text", m_resume); + strcpy(m_resume, line->GetParam("text")->AsString().c_str()); continue; } - - sprintf(op, "ScriptName.%c", m_app->GetLanguageChar()); - if (Cmd(line, op) && !resetObject) + + if(line->GetCommand() == "ScriptName" && !resetObject) { - OpString(line, "text", m_scriptName); + strcpy(m_scriptName, line->GetParam("text")->AsString().c_str()); continue; } - - static const boost::regex titleCmdRe("Title\\.[A-Z]"); - static const boost::regex resumeCmdRe("Resume\\.[A-Z]"); - static const boost::regex scriptNameCmdRe("ScriptName\\.[A-Z]"); - - if (boost::regex_match(GetCmd(line), titleCmdRe)) continue; // Ignore - if (boost::regex_match(GetCmd(line), resumeCmdRe)) continue; // Ignore - if (boost::regex_match(GetCmd(line), scriptNameCmdRe)) continue; // Ignore - - - if (Cmd(line, "ScriptFile") && !resetObject) + + if (line->GetCommand() == "ScriptFile" && !resetObject) { - OpString(line, "name", m_scriptFile); + strcpy(m_scriptFile, line->GetParam("name")->AsString().c_str()); continue; } - - if (Cmd(line, "Instructions") && !resetObject) + + if (line->GetCommand() == "Instructions" && !resetObject) { - OpString(line, "name", name); - std::string path = name; - InjectLevelDir(path, "help/%lng%"); - strcpy(m_infoFilename[SATCOM_HUSTON], path.c_str()); - - m_immediatSatCom = OpInt(line, "immediat", 0); - if (m_version >= 2) m_beginSatCom = m_lockedSatCom = OpInt(line, "lock", 0); + strcpy(m_infoFilename[SATCOM_HUSTON], line->GetParam("name")->AsPath("help/%lng%").c_str()); + + m_immediatSatCom = line->GetParam("immediat")->AsBool(false); + if (m_version >= 2) m_beginSatCom = m_lockedSatCom = line->GetParam("lock")->AsBool(false); if (m_app->GetSceneTestMode()) m_immediatSatCom = false; continue; } - - if (Cmd(line, "Satellite") && !resetObject) + + if (line->GetCommand() == "Satellite" && !resetObject) { - OpString(line, "name", name); - std::string path = name; - InjectLevelDir(path, "help/%lng%"); - strcpy(m_infoFilename[SATCOM_SAT], path.c_str()); + strcpy(m_infoFilename[SATCOM_SAT], line->GetParam("name")->AsPath("help/%lng%").c_str()); continue; } - - if (Cmd(line, "Loading") && !resetObject) + + if (line->GetCommand() == "Loading" && !resetObject) { - OpString(line, "name", name); - std::string path = name; - InjectLevelDir(path, "help/%lng%"); - strcpy(m_infoFilename[SATCOM_LOADING], path.c_str()); + strcpy(m_infoFilename[SATCOM_LOADING], line->GetParam("name")->AsPath("help/%lng%").c_str()); continue; } - - if (Cmd(line, "HelpFile") && !resetObject) + + if (line->GetCommand() == "HelpFile" && !resetObject) { - OpString(line, "name", name); - std::string path = name; - InjectLevelDir(path, "help/%lng%"); - strcpy(m_infoFilename[SATCOM_PROG], path.c_str()); + strcpy(m_infoFilename[SATCOM_PROG], line->GetParam("name")->AsPath("help/%lng%").c_str()); continue; } - if (Cmd(line, "SoluceFile") && !resetObject) + if (line->GetCommand() == "SoluceFile" && !resetObject) { - OpString(line, "name", name); - std::string path = name; - InjectLevelDir(path, "help/%lng%"); - strcpy(m_infoFilename[SATCOM_SOLUCE], path.c_str()); + strcpy(m_infoFilename[SATCOM_SOLUCE], line->GetParam("name")->AsPath("help/%lng%").c_str()); continue; } - - if (Cmd(line, "EndingFile") && !resetObject) + + if (line->GetCommand() == "EndingFile" && !resetObject) { - m_endingWinRank = OpInt(line, "win", 0); - m_endingLostRank = OpInt(line, "lost", 0); + // NOTE: The old default was 0, but I think -1 is more correct - 0 means "ending file 000", while -1 means "no ending file" + m_endingWinRank = line->GetParam("win")->AsInt(-1); + m_endingLostRank = line->GetParam("lost")->AsInt(-1); continue; } - - if (Cmd(line, "MessageDelay") && !resetObject) + + if (line->GetCommand() == "MessageDelay" && !resetObject) { - m_displayText->SetDelay(OpFloat(line, "factor", 1.0f)); + m_displayText->SetDelay(line->GetParam("factor")->AsFloat()); continue; } - - if (Cmd(line, "CacheAudio") && !resetObject && m_version >= 2) + + if (line->GetCommand() == "CacheAudio" && !resetObject && m_version >= 2) { - OpString(line, "filename", name); - m_sound->CacheMusic(name); + m_sound->CacheMusic(line->GetParam("filename")->AsPath("").c_str()); //TODO: don't make this relative to music/ continue; } - - if (Cmd(line, "AudioChange") && !resetObject && m_version >= 2 && m_controller == nullptr) + + if (line->GetCommand() == "AudioChange" && !resetObject && m_version >= 2 && m_controller == nullptr) { int i = m_audioChangeTotal; if (i < 10) { - m_audioChange[i].pos = OpPos(line, "pos")*g_unit; - m_audioChange[i].dist = OpFloat(line, "dist", 1000.0f)*g_unit; - m_audioChange[i].type = OpTypeObject(line, "type", OBJECT_NULL); - m_audioChange[i].min = OpInt(line, "min", 1); - m_audioChange[i].max = OpInt(line, "max", 9999); - m_audioChange[i].powermin = OpFloat(line, "powermin", -1); - m_audioChange[i].powermax = OpFloat(line, "powermax", 100); - m_audioChange[i].tool = OpTool(line, "tool"); - m_audioChange[i].drive = OpDrive(line, "drive"); - OpString(line, "filename", m_audioChange[i].music); - m_audioChange[i].repeat = OpInt(line, "repeat", 1); + m_audioChange[i].pos = line->GetParam("pos")->AsPoint(Math::Vector(0.0f, 0.0f, 0.0f))*g_unit; + m_audioChange[i].dist = line->GetParam("dist")->AsFloat(1000.0f)*g_unit; + m_audioChange[i].type = line->GetParam("type")->AsObjectType(OBJECT_NULL); + m_audioChange[i].min = line->GetParam("min")->AsInt(1); + 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); + strcpy(m_audioChange[i].music, line->GetParam("filename")->AsPath("").c_str()); //TODO: don't make this relative to music/ + m_audioChange[i].repeat = line->GetParam("repeat")->AsBool(true); m_audioChange[i].changed = false; m_sound->CacheMusic(m_audioChange[i].music); m_audioChangeTotal ++; } continue; } - - if (Cmd(line, "Audio") && !resetObject && m_controller == nullptr) + + if (line->GetCommand() == "Audio" && !resetObject && m_controller == nullptr) { if (m_version < 2) { - int trackid = OpInt(line, "track", 0); + int trackid = line->GetParam("track")->AsInt(); if (trackid != 0) { std::stringstream filenameStr; filenameStr << "music" << std::setfill('0') << std::setw(3) << trackid << ".ogg"; m_audioTrack = filenameStr.str(); } - m_audioRepeat = OpInt(line, "repeat", 1); + m_audioRepeat = line->GetParam("repeat")->AsBool(true); } else { - char trackname[100]; + m_audioTrack = line->GetParam("main")->AsPath("", ""); //TODO: don't make this relative to music/ + m_audioRepeat = line->GetParam("mainRepeat")->AsBool(true); - OpString(line, "main", trackname); - m_audioTrack = trackname; - m_audioRepeat = OpInt(line, "mainRepeat", 1); + m_satcomTrack = line->GetParam("satcom")->AsPath("", ""); //TODO: don't make this relative to music/ + m_satcomRepeat = line->GetParam("satcomRepeat")->AsBool(true); - OpString(line, "satcom", trackname); - m_satcomTrack = trackname; - m_satcomRepeat = OpInt(line, "satcomRepeat", 1); - - OpString(line, "editor", trackname); - m_editorTrack = trackname; - m_editorRepeat = OpInt(line, "editorRepeat", 1); + m_editorTrack = line->GetParam("editor")->AsPath("", ""); //TODO: don't make this relative to music/ + m_editorRepeat = line->GetParam("editorRepeat")->AsBool(true); } if (m_audioTrack != "") m_sound->CacheMusic(m_audioTrack); if (m_satcomTrack != "") m_sound->CacheMusic(m_satcomTrack); if (m_editorTrack != "") m_sound->CacheMusic(m_editorTrack); continue; } - - if (Cmd(line, "AmbientColor") && !resetObject) + + if (line->GetCommand() == "AmbientColor" && !resetObject) { - m_engine->SetAmbientColor(OpColor(line, "air", Gfx::Color(0.533f, 0.533f, 0.533f, 0.533f)), 0); - m_engine->SetAmbientColor(OpColor(line, "water", Gfx::Color(0.533f, 0.533f, 0.533f, 0.533f)), 1); + m_engine->SetAmbientColor(line->GetParam("air")->AsColor(Gfx::Color(0.533f, 0.533f, 0.533f, 0.533f)), 0); + m_engine->SetAmbientColor(line->GetParam("water")->AsColor(Gfx::Color(0.533f, 0.533f, 0.533f, 0.533f)), 1); continue; } - - if (Cmd(line, "FogColor") && !resetObject) + + if (line->GetCommand() == "FogColor" && !resetObject) { - m_engine->SetFogColor(OpColor(line, "air", Gfx::Color(0.533f, 0.533f, 0.533f, 0.533f)), 0); - m_engine->SetFogColor(OpColor(line, "water", Gfx::Color(0.533f, 0.533f, 0.533f, 0.533f)), 1); + m_engine->SetFogColor(line->GetParam("air")->AsColor(Gfx::Color(0.533f, 0.533f, 0.533f, 0.533f)), 0); + m_engine->SetFogColor(line->GetParam("water")->AsColor(Gfx::Color(0.533f, 0.533f, 0.533f, 0.533f)), 1); continue; } - - if (Cmd(line, "VehicleColor") && !resetObject) + + if (line->GetCommand() == "VehicleColor" && !resetObject) { - m_colorNewBot = OpColor(line, "color", Gfx::Color(0.533f, 0.533f, 0.533f, 0.533f)); + m_colorNewBot = line->GetParam("color")->AsColor(Gfx::Color(0.533f, 0.533f, 0.533f, 0.533f)); continue; } - - if (Cmd(line, "InsectColor") && !resetObject) + + if (line->GetCommand() == "InsectColor" && !resetObject) { - m_colorNewAlien = OpColor(line, "color", Gfx::Color(0.533f, 0.533f, 0.533f, 0.533f)); + m_colorNewAlien = line->GetParam("color")->AsColor(Gfx::Color(0.533f, 0.533f, 0.533f, 0.533f)); continue; } - - if (Cmd(line, "GreeneryColor") && !resetObject) + + if (line->GetCommand() == "GreeneryColor" && !resetObject) { - m_colorNewGreen = OpColor(line, "color", Gfx::Color(0.533f, 0.533f, 0.533f, 0.533f)); + m_colorNewGreen = line->GetParam("color")->AsColor(Gfx::Color(0.533f, 0.533f, 0.533f, 0.533f)); continue; } - - if (Cmd(line, "DeepView") && !resetObject) + + if (line->GetCommand() == "DeepView" && !resetObject) { - m_engine->SetDeepView(OpFloat(line, "air", 500.0f)*g_unit, 0, true); - m_engine->SetDeepView(OpFloat(line, "water", 100.0f)*g_unit, 1, true); + m_engine->SetDeepView(line->GetParam("air")->AsFloat(500.0f)*g_unit, 0, true); + m_engine->SetDeepView(line->GetParam("water")->AsFloat(100.0f)*g_unit, 1, true); continue; } - - if (Cmd(line, "FogStart") && !resetObject) + + if (line->GetCommand() == "FogStart" && !resetObject) { - m_engine->SetFogStart(OpFloat(line, "air", 0.5f), 0); - m_engine->SetFogStart(OpFloat(line, "water", 0.5f), 1); + m_engine->SetFogStart(line->GetParam("air")->AsFloat(0.5f), 0); + m_engine->SetFogStart(line->GetParam("water")->AsFloat(0.5f), 1); continue; } - - if (Cmd(line, "SecondTexture") && !resetObject) + + if (line->GetCommand() == "SecondTexture" && !resetObject) { - m_engine->SetSecondTexture(OpInt(line, "rank", 1)); + m_engine->SetSecondTexture(line->GetParam("rank")->AsInt()); continue; } - - if (Cmd(line, "Background") && !resetObject) - { - OpString(line, "image", name); - m_engine->SetBackground(name, - OpColor(line, "up", Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f)), - OpColor(line, "down", Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f)), - OpColor(line, "cloudUp", Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f)), - OpColor(line, "cloudDown", Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f)), - OpInt(line, "full", 0)); + + if (line->GetCommand() == "Background" && !resetObject) + { + m_engine->SetBackground(line->GetParam("image")->AsPath("", "").c_str(), //TODO: don't make this relative to textures/ + line->GetParam("up")->AsColor(Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f)), + line->GetParam("down")->AsColor(Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f)), + line->GetParam("cloudUp")->AsColor(Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f)), + line->GetParam("cloudDown")->AsColor(Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f)), + line->GetParam("full")->AsBool(false)); continue; } - - if (Cmd(line, "Planet") && !resetObject) + + if (line->GetCommand() == "Planet" && !resetObject) { Math::Vector ppos, uv1, uv2; - - ppos = OpPos(line, "pos"); - uv1 = OpPos(line, "uv1"); - uv2 = OpPos(line, "uv2"); - OpString(line, "image", name); - m_planet->Create(OpInt(line, "mode", 0), + + ppos = line->GetParam("pos")->AsPoint(); + uv1 = line->GetParam("uv1")->AsPoint(); + uv2 = line->GetParam("uv2")->AsPoint(); + m_planet->Create(line->GetParam("mode")->AsInt(0), Math::Point(ppos.x, ppos.z), - OpFloat(line, "dim", 0.2f), - OpFloat(line, "speed", 0.0f), - OpFloat(line, "dir", 0.0f), - name, + line->GetParam("dim")->AsFloat(0.2f), + line->GetParam("speed")->AsFloat(0.0f), + line->GetParam("dir")->AsFloat(0.0f), + line->GetParam("image")->AsPath(""), //TODO: don't make this relative to textures/ Math::Point(uv1.x, uv1.z), Math::Point(uv2.x, uv2.z), - strstr(name, "planet") != nullptr // TODO: add transparent op or modify textures - ); + line->GetParam("image")->AsPath("").find("planet") != std::string::npos // TODO: add transparent op or modify textures + ); continue; } - - if (Cmd(line, "ForegroundName") && !resetObject) + + if (line->GetCommand() == "ForegroundName" && !resetObject) { - OpString(line, "image", name); - m_engine->SetForegroundName(name); + m_engine->SetForegroundName(line->GetParam("image")->AsPath("")); //TODO: don't make this relative to textures/ continue; } - - if (((m_version == 1 && Cmd(line, "Global")) || (m_version >= 2 && Cmd(line, "Mission"))) && !resetObject) + + if (((line->GetCommand() == "Global") || (m_version >= 2 && line->GetCommand() == "Mission")) && !resetObject) { - g_unit = OpFloat(line, "unitScale", 4.0f); - m_engine->SetTracePrecision(OpFloat(line, "traceQuality", 1.0f)); - m_shortCut = OpInt(line, "shortcut", 1); + g_unit = line->GetParam("unitScale")->AsFloat(4.0f); + m_engine->SetTracePrecision(line->GetParam("traceQuality")->AsFloat(1.0f)); + m_shortCut = line->GetParam("shortcut")->AsBool(true); if (m_version >= 2) { - m_retroStyle = OpInt(line, "retro", 0); + m_retroStyle = line->GetParam("retro")->AsBool(false); if (m_retroStyle) GetLogger()->Info("Retro mode enabled.\n"); } continue; } - - if (Cmd(line, "TerrainGenerate") && !resetObject) - { - if (m_terrainCreate) - { - GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainGenerate after TerrainCreate\n", filename, lineNum); - continue; - } - - if (m_terrainInit) - { - GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainGenerate after TerrainInit\n", filename, lineNum); - continue; - } - - m_terrain->Generate(OpInt(line, "mosaic", 20), - OpInt(line, "brick", 3), - OpFloat(line, "size", 20.0f), - OpFloat(line, "vision", 500.0f)*g_unit, - OpInt(line, "depth", 2), - OpFloat(line, "hard", 0.5f)); - - m_terrainGenerate = true; + + if (line->GetCommand() == "TerrainGenerate" && !resetObject) + { + m_terrain->Generate(line->GetParam("mosaic")->AsInt(20), + line->GetParam("brick")->AsInt(3), + line->GetParam("size")->AsFloat(20.0f), + line->GetParam("vision")->AsFloat(500.0f)*g_unit, + line->GetParam("depth")->AsInt(2), + line->GetParam("hard")->AsFloat(0.5f)); continue; } - - if (Cmd(line, "TerrainWind") && !resetObject) + + if (line->GetCommand() == "TerrainWind" && !resetObject) { - if (m_terrainCreate) - { - GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainWind after TerrainCreate\n", filename, lineNum); - continue; - } - - if (m_terrainInit) - { - GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainWind after TerrainInit\n", filename, lineNum); - continue; - } - - if (!m_terrainGenerate) - { - GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainWind before TerrainGenerate\n", filename, lineNum); - continue; - } - - m_terrain->SetWind(OpPos(line, "speed")); + m_terrain->SetWind(line->GetParam("speed")->AsPoint()); continue; } - - if (Cmd(line, "TerrainRelief") && !resetObject) + + if (line->GetCommand() == "TerrainRelief" && !resetObject) { - if (m_terrainCreate) - { - GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainRelief after TerrainCreate\n", filename, lineNum); - continue; - } - - if (m_terrainInit) - { - GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainRelief after TerrainInit\n", filename, lineNum); - continue; - } - - if (!m_terrainGenerate) - { - GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainRelief before TerrainGenerate\n", filename, lineNum); - continue; - } - - OpString(line, "image", name); - m_terrain->LoadRelief(std::string("textures/")+name, OpFloat(line, "factor", 1.0f), OpInt(line, "border", 1)); + m_terrain->LoadRelief( + line->GetParam("image")->AsPath("textures"), + line->GetParam("factor")->AsFloat(1.0f), + line->GetParam("border")->AsBool(true)); continue; } - if (Cmd(line, "TerrainRandomRelief") && !resetObject) + if (line->GetCommand() == "TerrainRandomRelief" && !resetObject) { m_terrain->RandomizeRelief(); continue; } - - if (Cmd(line, "TerrainResource") && !resetObject) + + if (line->GetCommand() == "TerrainResource" && !resetObject) { - if (m_terrainCreate) - { - GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainResource after TerrainCreate\n", filename, lineNum); - continue; - } - - if (m_terrainInit) - { - GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainResource after TerrainInit\n", filename, lineNum); - continue; - } - - if (!m_terrainGenerate) - { - GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainResource before TerrainGenerate\n", filename, lineNum); - continue; - } - - OpString(line, "image", name); - m_terrain->LoadResources(std::string("textures/")+name); + m_terrain->LoadResources(line->GetParam("image")->AsPath("textures")); continue; } - - if (Cmd(line, "TerrainWater") && !resetObject) + + if (line->GetCommand() == "TerrainWater" && !resetObject) { - OpString(line, "image", name); Math::Vector pos; - pos.x = OpFloat(line, "moveX", 0.0f); - pos.y = OpFloat(line, "moveY", 0.0f); + pos.x = line->GetParam("moxeX")->AsFloat(0.0f); + pos.y = line->GetParam("moxeY")->AsFloat(0.0f); pos.z = pos.x; - m_water->Create(OpTypeWater(line, "air", Gfx::WATER_TT), - OpTypeWater(line, "water", Gfx::WATER_TT), - name, - OpColor(line, "diffuse", Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f)), - OpColor(line, "ambient", Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f)), - OpFloat(line, "level", 100.0f)*g_unit, - OpFloat(line, "glint", 1.0f), + m_water->Create(line->GetParam("air")->AsWaterType(Gfx::WATER_TT), + line->GetParam("water")->AsWaterType(Gfx::WATER_TT), + line->GetParam("image")->AsPath(""), //TODO: don't make this relative to textures/ + line->GetParam("diffuse")->AsColor(Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f)), + line->GetParam("ambient")->AsColor(Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f)), + line->GetParam("level")->AsFloat(100.0f)*g_unit, + line->GetParam("glint")->AsFloat(1.0f), pos); - m_colorNewWater = OpColor(line, "color", m_colorRefWater); - m_colorShiftWater = OpFloat(line, "brightness", 0.0f); + m_colorNewWater = line->GetParam("color")->AsColor(m_colorRefWater); + m_colorShiftWater = line->GetParam("brightness")->AsFloat(0.0f); continue; } - - if (Cmd(line, "TerrainLava") && !resetObject) + + if (line->GetCommand() == "TerrainLava" && !resetObject) { - m_water->SetLava(OpInt(line, "mode", 0)); + m_water->SetLava(line->GetParam("mode")->AsBool()); continue; } - - if (Cmd(line, "TerrainCloud") && !resetObject) + + if (line->GetCommand() == "TerrainCloud" && !resetObject) { - OpString(line, "image", name); - m_cloud->Create(name, - OpColor(line, "diffuse", Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f)), - OpColor(line, "ambient", Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f)), - OpFloat(line, "level", 500.0f) * g_unit); + m_cloud->Create(line->GetParam("image")->AsPath("", ""), //TODO: don't make this relative to textures/ + line->GetParam("diffuse")->AsColor(Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f)), + line->GetParam("ambient")->AsColor(Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f)), + line->GetParam("level")->AsFloat(500.0f)*g_unit); continue; } - - if (Cmd(line, "TerrainBlitz") && !resetObject) + + if (line->GetCommand() == "TerrainBlitz" && !resetObject) { - m_lightning->Create(OpFloat(line, "sleep", 0.0f), - OpFloat(line, "delay", 3.0f), - OpFloat(line, "magnetic", 50.0f) * g_unit); + m_lightning->Create(line->GetParam("sleep")->AsFloat(0.0f), + line->GetParam("delay")->AsFloat(3.0f), + line->GetParam("magnetic")->AsFloat(50.0f)*g_unit); continue; } - - if (Cmd(line, "TerrainInitTextures") && !resetObject) + + if (line->GetCommand() == "TerrainInitTextures" && !resetObject) { - if (m_terrainInit) - { - GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainInitTextures and TerrainInit at same time\n", filename, lineNum); - continue; + std::string name = line->GetParam("image")->AsPath(""); //TODO: don't make this relative to textures/ + if(name.find(".") == std::string::npos) + name += ".png"; + int dx = line->GetParam("dx")->AsInt(1); + int dy = line->GetParam("dy")->AsInt(1); + + int tt[100]; //TODO: I have no idea how TerrainInitTextures works, but maybe we shuld remove the limit to 100? + if(dx*dy > 100) + throw CLevelParserException("In TerrainInitTextures: dx*dy must be <100"); + if(line->GetParam("table")->IsDefined()) { + const std::vector& table = line->GetParam("table")->AsArray(); + + if(table.size() > dx*dy) + throw CLevelParserException("In TerrainInitTextures: table size must be dx*dy"); + + for (int i = 0; i < dx*dy; i++) + { + if(i >= table.size()) + { + tt[i] = 0; + } else { + tt[i] = table[i]->AsInt(); + } + } + } else { + for (int i = 0; i < dx*dy; i++) + { + tt[i] = 0; + } } - - OpString(line, "image", name); - AddExt(name, ".png"); - int dx = OpInt(line, "dx", 1); - int dy = OpInt(line, "dy", 1); - char* opTable = SearchOp(line, "table"); - int tt[100]; - for (int i = 0; i < dx*dy; i++) - tt[i] = GetInt(opTable, i, 0); - + + /*TODO: ??? if (strstr(name, "%user%") != 0) CopyFileListToTemp(name, tt, dx*dy); - - m_terrain->InitTextures(name, tt, dx, dy); - - m_terrainInitTextures = true; + */ + + m_terrain->InitTextures(name.c_str(), tt, dx, dy); continue; } - - if (Cmd(line, "TerrainInit") && !resetObject) + + if (line->GetCommand() == "TerrainInit" && !resetObject) { - if (m_terrainInitTextures) - { - GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainInit and TerrainInitTextures at same time\n", filename, lineNum); - continue; - } - - m_terrain->InitMaterials(OpInt(line, "id", 1)); + m_terrain->InitMaterials(line->GetParam("id")->AsInt(1)); m_terrainInit = true; continue; } - - if (Cmd(line, "TerrainMaterial") && !resetObject) + + if (line->GetCommand() == "TerrainMaterial" && !resetObject) { - if (m_terrainCreate) - { - GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainMaterial after TerrainCreate\n", filename, lineNum); - continue; - } - - if (m_terrainInit) - { - GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainMaterial after TerrainInit\n", filename, lineNum); - continue; - } - - if (m_terrainInitTextures) - { - GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainMaterial and TerrainInitTextures at same time\n", filename, lineNum); - continue; - } - - OpString(line, "image", name); - AddExt(name, ".png"); + std::string name = line->GetParam("image")->AsPath(""); //TODO: don't make this relative to textures/ + if(name.find(".") == std::string::npos) + name += ".png"; + /*TODO: ??? if (strstr(name, "%user%") != 0) { GetProfile().CopyFileToTemp(std::string(name)); } - - m_terrain->AddMaterial(OpInt(line, "id", 0), - name, - Math::Point(OpFloat(line, "u", 0.0f), - OpFloat(line, "v", 0.0f)), - OpInt(line, "up", 1), - OpInt(line, "right", 1), - OpInt(line, "down", 1), - OpInt(line, "left", 1), - OpFloat(line, "hard", 0.5f)); + */ + + m_terrain->AddMaterial(line->GetParam("id")->AsInt(0), + name.c_str(), + Math::Point(line->GetParam("u")->AsFloat(), + line->GetParam("v")->AsFloat()), + line->GetParam("up")->AsInt(), + line->GetParam("right")->AsInt(), + line->GetParam("down")->AsInt(), + line->GetParam("left")->AsInt(), + line->GetParam("hard")->AsFloat(0.5f)); continue; } - - if (Cmd(line, "TerrainLevel") && !resetObject) + + if (line->GetCommand() == "TerrainLevel" && !resetObject) { - if (m_terrainCreate) - { - GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainLevel after TerrainCreate\n", filename, lineNum); - continue; - } - - if (!m_terrainInit) - { - GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainLevel before TerrainInit\n", filename, lineNum); - continue; - } - - if (m_terrainInitTextures) - { - GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainLevel and TerrainInitTextures at same time\n", filename, lineNum); - continue; - } - - if (!m_terrainGenerate) - { - GetLogger()->Error("Syntax error in file '%s' (line %d): TerrainLevel before TerrainGenerate\n", filename, lineNum); - continue; - } - - char* opId = SearchOp(line, "id"); - int id[50]; - int i = 0; - while (i < 50) - { - id[i] = GetInt(opId, i, 0); - if (id[i++] == 0) break; + int id[50]; //TODO: I have no idea how TerrainLevel works, but maybe we should remove the limit to 50? + if(line->GetParam("id")->IsDefined()) { + const std::vector& id_array = line->GetParam("id")->AsArray(); + + if(id_array.size() > 50) + throw CLevelParserException("In TerrainLevel: id array size must be < 50"); + + int i = 0; + while (i < 50) + { + id[i] = id_array[i]->AsInt(); + i++; + if(i >= id_array.size()) break; + } } - + m_terrain->GenerateMaterials(id, - OpFloat(line, "min", 0.0f)*g_unit, - OpFloat(line, "max", 100.0f)*g_unit, - OpFloat(line, "slope", 5.0f), - OpFloat(line, "freq", 100.0f), - OpPos(line, "center")*g_unit, - OpFloat(line, "radius", 0.0f)*g_unit); + line->GetParam("min")->AsFloat(0.0f)*g_unit, + line->GetParam("max")->AsFloat(100.0f)*g_unit, + line->GetParam("slope")->AsFloat(5.0f), + line->GetParam("freq")->AsFloat(100.0f), + line->GetParam("center")->AsPoint(Math::Vector(0.0f, 0.0f, 0.0f))*g_unit, + line->GetParam("radius")->AsFloat(0.0f)*g_unit); continue; } - - if (Cmd(line, "TerrainCreate") && !resetObject) + + if (line->GetCommand() == "TerrainCreate" && !resetObject) { m_terrain->CreateObjects(); - m_terrainCreate = true; continue; } - - if (Cmd(line, "BeginObject")) + + if (line->GetCommand() == "BeginObject") { InitEye(); SetMovieLock(false); - + if (read[0] != 0) // loading file ? sel = IOReadScene(read, stack); - - m_beginObject = true; + continue; } - - if (Cmd(line, "MissionController") && read[0] == 0 && m_version >= 2) + + if (line->GetCommand() == "MissionController" && read[0] == 0 && m_version >= 2) { m_controller = CObjectManager::GetInstancePointer()->CreateObject(Math::Vector(0.0f, 0.0f, 0.0f), 0.0f, OBJECT_CONTROLLER, 100.0f); m_controller->SetMagnifyDamage(100.0f); @@ -4542,48 +4418,42 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) CBrain* brain = m_controller->GetBrain(); if (brain != nullptr) { - OpString(line, "script", name); - if (name[0] != 0) - brain->SetScriptName(0, name); + std::string name = line->GetParam("script")->AsPath(""); //TODO: Don't make this relative to ai/ + if (!name.empty()) + brain->SetScriptName(0, const_cast(name.c_str())); brain->SetScriptRun(0); } continue; } - - if (Cmd(line, "CreateObject") && read[0] == 0) + + if (line->GetCommand() == "CreateObject" && read[0] == 0) { - if (!m_beginObject) - { - GetLogger()->Error("Syntax error in file '%s' (line %d): CreateObject before BeginObject\n", filename, lineNum); - continue; - } - - ObjectType type = OpTypeObject(line, "type", OBJECT_NULL); - - int gadget = OpInt(line, "gadget", -1); + ObjectType type = line->GetParam("type")->AsObjectType(); + + int gadget = line->GetParam("gadget")->AsInt(-1); if ( gadget == -1 ) { gadget = 0; if ( type == OBJECT_TECH || - (type >= OBJECT_PLANT0 && - type <= OBJECT_PLANT19 ) || - (type >= OBJECT_TREE0 && - type <= OBJECT_TREE5 ) || - (type >= OBJECT_TEEN0 && - type <= OBJECT_TEEN44 ) || - (type >= OBJECT_QUARTZ0 && - type <= OBJECT_QUARTZ3 ) || - (type >= OBJECT_ROOT0 && - type <= OBJECT_ROOT4 ) ) // not ROOT5! + (type >= OBJECT_PLANT0 && + type <= OBJECT_PLANT19 ) || + (type >= OBJECT_TREE0 && + type <= OBJECT_TREE5 ) || + (type >= OBJECT_TEEN0 && + type <= OBJECT_TEEN44 ) || + (type >= OBJECT_QUARTZ0 && + type <= OBJECT_QUARTZ3 ) || + (type >= OBJECT_ROOT0 && + type <= OBJECT_ROOT4 ) ) // not ROOT5! { if ( type != OBJECT_TEEN11 && // lamp? - type != OBJECT_TEEN12 && // coke? - type != OBJECT_TEEN20 && // wall? - type != OBJECT_TEEN21 && // wall? - type != OBJECT_TEEN22 && // wall? - type != OBJECT_TEEN26 && // lamp? - type != OBJECT_TEEN28 && // bottle? - type != OBJECT_TEEN34 ) // stone? + type != OBJECT_TEEN12 && // coke? + type != OBJECT_TEEN20 && // wall? + type != OBJECT_TEEN21 && // wall? + type != OBJECT_TEEN22 && // wall? + type != OBJECT_TEEN26 && // lamp? + type != OBJECT_TEEN28 && // bottle? + type != OBJECT_TEEN34 ) // stone? { gadget = 1; } @@ -4593,19 +4463,20 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) { if (!TestGadgetQuantity(rankGadget++)) continue; } - - Math::Vector pos = OpPos(line, "pos")*g_unit; - float dirAngle = OpFloat(line, "dir", 0.0f)*Math::PI; + + Math::Vector pos = line->GetParam("pos")->AsPoint()*g_unit; + float dirAngle = line->GetParam("dir")->AsFloat(0.0f)*Math::PI; bool trainer; CObject* obj = CObjectManager::GetInstancePointer()->CreateObject( - pos, dirAngle, - type, - OpFloat(line, "power", 1.0f), - OpFloat(line, "z", 1.0f), - OpFloat(line, "h", 0.0f), - trainer = OpInt(line, "trainer", 0), - OpInt(line, "toy", 0), - OpInt(line, "option", 0)); + pos, dirAngle, + type, + line->GetParam("power")->AsFloat(1.0f), + line->GetParam("z")->AsFloat(1.0f), + line->GetParam("h")->AsFloat(0.0f), + trainer = line->GetParam("trainer")->AsBool(false), + line->GetParam("toy")->AsBool(false), + line->GetParam("option")->AsInt(0) + ); if (m_fixScene && type == OBJECT_HUMAN) { @@ -4613,108 +4484,112 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) if (m_phase == PHASE_WIN ) motion->SetAction(MHS_WIN, 0.4f); if (m_phase == PHASE_LOST) motion->SetAction(MHS_LOST, 0.5f); } - + if (obj != nullptr) { obj->SetDefRank(rankObj); - + if (type == OBJECT_BASE) m_base = true; - - Gfx::CameraType cType = OpCamera(line, "camera"); + + Gfx::CameraType cType = line->GetParam("camera")->AsCameraType(Gfx::CAM_TYPE_NULL); if (cType != Gfx::CAM_TYPE_NULL) obj->SetCameraType(cType); - - obj->SetCameraDist(OpFloat(line, "cameraDist", 50.0f)); - obj->SetCameraLock(OpInt(line, "cameraLock", 0)); - - Gfx::PyroType pType = OpPyro(line, "pyro"); + + obj->SetCameraDist(line->GetParam("cameraDist")->AsFloat(50.0f)); + obj->SetCameraLock(line->GetParam("cameraLock")->AsBool(false)); + + Gfx::PyroType pType = line->GetParam("pyro")->AsPyroType(Gfx::PT_NULL); if (pType != Gfx::PT_NULL) { Gfx::CPyro* pyro = new Gfx::CPyro(); pyro->Create(pType, obj); } - + // Puts information in terminal (OBJECT_INFO). for (int i = 0; i < OBJECTMAXINFO; i++) { - sprintf(op, "info%d", i+1); - char text[100]; - OpString(line, op, text); - if (text[0] == 0) break; - char* p = strchr(text, '='); - if (p == 0) break; - *p = 0; + std::string op = "info"+std::to_string(i+1); + if(!line->GetParam(op)->IsDefined()) break; + std::string text = line->GetParam(op)->AsString(); + std::size_t p = text.find_first_of("="); + if(p == std::string::npos) + throw CLevelParserExceptionBadParam(line->GetParam(op), "info"); Info info; - strcpy(info.name, text); - sscanf(p+1, "%f", &info.value); + strcpy(info.name, text.substr(0, p).c_str()); + try { + info.value = boost::lexical_cast(text.substr(p+1).c_str()); + } + catch(...) + { + throw CLevelParserExceptionBadParam(line->GetParam(op), "info.value (float)"); + } obj->SetInfo(i, info); } - + // Sets the parameters of the command line. - char* p = SearchOp(line, "cmdline"); - for (int i = 0; i < OBJECTMAXCMDLINE; i++) - { - float value = GetFloat(p, i, NAN); - if (value == NAN) break; - obj->SetCmdLine(i, value); + if(line->GetParam("cmdline")->IsDefined()) { + const std::vector& cmdline = line->GetParam("cmdline")->AsArray(); + for (int i = 0; i < OBJECTMAXCMDLINE && i < cmdline.size(); i++) //TODO: get rid of the limit + { + obj->SetCmdLine(i, cmdline[i]->AsFloat()); + } } - - if (OpInt(line, "select", 0) == 1) + + if (line->GetParam("select")->AsBool(false)) { sel = obj; } - - bool selectable = OpInt(line, "selectable", 1); + + bool selectable = line->GetParam("selectable")->AsBool(true); obj->SetSelectable(selectable); - obj->SetIgnoreBuildCheck(OpInt(line, "ignoreBuildCheck", 0)); - obj->SetEnable(OpInt(line, "enable", 1)); - obj->SetProxyActivate(OpInt(line, "proxyActivate", 0)); - obj->SetProxyDistance(OpFloat(line, "proxyDistance", 15.0f)*g_unit); - obj->SetRange(OpFloat(line, "range", 30.0f)); - obj->SetShield(OpFloat(line, "shield", 1.0f)); - obj->SetMagnifyDamage(OpFloat(line, "magnifyDamage", 1.0f)); - obj->SetClip(OpInt(line, "clip", 1)); - obj->SetCheckToken(m_version >= 2 ? trainer || !selectable : OpInt(line, "checkToken", 1)); + obj->SetIgnoreBuildCheck(line->GetParam("ignoreBuildCheck")->AsBool(false)); + obj->SetEnable(line->GetParam("enable")->AsBool(true)); + obj->SetProxyActivate(line->GetParam("proxyActivate")->AsBool(false)); + if(line->GetParam("proxyActivate")->AsBool(false)) + obj->SetProxyDistance(line->GetParam("proxyDistance")->AsFloat()*g_unit); + obj->SetRange(line->GetParam("range")->AsFloat(30.0f)); + obj->SetShield(line->GetParam("shield")->AsFloat(1.0f)); + obj->SetMagnifyDamage(line->GetParam("magnifyDamage")->AsFloat(1.0f)); + obj->SetClip(line->GetParam("clip")->AsBool(true)); + obj->SetCheckToken(m_version >= 2 ? trainer || !selectable : line->GetParam("checkToken")->AsBool(true)); // SetManual will affect bot speed if (type == OBJECT_MOBILEdr) { - obj->SetManual(m_version >= 2 ? !trainer : OpInt(line, "manual", 0)); + obj->SetManual(m_version >= 2 ? !trainer : line->GetParam("manual")->AsBool(false)); } - + if (m_version >= 2) { - Math::Vector zoom = OpDir(line, "zoom"); + Math::Vector zoom = line->GetParam("zoom")->AsPoint(Math::Vector(0.0f, 0.0f, 0.0f)); if (zoom.x != 0.0f || zoom.y != 0.0f || zoom.z != 0.0f) obj->SetZoom(0, zoom); } - + + //TODO: I don't remember what this is used for CMotion* motion = obj->GetMotion(); - if (motion != nullptr) + if (motion != nullptr && line->GetParam("param")->IsDefined()) { - p = SearchOp(line, "param"); - for (int i = 0; i < 10; i++) + const std::vector& p = line->GetParam("param")->AsArray(); + for (int i = 0; i < 10 && i < p.size(); i++) { - float value; - value = GetFloat(p, i, NAN); - if (value == NAN) break; - motion->SetParam(i, value); + motion->SetParam(i, p[i]->AsFloat()); } } - + int run = -1; CBrain* brain = obj->GetBrain(); if (brain != nullptr) { for (int i = 0; i < 10; i++) { - sprintf(op, "script%d", i+1); // script1..script10 - OpString(line, op, name); - if (name[0] != 0) - brain->SetScriptName(i, name); - + std::string op = "script"+std::to_string(i+1); // script1..script10 + if(line->GetParam(op)->IsDefined()) { + brain->SetScriptName(i, const_cast(line->GetParam(op)->AsPath("").c_str())); //TODO: don't make this relative to ai/ + } + } - - int i = OpInt(line, "run", 0); + + int i = line->GetParam("run")->AsInt(0); if (i != 0) { run = i-1; @@ -4724,17 +4599,16 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) CAuto* automat = obj->GetAuto(); if (automat != nullptr) { - type = OpTypeObject(line, "autoType", OBJECT_NULL); + type = line->GetParam("autoType")->AsObjectType(OBJECT_NULL); automat->SetType(type); for (int i = 0; i < 5; i++) { - sprintf(op, "autoValue%d", i+1); // autoValue1..autoValue5 - automat->SetValue(i, OpFloat(line, op, 0.0f)); + std::string op = "autoValue"+std::to_string(i+1); // autoValue1..autoValue5 + automat->SetValue(i, line->GetParam(op)->AsFloat(0.0f)); } - OpString(line, "autoString", name); - automat->SetString(name); - - int i = OpInt(line, "run", -1); + automat->SetString(const_cast(line->GetParam("autoString")->AsString("").c_str())); + + int i = line->GetParam("run")->AsInt(-1); if (i != -1) { if (i != PARAM_FIXSCENE && @@ -4742,30 +4616,29 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) automat->Start(i); // starts the film } } - - OpString(line, "soluce", name); - if (soluce && brain != 0 && name[0] != 0) - brain->SetSoluceName(name); - + + if (soluce && brain != nullptr && line->GetParam("soluce")->IsDefined()) + brain->SetSoluceName(const_cast(line->GetParam("soluce")->AsString().c_str())); + obj->SetResetPosition(obj->GetPosition(0)); obj->SetResetAngle(obj->GetAngle(0)); obj->SetResetRun(run); - - if (OpInt(line, "reset", 0) == 1) + + if (line->GetParam("reset")->AsBool(false)) obj->SetResetCap(RESET_MOVE); } - + rankObj ++; continue; } - - if (Cmd(line, "CreateFog") && !resetObject) + + if (line->GetCommand() == "CreateFog" && !resetObject) { - Gfx::ParticleType type = static_cast((Gfx::PARTIFOG0+OpInt(line, "type", 0))); - Math::Vector pos = OpPos(line, "pos")*g_unit; - float height = OpFloat(line, "height", 1.0f)*g_unit; - float ddim = OpFloat(line, "dim", 50.0f)*g_unit; - float delay = OpFloat(line, "delay", 2.0f); + Gfx::ParticleType type = static_cast(Gfx::PARTIFOG0+(line->GetParam("type")->AsInt())); + Math::Vector pos = line->GetParam("pos")->AsPoint()*g_unit; + float height = line->GetParam("height")->AsFloat(1.0f)*g_unit; + float ddim = line->GetParam("dim")->AsFloat(50.0f)*g_unit; + float delay = line->GetParam("delay")->AsFloat(2.0f); m_terrain->AdjustToFloor(pos); pos.y += height; Math::Point dim; @@ -4774,149 +4647,150 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) m_particle->CreateParticle(pos, Math::Vector(0.0f, 0.0f, 0.0f), dim, type, delay, 0.0f, 0.0f); continue; } - - if (Cmd(line, "CreateLight") && !resetObject) + + if (line->GetCommand() == "CreateLight" && !resetObject) { Gfx::EngineObjectType type; - - int lightRank = CreateLight(OpDir(line, "dir"), - OpColor(line, "color", Gfx::Color(0.5f, 0.5f, 0.5f, 1.0f))); - - type = OpTypeTerrain(line, "type", Gfx::ENG_OBJTYPE_NULL); + + int lightRank = CreateLight(line->GetParam("dir")->AsPoint(), + line->GetParam("color")->AsColor(Gfx::Color(0.5f, 0.5f, 0.5f, 1.0f))); + + type = line->GetParam("type")->AsTerrainType(Gfx::ENG_OBJTYPE_NULL); + if (type == Gfx::ENG_OBJTYPE_TERRAIN) { m_lightMan->SetLightPriority(lightRank, Gfx::LIGHT_PRI_HIGHEST); m_lightMan->SetLightIncludeType(lightRank, Gfx::ENG_OBJTYPE_TERRAIN); } - + if (type == Gfx::ENG_OBJTYPE_QUARTZ) m_lightMan->SetLightIncludeType(lightRank, Gfx::ENG_OBJTYPE_QUARTZ); - + if (type == Gfx::ENG_OBJTYPE_METAL) m_lightMan->SetLightIncludeType(lightRank, Gfx::ENG_OBJTYPE_METAL); - + if (type == Gfx::ENG_OBJTYPE_FIX) m_lightMan->SetLightExcludeType(lightRank, Gfx::ENG_OBJTYPE_TERRAIN); - + continue; } - if (Cmd(line, "CreateSpot") && !resetObject) + if (line->GetCommand() == "CreateSpot" && !resetObject) { Gfx::EngineObjectType type; - - int rankLight = CreateSpot(OpDir(line, "pos")*g_unit, - OpColor(line, "color", Gfx::Color(0.5f, 0.5f, 0.5f, 1.0f))); - - type = OpTypeTerrain(line, "type", Gfx::ENG_OBJTYPE_NULL); + + int rankLight = CreateSpot(line->GetParam("pos")->AsPoint()*g_unit, + line->GetParam("color")->AsColor(Gfx::Color(0.5f, 0.5f, 0.5f, 1.0f))); + + type = line->GetParam("type")->AsTerrainType(Gfx::ENG_OBJTYPE_NULL); if (type == Gfx::ENG_OBJTYPE_TERRAIN) m_lightMan->SetLightIncludeType(rankLight, Gfx::ENG_OBJTYPE_TERRAIN); - + if (type == Gfx::ENG_OBJTYPE_QUARTZ) m_lightMan->SetLightIncludeType(rankLight, Gfx::ENG_OBJTYPE_QUARTZ); - + if (type == Gfx::ENG_OBJTYPE_METAL) m_lightMan->SetLightIncludeType(rankLight, Gfx::ENG_OBJTYPE_METAL); - + if (type == Gfx::ENG_OBJTYPE_FIX) m_lightMan->SetLightExcludeType(rankLight, Gfx::ENG_OBJTYPE_TERRAIN); - + continue; } - - if (Cmd(line, "GroundSpot") && !resetObject) + + if (line->GetCommand() == "GroundSpot" && !resetObject) { rank = m_engine->CreateGroundSpot(); if (rank != -1) { - m_engine->SetObjectGroundSpotPos(rank, OpPos(line, "pos")*g_unit); - m_engine->SetObjectGroundSpotRadius(rank, OpFloat(line, "radius", 10.0f)*g_unit); - m_engine->SetObjectGroundSpotColor(rank, OpColor(line, "color", Gfx::Color(0.533f, 0.533f, 0.533f, 0.533f))); - m_engine->SetObjectGroundSpotSmooth(rank, OpFloat(line, "smooth", 1.0f)); - m_engine->SetObjectGroundSpotMinMax(rank, OpFloat(line, "min", 0.0f)*g_unit, - OpFloat(line, "max", 0.0f)*g_unit); + m_engine->SetObjectGroundSpotPos(rank, line->GetParam("pos")->AsPoint()*g_unit); + m_engine->SetObjectGroundSpotRadius(rank, line->GetParam("radius")->AsFloat(10.0f)*g_unit); + m_engine->SetObjectGroundSpotColor(rank, line->GetParam("color")->AsColor(Gfx::Color(0.533f, 0.533f, 0.533f, 0.533f))); + m_engine->SetObjectGroundSpotSmooth(rank, line->GetParam("smooth")->AsFloat(1.0f)); + m_engine->SetObjectGroundSpotMinMax(rank, line->GetParam("min")->AsFloat(0.0f)*g_unit, + line->GetParam("max")->AsFloat(0.0f)*g_unit); } continue; } - - if (Cmd(line, "WaterColor") && !resetObject) + + if (line->GetCommand() == "WaterColor" && !resetObject) { - m_engine->SetWaterAddColor(OpColor(line, "color", Gfx::Color(0.0f, 0.0f, 0.0f, 1.0f))); + m_engine->SetWaterAddColor(line->GetParam("color")->AsColor()); continue; } - - if (Cmd(line, "MapColor") && !resetObject) + + if (line->GetCommand() == "MapColor" && !resetObject) { - m_map->FloorColorMap(OpColor(line, "floor", Gfx::Color(0.533f, 0.533f, 0.533f, 0.533f)), - OpColor(line, "water", Gfx::Color(0.533f, 0.533f, 0.533f, 0.533f))); - m_mapShow = OpInt(line, "show", 1); + m_map->FloorColorMap(line->GetParam("floor")->AsColor(Gfx::Color(0.533f, 0.533f, 0.533f, 0.533f)), + line->GetParam("water")->AsColor(Gfx::Color(0.533f, 0.533f, 0.533f, 0.533f))); + m_mapShow = line->GetParam("show")->AsBool(true); m_map->ShowMap(m_mapShow); - m_map->SetToy(OpInt(line, "toyIcon", 0)); - m_mapImage = OpInt(line, "image", 0); + m_map->SetToy(line->GetParam("toyIcon")->AsBool(false)); + m_mapImage = line->GetParam("image")->AsBool(false); if (m_mapImage) { - Math::Vector offset; - OpString(line, "filename", m_mapFilename); - offset = OpPos(line, "offset"); - m_map->SetFixParam(OpFloat(line, "zoom", 1.0f), + Math::Vector offset; + strcpy(m_mapFilename, line->GetParam("filename")->AsPath("").c_str()); //TODO: don't make this relative to textures/ + offset = line->GetParam("offset")->AsPoint(Math::Vector(0.0f, 0.0f, 0.0f)); + m_map->SetFixParam(line->GetParam("zoom")->AsFloat(1.0f), offset.x, offset.z, - OpFloat(line, "angle", 0.0f)*Math::PI/180.0f, - OpInt(line, "mode", 0), - OpInt(line, "debug", 0)); + line->GetParam("angle")->AsFloat(0.0f)*Math::PI/180.0f, + line->GetParam("mode")->AsInt(0), + line->GetParam("debug")->AsBool(false)); } continue; } - - if (Cmd(line, "MapZoom") && !resetObject) + + if (line->GetCommand() == "MapZoom" && !resetObject) { - m_map->ZoomMap(OpFloat(line, "factor", 2.0f)); - m_map->MapEnable(OpInt(line, "enable", 1)); + m_map->ZoomMap(line->GetParam("factor")->AsFloat(2.0f)); + m_map->MapEnable(line->GetParam("enable")->AsBool(true)); continue; } - - if (Cmd(line, "MaxFlyingHeight") && !resetObject) + + if (line->GetCommand() == "MaxFlyingHeight" && !resetObject) { - m_terrain->SetFlyingMaxHeight(OpFloat(line, "max", 280.0f)*g_unit); + m_terrain->SetFlyingMaxHeight(line->GetParam("max")->AsFloat(280.0f)*g_unit); continue; } - - if (Cmd(line, "AddFlyingHeight") && !resetObject) + + if (line->GetCommand() == "AddFlyingHeight" && !resetObject) { - m_terrain->AddFlyingLimit(OpPos(line, "center")*g_unit, - OpFloat(line, "extRadius", 20.0f)*g_unit, - OpFloat(line, "intRadius", 10.0f)*g_unit, - OpFloat(line, "maxHeight", 200.0f)); + m_terrain->AddFlyingLimit(line->GetParam("center")->AsPoint()*g_unit, + line->GetParam("extRadius")->AsFloat(20.0f)*g_unit, + line->GetParam("intRadius")->AsFloat(10.0f)*g_unit, + line->GetParam("maxHeight")->AsFloat(200.0f)); continue; } - - if (Cmd(line, "Camera")) + + if (line->GetCommand() == "Camera") { - m_camera->Init(OpDir(line, "eye")*g_unit, - OpDir(line, "lookat")*g_unit, - resetObject?0.0f:OpFloat(line, "delay", 0.0f)); - - if (OpInt(line, "fadeIn", 0) == 1) + m_camera->Init(line->GetParam("eye")->AsPoint(Math::Vector(0.0f, 0.0f, 0.0f))*g_unit, + line->GetParam("lookat")->AsPoint(Math::Vector(0.0f, 0.0f, 0.0f))*g_unit, + resetObject ? 0.0f : line->GetParam("delay")->AsFloat(0.0f)); + + if (line->GetParam("fadeIn")->AsBool(false)) m_camera->StartOver(Gfx::CAM_OVER_EFFECT_FADEIN_WHITE, Math::Vector(0.0f, 0.0f, 0.0f), 1.0f); - - m_camera->SetFixDirection(OpFloat(line, "fixDirection", 0.25f)*Math::PI); + + m_camera->SetFixDirection(line->GetParam("fixDirection")->AsFloat(0.25f)*Math::PI); continue; } - - if (Cmd(line, "EndMissionTake") && !resetObject && m_controller == nullptr) + + if (line->GetCommand() == "EndMissionTake" && !resetObject && m_controller == nullptr) { int i = m_endTakeTotal; if (i < 10) { - m_endTake[i].pos = OpPos(line, "pos")*g_unit; - m_endTake[i].dist = OpFloat(line, "dist", (m_version < 2 ? 8.0f : 100.0f))*g_unit; - m_endTake[i].type = OpTypeObject(line, "type", OBJECT_NULL); - m_endTake[i].min = OpInt(line, "min", 1); - m_endTake[i].max = OpInt(line, "max", 9999); + m_endTake[i].pos = line->GetParam("pos")->AsPoint(Math::Vector(0.0f, 0.0f, 0.0f))*g_unit; + m_endTake[i].dist = line->GetParam("dist")->AsFloat(m_version < 2 ? 8.0f : 100.0f)*g_unit; + m_endTake[i].type = line->GetParam("type")->AsObjectType(OBJECT_NULL); + m_endTake[i].min = line->GetParam("min")->AsInt(1); + m_endTake[i].max = line->GetParam("max")->AsInt(9999); if (m_version >= 2) { - m_endTake[i].powermin = OpFloat(line, "powermin", -1); - m_endTake[i].powermax = OpFloat(line, "powermax", 100); - m_endTake[i].tool = OpTool(line, "tool"); - m_endTake[i].drive = OpDrive(line, "drive"); + 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); } else { @@ -4925,93 +4799,91 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) m_endTake[i].tool = TOOL_OTHER; m_endTake[i].drive = DRIVE_OTHER; } - m_endTake[i].lost = OpInt(line, "lost", -1); - m_endTake[i].immediat = OpInt(line, "immediat", 0); - OpString(line, "message", m_endTake[i].message); + m_endTake[i].lost = line->GetParam("lost")->AsInt(-1); + m_endTake[i].immediat = line->GetParam("immediat")->AsBool(false); + strcpy(m_endTake[i].message, line->GetParam("message")->AsString("").c_str()); //TODO: Really, ending mission on message()? Is this used anywhere? Do we need that? m_endTakeTotal ++; } continue; } - if (Cmd(line, "EndMissionDelay") && !resetObject && m_controller == nullptr) + if (line->GetCommand() == "EndMissionDelay" && !resetObject && m_controller == nullptr) { - m_endTakeWinDelay = OpFloat(line, "win", 2.0f); - m_endTakeLostDelay = OpFloat(line, "lost", 2.0f); + m_endTakeWinDelay = line->GetParam("win")->AsFloat(2.0f); + m_endTakeLostDelay = line->GetParam("lost")->AsFloat(2.0f); continue; } - if (Cmd(line, "EndMissionResearch") && !resetObject && m_controller == nullptr) + if (line->GetCommand() == "EndMissionResearch" && !resetObject && m_controller == nullptr) //TODO: Is this used anywhere? { - m_endTakeResearch |= OpResearch(line, "type"); + m_endTakeResearch |= line->GetParam("type")->AsResearchFlag(); continue; } - if (Cmd(line, "EndMissionNever") && !resetObject && m_controller == nullptr) + if (line->GetCommand() == "EndMissionNever" && !resetObject && m_controller == nullptr) { m_endTakeNever = true; continue; } - - if (Cmd(line, "ObligatoryToken") && !resetObject) + + if (line->GetCommand() == "ObligatoryToken" && !resetObject) //NOTE: This was used only in CeeBot, maybe we should add this to some Colobot exercises? { int i = m_obligatoryTotal; - if (i < 100) + if (i < 100) //TODO: remove the limit { - OpString(line, "text", m_obligatoryToken[i]); + strcpy(m_obligatoryToken[i], line->GetParam("text")->AsString().c_str()); m_obligatoryTotal ++; } continue; } - - if (Cmd(line, "ProhibitedToken") && !resetObject) + + if (line->GetCommand() == "ProhibitedToken" && !resetObject) //NOTE: This was used only in CeeBot, maybe we should add this to some Colobot exercises? { int i = m_prohibitedTotal; - if (i < 100) + if (i < 100) //TODO: remove the limit { - OpString(line, "text", m_prohibitedToken[i]); + strcpy(m_prohibitedToken[i], line->GetParam("text")->AsString().c_str()); m_prohibitedTotal ++; } continue; } - - if (Cmd(line, "EnableBuild") && !resetObject) + + if (line->GetCommand() == "EnableBuild" && !resetObject) { - g_build |= OpBuild(line, "type"); + g_build |= line->GetParam("type")->AsBuildFlag(); continue; } - - if (Cmd(line, "EnableResearch") && !resetObject) + + if (line->GetCommand() == "EnableResearch" && !resetObject) { - g_researchEnable |= OpResearch(line, "type"); + g_researchEnable |= line->GetParam("type")->AsResearchFlag(); continue; } - - if (Cmd(line, "DoneResearch") && read[0] == 0 && !resetObject) // not loading file? + + if (line->GetCommand() == "DoneResearch" && read[0] == 0 && !resetObject) // not loading file? { - g_researchDone |= OpResearch(line, "type"); + g_researchDone |= line->GetParam("type")->AsResearchFlag(); continue; } - - if (Cmd(line, "NewScript") && !resetObject) + + if (line->GetCommand() == "NewScript" && !resetObject) { - OpString(line, "name", name); - AddNewScriptName(OpTypeObject(line, "type", OBJECT_NULL), name); + char name[200]; + strcpy(name, line->GetParam("name")->AsPath("").c_str()); //TODO: don't make this relative to ai/ + AddNewScriptName(line->GetParam("type")->AsObjectType(OBJECT_NULL), name); continue; } - - if (line[0] == '\n') continue; // Ignore empty lines - if (line[0] == '\0') continue; // Ignore empty lines - if (read[0] != 0) continue; // Ignore when loading saved game - - GetLogger()->Error("Syntax error in file '%s' (line %d): Unknown command: %s", filename, lineNum, line); // Don't add \n at the end of log message - it's included in line variable + + if(read[0] != 0) continue; // ignore errors when loading saevd game (TODO: don't report ones that are just not loaded when loading saved game) + if(resetObject) continue; // ignore when reseting just objects (TODO: see above) + + throw CLevelParserException("Unknown command: '"+line->GetCommand()+"' in "+line->GetLevel()->GetFilename()+":"+std::to_string(line->GetLineNumber())); } - stream.close(); - if (read[0] == 0) CompileScript(soluce); // compiles all scripts - if (strcmp(base, "scene") == 0 && !resetObject) // mission? + if (strcmp(base, "missions") == 0 && !resetObject) // mission? WriteFreeParam(); - if (strcmp(base, "free") == 0 && !resetObject) // free play? + if (strcmp(base, "freemissions") == 0 && !resetObject) // free play? { g_researchDone = m_freeResearch; @@ -6541,20 +6413,28 @@ void CRobotMain::ResetCreate() m_camera->SetType(Gfx::CAM_TYPE_DIALOG); - CreateScene(m_dialog->GetSceneSoluce(), false, true); + try { + CreateScene(m_dialog->GetSceneSoluce(), false, true); - if (!GetNiceReset()) return; + if (!GetNiceReset()) return; - for (int i = 0; i < 1000000; i++) - { - CObject* obj = static_cast(iMan->SearchInstance(CLASS_OBJECT, i)); - if (obj == nullptr) break; + for (int i = 0; i < 1000000; i++) + { + CObject* obj = static_cast(iMan->SearchInstance(CLASS_OBJECT, i)); + if (obj == nullptr) break; - ResetCap cap = obj->GetResetCap(); - if (cap == RESET_NONE) continue; + ResetCap cap = obj->GetResetCap(); + if (cap == RESET_NONE) continue; - Gfx::CPyro* pyro = new Gfx::CPyro(); - pyro->Create(Gfx::PT_RESET, obj); + Gfx::CPyro* pyro = new Gfx::CPyro(); + pyro->Create(Gfx::PT_RESET, obj); + } + } + catch(const CLevelParserException& e) + { + CLogger::GetInstancePointer()->Error("An error occured while trying to reset scene\n"); + CLogger::GetInstancePointer()->Error("%s\n", e.what()); + ChangePhase(PHASE_TERM); } } -- cgit v1.2.3-1-g7c22 From de375548ade0015f6466fae74dc1fe9bba7c8357 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Fri, 26 Sep 2014 20:53:11 +0200 Subject: Userlevel listing --- src/object/robotmain.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'src/object/robotmain.cpp') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index ce7f8d0..315ffe1 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -3874,7 +3874,6 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) int rank = m_dialog->GetSceneRank(); const char* read = m_dialog->GetSceneRead().c_str(); const char* stack = m_dialog->GetStackRead().c_str(); - m_dialog->SetUserDir(base, rank); m_fixScene = fixScene; @@ -7137,16 +7136,7 @@ void CRobotMain::DisplayError(Error err, Math::Vector goal, float height, float m_displayText->DisplayError(err, goal, height, dist, time); } -void CRobotMain::InjectLevelDir(std::string& path, const std::string defaultDir) +std::string& CRobotMain::GetUserLevelName(int id) { - std::string oldPath = path; - std::string lvlDir; - CRobotMain::GetInstancePointer()->BuildSceneName(lvlDir, CRobotMain::GetInstancePointer()->GetSceneName(), CRobotMain::GetInstancePointer()->GetSceneRank(), false); - boost::replace_all(path, "%lvl%", lvlDir); - if(path == oldPath) - { - path = defaultDir + "/" + path; - } - std::string langStr(1, CApplication::GetInstancePointer()->GetLanguageChar()); - boost::replace_all(path, "%lng%", langStr); + return m_dialog->GetUserLevelName(id); } -- cgit v1.2.3-1-g7c22 From c29ef4ec41cc062c4dbc14af8736c5e1c7c25f02 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sat, 27 Sep 2014 16:49:00 +0200 Subject: Fixed some warnings Removed unused variables and fixed signed/unsigned comparation warnings --- src/object/robotmain.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/object/robotmain.cpp') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 315ffe1..0fa9b0d 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -4296,8 +4296,8 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) std::string name = line->GetParam("image")->AsPath(""); //TODO: don't make this relative to textures/ if(name.find(".") == std::string::npos) name += ".png"; - int dx = line->GetParam("dx")->AsInt(1); - int dy = line->GetParam("dy")->AsInt(1); + unsigned int dx = line->GetParam("dx")->AsInt(1); + unsigned int dy = line->GetParam("dy")->AsInt(1); int tt[100]; //TODO: I have no idea how TerrainInitTextures works, but maybe we shuld remove the limit to 100? if(dx*dy > 100) @@ -4308,7 +4308,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) if(table.size() > dx*dy) throw CLevelParserException("In TerrainInitTextures: table size must be dx*dy"); - for (int i = 0; i < dx*dy; i++) + for (unsigned int i = 0; i < dx*dy; i++) { if(i >= table.size()) { @@ -4318,7 +4318,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) } } } else { - for (int i = 0; i < dx*dy; i++) + for (unsigned int i = 0; i < dx*dy; i++) { tt[i] = 0; } @@ -4373,7 +4373,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) if(id_array.size() > 50) throw CLevelParserException("In TerrainLevel: id array size must be < 50"); - int i = 0; + unsigned int i = 0; while (i < 50) { id[i] = id_array[i]->AsInt(); @@ -4528,7 +4528,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) // Sets the parameters of the command line. if(line->GetParam("cmdline")->IsDefined()) { const std::vector& cmdline = line->GetParam("cmdline")->AsArray(); - for (int i = 0; i < OBJECTMAXCMDLINE && i < cmdline.size(); i++) //TODO: get rid of the limit + for (unsigned int i = 0; i < OBJECTMAXCMDLINE && i < cmdline.size(); i++) //TODO: get rid of the limit { obj->SetCmdLine(i, cmdline[i]->AsFloat()); } @@ -4569,7 +4569,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) if (motion != nullptr && line->GetParam("param")->IsDefined()) { const std::vector& p = line->GetParam("param")->AsArray(); - for (int i = 0; i < 10 && i < p.size(); i++) + for (unsigned int i = 0; i < 10 && i < p.size(); i++) { motion->SetParam(i, p[i]->AsFloat()); } -- cgit v1.2.3-1-g7c22 From 8fab044bcdafa0637c8a9b824f9ac81ea95db7ec Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sat, 27 Sep 2014 17:16:58 +0200 Subject: Removed more unused variables --- src/object/robotmain.cpp | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'src/object/robotmain.cpp') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 0fa9b0d..8496d7d 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -658,12 +658,6 @@ CRobotMain::CRobotMain(CApplication* app, bool loadProfile) m_selectObject = 0; m_infoUsed = 0; - m_beginObject = false; - m_terrainGenerate = false; - m_terrainInit = false; - m_terrainInitTextures = false; - m_terrainCreate = false; - m_version = 1; m_controller = nullptr; m_retroStyle = false; @@ -3945,12 +3939,6 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) strcpy(m_scriptName, scriptNameStr.c_str()); m_scriptFile[0] = 0; - m_beginObject = false; - m_terrainGenerate = false; - m_terrainInit = false; - m_terrainInitTextures = false; - m_terrainCreate = false; - m_version = 1; m_retroStyle = false; @@ -4336,7 +4324,6 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) if (line->GetCommand() == "TerrainInit" && !resetObject) { m_terrain->InitMaterials(line->GetParam("id")->AsInt(1)); - m_terrainInit = true; continue; } -- cgit v1.2.3-1-g7c22 From 32504be8a95e09736a84bdacd873d48fa971c055 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sat, 27 Sep 2014 17:46:52 +0200 Subject: Fixed TerrainLevel bug --- src/object/robotmain.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/object/robotmain.cpp') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 8496d7d..5499cc9 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -4367,6 +4367,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) i++; if(i >= id_array.size()) break; } + id[i] = 0; } m_terrain->GenerateMaterials(id, -- cgit v1.2.3-1-g7c22 From b3fa72c0071b965ffe5f4b1d68e9fb5d0cd99dcd Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sat, 27 Sep 2014 18:26:29 +0200 Subject: Moved effect??.png textures and made pos= in GroundSpot optional --- src/object/robotmain.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/object/robotmain.cpp') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 5499cc9..6fda290 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -4689,7 +4689,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) rank = m_engine->CreateGroundSpot(); if (rank != -1) { - m_engine->SetObjectGroundSpotPos(rank, line->GetParam("pos")->AsPoint()*g_unit); + m_engine->SetObjectGroundSpotPos(rank, line->GetParam("pos")->AsPoint(Math::Vector(0.0f, 0.0f, 0.0f))*g_unit); m_engine->SetObjectGroundSpotRadius(rank, line->GetParam("radius")->AsFloat(10.0f)*g_unit); m_engine->SetObjectGroundSpotColor(rank, line->GetParam("color")->AsColor(Gfx::Color(0.533f, 0.533f, 0.533f, 0.533f))); m_engine->SetObjectGroundSpotSmooth(rank, line->GetParam("smooth")->AsFloat(1.0f)); @@ -5102,12 +5102,12 @@ void CRobotMain::ChangeColor() // PARTIPLOUF0 and PARTIDROP : ts = Math::Point(0.500f, 0.500f); ti = Math::Point(0.875f, 0.750f); - m_engine->ChangeTextureColor("textures/interface/effect00.png", m_colorRefWater, m_colorNewWater, colorRef2, colorNew2, 0.20f, -1.0f, ts, ti, 0, m_colorShiftWater, true); + m_engine->ChangeTextureColor("textures/effect00.png", m_colorRefWater, m_colorNewWater, colorRef2, colorNew2, 0.20f, -1.0f, ts, ti, 0, m_colorShiftWater, true); // PARTIFLIC : ts = Math::Point(0.00f, 0.75f); ti = Math::Point(0.25f, 1.00f); - m_engine->ChangeTextureColor("textures/interface/effect02.png", m_colorRefWater, m_colorNewWater, colorRef2, colorNew2, 0.20f, -1.0f, ts, ti, 0, m_colorShiftWater, true); + m_engine->ChangeTextureColor("textures/effect02.png", m_colorRefWater, m_colorNewWater, colorRef2, colorNew2, 0.20f, -1.0f, ts, ti, 0, m_colorShiftWater, true); } //! Updates the number of unnecessary objects -- cgit v1.2.3-1-g7c22 From ad79babbc135ecc83a43391bbc026fd038efc290 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sat, 27 Sep 2014 18:34:08 +0200 Subject: Made proxyDistance optional --- src/object/robotmain.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/object/robotmain.cpp') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 6fda290..51af57c 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -4532,8 +4532,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) obj->SetIgnoreBuildCheck(line->GetParam("ignoreBuildCheck")->AsBool(false)); obj->SetEnable(line->GetParam("enable")->AsBool(true)); obj->SetProxyActivate(line->GetParam("proxyActivate")->AsBool(false)); - if(line->GetParam("proxyActivate")->AsBool(false)) - obj->SetProxyDistance(line->GetParam("proxyDistance")->AsFloat()*g_unit); + obj->SetProxyDistance(line->GetParam("proxyDistance")->AsFloat(15.0f)*g_unit); obj->SetRange(line->GetParam("range")->AsFloat(30.0f)); obj->SetShield(line->GetParam("shield")->AsFloat(1.0f)); obj->SetMagnifyDamage(line->GetParam("magnifyDamage")->AsFloat(1.0f)); -- cgit v1.2.3-1-g7c22 From f2c6b322dd3d909fe7928a35d4744992ab17adc1 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sun, 28 Sep 2014 19:25:28 +0200 Subject: Replaced std::to_string with boost::lexical_cast MXE has problems with std::to_string --- src/object/robotmain.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/object/robotmain.cpp') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 51af57c..a409aa0 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -4495,7 +4495,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) // Puts information in terminal (OBJECT_INFO). for (int i = 0; i < OBJECTMAXINFO; i++) { - std::string op = "info"+std::to_string(i+1); + std::string op = "info"+boost::lexical_cast(i+1); if(!line->GetParam(op)->IsDefined()) break; std::string text = line->GetParam(op)->AsString(); std::size_t p = text.find_first_of("="); @@ -4568,7 +4568,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) { for (int i = 0; i < 10; i++) { - std::string op = "script"+std::to_string(i+1); // script1..script10 + std::string op = "script"+boost::lexical_cast(i+1); // script1..script10 if(line->GetParam(op)->IsDefined()) { brain->SetScriptName(i, const_cast(line->GetParam(op)->AsPath("").c_str())); //TODO: don't make this relative to ai/ } @@ -4589,7 +4589,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) automat->SetType(type); for (int i = 0; i < 5; i++) { - std::string op = "autoValue"+std::to_string(i+1); // autoValue1..autoValue5 + std::string op = "autoValue"+boost::lexical_cast(i+1); // autoValue1..autoValue5 automat->SetValue(i, line->GetParam(op)->AsFloat(0.0f)); } automat->SetString(const_cast(line->GetParam("autoString")->AsString("").c_str())); @@ -4860,7 +4860,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) if(read[0] != 0) continue; // ignore errors when loading saevd game (TODO: don't report ones that are just not loaded when loading saved game) if(resetObject) continue; // ignore when reseting just objects (TODO: see above) - throw CLevelParserException("Unknown command: '"+line->GetCommand()+"' in "+line->GetLevel()->GetFilename()+":"+std::to_string(line->GetLineNumber())); + throw CLevelParserException("Unknown command: '"+line->GetCommand()+"' in "+line->GetLevel()->GetFilename()+":"+boost::lexical_cast(line->GetLineNumber())); } if (read[0] == 0) -- cgit v1.2.3-1-g7c22 From 9fd6cf54492cedd7f6231a0b1d0655120cb1c4d7 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Tue, 14 Oct 2014 15:11:37 +0200 Subject: Changed all occurences of PPC in the code to TerranovaTeam --- src/object/robotmain.cpp | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'src/object/robotmain.cpp') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index d33ea27..43b1bf9 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -1,18 +1,21 @@ -// * This file is part of the COLOBOT source code -// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch -// * -// * 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://www.gnu.org/licenses/. +/* + * This file is part of the Colobot: Gold Edition source code + * Copyright (C) 2001-2014, 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/robotmain.h" -- cgit v1.2.3-1-g7c22 From 0fb1cb11d4675f17023de43b3ffed6314ce31e8c Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sun, 19 Oct 2014 13:33:19 +0200 Subject: Changed max and default font size Min font size is 9, max is now 24 (previously 21) Default size is now 19 (previously 9) Closes #330 --- src/object/robotmain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/object/robotmain.cpp') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 43b1bf9..2ca2409 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -715,7 +715,7 @@ CRobotMain::CRobotMain(CApplication* app, bool loadProfile) FlushDisplayInfo(); - m_fontSize = 9.0f; + m_fontSize = 19.0f; m_windowPos = Math::Point(0.15f, 0.17f); m_windowDim = Math::Point(0.70f, 0.66f); -- cgit v1.2.3-1-g7c22 From c0ac60e4facfc9d7a588dd2a23fe548b7212975b Mon Sep 17 00:00:00 2001 From: krzys-h Date: Mon, 20 Oct 2014 21:15:39 +0200 Subject: Fixed save directories in things not yet refactored to use PHYSFS --- src/object/robotmain.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/object/robotmain.cpp') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 91e2d61..6ca1da1 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -5427,7 +5427,7 @@ void CRobotMain::LoadOneScript(CObject *obj, int &nbError) char filename[MAX_FNAME]; sprintf(filename, "%s/%s/%c%.3d%.3d%.1d.txt", - GetSavegameDir(), m_gamerName.c_str(), name[0], rank, objRank, i); + GetPHYSFSSavegameDir(), m_gamerName.c_str(), name[0], rank, objRank, i); brain->ReadProgram(i, filename); if (!brain->GetCompile(i)) nbError++; } @@ -5497,7 +5497,7 @@ void CRobotMain::SaveOneScript(CObject *obj) { char filename[MAX_FNAME]; sprintf(filename, "%s/%s/%c%.3d%.3d%.1d.txt", - GetSavegameDir(), m_gamerName.c_str(), name[0], rank, objRank, i); + GetPHYSFSSavegameDir(), m_gamerName.c_str(), name[0], rank, objRank, i); brain->WriteProgram(i, filename); } } @@ -6623,6 +6623,12 @@ bool CRobotMain::GetRadar() return false; } +//TODO: Use PHYSFS everywhere +const char* CRobotMain::GetPHYSFSSavegameDir() +{ + return m_dialog->GetPHYSFSSavegameDir().c_str(); +} + const char* CRobotMain::GetSavegameDir() { return m_dialog->GetSavegameDir().c_str(); -- cgit v1.2.3-1-g7c22 From 97b7c0cab173bd5556c831ad60adc146911416d0 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Mon, 20 Oct 2014 21:54:52 +0200 Subject: Fixed map turning gray after resizing window --- src/object/robotmain.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/object/robotmain.cpp') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 6ca1da1..1ad3c6d 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -959,6 +959,20 @@ void CRobotMain::LoadSceneOnStart(const std::string& name, int rank) ChangePhase(PHASE_LOADING); } +void CRobotMain::ResetAfterDeviceChanged() +{ + if(m_phase == PHASE_SETUPds || + m_phase == PHASE_SETUPgs || + m_phase == PHASE_SETUPps || + m_phase == PHASE_SETUPcs || + m_phase == PHASE_SETUPss || + m_phase == PHASE_SIMUL || + m_phase == PHASE_WIN || + m_phase == PHASE_LOST) + ChangeColor(); + UpdateMap(); +} + //! Creates the file colobot.ini at the first time void CRobotMain::CreateIni() -- cgit v1.2.3-1-g7c22 From 4c865322f0142b2ebeb89c4354c7a2f529ea4a7f Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sat, 25 Oct 2014 11:30:38 +0200 Subject: Fixed #341 --- src/object/robotmain.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/object/robotmain.cpp') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 1ad3c6d..f13ef8b 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -4416,7 +4416,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) std::string op = "autoValue"+boost::lexical_cast(i+1); // autoValue1..autoValue5 automat->SetValue(i, line->GetParam(op)->AsFloat(0.0f)); } - automat->SetString(const_cast(line->GetParam("autoString")->AsString("").c_str())); + automat->SetString(const_cast(line->GetParam("autoString")->AsPath("ai", "").c_str())); int i = line->GetParam("run")->AsInt(-1); if (i != -1) @@ -4681,7 +4681,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) continue; } - if(read[0] != 0) continue; // ignore errors when loading saevd game (TODO: don't report ones that are just not loaded when loading saved game) + if(read[0] != 0) continue; // ignore errors when loading saved game (TODO: don't report ones that are just not loaded when loading saved game) if(resetObject) continue; // ignore when reseting just objects (TODO: see above) throw CLevelParserException("Unknown command: '"+line->GetCommand()+"' in "+line->GetLevel()->GetFilename()+":"+boost::lexical_cast(line->GetLineNumber())); -- cgit v1.2.3-1-g7c22 From c12ebb1c7bd3a65c02f6383a8b450e0947d01980 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sat, 25 Oct 2014 17:16:39 +0200 Subject: Fixed NewScript (#341) --- src/object/robotmain.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/object/robotmain.cpp') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index f13ef8b..aa52791 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -4675,9 +4675,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) if (line->GetCommand() == "NewScript" && !resetObject) { - char name[200]; - strcpy(name, line->GetParam("name")->AsPath("").c_str()); //TODO: don't make this relative to ai/ - AddNewScriptName(line->GetParam("type")->AsObjectType(OBJECT_NULL), name); + AddNewScriptName(line->GetParam("type")->AsObjectType(OBJECT_NULL), const_cast(line->GetParam("name")->AsPath("ai").c_str())); continue; } -- cgit v1.2.3-1-g7c22 From ca4f1e85d2812ad715e21be96413efe155b58a84 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sun, 26 Oct 2014 18:30:56 +0100 Subject: Support for %lvl% in all commands Except for TerrainInitTextures (I'm not sure what it does but it does something weird) --- src/object/robotmain.cpp | 55 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 18 deletions(-) (limited to 'src/object/robotmain.cpp') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index aa52791..62176a1 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -3864,7 +3864,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) if (line->GetCommand() == "CacheAudio" && !resetObject && m_version >= 2) { - m_sound->CacheMusic(line->GetParam("filename")->AsPath("").c_str()); //TODO: don't make this relative to music/ + m_sound->CacheMusic(std::string("../")+line->GetParam("filename")->AsPath("music")); continue; } @@ -3882,7 +3882,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) 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); - strcpy(m_audioChange[i].music, line->GetParam("filename")->AsPath("").c_str()); //TODO: don't make this relative to music/ + 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; m_sound->CacheMusic(m_audioChange[i].music); @@ -3906,14 +3906,26 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) } else { - m_audioTrack = line->GetParam("main")->AsPath("", ""); //TODO: don't make this relative to music/ - m_audioRepeat = line->GetParam("mainRepeat")->AsBool(true); + if(line->GetParam("main")->IsDefined()) { + m_audioTrack = std::string("../")+line->GetParam("main")->AsPath("music"); + m_audioRepeat = line->GetParam("mainRepeat")->AsBool(true); + } else { + m_audioTrack = ""; + } - m_satcomTrack = line->GetParam("satcom")->AsPath("", ""); //TODO: don't make this relative to music/ - m_satcomRepeat = line->GetParam("satcomRepeat")->AsBool(true); + if(line->GetParam("satcom")->IsDefined()) { + m_satcomTrack = std::string("../")+line->GetParam("satcom")->AsPath("music"); + m_satcomRepeat = line->GetParam("satcomRepeat")->AsBool(true); + } else { + m_satcomTrack = ""; + } - m_editorTrack = line->GetParam("editor")->AsPath("", ""); //TODO: don't make this relative to music/ - m_editorRepeat = line->GetParam("editorRepeat")->AsBool(true); + if(line->GetParam("editor")->IsDefined()) { + m_editorTrack = std::string("../")+line->GetParam("editor")->AsPath("music"); + m_editorRepeat = line->GetParam("editorRepeat")->AsBool(true); + } else { + m_editorTrack = ""; + } } if (m_audioTrack != "") m_sound->CacheMusic(m_audioTrack); if (m_satcomTrack != "") m_sound->CacheMusic(m_satcomTrack); @@ -3975,7 +3987,10 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) if (line->GetCommand() == "Background" && !resetObject) { - m_engine->SetBackground(line->GetParam("image")->AsPath("", "").c_str(), //TODO: don't make this relative to textures/ + std::string path = ""; + if(line->GetParam("image")->IsDefined()) + path = "../"+line->GetParam("image")->AsPath("textures"); + m_engine->SetBackground(path.c_str(), line->GetParam("up")->AsColor(Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f)), line->GetParam("down")->AsColor(Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f)), line->GetParam("cloudUp")->AsColor(Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f)), @@ -3996,17 +4011,17 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) line->GetParam("dim")->AsFloat(0.2f), line->GetParam("speed")->AsFloat(0.0f), line->GetParam("dir")->AsFloat(0.0f), - line->GetParam("image")->AsPath(""), //TODO: don't make this relative to textures/ + "../"+line->GetParam("image")->AsPath("textures"), Math::Point(uv1.x, uv1.z), Math::Point(uv2.x, uv2.z), - line->GetParam("image")->AsPath("").find("planet") != std::string::npos // TODO: add transparent op or modify textures + line->GetParam("image")->AsPath("textures").find("planet") != std::string::npos // TODO: add transparent op or modify textures ); continue; } if (line->GetCommand() == "ForegroundName" && !resetObject) { - m_engine->SetForegroundName(line->GetParam("image")->AsPath("")); //TODO: don't make this relative to textures/ + m_engine->SetForegroundName("../"+line->GetParam("image")->AsPath("textures")); continue; } @@ -4069,7 +4084,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) pos.z = pos.x; m_water->Create(line->GetParam("air")->AsWaterType(Gfx::WATER_TT), line->GetParam("water")->AsWaterType(Gfx::WATER_TT), - line->GetParam("image")->AsPath(""), //TODO: don't make this relative to textures/ + "../"+line->GetParam("image")->AsPath("textures"), line->GetParam("diffuse")->AsColor(Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f)), line->GetParam("ambient")->AsColor(Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f)), line->GetParam("level")->AsFloat(100.0f)*g_unit, @@ -4088,7 +4103,10 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) if (line->GetCommand() == "TerrainCloud" && !resetObject) { - m_cloud->Create(line->GetParam("image")->AsPath("", ""), //TODO: don't make this relative to textures/ + std::string path = ""; + if(line->GetParam("image")->IsDefined()) + path = "../"+line->GetParam("image")->AsPath("textures"); + m_cloud->Create(path, line->GetParam("diffuse")->AsColor(Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f)), line->GetParam("ambient")->AsColor(Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f)), line->GetParam("level")->AsFloat(500.0f)*g_unit); @@ -4153,9 +4171,10 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) if (line->GetCommand() == "TerrainMaterial" && !resetObject) { - std::string name = line->GetParam("image")->AsPath(""); //TODO: don't make this relative to textures/ + std::string name = line->GetParam("image")->AsPath("textures"); if(name.find(".") == std::string::npos) name += ".png"; + name = "../"+name; /*TODO: ??? if (strstr(name, "%user%") != 0) { @@ -4229,7 +4248,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) CBrain* brain = m_controller->GetBrain(); if (brain != nullptr) { - std::string name = line->GetParam("script")->AsPath(""); //TODO: Don't make this relative to ai/ + std::string name = "../"+line->GetParam("script")->AsPath("ai"); if (!name.empty()) brain->SetScriptName(0, const_cast(name.c_str())); brain->SetScriptRun(0); @@ -4394,7 +4413,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) { std::string op = "script"+boost::lexical_cast(i+1); // script1..script10 if(line->GetParam(op)->IsDefined()) { - brain->SetScriptName(i, const_cast(line->GetParam(op)->AsPath("").c_str())); //TODO: don't make this relative to ai/ + brain->SetScriptName(i, const_cast(("../"+line->GetParam(op)->AsPath("ai")).c_str())); } } @@ -4539,7 +4558,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) if (m_mapImage) { Math::Vector offset; - strcpy(m_mapFilename, line->GetParam("filename")->AsPath("").c_str()); //TODO: don't make this relative to textures/ + strcpy(m_mapFilename, ("../"+line->GetParam("filename")->AsPath("textures")).c_str()); offset = line->GetParam("offset")->AsPoint(Math::Vector(0.0f, 0.0f, 0.0f)); m_map->SetFixParam(line->GetParam("zoom")->AsFloat(1.0f), offset.x, offset.z, -- cgit v1.2.3-1-g7c22 From d6e88a07b08585d6a6f151d34a07d8bca78711ea Mon Sep 17 00:00:00 2001 From: krzys-h Date: Mon, 27 Oct 2014 21:15:14 +0100 Subject: Support for %lvl% in TerrainInitTextures + cleanup cleanup: * Removed CProfile::SetUserPath (unused) * Removed CProfile::GetUserBasedPath (unused) * Removed CProfile::CopyFileToTemp (i have no idea why it even existed) * Removed CopyFileListToTemp (it did the same as CopyFileToTemp but for multiple files, wasn't even fully implemented) --- src/object/robotmain.cpp | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'src/object/robotmain.cpp') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 62176a1..012b08a 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -4123,7 +4123,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) if (line->GetCommand() == "TerrainInitTextures" && !resetObject) { - std::string name = line->GetParam("image")->AsPath(""); //TODO: don't make this relative to textures/ + std::string name = "../"+line->GetParam("image")->AsPath("textures"); if(name.find(".") == std::string::npos) name += ".png"; unsigned int dx = line->GetParam("dx")->AsInt(1); @@ -4154,11 +4154,6 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) } } - /*TODO: ??? - if (strstr(name, "%user%") != 0) - CopyFileListToTemp(name, tt, dx*dy); - */ - m_terrain->InitTextures(name.c_str(), tt, dx, dy); continue; } @@ -4175,12 +4170,6 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) if(name.find(".") == std::string::npos) name += ".png"; name = "../"+name; - /*TODO: ??? - if (strstr(name, "%user%") != 0) - { - GetProfile().CopyFileToTemp(std::string(name)); - } - */ m_terrain->AddMaterial(line->GetParam("id")->AsInt(0), name.c_str(), -- cgit v1.2.3-1-g7c22 From 11854dc89ed5925d39634de12048cee9e0f7547a Mon Sep 17 00:00:00 2001 From: krzys-h Date: Mon, 27 Oct 2014 21:49:03 +0100 Subject: Fixed script saving (issue #348) --- src/object/robotmain.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/object/robotmain.cpp') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 012b08a..adbe81d 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -5465,9 +5465,12 @@ void CRobotMain::LoadFileScript(CObject *obj, const char* filename, int objRank, ObjectType type = obj->GetType(); if (type == OBJECT_HUMAN) return; - + + std::string fnstr = filename; + boost::replace_all(fnstr, m_dialog->GetSavegameDir(), m_dialog->GetPHYSFSSavegameDir()); //TODO: Refactor to get physfs path here + //TODO: Refactor to std::string char fn[MAX_FNAME]; - strcpy(fn, filename); + strcpy(fn, fnstr.c_str()); char* ldir = SearchLastDir(fn); if (ldir == 0) return; @@ -5534,8 +5537,11 @@ void CRobotMain::SaveFileScript(CObject *obj, const char* filename, int objRank) ObjectType type = obj->GetType(); if (type == OBJECT_HUMAN) return; + std::string fnstr = filename; + boost::replace_all(fnstr, m_dialog->GetSavegameDir(), m_dialog->GetPHYSFSSavegameDir()); //TODO: Refactor to get physfs path here + //TODO: Refactor to std::string char fn[MAX_FNAME]; - strcpy(fn, filename); + strcpy(fn, fnstr.c_str()); char* ldir = SearchLastDir(fn); if (ldir == 0) return; -- cgit v1.2.3-1-g7c22 From d91569e165083a7c12b1c672713a9725d80c261c Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sat, 11 Jan 2014 17:51:13 +0100 Subject: Showing coordinates in stats menu (F12/showstat); removed "showpos" cheat Issue #277 Conflicts: src/object/cheat.cpp src/object/robotmain.cpp src/object/robotmain.h --- src/object/robotmain.cpp | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'src/object/robotmain.cpp') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index adbe81d..90faceb 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -673,7 +673,6 @@ CRobotMain::CRobotMain(CApplication* app, bool loadProfile) m_editFull = false; m_hilite = false; m_freePhoto = false; - m_showPos = false; m_selectInsect = false; m_showSoluce = false; @@ -2080,12 +2079,6 @@ void CRobotMain::ExecuteCmd(char *cmd) return; } - if (strcmp(cmd, "showpos") == 0) - { - m_showPos = !m_showPos; - return; - } - if (strcmp(cmd, "selectinsect") == 0) { m_selectInsect = !m_selectInsect; @@ -3369,16 +3362,11 @@ void CRobotMain::AbortMovie() //! Updates the text information void CRobotMain::UpdateInfoText() { - if (m_showPos) + CObject* obj = GetSelect(); + if (obj != nullptr) { - CObject* obj = GetSelect(); - if (obj != nullptr) - { - Math::Vector pos = obj->GetPosition(0); - char info[100]; - sprintf(info, "Pos = %.2f ; %.2f", pos.x/g_unit, pos.z/g_unit); - //TODO: m_engine->SetInfoText(4, info); - } + Math::Vector pos = obj->GetPosition(0); + m_engine->SetStatisticPos(pos); } } -- cgit v1.2.3-1-g7c22 From 61e06149c65fbc61c6d927f527195a9b4a8154dc Mon Sep 17 00:00:00 2001 From: krzys-h Date: Wed, 29 Oct 2014 16:08:45 +0100 Subject: Fixed position updating --- src/object/robotmain.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/object/robotmain.cpp') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 90faceb..6ebd34c 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -1416,6 +1416,11 @@ bool CRobotMain::ProcessEvent(Event &event) m_interface->EventProcess(event); if (m_displayInfo != nullptr) // current edition? m_displayInfo->EventProcess(event); + + if (m_phase == PHASE_SIMUL) + { + UpdateInfoText(); + } return EventFrame(event); } @@ -1500,8 +1505,6 @@ bool CRobotMain::ProcessEvent(Event &event) // Simulation phase of the game if (m_phase == PHASE_SIMUL) { - UpdateInfoText(); - if (!m_editFull) m_camera->EventProcess(event); -- cgit v1.2.3-1-g7c22 From 6d2fd18b419ddc202fa14cb14c98e8f3d5ecf646 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Wed, 29 Oct 2014 17:53:46 +0100 Subject: Implemented mission timer --- src/object/robotmain.cpp | 67 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 59 insertions(+), 8 deletions(-) (limited to 'src/object/robotmain.cpp') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 6ebd34c..10e7648 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -645,6 +645,10 @@ CRobotMain::CRobotMain(CApplication* app, bool loadProfile) m_time = 0.0f; m_gameTime = 0.0f; m_checkEndTime = 0.0f; + + m_missionTimerEnabled = false; + m_missionTimerStarted = false; + m_missionTimer = 0.0f; m_phase = PHASE_NAME; m_cameraRank = -1; @@ -1087,6 +1091,9 @@ void CRobotMain::ResetKeyStates() //! Changes phase void CRobotMain::ChangePhase(Phase phase) { + m_missionTimerEnabled = m_missionTimerStarted = false; + m_missionTimer = 0.0f; + if (m_phase == PHASE_SIMUL) // ends a simulation? { SaveAllScript(); @@ -1417,10 +1424,7 @@ bool CRobotMain::ProcessEvent(Event &event) if (m_displayInfo != nullptr) // current edition? m_displayInfo->EventProcess(event); - if (m_phase == PHASE_SIMUL) - { - UpdateInfoText(); - } + UpdateInfoText(); return EventFrame(event); } @@ -1754,12 +1758,14 @@ bool CRobotMain::ProcessEvent(Event &event) break; case EVENT_WIN: + m_missionTimerEnabled = m_missionTimerStarted = false; ChangePhase(PHASE_WIN); if(m_exitAfterMission) m_eventQueue->AddEvent(Event(EVENT_QUIT)); break; case EVENT_LOST: + m_missionTimerEnabled = m_missionTimerStarted = false; ChangePhase(PHASE_LOST); if(m_exitAfterMission) m_eventQueue->AddEvent(Event(EVENT_QUIT)); @@ -3365,12 +3371,16 @@ void CRobotMain::AbortMovie() //! Updates the text information void CRobotMain::UpdateInfoText() { - CObject* obj = GetSelect(); - if (obj != nullptr) + if (m_phase == PHASE_SIMUL) { - Math::Vector pos = obj->GetPosition(0); - m_engine->SetStatisticPos(pos); + CObject* obj = GetSelect(); + if (obj != nullptr) + { + Math::Vector pos = obj->GetPosition(0); + m_engine->SetStatisticPos(pos); + } } + m_engine->SetTimerDisplay(m_missionTimerEnabled && m_missionTimerStarted ? TimeFormat(m_missionTimer) : ""); } @@ -3394,6 +3404,9 @@ bool CRobotMain::EventFrame(const Event &event) m_displayText->DisplayError(INFO_BEGINSATCOM, Math::Vector(0.0f,0.0f,0.0f)); m_beginSatCom = true; // message appears } + + if(!m_movieLock && m_pause->GetPause() == PAUSE_NONE && m_missionTimerStarted) + m_missionTimer += event.rTime; m_water->EventProcess(event); m_cloud->EventProcess(event); @@ -3760,6 +3773,11 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) m_missionResult = ERR_MISSION_NOTERM; } + //NOTE: Reset timer always, even when only resetting object positions + m_missionTimerEnabled = false; + m_missionTimerStarted = false; + m_missionTimer = 0.0f; + CLevelParser* level = new CLevelParser(base, rank/100, rank%100); level->Load(); @@ -3853,6 +3871,15 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) continue; } + if (line->GetCommand() == "MissionTimer") + { + m_missionTimerEnabled = line->GetParam("enabled")->AsBool(); + if(!line->GetParam("program")->AsBool(false)) { + m_missionTimerStarted = true; + } + continue; + } + if (line->GetCommand() == "CacheAudio" && !resetObject && m_version >= 2) { m_sound->CacheMusic(std::string("../")+line->GetParam("filename")->AsPath("music")); @@ -6342,12 +6369,14 @@ Error CRobotMain::CheckEndMission(bool frame) if (m_missionResult == INFO_LOST) //mission lost? { m_displayText->DisplayError(INFO_LOST, Math::Vector(0.0f,0.0f,0.0f)); + m_missionTimerEnabled = m_missionTimerStarted = false; m_winDelay = 0.0f; if (m_lostDelay == 0) m_lostDelay = m_endTakeLostDelay; m_displayText->SetEnable(false); } if (m_missionResult == INFO_LOSTq) //mission lost? { + m_missionTimerEnabled = m_missionTimerStarted = false; m_winDelay = 0.0f; if (m_lostDelay == 0) m_lostDelay = 0.1f; m_displayText->SetEnable(false); @@ -6355,6 +6384,11 @@ Error CRobotMain::CheckEndMission(bool frame) if (frame && m_base) return ERR_MISSION_NOTERM; if (m_missionResult == ERR_OK) { //mission win? m_displayText->DisplayError(INFO_WIN, Math::Vector(0.0f,0.0f,0.0f)); + if(m_missionTimerEnabled && m_missionTimerStarted) { + CLogger::GetInstancePointer()->Info("Mission time: %s\n", TimeFormat(m_missionTimer).c_str()); + m_displayText->DisplayText(("Time: "+TimeFormat(m_missionTimer)).c_str(), Math::Vector(0.0f,0.0f,0.0f)); + } + m_missionTimerEnabled = m_missionTimerStarted = false; if (m_winDelay == 0) m_winDelay = m_endTakeWinDelay; m_lostDelay = 0.0f; m_displayText->SetEnable(false); @@ -6431,6 +6465,7 @@ Error CRobotMain::CheckEndMission(bool frame) m_lostDelay = 0.1f; // lost immediately m_winDelay = 0.0f; } + m_missionTimerEnabled = m_missionTimerStarted = false; m_displayText->SetEnable(false); return INFO_LOSTq; } @@ -6442,6 +6477,7 @@ Error CRobotMain::CheckEndMission(bool frame) m_lostDelay = m_endTakeLostDelay; // lost in 6 seconds m_winDelay = 0.0f; } + m_missionTimerEnabled = m_missionTimerStarted = false; m_displayText->SetEnable(false); return INFO_LOST; } @@ -6460,6 +6496,7 @@ Error CRobotMain::CheckEndMission(bool frame) m_winDelay = m_endTakeWinDelay; // wins in x seconds m_lostDelay = 0.0f; } + m_missionTimerEnabled = m_missionTimerStarted = false; m_displayText->SetEnable(false); return ERR_OK; // mission ended } @@ -6478,6 +6515,7 @@ Error CRobotMain::CheckEndMission(bool frame) { m_winDelay = 1.0f; // wins in one second m_lostDelay = 0.0f; + m_missionTimerEnabled = m_missionTimerStarted = false; m_displayText->SetEnable(false); return ERR_OK; // mission ended } @@ -6487,6 +6525,11 @@ Error CRobotMain::CheckEndMission(bool frame) if (m_winDelay == 0.0f) { m_displayText->DisplayError(INFO_WIN, Math::Vector(0.0f,0.0f,0.0f)); + if(m_missionTimerEnabled && m_missionTimerStarted) { + CLogger::GetInstancePointer()->Info("Mission time: %s\n", TimeFormat(m_missionTimer).c_str()); + m_displayText->DisplayText(("Time: "+TimeFormat(m_missionTimer)).c_str(), Math::Vector(0.0f,0.0f,0.0f)); + } + m_missionTimerEnabled = m_missionTimerStarted = false; m_winDelay = m_endTakeWinDelay; // wins in two seconds m_lostDelay = 0.0f; } @@ -6960,3 +7003,11 @@ std::string& CRobotMain::GetUserLevelName(int id) { return m_dialog->GetUserLevelName(id); } + +void CRobotMain::StartMissionTimer() +{ + if(m_missionTimerEnabled && !m_missionTimerStarted) { + CLogger::GetInstancePointer()->Info("Starting mission timer...\n"); + m_missionTimerStarted = true; + } +} -- cgit v1.2.3-1-g7c22 From 601ea0ec87f1350ce61f7bba0b2821e359972421 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Thu, 30 Oct 2014 22:26:14 +0100 Subject: Increased mission end accuracy It whould now detect mission end immediately. We need somebody with an older computer than mine to make sure it doesn't cause FPS drop. --- src/object/robotmain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/object/robotmain.cpp') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 10e7648..ce6b9c1 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -3555,7 +3555,7 @@ bool CRobotMain::EventFrame(const Event &event) if (m_phase == PHASE_SIMUL) { - if (!m_editLock && m_checkEndTime+1.0f < m_time) + if (!m_editLock /*&& m_checkEndTime+1.0f < m_time*/) { m_checkEndTime = m_time; CheckEndMission(true); -- cgit v1.2.3-1-g7c22 From d0383ae09babc015b84997241d403b01ad40f677 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Fri, 31 Oct 2014 15:32:24 +0100 Subject: -runscene for userlevels You need to know which ID is assigned to te userlevel category (by order in "User" menu) -runscene custom101 = first userlevel from first chapter --- src/object/robotmain.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/object/robotmain.cpp') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index ce6b9c1..afdca9e 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -957,6 +957,7 @@ void CRobotMain::LoadSceneOnStart(const std::string& name, int rank) { m_exitAfterMission = true; // TODO: fix this ugly dependency :( + ChangePhase(PHASE_USER); // To load userlevel list m_dialog->SetSceneName(name.c_str()); m_dialog->SetSceneRank(rank); ChangePhase(PHASE_LOADING); -- cgit v1.2.3-1-g7c22 From 71577b7b0a4f57a34bf31a15fb52d32e926026e2 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Fri, 31 Oct 2014 20:19:33 +0100 Subject: Fixed #335 and #348 --- src/object/robotmain.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/object/robotmain.cpp') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index afdca9e..ad78e39 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -5390,9 +5390,9 @@ void CRobotMain::CompileScript(bool soluce) if (brain->GetCompile(j)) continue; std::string name = brain->GetScriptName(j); - name = "ai/"+name; if (name[0] != 0) { + name = "ai/"+name; if(! brain->ReadProgram(j, const_cast(name.c_str()))) { CLogger::GetInstancePointer()->Error("Unable to read script from file \"%s\"\n", name.c_str()); } @@ -5486,6 +5486,7 @@ void CRobotMain::LoadFileScript(CObject *obj, const char* filename, int objRank, std::string fnstr = filename; + boost::replace_all(fnstr, "\\", "/"); boost::replace_all(fnstr, m_dialog->GetSavegameDir(), m_dialog->GetPHYSFSSavegameDir()); //TODO: Refactor to get physfs path here //TODO: Refactor to std::string char fn[MAX_FNAME]; @@ -5557,6 +5558,7 @@ void CRobotMain::SaveFileScript(CObject *obj, const char* filename, int objRank) if (type == OBJECT_HUMAN) return; std::string fnstr = filename; + boost::replace_all(fnstr, "\\", "/"); boost::replace_all(fnstr, m_dialog->GetSavegameDir(), m_dialog->GetPHYSFSSavegameDir()); //TODO: Refactor to get physfs path here //TODO: Refactor to std::string char fn[MAX_FNAME]; -- cgit v1.2.3-1-g7c22 From 501cd7026be0422621e2657bb4aea842f2f7950d Mon Sep 17 00:00:00 2001 From: krzys-h Date: Fri, 31 Oct 2014 20:49:40 +0100 Subject: Fixed m_exitAfterMission --- src/object/robotmain.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/object/robotmain.cpp') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index ad78e39..cc330f6 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -1761,15 +1761,11 @@ bool CRobotMain::ProcessEvent(Event &event) case EVENT_WIN: m_missionTimerEnabled = m_missionTimerStarted = false; ChangePhase(PHASE_WIN); - if(m_exitAfterMission) - m_eventQueue->AddEvent(Event(EVENT_QUIT)); break; case EVENT_LOST: m_missionTimerEnabled = m_missionTimerStarted = false; ChangePhase(PHASE_LOST); - if(m_exitAfterMission) - m_eventQueue->AddEvent(Event(EVENT_QUIT)); break; default: @@ -6376,6 +6372,8 @@ Error CRobotMain::CheckEndMission(bool frame) m_winDelay = 0.0f; if (m_lostDelay == 0) m_lostDelay = m_endTakeLostDelay; m_displayText->SetEnable(false); + if(m_exitAfterMission) + m_eventQueue->AddEvent(Event(EVENT_QUIT)); } if (m_missionResult == INFO_LOSTq) //mission lost? { @@ -6383,6 +6381,8 @@ Error CRobotMain::CheckEndMission(bool frame) m_winDelay = 0.0f; if (m_lostDelay == 0) m_lostDelay = 0.1f; m_displayText->SetEnable(false); + if(m_exitAfterMission) + m_eventQueue->AddEvent(Event(EVENT_QUIT)); } if (frame && m_base) return ERR_MISSION_NOTERM; if (m_missionResult == ERR_OK) { //mission win? @@ -6395,6 +6395,8 @@ Error CRobotMain::CheckEndMission(bool frame) if (m_winDelay == 0) m_winDelay = m_endTakeWinDelay; m_lostDelay = 0.0f; m_displayText->SetEnable(false); + if(m_exitAfterMission) + m_eventQueue->AddEvent(Event(EVENT_QUIT)); } if (m_missionResult == ERR_MISSION_NOTERM) m_displayText->SetEnable(true); return m_missionResult; @@ -6520,6 +6522,8 @@ Error CRobotMain::CheckEndMission(bool frame) m_lostDelay = 0.0f; m_missionTimerEnabled = m_missionTimerStarted = false; m_displayText->SetEnable(false); + if(m_exitAfterMission) + m_eventQueue->AddEvent(Event(EVENT_QUIT)); return ERR_OK; // mission ended } @@ -6535,6 +6539,8 @@ Error CRobotMain::CheckEndMission(bool frame) m_missionTimerEnabled = m_missionTimerStarted = false; m_winDelay = m_endTakeWinDelay; // wins in two seconds m_lostDelay = 0.0f; + if(m_exitAfterMission) + m_eventQueue->AddEvent(Event(EVENT_QUIT)); } m_displayText->SetEnable(false); return ERR_OK; // mission ended -- cgit v1.2.3-1-g7c22 From 11a874207935f86248c0b9034a11b415ee14b1cf Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sat, 1 Nov 2014 14:02:39 +0100 Subject: #335, #348, #352 I don't know what I'm doing anymore :/ I should set up dev envrioment on Windows so I don't have to commit every time I want somebody on Windows to test if my changes work --- src/object/robotmain.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/object/robotmain.cpp') diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index cc330f6..2c9384c 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -32,6 +32,7 @@ #include "common/profile.h" #include "common/restext.h" +#include "common/resources/resourcemanager.h" #include "common/resources/inputstream.h" #include "graphics/engine/camera.h" @@ -5482,8 +5483,10 @@ void CRobotMain::LoadFileScript(CObject *obj, const char* filename, int objRank, std::string fnstr = filename; + std::string savedir = CResourceManager::GetSaveLocation()+"/"; boost::replace_all(fnstr, "\\", "/"); - boost::replace_all(fnstr, m_dialog->GetSavegameDir(), m_dialog->GetPHYSFSSavegameDir()); //TODO: Refactor to get physfs path here + boost::replace_all(savedir, "\\", "/"); + boost::replace_all(fnstr, savedir, ""); //TODO: Refactor to get physfs path here //TODO: Refactor to std::string char fn[MAX_FNAME]; strcpy(fn, fnstr.c_str()); @@ -5554,8 +5557,10 @@ void CRobotMain::SaveFileScript(CObject *obj, const char* filename, int objRank) if (type == OBJECT_HUMAN) return; std::string fnstr = filename; + std::string savedir = CResourceManager::GetSaveLocation()+"/"; boost::replace_all(fnstr, "\\", "/"); - boost::replace_all(fnstr, m_dialog->GetSavegameDir(), m_dialog->GetPHYSFSSavegameDir()); //TODO: Refactor to get physfs path here + boost::replace_all(savedir, "\\", "/"); + boost::replace_all(fnstr, savedir, ""); //TODO: Refactor to get physfs path here //TODO: Refactor to std::string char fn[MAX_FNAME]; strcpy(fn, fnstr.c_str()); -- cgit v1.2.3-1-g7c22