diff options
Diffstat (limited to 'engines/sci/scicore')
-rw-r--r-- | engines/sci/scicore/console.cpp | 8 | ||||
-rw-r--r-- | engines/sci/scicore/decompress0.cpp | 15 | ||||
-rw-r--r-- | engines/sci/scicore/decompress01.cpp | 13 | ||||
-rw-r--r-- | engines/sci/scicore/decompress1.cpp | 45 | ||||
-rw-r--r-- | engines/sci/scicore/decompress11.cpp | 11 | ||||
-rw-r--r-- | engines/sci/scicore/resource.cpp | 20 | ||||
-rw-r--r-- | engines/sci/scicore/resource_map.cpp | 14 | ||||
-rw-r--r-- | engines/sci/scicore/sci_memory.cpp | 20 | ||||
-rw-r--r-- | engines/sci/scicore/script.cpp | 8 | ||||
-rw-r--r-- | engines/sci/scicore/tools.cpp | 18 | ||||
-rw-r--r-- | engines/sci/scicore/vocab.cpp | 14 | ||||
-rw-r--r-- | engines/sci/scicore/vocab_debug.cpp | 2 |
12 files changed, 96 insertions, 92 deletions
diff --git a/engines/sci/scicore/console.cpp b/engines/sci/scicore/console.cpp index ece958bb89..e788ab8244 100644 --- a/engines/sci/scicore/console.cpp +++ b/engines/sci/scicore/console.cpp @@ -50,12 +50,12 @@ sciprintf(const char *fmt, ...) { char *buf = (char *) sci_malloc(bufsize); if (NULL == fmt) { - fprintf(stderr, "console.c: sciprintf(): NULL passed for parameter fmt\n"); + error("console.c: sciprintf(): NULL passed for parameter fmt\n"); return -1; } if (NULL == buf) { - fprintf(stderr, "console.c: sciprintf(): malloc failed for buf\n"); + error("console.c: sciprintf(): malloc failed for buf\n"); return -1; } @@ -116,7 +116,7 @@ open_console_file(char *filename) { fclose(con_file); if (NULL == filename) { - fprintf(stderr, "console.c: open_console_file(): NULL passed for parameter filename\r\n"); + error("console.c: open_console_file(): NULL passed for parameter filename\r\n"); } #ifdef WIN32 con_file = fopen(filename, "wt"); @@ -125,7 +125,7 @@ open_console_file(char *filename) { #endif if (NULL == con_file) - fprintf(stderr, "console.c: open_console_file(): Could not open output file %s\n", filename); + error("console.c: open_console_file(): Could not open output file %s\n", filename); } diff --git a/engines/sci/scicore/decompress0.cpp b/engines/sci/scicore/decompress0.cpp index 0c829ad3d8..0eb3774b31 100644 --- a/engines/sci/scicore/decompress0.cpp +++ b/engines/sci/scicore/decompress0.cpp @@ -27,6 +27,7 @@ ** This is for SCI version 0 style compression. */ +#include "common/util.h" #include "sci/include/sci_memory.h" #include "sci/include/sciresource.h" @@ -99,7 +100,7 @@ decrypt1(guint8 *dest, guint8 *src, int length, int complength) if (token > 0xff) { if (token >= tokenctr) { #ifdef _SCI_DECOMPRESS_DEBUG - fprintf(stderr, "decrypt1: Bad token %x!\n", token); + error("decrypt1: Bad token %x", token); #endif /* Well this is really bad */ /* May be it should throw something like SCI_ERROR_DECOMPRESSION_INSANE */ @@ -109,7 +110,7 @@ decrypt1(guint8 *dest, guint8 *src, int length, int complength) #ifdef _SCI_DECOMPRESS_DEBUG /* For me this seems a normal situation, It's necessary to handle it*/ - printf("decrypt1: Trying to write beyond the end of array(len=%d, destctr=%d, tok_len=%d)!\n", + printf("decrypt1: Trying to write beyond the end of array(len=%d, destctr=%d, tok_len=%d)", length, destctr, tokenlastlength); #endif @@ -127,7 +128,7 @@ decrypt1(guint8 *dest, guint8 *src, int length, int complength) tokenlastlength = 1; if (destctr >= length) { #ifdef _SCI_DECOMPRESS_DEBUG - printf("decrypt1: Try to write single byte beyond end of array!\n"); + printf("decrypt1: Try to write single byte beyond end of array"); #endif } else dest[destctr++] = (byte)token; @@ -301,12 +302,12 @@ int decompress0(resource_t *result, Common::ReadStream &stream, int sci_version) #ifdef _SCI_DECOMPRESS_DEBUG - fprintf(stderr, "Resource %s.%03hi encrypted with method %hi at %.2f%%" + error("Resource %s.%03hi encrypted with method %hi at %.2f%%" " ratio\n", sci_resource_types[result->type], result->number, compressionMethod, (result->size == 0) ? -1.0 : (100.0 * compressedLength / result->size)); - fprintf(stderr, " compressedLength = 0x%hx, actualLength=0x%hx\n", + error(" compressedLength = 0x%hx, actualLength=0x%hx\n", compressedLength, result->size); #endif @@ -347,8 +348,8 @@ int decompress0(resource_t *result, Common::ReadStream &stream, int sci_version) break; default: - fprintf(stderr, "Resource %s.%03hi: Compression method %hi not " - "supported!\n", sci_resource_types[result->type], result->number, + error("Resource %s.%03hi: Compression method %hi not " + "supported", sci_resource_types[result->type], result->number, compressionMethod); free(result->data); result->data = 0; /* So that we know that it didn't work */ diff --git a/engines/sci/scicore/decompress01.cpp b/engines/sci/scicore/decompress01.cpp index e3219d3a5f..4fb450e9a7 100644 --- a/engines/sci/scicore/decompress01.cpp +++ b/engines/sci/scicore/decompress01.cpp @@ -25,6 +25,7 @@ /* Reads data from a resource file and stores the result in memory */ +#include "common/util.h" #include "sci/include/sci_memory.h" #include "sci/include/sciresource.h" @@ -425,7 +426,7 @@ byte *view_reorder(byte *inbuffer, int dsize) { for (l = 0;l < loopheaders;l++) { if (lh_mask & lb) { /* The loop is _not_ present */ if (lh_last == -1) { - fprintf(stderr, "Error: While reordering view: Loop not present, but can't re-use last loop!\n"); + error("Error: While reordering view: Loop not present, but can't re-use last loop"); lh_last = 0; } putInt16(lh_ptr, lh_last); @@ -459,7 +460,7 @@ byte *view_reorder(byte *inbuffer, int dsize) { } if (celindex < cel_total) { - fprintf(stderr, "View decompression generated too few (%d / %d) headers!\n", celindex, cel_total); + error("View decompression generated too few (%d / %d) headers", celindex, cel_total); return NULL; } @@ -546,12 +547,12 @@ int decompress01(resource_t *result, Common::ReadStream &stream, int sci_version #ifdef _SCI_DECOMPRESS_DEBUG - fprintf(stderr, "Resource %s.%03hi encrypted with method SCI01/%hi at %.2f%%" + error("Resource %s.%03hi encrypted with method SCI01/%hi at %.2f%%" " ratio\n", sci_resource_types[result->type], result->number, compressionMethod, (result->size == 0) ? -1.0 : (100.0 * compressedLength / result->size)); - fprintf(stderr, " compressedLength = 0x%hx, actualLength=0x%hx\n", + error(" compressedLength = 0x%hx, actualLength=0x%hx\n", compressedLength, result->size); #endif @@ -619,8 +620,8 @@ int decompress01(resource_t *result, Common::ReadStream &stream, int sci_version break; default: - fprintf(stderr, "Resource %s.%03hi: Compression method SCI1/%hi not " - "supported!\n", sci_resource_types[result->type], result->number, + error("Resource %s.%03hi: Compression method SCI1/%hi not " + "supported", sci_resource_types[result->type], result->number, compressionMethod); free(result->data); result->data = 0; /* So that we know that it didn't work */ diff --git a/engines/sci/scicore/decompress1.cpp b/engines/sci/scicore/decompress1.cpp index 7269e29479..250aa9bb83 100644 --- a/engines/sci/scicore/decompress1.cpp +++ b/engines/sci/scicore/decompress1.cpp @@ -25,6 +25,7 @@ /* Reads data from a resource file and stores the result in memory */ +#include "common/util.h" #include "sci/include/sci_memory.h" #include "sci/include/sciresource.h" @@ -72,7 +73,7 @@ getbits_msb_first(struct bit_read_struct *inp, int bits) { int i; if (inp->bytepos + morebytes >= inp->length) { - fprintf(stderr, "read out-of-bounds with bytepos %d + morebytes %d >= length %d\n", + error("read out-of-bounds with bytepos %d + morebytes %d >= length %d\n", inp->bytepos, morebytes, inp->length); return -SCI_ERROR_DECOMPRESSION_OVERFLOW; } @@ -98,7 +99,7 @@ getbits(struct bit_read_struct *inp, int bits) { int i; if (inp->bytepos + morebytes >= inp->length) { - fprintf(stderr, "read out-of-bounds with bytepos %d + morebytes %d >= length %d\n", + error("read out-of-bounds with bytepos %d + morebytes %d >= length %d\n", inp->bytepos, morebytes, inp->length); return -SCI_ERROR_DECOMPRESSION_OVERFLOW; } @@ -113,7 +114,7 @@ getbits(struct bit_read_struct *inp, int bits) { inp->bytepos += morebytes; if (DEBUG_DCL_INFLATE) - fprintf(stderr, "(%d:%04x)", bits, result); + error("(%d:%04x)", bits, result); return result; } @@ -126,14 +127,14 @@ huffman_lookup(struct bit_read_struct *inp, int *tree) { while (!(tree[pos] & HUFFMAN_LEAF)) { CALLC(bit = getbits(inp, 1)); if (DEBUG_DCL_INFLATE) - fprintf(stderr, "[%d]:%d->", pos, bit); + error("[%d]:%d->", pos, bit); if (bit) pos = tree[pos] & ~(~0 << BRANCH_SHIFT); else pos = tree[pos] >> BRANCH_SHIFT; } if (DEBUG_DCL_INFLATE) - fprintf(stderr, "=%02x\n", tree[pos] & 0xffff); + error("=%02x\n", tree[pos] & 0xffff); return tree[pos] & 0xffff; } @@ -150,28 +151,28 @@ decrypt4_hdyn(byte *dest, int length, struct bit_read_struct *reader) { CALLC(length_param = getbits(reader, 8)); if (mode == DCL_ASCII_MODE) { - fprintf(stderr, "DCL-INFLATE: Warning: Decompressing ASCII mode (untested)\n"); + error("DCL-INFLATE: Warning: Decompressing ASCII mode (untested)\n"); /* DEBUG_DCL_INFLATE = 1; */ } else if (mode) { - fprintf(stderr, "DCL-INFLATE: Error: Encountered mode %02x, expected 00 or 01\n", mode); + error("DCL-INFLATE: Error: Encountered mode %02x, expected 00 or 01\n", mode); return 1; } if (DEBUG_DCL_INFLATE) { int i; for (i = 0; i < reader->length; i++) { - fprintf(stderr, "%02x ", reader->data[i]); + error("%02x ", reader->data[i]); if (!((i + 1) & 0x1f)) - fprintf(stderr, "\n"); + error("\n"); } - fprintf(stderr, "\n---\n"); + error("\n---\n"); } if (length_param < 3 || length_param > 6) - fprintf(stderr, "Warning: Unexpected length_param value %d (expected in [3,6])\n", length_param); + error("Warning: Unexpected length_param value %d (expected in [3,6])\n", length_param); while (write_pos < length) { CALLC(value = getbits(reader, 1)); @@ -190,7 +191,7 @@ decrypt4_hdyn(byte *dest, int length, struct bit_read_struct *reader) { } if (DEBUG_DCL_INFLATE) - fprintf(stderr, " | "); + error(" | "); CALLC(value = huffman_lookup(reader, distance_tree)); @@ -208,15 +209,15 @@ decrypt4_hdyn(byte *dest, int length, struct bit_read_struct *reader) { ++val_distance; if (DEBUG_DCL_INFLATE) - fprintf(stderr, "\nCOPY(%d from %d)\n", val_length, val_distance); + error("\nCOPY(%d from %d)\n", val_length, val_distance); if (val_length + write_pos > length) { - fprintf(stderr, "DCL-INFLATE Error: Write out of bounds while copying %d bytes\n", val_length); + error("DCL-INFLATE Error: Write out of bounds while copying %d bytes\n", val_length); return -SCI_ERROR_DECOMPRESSION_OVERFLOW; } if (write_pos < val_distance) { - fprintf(stderr, "DCL-INFLATE Error: Attempt to copy from before beginning of input stream\n"); + error("DCL-INFLATE Error: Attempt to copy from before beginning of input stream\n"); return -SCI_ERROR_DECOMPRESSION_INSANE; } @@ -228,8 +229,8 @@ decrypt4_hdyn(byte *dest, int length, struct bit_read_struct *reader) { if (DEBUG_DCL_INFLATE) { int i; for (i = 0; i < copy_length; i++) - fprintf(stderr, "\33[32;31m%02x\33[37;37m ", dest[write_pos + i]); - fprintf(stderr, "\n"); + error("\33[32;31m%02x\33[37;37m ", dest[write_pos + i]); + error("\n"); } val_length -= copy_length; @@ -247,7 +248,7 @@ decrypt4_hdyn(byte *dest, int length, struct bit_read_struct *reader) { dest[write_pos++] = value; if (DEBUG_DCL_INFLATE) - fprintf(stderr, "\33[32;31m%02x \33[37;37m", value); + error("\33[32;31m%02x \33[37;37m", value); } } @@ -343,14 +344,14 @@ int decompress1(resource_t *result, Common::ReadStream &stream, int sci_version) #ifdef _SCI_DECOMPRESS_DEBUG - fprintf(stderr, "Resource %i.%s encrypted with method SCI1%c/%hi at %.2f%%" + error("Resource %i.%s encrypted with method SCI1%c/%hi at %.2f%%" " ratio\n", result->number, sci_resource_type_suffixes[result->type], early ? 'e' : 'l', compressionMethod, (result->size == 0) ? -1.0 : (100.0 * compressedLength / result->size)); - fprintf(stderr, " compressedLength = 0x%hx, actualLength=0x%hx\n", + error(" compressedLength = 0x%hx, actualLength=0x%hx\n", compressedLength, result->size); #endif @@ -418,8 +419,8 @@ int decompress1(resource_t *result, Common::ReadStream &stream, int sci_version) break; default: - fprintf(stderr, "Resource %s.%03hi: Compression method SCI1/%hi not " - "supported!\n", sci_resource_types[result->type], result->number, + error("Resource %s.%03hi: Compression method SCI1/%hi not " + "supported", sci_resource_types[result->type], result->number, compressionMethod); free(result->data); result->data = 0; /* So that we know that it didn't work */ diff --git a/engines/sci/scicore/decompress11.cpp b/engines/sci/scicore/decompress11.cpp index 99b1b9e22e..41add67db7 100644 --- a/engines/sci/scicore/decompress11.cpp +++ b/engines/sci/scicore/decompress11.cpp @@ -25,6 +25,7 @@ /* Reads data from a resource file and stores the result in memory */ +#include "common/util.h" #include "sci/include/sci_memory.h" #include "sci/include/sciresource.h" @@ -99,13 +100,13 @@ int decompress11(resource_t *result, Common::ReadStream &stream, int sci_version } #ifdef _SCI_DECOMPRESS_DEBUG - fprintf(stderr, "Resource %i.%s encrypted with method SCI1.1/%hi at %.2f%%" + error("Resource %i.%s encrypted with method SCI1.1/%hi at %.2f%%" " ratio\n", result->number, sci_resource_type_suffixes[result->type], compressionMethod, (result->size == 0) ? -1.0 : (100.0 * compressedLength / result->size)); - fprintf(stderr, " compressedLength = 0x%hx, actualLength=0x%hx\n", + error(" compressedLength = 0x%hx, actualLength=0x%hx\n", compressedLength, result->size); #endif @@ -140,7 +141,7 @@ int decompress11(resource_t *result, Common::ReadStream &stream, int sci_version case 3: case 4: /* NYI */ - fprintf(stderr, "Resource %d.%s: Warning: compression type #%d not yet implemented\n", + error("Resource %d.%s: Warning: compression type #%d not yet implemented\n", result->number, sci_resource_type_suffixes[result->type], compressionMethod); free(result->data); result->data = NULL; @@ -148,8 +149,8 @@ int decompress11(resource_t *result, Common::ReadStream &stream, int sci_version break; default: - fprintf(stderr, "Resource %d.%s: Compression method SCI1/%hi not " - "supported!\n", result->number, sci_resource_type_suffixes[result->type], + error("Resource %d.%s: Compression method SCI1/%hi not " + "supported", result->number, sci_resource_type_suffixes[result->type], compressionMethod); free(result->data); result->data = NULL; /* So that we know that it didn't work */ diff --git a/engines/sci/scicore/resource.cpp b/engines/sci/scicore/resource.cpp index 45cb4a64a7..1eb69fa163 100644 --- a/engines/sci/scicore/resource.cpp +++ b/engines/sci/scicore/resource.cpp @@ -522,7 +522,7 @@ ResourceManager::ResourceManager(int version, int maxMemory) { free(_resources); _resources = NULL; } - sciprintf("Resmgr: Could not retrieve a resource list!\n"); + sciprintf("Resmgr: Could not retrieve a resource list"); _scir_free_resource_sources(mgr->_sources); error("FIXME: Move this code to an init() method so that we can perform error handling"); // return NULL; @@ -587,7 +587,7 @@ ResourceManager::ResourceManager(int version, int maxMemory) { break; default: sciprintf("Resmgr: Warning: While autodetecting: Couldn't" - " determine SCI version!\n"); + " determine SCI version"); } if (!resource_error) { @@ -678,7 +678,7 @@ _scir_add_to_lru(ResourceManager *mgr, resource_t *res) { mgr->memory_lru += res->size; #if (SCI_VERBOSE_RESMGR > 1) - fprintf(stderr, "Adding %s.%03d (%d bytes) to lru control: %d bytes total\n", + error("Adding %s.%03d (%d bytes) to lru control: %d bytes total\n", sci_resource_types[res->type], res->number, res->size, mgr->memory_lru); @@ -694,7 +694,7 @@ _scir_print_lru_list(ResourceManager *mgr) { resource_t *res = mgr->lru_first; while (res) { - fprintf(stderr, "\t%s.%03d: %d bytes\n", + error("\t%s.%03d: %d bytes\n", sci_resource_types[res->type], res->number, res->size); mem += res->size; @@ -702,7 +702,7 @@ _scir_print_lru_list(ResourceManager *mgr) { res = res->next; } - fprintf(stderr, "Total: %d entries, %d bytes (mgr says %d)\n", + error("Total: %d entries, %d bytes (mgr says %d)\n", entries, mem, mgr->memory_lru); } @@ -712,9 +712,9 @@ _scir_free_old_resources(ResourceManager *mgr, int last_invulnerable) { && (!last_invulnerable || mgr->lru_first != mgr->lru_last)) { resource_t *goner = mgr->lru_last; if (!goner) { - fprintf(stderr, "Internal error: mgr->lru_last is NULL!\n"); - fprintf(stderr, "LRU-mem= %d\n", mgr->memory_lru); - fprintf(stderr, "lru_first = %p\n", (void *)mgr->lru_first); + error("Internal error: mgr->lru_last is NULL"); + error("LRU-mem= %d\n", mgr->memory_lru); + error("lru_first = %p\n", (void *)mgr->lru_first); _scir_print_lru_list(mgr); } @@ -782,9 +782,9 @@ void scir_unlock_resource(ResourceManager *mgr, resource_t *res, int resnum, int restype) { if (!res) { if (restype >= ARRAYSIZE(sci_resource_types)) - sciprintf("Resmgr: Warning: Attempt to unlock non-existant resource %03d.%03d!\n", restype, resnum); + sciprintf("Resmgr: Warning: Attempt to unlock non-existant resource %03d.%03d", restype, resnum); else - sciprintf("Resmgr: Warning: Attempt to unlock non-existant resource %s.%03d!\n", sci_resource_types[restype], resnum); + sciprintf("Resmgr: Warning: Attempt to unlock non-existant resource %s.%03d", sci_resource_types[restype], resnum); return; } diff --git a/engines/sci/scicore/resource_map.cpp b/engines/sci/scicore/resource_map.cpp index c79027d0a5..5aa5a61303 100644 --- a/engines/sci/scicore/resource_map.cpp +++ b/engines/sci/scicore/resource_map.cpp @@ -147,7 +147,7 @@ sci_res_read_entry(ResourceManager *mgr, ResourceSource *map, } #if 0 - fprintf(stderr, "Read [%04x] %6d.%s\tresource.%03d, %08x\n", + error("Read [%04x] %6d.%s\tresource.%03d, %08x\n", res->id, res->number, sci_resource_type_suffixes[res->type], res->file, res->file_offset); @@ -302,7 +302,7 @@ int sci0_read_resource_map(ResourceManager *mgr, ResourceSource *map, resource_t if (++resources_total_read >= resource_nr) { sciprintf("Warning: After %d entries, resource.map" - " is not terminated!\n", resource_index); + " is not terminated", resource_index); next_entry = 0; } @@ -313,7 +313,7 @@ int sci0_read_resource_map(ResourceManager *mgr, ResourceSource *map, resource_t file.close(); if (!resource_index) { - sciprintf("resource.map was empty!\n"); + sciprintf("resource.map was empty"); _scir_free_resources(resources, resource_nr); return SCI_ERROR_RESMAP_NOT_FOUND; } @@ -345,7 +345,7 @@ int sci0_read_resource_map(ResourceManager *mgr, ResourceSource *map, resource_t return 0; } -#define TEST fprintf(stderr, "OK in line %d\n", __LINE__); +#define TEST error("OK in line %d\n", __LINE__); static int sci10_or_11(int *types) { int this_restype = 0; @@ -474,7 +474,7 @@ sci1_read_resource_map(ResourceManager *mgr, ResourceSource *map, ResourceSource } #if 0 - fprintf(stderr, "Read [%04x] %6d.%s\tresource.%03d, %08x ==> %d\n", + error("Read [%04x] %6d.%s\tresource.%03d, %08x ==> %d\n", res->id, res->number, sci_resource_type_suffixes[res->type], res->file, res->file_offset, addto); @@ -506,7 +506,7 @@ main(int argc, char **argv) { int notok = sci0_read_resource_map(".", &resources, &resource_nr); if (notok) { - fprintf(stderr, "Failed: Error code %d\n", notok); + error("Failed: Error code %d\n", notok); return 1; } @@ -524,7 +524,7 @@ main(int argc, char **argv) { res->number); } } else - fprintf(stderr, "Found no resources.\n"); + error("Found no resources.\n"); return 0; } diff --git a/engines/sci/scicore/sci_memory.cpp b/engines/sci/scicore/sci_memory.cpp index 7e73cf234d..e762475e20 100644 --- a/engines/sci/scicore/sci_memory.cpp +++ b/engines/sci/scicore/sci_memory.cpp @@ -70,9 +70,9 @@ char * sci_strdup(const char *src) { void *res; if (!src) { - fprintf(stderr, "_SCI_STRDUP() [%s (%s) : %u]\n", + error("_SCI_STRDUP() [%s (%s) : %u]\n", __FILE__, "", __LINE__); - fprintf(stderr, " attempt to strdup NULL pointer\n"); + error(" attempt to strdup NULL pointer\n"); BREAKPOINT(); } ALLOC_MEM((res = strdup(src)), strlen(src), __FILE__, __LINE__, "") @@ -86,9 +86,9 @@ sci_strndup(const char *src, size_t length) { char *strres; size_t rlen = (int)MIN(strlen(src), length) + 1; if (!src) { - fprintf(stderr, "_SCI_STRNDUP() [%s (%s) : %u]\n", + error("_SCI_STRNDUP() [%s (%s) : %u]\n", __FILE__, "", __LINE__); - fprintf(stderr, " attempt to strndup NULL pointer\n"); + error(" attempt to strndup NULL pointer\n"); BREAKPOINT(); } ALLOC_MEM((res = malloc(rlen)), rlen, __FILE__, __LINE__, "") @@ -120,7 +120,7 @@ extern void * sci_refcount_alloc(size_t length) { guint32 *data = (guint32*)sci_malloc(REFCOUNT_OVERHEAD + length); #ifdef TRACE_REFCOUNT - fprintf(stderr, "[] REF: Real-alloc at %p\n", data); + error("[] REF: Real-alloc at %p\n", data); #endif data += 3; @@ -128,7 +128,7 @@ extern void * data[-3] = REFCOUNT_MAGIC_LIVE_2; REFCOUNT(data) = 1; #ifdef TRACE_REFCOUNT - fprintf(stderr, "[] REF: Alloc'd %p (ref=%d) OK=%d\n", data, REFCOUNT(data), + error("[] REF: Alloc'd %p (ref=%d) OK=%d\n", data, REFCOUNT(data), REFCOUNT_CHECK(data)); #endif return data; @@ -141,14 +141,14 @@ extern void *sci_refcount_incref(void *data) { REFCOUNT(data)++; #ifdef TRACE_REFCOUNT - fprintf(stderr, "[] REF: Inc'ing %p (now ref=%d)\n", data, REFCOUNT(data)); + error("[] REF: Inc'ing %p (now ref=%d)\n", data, REFCOUNT(data)); #endif return data; } extern void sci_refcount_decref(void *data) { #ifdef TRACE_REFCOUNT - fprintf(stderr, "[] REF: Dec'ing %p (prev ref=%d) OK=%d\n", data, REFCOUNT(data), + error("[] REF: Dec'ing %p (prev ref=%d) OK=%d\n", data, REFCOUNT(data), REFCOUNT_CHECK(data)); #endif if (!REFCOUNT_CHECK(data)) { @@ -160,11 +160,11 @@ extern void sci_refcount_decref(void *data) { fdata[-3] = REFCOUNT_MAGIC_DEAD_2; #ifdef TRACE_REFCOUNT - fprintf(stderr, "[] REF: Freeing (%p)...\n", fdata - 3); + error("[] REF: Freeing (%p)...\n", fdata - 3); #endif free(fdata - 3); #ifdef TRACE_REFCOUNT - fprintf(stderr, "[] REF: Done.\n"); + error("[] REF: Done.\n"); #endif } } diff --git a/engines/sci/scicore/script.cpp b/engines/sci/scicore/script.cpp index b8300a2696..ebdfea695c 100644 --- a/engines/sci/scicore/script.cpp +++ b/engines/sci/scicore/script.cpp @@ -111,7 +111,7 @@ script_find_selector(state_t *s, const char *selectorname) { if (strcmp(selectorname, s->selector_names[i]) == 0) return i; - sciprintf("Warning: Could not map '%s' to any selector!\n", selectorname); + sciprintf("Warning: Could not map '%s' to any selector", selectorname); return -1; } @@ -323,7 +323,7 @@ script_dump_class(char *data, int seeker, int objsize, char **snames, int snames while (overloads--) { int selector = getInt16((unsigned char *) data + (seeker)); - fprintf(stderr, "selector=%d; snames_nr =%d\n", selector, snames_nr); + error("selector=%d; snames_nr =%d\n", selector, snames_nr); sciprintf(" [%03x] %s: @", selector & 0xffff, (snames && selector >= 0 && selector < snames_nr) ? snames[selector] : "<?>"); @@ -343,7 +343,7 @@ script_dissect(ResourceManager *resmgr, int res_no, char **snames, int snames_nr int word_count; if (!script) { - sciprintf("Script not found!\n"); + sciprintf("Script not found"); return; } @@ -480,7 +480,7 @@ script_dissect(ResourceManager *resmgr, int res_no, char **snames, int snames_nr break; default: - sciprintf("Unsupported!\n"); + sciprintf("Unsupported"); return; } diff --git a/engines/sci/scicore/tools.cpp b/engines/sci/scicore/tools.cpp index 417165af99..54c6e5e89c 100644 --- a/engines/sci/scicore/tools.cpp +++ b/engines/sci/scicore/tools.cpp @@ -51,10 +51,10 @@ Sleep(0); \ } else { \ if (timeBeginPeriod(1) != TIMERR_NOERROR) \ - fprintf(stderr, "timeBeginPeriod(1) failed\n"); \ + error("timeBeginPeriod(1) failed\n"); \ Sleep(x); \ if (timeEndPeriod(1) != TIMERR_NOERROR) \ - fprintf(stderr, "timeEndPeriod(1) failed\n"); \ + error("timeEndPeriod(1) failed\n"); \ } \ } while (0); #endif @@ -201,13 +201,13 @@ void sci_gettime(long *seconds, long *useconds) { DWORD tm; if (TIMERR_NOERROR != timeBeginPeriod(1)) { - fprintf(stderr, "timeBeginPeriod(1) failed in sci_gettime\n"); + error("timeBeginPeriod(1) failed in sci_gettime\n"); } tm = timeGetTime(); if (TIMERR_NOERROR != timeEndPeriod(1)) { - fprintf(stderr, "timeEndPeriod(1) failed in sci_gettime\n"); + error("timeEndPeriod(1) failed in sci_gettime\n"); } *seconds = tm / 1000; @@ -322,7 +322,7 @@ sci_find_first(sci_dir_t *dir, const char *mask) { closedir(dir->dir); if (!(dir->dir = opendir("."))) { - sciprintf("%s, L%d: opendir(\".\") failed!\n", __FILE__, __LINE__); + sciprintf("%s, L%d: opendir(\".\") failed", __FILE__, __LINE__); return NULL; } @@ -373,7 +373,7 @@ sci_mkpath(const char *path) { char *next_separator = NULL; if (chdir(G_DIR_SEPARATOR_S)) { /* Go to root */ - sciprintf("Error: Could not change to root directory '%s'!\n", + sciprintf("Error: Could not change to root directory '%s'", G_DIR_SEPARATOR_S); return -1; } @@ -393,7 +393,7 @@ sci_mkpath(const char *path) { path_position); if (next_separator) *next_separator = G_DIR_SEPARATOR_S[0]; - sciprintf(" '%s'!\n", path); + sciprintf(" '%s'", path); return -2; } } @@ -449,7 +449,7 @@ Common::String _fcaseseek(const char *fname) { ** free it afterwards */ if (strchr(fname, G_DIR_SEPARATOR)) { - fprintf(stderr, "_fcaseseek() does not support subdirs\n"); + error("_fcaseseek() does not support subdirs\n"); BREAKPOINT(); } @@ -501,7 +501,7 @@ sci_getcwd(void) { free(cwd); } - fprintf(stderr, "Could not determine current working directory!\n"); + error("Could not determine current working directory"); return NULL; } diff --git a/engines/sci/scicore/vocab.cpp b/engines/sci/scicore/vocab.cpp index 904c0d28c1..c962b0c4c7 100644 --- a/engines/sci/scicore/vocab.cpp +++ b/engines/sci/scicore/vocab.cpp @@ -82,14 +82,14 @@ vocab_get_words(ResourceManager *resmgr, int *word_counter) { vocab_version = 0; if (!resource) { - fprintf(stderr, "SCI0: Could not find a main vocabulary, trying SCI01.\n"); + error("SCI0: Could not find a main vocabulary, trying SCI01.\n"); resource = scir_find_resource(resmgr, sci_vocab, VOCAB_RESOURCE_SCI1_MAIN_VOCAB, 0); vocab_version = 1; } if (!resource) { - fprintf(stderr, "SCI1: Could not find a main vocabulary!\n"); + error("SCI1: Could not find a main vocabulary"); return NULL; /* NOT critical: SCI1 games and some demos don't have one! */ } @@ -99,7 +99,7 @@ vocab_get_words(ResourceManager *resmgr, int *word_counter) { seeker = 26 * 2; /* vocab.000 starts with 26 16-bit pointers which we don't use */ if (resource->size < seeker) { - fprintf(stderr, "Invalid main vocabulary encountered: Too small\n"); + error("Invalid main vocabulary encountered: Too small\n"); return NULL; /* Now this ought to be critical, but it'll just cause parse() and said() not to work */ } @@ -122,7 +122,7 @@ vocab_get_words(ResourceManager *resmgr, int *word_counter) { currentword[currentwordpos++] = c; } if (seeker == resource->size) { - fprintf(stderr, "SCI1: Vocabulary not usable, disabling.\n"); + error("SCI1: Vocabulary not usable, disabling.\n"); vocab_free_words(words, counter); return NULL; } @@ -197,7 +197,7 @@ vocab_get_suffices(ResourceManager *resmgr, int *suffices_nr) { unsigned int seeker = 1; if (!resource) { - fprintf(stderr, "Could not find suffix vocabulary!\n"); + error("Could not find suffix vocabulary"); return NULL; /* Not critical */ } @@ -269,14 +269,14 @@ vocab_get_branches(ResourceManager * resmgr, int *branches_nr) { int i; if (!resource) { - fprintf(stderr, "No parser tree data found!\n"); + error("No parser tree data found"); return NULL; } *branches_nr = resource->size / 20; if (*branches_nr == 0) { - fprintf(stderr, "Parser tree data is empty!\n"); + error("Parser tree data is empty"); return NULL; } diff --git a/engines/sci/scicore/vocab_debug.cpp b/engines/sci/scicore/vocab_debug.cpp index 782b75432b..bccb8fcf72 100644 --- a/engines/sci/scicore/vocab_debug.cpp +++ b/engines/sci/scicore/vocab_debug.cpp @@ -244,7 +244,7 @@ opcode* vocabulary_get_opcodes(ResourceManager *resmgr) { /* if the resource couldn't be loaded, leave */ if (r == NULL) { - fprintf(stderr, "unable to load vocab.%03d\n", VOCAB_RESOURCE_OPCODES); + error("unable to load vocab.%03d\n", VOCAB_RESOURCE_OPCODES); return NULL; } |