remove Engine::FileLoader
This commit is contained in:
parent
89d98be780
commit
08dbe60b7b
@ -1260,52 +1260,36 @@ void Engine::drawObjects()
|
||||
}
|
||||
}
|
||||
|
||||
/******** Engine::EngineFileLoader functions ********/
|
||||
|
||||
Engine::EngineFileLoader::EngineFileLoader(Engine * engine)
|
||||
{
|
||||
m_engine = engine;
|
||||
}
|
||||
|
||||
int Engine::EngineFileLoader::getSize(const Path & path)
|
||||
int Engine::getFileSize(const char *fname)
|
||||
{
|
||||
struct stat st;
|
||||
string file_path = resolvePath(path);
|
||||
|
||||
if (file_path == "")
|
||||
return -1;
|
||||
if (stat(file_path.c_str(), &st))
|
||||
if (stat(fname, &st))
|
||||
return -2;
|
||||
return st.st_size;
|
||||
}
|
||||
|
||||
FileLoader::Buffer Engine::EngineFileLoader::load(const Path & path)
|
||||
const unsigned char *Engine::loadFile(const char *fname, unsigned int *len)
|
||||
{
|
||||
string file_path = resolvePath(path);
|
||||
int size = getSize(path);
|
||||
string file_path = locateResource(fname);
|
||||
unsigned int size = getFileSize(file_path.c_str());
|
||||
if (size > 0)
|
||||
{
|
||||
FILE * fp = fopen(file_path.c_str(), "rb");
|
||||
if (fp != NULL)
|
||||
{
|
||||
Buffer buf(size);
|
||||
int num_read = fread(buf.data, size, 1, fp);
|
||||
unsigned char *data = malloc(size);
|
||||
int num_read = fread(data, size, 1, fp);
|
||||
fclose(fp);
|
||||
if (num_read > 0)
|
||||
{
|
||||
return buf;
|
||||
if (len != NULL)
|
||||
*len = size;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Buffer(0);
|
||||
}
|
||||
|
||||
string Engine::EngineFileLoader::resolvePath(const Path & path)
|
||||
{
|
||||
string file_path = m_engine->locateResource(path.shortPath);
|
||||
if (file_path == "")
|
||||
file_path = path.fullPath;
|
||||
return file_path;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
15
src/Engine.h
15
src/Engine.h
@ -9,7 +9,6 @@
|
||||
#include <SDL.h>
|
||||
#include "OdeWorld/OdeWorld.h"
|
||||
#include "TextureCache/TextureCache.h"
|
||||
#include "FileLoader/FileLoader.h"
|
||||
#include "WFObj/WFObj.h"
|
||||
#include "AV.h"
|
||||
#include "refptr/refptr.h"
|
||||
@ -131,17 +130,6 @@ class Engine
|
||||
float m_texture_scale;
|
||||
};
|
||||
|
||||
class EngineFileLoader : public FileLoader
|
||||
{
|
||||
public:
|
||||
EngineFileLoader(Engine * engine);
|
||||
virtual int getSize(const Path & path);
|
||||
virtual Buffer load(const Path & path);
|
||||
protected:
|
||||
std::string resolvePath(const Path & path);
|
||||
Engine * m_engine;
|
||||
};
|
||||
|
||||
class PickedObject
|
||||
{
|
||||
public:
|
||||
@ -312,6 +300,8 @@ class Engine
|
||||
|
||||
protected:
|
||||
static Uint32 updateCallback(Uint32 interval, void * param);
|
||||
int getFileSize(const char *fname);
|
||||
const unsigned char *loadFile(const char *fname, unsigned int *len);
|
||||
|
||||
Uint32 updateCallback(Uint32 interval);
|
||||
void registerLibraries();
|
||||
@ -341,7 +331,6 @@ class Engine
|
||||
bool m_script_cursor_visible;
|
||||
bool m_input_grabbed;
|
||||
TextureCache m_textureCache;
|
||||
EngineFileLoader * m_fileLoader;
|
||||
lua_State * m_luaState;
|
||||
std::string m_program_path;
|
||||
std::string m_program_directory;
|
||||
|
Loading…
x
Reference in New Issue
Block a user