diff options
-rw-r--r-- | engines/sci/engine/game.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/kfile.cpp | 72 | ||||
-rw-r--r-- | engines/sci/engine/savegame.cfsml | 2 | ||||
-rw-r--r-- | engines/sci/engine/savegame.cpp | 4 | ||||
-rw-r--r-- | engines/sci/include/engine.h | 2 | ||||
-rw-r--r-- | engines/sci/sci.cpp | 12 |
6 files changed, 14 insertions, 80 deletions
diff --git a/engines/sci/engine/game.cpp b/engines/sci/engine/game.cpp index 9c5a23ed2e..a80c8fd57e 100644 --- a/engines/sci/engine/game.cpp +++ b/engines/sci/engine/game.cpp @@ -445,8 +445,6 @@ EngineState::EngineState() { widget_serial_counter = 0; - resource_dir = 0; - work_dir = 0; resmgr = 0; game_name = 0; diff --git a/engines/sci/engine/kfile.cpp b/engines/sci/engine/kfile.cpp index 926fc26a40..20d02e5f93 100644 --- a/engines/sci/engine/kfile.cpp +++ b/engines/sci/engine/kfile.cpp @@ -45,10 +45,6 @@ namespace Sci { -#ifndef O_BINARY -#define O_BINARY 0 -#endif - #ifdef WIN32 # define FO_BINARY "b" #else @@ -71,19 +67,14 @@ static struct _savegame_index_struct { ** Otherwise, the new file is then opened for reading or writing. */ static FILE *f_open_mirrored(EngineState *s, char *fname) { - int fd; - char *buf = NULL; - int fsize; - - debug(3, "f_open_mirrored(%s)", fname); + #if 0 - // TODO/FIXME: Use s->resource_dir to locate the file??? - File file; + Common::File file; if (!file.open(fname)) return NULL; - fsize = file.size(); + int fsize = file.size(); if (fsize > 0) { buf = (char *)sci_malloc(fsize); file.read(buf, fsize); @@ -91,58 +82,17 @@ static FILE *f_open_mirrored(EngineState *s, char *fname) { file.close(); - .... copy the file to a savegame -> only makes sense to perform this change if we at the same time change the code for loading files to look among the savestates, and also change *all* file writing code to write to savestates, as it should - ... -#endif - - chdir(s->resource_dir); - fd = sci_open(fname, O_RDONLY | O_BINARY); - if (!IS_VALID_FD(fd)) { - chdir(s->work_dir); - return NULL; - } - - fsize = sci_fd_size(fd); - if (fsize > 0) { - buf = (char*)sci_malloc(fsize); - read(fd, buf, fsize); - } - - close(fd); - - chdir(s->work_dir); - - // Visual C++ doesn't allow to specify O_BINARY with creat() -#ifdef _MSC_VER - fd = _open(fname, O_CREAT | O_BINARY | O_RDWR, S_IREAD | S_IWRITE); -#else - fd = open(fname, O_CREAT | O_BINARY | O_RDWR, S_IREAD | S_IWRITE); + + Also, we may have to change the filename when creating a matchin savegame, + e.g. prefix it with the target name #endif - if (!IS_VALID_FD(fd) && buf) { - free(buf); - sciprintf("kfile.c: f_open_mirrored(): Warning: Could not create '%s' in '%s' (%d bytes to copy)\n", fname, s->work_dir, fsize); - return NULL; - } - - if (fsize) { - int ret; - ret = write(fd, buf, fsize); - if (ret < fsize) { - sciprintf("kfile.c: f_open_mirrored(): Warning: Could not write all %ld bytes to '%s' in '%s' (only wrote %d)\n", - (long)fsize, fname, s->work_dir, ret); - } - - free(buf); - } - - close(fd); - - return sci_fopen(fname, "r" FO_BINARY "+"); + // FIXME: for now we just pretend this has failed + return 0; } #define _K_FILE_MODE_OPEN_OR_CREATE 0 @@ -372,7 +322,7 @@ reg_t kDeviceInfo(EngineState *s, int funct_nr, int argc, reg_t *argv) { output_s = kernel_dereference_char_pointer(s, argv[1], 0); game_prefix = kernel_dereference_char_pointer(s, argv[2], 0); - sprintf(output_s, "%s/__throwaway", s->work_dir); + sprintf(output_s, "__throwaway"); debug(3, "K_DEVICE_INFO_GET_SAVECAT_NAME(%s) -> %s", game_prefix, output_s); } @@ -381,9 +331,9 @@ reg_t kDeviceInfo(EngineState *s, int funct_nr, int argc, reg_t *argv) { output_s = kernel_dereference_char_pointer(s, argv[1], 0); game_prefix = kernel_dereference_char_pointer(s, argv[2], 0); int savegame_id = UKPV(3); - sprintf(output_s, "%s/__throwaway", s->work_dir); - delete_savegame(s, savegame_id); + sprintf(output_s, "__throwaway"); debug(3, "K_DEVICE_INFO_GET_SAVEFILE_NAME(%s,%d) -> %s", game_prefix, savegame_id, output_s); + delete_savegame(s, savegame_id); } break; diff --git a/engines/sci/engine/savegame.cfsml b/engines/sci/engine/savegame.cfsml index 8475bbd279..ba4164692e 100644 --- a/engines/sci/engine/savegame.cfsml +++ b/engines/sci/engine/savegame.cfsml @@ -1143,8 +1143,6 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) { retval->debug_mode = s->debug_mode; - retval->resource_dir = s->resource_dir; - retval->work_dir = s->work_dir; retval->kernel_opt_flags = 0; retval->have_mouse_flag = 1; diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index 6d48bbcf96..1ecb65b5e6 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -5272,8 +5272,6 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) { retval->debug_mode = s->debug_mode; - retval->resource_dir = s->resource_dir; - retval->work_dir = s->work_dir; retval->kernel_opt_flags = 0; retval->have_mouse_flag = 1; @@ -5326,7 +5324,7 @@ bool get_savegame_metadata(Common::SeekableReadStream* stream, SavegameMetadata* } } // End of auto-generated CFSML data reader code -#line 1169 "engines/sci/engine/savegame.cfsml" +#line 1167 "engines/sci/engine/savegame.cfsml" if (read_eof) return false; diff --git a/engines/sci/include/engine.h b/engines/sci/include/engine.h index b8d8ff5b65..d959ec2160 100644 --- a/engines/sci/include/engine.h +++ b/engines/sci/include/engine.h @@ -100,8 +100,6 @@ struct EngineState { int widget_serial_counter; /* Used for savegames */ - char *resource_dir; /* Directory the resource files are kept in */ - char *work_dir; /* Directory the game metadata should be written to */ ResourceManager *resmgr; /* The resource manager */ char *game_name; /* Designation of the primary object (which inherits from Game) */ diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp index 51a055a6ff..c9de771958 100644 --- a/engines/sci/sci.cpp +++ b/engines/sci/sci.cpp @@ -213,14 +213,10 @@ Common::Error SciEngine::go() { version = getVersion(); - char resource_dir[MAXPATHLEN+1] = ""; - getcwd(resource_dir, MAXPATHLEN); // Store resource directory - _resmgr = new ResourceManager(res_version, 256 * 1024); if (!_resmgr) { - printf("No resources found in '%s'.\nAborting...\n", - resource_dir); + printf("No resources found, aborting...\n"); return Common::kNoGameDataFoundError; } @@ -232,7 +228,7 @@ Common::Error SciEngine::go() { map_MIDI_instruments(_resmgr); #endif - EngineState* gamestate = new EngineState(); + EngineState *gamestate = new EngineState(); gamestate->resmgr = _resmgr; gamestate->gfx_state = NULL; @@ -249,9 +245,6 @@ Common::Error SciEngine::go() { // Set the savegame dir script_set_gamestate_save_dir(gamestate, ConfMan.get("savepath").c_str()); - // Originally, work_dir tried to be ~/.freesci/game_name - gamestate->work_dir = sci_strdup(ConfMan.get("savepath").c_str()); - gamestate->resource_dir = resource_dir; gamestate->port_serial = 0; gamestate->have_mouse_flag = 1; gamestate->animation_delay = 5; @@ -310,7 +303,6 @@ Common::Error SciEngine::go() { game_exit(gamestate); script_free_engine(gamestate); // Uninitialize game state script_free_breakpoints(gamestate); - free(gamestate->work_dir); delete gamestate; |