mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-22 02:12:45 +01:00
commit
30e4a7faf1
@ -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;
|
||||
}
|
||||
|
||||
@ -371,7 +361,7 @@ void GameData::loadGXT(const std::string &name)
|
||||
|
||||
void GameData::loadWaterpro(const std::string& path)
|
||||
{
|
||||
std::ifstream ifstr(path.c_str());
|
||||
std::ifstream ifstr(path.c_str(), std::ios_base::binary);
|
||||
|
||||
if(ifstr.is_open()) {
|
||||
uint32_t numlevels;
|
||||
|
@ -510,7 +510,7 @@ template<class T> bool readBlock(std::FILE* str, T& out) {
|
||||
|
||||
bool SaveGame::loadGame(GameState& state, const std::string& file)
|
||||
{
|
||||
std::FILE* loadFile = std::fopen(file.c_str(), "r");
|
||||
std::FILE* loadFile = std::fopen(file.c_str(), "rb");
|
||||
if (loadFile == nullptr) {
|
||||
std::cerr << "Failed to open save file" << std::endl;
|
||||
return false;
|
||||
@ -1202,7 +1202,7 @@ bool SaveGame::loadGame(GameState& state, const std::string& file)
|
||||
#include <dirent.h>
|
||||
bool SaveGame::getSaveInfo(const std::string& file, BasicState *basicState)
|
||||
{
|
||||
std::FILE* loadFile = std::fopen(file.c_str(), "r");
|
||||
std::FILE* loadFile = std::fopen(file.c_str(), "rb");
|
||||
|
||||
SaveGameInfo info;
|
||||
info.savePath = file;
|
||||
|
@ -107,7 +107,6 @@ RWGame::RWGame(int argc, char* argv[])
|
||||
data->loadIMG("/models/gta3");
|
||||
//engine->data.loadIMG("/models/txd");
|
||||
data->loadIMG("/anim/cuts");
|
||||
data->loadTXD("/models/hud.txd");
|
||||
|
||||
data->load();
|
||||
|
||||
@ -215,7 +214,7 @@ void RWGame::loadGame(const std::string& savename)
|
||||
|
||||
newGame();
|
||||
|
||||
startScript("data/main.scm");
|
||||
startScript("main.scm");
|
||||
|
||||
if(! SaveGame::loadGame(*state, savename) )
|
||||
{
|
||||
|
@ -74,7 +74,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" );
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ FileHandle FileIndex::openFile(const std::string& filename)
|
||||
}
|
||||
else
|
||||
{
|
||||
std::ifstream dfile(fsName.c_str());
|
||||
std::ifstream dfile(fsName.c_str(), std::ios_base::binary);
|
||||
if ( ! dfile.is_open()) {
|
||||
throw std::runtime_error("Unable to open file: " + fsName);
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ void dumpOpcodes(SCMFile* scm, SCMOpcodes* codes, unsigned int offset, unsigned
|
||||
|
||||
void disassemble(const std::string& scmname)
|
||||
{
|
||||
std::ifstream scmfile(scmname.c_str());
|
||||
std::ifstream scmfile(scmname.c_str(), std::ios_base::binary);
|
||||
|
||||
if( !scmfile.is_open() ) {
|
||||
std::cerr << "Failed to open " << scmname << std::endl;
|
||||
|
@ -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