aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/engine
diff options
context:
space:
mode:
authorMax Horn2009-02-23 04:31:11 +0000
committerMax Horn2009-02-23 04:31:11 +0000
commit2413a5690e588f71b3b9dea56f60f63bf45a80f0 (patch)
tree82c64a3999d2a3b6089585ce87a43afe30f2b8d9 /engines/sci/engine
parent6147bd3ed9410f5c61b94c2d27e4bf26a78df074 (diff)
downloadscummvm-rg350-2413a5690e588f71b3b9dea56f60f63bf45a80f0.tar.gz
scummvm-rg350-2413a5690e588f71b3b9dea56f60f63bf45a80f0.tar.bz2
scummvm-rg350-2413a5690e588f71b3b9dea56f60f63bf45a80f0.zip
SCI: Got rid of resource_dir & work_dir (temporarily disabled f_open_mirrored for that)
svn-id: r38807
Diffstat (limited to 'engines/sci/engine')
-rw-r--r--engines/sci/engine/game.cpp2
-rw-r--r--engines/sci/engine/kfile.cpp72
-rw-r--r--engines/sci/engine/savegame.cfsml2
-rw-r--r--engines/sci/engine/savegame.cpp4
4 files changed, 12 insertions, 68 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;