diff options
56 files changed, 532 insertions, 523 deletions
diff --git a/engines/sci/engine/game.cpp b/engines/sci/engine/game.cpp index bbb02fe87c..28f0454710 100644 --- a/engines/sci/engine/game.cpp +++ b/engines/sci/engine/game.cpp @@ -53,7 +53,7 @@ static int _init_vocabulary(state_t *s) { // initialize vocabulary and related r s->opcodes = vocabulary_get_opcodes(s->resmgr); if (!(s->selector_names = vocabulary_get_snames(s->resmgr, NULL, s->version))) { - sciprintf("_init_vocabulary(): Could not retrieve selector names (vocab.997)!\n"); + sciprintf("_init_vocabulary(): Could not retrieve selector names (vocab.997)"); return 1; } @@ -150,7 +150,7 @@ int _reset_graphics_input(state_t *s) { _sci1_alloc_system_colors(s); scir_unlock_resource(s->resmgr, resource, sci_palette, 999); } else { - sciprintf("Couldn't find the default palette!\n"); + sciprintf("Couldn't find the default palette"); } } } @@ -328,7 +328,7 @@ int create_class_table_sci11(state_t *s) { classnr = getUInt16((byte*)seeker_ptr + 10); if (classnr >= s->classtable_size) { if (classnr >= SCRIPT_MAX_CLASSTABLE_SIZE) { - fprintf(stderr, "Invalid class number 0x%x in script.%d(0x%x), offset %04x\n", + error("Invalid class number 0x%x in script.%d(0x%x), offset %04x\n", classnr, scriptnr, scriptnr, seeker_offset); return 1; } @@ -402,7 +402,7 @@ static int create_class_table_sci0(state_t *s) { if (classnr >= s->classtable_size) { if (classnr >= SCRIPT_MAX_CLASSTABLE_SIZE) { - fprintf(stderr, "Invalid class number 0x%x in script.%d(0x%x), offset %04x\n", + error("Invalid class number 0x%x in script.%d(0x%x), offset %04x\n", classnr, scriptnr, scriptnr, seeker); return 1; } diff --git a/engines/sci/engine/gc.cpp b/engines/sci/engine/gc.cpp index 86ab8f3cd5..bf523e5f7b 100644 --- a/engines/sci/engine/gc.cpp +++ b/engines/sci/engine/gc.cpp @@ -77,7 +77,7 @@ static reg_t worklist_pop(worklist_t **wlp) { reg_t retval; if (!wl || !wl->used) { - fprintf(stderr, "Attempt to pop from empty worklist"); + error("Attempt to pop from empty worklist"); exit(1); } diff --git a/engines/sci/engine/heap.cpp b/engines/sci/engine/heap.cpp index 35f7b7066e..b356172c16 100644 --- a/engines/sci/engine/heap.cpp +++ b/engines/sci/engine/heap.cpp @@ -116,7 +116,7 @@ heap_ptr heap_allocate(heap_t *h, int size) { unsigned int current = previous; if (!size) { - fprintf(stderr, "Warning: heap_alloc'd zero bytes!\n"); + error("Warning: heap_alloc'd zero bytes"); size += 2; } diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp index 26f112fa6a..b84753a638 100644 --- a/engines/sci/engine/kernel.cpp +++ b/engines/sci/engine/kernel.cpp @@ -353,7 +353,7 @@ static const char *argtype_description[] = { "Undetermined (WTF?)", "List", "Nod int kernel_oops(state_t *s, const char *file, int line, const char *reason) { sciprintf("Kernel Oops in file %s, line %d: %s\n", file, line, reason); - fprintf(stderr, "Kernel Oops in file %s, line %d: %s\n", file, line, reason); + error("Kernel Oops in file %s, line %d: %s\n", file, line, reason); script_debug_flag = script_error_flag = 1; return 0; } @@ -386,7 +386,7 @@ byte *kmem(state_t *s, reg_t handle) { hunk_table_t *ht = &(mobj->data.hunks); if (!mobj || !ENTRY_IS_VALID(ht, handle.offset)) { - SCIkwarn(SCIkERROR, "Error: kmem() with invalid handle\n"); + error("Error: kmem() with invalid handle\n"); return NULL; } @@ -504,7 +504,7 @@ reg_t kGetTime(state_t *s, int funct_nr, int argc, reg_t *argv) { #ifdef WIN32 if (TIMERR_NOERROR != timeBeginPeriod(1)) { - fprintf(stderr, "timeBeginPeriod(1) failed in kGetTime!\n"); + error("timeBeginPeriod(1) failed in kGetTime"); } #endif // WIN32 @@ -513,7 +513,7 @@ reg_t kGetTime(state_t *s, int funct_nr, int argc, reg_t *argv) { #ifdef WIN32 if (TIMERR_NOERROR != timeEndPeriod(1)) { - fprintf(stderr, "timeEndPeriod(1) failed in kGetTime!\n"); + error("timeEndPeriod(1) failed in kGetTime"); } #endif // WIN32 @@ -577,7 +577,7 @@ reg_t kMemory(state_t *s, int funct_nr, int argc, reg_t *argv) { switch (UKPV(0)) { case K_MEMORY_ALLOCATE_CRITICAL : if (!sm_alloc_dynmem(&s->seg_manager, UKPV(1), "kMemory() critical", &s->r_acc)) { - SCIkwarn(SCIkERROR, "Critical heap allocation failed\n"); + error("Critical heap allocation failed\n"); script_error_flag = script_debug_flag = 1; } return s->r_acc; @@ -587,7 +587,7 @@ reg_t kMemory(state_t *s, int funct_nr, int argc, reg_t *argv) { break; case K_MEMORY_FREE : if (sm_free_dynmem(&s->seg_manager, argv[1])) { - SCIkwarn(SCIkERROR, "Attempt to kMemory::free() non-dynmem pointer "PREG"!\n", PRINT_REG(argv[1])); + error("Attempt to kMemory::free() non-dynmem pointer "PREG"", PRINT_REG(argv[1])); } break; case K_MEMORY_MEMCPY : { @@ -612,7 +612,7 @@ reg_t kMemory(state_t *s, int funct_nr, int argc, reg_t *argv) { byte *ref = kernel_dereference_bulk_pointer(s, argv[1], 2); if (!ref) { - SCIkdebug(SCIkERROR, "Attempt to poke invalid memory at "PREG"!\n", PRINT_REG(argv[1])); + error("Attempt to poke invalid memory at "PREG"", PRINT_REG(argv[1])); return s->r_acc; } if (s->seg_manager.heap[argv[1].segment]->type == MEM_OBJ_LOCALS) @@ -625,7 +625,7 @@ reg_t kMemory(state_t *s, int funct_nr, int argc, reg_t *argv) { byte *ref = kernel_dereference_bulk_pointer(s, argv[1], 2); if (!ref) { - SCIkdebug(SCIkERROR, "Attempt to poke invalid memory at "PREG"!\n", PRINT_REG(argv[1])); + error("Attempt to poke invalid memory at "PREG"", PRINT_REG(argv[1])); return s->r_acc; } @@ -633,7 +633,7 @@ reg_t kMemory(state_t *s, int funct_nr, int argc, reg_t *argv) { *((reg_t *) ref) = argv[2]; else { if (argv[2].segment) { - SCIkdebug(SCIkERROR, "Attempt to poke memory reference "PREG" to "PREG"!\n", PRINT_REG(argv[2]), PRINT_REG(argv[1])); + error("Attempt to poke memory reference "PREG" to "PREG"", PRINT_REG(argv[2]), PRINT_REG(argv[1])); return s->r_acc; putInt16(ref, argv[2].offset); // ??? } @@ -951,12 +951,12 @@ static inline void *_kernel_dereference_pointer(struct _state *s, reg_t pointer, void *retval = sm_dereference(&s->seg_manager, pointer, &maxsize); if (pointer.offset & (align - 1)) { - SCIkdebug(SCIkERROR, "Unaligned pointer read: "PREG" expected with %d alignment!\n", PRINT_REG(pointer), align); + error("Unaligned pointer read: "PREG" expected with %d alignment", PRINT_REG(pointer), align); return NULL; } if (entries > maxsize) { - SCIkdebug(SCIkERROR, "Trying to dereference pointer "PREG" beyond end of segment!\n", PRINT_REG(pointer)); + error("Trying to dereference pointer "PREG" beyond end of segment", PRINT_REG(pointer)); return NULL; } return retval; diff --git a/engines/sci/engine/kfile.cpp b/engines/sci/engine/kfile.cpp index 7580782472..2b22f6d87a 100644 --- a/engines/sci/engine/kfile.cpp +++ b/engines/sci/engine/kfile.cpp @@ -144,7 +144,7 @@ void file_open(state_t *s, char *filename, int mode) { SCIkdebug(SCIkFILE, "Failed. Attempting to copy from resource dir...\n"); file = f_open_mirrored(s, filename); if (file) - SCIkdebug(SCIkFILE, "Success!\n"); + SCIkdebug(SCIkFILE, "Success"); else SCIkdebug(SCIkFILE, "Not found.\n"); } @@ -181,12 +181,12 @@ reg_t kFOpen(state_t *s, int funct_nr, int argc, reg_t *argv) { static FILE *getFileFromHandle(state_t *s, int handle) { if (handle == 0) { - SCIkwarn(SCIkERROR, "Attempt to use file handle 0\n"); + error("Attempt to use file handle 0\n"); return 0; } if ((handle >= s->file_handles_nr) || (s->file_handles[handle] == NULL)) { - SCIkwarn(SCIkERROR, "Attempt to use invalid/unused file handle %d\n", handle); + error("Attempt to use invalid/unused file handle %d\n", handle); return 0; } @@ -421,7 +421,7 @@ reg_t kDeviceInfo_Win32(state_t *s, int funct_nr, int argc, reg_t *argv) { } break; default: { - SCIkwarn(SCIkERROR, "Unknown DeviceInfo() sub-command: %d\n", mode); + error("Unknown DeviceInfo() sub-command: %d\n", mode); } } return s->r_acc; @@ -483,7 +483,7 @@ reg_t kDeviceInfo_Unix(state_t *s, int funct_nr, int argc, reg_t *argv) { } break; default: { - SCIkwarn(SCIkERROR, "Unknown DeviceInfo() sub-command: %d\n", mode); + error("Unknown DeviceInfo() sub-command: %d\n", mode); } } @@ -780,13 +780,13 @@ reg_t kSaveGame(state_t *s, int funct_nr, int argc, reg_t *argv) { } else ++i; } if (savedir_id >= MAX_SAVEGAME_NR) { - sciprintf("Internal error: Free savegame ID is %d, shouldn't happen!\n", savedir_id); + sciprintf("Internal error: Free savegame ID is %d, shouldn't happen", savedir_id); return NULL_REG; } // This loop terminates when savedir_id is not in [x | ex. n. _savegame_indices[n].id = x] } else { - sciprintf("Savegame ID %d is not allowed!\n", savedir_nr); + sciprintf("Savegame ID %d is not allowed", savedir_nr); return NULL_REG; } @@ -853,7 +853,7 @@ reg_t kRestoreGame(state_t *s, int funct_nr, int argc, reg_t *argv) { } } else { s->r_acc = make_reg(0, 1); - sciprintf("Savegame #%d not found!\n", savedir_nr); + sciprintf("Savegame #%d not found", savedir_nr); } _chdir_restoredir(workdir); @@ -904,7 +904,7 @@ void next_file(state_t *s) { void first_file(state_t *s, const char *dir, char *mask, reg_t buffer) { if (!buffer.segment) { - sciprintf("Warning: first_file(state,\"%s\",\"%s\", 0) invoked!\n", dir, mask); + sciprintf("Warning: first_file(state,\"%s\",\"%s\", 0) invoked", dir, mask); s->r_acc = NULL_REG; return; } @@ -1014,7 +1014,7 @@ reg_t kFileIO(state_t *s, int funct_nr, int argc, reg_t *argv) { break; } default : - SCIkwarn(SCIkERROR, "Unknown FileIO() sub-command: %d\n", func_nr); + error("Unknown FileIO() sub-command: %d\n", func_nr); } return s->r_acc; diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp index c4fb62c7d3..8f41ac2d91 100644 --- a/engines/sci/engine/kgraphics.cpp +++ b/engines/sci/engine/kgraphics.cpp @@ -90,7 +90,7 @@ if (val == GFX_ERROR) \ warning("GFX subsystem returned error on \"" #x "\""); \ else {\ - SCIkwarn(SCIkERROR, "GFX subsystem fatal error condition on \"" #x "\"!\n"); \ + error("GFX subsystem fatal error condition on \"" #x "\""); \ vm_handle_fatal_error(s, __LINE__, __FILE__); \ } \ }\ @@ -99,7 +99,7 @@ #define ASSERT(x) { \ int val = !!(x); \ if (!val) { \ - SCIkwarn(SCIkERROR, "Fatal error condition on \"" #x "\"!\n"); \ + error("Fatal error condition on \"" #x "\""); \ BREAKPOINT(); \ vm_handle_fatal_error(s, __LINE__, __FILE__); \ } \ @@ -218,7 +218,7 @@ void graph_restore_box(state_t *s, reg_t handle) { while (port_nr > 2 && !(s->port->flags & GFXW_FLAG_IMMUNE_TO_SNAPSHOTS) && (gfxw_widget_matches_snapshot(*ptr, GFXW(s->port)))) { // This shouldn't ever happen, actually, since windows (ports w/ ID > 2) should all be immune gfxw_port_t *newport = gfxw_find_port(s->visual, port_nr); - SCIkwarn(SCIkERROR, "Port %d is not immune against snapshots!\n", s->port->ID); + error("Port %d is not immune against snapshots", s->port->ID); port_nr--; if (newport) s->port = newport; @@ -232,7 +232,7 @@ void graph_restore_box(state_t *s, reg_t handle) { } while (parent && (gfxw_widget_matches_snapshot(*ptr, GFXW(parent)))); if (!parent) { - SCIkwarn(SCIkERROR, "Attempted widget mass destruction by a snapshot\n"); + error("Attempted widget mass destruction by a snapshot\n"); BREAKPOINT(); } @@ -241,7 +241,7 @@ void graph_restore_box(state_t *s, reg_t handle) { if (!ptr) { - SCIkwarn(SCIkERROR, "Attempt to restore invalid snaphot with handle %04x!\n", handle); + error("Attempt to restore invalid snaphot with handle %04x", handle); return; } @@ -271,7 +271,7 @@ gfx_pixmap_color_t *get_pic_color(state_t *s, int color) { else if (color < KERNEL_COLORS_NR) return &(KERNEL_COLOR_PALETTE[color]); else { - SCIkwarn(SCIkERROR, "Color index %d out of bounds for pic %d (%d max)", color, s->gfx_state->pic_nr, KERNEL_COLORS_NR); + error("Color index %d out of bounds for pic %d (%d max)", color, s->gfx_state->pic_nr, KERNEL_COLORS_NR); BREAKPOINT(); return NULL; } @@ -332,7 +332,7 @@ reg_t kSetCursor_SCI11(state_t *s, int funct_nr, int argc, reg_t *argv) { break; } default : - SCIkwarn(SCIkERROR, "kSetCursor: Unhandled case: %d arguments given!\n", argc); + error("kSetCursor: Unhandled case: %d arguments given", argc); break; } return s->r_acc; @@ -435,7 +435,7 @@ reg_t kPicNotValid(state_t *s, int funct_nr, int argc, reg_t *argv) { } void _k_redraw_box(state_t *s, int x1, int y1, int x2, int y2) { - sciprintf("_k_redraw_box(): Unimplemented!\n"); + sciprintf("_k_redraw_box(): Unimplemented"); #if 0 int i; view_object_t *list = s->dyn_views; @@ -710,7 +710,7 @@ void _k_dirloop(reg_t obj, word angle, state_t *s, int funct_nr, int argc, reg_t maxloops = gfxop_lookup_view_get_loops(s->gfx_state, view); if (maxloops == GFX_ERROR) { - SCIkwarn(SCIkERROR, "Invalid view.%03d\n", view); + error("Invalid view.%03d\n", view); return; } else if ((loop > 1) && (maxloops < 4)) return; @@ -901,7 +901,7 @@ reg_t kCelHigh(state_t *s, int funct_nr, int argc, reg_t *argv) { } if (gfxop_get_cel_parameters(s->gfx_state, view, loop, cel, &width, &height, &offset)) { - SCIkwarn(SCIkERROR, "Invalid loop (%d) or cel (%d) in view.%d (0x%x), or view invalid\n", loop, cel, view, view); + error("Invalid loop (%d) or cel (%d) in view.%d (0x%x), or view invalid\n", loop, cel, view, view); return NULL_REG; } else return make_reg(0, height); @@ -919,7 +919,7 @@ reg_t kCelWide(state_t *s, int funct_nr, int argc, reg_t *argv) { } if (gfxop_get_cel_parameters(s->gfx_state, view, loop, cel, &width, &height, &offset)) { - SCIkwarn(SCIkERROR, "Invalid loop (%d) or cel (%d) in view.%d (0x%x), or view invalid\n", loop, cel, view, view); + error("Invalid loop (%d) or cel (%d) in view.%d (0x%x), or view invalid\n", loop, cel, view, view); return NULL_REG; } else return make_reg(0, width); @@ -931,7 +931,7 @@ reg_t kNumLoops(state_t *s, int funct_nr, int argc, reg_t *argv) { int loops_nr = gfxop_lookup_view_get_loops(s->gfx_state, view); if (loops_nr < 0) { - SCIkwarn(SCIkERROR, "view.%d (0x%x) not found\n", view, view); + error("view.%d (0x%x) not found\n", view, view); return NULL_REG; } @@ -950,7 +950,7 @@ reg_t kNumCels(state_t *s, int funct_nr, int argc, reg_t *argv) { if (gfxop_check_cel(s->gfx_state, view, &loop, &cel)) { // OK, this is a hack and there's a // real function to calculate cel numbers... - SCIkwarn(SCIkERROR, "view.%d (0x%x) not found\n", view, view); + error("view.%d (0x%x) not found\n", view, view); return NULL_REG; } @@ -1054,10 +1054,10 @@ reg_t kDrawPic(state_t *s, int funct_nr, int argc, reg_t *argv) { if (sci01_priority_table_flags & 0x2) { if (s->pic_priority_table) { int i; - fprintf(stderr, "---------------------------\nPriority table:\n"); + error("---------------------------\nPriority table:\n"); for (i = 0; i < 16; i++) - fprintf(stderr, "\t%d:\t%d\n", i, s->pic_priority_table[i]); - fprintf(stderr, "---------------------------\n"); + error("\t%d:\t%d\n", i, s->pic_priority_table[i]); + error("---------------------------\n"); } } if (sci01_priority_table_flags & 0x1) @@ -1115,7 +1115,7 @@ abs_rect_t set_base(state_t *s, reg_t object) { if (loop != oldloop) { loop = 0; PUT_SEL32V(object, loop, 0); - SCIkdebug(SCIkGRAPHICS, "Resetting loop for "PREG"!\n", PRINT_REG(object)); + SCIkdebug(SCIkGRAPHICS, "Resetting loop for "PREG"", PRINT_REG(object)); } if (cel != oldcel) { @@ -1719,19 +1719,19 @@ static void _k_view_list_do_postdraw(state_t *s, gfxw_list_t *list) { temp = GET_SEL32V(obj, nsBottom); PUT_SEL32V(obj, lsBottom, temp); #ifdef DEBUG_LSRECT - fprintf(stderr, "lsRected "PREG"\n", PRINT_REG(obj)); + error("lsRected "PREG"\n", PRINT_REG(obj)); #endif } #ifdef DEBUG_LSRECT else - fprintf(stderr, "Not lsRecting "PREG" because %d\n", PRINT_REG(obj), lookup_selector(s, obj, s->selector_map.nsBottom, NULL, NULL)); + error("Not lsRecting "PREG" because %d\n", PRINT_REG(obj), lookup_selector(s, obj, s->selector_map.nsBottom, NULL, NULL)); #endif if (widget->signal & _K_VIEW_SIG_FLAG_HIDDEN) widget->signal |= _K_VIEW_SIG_FLAG_REMOVE; } #ifdef DEBUG_LSRECT - fprintf(stderr, "obj "PREG" has pflags %x\n", PRINT_REG(obj), (widget->signal & (_K_VIEW_SIG_FLAG_REMOVE | _K_VIEW_SIG_FLAG_NO_UPDATE))); + error("obj "PREG" has pflags %x\n", PRINT_REG(obj), (widget->signal & (_K_VIEW_SIG_FLAG_REMOVE | _K_VIEW_SIG_FLAG_NO_UPDATE))); #endif if (widget->signalp) { @@ -1783,7 +1783,7 @@ int _k_view_list_dispose_loop(state_t *s, list_t *list, gfxw_dyn_view_t *widget, reg_t under_bits = NULL_REG; if (!is_object(s, obj)) { - SCIkwarn(SCIkERROR, "Non-object "PREG" present in view list during delete time\n", PRINT_REG(obj)); + error("Non-object "PREG" present in view list during delete time\n", PRINT_REG(obj)); obj = NULL_REG; } else if (widget->under_bitsp) { // Is there a bg picture left to clean? @@ -1820,7 +1820,7 @@ int _k_view_list_dispose_loop(state_t *s, list_t *list, gfxw_dyn_view_t *widget, if (!(signal & _K_VIEW_SIG_FLAG_HIDDEN)) { SCIkdebug(SCIkGRAPHICS, "Adding view at "PREG" to background\n", PRINT_REG(obj)); if (!(gfxw_remove_id(widget->parent, widget->ID, widget->subID) == GFXW(widget))) { - SCIkwarn(SCIkERROR, "Attempt to remove view with ID %x:%x from list failed!\n", widget->ID, widget->subID); + error("Attempt to remove view with ID %x:%x from list failed", widget->ID, widget->subID); BREAKPOINT(); } @@ -1938,7 +1938,7 @@ static void _k_make_view_list(state_t *s, gfxw_list_t **widget_list, list_t *lis gfxw_dyn_view_t *widget; if (!*widget_list) { - SCIkwarn(SCIkERROR, "make_view_list with widget_list == ()\n"); + error("make_view_list with widget_list == ()\n"); BREAKPOINT(); }; @@ -1947,7 +1947,7 @@ static void _k_make_view_list(state_t *s, gfxw_list_t **widget_list, list_t *lis // Yes, this _does_ happen! if (!list) { // list sanity check - SCIkwarn(SCIkERROR, "Attempt to make list from non-list!\n"); + error("Attempt to make list from non-list"); BREAKPOINT(); } @@ -2066,7 +2066,7 @@ static void _k_prepare_view_list(state_t *s, gfxw_list_t *list, int options) { // Never happens /* if (view->signal & 0) { view->signal &= ~_K_VIEW_SIG_FLAG_FREESCI_STOPUPD; - fprintf(stderr, "Unsetting magic StopUpd for view "PREG"\n", PRINT_REG(obj)); + error("Unsetting magic StopUpd for view "PREG"\n", PRINT_REG(obj)); } */ view = (gfxw_dyn_view_t *) view->next; @@ -2265,7 +2265,7 @@ reg_t kAddToPic(state_t *s, int funct_nr, int argc, reg_t *argv) { priority, -1 /* No priority */ , ALIGN_CENTER, ALIGN_BOTTOM, 0)); if (!widget) { - SCIkwarn(SCIkERROR, "Attempt to single-add invalid picview (%d/%d/%d)\n", view, loop, cel); + error("Attempt to single-add invalid picview (%d/%d/%d)\n", view, loop, cel); } else { widget->ID = -1; if (control >= 0) { @@ -2329,7 +2329,7 @@ reg_t kSetPort(state_t *s, int funct_nr, int argc, reg_t *argv) { new_port = gfxw_find_port(s->visual, port_nr); if (!new_port) { - SCIkwarn(SCIkERROR, "Invalid port %04x requested\n", port_nr); + error("Invalid port %04x requested\n", port_nr); return NULL_REG; } @@ -2357,7 +2357,7 @@ reg_t kSetPort(state_t *s, int funct_nr, int argc, reg_t *argv) { break; } default : - SCIkwarn(SCIkERROR, "SetPort was called with %d parameters\n", argc); + error("SetPort was called with %d parameters\n", argc); break; } @@ -2386,13 +2386,13 @@ reg_t kDrawCel(state_t *s, int funct_nr, int argc, reg_t *argv) { /* if (!view) { - SCIkwarn(SCIkERROR, "Attempt to draw non-existing view.%03d\n", view); + error("Attempt to draw non-existing view.%03d\n", view); return; } */ if (gfxop_check_cel(s->gfx_state, view, &loop, &cel)) { - SCIkwarn(SCIkERROR, "Attempt to draw non-existing view.%03d\n", view); + error("Attempt to draw non-existing view.%03d\n", view); return s->r_acc; } @@ -2420,7 +2420,7 @@ reg_t kDisposeWindow(state_t *s, int funct_nr, int argc, reg_t *argv) { gfxw_widget_kill_chrono(s->visual, goner_nr); goner = gfxw_find_port(s->visual, goner_nr); if ((goner_nr < 3) || (goner == NULL)) { - SCIkwarn(SCIkERROR, "Removal of invalid window %04x requested\n", goner_nr); + error("Removal of invalid window %04x requested\n", goner_nr); return s->r_acc; } @@ -2569,7 +2569,7 @@ static void animate_do_animation(state_t *s, int funct_nr, int argc, reg_t *argv gfxop_set_clip_zone(s->gfx_state, gfx_rect_fullscreen); if (!newscreen) { - SCIkwarn(SCIkERROR, "Failed to allocate 'newscreen'!\n"); + error("Failed to allocate 'newscreen'"); return; } @@ -3121,7 +3121,7 @@ reg_t kDisplay(state_t *s, int funct_nr, int argc, reg_t *argv) { } if (!text) { - SCIkdebug(SCIkERROR, "Display with invalid reference "PREG"!\n", PRINT_REG(textp)); + error("Display with invalid reference "PREG"", PRINT_REG(textp)); return NULL_REG; } @@ -3247,7 +3247,7 @@ reg_t kDisplay(state_t *s, int funct_nr, int argc, reg_t *argv) { text_handle = gfxw_new_text(s->gfx_state, area, font_nr, text, halign, ALIGN_TOP, color0, *color1, bg_color, 0); if (!text_handle) { - SCIkwarn(SCIkERROR, "Display: Failed to create text widget!\n"); + error("Display: Failed to create text widget"); return NULL_REG; } diff --git a/engines/sci/engine/klists.cpp b/engines/sci/engine/klists.cpp index 5380c30bd5..e08610a9af 100644 --- a/engines/sci/engine/klists.cpp +++ b/engines/sci/engine/klists.cpp @@ -172,12 +172,12 @@ reg_t kDisposeList(state_t *s, int funct_nr, int argc, reg_t *argv) { list_t *l = LOOKUP_LIST(argv[0]); if (!l) { - SCIkwarn(SCIkERROR, "Attempt to dispose non-list at "PREG"!\n", PRINT_REG(argv[0])); + error("Attempt to dispose non-list at "PREG"", PRINT_REG(argv[0])); return NULL_REG; } if (!sane_listp(s, argv[0])) - SCIkwarn(SCIkERROR, "List at "PREG" is not sane anymore!\n", PRINT_REG(argv[0])); + error("List at "PREG" is not sane anymore", PRINT_REG(argv[0])); /* if (!IS_NULL_REG(l->first)) { reg_t n_addr = l->first; @@ -222,7 +222,7 @@ reg_t kFirstNode(state_t *s, int funct_nr, int argc, reg_t *argv) { list_t *l = LOOKUP_NULL_LIST(argv[0]); if (l && !sane_listp(s, argv[0])) - SCIkwarn(SCIkERROR, "List at "PREG" is not sane anymore!\n", PRINT_REG(argv[0])); + error("List at "PREG" is not sane anymore", PRINT_REG(argv[0])); if (l) return l->first; @@ -234,7 +234,7 @@ reg_t kLastNode(state_t *s, int funct_nr, int argc, reg_t *argv) { list_t *l = LOOKUP_LIST(argv[0]); if (l && !sane_listp(s, argv[0])) - SCIkwarn(SCIkERROR, "List at "PREG" is not sane anymore!\n", PRINT_REG(argv[0])); + error("List at "PREG" is not sane anymore", PRINT_REG(argv[0])); if (l) return l->last; @@ -246,7 +246,7 @@ reg_t kEmptyList(state_t *s, int funct_nr, int argc, reg_t *argv) { list_t *l = LOOKUP_LIST(argv[0]); if (!l || !sane_listp(s, argv[0])) - SCIkwarn(SCIkERROR, "List at "PREG" is invalid or not sane anymore!\n", PRINT_REG(argv[0])); + error("List at "PREG" is invalid or not sane anymore", PRINT_REG(argv[0])); return make_reg(0, ((l) ? IS_NULL_REG(l->first) : 0)); } @@ -258,9 +258,9 @@ inline void _k_add_to_front(state_t *s, reg_t listbase, reg_t nodebase) { SCIkdebug(SCIkNODES, "Adding node "PREG" to end of list "PREG"\n", PRINT_REG(nodebase), PRINT_REG(listbase)); if (!new_n) - SCIkwarn(SCIkERROR, "Attempt to add non-node ("PREG") to list at "PREG"\n", PRINT_REG(nodebase), PRINT_REG(listbase)); + error("Attempt to add non-node ("PREG") to list at "PREG"\n", PRINT_REG(nodebase), PRINT_REG(listbase)); if (!l || !sane_listp(s, listbase)) - SCIkwarn(SCIkERROR, "List at "PREG" is not sane anymore!\n", PRINT_REG(listbase)); + error("List at "PREG" is not sane anymore", PRINT_REG(listbase)); new_n->succ = l->first; new_n->pred = NULL_REG; @@ -281,9 +281,9 @@ inline void _k_add_to_end(state_t *s, reg_t listbase, reg_t nodebase) { SCIkdebug(SCIkNODES, "Adding node "PREG" to end of list "PREG"\n", PRINT_REG(nodebase), PRINT_REG(listbase)); if (!new_n) - SCIkwarn(SCIkERROR, "Attempt to add non-node ("PREG") to list at "PREG"\n", PRINT_REG(nodebase), PRINT_REG(listbase)); + error("Attempt to add non-node ("PREG") to list at "PREG"\n", PRINT_REG(nodebase), PRINT_REG(listbase)); if (!l || !sane_listp(s, listbase)) - SCIkwarn(SCIkERROR, "List at "PREG" is not sane anymore!\n", PRINT_REG(listbase)); + error("List at "PREG" is not sane anymore", PRINT_REG(listbase)); new_n->succ = NULL_REG; new_n->pred = l->last; @@ -300,7 +300,7 @@ inline void _k_add_to_end(state_t *s, reg_t listbase, reg_t nodebase) { reg_t kNextNode(state_t *s, int funct_nr, int argc, reg_t *argv) { node_t *n = LOOKUP_NODE(argv[0]); if (!sane_nodep(s, argv[0])) { - SCIkwarn(SCIkERROR, "List node at "PREG" is not sane anymore!\n", PRINT_REG(argv[0])); + error("List node at "PREG" is not sane anymore", PRINT_REG(argv[0])); script_error_flag = script_debug_flag = 0; return NULL_REG; } @@ -311,7 +311,7 @@ reg_t kNextNode(state_t *s, int funct_nr, int argc, reg_t *argv) { reg_t kPrevNode(state_t *s, int funct_nr, int argc, reg_t *argv) { node_t *n = LOOKUP_NODE(argv[0]); if (!sane_nodep(s, argv[0])) - SCIkwarn(SCIkERROR, "List node at "PREG" is not sane anymore!\n", PRINT_REG(argv[0])); + error("List node at "PREG" is not sane anymore", PRINT_REG(argv[0])); return n->pred; } @@ -319,7 +319,7 @@ reg_t kPrevNode(state_t *s, int funct_nr, int argc, reg_t *argv) { reg_t kNodeValue(state_t *s, int funct_nr, int argc, reg_t *argv) { node_t *n = LOOKUP_NODE(argv[0]); if (!sane_nodep(s, argv[0])) { - SCIkwarn(SCIkERROR, "List node at "PREG" is not sane!\n", PRINT_REG(argv[0])); + error("List node at "PREG" is not sane", PRINT_REG(argv[0])); script_debug_flag = script_error_flag = 0; return NULL_REG; } @@ -338,10 +338,10 @@ reg_t kAddAfter(state_t *s, int funct_nr, int argc, reg_t *argv) { node_t *newnode = LOOKUP_NODE(argv[2]); if (!l || !sane_listp(s, argv[0])) - SCIkwarn(SCIkERROR, "List at "PREG" is not sane anymore!\n", PRINT_REG(argv[0])); + error("List at "PREG" is not sane anymore", PRINT_REG(argv[0])); if (!newnode) { - SCIkwarn(SCIkERROR, "New 'node' "PREG" is not a node!\n", argv[1], argv[2]); + error("New 'node' "PREG" is not a node", argv[1], argv[2]); return NULL_REG; } @@ -384,7 +384,7 @@ reg_t kFindKey(state_t *s, int funct_nr, int argc, reg_t *argv) { SCIkdebug(SCIkNODES, "Looking for key "PREG" in list "PREG"\n", PRINT_REG(key), PRINT_REG(list_pos)); if (!sane_listp(s, list_pos)) - SCIkwarn(SCIkERROR, "List at "PREG" is not sane anymore!\n", PRINT_REG(list_pos)); + error("List at "PREG" is not sane anymore", PRINT_REG(list_pos)); node_pos = LOOKUP_LIST(list_pos)->first; diff --git a/engines/sci/engine/kmovement.cpp b/engines/sci/engine/kmovement.cpp index 45e080016e..a5e9a4ec53 100644 --- a/engines/sci/engine/kmovement.cpp +++ b/engines/sci/engine/kmovement.cpp @@ -423,7 +423,7 @@ reg_t kDoAvoider(state_t *s, int funct_nr, int argc, reg_t *argv) { SCIkdebug(SCIkBRESEN, "Doing avoider %04x (dest=%d,%d)\n", avoider, destx, desty); if (invoke_selector(INV_SEL(mover, doit, 1) , 0)) { - SCIkwarn(SCIkERROR, "Mover "PREG" of avoider "PREG" doesn't have a doit() funcselector\n", PRINT_REG(mover), PRINT_REG(avoider)); + error("Mover "PREG" of avoider "PREG" doesn't have a doit() funcselector\n", PRINT_REG(mover), PRINT_REG(avoider)); return NULL_REG; } @@ -432,7 +432,7 @@ reg_t kDoAvoider(state_t *s, int funct_nr, int argc, reg_t *argv) { return s->r_acc; // Return gracefully. if (invoke_selector(INV_SEL(client, isBlocked, 1) , 0)) { - SCIkwarn(SCIkERROR, "Client "PREG" of avoider "PREG" doesn't" + error("Client "PREG" of avoider "PREG" doesn't" " have an isBlocked() funcselector\n", PRINT_REG(client), PRINT_REG(avoider)); return NULL_REG; } @@ -463,7 +463,7 @@ reg_t kDoAvoider(state_t *s, int funct_nr, int argc, reg_t *argv) { SCIkdebug(SCIkBRESEN, "Pos (%d,%d): Trying angle %d; delta=(%d,%d)\n", oldx, oldy, angle, move_x, move_y); if (invoke_selector(INV_SEL(client, canBeHere, 1) , 0)) { - SCIkwarn(SCIkERROR, "Client "PREG" of avoider "PREG" doesn't" + error("Client "PREG" of avoider "PREG" doesn't" " have a canBeHere() funcselector\n", PRINT_REG(client), PRINT_REG(avoider)); return NULL_REG; } @@ -497,7 +497,7 @@ reg_t kDoAvoider(state_t *s, int funct_nr, int argc, reg_t *argv) { if (looper.segment) { if (invoke_selector(INV_SEL(looper, doit, 1), 2, angle, client)) { - SCIkwarn(SCIkERROR, "Looper "PREG" of avoider "PREG" doesn't" + error("Looper "PREG" of avoider "PREG" doesn't" " have a doit() funcselector\n", PRINT_REG(looper), PRINT_REG(avoider)); } else return s->r_acc; diff --git a/engines/sci/engine/kscripts.cpp b/engines/sci/engine/kscripts.cpp index 40e1d0159e..0819965cfe 100644 --- a/engines/sci/engine/kscripts.cpp +++ b/engines/sci/engine/kscripts.cpp @@ -69,7 +69,7 @@ int invoke_selector(state_t *s, reg_t object, int selector_id, int noinvalid, in slc_type = lookup_selector(s, object, selector_id, NULL, &address); if (slc_type == SELECTOR_NONE) { - SCIkwarn(SCIkERROR, "Selector '%s' of object at "PREG" could not be invoked (%s L%d)\n", + error("Selector '%s' of object at "PREG" could not be invoked (%s L%d)\n", s->selector_names[selector_id], PRINT_REG(object), fname, line); if (noinvalid == 0) KERNEL_OOPS("Not recoverable: VM was halted\n"); @@ -158,7 +158,7 @@ reg_t kClone(state_t *s, int funct_nr, int argc, reg_t *argv) { int varblock_size; if (!parent_obj) { - SCIkwarn(SCIkERROR, "Attempt to clone non-object/class at "PREG" failed", PRINT_REG(parent_addr)); + error("Attempt to clone non-object/class at "PREG" failed", PRINT_REG(parent_addr)); return NULL_REG; } @@ -167,7 +167,7 @@ reg_t kClone(state_t *s, int funct_nr, int argc, reg_t *argv) { clone_obj = sm_alloc_clone(&s->seg_manager, &clone_addr); if (!clone_obj) { - SCIkwarn(SCIkERROR, "Cloning "PREG" failed-- internal error!\n", PRINT_REG(parent_addr)); + error("Cloning "PREG" failed-- internal error", PRINT_REG(parent_addr)); return NULL_REG; } @@ -196,7 +196,7 @@ reg_t kDisposeClone(state_t *s, int funct_nr, int argc, reg_t *argv) { word underBits; if (!victim_obj) { - SCIkwarn(SCIkERROR, "Attempt to dispose non-class/object at "PREG"\n", + error("Attempt to dispose non-class/object at "PREG"\n", PRINT_REG(victim_addr)); return s->r_acc; } @@ -244,12 +244,12 @@ reg_t kScriptID(state_t *s, int funct_nr, int argc, reg_t *argv) { scr = &(s->seg_manager.heap[scriptid]->data.script); if (!scr->exports_nr) { - SCIkdebug(SCIkERROR, "Script 0x%x does not have a dispatch table\n", script); + error("Script 0x%x does not have a dispatch table\n", script); return NULL_REG; } if (index > scr->exports_nr) { - SCIkwarn(SCIkERROR, "Dispatch index too big: %d > %d\n", index, scr->exports_nr); + error("Dispatch index too big: %d > %d\n", index, scr->exports_nr); return NULL_REG; } diff --git a/engines/sci/engine/ksound.cpp b/engines/sci/engine/ksound.cpp index fc5bc49224..21b476c5c1 100644 --- a/engines/sci/engine/ksound.cpp +++ b/engines/sci/engine/ksound.cpp @@ -938,14 +938,14 @@ kDoSound_SCI1(state_t *s, int funct_nr, int argc, reg_t *argv) { case SI_ABSOLUTE_CUE: signal = cue; - fprintf(stderr, "[CUE] "PREG" Absolute Cue: %d\n", + error("[CUE] "PREG" Absolute Cue: %d\n", PRINT_REG(obj), signal); PUT_SEL32V(obj, signal, signal); break; case SI_RELATIVE_CUE: - fprintf(stderr, "[CUE] "PREG" Relative Cue: %d\n", + error("[CUE] "PREG" Relative Cue: %d\n", PRINT_REG(obj), cue); PUT_SEL32V(obj, dataInc, cue); diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp index 4f15276f21..7f2d82858b 100644 --- a/engines/sci/engine/kstring.cpp +++ b/engines/sci/engine/kstring.cpp @@ -31,7 +31,7 @@ #define CHECK_OVERFLOW1(pt, size, rv) \ if (((pt) - (str_base)) + (size) > maxsize) { \ - SCIkwarn(SCIkERROR, "String expansion exceeded heap boundaries\n"); \ + error("String expansion exceeded heap boundaries\n"); \ return rv;\ } @@ -50,7 +50,7 @@ kernel_lookup_text(state_t *s, reg_t address, int index) textres = scir_find_resource(s->resmgr, sci_text, address.offset, 0); if (!textres) { - SCIkwarn(SCIkERROR, "text.%03d not found\n", address); + error("text.%03d not found\n", address); return NULL; /* Will probably segfault */ } @@ -63,7 +63,7 @@ kernel_lookup_text(state_t *s, reg_t address, int index) if (textlen) return seeker; else { - SCIkwarn(SCIkERROR, "Index %d out of bounds in text.%03d\n", _index, address); + error("Index %d out of bounds in text.%03d\n", _index, address); return 0; } @@ -224,7 +224,7 @@ kSetSynonyms(state_t *s, int funct_nr, int argc, reg_t *argv) { synonyms_nr, script); if (synonyms_nr > 16384) { - SCIkwarn(SCIkERROR, "Segtable corruption: script.%03d has %d synonyms!\n", + error("Segtable corruption: script.%03d has %d synonyms", script, synonyms_nr); /* We used to reset the corrupted value here. I really don't think it's appropriate. * Lars */ @@ -708,7 +708,7 @@ kGetFarText(state_t *s, int funct_nr, int argc, reg_t *argv) { if (!textres) { - SCIkwarn(SCIkERROR, "text.%d does not exist\n", UKPV(0)); + error("text.%d does not exist\n", UKPV(0)); return NULL_REG; } diff --git a/engines/sci/engine/said.cpp b/engines/sci/engine/said.cpp index 1ae8b2b1f2..fa1979ff82 100644 --- a/engines/sci/engine/said.cpp +++ b/engines/sci/engine/said.cpp @@ -832,10 +832,10 @@ yytype_int16 *bottom; yytype_int16 *top; #endif { - YYFPRINTF(stderr, "Stack now"); + YYerror("Stack now"); for (; bottom <= top; ++bottom) - YYFPRINTF(stderr, " %d", *bottom); - YYFPRINTF(stderr, "\n"); + YYerror(" %d", *bottom); + YYerror("\n"); } # define YY_STACK_PRINT(Bottom, Top) \ @@ -863,15 +863,15 @@ int yyrule; int yynrhs = yyr2[yyrule]; int yyi; unsigned long int yylno = yyrline[yyrule]; - YYFPRINTF(stderr, "Reducing stack by rule %d (line %lu):\n", + YYerror("Reducing stack by rule %d (line %lu):\n", yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { - fprintf(stderr, " $%d = ", yyi + 1); + error(" $%d = ", yyi + 1); yy_symbol_print(stderr, yyrhs[yyprhs[yyrule] + yyi], &(yyvsp[(yyi + 1) - (yynrhs)]) ); - fprintf(stderr, "\n"); + error("\n"); } } @@ -1890,7 +1890,7 @@ static tree_t said_aug_branch(int n1, int n2, tree_t t1, tree_t t2) { said_branch_node(SAID_NEXT_NODE, said_leaf_node(SAID_NEXT_NODE, n2), t1)), t2); #ifdef SAID_DEBUG - fprintf(stderr, "AUG(0x%x, 0x%x, [%04x], [%04x]) = [%04x]\n", n1, n2, t1, t2, retval); + error("AUG(0x%x, 0x%x, [%04x], [%04x]) = [%04x]\n", n1, n2, t1, t2, retval); #endif return retval; @@ -1898,7 +1898,7 @@ static tree_t said_aug_branch(int n1, int n2, tree_t t1, tree_t t2) { static tree_t said_attach_branch(tree_t base, tree_t attacheant) { #ifdef SAID_DEBUG - fprintf(stderr, "ATT2([%04x], [%04x]) = [%04x]\n", base, attacheant, base); + error("ATT2([%04x], [%04x]) = [%04x]\n", base, attacheant, base); #endif if (!attacheant) @@ -1916,7 +1916,7 @@ static tree_t said_attach_branch(tree_t base, tree_t attacheant) { static said_spec_t said_top_branch(tree_t first) { #ifdef SAID_DEBUG - fprintf(stderr, "TOP([%04x])\n", first); + error("TOP([%04x])\n", first); #endif said_branch_node(0, 1, 2); said_leaf_node(1, 0x141); // Magic number #1 diff --git a/engines/sci/engine/scriptconsole.cpp b/engines/sci/engine/scriptconsole.cpp index 5687d30559..8357b212b9 100644 --- a/engines/sci/engine/scriptconsole.cpp +++ b/engines/sci/engine/scriptconsole.cpp @@ -579,7 +579,7 @@ con_parse(state_t *s, const char *command) { break; default: - fprintf(stderr, "Internal error: Heap corruption or prior assertion failed:\n" + error("Internal error: Heap corruption or prior assertion failed:\n" "Unknown parameter type '%c' for funtion\n", paramtype); } @@ -587,7 +587,7 @@ con_parse(state_t *s, const char *command) { if (do_execute) { command_todo->command(s); - } else fprintf(stderr, "Skipping command...\n"); + } else error("Skipping command...\n"); } } } @@ -907,7 +907,7 @@ c_list(state_t * s) { + i * cmd_mm[mm_found].size_per_entry), 0); else { if (!s) { - sciprintf("You need a state to do that!\n"); + sciprintf("You need a state to do that"); return 1; } @@ -1047,14 +1047,14 @@ c_hexgrep(state_t * s) { char *dot = strchr(cmd_params[0].str, '.'); if (NULL == s) { - fprintf(stderr, "console.c: c_hexgrep(): NULL passed for s\r\n"); + error("console.c: c_hexgrep(): NULL passed for s\r\n"); return(-1); } seekstr = (unsigned char*)sci_malloc(seeklen = (cmd_paramlength - 1)); if (NULL == seekstr) { - fprintf(stderr, "console.c: c_hexgrep(): malloc failed for seekstr\r\n"); + error("console.c: c_hexgrep(): malloc failed for seekstr\r\n"); return(-1); } @@ -1126,7 +1126,7 @@ c_selectornames(state_t * s) { snames = vocabulary_get_snames(s->resmgr, &namectr, s ? s->version : 0); if (!snames) { - sciprintf("No selector name table found!\n"); + sciprintf("No selector name table found"); return 1; } @@ -1151,7 +1151,7 @@ c_kernelnames(state_t * s) { } if (!knames) { - sciprintf("No kernel name table found!\n"); + sciprintf("No kernel name table found"); return 1; } diff --git a/engines/sci/engine/scriptdebug.cpp b/engines/sci/engine/scriptdebug.cpp index 6fa17d5227..b5c9c9b377 100644 --- a/engines/sci/engine/scriptdebug.cpp +++ b/engines/sci/engine/scriptdebug.cpp @@ -38,10 +38,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 @@ -158,24 +158,24 @@ midi_hexdump(byte *data, int size, int notational_offset) { /* Specialised for S int blanks = 0; offset += offset_mod; - fprintf(stderr, " [%04x] %d\t", + error(" [%04x] %d\t", old_offset + notational_offset, time); cmd = data[offset]; if (!(cmd & 0x80)) { cmd = prev; if (prev < 0x80) { - fprintf(stderr, "Track broken at %x after" + error("Track broken at %x after" " offset mod of %d\n", offset + notational_offset, offset_mod); sci_hexdump(data, size, notational_offset); return; } - fprintf(stderr, "(rs %02x) ", cmd); + error("(rs %02x) ", cmd); blanks += 8; } else { ++offset; - fprintf(stderr, "%02x ", cmd); + error("%02x ", cmd); blanks += 3; } prev = cmd; @@ -188,37 +188,37 @@ midi_hexdump(byte *data, int size, int notational_offset) { /* Specialised for S for (i = 0; i < pleft; i++) { if (i == 0) firstarg = data[offset]; - fprintf(stderr, "%02x ", data[offset++]); + error("%02x ", data[offset++]); blanks += 3; } while (blanks < 16) { blanks += 4; - fprintf(stderr, " "); + error(" "); } while (blanks < 20) { ++blanks; - fprintf(stderr, " "); + error(" "); } if (cmd == SCI_MIDI_EOT) - fprintf(stderr, ";; EOT"); + error(";; EOT"); else if (cmd == SCI_MIDI_SET_SIGNAL) { if (firstarg == SCI_MIDI_SET_SIGNAL_LOOP) - fprintf(stderr, ";; LOOP point"); + error(";; LOOP point"); else - fprintf(stderr, ";; CUE (%d)", firstarg); + error(";; CUE (%d)", firstarg); } else if (SCI_MIDI_CONTROLLER(cmd)) { if (firstarg == SCI_MIDI_CUMULATIVE_CUE) - fprintf(stderr, ";; CUE (cumulative)"); + error(";; CUE (cumulative)"); else if (firstarg == SCI_MIDI_RESET_ON_SUSPEND) - fprintf(stderr, ";; RESET-ON-SUSPEND flag"); + error(";; RESET-ON-SUSPEND flag"); } - fprintf(stderr, "\n"); + error("\n"); if (old_offset >= offset) { - fprintf(stderr, "-- Not moving forward anymore," + error("-- Not moving forward anymore," " aborting (%x/%x)\n", offset, old_offset); return; } @@ -406,7 +406,7 @@ print_list(state_t *s, list_t *l) { mem_obj_t *mobj = GET_SEGMENT(s->seg_manager, pos.segment, MEM_OBJ_NODES); if (!mobj || !ENTRY_IS_VALID(&(mobj->data.nodes), pos.offset)) { - sciprintf(" WARNING: "PREG": Doesn't contain list node!\n", + sciprintf(" WARNING: "PREG": Doesn't contain list node", PRINT_REG(pos)); return; } @@ -417,7 +417,7 @@ print_list(state_t *s, list_t *l) { PRINT_REG(pos), PRINT_REG(node->key), PRINT_REG(node->value)); if (!REG_EQ(my_prev, node->pred)) - sciprintf(" WARNING: current node gives "PREG" as predecessor!\n", + sciprintf(" WARNING: current node gives "PREG" as predecessor", PRINT_REG(node->pred)); my_prev = pos; @@ -425,7 +425,7 @@ print_list(state_t *s, list_t *l) { } if (!REG_EQ(my_prev, l->last)) - sciprintf(" WARNING: Last node was expected to be "PREG", was "PREG"!\n", + sciprintf(" WARNING: Last node was expected to be "PREG", was "PREG"", PRINT_REG(l->last), PRINT_REG(my_prev)); sciprintf("\t>\n"); } @@ -2006,7 +2006,7 @@ c_gfx_draw_cel(state_t *s) { int cel = cmd_params[2].val; int palette = cmd_params[3].val; if (!s) { - sciprintf("Not in debug state!\n"); + sciprintf("Not in debug state"); return 1; } @@ -2023,7 +2023,7 @@ c_gfx_fill_screen(state_t *s) { int col = cmd_params[0].val; if (!s) { - sciprintf("Not in debug state!\n"); + sciprintf("Not in debug state"); return 1; } @@ -2042,7 +2042,7 @@ c_gfx_draw_rect(state_t *s) { int col = cmd_params[4].val; if (!s) { - sciprintf("Not in debug state!\n"); + sciprintf("Not in debug state"); return 1; } @@ -2062,7 +2062,7 @@ c_gfx_propagate_rect(state_t *s) { rect_t rect; if (!s) { - sciprintf("Not in debug state!\n"); + sciprintf("Not in debug state"); return 1; } @@ -2107,7 +2107,7 @@ c_gfx_draw_viewobj(state_t *s) { int brLeft, brRight, brBottom, brTop; if (!s) { - sciprintf("Not in debug state!\n"); + sciprintf("Not in debug state"); return 1; } diff --git a/engines/sci/engine/seg_manager.cpp b/engines/sci/engine/seg_manager.cpp index 1524f7c737..612ad90f14 100644 --- a/engines/sci/engine/seg_manager.cpp +++ b/engines/sci/engine/seg_manager.cpp @@ -215,7 +215,7 @@ static void sm_set_script_size(mem_obj_t *mem, struct _state *s, int script_nr) sciprintf("Script and heap sizes combined exceed 64K.\n" "This means a fundamental design bug was made in FreeSCI\n" "regarding SCI1.1 games.\nPlease report this so it can be" - "fixed in the next major version!\n"); + "fixed in the next major version"); return; } } @@ -323,7 +323,7 @@ _sm_deallocate(seg_manager_t* self, int seg, int recursive) { free(mobj->data.reserved); break; default: - fprintf(stderr, "Deallocating segment type %d not supported!\n", + error("Deallocating segment type %d not supported", mobj->type); BREAKPOINT(); } @@ -1442,7 +1442,7 @@ sm_dereference(seg_manager_t *self, reg_t pointer, int *size) { if (!pointer.segment || (pointer.segment >= self->heap_size) || !self->heap[pointer.segment]) { - sciprintf("Error: Attempt to dereference invalid pointer "PREG"!\n", + sciprintf("Error: Attempt to dereference invalid pointer "PREG"", PRINT_REG(pointer)); return NULL; /* Invalid */ } @@ -1486,20 +1486,20 @@ sm_dereference(seg_manager_t *self, reg_t pointer, int *size) { && mobj->data.sys_strings.strings[pointer.offset].name) return (byte *)(mobj->data.sys_strings.strings[pointer.offset].value); else { - sciprintf("Error: Attempt to dereference invalid pointer "PREG"!\n", + sciprintf("Error: Attempt to dereference invalid pointer "PREG"", PRINT_REG(pointer)); return NULL; } case MEM_OBJ_RESERVED: - sciprintf("Error: Trying to dereference pointer "PREG" to reserved segment `%s'!\n", + sciprintf("Error: Trying to dereference pointer "PREG" to reserved segment `%s'", mobj->data.reserved); return NULL; break; default: sciprintf("Error: Trying to dereference pointer "PREG" to inappropriate" - " segment!\n", + " segment", PRINT_REG(pointer)); return NULL; } @@ -1640,10 +1640,10 @@ list_all_outgoing_references_script(seg_interface_t *self, state_t *s, reg_t add for (i = 0; i < obj->variables_nr; i++) (*note)(param, obj->variables[i]); } else { - fprintf(stderr, "Request for outgoing script-object reference at "PREG" yielded invalid index %d\n", PRINT_REG(addr), idx); + error("Request for outgoing script-object reference at "PREG" yielded invalid index %d\n", PRINT_REG(addr), idx); } } else { - /* fprintf(stderr, "Unexpected request for outgoing script-object references at "PREG"\n", PRINT_REG(addr));*/ + /* error("Unexpected request for outgoing script-object references at "PREG"\n", PRINT_REG(addr));*/ /* Happens e.g. when we're looking into strings */ } } @@ -1687,7 +1687,7 @@ list_all_outgoing_references_clones(seg_interface_t *self, state_t *s, reg_t add assert(addr.segment == self->seg_id); if (!(ENTRY_IS_VALID(clone_table, addr.offset))) { - fprintf(stderr, "Unexpected request for outgoing references from clone at "PREG"\n", PRINT_REG(addr)); + error("Unexpected request for outgoing references from clone at "PREG"\n", PRINT_REG(addr)); // BREAKPOINT(); return; } @@ -1786,10 +1786,10 @@ static seg_interface_t seg_interface_locals = { static void list_all_outgoing_references_stack(seg_interface_t *self, state_t *s, reg_t addr, void *param, void (*note)(void*param, reg_t addr)) { int i; - fprintf(stderr, "Emitting %d stack entries\n", self->mobj->data.stack.nr); + error("Emitting %d stack entries\n", self->mobj->data.stack.nr); for (i = 0; i < self->mobj->data.stack.nr; i++) (*note)(param, self->mobj->data.stack.entries[i]); - fprintf(stderr, "DONE"); + error("DONE"); } /*-------------------- stack --------------------*/ @@ -1831,7 +1831,7 @@ list_all_outgoing_references_list(seg_interface_t *self, state_t *s, reg_t addr, list_t *list = &(table->table[addr.offset].entry); if (!ENTRY_IS_VALID(table, addr.offset)) { - fprintf(stderr, "Invalid list referenced for outgoing references: "PREG"\n", PRINT_REG(addr)); + error("Invalid list referenced for outgoing references: "PREG"\n", PRINT_REG(addr)); return; } @@ -1871,7 +1871,7 @@ list_all_outgoing_references_nodes(seg_interface_t *self, state_t *s, reg_t addr node_t *node = &(table->table[addr.offset].entry); if (!ENTRY_IS_VALID(table, addr.offset)) { - fprintf(stderr, "Invalid node referenced for outgoing references: "PREG"\n", PRINT_REG(addr)); + error("Invalid node referenced for outgoing references: "PREG"\n", PRINT_REG(addr)); return; } @@ -1979,7 +1979,7 @@ get_seg_interface(seg_manager_t *self, seg_id_t segid) { memcpy(retval, seg_interfaces[mobj->type - 1], sizeof(seg_interface_t)); if (mobj->type != retval->type_id) { - fprintf(stderr, "Improper segment interface for %d", mobj->type); + error("Improper segment interface for %d", mobj->type); exit(1); } diff --git a/engines/sci/engine/sys_strings.cpp b/engines/sci/engine/sys_strings.cpp index e3091236fe..613e995805 100644 --- a/engines/sci/engine/sys_strings.cpp +++ b/engines/sci/engine/sys_strings.cpp @@ -23,6 +23,7 @@ * */ +#include "common/util.h" #include "sci/include/sys_strings.h" #include "sci/include/sci_memory.h" @@ -31,7 +32,7 @@ sys_string_acquire(sys_strings_t *strings, int index, const char *name, int max_ sys_string_t *str = strings->strings + index; if (index < 0 || index >= SYS_STRINGS_MAX) { - fprintf(stderr, "[SYSSTR] Error: Attempt to acquire string #%d\n", + error("[SYSSTR] Error: Attempt to acquire string #%d\n", index); BREAKPOINT(); } @@ -39,7 +40,7 @@ sys_string_acquire(sys_strings_t *strings, int index, const char *name, int max_ if (str->name && (strcmp(name, str->name) || (str->max_size != max_len))) { - fprintf(stderr, "[SYSSTR] Error: Attempt to re-acquire existing string #%d;" + error("[SYSSTR] Error: Attempt to re-acquire existing string #%d;" "was '%s', tried to claim as '%s'\n", index, str->name, name); BREAKPOINT(); @@ -56,7 +57,7 @@ sys_string_set(sys_strings_t *strings, int index, const char *value) { sys_string_t *str = strings->strings + index; if (index < 0 || index >= SYS_STRINGS_MAX || !str->name) { - fprintf(stderr, "[SYSSTR] Error: Attempt to write to invalid/unused string #%d\n", + error("[SYSSTR] Error: Attempt to write to invalid/unused string #%d\n", index); BREAKPOINT(); return 1; diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index 9aee6eb123..360fdd37f4 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -74,14 +74,14 @@ static inline reg_t * validate_property(object_t *obj, int index) { if (!obj) { if (sci_debug_flags & 4) - sciprintf("[VM] Sending to disposed object!\n"); + sciprintf("[VM] Sending to disposed object"); _dummy_register = NULL_REG; return &_dummy_register; } if (index < 0 || index >= obj->variables_nr) { if (sci_debug_flags & 4) - sciprintf("[VM] Invalid property #%d (out of [0..%d]) requested!\n", index, + sciprintf("[VM] Invalid property #%d (out of [0..%d]) requested", index, obj->variables_nr); _dummy_register = NULL_REG; @@ -595,12 +595,12 @@ add_exec_stack_entry(state_t *s, reg_t pc, stack_ptr_t sp, reg_t objp, int argc, void vm_handle_fatal_error(state_t *s, int line, const char *file) { - fprintf(stderr, "Fatal VM error in %s, L%d; aborting...\n", file, line); + error("Fatal VM error in %s, L%d; aborting...\n", file, line); #ifdef HAVE_SETJMP_H if (jump_initialized) longjmp(vm_error_address, 0); #endif - fprintf(stderr, "Could not recover, exitting...\n"); + error("Could not recover, exitting...\n"); exit(1); } @@ -740,7 +740,7 @@ run_vm(state_t *s, int restoring) { scr = script_locate_by_segment(s, xs->addr.pc.segment); if (!scr) { /* No script? Implicit return via fake instruction buffer */ - warning("Running on non-existant script in segment %x!\n", xs->addr.pc.segment); + warning("Running on non-existant script in segment %x", xs->addr.pc.segment); code_buf = _fake_return_buffer; #ifndef DISABLE_VALIDATIONS code_buf_size = 2; @@ -887,7 +887,7 @@ run_vm(state_t *s, int restoring) { /* Pointer arithmetics! */ if (s->r_acc.segment) { if (r_temp.segment) { - sciprintf("Error: Attempt to add two pointers, stack="PREG" and acc="PREG"!\n", + sciprintf("Error: Attempt to add two pointers, stack="PREG" and acc="PREG"", PRINT_REG(r_temp), PRINT_REG(s->r_acc)); script_debug_flag = script_error_flag = 1; offset = 0; @@ -914,7 +914,7 @@ run_vm(state_t *s, int restoring) { /* Pointer arithmetics! */ if (s->r_acc.segment) { if (r_temp.segment) { - sciprintf("Error: Attempt to subtract two pointers, stack="PREG" and acc="PREG"!\n", + sciprintf("Error: Attempt to subtract two pointers, stack="PREG" and acc="PREG"", PRINT_REG(r_temp), PRINT_REG(s->r_acc)); script_debug_flag = script_error_flag = 1; offset = 0; diff --git a/engines/sci/gfx/font.cpp b/engines/sci/gfx/font.cpp index c7b2a242c5..0b25ba2edf 100644 --- a/engines/sci/gfx/font.cpp +++ b/engines/sci/gfx/font.cpp @@ -127,7 +127,7 @@ gfxr_scale_font_unfiltered(gfx_bitmap_font_t *orig_font, gfx_mode_t *mode) { gfx_bitmap_font_t * gfxr_scale_font(gfx_bitmap_font_t *orig_font, gfx_mode_t *mode, gfxr_font_scale_filter_t filter) { - GFXWARN("This function hasn't been tested yet!\n"); + GFXWARN("This function hasn't been tested yet"); switch (filter) { @@ -135,7 +135,7 @@ gfxr_scale_font(gfx_bitmap_font_t *orig_font, gfx_mode_t *mode, gfxr_font_scale_ return gfxr_scale_font_unfiltered(orig_font, mode); default: - GFXERROR("Invalid font filter mode %d!\n", filter); + GFXERROR("Invalid font filter mode %d", filter); return NULL; } } @@ -318,7 +318,7 @@ gfxr_draw_font(gfx_bitmap_font_t *font, const char *stext, int characters, int ch = (int) text[i]; if (ch >= font->chars_nr) { - GFXERROR("Invalid character 0x%02x encountered!\n", text[i]); + GFXERROR("Invalid character 0x%02x encountered", text[i]); return NULL; } @@ -329,7 +329,7 @@ gfxr_draw_font(gfx_bitmap_font_t *font, const char *stext, int characters, pxm->colors_nr = !!fg0 + !!fg1 + !!bg; if (pxm->colors_nr == 0) { - GFXWARN("Pixmap would have zero colors, resetting!\n"); + GFXWARN("Pixmap would have zero colors, resetting"); pxm->colors_nr = 3; hack = 1; fg0 = fg1 = bg = &dummy; diff --git a/engines/sci/gfx/gfx_driver.cpp b/engines/sci/gfx/gfx_driver.cpp index 85194a0858..841ab04b8b 100644 --- a/engines/sci/gfx/gfx_driver.cpp +++ b/engines/sci/gfx/gfx_driver.cpp @@ -252,7 +252,7 @@ scummvm_grab_pixmap(struct _gfx_driver *drv, rect_t src, gfx_pixmap_t *pxm, break; case GFX_MASK_PRIORITY: - printf("FIXME: priority map grab not implemented yet!\n"); + printf("FIXME: priority map grab not implemented yet"); break; default: @@ -306,7 +306,7 @@ scummvm_update(struct _gfx_driver *drv, rect_t src, Common::Point dest, gfx_buff S->update_screen = true; break; default: - GFXERROR("Invalid buffer %d in update!\n", buffer); + GFXERROR("Invalid buffer %d in update", buffer); return GFX_ERROR; } diff --git a/engines/sci/gfx/gfx_res_options.cpp b/engines/sci/gfx/gfx_res_options.cpp index 230d69e0a7..d61bfb57e9 100644 --- a/engines/sci/gfx/gfx_res_options.cpp +++ b/engines/sci/gfx/gfx_res_options.cpp @@ -45,7 +45,7 @@ matches_patternlist(gfx_res_pattern_t *patterns, int nr, int val) { #ifdef DEBUG static void print_pattern(gfx_res_pattern_t *pat) { - fprintf(stderr, "[%d..%d]", + error("[%d..%d]", pat->min, pat->max); } #endif @@ -56,24 +56,24 @@ resource_matches_patternlists(gfx_res_conf_t *conf, int loc; #ifdef DEBUG int i; - fprintf(stderr, "[DEBUG:gfx-res] Trying to match against %d/%d/%d choices\n", + error("[DEBUG:gfx-res] Trying to match against %d/%d/%d choices\n", conf->patterns_nr, conf->loops_nr, conf->cels_nr); for (i = 0; i < conf->patterns_nr; i++) { - fprintf(stderr, "[DEBUG:gfx-res] Pat #%d: ", i); + error("[DEBUG:gfx-res] Pat #%d: ", i); print_pattern(conf->patterns + i); - fprintf(stderr, "\n"); + error("\n"); } loc = conf->patterns_nr; for (i = 0; i < conf->loops_nr; i++) { - fprintf(stderr, "[DEBUG:gfx-res] Loop #%d: ", i); + error("[DEBUG:gfx-res] Loop #%d: ", i); print_pattern(conf->patterns + i + loc); - fprintf(stderr, "\n"); + error("\n"); } loc += conf->loops_nr; for (i = 0; i < conf->cels_nr; i++) { - fprintf(stderr, "[DEBUG:gfx-res] Cel #%d: ", i); + error("[DEBUG:gfx-res] Cel #%d: ", i); print_pattern(conf->patterns + i + loc); - fprintf(stderr, "\n"); + error("\n"); } #endif if (conf->patterns_nr && @@ -114,7 +114,7 @@ find_match(gfx_res_conf_t *conflist, if (resource_matches_patternlists(conflist, type, nr, loop, cel)) { #ifdef DEBUG - fprintf(stderr, "[DEBUG:gfx-res] Found match!\n"); + error("[DEBUG:gfx-res] Found match"); #endif return conflist; } @@ -187,7 +187,7 @@ gfx_get_res_config(gfx_options_t *options, gfx_pixmap_t *pxm) { gfx_res_conf_t *conf; #ifdef DEBUG - fprintf(stderr, "[DEBUG:gfx-res] Trying to conf %d/%d/%d/%d (ID=%d)\n", + error("[DEBUG:gfx-res] Trying to conf %d/%d/%d/%d (ID=%d)\n", restype, nr, loop, cel, pxm->ID); #endif diff --git a/engines/sci/gfx/gfx_resource.cpp b/engines/sci/gfx/gfx_resource.cpp index c454d23d93..43e49dcad7 100644 --- a/engines/sci/gfx/gfx_resource.cpp +++ b/engines/sci/gfx/gfx_resource.cpp @@ -203,7 +203,7 @@ gfxr_endianness_adjust(gfx_pixmap_t *pixmap, gfx_mode_t *mode) { break; default: - fprintf(stderr, "gfxr_endianness_adjust(): Cannot adjust endianness for %d bytespp!\n", bytespp); + error("gfxr_endianness_adjust(): Cannot adjust endianness for %d bytespp", bytespp); return NULL; } @@ -369,7 +369,7 @@ gfx_xlate_pixmap(gfx_pixmap_t *pxm, gfx_mode_t *mode, gfx_xlate_filter_t filter) for (i = 0; i < pxm->colors_nr; i++) { if (gfx_alloc_color(mode->palette, pxm->colors + i) < 0) { - GFXWARN("Failed to allocate color %d/%d in pixmap (color %02x/%02x/%02x)!\n", + GFXWARN("Failed to allocate color %d/%d in pixmap (color %02x/%02x/%02x)", i, pxm->colors_nr, pxm->colors[i].r, pxm->colors[i].g, pxm->colors[i].b); pxm->colors[i].global_index = 0; } diff --git a/engines/sci/gfx/gfx_support.cpp b/engines/sci/gfx/gfx_support.cpp index 18734b1006..81abaae6d1 100644 --- a/engines/sci/gfx/gfx_support.cpp +++ b/engines/sci/gfx/gfx_support.cpp @@ -77,7 +77,7 @@ gfx_draw_line_buffer(byte *buffer, int linewidth, int pixelwidth, Common::Point return; default: - GFXERROR("pixelwidth=%d not supported!\n", pixelwidth); + GFXERROR("pixelwidth=%d not supported", pixelwidth); return; } @@ -363,7 +363,7 @@ gfx_crossblit_pixmap(gfx_mode_t *mode, gfx_pixmap_t *pxm, int priority, alpha_mask = mode->alpha_mask; if (!alpha_mask && pxm->alpha_map) { - GFXERROR("Invalid alpha mode: both pxm->alpha_map and alpha_mask are white!\n"); + GFXERROR("Invalid alpha mode: both pxm->alpha_map and alpha_mask are white"); return GFX_ERROR; } diff --git a/engines/sci/gfx/gfx_tools.cpp b/engines/sci/gfx/gfx_tools.cpp index 1aded808d7..5cf195f80a 100644 --- a/engines/sci/gfx/gfx_tools.cpp +++ b/engines/sci/gfx/gfx_tools.cpp @@ -213,7 +213,7 @@ gfx_pixmap_alloc_index_data(gfx_pixmap_t *pixmap) { int size; if (pixmap->index_data) { - GFXWARN("Attempt to allocate pixmap index data twice!\n"); + GFXWARN("Attempt to allocate pixmap index data twice"); return pixmap; } @@ -232,7 +232,7 @@ gfx_pixmap_alloc_index_data(gfx_pixmap_t *pixmap) { gfx_pixmap_t * gfx_pixmap_free_index_data(gfx_pixmap_t *pixmap) { if (!pixmap->index_data) { - GFXWARN("Attempt to free pixmap index data twice!\n"); + GFXWARN("Attempt to free pixmap index data twice"); return pixmap; } @@ -247,7 +247,7 @@ gfx_pixmap_alloc_data(gfx_pixmap_t *pixmap, gfx_mode_t *mode) { int size; if (pixmap->data) { - GFXWARN("Attempt to allocate pixmap data twice!\n"); + GFXWARN("Attempt to allocate pixmap data twice"); return pixmap; } @@ -271,7 +271,7 @@ gfx_pixmap_alloc_data(gfx_pixmap_t *pixmap, gfx_mode_t *mode) { gfx_pixmap_t * gfx_pixmap_free_data(gfx_pixmap_t *pixmap) { if (!pixmap->data) { - GFXWARN("Attempt to free pixmap data twice!\n"); + GFXWARN("Attempt to free pixmap data twice"); return pixmap; } @@ -293,14 +293,14 @@ gfx_alloc_color(gfx_palette_t *pal, gfx_pixmap_color_t *color) { return GFX_OK; if (pal->max_colors_nr <= 0) { - GFXERROR("Palette has zero or less color entries!\n"); + GFXERROR("Palette has zero or less color entries"); return GFX_ERROR; } if (color->global_index != GFX_COLOR_INDEX_UNMAPPED) { #if 0 - GFXDEBUG("Attempt to allocate color twice: index 0x%d (%02x/%02x/%02x)!\n", + GFXDEBUG("Attempt to allocate color twice: index 0x%d (%02x/%02x/%02x)", color->global_index, color->r, color->g, color->b); #endif return GFX_OK; @@ -343,7 +343,7 @@ gfx_alloc_color(gfx_palette_t *pal, gfx_pixmap_color_t *color) { color->global_index = bestcolor; -// GFXWARN("Out of palette colors- doing approximated mapping!\n"); +// GFXWARN("Out of palette colors- doing approximated mapping"); return GFX_OK; } @@ -356,19 +356,19 @@ gfx_free_color(gfx_palette_t *pal, gfx_pixmap_color_t *color) { return GFX_OK; if (color->global_index == GFX_COLOR_INDEX_UNMAPPED) { - GFXWARN("Attempt to free unmapped color %02x/%02x/%02x!\n", color->r, color->g, color->b); + GFXWARN("Attempt to free unmapped color %02x/%02x/%02x", color->r, color->g, color->b); BREAKPOINT(); return GFX_ERROR; } if (color->global_index >= pal->max_colors_nr) { - GFXERROR("Attempt to free invalid color index %d (%02x/%02x/%02x)!\n", + GFXERROR("Attempt to free invalid color index %d (%02x/%02x/%02x)", color->global_index, color->r, color->g, color->b); return GFX_ERROR; } if (!palette_color->lockers) { - GFXERROR("Attempt to free unused color index %d (%02x/%02x/%02x)!\n", + GFXERROR("Attempt to free unused color index %d (%02x/%02x/%02x)", color->global_index, color->r, color->g, color->b); return GFX_ERROR; } @@ -403,7 +403,7 @@ gfx_pixmap_scale_index_data(gfx_pixmap_t *pixmap, gfx_mode_t *mode) { old_data = pixmap->index_data; if (!old_data) { - GFXERROR("Attempt to scale index data without index data!\n"); + GFXERROR("Attempt to scale index data without index data"); return pixmap; } diff --git a/engines/sci/gfx/operations.cpp b/engines/sci/gfx/operations.cpp index d1f19032e4..7045583b56 100644 --- a/engines/sci/gfx/operations.cpp +++ b/engines/sci/gfx/operations.cpp @@ -36,7 +36,7 @@ ** in widget management */ #ifdef GFXW_DEBUG_DIRTY -# define DDIRTY fprintf(stderr, "%s:%5d| ", __FILE__, __LINE__); fprintf +# define DDIRTY error("%s:%5d| ", __FILE__, __LINE__); fprintf #else # define DDIRTY if (0) fprintf #endif @@ -59,19 +59,19 @@ gfx_pixmap_color_t default_colors[DEFAULT_COLORS_NR] = {{GFX_COLOR_SYSTEM, 0x00, /* Performs basic checks that apply to most functions */ #define BASIC_CHECKS(error_retval) \ if (!state) { \ - GFXERROR("Null state!\n"); \ + GFXERROR("Null state"); \ return error_retval; \ } \ if (!state->driver) { \ - GFXERROR("GFX driver invalid!\n"); \ + GFXERROR("GFX driver invalid"); \ return error_retval; \ } /* How to determine whether colors have to be allocated */ #define PALETTE_MODE state->driver->mode->palette -#define DRAW_POINTER { int __x = _gfxop_draw_pointer(state); if (__x) { GFXERROR("Drawing the mouse pointer failed!\n"); return __x;} } -#define REMOVE_POINTER { int __x = _gfxop_remove_pointer(state); if (__x) { GFXERROR("Removing the mouse pointer failed!\n"); return __x;} } +#define DRAW_POINTER { int __x = _gfxop_draw_pointer(state); if (__x) { GFXERROR("Drawing the mouse pointer failed"); return __x;} } +#define REMOVE_POINTER { int __x = _gfxop_remove_pointer(state); if (__x) { GFXERROR("Removing the mouse pointer failed"); return __x;} } /* #define GFXOP_DEBUG_DIRTY */ @@ -199,7 +199,7 @@ _gfxop_grab_pixmap(gfx_state_t *state, gfx_pixmap_t **pxmp, int x, int y, int x,y; \ \ if (!pxm->index_data) { \ - GFXERROR("Attempt to draw control color %d on pixmap %d/%d/%d without index data!\n", \ + GFXERROR("Attempt to draw control color %d on pixmap %d/%d/%d without index data", \ color, pxm->ID, pxm->loop, pxm->cel); \ return; \ } \ @@ -250,7 +250,7 @@ _gfxop_install_pixmap(gfx_driver_t *driver, gfx_pixmap_t *pxm) { pxm->colors[i].g, pxm->colors[i].b))) { - GFXWARN("driver->set_palette(%d, %02x/%02x/%02x) failed!\n", + GFXWARN("driver->set_palette(%d, %02x/%02x/%02x) failed", pxm->colors[i].global_index, pxm->colors[i].r, pxm->colors[i].g, @@ -308,7 +308,7 @@ _gfxop_draw_pixmap(gfx_driver_t *driver, gfx_pixmap_t *pxm, int priority, int co static_buf ? GFX_BUFFER_STATIC : GFX_BUFFER_BACK); if (error) { - GFXERROR("driver->draw_pixmap() returned error!\n"); + GFXERROR("driver->draw_pixmap() returned error"); return error; } return GFX_OK; @@ -479,7 +479,7 @@ gfxdr_add_dirty(gfx_dirty_rect_t *base, rect_t box, int strategy) { box.yl = - box.yl; } #ifdef GFXOP_DEBUG_DIRTY - fprintf(stderr, "Adding new dirty (%d %d %d %d)\n", + error("Adding new dirty (%d %d %d %d)\n", GFX_PRINT_RECT(box)); #endif if (_gfxop_clip(&box, gfx_rect(0, 0, 320, 200))) @@ -552,7 +552,7 @@ _gfxop_clear_dirty_rec(gfx_state_t *state, struct _dirty_rect *rect) { return GFX_OK; #ifdef GFXOP_DEBUG_DIRTY - fprintf(stderr, "\tClearing dirty (%d %d %d %d)\n", + error("\tClearing dirty (%d %d %d %d)\n", GFX_PRINT_RECT(rect->rect)); #endif if (!state->fullscreen_override) @@ -585,7 +585,7 @@ _gfxop_init_common(gfx_state_t *state, gfx_options_t *options, void *misc_payloa state->options, state->driver, misc_payload)))) { - GFXERROR("Failed to initialize resource manager!\n"); + GFXERROR("Failed to initialize resource manager"); return GFX_FATAL; } @@ -1276,7 +1276,7 @@ gfxop_draw_box(gfx_state_t *state, rect_t box, gfx_color_t color1, gfx_color_t c return drv->draw_filled_rect(drv, new_box, color1, color1, GFX_SHADE_FLAT); else { if (PALETTE_MODE) { - GFXWARN("Attempting to draw shaded box in palette mode!\n"); + GFXWARN("Attempting to draw shaded box in palette mode"); return GFX_ERROR; } @@ -1376,7 +1376,7 @@ gfxop_set_visible_map(gfx_state_t *state, gfx_map_mask_t visible_map) { break; default: - fprintf(stderr, "Invalid display map %d selected!\n", visible_map); + error("Invalid display map %d selected", visible_map); return GFX_ERROR; } @@ -1404,7 +1404,7 @@ gfxop_update(gfx_state_t *state) { } if (retval) { - GFXERROR("Clearing the dirty rectangles failed!\n"); + GFXERROR("Clearing the dirty rectangles failed"); } if (state->tag_mode) { @@ -1457,7 +1457,7 @@ gfxop_disable_dirty_frames(gfx_state_t *state) { /* Sure, this may seem silly, but it's too easy to miss a zero...) */ -#define GFXOP_FULL_POINTER_REFRESH if (_gfxop_full_pointer_refresh(state)) { GFXERROR("Failed to do full pointer refresh!\n"); return GFX_ERROR; } +#define GFXOP_FULL_POINTER_REFRESH if (_gfxop_full_pointer_refresh(state)) { GFXERROR("Failed to do full pointer refresh"); return GFX_ERROR; } static int _gfxop_full_pointer_refresh(gfx_state_t *state) { @@ -1774,7 +1774,7 @@ gfxop_get_event(gfx_state_t *state, unsigned int mask) { BASIC_CHECKS(error_event); if (_gfxop_remove_pointer(state)) { - GFXERROR("Failed to remove pointer before processing event!\n"); + GFXERROR("Failed to remove pointer before processing event"); } while (*seekerp && !((*seekerp)->event.type & mask)) @@ -1807,7 +1807,7 @@ gfxop_get_event(gfx_state_t *state, unsigned int mask) { } if (_gfxop_full_pointer_refresh(state)) { - GFXERROR("Failed to update the mouse pointer!\n"); + GFXERROR("Failed to update the mouse pointer"); return error_event; } @@ -2043,13 +2043,13 @@ gfxop_new_pic(gfx_state_t *state, int nr, int flags, int default_palette) { state->pic_unscaled = gfxr_get_pic(state->resstate, nr, GFX_MASK_VISUAL, flags, default_palette, 0); if (!state->pic || !state->pic_unscaled) { - GFXERROR("Could not retrieve background pic %d!\n", nr); + GFXERROR("Could not retrieve background pic %d", nr); if (state->pic) { - GFXERROR(" -- Inconsistency: scaled pic _was_ retrieved!\n"); + GFXERROR(" -- Inconsistency: scaled pic _was_ retrieved"); } if (state->pic_unscaled) { - GFXERROR(" -- Inconsistency: unscaled pic _was_ retrieved!\n"); + GFXERROR(" -- Inconsistency: unscaled pic _was_ retrieved"); } state->pic = state->pic_unscaled = NULL; @@ -2067,13 +2067,13 @@ gfxop_add_to_pic(gfx_state_t *state, int nr, int flags, int default_palette) { BASIC_CHECKS(GFX_FATAL); if (!state->pic) { - GFXERROR("Attempt to add to pic with no pic active!\n"); + GFXERROR("Attempt to add to pic with no pic active"); return GFX_ERROR; } if (!(state->pic = gfxr_add_to_pic(state->resstate, state->pic_nr, nr, GFX_MASK_VISUAL, flags, state->palette_nr, default_palette, 1))) { - GFXERROR("Could not add pic #%d to pic #%d!\n", state->pic_nr, nr); + GFXERROR("Could not add pic #%d to pic #%d", state->pic_nr, nr); return GFX_ERROR; } state->pic_unscaled = gfxr_add_to_pic(state->resstate, state->pic_nr, nr, @@ -2264,7 +2264,7 @@ gfxop_draw_text(gfx_state_t *state, gfx_text_handle_t *handle, rect_t zone) { REMOVE_POINTER; if (!handle) { - GFXERROR("Attempt to draw text with NULL handle!\n"); + GFXERROR("Attempt to draw text with NULL handle"); return GFX_ERROR; } @@ -2293,7 +2293,7 @@ gfxop_draw_text(gfx_state_t *state, gfx_text_handle_t *handle, rect_t zone) { break; default: - GFXERROR("Invalid vertical alignment %d!\n", handle->valign); + GFXERROR("Invalid vertical alignment %d", handle->valign); return GFX_FATAL; /* Internal error... */ } @@ -2326,7 +2326,7 @@ gfxop_draw_text(gfx_state_t *state, gfx_text_handle_t *handle, rect_t zone) { break; default: - GFXERROR("Invalid vertical alignment %d!\n", handle->valign); + GFXERROR("Invalid vertical alignment %d", handle->valign); return GFX_FATAL; /* Internal error... */ } @@ -2352,7 +2352,7 @@ gfxop_grab_pixmap(gfx_state_t *state, rect_t area) { rect_t resultzone; /* Ignored for this application */ BASIC_CHECKS(NULL); if (_gfxop_remove_pointer(state)) { - GFXERROR("Could not remove pointer!\n"); + GFXERROR("Could not remove pointer"); return NULL; } @@ -2371,7 +2371,7 @@ gfxop_draw_pixmap(gfx_state_t *state, gfx_pixmap_t *pxm, rect_t zone, Common::Po BASIC_CHECKS(GFX_ERROR); if (!pxm) { - GFXERROR("Attempt to draw NULL pixmap!\n"); + GFXERROR("Attempt to draw NULL pixmap"); return GFX_ERROR; } diff --git a/engines/sci/gfx/resmgr.cpp b/engines/sci/gfx/resmgr.cpp index 1a4450baeb..b1bda530bf 100644 --- a/engines/sci/gfx/resmgr.cpp +++ b/engines/sci/gfx/resmgr.cpp @@ -70,7 +70,7 @@ gfxr_new_resource_manager(int version, gfx_options_t *options, else { tree = sbtree_new(entries_nr, resources); if (!tree) { - GFXWARN("Failed to allocate tree for %d entries of resource type %d!\n", entries_nr, i); + GFXWARN("Failed to allocate tree for %d entries of resource type %d", entries_nr, i); } state->resource_trees[i] = tree; free(resources); @@ -302,7 +302,7 @@ gfxr_get_pic(gfx_resstate_t *state, int nr, int maps, int flags, int default_pal state->misc_payload); if (!pic) { - GFXERROR("Failed to allocate scaled pic!\n"); + GFXERROR("Failed to allocate scaled pic"); return NULL; } @@ -314,7 +314,7 @@ gfxr_get_pic(gfx_resstate_t *state, int nr, int maps, int flags, int default_pal GFXR_RES_ID(restype, nr), state->misc_payload); if (!unscaled_pic) { - GFXERROR("Failed to allocate unscaled pic!\n"); + GFXERROR("Failed to allocate unscaled pic"); return NULL; } gfxr_interpreter_clear_pic(state->version, unscaled_pic, diff --git a/engines/sci/gfx/resource/sci_pic_0.cpp b/engines/sci/gfx/resource/sci_pic_0.cpp index ccb8790578..41ac4a1110 100644 --- a/engines/sci/gfx/resource/sci_pic_0.cpp +++ b/engines/sci/gfx/resource/sci_pic_0.cpp @@ -375,11 +375,11 @@ _gfxr_auxbuf_spread(gfxr_pic_t *pic, int *min_x, int *min_y, int *max_x, int *ma #ifdef FILL_RECURSIVE_DEBUG if (!fillmagc) { - fprintf(stderr, "------------------------------------------------\n"); - fprintf(stderr, "LineID: "); + error("------------------------------------------------\n"); + error("LineID: "); for (i = 0; i < 5; i++) - fprintf(stderr, " %d ", i); - fprintf(stderr, "\n"); + error(" %d ", i); + error("\n"); } #endif @@ -481,10 +481,10 @@ _gfxr_auxbuf_spread(gfxr_pic_t *pic, int *min_x, int *min_y, int *max_x, int *ma #ifdef FILL_RECURSIVE_DEBUG if (!fillmagc && intervals_nr) { - fprintf(stderr, "AI L#%03d:", y); + error("AI L#%03d:", y); for (int j = 0; j < intervals_nr; j++) - fprintf(stderr, "%c[%03d,%03d]", intervals[ivi][j].tag ? ' ' : '-', intervals[ivi][j].xl, intervals[ivi][j].xr); - fprintf(stderr, "\n"); + error("%c[%03d,%03d]", intervals[ivi][j].tag ? ' ' : '-', intervals[ivi][j].xl, intervals[ivi][j].xr); + error("\n"); } #endif @@ -631,7 +631,7 @@ _gfxr_fill_ellipse(gfxr_pic_t *pic, byte *buffer, int linewidth, int x, int y, break; default: - fprintf(stderr, "%s L%d: Invalid ellipse fill mode!\n", __FILE__, __LINE__); + error("%s L%d: Invalid ellipse fill mode", __FILE__, __LINE__); return; } @@ -968,7 +968,7 @@ _gfxr_draw_subline(gfxr_pic_t *pic, int x, int y, int ex, int ey, int color, int end.y = ey; if (ex >= pic->visual_map->index_xl || ey >= pic->visual_map->index_yl || x < 0 || y < 0) { - fprintf(stderr, "While drawing pic0: INVALID LINE %d,%d,%d,%d\n", + error("While drawing pic0: INVALID LINE %d,%d,%d,%d\n", start.x, start.y, end.x, end.y); return; } @@ -1307,7 +1307,7 @@ gfxr_remove_artifacts_pic0(gfxr_pic_t *dest, gfxr_pic_t *src) { if (bound_x == 1 && bound_y == 1) { /* D'Oh! */ - GFXWARN("attempt to remove artifacts from unscaled pic!\n"); + GFXWARN("attempt to remove artifacts from unscaled pic"); return; } @@ -1494,12 +1494,12 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, GET_ABS_COORDS(oldx, oldy); while (*(resource + pos) < PIC_OP_FIRST) { #if 0 - fprintf(stderr, "Medium-line: [%04x] from %d,%d, data %02x %02x (dx=%d)", pos, oldx, oldy, + error("Medium-line: [%04x] from %d,%d, data %02x %02x (dx=%d)", pos, oldx, oldy, 0xff & resource[pos], 0xff & resource[pos+1], *((signed char *) resource + pos + 1)); #endif GET_MEDREL_COORDS(oldx, oldy); #if 0 - fprintf(stderr, " to %d,%d\n", x, y); + error(" to %d,%d\n", x, y); #endif _gfxr_draw_line(pic, oldx, oldy, x, y, color, priority, control, drawenable, line_mode, PIC_OP_MEDIUM_LINES, sci_titlebar_size); @@ -1780,7 +1780,7 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, *if it's not for some reason, we should die */ if (!(view->flags & GFX_PIXMAP_FLAG_EXTERNAL_PALETTE) && !sci1) { - sciprintf("gfx_draw_pic0(): can't set a non-static palette for an embedded view!\n"); + sciprintf("gfx_draw_pic0(): can't set a non-static palette for an embedded view"); } /* For SCI0, use special color mapping to copy the low @@ -1832,7 +1832,7 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, if (!pic->internal) { pic->internal = sci_malloc(16 * sizeof(int)); } else { - GFXERROR("pic->internal is not NULL (%08x); this only occurs with overlaid pics, otherwise it's a bug!\n", pic->internal); + GFXERROR("pic->internal is not NULL (%08x); this only occurs with overlaid pics, otherwise it's a bug", pic->internal); } pri_table = (int*)pic->internal; @@ -1854,7 +1854,7 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, if (!pic->internal) { pic->internal = sci_malloc(16 * sizeof(int)); } else { - GFXERROR("pic->internal is not NULL (%08x); possible memory corruption!\n", pic->internal); + GFXERROR("pic->internal is not NULL (%08x); possible memory corruption", pic->internal); } pri_table = (int*)pic->internal; @@ -1980,7 +1980,7 @@ gfxr_dither_pic0(gfxr_pic_t *pic, int dmode, int pattern) { break; default: - GFXERROR("Invalid dither mode %d!\n", dmode); + GFXERROR("Invalid dither mode %d", dmode); return; } diff --git a/engines/sci/gfx/resource/sci_view_1.cpp b/engines/sci/gfx/resource/sci_view_1.cpp index 7f989b646a..aef02b694b 100644 --- a/engines/sci/gfx/resource/sci_view_1.cpp +++ b/engines/sci/gfx/resource/sci_view_1.cpp @@ -347,7 +347,7 @@ gfxr_draw_view1(int id, byte *resource, int size, gfx_pixmap_color_t *static_pal return NULL; } - /* fprintf(stderr, "View flags are 0x%02x\n", resource[3]);*/ + /* error("View flags are 0x%02x\n", resource[3]);*/ /* for (i = 0; i < V1_MAGICS_NR; i++) diff --git a/engines/sci/gfx/sbtree.cpp b/engines/sci/gfx/sbtree.cpp index d5ef5ea510..5158feefad 100644 --- a/engines/sci/gfx/sbtree.cpp +++ b/engines/sci/gfx/sbtree.cpp @@ -25,7 +25,7 @@ /* Static binary lookup tree lookup */ - +#include "common/util.h" #include "sci/include/sci_memory.h" #include "sci/include/sbtree.h" #include <stdlib.h> @@ -84,14 +84,14 @@ sbtree_new(int size, int *keys) { table[i].key = NOT_A_KEY; if (!table) { - fprintf(stderr, "SBTree: Out of memory: Could not allocate %d cells\n", table_size); + error("SBTree: Out of memory: Could not allocate %d cells\n", table_size); return NULL; } tree = (sbtree_t*)sci_malloc(sizeof(sbtree_t)); if (!tree) { - fprintf(stderr, "SBTree: Could not allocate tree structure\n"); + error("SBTree: Could not allocate tree structure\n"); free(table); return NULL; } @@ -103,7 +103,7 @@ sbtree_new(int size, int *keys) { tree->levels = levels; tree->entries_nr = size; if ((tree->min_entry = keys[0]) < 0) { - fprintf(stderr, "SBTree: Error: Using negative keys\n"); + error("SBTree: Error: Using negative keys\n"); free(table); free(tree); return NULL; @@ -118,7 +118,7 @@ sbtree_new(int size, int *keys) { void sbtree_free(sbtree_t *tree) { if (!tree) { - fprintf(stderr, "SBTree: Attempt to free NULL sbtree\n"); + error("SBTree: Attempt to free NULL sbtree\n"); return; } @@ -188,24 +188,24 @@ sbtree_print(sbtree_t *tree) { int l, i; sbcell_t *cells = (sbcell_t *) tree->data; - fprintf(stderr, "\tTree:\n"); + error("\tTree:\n"); for (l = 0; l <= tree->levels; l++) { - fprintf(stderr, "\t "); + error("\t "); for (i = 0; i < (1 << l); i++) { if (cells->key == NOT_A_KEY) - fprintf(stderr, "-- "); + error("-- "); else { if (cells->value) - fprintf(stderr, "%d+ ", cells->key); + error("%d+ ", cells->key); else - fprintf(stderr, "%d ", cells->key); + error("%d ", cells->key); } cells = cells + 1; } - fprintf(stderr, "\n"); + error("\n"); } - fprintf(stderr, "\n"); + error("\n"); } #endif @@ -223,7 +223,7 @@ foreach_double_func(sbtree_t *tree, const int key, const void *value, void *args int *real_value = (int *) value; if (!real_value) - fprintf(stderr, "foreach_double_func(): key %d mapped to non-value!\n", key); + error("foreach_double_func(): key %d mapped to non-value", key); else *real_value *= 2; return real_value; @@ -267,7 +267,7 @@ insert_values(sbtree_t *tree, int nr, int *data) { for (i = 0; i < nr; i++) if (sbtree_set(tree, data[i], (void *)(data + i))) { - fprintf(stderr, "While inserting: %d incorrectly deemed invalid\n", data[i]); + error("While inserting: %d incorrectly deemed invalid\n", data[i]); any_error = 1; } } @@ -296,18 +296,18 @@ test_value(sbtree_t *tree, int times, int max, int numbers, int *data, int mode) found = 1; if (found && !value) { - fprintf(stderr, "!%d ", key); + error("!%d ", key); ++failed; } else if (!found && found) { - fprintf(stderr, "?[%d]=%d ", key, *value); + error("?[%d]=%d ", key, *value); ++failed; } } if (failed) - fprintf(stderr, "(%d/%d errors)\n", any_error = failed, times); + error("(%d/%d errors)\n", any_error = failed, times); else - fprintf(stderr, "OK\n"); + error("OK\n"); } @@ -320,23 +320,23 @@ test_boundary(sbtree_t *tree, int max, int random) { int failure = (value_too_low || value_too_high || (!random && (!value_low || !value_high))); if (!failure) - fprintf(stderr, "OK\n"); + error("OK\n"); else { any_error = 1; - fprintf(stderr, "Errors: "); + error("Errors: "); if (value_too_low) - fprintf(stderr, "too-low=%d ", *value_too_low); + error("too-low=%d ", *value_too_low); if (value_too_high) - fprintf(stderr, "too-high=%d ", *value_too_high); + error("too-high=%d ", *value_too_high); if (!random) { if (!value_low) - fprintf(stderr, "!low "); + error("!low "); if (!value_high) - fprintf(stderr, "!high "); + error("!high "); } - fprintf(stderr, "\n"); + error("\n"); } } @@ -351,15 +351,15 @@ test_empty(sbtree_t *tree, int count, int max) { int *value; if ((value = (int *) sbtree_get(tree, key))) { - fprintf(stderr, "?[%d]=%d\n", key, *value); + error("?[%d]=%d\n", key, *value); ++errors; } } if (errors) - fprintf(stderr, " (%d/%d errors)\n", any_error = errors, count); + error(" (%d/%d errors)\n", any_error = errors, count); else - fprintf(stderr, "OK\n"); + error("OK\n"); } void @@ -369,23 +369,23 @@ run_test(sbtree_t *tree, int entries, int *data, int random, int max_value) { any_error = 0; - fprintf(stderr, "\tEmpty test: \t\t\t"); + error("\tEmpty test: \t\t\t"); test_empty(tree, entries * 2, entries + 1); insert_values(tree, entries, data); - fprintf(stderr, "\tBoundary test: \t\t\t"); + error("\tBoundary test: \t\t\t"); test_boundary(tree, max_value, random); for (i = 0; i < 3; i++) { - fprintf(stderr, tests[i]); + error(tests[i]); test_value(tree, entries * 2, entries * 2, entries, data, i); } if (!random) { i = data[0]; sbtree_foreach(tree, NULL, foreach_double_func); - fprintf(stderr, "\tForeach test: \t\t\t"); + error("\tForeach test: \t\t\t"); if (i * 2 != data[0]) { - fprintf(stderr, "Error: No effect: %d * 2 != %d\n", i, data[0]); + error("Error: No effect: %d * 2 != %d\n", i, data[0]); any_error = 1; } else test_value(tree, entries * 2, entries * 2, entries, data, MODE_LINEAR_DOUBLE); @@ -406,46 +406,46 @@ main(int argc, char **argv) { int tests_nr = TESTS_NR; int test_sizes[TESTS_NR] = {1, 2, 3, 7, 8, 9, 1000, 16383, 16384, 16385, 1000000}; int i; - fprintf(stderr, "sbtree.c Copyright (C) 2000 Christoph Reichenbach <jameson@linuxgames.com>\n" + error("sbtree.c Copyright (C) 2000 Christoph Reichenbach <jameson@linuxgames.com>\n" "This program is provided WITHOUT WARRANTY of any kind\n" "Please refer to the file COPYING that should have come with this program\n"); - fprintf(stderr, "Static Binary Tree testing facility\n"); + error("Static Binary Tree testing facility\n"); free(malloc(42)); /* Make sure libefence's Copyright message is print here if we're using it */ - fprintf(stderr, "\nsbtree.c: Running %d tests.\n", tests_nr); + error("\nsbtree.c: Running %d tests.\n", tests_nr); for (i = 0; i < tests_nr; i++) { int entries = test_sizes[i]; sbtree_t *tree; int *data; - fprintf(stderr, "Test #%d: %d entries\n", i + 1, entries); + error("Test #%d: %d entries\n", i + 1, entries); - fprintf(stderr, "\t%da: Linear values\n", i + 1); + error("\t%da: Linear values\n", i + 1); data = generate_linear_forward(entries); tree = sbtree_new(entries, data); run_test(tree, entries, data, 0, entries); - fprintf(stderr, "\t%db: Reverse linear values\n", i + 1); + error("\t%db: Reverse linear values\n", i + 1); data = generate_linear_backward(entries); tree = sbtree_new(entries, data); run_test(tree, entries, data, 0, entries); - fprintf(stderr, "\t%dc: Dense random values\n", i + 1); + error("\t%dc: Dense random values\n", i + 1); data = generate_random(entries, 1 + (entries >> 2)); tree = sbtree_new(entries, data); run_test(tree, entries, data, 1, 1 + (entries >> 2)); - fprintf(stderr, "\t%dc: Sparse random values\n", i + 1); + error("\t%dc: Sparse random values\n", i + 1); data = generate_random(entries, (entries << 2)); tree = sbtree_new(entries, data); run_test(tree, entries, data, 1, entries << 2); - fprintf(stderr, "Test #%d completed.\n\n", i + 1); + error("Test #%d completed.\n\n", i + 1); } - fprintf(stderr, "Test suite completed.\n"); + error("Test suite completed.\n"); return 0; } diff --git a/engines/sci/gfx/sci_widgets.cpp b/engines/sci/gfx/sci_widgets.cpp index 97e2a0acd0..e39c9a37c8 100644 --- a/engines/sci/gfx/sci_widgets.cpp +++ b/engines/sci/gfx/sci_widgets.cpp @@ -80,14 +80,14 @@ sciw_set_status_bar(state_t *s, gfxw_port_t *status_bar, char *text, int fgcolor gfx_color_t black = s->ega_colors[0]; if (!status_bar->visual) { - GFXERROR("Attempt to change title bar without visual!\n"); + GFXERROR("Attempt to change title bar without visual"); return; } state = status_bar->visual->gfx_state; if (!state) { - GFXERROR("Attempt to change title bar with stateless visual!\n"); + GFXERROR("Attempt to change title bar with stateless visual"); return; } @@ -224,7 +224,7 @@ sciw_new_window(state_t *s, rect_t area, int font, gfx_color_t color, gfx_color_ if (!(flags & WINDOW_FLAG_NO_DROP_SHADOW)) { if (gfxop_set_color(state, &black, 0, 0, 0, 0x80, bgcolor.priority, -1)) { - GFXERROR("Could not get black/semitrans color entry!\n"); + GFXERROR("Could not get black/semitrans color entry"); return NULL; } @@ -242,7 +242,7 @@ sciw_new_window(state_t *s, rect_t area, int font, gfx_color_t color, gfx_color_ /* Draw frame */ if (gfxop_set_color(state, &black, 0, 0, 0, 0, bgcolor.priority, -1)) { - GFXERROR("Could not get black color entry!\n"); + GFXERROR("Could not get black color entry"); return NULL; } @@ -461,7 +461,7 @@ sciw_new_icon_control(gfxw_port_t *port, reg_t ID, rect_t zone, int view, int lo gfxw_set_id(GFXW(list), ID.segment, ID.offset); if (!port->visual) { - GFXERROR("Attempting to create icon control for virtual port!\n"); + GFXERROR("Attempting to create icon control for virtual port"); return NULL; } diff --git a/engines/sci/gfx/widgets.cpp b/engines/sci/gfx/widgets.cpp index fc0a177a50..777d567a32 100644 --- a/engines/sci/gfx/widgets.cpp +++ b/engines/sci/gfx/widgets.cpp @@ -29,7 +29,7 @@ #undef GFXW_DEBUG_DIRTY /* Enable to debug dirty rectangle propagation (writes to stderr) */ #ifdef GFXW_DEBUG_DIRTY -# define DDIRTY fprintf(stderr, "%s:%5d| ", __FILE__, __LINE__); fprintf +# define DDIRTY error("%s:%5d| ", __FILE__, __LINE__); fprintf #else # define DDIRTY if (0) fprintf #endif @@ -47,7 +47,7 @@ int debug_widget_pos = 0; static void _gfxw_debug_add_widget(gfxw_widget_t *widget) { if (debug_widget_pos == GFXW_DEBUG_WIDGETS) { - GFXERROR("WIDGET DEBUG: Allocated the maximum number of %d widgets- Aborting!\n", GFXW_DEBUG_WIDGETS); + GFXERROR("WIDGET DEBUG: Allocated the maximum number of %d widgets- Aborting", GFXW_DEBUG_WIDGETS); BREAKPOINT(); } debug_widgets[debug_widget_pos++] = widget; @@ -67,12 +67,12 @@ _gfxw_debug_remove_widget(gfxw_widget_t *widget) { } if (found > 1) { - GFXERROR("While removing widget: Found it %d times!\n", found); + GFXERROR("While removing widget: Found it %d times", found); BREAKPOINT(); } if (found == 0) { - GFXERROR("Attempted removal of unregistered widget!\n"); + GFXERROR("Attempted removal of unregistered widget"); BREAKPOINT(); } } @@ -199,7 +199,7 @@ _gfxw_unallocate_widget(gfx_state_t *state, gfxw_widget_t *widget) { if (text->text_handle) { if (!state) { - GFXERROR("Attempt to free text without supplying mode to free it from!\n"); + GFXERROR("Attempt to free text without supplying mode to free it from"); BREAKPOINT(); } else { gfxop_free_text(state, text->text_handle); @@ -217,7 +217,7 @@ _gfxw_unallocate_widget(gfx_state_t *state, gfxw_widget_t *widget) { { \ int retval = (_x); \ if (retval == GFX_ERROR) { \ - GFXERROR("Error occured while drawing widget!\n"); \ + GFXERROR("Error occured while drawing widget"); \ return 1; \ } else if (retval == GFX_FATAL) { \ GFXERROR("Fatal error occured while drawing widget!\nGraphics state invalid; aborting program..."); \ @@ -235,11 +235,11 @@ _gfxw_unallocate_widget(gfx_state_t *state, gfxw_widget_t *widget) { /* Assertion for drawing */ #define DRAW_ASSERT(widget, exp_type) \ if (!(widget)) { \ - sciprintf("L%d: NULL widget!\n", __LINE__); \ + sciprintf("L%d: NULL widget", __LINE__); \ return 1; \ } \ if (!(widget)->print) { \ - sciprintf("L%d: Widget of type %d does not have print function!\n", __LINE__, \ + sciprintf("L%d: Widget of type %d does not have print function", __LINE__, \ (widget)->type); \ } \ if ((widget)->type != (exp_type)) { \ @@ -324,7 +324,7 @@ gfxw_remove_widget_from_container(gfxw_container_t *container, gfxw_widget_t *wi gfxw_widget_t **seekerp; if (!container) { - GFXERROR("Attempt to remove widget from NULL container!\n"); + GFXERROR("Attempt to remove widget from NULL container"); BREAKPOINT(); } @@ -342,7 +342,7 @@ gfxw_remove_widget_from_container(gfxw_container_t *container, gfxw_widget_t *wi seekerp = &((*seekerp)->next); if (!*seekerp) { - GFXERROR("Internal error: Attempt to remove widget from container it was not contained in!\n"); + GFXERROR("Internal error: Attempt to remove widget from container it was not contained in"); sciprintf("Widget:"); widget->print(GFXW(widget), 1); sciprintf("Container:"); @@ -705,7 +705,7 @@ _gfxw_new_simple_view(gfx_state_t *state, Common::Point pos, int view, int loop, Common::Point offset; if (!state) { - GFXERROR("Attempt to create view widget with NULL state!\n"); + GFXERROR("Attempt to create view widget with NULL state"); return NULL; } @@ -988,7 +988,7 @@ gfxw_new_dyn_view(gfx_state_t *state, Common::Point pos, int z, int view, int lo Common::Point offset; if (!state) { - GFXERROR("Attempt to create view widget with NULL state!\n"); + GFXERROR("Attempt to create view widget with NULL state"); return NULL; } @@ -1657,7 +1657,7 @@ _gfxwop_list_equals(gfxw_widget_t *widget, gfxw_widget_t *other) return 0; if (!GFXW_IS_LIST(widget)) { - GFXWARN("_gfxwop_list_equals(): Method called on non-list!\n"); + GFXWARN("_gfxwop_list_equals(): Method called on non-list"); widget->print(widget, 0); sciprintf("\n"); return 0; @@ -1866,9 +1866,9 @@ _gfxwop_visual_print(gfxw_widget_t *widget, int indentation) { static int _gfxwop_visual_set_visual(gfxw_widget_t *self, gfxw_visual_t *visual) { if (self != GFXW(visual)) { - GFXWARN("Attempt to set a visual's parent visual to something else!\n"); + GFXWARN("Attempt to set a visual's parent visual to something else"); } else { - GFXWARN("Attempt to set a visual's parent visual!\n"); + GFXWARN("Attempt to set a visual's parent visual"); } return 1; } @@ -1967,12 +1967,12 @@ _gfxwop_port_free(gfxw_widget_t *widget) { int ID = port->ID; if (ID < 0 || ID >= visual->port_refs_nr) { - GFXWARN("Attempt to free port #%d; allowed: [0..%d]!\n", ID, visual->port_refs_nr); + GFXWARN("Attempt to free port #%d; allowed: [0..%d]", ID, visual->port_refs_nr); return GFX_ERROR; } if (visual->port_refs[ID] != port) { - GFXWARN("While freeing port %d: Port is at %p, but port list indicates %p!\n", + GFXWARN("While freeing port %d: Port is at %p, but port list indicates %p", ID, port, visual->port_refs[ID]); } else visual->port_refs[ID] = NULL; @@ -2045,7 +2045,7 @@ _gfxwop_port_add_dirty(gfxw_container_t *widget, rect_t dirty, int propagate) { if (self->port_bg->superarea_of(self->port_bg, &foo)) { gfxw_container_t *parent = self->parent; while (parent) { - fprintf(stderr, "Dirtifying parent id %d\n", parent->ID); + error("Dirtifying parent id %d\n", parent->ID); parent->flags |= GFXW_FLAG_DIRTY; parent = parent->parent; } diff --git a/engines/sci/include/heapmgr.h b/engines/sci/include/heapmgr.h index 5e837e7993..c6912b6f44 100644 --- a/engines/sci/include/heapmgr.h +++ b/engines/sci/include/heapmgr.h @@ -78,8 +78,8 @@ free_##ENTRY##_entry(ENTRY##_table_t *table, int index) \ ENTRY##_entry_t *e = table->table + index; \ \ if (index < 0 || index >= table->max_entry) { \ - fprintf(stderr, "heapmgr: Attempt to release" \ - " invalid table index %d!\n", index); \ + error("heapmgr: Attempt to release" \ + " invalid table index %d", index); \ BREAKPOINT(); \ } \ CLEANUP_FN(&(e->entry)); \ diff --git a/engines/sci/include/kdebug.h b/engines/sci/include/kdebug.h index dbe890f8ff..73aed0feea 100644 --- a/engines/sci/include/kdebug.h +++ b/engines/sci/include/kdebug.h @@ -40,7 +40,6 @@ struct _state; #define SCIkPARSER_NR 10 #define SCIkAVOIDPATH_NR 17 -#define SCIkERROR s, __FILE__, __LINE__, SCIkERROR_NR #define SCIkNODES s, __FILE__, __LINE__, 1 #define SCIkGRAPHICS s, __FILE__, __LINE__, 2 #define SCIkSTRINGS s, __FILE__, __LINE__, 3 diff --git a/engines/sci/include/resource.h b/engines/sci/include/resource.h index 278810490d..ada1e4823f 100644 --- a/engines/sci/include/resource.h +++ b/engines/sci/include/resource.h @@ -295,7 +295,7 @@ sci_sched_yield(void); # endif /* !__i386__ && !__alpha__ */ #endif #ifndef BREAKPOINT -# define BREAKPOINT() { fprintf(stderr, "Missed breakpoint in %s, line %d\n", __FILE__, __LINE__); *((int *) NULL) = 42; } +# define BREAKPOINT() { error("Missed breakpoint in %s, line %d\n", __FILE__, __LINE__); *((int *) NULL) = 42; } #endif /* !BREAKPOINT() */ #endif diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp index d2450f69b7..2de16d2f6b 100644 --- a/engines/sci/sci.cpp +++ b/engines/sci/sci.cpp @@ -121,7 +121,7 @@ init_gamestate(state_t *gamestate, sci_version_t version) { } if (!recovered) { - fprintf(stderr, "Script initialization failed. Aborting...\n"); + error("Script initialization failed. Aborting...\n"); return 1; } } @@ -244,7 +244,7 @@ Common::Error SciEngine::go() { if (game_init(gamestate)) { /* Initialize */ - fprintf(stderr, "Game initialization failed: Aborting...\n"); + error("Game initialization failed: Aborting...\n"); // TODO: Add an "init failed" error? return Common::kUnknownError; } @@ -290,17 +290,17 @@ Common::Error SciEngine::go() { /**** Default config ends */ if (gfxop_init_default(&gfx_state, &gfx_options, resmgr)) { - fprintf(stderr, "Graphics initialization failed. Aborting...\n"); + error("Graphics initialization failed. Aborting...\n"); return Common::kUnknownError; } if (game_init_graphics(gamestate)) { /* Init interpreter graphics */ - fprintf(stderr, "Game initialization failed: Error in GFX subsystem. Aborting...\n"); + error("Game initialization failed: Error in GFX subsystem. Aborting...\n"); return Common::kUnknownError; } if (game_init_sound(gamestate, 0)) { - fprintf(stderr, "Game initialization failed: Error in sound subsystem. Aborting...\n"); + error("Game initialization failed: Error in sound subsystem. Aborting...\n"); return Common::kUnknownError; } 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; } diff --git a/engines/sci/sfx/core.cpp b/engines/sci/sfx/core.cpp index 47942bdbf4..6a2180d2ed 100644 --- a/engines/sci/sfx/core.cpp +++ b/engines/sci/sfx/core.cpp @@ -129,22 +129,22 @@ static void _dump_playing_list(sfx_state_t *self, char *msg) { song_t *song = self->song; - fprintf(stderr, "[] Song list : [ "); + warning("[] Song list : [ "); song = *(self->songlib.lib); while (song) { - fprintf(stderr, "%08lx:%d ", song->handle, song->status); + warning("%08lx:%d ", song->handle, song->status); song = song->next_playing; } - fprintf(stderr, "]\n"); + warning("]\n"); - fprintf(stderr, "[] Play list (%s) : [ " , msg); + warning("[] Play list (%s) : [ " , msg); while (song) { - fprintf(stderr, "%08lx ", song->handle); + warning("%08lx ", song->handle); song = song->next_playing; } - fprintf(stderr, "]\n"); + warning("]\n"); } #endif @@ -153,17 +153,17 @@ _dump_songs(sfx_state_t *self) { #if 0 song_t *song = self->song; - fprintf(stderr, "Cue iterators:\n"); + warning("Cue iterators:\n"); song = *(self->songlib.lib); while (song) { - fprintf(stderr, " **\tHandle %08x (p%d): status %d\n", + warning(" **\tHandle %08x (p%d): status %d\n", song->handle, song->priority, song->status); SIMSG_SEND(song->it, SIMSG_PRINT(1)); song = song->next; } if (player) { - fprintf(stderr, "Audio iterator:\n"); + warning("Audio iterator:\n"); player->iterator_message(songit_make_message(0, SIMSG_PRINT(1))); } #endif @@ -238,8 +238,8 @@ _sfx_set_song_status(sfx_state_t *self, song_t *song, int status) { break; default: - fprintf(stderr, "%s L%d: Attempt to set invalid song" - " state %d!\n", __FILE__, __LINE__, status); + warning("%s L%d: Attempt to set invalid song" + " state %d", __FILE__, __LINE__, status); return; } @@ -399,7 +399,7 @@ static int _sfx_timer_active = 0; /* Timer toggle */ int sfx_play_iterator_pcm(song_iterator_t *it, song_handle_t handle) { #ifdef DEBUG_SONG_API - fprintf(stderr, "[sfx-core] Playing PCM: %08lx\n", handle); + warning("[sfx-core] Playing PCM: %08lx\n", handle); #endif if (mixer) { sfx_pcm_feed_t *newfeed = it->get_pcm_feed(it); @@ -451,7 +451,7 @@ sfx_init(sfx_state_t *self, ResourceManager *resmgr, int flags) { #ifdef DEBUG_SONG_API - fprintf(stderr, "[sfx-core] Initialising: flags=%x\n", flags); + warning("[sfx-core] Initialising: flags=%x\n", flags); #endif /*------------------*/ @@ -462,8 +462,8 @@ sfx_init(sfx_state_t *self, ResourceManager *resmgr, int flags) { timer = &sfx_timer_scummvm; if (!timer) { - fprintf(stderr, "[SFX] " __FILE__": Could not find timing mechanism\n"); - fprintf(stderr, "[SFX] Disabled sound support\n"); + warning("[SFX] " __FILE__": Could not find timing mechanism\n"); + warning("[SFX] Disabled sound support\n"); pcm_device = NULL; player = NULL; mixer = NULL; @@ -471,8 +471,8 @@ sfx_init(sfx_state_t *self, ResourceManager *resmgr, int flags) { } if (timer->init(_sfx_timer_callback, NULL)) { - fprintf(stderr, "[SFX] " __FILE__": Timer failed to initialize\n"); - fprintf(stderr, "[SFX] Disabled sound support\n"); + warning("[SFX] " __FILE__": Timer failed to initialize\n"); + warning("[SFX] Disabled sound support\n"); timer = NULL; pcm_device = NULL; player = NULL; @@ -527,7 +527,7 @@ sfx_exit(sfx_state_t *self) { callbackMutex->lock(); _sfx_timer_active = 0; #ifdef DEBUG_SONG_API - fprintf(stderr, "[sfx-core] Uninitialising\n"); + warning("[sfx-core] Uninitialising\n"); #endif song_lib_free(self->songlib); @@ -535,7 +535,7 @@ sfx_exit(sfx_state_t *self) { pcm_device = NULL; if (timer && timer->exit()) - fprintf(stderr, "[SFX] Timer reported error on exit\n"); + warning("[SFX] Timer reported error on exit\n"); /* WARNING: The mixer may hold feeds from the ** player, so we must stop the mixer BEFORE @@ -562,7 +562,7 @@ time_le(GTimeVal a, GTimeVal b) { void sfx_suspend(sfx_state_t *self, int suspend) { #ifdef DEBUG_SONG_API - fprintf(stderr, "[sfx-core] Suspending? = %d\n", suspend); + warning("[sfx-core] Suspending? = %d\n", suspend); #endif if (suspend && (!self->suspended)) { /* suspend */ @@ -599,7 +599,7 @@ sfx_poll(sfx_state_t *self, song_handle_t *handle, int *cue) *handle = self->song->handle; #ifdef DEBUG_SONG_API - fprintf(stderr, "[sfx-core] Polling any (%08lx)\n", *handle); + warning("[sfx-core] Polling any (%08lx)\n", *handle); #endif return sfx_poll_specific(self, *handle, cue); } @@ -618,7 +618,7 @@ sfx_poll_specific(sfx_state_t *self, song_handle_t handle, int *cue) { return 0; /* Song not playing */ if (self->debug & SFX_DEBUG_CUES) { - fprintf(stderr, "[SFX:CUE] Polled song %08lx ", handle); + warning("[SFX:CUE] Polled song %08lx ", handle); } while (1) { @@ -665,9 +665,6 @@ sfx_poll_specific(sfx_state_t *self, song_handle_t handle, int *cue) { break; } } - if (self->debug & SFX_DEBUG_CUES) { - fprintf(stderr, "\n"); - } } @@ -680,10 +677,10 @@ sfx_add_song(sfx_state_t *self, song_iterator_t *it, int priority, song_handle_t song_t *song = song_lib_find(self->songlib, handle); #ifdef DEBUG_SONG_API - fprintf(stderr, "[sfx-core] Adding song: %08lx at %d, it=%p\n", handle, priority, it); + warning("[sfx-core] Adding song: %08lx at %d, it=%p\n", handle, priority, it); #endif if (!it) { - fprintf(stderr, "[SFX] Attempt to add empty song with handle %08lx\n", handle); + warning("[SFX] Attempt to add empty song with handle %08lx\n", handle); return -1; } @@ -699,10 +696,10 @@ sfx_add_song(sfx_state_t *self, song_iterator_t *it, int priority, song_handle_t if (song) { _sfx_set_song_status(self, song, SOUND_STATUS_STOPPED); - fprintf(stderr, "Overwriting old song (%08lx) ...\n", handle); + warning("Overwriting old song (%08lx) ...\n", handle); if (song->status == SOUND_STATUS_PLAYING || song->status == SOUND_STATUS_SUSPENDED) { - fprintf(stderr, "Unexpected (error): Song %ld still playing/suspended (%d)\n", + warning("Unexpected (error): Song %ld still playing/suspended (%d)\n", handle, song->status); songit_free(it); return -1; @@ -727,7 +724,7 @@ sfx_add_song(sfx_state_t *self, song_iterator_t *it, int priority, song_handle_t void sfx_remove_song(sfx_state_t *self, song_handle_t handle) { #ifdef DEBUG_SONG_API - fprintf(stderr, "[sfx-core] Removing song: %08lx\n", handle); + warning("[sfx-core] Removing song: %08lx\n", handle); #endif if (self->song && self->song->handle == handle) self->song = NULL; @@ -742,14 +739,14 @@ sfx_remove_song(sfx_state_t *self, song_handle_t handle) { /* Song modifications */ /**********************/ -#define ASSERT_SONG(s) if (!(s)) { fprintf(stderr, "Looking up song handle %08lx failed in %s, L%d\n", handle, __FILE__, __LINE__); return; } +#define ASSERT_SONG(s) if (!(s)) { warning("Looking up song handle %08lx failed in %s, L%d\n", handle, __FILE__, __LINE__); return; } void sfx_song_set_status(sfx_state_t *self, song_handle_t handle, int status) { song_t *song = song_lib_find(self->songlib, handle); ASSERT_SONG(song); #ifdef DEBUG_SONG_API - fprintf(stderr, "[sfx-core] Setting song status to %d" + warning("[sfx-core] Setting song status to %d" " (0:stop, 1:play, 2:susp, 3:wait): %08lx\n", status, handle); #endif @@ -769,7 +766,7 @@ sfx_song_set_fade(sfx_state_t *self, song_handle_t handle, ASSERT_SONG(song); #ifdef DEBUG_SONG_API - fprintf(stderr, "[sfx-core] Setting fade params of %08lx to " + warning("[sfx-core] Setting fade params of %08lx to " "final volume %d in steps of %d per %d ticks. %s.\n", handle, fade->final_volume, fade->step_size, fade->ticks_per_step, stopmsg[fade->action]); @@ -785,7 +782,7 @@ sfx_song_renice(sfx_state_t *self, song_handle_t handle, int priority) { song_t *song = song_lib_find(self->songlib, handle); ASSERT_SONG(song); #ifdef DEBUG_SONG_API - fprintf(stderr, "[sfx-core] Renicing song %08lx to %d\n", + warning("[sfx-core] Renicing song %08lx to %d\n", handle, priority); #endif @@ -802,7 +799,7 @@ sfx_song_set_loops(sfx_state_t *self, song_handle_t handle, int loops) { ASSERT_SONG(song); #ifdef DEBUG_SONG_API - fprintf(stderr, "[sfx-core] Setting loops on %08lx to %d\n", + warning("[sfx-core] Setting loops on %08lx to %d\n", handle, loops); #endif songit_handle_message(&(song->it), msg); @@ -822,7 +819,7 @@ sfx_song_set_hold(sfx_state_t *self, song_handle_t handle, int hold) { song->hold = hold; #ifdef DEBUG_SONG_API - fprintf(stderr, "[sfx-core] Setting hold on %08lx to %d\n", + warning("[sfx-core] Setting hold on %08lx to %d\n", handle, loops); #endif songit_handle_message(&(song->it), msg); @@ -852,7 +849,7 @@ sfx_send_midi(sfx_state_t *self, song_handle_t handle, int channel, if (command == 0xb0 && arg1 == SCI_MIDI_CHANNEL_MUTE) { - sciprintf("TODO: channel mute (channel %d %s)!\n", channel, + sciprintf("TODO: channel mute (channel %d %s)", channel, channel_state[arg2]); /* We need to have a GET_PLAYMASK interface to use here. SET_PLAYMASK we've got. @@ -888,19 +885,19 @@ sfx_send_midi(sfx_state_t *self, song_handle_t handle, int channel, int sfx_get_volume(sfx_state_t *self) { - fprintf(stderr, "FIXME: Implement volume\n"); + warning("FIXME: Implement volume\n"); return 0; } void sfx_set_volume(sfx_state_t *self, int volume) { - fprintf(stderr, "FIXME: Implement volume\n"); + warning("FIXME: Implement volume\n"); } void sfx_all_stop(sfx_state_t *self) { #ifdef DEBUG_SONG_API - fprintf(stderr, "[sfx-core] All stop\n"); + warning("[sfx-core] All stop\n"); #endif song_lib_free(self->songlib); diff --git a/engines/sci/sfx/device/devices.cpp b/engines/sci/sfx/device/devices.cpp index a735cdaf3d..42f5a89dbb 100644 --- a/engines/sci/sfx/device/devices.cpp +++ b/engines/sci/sfx/device/devices.cpp @@ -23,6 +23,8 @@ * */ +#include "common/util.h" + #ifdef HAVE_CONFIG_H # include <config.h> #endif @@ -72,7 +74,7 @@ sfx_find_device(int type, char *name) { if (dev) { if (dev->init(dev)) { - fprintf(stderr, "[SFX] Opening device '%s' failed\n", + error("[SFX] Opening device '%s' failed\n", dev->name); return NULL; } diff --git a/engines/sci/sfx/iterator.cpp b/engines/sci/sfx/iterator.cpp index 0dad4a48f4..cf1e6db059 100644 --- a/engines/sci/sfx/iterator.cpp +++ b/engines/sci/sfx/iterator.cpp @@ -25,6 +25,8 @@ /* Song iterators */ +#include "common/util.h" + #include <stdio.h> #include "sci/include/sfx_iterator_internal.h" #include "sci/include/sfx_player.h" @@ -41,9 +43,9 @@ static const int MIDI_cmdlen[16] = {0, 0, 0, 0, 0, 0, 0, 0, void print_tabs_id(int nr, songit_id_t id) { while (nr-- > 0) - fprintf(stderr, "\t"); + error("\t"); - fprintf(stderr, "[%08lx] ", id); + error("[%08lx] ", id); } #ifndef HAVE_MEMCHR @@ -85,14 +87,14 @@ _common_init(base_song_iterator_t *self) { #define CHECK_FOR_END_ABSOLUTE(offset) \ if (offset > self->size) { \ - fprintf(stderr, SIPFX "Reached end of song without terminator (%x/%x) at %d!\n", offset, self->size, __LINE__); \ + error(SIPFX "Reached end of song without terminator (%x/%x) at %d", offset, self->size, __LINE__); \ return SI_FINISHED; \ } #define CHECK_FOR_END(offset_augment) \ if ((channel->offset + (offset_augment)) > channel->end) { \ channel->state = SI_STATE_FINISHED; \ - fprintf(stderr, SIPFX "Reached end of track %d without terminator (%x+%x/%x) at %d!\n", channel->id, channel->offset, offset_augment, channel->end, __LINE__); \ + error(SIPFX "Reached end of track %d without terminator (%x+%x/%x) at %d", channel->id, channel->offset, offset_augment, channel->end, __LINE__); \ return SI_FINISHED; \ } @@ -170,7 +172,7 @@ _parse_sci_midi_command(base_song_iterator_t *self, unsigned char *buf, int *res } if (cmd == 0xfe) { - fprintf(stderr, "song iterator subsystem: Corrupted sound resource detected.\n"); + error("song iterator subsystem: Corrupted sound resource detected.\n"); return SI_FINISHED; } @@ -181,9 +183,9 @@ _parse_sci_midi_command(base_song_iterator_t *self, unsigned char *buf, int *res #if 0 if (1) { - fprintf(stderr, "[IT]: off=%x, cmd=%02x, takes %d args ", + error("[IT]: off=%x, cmd=%02x, takes %d args ", channel->offset - 1, cmd, paramsleft); - fprintf(stderr, "[%02x %02x <%02x> %02x %02x %02x]\n", + error("[%02x %02x <%02x> %02x %02x %02x]\n", self->data[channel->offset-3], self->data[channel->offset-2], self->data[channel->offset-1], @@ -221,19 +223,19 @@ _parse_sci_midi_command(base_song_iterator_t *self, unsigned char *buf, int *res if (cmd == SCI_MIDI_EOT) { /* End of track? */ _reset_synth_channels(self, channel); - /* fprintf(stderr, "eot; loops = %d, notesplayed=%d\n", self->loops, channel->notes_played);*/ + /* error("eot; loops = %d, notesplayed=%d\n", self->loops, channel->notes_played);*/ if (self->loops > 1 /* && channel->notes_played*/) { /* If allowed, decrement the number of loops */ if (!(flags & PARSE_FLAG_LOOPS_UNLIMITED)) *result = --self->loops; #ifdef DEBUG_DECODING - fprintf(stderr, "%s L%d: (%p):%d Looping ", __FILE__, __LINE__, self, channel->id); + error("%s L%d: (%p):%d Looping ", __FILE__, __LINE__, self, channel->id); if (flags & PARSE_FLAG_LOOPS_UNLIMITED) - fprintf(stderr, "(indef.)"); + error("(indef.)"); else - fprintf(stderr, "(%d)", self->loops); - fprintf(stderr, " %x -> %x\n", + error("(%d)", self->loops); + error(" %x -> %x\n", channel->offset, channel->loop_offset); #endif channel->offset = channel->loop_offset; @@ -241,12 +243,12 @@ _parse_sci_midi_command(base_song_iterator_t *self, unsigned char *buf, int *res channel->state = SI_STATE_DELTA_TIME; channel->total_timepos = channel->loop_timepos; channel->last_cmd = 0xfe; - fprintf(stderr, "Looping song iterator %08lx.\n", self->ID); + error("Looping song iterator %08lx.\n", self->ID); return SI_LOOP; } else { channel->state = SI_STATE_FINISHED; #ifdef DEBUG_DECODING - fprintf(stderr, "%s L%d: (%p):%d EOT because" + error("%s L%d: (%p):%d EOT because" " %d notes, %d loops\n", __FILE__, __LINE__, self, channel->id, channel->notes_played, self->loops); @@ -389,12 +391,12 @@ _sci_midi_process_state(base_song_iterator_t *self, unsigned char *buf, int *res channel->state = SI_STATE_FINISHED; delay = (size * 50 + format.rate - 1) / format.rate; /* number of ticks to completion*/ - fprintf(stderr, "delaying %d ticks\n", delay); + error("delaying %d ticks\n", delay); return delay; } case SI_STATE_UNINITIALISED: - fprintf(stderr, SIPFX "Attempt to read command from uninitialized iterator!\n"); + error(SIPFX "Attempt to read command from uninitialized iterator"); self->init((song_iterator_t *) self); return self->next((song_iterator_t *) self, buf, result); @@ -433,7 +435,7 @@ _sci_midi_process_state(base_song_iterator_t *self, unsigned char *buf, int *res if (self->active_channels) --(self->active_channels); #ifdef DEBUG_DECODING - fprintf(stderr, "%s L%d: (%p):%d Finished channel, %d channels left\n", + error("%s L%d: (%p):%d Finished channel, %d channels left\n", __FILE__, __LINE__, self, channel->id, self->active_channels); #endif @@ -450,7 +452,7 @@ _sci_midi_process_state(base_song_iterator_t *self, unsigned char *buf, int *res } default: - fprintf(stderr, SIPFX "Invalid iterator state %d!\n", + error(SIPFX "Invalid iterator state %d", channel->state); BREAKPOINT(); return SI_FINISHED; @@ -509,8 +511,8 @@ _sci0_get_pcm_data(sci0_song_iterator_t *self, self->size - offset); if (!fc) { - fprintf(stderr, SIPFX "Warning: Playing unterminated" - " song!\n"); + error(SIPFX "Warning: Playing unterminated" + " song"); return 1; } @@ -523,7 +525,7 @@ _sci0_get_pcm_data(sci0_song_iterator_t *self, } if (!found_it) { - fprintf(stderr, SIPFX + error(SIPFX "Warning: Song indicates presence of PCM, but" " none found (finally at offset %04x)\n", offset); @@ -542,9 +544,9 @@ _sci0_get_pcm_data(sci0_song_iterator_t *self, if (offset + SCI0_PCM_DATA_OFFSET + size != self->size) { int d = offset + SCI0_PCM_DATA_OFFSET + size - self->size; - fprintf(stderr, SIPFX + error(SIPFX "Warning: PCM advertizes %d bytes of data, but %d" - " bytes are trailing in the resource!\n", + " bytes are trailing in the resource", size, self->size - (offset + SCI0_PCM_DATA_OFFSET)); if (d > 0) @@ -581,7 +583,7 @@ _sci0_handle_message(sci0_song_iterator_t *self, song_iterator_message_t msg) { case _SIMSG_BASEMSG_PRINT: print_tabs_id(msg.args[0].i, self->ID); - fprintf(stderr, "SCI0: dev=%d, active-chan=%d, size=%d, loops=%d\n", + error("SCI0: dev=%d, active-chan=%d, size=%d, loops=%d\n", self->device_id, self->active_channels, self->size, self->loops); break; @@ -596,7 +598,7 @@ _sci0_handle_message(sci0_song_iterator_t *self, song_iterator_message_t msg) { memcpy(mem, self, tsize); sci_refcount_incref(mem->data); #ifdef DEBUG_VERBOSE - fprintf(stderr, "** CLONE INCREF for new %p from %p at %p\n", mem, self, mem->data); + error("** CLONE INCREF for new %p from %p at %p\n", mem, self, mem->data); #endif return (struct _song_iterator *) mem; /* Assume caller has another copy of this */ } @@ -692,7 +694,7 @@ _sci0_init(sci0_song_iterator_t *self) { static void _sci0_cleanup(sci0_song_iterator_t *self) { #ifdef DEBUG_VERBOSE - fprintf(stderr, "** FREEING it %p: data at %p\n", self, self->data); + error("** FREEING it %p: data at %p\n", self, self->data); #endif if (self->data) sci_refcount_decref(self->data); @@ -746,7 +748,7 @@ _sci1_sample_init(sci1_song_iterator_t *self, int offset) { sample->data = self->data + offset + 10; #ifdef DEBUG_VERBOSE - fprintf(stderr, "[SAMPLE] %x/%x/%x/%x l=%x\n", + error("[SAMPLE] %x/%x/%x/%x l=%x\n", offset + 10, begin, end, self->size, length); #endif @@ -1080,7 +1082,7 @@ _sci1_process_next_command(sci1_song_iterator_t *self, } } else if (retval == SI_FINISHED) { #ifdef DEBUG - fprintf(stderr, "FINISHED some channel\n"); + error("FINISHED some channel\n"); #endif } else if (retval > 0) { int sd ; @@ -1116,7 +1118,7 @@ static struct _song_iterator * playmask |= self->channels[i].playmask; print_tabs_id(msg.args[0].i, self->ID); - fprintf(stderr, "SCI1: chan-nr=%d, playmask=%04x\n", + error("SCI1: chan-nr=%d, playmask=%04x\n", self->channels_nr, playmask); } break; @@ -1230,7 +1232,7 @@ static struct _song_iterator * } default: - fprintf(stderr, SIPFX "Unsupported command %d to" + error(SIPFX "Unsupported command %d to" " SCI1 iterator", msg.type); } return (song_iterator_t *) self; @@ -1300,7 +1302,7 @@ _cleanup_iterator_handle_message(song_iterator_t *i, song_iterator_message_t msg if (msg.recipient == _SIMSG_BASEMSG_PRINT && msg.type == _SIMSG_BASEMSG_PRINT) { print_tabs_id(msg.args[0].i, i->ID); - fprintf(stderr, "CLEANUP\n"); + error("CLEANUP\n"); } return NULL; @@ -1403,7 +1405,7 @@ _ff_handle_message(fast_forward_song_iterator_t *self, case _SIMSG_BASEMSG_PRINT: print_tabs_id(msg.args[0].i, self->ID); - fprintf(stderr, "PLASTICWRAP:\n"); + error("PLASTICWRAP:\n"); msg.args[0].i++; songit_handle_message(&(self->delegate), msg); break; @@ -1476,7 +1478,7 @@ _tee_read_next_command(tee_song_iterator_t *it, unsigned char *buf, int retid; #ifdef DEBUG_TEE_ITERATOR - fprintf(stderr, "[Tee] %02x\n", it->status); + error("[Tee] %02x\n", it->status); #endif if (!(it->status & (TEE_LEFT_ACTIVE | TEE_RIGHT_ACTIVE))) @@ -1491,7 +1493,7 @@ _tee_read_next_command(tee_song_iterator_t *it, unsigned char *buf, /* Not all are is active? */ int which = 0; #ifdef DEBUG_TEE_ITERATOR - fprintf(stderr, "\tRequesting transformation...\n"); + error("\tRequesting transformation...\n"); #endif if (it->status & TEE_LEFT_ACTIVE) which = TEE_LEFT; @@ -1525,7 +1527,7 @@ _tee_read_next_command(tee_song_iterator_t *it, unsigned char *buf, it->status |= ready_masks[i]; #ifdef DEBUG_TEE_ITERATOR - fprintf(stderr, "\t Must check %d: %d\n", i, + error("\t Must check %d: %d\n", i, it->children[i].retval); #endif @@ -1536,7 +1538,7 @@ _tee_read_next_command(tee_song_iterator_t *it, unsigned char *buf, it->status &= ~active_masks[i]; /* Recurse to complete */ #ifdef DEBUG_TEE_ITERATOR - fprintf(stderr, "\t Child %d signalled completion, recursing w/ status %02x\n", i, it->status); + error("\t Child %d signalled completion, recursing w/ status %02x\n", i, it->status); #endif return _tee_read_next_command(it, buf, result); } else if (it->children[i].retval == SI_PCM) { @@ -1557,7 +1559,7 @@ _tee_read_next_command(tee_song_iterator_t *it, unsigned char *buf, retid = TEE_RIGHT; #ifdef DEBUG_TEE_ITERATOR - fprintf(stderr, "\tl:%d / r:%d / chose %d\n", + error("\tl:%d / r:%d / chose %d\n", it->children[TEE_LEFT].retval, it->children[TEE_RIGHT].retval, retid); #endif #if 0 @@ -1621,7 +1623,7 @@ _tee_handle_message(tee_song_iterator_t *self, song_iterator_message_t msg) { case _SIMSG_BASEMSG_PRINT: print_tabs_id(msg.args[0].i, self->ID); - fprintf(stderr, "TEE:\n"); + error("TEE:\n"); msg.args[0].i++; break; /* And continue with our children */ @@ -1752,7 +1754,7 @@ songit_new_tee(song_iterator_t *left, song_iterator_t *right, int may_destroy) { if (firstfree == MIDI_CHANNELS) { incomplete_map = 1; - fprintf(stderr, "[songit-tee <%08lx,%08lx>] " + error("[songit-tee <%08lx,%08lx>] " "Could not remap right channel #%d:" " Out of channels\n", left->ID, right->ID, i); @@ -1766,14 +1768,14 @@ songit_new_tee(song_iterator_t *left, song_iterator_t *right, int may_destroy) { #ifdef DEBUG_TEE_ITERATOR if (incomplete_map) { int c; - fprintf(stderr, "[songit-tee <%08lx,%08lx>] Channels:" + error("[songit-tee <%08lx,%08lx>] Channels:" " %04x <- %04x | %04x\n", left->ID, right->ID, it->channel_mask, left->channel_mask, right->channel_mask); for (c = 0 ; c < 2; c++) for (i = 0 ; i < 16; i++) - fprintf(stderr, " map [%d][%d] -> %d\n", + error(" map [%d][%d] -> %d\n", c, i, it->children[c].channel_remap[i]); } #endif @@ -1821,14 +1823,14 @@ songit_next(song_iterator_t **it, unsigned char *buf, int *result, int mask) { do { retval = (*it)->next(*it, buf, result); if (retval == SI_MORPH) { - fprintf(stderr, " Morphing %p (stored at %p)\n", (void *)*it, (void *)it); + error(" Morphing %p (stored at %p)\n", (void *)*it, (void *)it); if (!SIMSG_SEND((*it), SIMSG_ACK_MORPH)) { BREAKPOINT(); - } else fprintf(stderr, "SI_MORPH successful\n"); + } else error("SI_MORPH successful\n"); } if (retval == SI_FINISHED) - fprintf(stderr, "[song-iterator] Song finished. mask = %04x, cm=%04x\n", + error("[song-iterator] Song finished. mask = %04x, cm=%04x\n", mask, (*it)->channel_mask); if (retval == SI_FINISHED && (mask & IT_READER_MAY_CLEAN) @@ -1871,7 +1873,7 @@ songit_new(unsigned char *data, unsigned int size, int type, songit_id_t id) { int i; if (!data || size < 22) { - fprintf(stderr, SIPFX "Attempt to instantiate song iterator for null" + error(SIPFX "Attempt to instantiate song iterator for null" " song data\n"); return NULL; } @@ -1921,7 +1923,7 @@ songit_new(unsigned char *data, unsigned int size, int type, songit_id_t id) { default: /**-- Invalid/unsupported sound resources --**/ - fprintf(stderr, SIPFX "Attempt to instantiate invalid/unknown" + error(SIPFX "Attempt to instantiate invalid/unknown" " song iterator type %d\n", type); return NULL; } @@ -2004,7 +2006,7 @@ song_iterator_add_death_listener(song_iterator_t *it, void *client, void (*notify)(void *self, void *notifier)) { if (it->death_listeners_nr >= SONGIT_MAX_LISTENERS) { - fprintf(stderr, "FATAL: Too many death listeners for song" + error("FATAL: Too many death listeners for song" " iterator\n"); BREAKPOINT(); exit(1); @@ -2033,7 +2035,7 @@ song_iterator_remove_death_listener(song_iterator_t *it, } } - fprintf(stderr, "FATAL: Could not remove death listener from " + error("FATAL: Could not remove death listener from " "song iterator\n"); BREAKPOINT(); exit(1); diff --git a/engines/sci/sfx/mixer/soft.cpp b/engines/sci/sfx/mixer/soft.cpp index 093a57e3e9..5aa80c11ae 100644 --- a/engines/sci/sfx/mixer/soft.cpp +++ b/engines/sci/sfx/mixer/soft.cpp @@ -23,6 +23,7 @@ * */ +#include "common/util.h" #include "../mixer.h" #include "sci/include/sci_memory.h" @@ -48,9 +49,9 @@ static volatile int mixer_lock = 0; /*#define DEBUG_LOCKS*/ #ifdef DEBUG_LOCKS -# define DEBUG_ACQUIRE fprintf(stderr, "[ -LOCK -] ACKQ %d: %d\n", __LINE__, mixer_lock) -# define DEBUG_WAIT fprintf(stderr, "[ -LOCK -] WAIT %d: %d\n", __LINE__, mixer_lock); -# define DEBUG_RELEASE ; fprintf(stderr, "[ -LOCK -] REL %d: %d\n", __LINE__, mixer_lock); +# define DEBUG_ACQUIRE error("[ -LOCK -] ACKQ %d: %d\n", __LINE__, mixer_lock) +# define DEBUG_WAIT error("[ -LOCK -] WAIT %d: %d\n", __LINE__, mixer_lock); +# define DEBUG_RELEASE ; error("[ -LOCK -] REL %d: %d\n", __LINE__, mixer_lock); #else # define DEBUG_ACQUIRE # define DEBUG_WAIT @@ -164,7 +165,7 @@ mix_subscribe(sfx_pcm_mixer_t *self, sfx_pcm_feed_t *feed) { fs->buf_size = 2 + /* Additional safety */ (self->dev->buf_size * (1 + (feed->conf.rate / self->dev->conf.rate))); - fprintf(stderr, " ---> %d/%d/%d/%d = %d\n", + warning(" ---> %d/%d/%d/%d = %d\n", self->dev->buf_size, feed->conf.rate, self->dev->conf.rate, @@ -172,7 +173,7 @@ mix_subscribe(sfx_pcm_mixer_t *self, sfx_pcm_feed_t *feed) { fs->buf_size); fs->buf = (byte*)sci_malloc(fs->buf_size * feed->frame_size); - fprintf(stderr, " ---> --> %d for %p at %p\n", fs->buf_size * feed->frame_size, (void *)fs, (void *)fs->buf); + warning(" ---> --> %d for %p at %p\n", fs->buf_size * feed->frame_size, (void *)fs, (void *)fs->buf); { int i; for (i = 0; i < fs->buf_size * feed->frame_size; i++) @@ -232,7 +233,7 @@ _mix_unsubscribe(sfx_pcm_mixer_t *self, sfx_pcm_feed_t *feed) { } for (i = 0; i < self->feeds_nr; i++) - fprintf(stderr, " Feed #%d: %s-%x\n", + warning(" Feed #%d: %s-%x\n", i, self->feeds[i].feed->debug_name, self->feeds[i].feed->debug_nr); @@ -240,7 +241,7 @@ _mix_unsubscribe(sfx_pcm_mixer_t *self, sfx_pcm_feed_t *feed) { } } - fprintf(stderr, "[sfx-mixer] Assertion failed: Deleting invalid feed %p out of %d\n", + error("[sfx-mixer] Assertion failed: Deleting invalid feed %p out of %d\n", (void *)feed, self->feeds_nr); BREAKPOINT(); @@ -412,7 +413,7 @@ mix_compute_buf_len(sfx_pcm_mixer_t *self, int *skip_frames) return self->dev->buf_size; } - /* fprintf(stderr, "[%d:%d]S%d ", secs, usecs, P->skew);*/ + /* error("[%d:%d]S%d ", secs, usecs, P->skew);*/ if (P->skew > usecs) { secs--; @@ -425,7 +426,7 @@ mix_compute_buf_len(sfx_pcm_mixer_t *self, int *skip_frames) played_frames = frame_pos - P->played_this_second + ((secs - P->lsec) * self->dev->conf.rate); /* - fprintf(stderr, "%d:%d - %d:%d => %d\n", secs, frame_pos, + error("%d:%d - %d:%d => %d\n", secs, frame_pos, P->lsec, P->played_this_second, played_frames); */ @@ -433,7 +434,7 @@ mix_compute_buf_len(sfx_pcm_mixer_t *self, int *skip_frames) played_frames = self->dev->buf_size; /* - fprintf(stderr, "Between %d:? offset=%d and %d:%d offset=%d: Played %d at %d\n", P->lsec, P->played_this_second, + error("Between %d:? offset=%d and %d:%d offset=%d: Played %d at %d\n", P->lsec, P->played_this_second, secs, usecs, frame_pos, played_frames, self->dev->conf.rate); */ @@ -489,7 +490,7 @@ mix_compute_buf_len(sfx_pcm_mixer_t *self, int *skip_frames) } if (result_frames > self->dev->buf_size) { - fprintf(stderr, "[soft-mixer] Internal assertion failed: frames-to-write %d > %d\n", + error("[soft-mixer] Internal assertion failed: frames-to-write %d > %d\n", result_frames, self->dev->buf_size); } return result_frames; @@ -584,7 +585,7 @@ mix_compute_input_linear(sfx_pcm_mixer_t *self, int add_result, ts->secs = -1; if (frames_nr > fs->buf_size) { - fprintf(stderr, "%d (%d*%d + somethign) bytes, but only %d allowed!!!!!\n", + error("%d (%d*%d + somethign) bytes, but only %d allowed!!!!", frames_nr * f->frame_size, fs->spd.val, len, fs->buf_size); @@ -635,7 +636,7 @@ mix_compute_input_linear(sfx_pcm_mixer_t *self, int add_result, return; default: - fprintf(stderr, "[soft-mixer] Fatal: Invalid mode returned by PCM feed %s-%d's get_timestamp(): %d\n", + error("[soft-mixer] Fatal: Invalid mode returned by PCM feed %s-%d's get_timestamp(): %d\n", f->debug_name, f->debug_nr, newmode); exit(1); } @@ -788,7 +789,7 @@ mix_compute_input_linear(sfx_pcm_mixer_t *self, int add_result, xx_size = frames_left * f->frame_size; if (xx_offset + xx_size >= fs->buf_size * f->frame_size) { - fprintf(stderr, "offset %d >= max %d!\n", + error("offset %d >= max %d", (xx_offset + xx_size), fs->buf_size * f->frame_size); BREAKPOINT(); } diff --git a/engines/sci/sfx/player/polled.cpp b/engines/sci/sfx/player/polled.cpp index b5b2eaf386..2274b0003a 100644 --- a/engines/sci/sfx/player/polled.cpp +++ b/engines/sci/sfx/player/polled.cpp @@ -25,12 +25,13 @@ /* Polled player, mostly for PCM-based thingies (which _can_ poll, after all) */ +#include "common/file.h" +#include "common/util.h" + #include "sci/include/sfx_player.h" #include "sci/sfx/softseq.h" #include "sci/sfx/mixer.h" -#include "common/file.h" - static song_iterator_t *play_it; static int play_paused = 0; static sfx_softseq_t *seq; @@ -237,7 +238,7 @@ pp_add_iterator(song_iterator_t *it, GTimeVal start_time) { static int pp_fade_out(void) { - fprintf(stderr, __FILE__": Attempt to fade out- not implemented yet\n"); + warning(__FILE__": Attempt to fade out- not implemented yet\n"); return SFX_ERROR; } @@ -246,7 +247,7 @@ pp_stop(void) { song_iterator_t *it = play_it; play_it = NULL; - fprintf(stderr, "[play] Now stopping it %p\n", (void *)it); + warning("[play] Now stopping it %p\n", (void *)it); if (it) songit_free(it); diff --git a/engines/sci/sfx/player/realtime.cpp b/engines/sci/sfx/player/realtime.cpp index 5821d0b59d..ab3abc1513 100644 --- a/engines/sci/sfx/player/realtime.cpp +++ b/engines/sci/sfx/player/realtime.cpp @@ -27,6 +27,7 @@ ** prays for some reasonable amount of soft real-time, but it's close ** enough, I guess. */ +#include "common/util.h" #include "sci/include/sfx_player.h" #include "sci/sfx/sequencer.h" @@ -158,7 +159,7 @@ find_patch(ResourceManager *resmgr, const char *seq_name, int patchfile) { if (patchfile != SFX_SEQ_PATCHFILE_NONE) { res = scir_find_resource(resmgr, sci_patch, patchfile, 0); if (!res) { - fprintf(stderr, "[SFX] " __FILE__": patch.%03d requested by sequencer (%s), but not found\n", + error("[SFX] " __FILE__": patch.%03d requested by sequencer (%s), but not found\n", patchfile, seq_name); } } @@ -182,7 +183,7 @@ rt_init(ResourceManager *resmgr, int expected_latency) { seq = sfx_find_sequencer(NULL); if (!seq) { - fprintf(stderr, "[SFX] " __FILE__": Could not find sequencer\n"); + error("[SFX] " __FILE__": Could not find sequencer\n"); return SFX_ERROR; } @@ -199,7 +200,7 @@ rt_init(ResourceManager *resmgr, int expected_latency) { res2 ? res2->size : 0, res2 ? res2->data : NULL, seq_dev)) { - fprintf(stderr, "[SFX] " __FILE__": Sequencer failed to initialize\n"); + error("[SFX] " __FILE__": Sequencer failed to initialize\n"); return SFX_ERROR; } @@ -233,7 +234,7 @@ rt_add_iterator(song_iterator_t *it, GTimeVal start_time) { static int rt_fade_out(void) { - fprintf(stderr, __FILE__": Attempt to fade out- not implemented yet\n"); + error(__FILE__": Attempt to fade out- not implemented yet\n"); return SFX_ERROR; } @@ -286,7 +287,7 @@ rt_exit(void) { int retval = SFX_OK; if (seq->close()) { - fprintf(stderr, "[SFX] Sequencer reported error on close\n"); + error("[SFX] Sequencer reported error on close\n"); retval = SFX_ERROR; } diff --git a/engines/sci/sfx/softseq/SN76496.cpp b/engines/sci/sfx/softseq/SN76496.cpp index 0f398180a9..8ec8eb89e4 100644 --- a/engines/sci/sfx/softseq/SN76496.cpp +++ b/engines/sci/sfx/softseq/SN76496.cpp @@ -64,7 +64,7 @@ SN76496_event(sfx_softseq_t *self, byte command, int argc, byte *argv) { int i; int chan = -1; #if 0 - fprintf(stderr, "Note [%02x : %02x %02x]\n", command, argc ? argv[0] : 0, (argc > 1) ? argv[1] : 0); + error("Note [%02x : %02x %02x]\n", command, argc ? argv[0] : 0, (argc > 1) ? argv[1] : 0); #endif if ((command & 0xe0) == 0x80) { int chan_nr = command & 0xf; @@ -96,7 +96,7 @@ SN76496_event(sfx_softseq_t *self, byte command, int argc, byte *argv) { } } #if 0 - fprintf(stderr, " --> %d [%04x], {%d,%d,%d}@%d\n", chan, + error(" --> %d [%04x], {%d,%d,%d}@%d\n", chan, channels_assigned, chan_nrs[0], chan_nrs[1], chan_nrs[2], channel_assigner); #endif @@ -125,7 +125,7 @@ SN76496_event(sfx_softseq_t *self, byte command, int argc, byte *argv) { default: #if DEBUG - fprintf(stderr, "[SFX:PCM-PC] Unused MIDI command %02x %02x %02x\n", command, argc ? argv[0] : 0, (argc > 1) ? argv[1] : 0); + error("[SFX:PCM-PC] Unused MIDI command %02x %02x %02x\n", command, argc ? argv[0] : 0, (argc > 1) ? argv[1] : 0); #endif break; /* ignore */ } diff --git a/engines/sci/sfx/softseq/opl2.cpp b/engines/sci/sfx/softseq/opl2.cpp index 9dc9bf387b..d84a114158 100644 --- a/engines/sci/sfx/softseq/opl2.cpp +++ b/engines/sci/sfx/softseq/opl2.cpp @@ -473,12 +473,12 @@ opl2_poll(sfx_softseq_t *self, byte *dest, int count) { gint16 *ptr = buffer; if (!ready) { - fprintf(stderr, "synth_mixer(): !ready \n"); + error("synth_mixer(): !ready \n"); exit(1); } if (!buffer) { - fprintf(stderr, "synth_mixer(): !buffer \n"); + error("synth_mixer(): !buffer \n"); exit(1); } @@ -537,7 +537,7 @@ opl2_init(sfx_softseq_t *self, byte *data_ptr, int data_length, byte *data2_ptr, if (!(ym3812_L = OPLCreate(OPL_TYPE_YM3812, OPL_INTERNAL_FREQ, SAMPLE_RATE)) || !(ym3812_R = OPLCreate(OPL_TYPE_YM3812, OPL_INTERNAL_FREQ, SAMPLE_RATE))) { - sciprintf("[sfx:seq:opl2] Failure: Emulator init failed!\n"); + sciprintf("[sfx:seq:opl2] Failure: Emulator init failed"); return SFX_ERROR; } diff --git a/engines/sci/sfx/softseq/pcspeaker.cpp b/engines/sci/sfx/softseq/pcspeaker.cpp index ba4236a917..f0685914f1 100644 --- a/engines/sci/sfx/softseq/pcspeaker.cpp +++ b/engines/sci/sfx/softseq/pcspeaker.cpp @@ -56,7 +56,7 @@ sps_exit(sfx_softseq_t *self) { static void sps_event(sfx_softseq_t *self, byte command, int argc, byte *argv) { #if 0 - fprintf(stderr, "Note [%02x : %02x %02x]\n", command, argc ? argv[0] : 0, (argc > 1) ? argv[1] : 0); + error("Note [%02x : %02x %02x]\n", command, argc ? argv[0] : 0, (argc > 1) ? argv[1] : 0); #endif switch (command & 0xf0) { @@ -82,7 +82,7 @@ sps_event(sfx_softseq_t *self, byte command, int argc, byte *argv) { default: #if DEBUG - fprintf(stderr, "[SFX:PCM-PC] Unused MIDI command %02x %02x %02x\n", command, argc ? argv[0] : 0, (argc > 1) ? argv[1] : 0); + error("[SFX:PCM-PC] Unused MIDI command %02x %02x %02x\n", command, argc ? argv[0] : 0, (argc > 1) ? argv[1] : 0); #endif break; /* ignore */ } diff --git a/engines/sci/sfx/time.cpp b/engines/sci/sfx/time.cpp index f908525983..9e366ca4d9 100644 --- a/engines/sci/sfx/time.cpp +++ b/engines/sci/sfx/time.cpp @@ -23,6 +23,7 @@ * */ +#include "common/util.h" #include "sci/include/sfx_time.h" #include "sci/include/resource.h" @@ -60,7 +61,7 @@ sfx_timestamp_frame_diff(sfx_timestamp_t a, sfx_timestamp_t b) { long usecdelta = 0; if (a.frame_rate != b.frame_rate) { - fprintf(stderr, "Fatal: The semantics of subtracting two timestamps with a different base from each other is not defined!\n"); + error("Fatal: The semantics of subtracting two timestamps with a different base from each other is not defined"); BREAKPOINT(); } |