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:
parent
c19df1d936
commit
593aa73bda
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -218,7 +218,7 @@ void RWGame::loadGame(const std::string& savename)
|
||||
|
||||
newGame();
|
||||
|
||||
startScript("data/main.scm");
|
||||
startScript("main.scm");
|
||||
|
||||
if(! SaveGame::loadGame(*state, savename) )
|
||||
{
|
||||
|
@ -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" );
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user