More work on levels
parent
0556b5dfbc
commit
3aca1de731
|
@ -27,6 +27,7 @@ CResourceStreamBuffer::CResourceStreamBuffer(size_t buffer_size) : m_buffer_size
|
|||
}
|
||||
|
||||
m_buffer = new char[buffer_size];
|
||||
m_file = nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -436,7 +436,7 @@ bool CModelFile::ReadModel(const std::string& fileName)
|
|||
|
||||
CInputStream stream;
|
||||
stream.open(fileName.c_str());
|
||||
if (!stream.good())
|
||||
if (!stream.is_open())
|
||||
{
|
||||
GetLogger()->Error("Could not open file '%s'\n", fileName.c_str());
|
||||
return false;
|
||||
|
@ -827,7 +827,7 @@ bool CModelFile::ReadTextModel(const std::string& fileName)
|
|||
{
|
||||
CInputStream stream;
|
||||
stream.open(fileName.c_str());
|
||||
if (!stream.good())
|
||||
if (!stream.is_open())
|
||||
{
|
||||
GetLogger()->Error("Could not open file '%s'\n", fileName.c_str());
|
||||
return false;
|
||||
|
@ -1024,7 +1024,7 @@ bool CModelFile::ReadBinaryModel(const std::string& fileName)
|
|||
{
|
||||
CInputStream stream;
|
||||
stream.open(fileName.c_str());
|
||||
if (!stream.good())
|
||||
if (!stream.is_open())
|
||||
{
|
||||
GetLogger()->Error("Could not open file '%s'\n", fileName.c_str());
|
||||
return false;
|
||||
|
|
|
@ -47,7 +47,7 @@ bool CModelManager::LoadModel(const std::string& fileName, bool mirrored)
|
|||
if (CApplication::GetInstance().IsDebugModeActive(DEBUG_MODELS))
|
||||
modelFile.SetPrintDebugInfo(true);
|
||||
|
||||
if (!modelFile.ReadModel(fileName))
|
||||
if (!modelFile.ReadModel("models/" + fileName))
|
||||
{
|
||||
GetLogger()->Error("Loading model '%s' failed\n", fileName.c_str());
|
||||
return false;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
#include "common/restext.h"
|
||||
#include "common/stringutils.h"
|
||||
|
||||
#include "common/resources/inputstream.h"
|
||||
#include "common/resources/resourcemanager.h"
|
||||
|
||||
#include "graphics/engine/terrain.h"
|
||||
#include "graphics/engine/water.h"
|
||||
#include "graphics/engine/text.h"
|
||||
|
@ -50,6 +53,7 @@
|
|||
#include "ui/edit.h"
|
||||
#include "ui/list.h"
|
||||
#include "ui/displaytext.h"
|
||||
#include <test/cbot/CBot_console/CClass.h>
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -4363,7 +4367,6 @@ void CScript::GetError(std::string& error)
|
|||
|
||||
void CScript::New(Ui::CEdit* edit, const char* name)
|
||||
{
|
||||
FILE *file = NULL;
|
||||
char res[100];
|
||||
char text[100];
|
||||
char script[500];
|
||||
|
@ -4407,17 +4410,17 @@ void CScript::New(Ui::CEdit* edit, const char* name)
|
|||
if ( sf[0] != 0 ) // Load an empty program specific?
|
||||
{
|
||||
std::string filename = sf;
|
||||
file = fopen(filename.c_str(), "rb");
|
||||
if ( file != NULL )
|
||||
CInputStream stream;
|
||||
stream.open(filename);
|
||||
|
||||
if (stream.is_open())
|
||||
{
|
||||
fseek(file, 0, SEEK_END);
|
||||
len = ftell(file);
|
||||
fseek(file, 0, SEEK_SET);
|
||||
len = stream.size();
|
||||
|
||||
if ( len > 500-1 ) len = 500-1;
|
||||
fread(buffer, 1, len, file);
|
||||
stream.read(buffer, len);
|
||||
buffer[len] = 0;
|
||||
fclose(file);
|
||||
stream.close();
|
||||
|
||||
cursor1 = 0;
|
||||
i = 0;
|
||||
|
@ -4494,12 +4497,9 @@ bool CScript::SendScript(const char* text)
|
|||
|
||||
bool CScript::ReadScript(const char* filename)
|
||||
{
|
||||
FILE* file;
|
||||
Ui::CEdit* edit;
|
||||
|
||||
file = fopen(filename, "rb");
|
||||
if ( file == NULL ) return false;
|
||||
fclose(file);
|
||||
if (!CResourceManager::Exists(filename)) return false;
|
||||
|
||||
delete[] m_script;
|
||||
m_script = nullptr;
|
||||
|
|
Loading…
Reference in New Issue