diff options
Diffstat (limited to 'src/object')
-rw-r--r-- | src/object/robotmain.cpp | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 83b9fc9..8108129 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" @@ -30,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" @@ -3944,8 +3945,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; @@ -3958,7 +3962,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++) @@ -4016,8 +4020,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); @@ -4028,31 +4031,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; } @@ -4309,7 +4308,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; } @@ -4340,7 +4339,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; } @@ -4999,7 +4998,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 @@ -5239,12 +5238,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("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("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 @@ -5678,11 +5677,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<char*>(name.c_str()))) { + CLogger::GetInstancePointer()->Error("Unable to read script from file \"%s\"\n", name.c_str()); } if (!brain->GetCompile(j)) nbError++; } |