aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/engine
diff options
context:
space:
mode:
authorMax Horn2009-02-22 19:45:53 +0000
committerMax Horn2009-02-22 19:45:53 +0000
commit8997a45773a51583b2e686907cfa60f85b79bfc2 (patch)
tree1b08841cd79189a716a24dcd421e759968312684 /engines/sci/engine
parenta5e6684151c65cd0a16659692256a699c52ceba8 (diff)
downloadscummvm-rg350-8997a45773a51583b2e686907cfa60f85b79bfc2.tar.gz
scummvm-rg350-8997a45773a51583b2e686907cfa60f85b79bfc2.tar.bz2
scummvm-rg350-8997a45773a51583b2e686907cfa60f85b79bfc2.zip
SCI: Replaced two uses of sci_fopen by Common::File; moved is_print_str() to the only spot it is used
svn-id: r38791
Diffstat (limited to 'engines/sci/engine')
-rw-r--r--engines/sci/engine/game.cpp9
-rw-r--r--engines/sci/engine/kstring.cpp17
2 files changed, 22 insertions, 4 deletions
diff --git a/engines/sci/engine/game.cpp b/engines/sci/engine/game.cpp
index 5c7bd07f3e..83a62c57b0 100644
--- a/engines/sci/engine/game.cpp
+++ b/engines/sci/engine/game.cpp
@@ -24,6 +24,7 @@
*/
#include "common/system.h"
+#include "common/file.h"
#include "sci/include/sciresource.h"
#include "sci/include/engine.h"
@@ -139,10 +140,10 @@ int _reset_graphics_input(EngineState *s) {
}
} else {
// Check for Amiga palette file.
- FILE *f = sci_fopen("spal", "rb");
- if (f) {
- s->gfx_state->resstate->static_palette = gfxr_read_pal1_amiga(&s->gfx_state->resstate->static_palette_entries, f);
- fclose(f);
+ Common::File file;
+ if (file.open("spal")) {
+ s->gfx_state->resstate->static_palette = gfxr_read_pal1_amiga(&s->gfx_state->resstate->static_palette_entries, file);
+ file.close();
_sci1_alloc_system_colors(s);
} else {
resource = scir_find_resource(s->resmgr, sci_palette, 999, 1);
diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp
index f961515c94..0e48254026 100644
--- a/engines/sci/engine/kstring.cpp
+++ b/engines/sci/engine/kstring.cpp
@@ -408,6 +408,23 @@ reg_t kStrCpy(EngineState *s, int funct_nr, int argc, reg_t *argv) {
return argv[0];
}
+/* Simple heuristic to work around array handling peculiarity in SQ4:
+It uses StrAt() to read the individual elements, so we must determine
+whether a string is really a string or an array. */
+static int is_print_str(char *str) {
+ int printable = 0;
+ int len = strlen(str);
+
+ if (len == 0) return 1;
+
+ while (*str) {
+ if (isprint(*str)) printable++;
+ str++;
+ }
+
+ return ((float)printable / (float)len >= 0.5);
+}
+
reg_t kStrAt(EngineState *s, int funct_nr, int argc, reg_t *argv) {
unsigned char *dest = (unsigned char *) kernel_dereference_bulk_pointer(s, argv[0], 0);