1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-09-15 15:02:34 +02:00

Use existing file loading method for SCM

This commit is contained in:
haphzd 2016-06-11 19:07:30 +04:00
parent c19df1d936
commit 593aa73bda
5 changed files with 8 additions and 18 deletions

View File

@ -105,7 +105,7 @@ public:
void loadHandling(const std::string& path);
SCMFile* loadSCM(const std::string& path);
SCMFile* loadSCM(const std::string& name);
void loadGXT(const std::string& name);

View File

@ -341,22 +341,12 @@ void GameData::loadHandling(const std::string& path)
l.loadHandling(path, vehicleInfo);
}
SCMFile *GameData::loadSCM(const std::string &path)
SCMFile *GameData::loadSCM(const std::string &name)
{
std::ifstream f(datpath + "/" + path);
if(! f.is_open() ) return nullptr;
f.seekg(0, std::ios_base::end);
unsigned int size = f.tellg();
f.seekg(0);
char* buff = new char[size];
f.read(buff, size);
auto scm_h = openFile(name);
SCMFile* scm = new SCMFile;
scm->loadFile(buff, size);
delete[] buff;
scm->loadFile(scm_h->data, scm_h->length);
scm_h.reset();
return scm;
}

View File

@ -218,7 +218,7 @@ void RWGame::loadGame(const std::string& savename)
newGame();
startScript("data/main.scm");
startScript("main.scm");
if(! SaveGame::loadGame(*state, savename) )
{

View File

@ -79,7 +79,7 @@ void IngameState::startTest()
void IngameState::startGame()
{
game->startScript("data/main.scm");
game->startScript("main.scm");
game->getScript()->startThread(0);
getWorld()->sound.playBackground( getWorld()->data->getDataPath() + "/audio/City.wav" );
}

View File

@ -55,7 +55,7 @@ BOOST_AUTO_TEST_CASE(test_load_game)
GameState state;
GameWorld world();
SCMOpcodes s;
auto file = Global::get().d->loadSCM("data/main.scm");
auto file = Global::get().d->loadSCM("main.scm");
ScriptMachine machine(&state, file, &s);
state.world = Global::get().e;