diff options
-rw-r--r-- | saga/actionmap.cpp | 6 | ||||
-rw-r--r-- | saga/actor.cpp | 27 | ||||
-rw-r--r-- | saga/animation.cpp | 34 | ||||
-rw-r--r-- | saga/console.cpp | 11 | ||||
-rw-r--r-- | saga/cvar.cpp | 2 | ||||
-rw-r--r-- | saga/events.cpp | 8 | ||||
-rw-r--r-- | saga/events.h | 1 | ||||
-rw-r--r-- | saga/font.cpp | 20 | ||||
-rw-r--r-- | saga/font.h | 2 | ||||
-rw-r--r-- | saga/game.cpp | 14 | ||||
-rw-r--r-- | saga/interface.cpp | 2 | ||||
-rw-r--r-- | saga/ite_introproc.cpp | 28 | ||||
-rw-r--r-- | saga/music.cpp | 3 | ||||
-rw-r--r-- | saga/objectmap.cpp | 32 | ||||
-rw-r--r-- | saga/palanim.cpp | 26 | ||||
-rw-r--r-- | saga/reinherit.h | 11 | ||||
-rw-r--r-- | saga/saga.cpp | 10 | ||||
-rw-r--r-- | saga/scene.cpp | 119 | ||||
-rw-r--r-- | saga/sceneproc.cpp | 4 | ||||
-rw-r--r-- | saga/script.cpp | 54 | ||||
-rw-r--r-- | saga/sdata.cpp | 6 | ||||
-rw-r--r-- | saga/sprite.cpp | 6 | ||||
-rw-r--r-- | saga/sthread.cpp | 4 |
23 files changed, 189 insertions, 241 deletions
diff --git a/saga/actionmap.cpp b/saga/actionmap.cpp index e884b716f1..57238d51ff 100644 --- a/saga/actionmap.cpp +++ b/saga/actionmap.cpp @@ -42,7 +42,7 @@ int ACTIONMAP_Register(void) { } int ACTIONMAP_Init(void) { - R_printf(R_STDOUT, "ACTIONMAP Module: Initializing...\n"); + debug(0, "ACTIONMAP Module: Initializing..."); ActmapModule.init = 1; return R_SUCCESS; } @@ -68,7 +68,7 @@ int ACTIONMAP_Load(const byte * exmap_res, size_t exmap_res_len) { exmap_entry = (R_ACTIONMAP_ENTRY *)malloc(exit_ct * sizeof *exmap_entry); if (exmap_entry == NULL) { - R_printf(R_STDERR, "Memory allocation failure.\n"); + warning("Memory allocation failure"); return R_MEM; } @@ -86,7 +86,7 @@ int ACTIONMAP_Load(const byte * exmap_res, size_t exmap_res_len) { exmap_pt_tbl = (R_POINT *)malloc(exmap_entry[i].pt_count * sizeof *exmap_pt_tbl); if (exmap_pt_tbl == NULL) { - R_printf(R_STDERR, "Memory allocation failure.\n"); + warning("Memory allocation failure"); return R_MEM; } diff --git a/saga/actor.cpp b/saga/actor.cpp index 4a05a917e7..4a1fc66dae 100644 --- a/saga/actor.cpp +++ b/saga/actor.cpp @@ -351,7 +351,7 @@ int AddActor(R_ACTOR * actor) { } if (last_frame >= SPRITE_GetListLen(actor->sl_p)) { - R_printf(R_STDOUT, "Appending to sprite list %d.\n", actor->sl_rn); + debug(0, "Appending to sprite list %d.", actor->sl_rn); if (SPRITE_AppendList(actor->sl_rn + 1, actor->sl_p) != R_SUCCESS) { return R_FAILURE; @@ -662,18 +662,18 @@ int LoadActorSpriteIndex(R_ACTOR * actor, int si_rn, int *last_frame_p) { result = RSC_LoadResource(ActorModule.actor_ctxt, si_rn, &res_p, &res_len); if (result != R_SUCCESS) { - R_printf(R_STDERR, "Couldn't load sprite action index resource.\n"); + warning("Couldn't load sprite action index resource"); return R_FAILURE; } s_action_ct = res_len / 16; - R_printf(R_STDOUT, "Sprite resource contains %d sprite actions.\n", s_action_ct); + debug(0, "Sprite resource contains %d sprite actions.", s_action_ct); action_p = (R_ACTORACTION *)malloc(sizeof(R_ACTORACTION) * s_action_ct); MemoryReadStream *readS = new MemoryReadStream(res_p, res_len); if (action_p == NULL) { - R_printf(R_STDERR, "Couldn't allocate memory for sprite actions.\n"); + warning("Couldn't allocate memory for sprite actions"); RSC_FreeResource(res_p); return R_MEM; } @@ -838,16 +838,14 @@ int HandleWalkIntent(R_ACTOR *actor, R_WALKINTENT *a_walkint, int *complete_p, i if (node_p->calc_flag == 0) { -#if 0 - R_printf(R_STDOUT, "Calculating new path vector to point (%d, %d)\n", node_p->node_pt.x, node_p->node_pt.y); -#endif + debug(2, "Calculating new path vector to point (%d, %d)", node_p->node_pt.x, node_p->node_pt.y); dx = a_walkint->org.x - node_p->node_pt.x; dy = a_walkint->org.y - node_p->node_pt.y; if (dx == 0) { - R_printf(R_STDOUT, "Vertical paths not implemented.\n"); + debug(0, "Vertical paths not implemented."); ys_dll_delete(walk_p); a_walkint->wi_active = 0; @@ -889,9 +887,7 @@ int HandleWalkIntent(R_ACTOR *actor, R_WALKINTENT *a_walkint, int *complete_p, i sprintf(buf, "%f", a_walkint->slope); -#if 0 - R_printf(R_STDOUT, "Path slope: %s.\n", buf); -#endif + debug(2, "Path slope: %s.", buf); actor->action = ACTION_WALK; actor->action_flags = ACTION_LOOP; @@ -917,9 +913,7 @@ int HandleWalkIntent(R_ACTOR *actor, R_WALKINTENT *a_walkint, int *complete_p, i if (a_walkint->x_dir == 1) { if (new_a_x >= node_p->node_pt.x) { -#if 0 - R_printf(R_STDOUT, "Path complete.\n"); -#endif + debug(2, "Path complete."); ys_dll_delete(walk_p); a_walkint->wi_active = 0; @@ -935,10 +929,7 @@ int HandleWalkIntent(R_ACTOR *actor, R_WALKINTENT *a_walkint, int *complete_p, i } } else { if (new_a_x <= node_p->node_pt.x) { - -#if 0 - R_printf(R_STDOUT, "Path complete.\n"); -#endif + debug(2, "Path complete."); ys_dll_delete(walk_p); a_walkint->wi_active = 0; diff --git a/saga/animation.cpp b/saga/animation.cpp index 92195afad4..09c50f4064 100644 --- a/saga/animation.cpp +++ b/saga/animation.cpp @@ -85,7 +85,7 @@ int ANIM_Load(const byte *anim_resdata, size_t anim_resdata_len, uint16 *anim_id new_anim = (R_ANIMATION *)malloc(sizeof *new_anim); if (new_anim == NULL) { - R_printf(R_STDERR, "Error: Allocation failure.\n"); + warning("Error: Allocation failure"); return R_MEM; } @@ -94,14 +94,14 @@ int ANIM_Load(const byte *anim_resdata, size_t anim_resdata_len, uint16 *anim_id if (GAME_GetGameType() == R_GAMETYPE_ITE) { if (ANIM_GetNumFrames(anim_resdata, anim_resdata_len, &new_anim->n_frames) != R_SUCCESS) { - R_printf(R_STDERR, "Error: Couldn't get animation frame count.\n"); + warning("Error: Couldn't get animation frame count"); return R_FAILURE; } // Cache frame offsets new_anim->frame_offsets = (size_t *)malloc(new_anim->n_frames * sizeof *new_anim->frame_offsets); if (new_anim->frame_offsets == NULL) { - R_printf(R_STDERR, "Error: Allocation failure.\n"); + warning("Error: Allocation failure"); return R_MEM; } @@ -195,20 +195,20 @@ int ANIM_Play(uint16 anim_id, int vector_time) { result = ITE_DecodeFrame(anim->resdata, anim->resdata_len, anim->frame_offsets[frame - 1], display_buf, disp_info.logical_w * disp_info.logical_h); if (result != R_SUCCESS) { - R_printf(R_STDERR, "ANIM_Play: Error decoding frame %u", anim->current_frame); + warning("ANIM_Play: Error decoding frame %u", anim->current_frame); anim->play_flag = 0; return R_FAILURE; } } else { if (anim->cur_frame_p == NULL) { - R_printf(R_STDERR, "ANIM_Play: Frames exhausted.\n"); + warning("ANIM_Play: Frames exhausted"); return R_FAILURE; } result = IHNM_DecodeFrame(display_buf, disp_info.logical_w * disp_info.logical_h, anim->cur_frame_p, anim->cur_frame_len, &nextf_p, &nextf_len); if (result != R_SUCCESS) { - R_printf(R_STDERR, "ANIM_Play: Error decoding frame %u", anim->current_frame); + warning("ANIM_Play: Error decoding frame %u", anim->current_frame); anim->play_flag = 0; return R_FAILURE; } @@ -436,7 +436,7 @@ int ITE_DecodeFrame(const byte *resdata, size_t resdata_len, size_t frame_offset if ((screen_w * screen_h) > buf_len) { // Buffer argument is too small to hold decoded frame, abort. - R_printf(R_STDERR, "ITE_DecodeFrame: Buffer size inadequate.\n"); + warning("ITE_DecodeFrame: Buffer size inadequate"); return R_FAILURE; } @@ -446,7 +446,7 @@ int ITE_DecodeFrame(const byte *resdata, size_t resdata_len, size_t frame_offset // Check for frame magic byte magic = readS->readByte(); if (magic != SAGA_FRAME_HEADER_MAGIC) { - R_printf(R_STDERR, "ITE_DecodeFrame: Invalid frame offset.\n"); + warning("ITE_DecodeFrame: Invalid frame offset"); return R_FAILURE; } @@ -543,7 +543,7 @@ int ITE_DecodeFrame(const byte *resdata, size_t resdata_len, size_t frame_offset break; default: // Unknown marker found - abort - R_printf(R_STDERR, "ITE_DecodeFrame: Invalid RLE marker encountered.\n"); + warning("ITE_DecodeFrame: Invalid RLE marker encountered"); return R_FAILURE; break; } @@ -596,7 +596,7 @@ int IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte *thisf_ int param6; if (thisf_len - readS->tell() < 13) { - R_printf(R_STDERR, "0x%02X: Input buffer underrun.", in_ch); + warning("0x%02X: Input buffer underrun", in_ch); return R_FAILURE; } @@ -614,7 +614,7 @@ int IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte *thisf_ outbuf_p = decode_buf + x_origin + (y_origin * di.logical_w); if (outbuf_p > outbuf_endp) { - R_printf(R_STDERR, "0x%02X: (0x%X) Invalid output position. (x: %d, y: %d)\n", + warning("0x%02X: (0x%X) Invalid output position. (x: %d, y: %d)", in_ch, in_ch_offset, x_origin, y_origin); return R_FAILURE; } @@ -626,11 +626,11 @@ int IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte *thisf_ case 0x10: // Long Unencoded Run runcount = readS->readSint16BE(); if (thisf_len - readS->tell() < runcount) { - R_printf(R_STDERR, "0x%02X: Input buffer underrun.", in_ch); + warning("0x%02X: Input buffer underrun", in_ch); return R_FAILURE; } if (outbuf_remain < runcount) { - R_printf(R_STDERR, "0x%02X: Output buffer overrun.", in_ch); + warning("0x%02X: Output buffer overrun", in_ch); return R_FAILURE; } @@ -647,7 +647,7 @@ int IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte *thisf_ break; case 0x1F: // 31: Unusued? if (thisf_len - readS->tell() < 3) { - R_printf(R_STDERR, "0x%02X: Input buffer underrun.", in_ch); + warning("0x%02X: Input buffer underrun", in_ch); return R_FAILURE; } @@ -658,7 +658,7 @@ int IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte *thisf_ break; case 0x20: // Long compressed run if (thisf_len - readS->tell() <= 3) { - R_printf(R_STDERR, "0x%02X: Input buffer underrun.", in_ch); + warning("0x%02X: Input buffer underrun", in_ch); return R_FAILURE; } @@ -693,7 +693,7 @@ int IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte *thisf_ x_vector = readS->readSint16BE(); if (((x_vector > 0) && ((size_t) x_vector > outbuf_remain)) || (-x_vector > outbuf_p - decode_buf)) { - R_printf(R_STDERR, "0x30: Invalid x_vector.\n"); + warning("0x30: Invalid x_vector"); return R_FAILURE; } @@ -703,7 +703,7 @@ int IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte *thisf_ break; case 0x3F: // 68: Frame end marker - printf("0x3F: Frame end marker\n"); + debug(1, "0x3F: Frame end marker"); if (decoded_data && (thisf_len - readS->tell() > 0)) { *nextf_p = thisf_p + readS->tell(); *nextf_len = thisf_len - readS->tell(); diff --git a/saga/console.cpp b/saga/console.cpp index b1cf724f6b..8c8aabe7d2 100644 --- a/saga/console.cpp +++ b/saga/console.cpp @@ -67,7 +67,7 @@ int CON_Init() { } int CON_Shutdown() { - R_printf(R_STDOUT, "CON_Shutdown(): Deleting console scrollback and command history.\n"); + debug(0, "CON_Shutdown(): Deleting console scrollback and command history."); CON_DeleteScroll(&ConScrollback); CON_DeleteScroll(&ConHistory); @@ -283,7 +283,7 @@ int CON_CmdUp() { strcpy(ConInfo.input_buf, start_ptr->str_p); ConInfo.input_pos = start_ptr->str_len - 1; - R_printf(R_STDOUT, "History pos: %d/%d", ConInfo.hist_pos, ConHistory.lines); + debug(0, "History pos: %d/%d", ConInfo.hist_pos, ConHistory.lines); return R_SUCCESS; } @@ -293,7 +293,7 @@ int CON_CmdDown(void) { int i; if (ConInfo.hist_pos == 1) { - R_printf(R_STDOUT, "Erased input buffer."); + debug(0, "Erased input buffer."); memset(ConInfo.input_buf, 0, R_CON_INPUTBUF_LEN); ConInfo.input_pos = 0; ConInfo.hist_pos--; @@ -316,8 +316,7 @@ int CON_CmdDown(void) { strcpy(ConInfo.input_buf, start_ptr->str_p); ConInfo.input_pos = start_ptr->str_len - 1; - R_printf(R_STDOUT, "History pos: %d/%d", ConInfo.hist_pos, - ConHistory.lines); + debug(0, "History pos: %d/%d", ConInfo.hist_pos, ConHistory.lines); return R_SUCCESS; } @@ -330,7 +329,7 @@ int CON_PageUp() { ConInfo.line_pos += n_lines; } - R_printf(R_STDOUT, "Line pos: %d", ConInfo.line_pos); + debug(0, "Line pos: %d", ConInfo.line_pos); return R_SUCCESS; } diff --git a/saga/cvar.cpp b/saga/cvar.cpp index 048b5b1985..84fd9888ff 100644 --- a/saga/cvar.cpp +++ b/saga/cvar.cpp @@ -77,7 +77,7 @@ int CVAR_Shutdown() { R_CVAR *temp_ptr; int i; - R_printf(R_STDOUT, "CVAR_Shutdown(): Deleting cvar hash table.\n"); + debug(0, "CVAR_Shutdown(): Deleting cvar hash table."); for (i = 0; i < R_CVAR_HASHLEN; i++) { for (walk_ptr = CVHashTbl[i]; walk_ptr; walk_ptr = temp_ptr) { diff --git a/saga/events.cpp b/saga/events.cpp index aff450b37f..dc9d49ef2e 100644 --- a/saga/events.cpp +++ b/saga/events.cpp @@ -49,13 +49,13 @@ namespace Saga { static YS_DL_LIST *EventList; int EVENT_Init() { - R_printf(R_STDOUT, "Initializing event subsystem...\n"); + debug(0, "Initializing event subsystem..."); EventList = ys_dll_create(); return (EventList != NULL) ? R_SUCCESS : R_FAILURE; } int EVENT_Shutdown() { - R_printf(R_STDOUT, "Shutting down event subsystem...\n"); + debug(0, "Shutting down event subsystem..."); EVENT_FreeList(); return R_SUCCESS; } @@ -99,7 +99,7 @@ int EVENT_HandleEvents(long msec) { default: result = R_EVENT_INVALIDCODE; - R_printf(R_STDERR, "Invalid event code encountered.\n"); + warning("Invalid event code encountered"); break; } @@ -447,7 +447,7 @@ static int ProcessEventTime(long msec) { event_count++; if (event_count > R_EVENT_WARNINGCOUNT) { - R_printf(R_STDERR, "WARNING: Event list exceeds %u.\n", R_EVENT_WARNINGCOUNT); + warning("Event list exceeds %u", R_EVENT_WARNINGCOUNT); } } diff --git a/saga/events.h b/saga/events.h index c2ae1a1d84..8d22151a6e 100644 --- a/saga/events.h +++ b/saga/events.h @@ -28,7 +28,6 @@ namespace Saga { -#define R_EVENT_DBGLVL R_DEBUG_NONE #define R_EVENT_WARNINGCOUNT 1000 #define R_EVENT_MASK 0x00FF diff --git a/saga/font.cpp b/saga/font.cpp index f073d85c46..1e72e1eb57 100644 --- a/saga/font.cpp +++ b/saga/font.cpp @@ -74,7 +74,7 @@ int FONT_Init() { int FONT_Shutdown() { // int i; - R_printf(R_STDOUT, "FONT_Shutdown(): Freeing fonts.\n"); + debug(0, "FONT_Shutdown(): Freeing fonts."); /* for ( i = 0 ; i < R_FONT_COUNT ; i ++ ) { if ( FontModule.fonts[i] != NULL ) { @@ -132,15 +132,11 @@ int FONT_Load(uint32 font_rn, int font_id) { fh.c_width = readS->readUint16LE(); fh.row_length = readS->readUint16LE(); -#if R_FONT_DBGLVL >= R_DEBUG_INFO - R_printf(R_STDOUT, "FONT_Load(): Reading font resource...\n"); -#endif + debug(1, "FONT_Load(): Reading font resource..."); -#if R_FONT_DBGLVL >= R_DEBUG_VERBOSE - R_printf(R_STDOUT, "Character width:\t%d\n", fh.c_width); - R_printf(R_STDOUT, "Character height:\t%d\n", fh.c_height); - R_printf(R_STDOUT, "Row padding:\t%d\n", fh.row_length); -#endif + debug(2, "Character width:\t%d", fh.c_width); + debug(2, "Character height:\t%d", fh.c_height); + debug(2, "Row padding:\t%d", fh.row_length); // Create normal font style normal_font = (R_FONT_STYLE *)malloc(sizeof *normal_font); @@ -173,7 +169,7 @@ int FONT_Load(uint32 font_rn, int font_id) { } if (readS->tell() != R_FONT_DESCSIZE) { - R_printf(R_STDERR, "Invalid font resource size.\n"); + warning("Invalid font resource size."); return R_FAILURE; } @@ -267,9 +263,7 @@ static R_FONT_STYLE *FONT_CreateOutline(R_FONT_STYLE *src_font) { new_row_len += new_byte_width; } -#if R_FONT_DBGLVL >= R_DEBUG_VERBOSE - R_printf(R_STDOUT, "New row length: %d\n", new_row_len); -#endif + debug(2, "New row length: %d", new_row_len); new_font->hdr.c_width = s_width + 2; new_font->hdr.c_height = s_height + 2; diff --git a/saga/font.h b/saga/font.h index d3813d3c9b..a3e5843f84 100644 --- a/saga/font.h +++ b/saga/font.h @@ -28,8 +28,6 @@ namespace Saga { -#define R_FONT_DBGLVL R_DEBUG_NONE - #define R_FONT_SHOWUNDEFINED 1 // Define to draw undefined characters * as ?'s // The first defined character (!) is the only one that may diff --git a/saga/game.cpp b/saga/game.cpp index 5eb9a41722..e3760fc05a 100644 --- a/saga/game.cpp +++ b/saga/game.cpp @@ -355,27 +355,27 @@ int LoadLanguage() { if (GameDescs[game_n].gd_game_type == R_GAMETYPE_ITE) { snprintf(lang_file, R_MAXPATH, "%s%s.%s", R_GAME_ITE_LANG_PREFIX, GameModule.game_language, R_GAME_LANG_EXT); if (!test_file.open(lang_file)) { - R_printf(R_STDOUT, "Couldn't open language file %s. Using default (US English)\n", lang_file); + debug(0, "Couldn't open language file %s. Using default (US English)", lang_file); return R_SUCCESS; } test_file.close(); if (INTERFACE_RegisterLang() != R_SUCCESS) { - R_printf(R_STDERR, "Error registering interface language cvars."); + warning("Error registering interface language cvars"); return R_FAILURE; } if (ITE_IntroRegisterLang() != R_SUCCESS) { - R_printf(R_STDERR, "Error registering intro sequence language cvars."); + warning("Error registering intro sequence language cvars"); return R_FAILURE; } - R_printf(R_STDOUT, "Using language file %s.\n", lang_file); + debug(0, "Using language file %s.", lang_file); // FIXME //CFG_Read(lang_path); } else { - R_printf(R_STDOUT, "Language support for this game not implemented.\n"); + debug(0, "Language support for this game not implemented."); } return R_SUCCESS; @@ -494,7 +494,7 @@ int DetectGame(const char *game_dir, uint16 *game_n_p) { continue; } - R_printf(R_STDOUT, "Found game: %s\n", GameDescs[game_n].gd_title); + debug(0, "Found game: %s", GameDescs[game_n].gd_title); *game_n_p = game_n; return R_SUCCESS; } @@ -530,7 +530,7 @@ int LoadGame(const char *game_dir, uint16 game_n) { return R_FAILURE; } - R_printf(R_STDOUT, "Opened resource file: %s\n", game_fname); + debug(0, "Opened resource file: %s", game_fname); GameModule.gfile_data[i].file_ctxt = load_ctxt; GameModule.gfile_data[i].file_types = GameDescs[game_n].gd_filedescs[i].gf_type; GameModule.gfile_data[i].file_flags = 0; diff --git a/saga/interface.cpp b/saga/interface.cpp index 1c03c285fb..8d1b56457b 100644 --- a/saga/interface.cpp +++ b/saga/interface.cpp @@ -150,7 +150,7 @@ int INTERFACE_Init(void) { IfModule.i_thread = STHREAD_Create(); if (IfModule.i_thread == NULL) { - R_printf(R_STDERR, "Error creating script thread for game interface module.\n"); + warning("Error creating script thread for game interface module"); return R_FAILURE; } diff --git a/saga/ite_introproc.cpp b/saga/ite_introproc.cpp index c4e00ce6b7..bf9a1df6a5 100644 --- a/saga/ite_introproc.cpp +++ b/saga/ite_introproc.cpp @@ -158,7 +158,7 @@ int ITE_IntroRegisterLang() { if (CVAR_Register_S(IntroDiag[i].i_str, IntroDiag[i].i_cvar_name, NULL, R_CVAR_CFG, R_INTRO_STRMAX) != R_SUCCESS) { - R_printf(R_STDERR, "Error registering intro text cvars."); + warning("Error registering intro text cvars"); return R_FAILURE; } } @@ -184,8 +184,8 @@ int ITE_IntroAnimProc(int param, R_SCENE_INFO *scene_info) { EVENT_Queue(&event); - R_printf(R_STDOUT, "Intro animation procedure started.\n"); - R_printf(R_STDOUT, "Linking animation resources...\n"); + debug(0, "Intro animation procedure started."); + debug(0, "Linking animation resources..."); ANIM_SetFrameTime(0, ITE_INTRO_FRAMETIME); @@ -201,7 +201,7 @@ int ITE_IntroAnimProc(int param, R_SCENE_INFO *scene_info) { // Scene should end on display of last animation frame ANIM_SetFlag(6, ANIM_ENDSCENE); - R_printf(R_STDOUT, "Beginning animation playback.\n"); + debug(0, "Beginning animation playback."); ANIM_Play(0, 0); @@ -218,7 +218,7 @@ int ITE_IntroAnimProc(int param, R_SCENE_INFO *scene_info) { case SCENE_END: break; default: - R_printf(R_STDERR, "Illegal scene procedure parameter.\n"); + warning("Illegal scene procedure parameter"); break; } @@ -337,7 +337,7 @@ int ITE_IntroCave1Proc(int param, R_SCENE_INFO *scene_info) { break; default: - R_printf(R_STDERR, "Illegal scene procedure paramater.\n"); + warning("Illegal scene procedure paramater"); break; } @@ -433,7 +433,7 @@ int ITE_IntroCave2Proc(int param, R_SCENE_INFO *scene_info) { case SCENE_END: break; default: - R_printf(R_STDERR, "Illegal scene procedure paramater.\n"); + warning("Illegal scene procedure paramater"); break; } @@ -530,7 +530,7 @@ int ITE_IntroCave3Proc(int param, R_SCENE_INFO *scene_info) { case SCENE_END: break; default: - R_printf(R_STDERR, "Illegal scene procedure paramater.\n"); + warning("Illegal scene procedure paramater"); break; } @@ -627,7 +627,7 @@ int ITE_IntroCave4Proc(int param, R_SCENE_INFO *scene_info) { case SCENE_END: break; default: - R_printf(R_STDERR, "Illegal scene procedure paramater.\n"); + warning("Illegal scene procedure paramater"); break; } @@ -672,7 +672,7 @@ int ITE_IntroValleyProc(int param, R_SCENE_INFO *scene_info) { q_event = EVENT_Queue(&event); - R_printf(R_STDOUT, "Beginning animation playback.\n"); + debug(0, "Beginning animation playback."); // Begin title screen background animation ANIM_SetFlag(0, ANIM_LOOP); @@ -732,7 +732,7 @@ int ITE_IntroValleyProc(int param, R_SCENE_INFO *scene_info) { case SCENE_END: break; default: - R_printf(R_STDERR, "Illegal scene procedure parameter.\n"); + warning("Illegal scene procedure parameter"); break; } @@ -838,7 +838,7 @@ int ITE_IntroTreeHouseProc(int param, R_SCENE_INFO *scene_info) { case SCENE_END: break; default: - R_printf(R_STDERR, "Illegal scene procedure parameter.\n"); + warning("Illegal scene procedure parameter"); break; } @@ -947,7 +947,7 @@ int ITE_IntroFairePathProc(int param, R_SCENE_INFO *scene_info) { case SCENE_END: break; default: - R_printf(R_STDERR, "Illegal scene procedure parameter.\n"); + warning("Illegal scene procedure parameter"); break; } @@ -983,7 +983,7 @@ int ITE_IntroFaireTentProc(int param, R_SCENE_INFO *scene_info) { case SCENE_END: break; default: - R_printf(R_STDERR, "Illegal scene procedure parameter.\n"); + warning("Illegal scene procedure parameter"); break; } diff --git a/saga/music.cpp b/saga/music.cpp index 8479beca5d..a76ba785e4 100644 --- a/saga/music.cpp +++ b/saga/music.cpp @@ -297,8 +297,7 @@ int Music::play(uint32 music_rn, uint16 flags) { if (RSC_LoadResource(rsc_ctxt, music_rn, &resource_data, &resource_size) != R_SUCCESS ) { - R_printf(R_STDERR, "SYSMUSIC_Play(): Resource load failed: %u", - music_rn); + warning("SYSMUSIC_Play(): Resource load failed: %u", music_rn); return R_FAILURE; } diff --git a/saga/objectmap.cpp b/saga/objectmap.cpp index 5115cc9650..23fc284396 100644 --- a/saga/objectmap.cpp +++ b/saga/objectmap.cpp @@ -34,8 +34,6 @@ #include "gfx_mod.h" #include "font_mod.h" -#define R_OBJECTMAP_DEBUG R_DEBUG_INFO - #include "objectmap_mod.h" #include "objectmap.h" @@ -51,7 +49,7 @@ int OBJECTMAP_Register() { // Initializes the object map module, creates module allocation context int OBJECTMAP_Init() { - R_printf(R_STDOUT, "OBJECTMAP Module: Initializing...\n"); + debug(0, "OBJECTMAP Module: Initializing..."); OMInfo.initialized = 1; return R_SUCCESS; @@ -63,12 +61,12 @@ int OBJECTMAP_Shutdown() { return R_FAILURE; } - R_printf(R_STDOUT, "OBJECTMAP Module: Shutting down...\n"); + debug(0, "OBJECTMAP Module: Shutting down..."); OBJECTMAP_Free(); OBJECTMAP_FreeNames(); - R_printf(R_STDOUT, "OBJECTMAP Module: Shutdown AOK.\n"); + debug(0, "OBJECTMAP Module: Shutdown AOK."); OMInfo.initialized = 0; return R_SUCCESS; @@ -85,7 +83,7 @@ int OBJECTMAP_Load(const byte *om_res, size_t om_res_len) { MemoryReadStream *readS = new MemoryReadStream(om_res, om_res_len); if (!OMInfo.initialized) { - R_printf(R_STDERR, "Error: Object map module not initialized!\n"); + warning("Error: Object map module not initialized"); return R_FAILURE; } @@ -99,7 +97,7 @@ int OBJECTMAP_Load(const byte *om_res, size_t om_res_len) { OMInfo.object_maps = (R_OBJECTMAP_ENTRY *)malloc(OMInfo.n_objects * sizeof *OMInfo.object_maps); if (OMInfo.object_maps == NULL) { - R_printf(R_STDERR, "Error: Memory allocation failed.\n"); + warning("Error: Memory allocation failed"); return R_MEM; } @@ -114,7 +112,7 @@ int OBJECTMAP_Load(const byte *om_res, size_t om_res_len) { object_map->clickareas = (R_CLICKAREA *)malloc(object_map->n_clickareas * sizeof *(object_map->clickareas)); if (object_map->clickareas == NULL) { - R_printf(R_STDERR, "Error: Memory allocation failed.\n"); + warning("Error: Memory allocation failed"); return R_MEM; } @@ -126,7 +124,7 @@ int OBJECTMAP_Load(const byte *om_res, size_t om_res_len) { clickarea->points = (R_POINT *)malloc(clickarea->n_points * sizeof *(clickarea->points)); if (clickarea->points == NULL) { - R_printf(R_STDERR, "Error: Memory allocation failed.\n"); + warning("Error: Memory allocation failed"); return R_MEM; } @@ -136,10 +134,8 @@ int OBJECTMAP_Load(const byte *om_res, size_t om_res_len) { point->x = readS->readSint16LE(); point->y = readS->readSint16LE(); } -#if R_OBJECTMAP_DEBUG >= R_DEBUG_PARANOID - R_printf(R_STDOUT, "OBJECTMAP_Load(): Read %d points for clickarea %d in object %d.\n", + debug(2, "OBJECTMAP_Load(): Read %d points for clickarea %d in object %d.", clickarea->n_points, k, object_map->object_num); -#endif } } @@ -196,15 +192,11 @@ int OBJECTMAP_LoadNames(const unsigned char *onl_res, size_t onl_res_len) { n_names = table_len / 2 - 2; OMInfo.n_names = n_names; -#if 0 -#if R_OBJECTMAP_DEBUG >= R_DEBUG_INFO - R_printf(R_STDOUT, "OBJECTMAP_LoadNames: Loading %d object names.\n", n_names); -#endif -#endif + debug(2, "OBJECTMAP_LoadNames: Loading %d object names.", n_names); OMInfo.names = (const char **)malloc(n_names * sizeof *OMInfo.names); if (OMInfo.names == NULL) { - R_printf(R_STDERR, "Error: Memory allocation failed.\n"); + warning("Error: Memory allocation failed"); return R_MEM; } @@ -212,9 +204,7 @@ int OBJECTMAP_LoadNames(const unsigned char *onl_res, size_t onl_res_len) { name_offset = readS->readUint16LE(); OMInfo.names[i] = (const char *)(onl_res + name_offset); -#if R_OBJECTMAP_DEBUG >= R_DEBUG_VERBOSE - R_printf(R_STDOUT, "Loaded object name string: %s\n", OMInfo.names[i]); -#endif + debug(3, "Loaded object name string: %s", OMInfo.names[i]); } OMInfo.names_loaded = 1; diff --git a/saga/palanim.cpp b/saga/palanim.cpp index d0d3565952..6936e913c8 100644 --- a/saga/palanim.cpp +++ b/saga/palanim.cpp @@ -56,11 +56,11 @@ int PALANIM_Load(const byte *resdata, size_t resdata_len) { PAnimData.entry_count = readS->readUint16LE(); - R_printf(R_STDOUT, "PALANIM_Load(): Loading %d PALANIM entries.\n", PAnimData.entry_count); + debug(0, "PALANIM_Load(): Loading %d PALANIM entries.", PAnimData.entry_count); test_p = calloc(PAnimData.entry_count, sizeof(PALANIM_ENTRY)); if (test_p == NULL) { - R_printf(R_STDERR, "PALANIM_Load(): Allocation failure.\n"); + warning("PALANIM_Load(): Allocation failure"); return R_MEM; } @@ -77,25 +77,21 @@ int PALANIM_Load(const byte *resdata, size_t resdata_len) { PAnimData.entries[i].pal_count = pal_count; PAnimData.entries[i].color_count = color_count; -#if 0 - R_printf(R_STDOUT, "PALANIM_Load(): Entry %d: Loading %d palette indices.\n", i, pal_count); -#endif + debug(2, "PALANIM_Load(): Entry %d: Loading %d palette indices.\n", i, pal_count); test_p = calloc(1, sizeof(char) * pal_count); if (test_p == NULL) { - R_printf(R_STDERR, "PALANIM_Load(): Allocation failure.\n"); + warning("PALANIM_Load(): Allocation failure"); return R_MEM; } PAnimData.entries[i].pal_index = (byte *)test_p; -#if 0 - R_printf(R_STDOUT, "PALANIM_Load(): Entry %d: Loading %d SAGA_COLOR structures.\n", i, color_count); -#endif + debug(2, "PALANIM_Load(): Entry %d: Loading %d SAGA_COLOR structures.", i, color_count); test_p = calloc(1, sizeof(R_COLOR) * color_count); if (test_p == NULL) { - R_printf(R_STDERR, "PALANIM_Load(): Allocation failure.\n"); + warning("PALANIM_Load(): Allocation failure"); return R_MEM; } @@ -191,17 +187,13 @@ int PALANIM_Free() { } for (i = 0; i < PAnimData.entry_count; i++) { -#if 0 - R_printf(R_STDOUT, "PALANIM_Free(): Entry %d: Freeing colors.\n", i); -#endif + debug(2, "PALANIM_Free(): Entry %d: Freeing colors.", i); free(PAnimData.entries[i].colors); -#if 0 - R_printf(R_STDOUT, "PALANIM_Free(): Entry %d: Freeing indices.\n", i); -#endif + debug(2, "PALANIM_Free(): Entry %d: Freeing indices.", i); free(PAnimData.entries[i].pal_index); } - R_printf(R_STDOUT, "PALANIM_Free(): Freeing entries.\n"); + debug(0, "PALANIM_Free(): Freeing entries."); free(PAnimData.entries); diff --git a/saga/reinherit.h b/saga/reinherit.h index 4ebb09ce19..896286e21d 100644 --- a/saga/reinherit.h +++ b/saga/reinherit.h @@ -36,19 +36,8 @@ namespace Saga { #define R_MAXPATH 512 -// For debug message processing -#define R_DEBUG_NONE 0 -#define R_DEBUG_INFO 1 -#define R_DEBUG_VERBOSE 2 -#define R_DEBUG_PARANOID 3 - #define R_MEMFAIL_MSG "Memory allocation error." -#define R_STDOUT stdout -#define R_STDERR stderr - -#define R_printf fprintf - // Define opaque types // r_rscfile diff --git a/saga/saga.cpp b/saga/saga.cpp index c6f6abd79a..a850ece448 100644 --- a/saga/saga.cpp +++ b/saga/saga.cpp @@ -142,7 +142,7 @@ void SagaEngine::go() { // FIXME /* if (CFG_Read(NULL) != R_SUCCESS) { - R_printf(R_STDERR, "Couldn't read configuration file.\n"); + warning("Couldn't read configuration file"); } */ @@ -150,7 +150,7 @@ void SagaEngine::go() { // Detect game and open resource files if (GAME_Init() != R_SUCCESS) { - R_printf(R_STDERR, "Couldn't start the game: %s\n", GAME_GetErrS()); + warning("Couldn't start the game: %s", GAME_GetErrS()); return; } @@ -168,7 +168,7 @@ void SagaEngine::go() { ACTOR_Init(); if (SCENE_Init() != R_SUCCESS) { - R_printf(R_STDERR, "Couldn't initialize scene module.\n"); + warning("Couldn't initialize scene module"); return; } @@ -192,7 +192,7 @@ void SagaEngine::go() { _music->hasNativeMT32(ConfMan.getBool("native_mt32")); if (!MainData.music_enabled) { - R_printf(R_STDOUT, "Music disabled.\n"); + debug(0, "Music disabled."); } // Initialize graphics @@ -203,7 +203,7 @@ void SagaEngine::go() { // Initialize system specific sound _sound = new Sound(this, _mixer, MainData.sound_enabled); if (!MainData.sound_enabled) { - R_printf(R_STDOUT, "Sound disabled.\n"); + debug(0, "Sound disabled."); } SYSINPUT_Init(); diff --git a/saga/scene.cpp b/saga/scene.cpp index 9c4e39c9d5..8179df4fb7 100644 --- a/saga/scene.cpp +++ b/saga/scene.cpp @@ -71,7 +71,7 @@ int SCENE_Init() { // Load scene module resource context result = GAME_GetFileContext(&SceneModule.scene_ctxt, R_GAME_RESOURCEFILE, 0); if (result != R_SUCCESS) { - R_printf(R_STDERR, "Couldn't load scene resource context.\n"); + warning("Couldn't load scene resource context"); return R_FAILURE; } @@ -82,10 +82,10 @@ int SCENE_Init() { } // Load scene lookup table - R_printf(R_STDOUT, "SCENE_Init(): Loading scene LUT from resource %u.\n", gs_desc.scene_lut_rn); + debug(0, "SCENE_Init(): Loading scene LUT from resource %u.", gs_desc.scene_lut_rn); result = RSC_LoadResource(SceneModule.scene_ctxt, gs_desc.scene_lut_rn, &scene_lut_p, &scene_lut_len); if (result != R_SUCCESS) { - R_printf(R_STDERR, "Error: couldn't load scene LUT.\n"); + warning("Error: couldn't load scene LUT"); return R_FAILURE; } @@ -93,7 +93,7 @@ int SCENE_Init() { SceneModule.scene_max = SceneModule.scene_count - 1; SceneModule.scene_lut = (int *)malloc(SceneModule.scene_max * sizeof *SceneModule.scene_lut); if (SceneModule.scene_lut == NULL) { - R_printf(R_STDERR, "SCENE_Init(): Memory allocation failed.\n"); + warning("SCENE_Init(): Memory allocation failed"); return R_MEM; } @@ -109,16 +109,15 @@ int SCENE_Init() { SceneModule.first_scene = gs_desc.first_scene; } - R_printf(R_STDOUT, - "SCENE_Init(): First scene set to %d.\n", SceneModule.first_scene); + debug(0, "SCENE_Init(): First scene set to %d.", SceneModule.first_scene); - R_printf(R_STDOUT, "SCENE_Init(): LUT has %d entries.\n", SceneModule.scene_max); + debug(0, "SCENE_Init(): LUT has %d entries.", SceneModule.scene_max); // Create scene module text list SceneModule.text_list = TEXT_CreateList(); if (SceneModule.text_list == NULL) { - R_printf(R_STDERR, "Error: Couldn't create scene text list.\n"); + warning("Error: Couldn't create scene text list"); return R_FAILURE; } @@ -160,12 +159,12 @@ int SCENE_Start() { assert(SceneModule.init); if (SceneModule.scene_loaded) { - R_printf(R_STDERR, "Error: Can't start game...scene already loaded!\n"); + warning("Error: Can't start game...scene already loaded"); return R_FAILURE; } if (SceneModule.in_game) { - R_printf(R_STDERR, "Error: Can't start game...game already started!\n"); + warning("Error: Can't start game...game already started"); return R_FAILURE; } @@ -177,7 +176,7 @@ int SCENE_Start() { IHNM_StartProc(); break; default: - R_printf(R_STDERR, "Error: Can't start game... gametype not supported.\n"); + warning("Error: Can't start game... gametype not supported"); break; } @@ -202,12 +201,12 @@ int SCENE_Next() { assert(SceneModule.init); if (!SceneModule.scene_loaded) { - R_printf(R_STDERR, "Error: Can't advance scene...no scene loaded!\n"); + warning("Error: Can't advance scene...no scene loaded"); return R_FAILURE; } if (SceneModule.in_game) { - R_printf(R_STDERR, "Error: Can't advance scene...game already started!\n"); + warning("Error: Can't advance scene...game already started"); return R_FAILURE; } @@ -246,19 +245,19 @@ int SCENE_Skip() { assert(SceneModule.init); if (!SceneModule.scene_loaded) { - R_printf(R_STDERR, "Error: Can't skip scene...no scene loaded.\n"); + warning("Error: Can't skip scene...no scene loaded"); return R_FAILURE; } if (SceneModule.in_game) { - R_printf(R_STDERR, "Error: Can't skip scene...game already started.\n"); + warning("Error: Can't skip scene...game already started"); return R_FAILURE; } // Walk down scene queue and try to find a skip target node = ys_dll_head(SceneModule.scene_queue); if (node == NULL) { - R_printf(R_STDERR, "Error: Can't skip scene...no scenes in queue.\n"); + warning("Error: Can't skip scene...no scenes in queue"); return R_FAILURE; } @@ -291,17 +290,17 @@ int SCENE_Change(int scene_num) { assert(SceneModule.init); if (!SceneModule.scene_loaded) { - R_printf(R_STDERR, "Error: Can't change scene. No scene currently loaded. Game in invalid state.\n"); + warning("Error: Can't change scene. No scene currently loaded. Game in invalid state"); return R_FAILURE; } if ((scene_num < 0) || (scene_num > SceneModule.scene_max)) { - R_printf(R_STDERR, "Error: Can't change scene. Invalid scene number.\n"); + warning("Error: Can't change scene. Invalid scene number"); return R_FAILURE; } if (SceneModule.scene_lut[scene_num] == 0) { - R_printf(R_STDERR, "Error: Can't change scene; invalid scene descriptor resource number (0)\n"); + warning("Error: Can't change scene; invalid scene descriptor resource number (0)"); return R_FAILURE; } @@ -402,7 +401,7 @@ int SCENE_Load(int scene_num, int load_flag, R_SCENE_PROC scene_proc, R_SCENE_DE assert(SceneModule.init); if (SceneModule.scene_loaded == 1) { - R_printf(R_STDERR, "Error, a scene is already loaded.\n"); + warning("Error, a scene is already loaded"); return R_FAILURE; } @@ -428,7 +427,7 @@ int SCENE_Load(int scene_num, int load_flag, R_SCENE_PROC scene_proc, R_SCENE_DE SceneModule.reslist_entries = scene_desc_param->res_list_ct; break; default: - R_printf(R_STDERR, "Error: Invalid scene load flag.\n"); + warning("Error: Invalid scene load flag"); return R_FAILURE; break; } @@ -438,19 +437,19 @@ int SCENE_Load(int scene_num, int load_flag, R_SCENE_PROC scene_proc, R_SCENE_DE SceneModule.scene_rn = res_number; assert(SceneModule.scene_rn != 0); - R_printf(R_STDOUT, "Loading scene resource %u:\n", res_number); + debug(0, "Loading scene resource %u:", res_number); if (LoadSceneDescriptor(res_number) != R_SUCCESS) { - R_printf(R_STDERR, "Error reading scene descriptor.\n"); + warning("Error reading scene descriptor"); return R_FAILURE; } if (LoadSceneResourceList(SceneModule.desc.res_list_rn) != R_SUCCESS) { - R_printf(R_STDERR, "Error reading scene resource list.\n"); + warning("Error reading scene resource list"); return R_FAILURE; } } else { - R_printf(R_STDOUT, "Loading memory scene resource.\n"); + debug(0, "Loading memory scene resource."); } // Load resources from scene resource list @@ -458,21 +457,21 @@ int SCENE_Load(int scene_num, int load_flag, R_SCENE_PROC scene_proc, R_SCENE_DE result = RSC_LoadResource(SceneModule.scene_ctxt, SceneModule.reslist[i].res_number, &SceneModule.reslist[i].res_data, &SceneModule.reslist[i].res_data_len); if (result != R_SUCCESS) { - R_printf(R_STDERR, "Error: Allocation failure loading scene resource list.\n"); + warning("Error: Allocation failure loading scene resource list"); return R_FAILURE; } } // Process resources from scene resource list if (ProcessSceneResources() != R_SUCCESS) { - R_printf(R_STDERR, "Error loading scene resources.\n"); + warning("Error loading scene resources"); return R_FAILURE; } // Load scene script data if (SceneModule.desc.script_num > 0) { if (SCRIPT_Load(SceneModule.desc.script_num) != R_SUCCESS) { - R_printf(R_STDERR, "Error loading scene script.\n"); + warning("Error loading scene script"); return R_FAILURE; } } @@ -499,12 +498,12 @@ int LoadSceneDescriptor(uint32 res_number) { result = RSC_LoadResource(SceneModule.scene_ctxt, res_number, &scene_desc_data, &scene_desc_len); if (result != R_SUCCESS) { - R_printf(R_STDERR, "Error: couldn't load scene descriptor.\n"); + warning("Error: couldn't load scene descriptor"); return R_FAILURE; } if (scene_desc_len != SAGA_SCENE_DESC_LEN) { - R_printf(R_STDERR, "Error: scene descriptor length invalid.\n"); + warning("Error: scene descriptor length invalid"); return R_FAILURE; } @@ -533,7 +532,7 @@ int LoadSceneResourceList(uint32 reslist_rn) { // Load the scene resource table result = RSC_LoadResource(SceneModule.scene_ctxt, reslist_rn, &resource_list, &resource_list_len); if (result != R_SUCCESS) { - R_printf(R_STDERR, "Error: couldn't load scene resource list.\n"); + warning("Error: couldn't load scene resource list"); return R_FAILURE; } @@ -541,17 +540,17 @@ int LoadSceneResourceList(uint32 reslist_rn) { // Allocate memory for scene resource list SceneModule.reslist_entries = resource_list_len / SAGA_RESLIST_ENTRY_LEN; - R_printf(R_STDOUT, "Scene resource list contains %d entries.\n", SceneModule.reslist_entries); + debug(0, "Scene resource list contains %d entries.", SceneModule.reslist_entries); SceneModule.reslist = (R_SCENE_RESLIST *)calloc(SceneModule.reslist_entries, sizeof *SceneModule.reslist); if (SceneModule.reslist == NULL) { - R_printf(R_STDERR, "Error: Memory allocation failed.\n"); + warning("Error: Memory allocation failed"); return R_MEM; } // Load scene resource list from raw scene // resource table - R_printf(R_STDOUT, "Loading scene resource list...\n"); + debug(0, "Loading scene resource list..."); for (i = 0; i < SceneModule.reslist_entries; i++) { SceneModule.reslist[i].res_number = readS->readUint16LE(); @@ -576,11 +575,11 @@ int ProcessSceneResources() { switch (SceneModule.reslist[i].res_type) { case SAGA_BG_IMAGE: // Scene background resource if (SceneModule.bg.loaded) { - R_printf(R_STDERR, "Error: Multiple background resources encountered.\n"); + warning("Error: Multiple background resources encountered"); return R_FAILURE; } - R_printf(R_STDOUT, "Loading background resource.\n"); + debug(0, "Loading background resource."); SceneModule.bg.res_buf = SceneModule.reslist[i].res_data; SceneModule.bg.res_len = SceneModule.reslist[i].res_data_len; SceneModule.bg.loaded = 1; @@ -591,7 +590,7 @@ int ProcessSceneResources() { &SceneModule.bg.buf_len, &SceneModule.bg.w, &SceneModule.bg.h) != R_SUCCESS) { - R_printf(R_STDERR, "Error loading background resource: %u\n", SceneModule.reslist[i].res_number); + warning("Error loading background resource: %u", SceneModule.reslist[i].res_number); return R_FAILURE; } @@ -601,9 +600,9 @@ int ProcessSceneResources() { break; case SAGA_BG_MASK: // Scene background mask resource if (SceneModule.bg_mask.loaded) { - R_printf(R_STDERR, "Error: Duplicate background mask resource encountered.\n"); + warning("Error: Duplicate background mask resource encountered"); } - R_printf(R_STDOUT, "Loading BACKGROUND MASK resource.\n"); + debug(0, "Loading BACKGROUND MASK resource."); SceneModule.bg_mask.res_buf = SceneModule.reslist[i].res_data; SceneModule.bg_mask.res_len = SceneModule.reslist[i].res_data_len; SceneModule.bg_mask.loaded = 1; @@ -611,34 +610,34 @@ int ProcessSceneResources() { &SceneModule.bg_mask.buf_len, &SceneModule.bg_mask.w, &SceneModule.bg_mask.h); break; case SAGA_OBJECT_NAME_LIST: - R_printf(R_STDOUT, "Loading object name list resource...\n"); + debug(0, "Loading object name list resource..."); OBJECTMAP_LoadNames(SceneModule.reslist[i].res_data, SceneModule.reslist[i].res_data_len); break; case SAGA_OBJECT_MAP: - R_printf(R_STDOUT, "Loading object map resource...\n"); + debug(0, "Loading object map resource..."); if (OBJECTMAP_Load(res_data, res_data_len) != R_SUCCESS) { - R_printf(R_STDERR, "Error loading object map resource.\n"); + warning("Error loading object map resource"); return R_FAILURE; } break; case SAGA_ACTION_MAP: - R_printf(R_STDOUT, "Loading exit map resource...\n"); + debug(0, "Loading exit map resource..."); if (ACTIONMAP_Load(res_data, res_data_len) != R_SUCCESS) { - R_printf(R_STDERR, "Error loading exit map resource.\n"); + warning("Error loading exit map resource"); return R_FAILURE; } break; case SAGA_ISO_TILESET: if (SceneModule.scene_mode == R_SCENE_MODE_NORMAL) { - R_printf(R_STDERR, "Isometric tileset incompatible with normal scene mode.\n"); + warning("Isometric tileset incompatible with normal scene mode"); return R_FAILURE; } - R_printf(R_STDOUT, "Loading isometric tileset resource.\n"); + debug(0, "Loading isometric tileset resource."); if (ISOMAP_LoadTileset(res_data, res_data_len) != R_SUCCESS) { - R_printf(R_STDERR, "Error loading isometric tileset resource.\n"); + warning("Error loading isometric tileset resource"); return R_FAILURE; } @@ -646,14 +645,14 @@ int ProcessSceneResources() { break; case SAGA_ISO_METAMAP: if (SceneModule.scene_mode == R_SCENE_MODE_NORMAL) { - R_printf(R_STDERR, "Isometric metamap incompatible with normal scene mode.\n"); + warning("Isometric metamap incompatible with normal scene mode"); return R_FAILURE; } - R_printf(R_STDOUT, "Loading isometric metamap resource.\n"); + debug(0, "Loading isometric metamap resource."); if (ISOMAP_LoadMetamap(res_data, res_data_len) != R_SUCCESS) { - R_printf(R_STDERR, "Error loading isometric metamap resource.\n"); + warning("Error loading isometric metamap resource"); return R_FAILURE; } @@ -661,14 +660,14 @@ int ProcessSceneResources() { break; case SAGA_ISO_METATILESET: if (SceneModule.scene_mode == R_SCENE_MODE_NORMAL) { - R_printf(R_STDERR, "Isometric metatileset incompatible with normal scene mode.\n"); + warning("Isometric metatileset incompatible with normal scene mode"); return R_FAILURE; } - R_printf(R_STDOUT, "Loading isometric metatileset resource.\n"); + debug(0, "Loading isometric metatileset resource."); if (ISOMAP_LoadMetaTileset(res_data, res_data_len) != R_SUCCESS) { - R_printf(R_STDERR, "Error loading isometric tileset resource.\n"); + warning("Error loading isometric tileset resource"); return R_FAILURE; } @@ -685,11 +684,11 @@ int ProcessSceneResources() { SCENE_ANIMINFO *new_animinfo; uint16 new_anim_id; - R_printf(R_STDOUT, "Loading animation resource...\n"); + debug(0, "Loading animation resource..."); new_animinfo = (SCENE_ANIMINFO *)malloc(sizeof *new_animinfo); if (new_animinfo == NULL) { - R_printf(R_STDERR, "Memory allocation error.\n"); + warning("Memory allocation error"); return R_MEM; } @@ -697,7 +696,7 @@ int ProcessSceneResources() { SceneModule.reslist[i].res_data_len, &new_anim_id) == R_SUCCESS) { } else { - R_printf(R_STDERR, "Error loading animation resource\n"); + warning("Error loading animation resource"); return R_FAILURE; } @@ -708,11 +707,11 @@ int ProcessSceneResources() { } break; case SAGA_PAL_ANIM: - R_printf(R_STDOUT, "Loading palette animation resource.\n"); + debug(0, "Loading palette animation resource."); PALANIM_Load(SceneModule.reslist[i].res_data, SceneModule.reslist[i].res_data_len); break; default: - R_printf(R_STDERR, "Encountered unknown resource type: %d\n", SceneModule.reslist[i].res_type); + warning("Encountered unknown resource type: %d", SceneModule.reslist[i].res_type); break; } } @@ -757,11 +756,11 @@ int SCENE_End() { assert(SceneModule.init); if (SceneModule.scene_loaded != 1) { - R_printf(R_STDERR, "SCENE_End(): No scene to end.\n"); + warning("SCENE_End(): No scene to end"); return -1; } - R_printf(R_STDOUT, "SCENE_End(): Ending scene...\n"); + debug(0, "SCENE_End(): Ending scene..."); SCENE_GetInfo(&scene_info); diff --git a/saga/sceneproc.cpp b/saga/sceneproc.cpp index fb0dae1243..37f96c29a3 100644 --- a/saga/sceneproc.cpp +++ b/saga/sceneproc.cpp @@ -109,7 +109,7 @@ int InitialSceneProc(int param, R_SCENE_INFO *scene_info) { case SCENE_END: break; default: - R_printf(R_STDERR, "Illegal scene procedure parameter.\n"); + warning("Illegal scene procedure parameter"); break; } @@ -151,7 +151,7 @@ int DefaultSceneProc(int param, R_SCENE_INFO *scene_info) { case SCENE_END: break; default: - R_printf(R_STDERR, "Illegal scene procedure parameter.\n"); + warning("Illegal scene procedure parameter"); break; } diff --git a/saga/script.cpp b/saga/script.cpp index 21f7677e93..925addc3be 100644 --- a/saga/script.cpp +++ b/saga/script.cpp @@ -60,24 +60,24 @@ int SCRIPT_Init() { int result; int i, j; - R_printf(R_STDOUT, "Initializing scripting subsystem.\n"); + debug(0, "Initializing scripting subsystem."); // Load script resource file context result = GAME_GetFileContext(&ScriptModule.script_ctxt, R_GAME_SCRIPTFILE, 0); if (result != R_SUCCESS) { - R_printf(R_STDERR, "Couldn't get script file context.\n"); + warning("Couldn't get script file context"); return R_FAILURE; } // Load script LUT resource result = GAME_GetFileContext(&s_lut_ctxt, R_GAME_RESOURCEFILE, 0); if (result != R_SUCCESS) { - R_printf(R_STDERR, "Couldn't get resource file context.\n"); + warning("Couldn't get resource file context"); return R_FAILURE; } result = RSC_LoadResource(s_lut_ctxt, ITE_SCRIPT_LUT, &rsc_ptr, &rsc_len); if (result != R_SUCCESS) { - R_printf(R_STDERR, "Error: Couldn't load script resource look-up table.\n"); + warning("Error: Couldn't load script resource look-up table"); return R_FAILURE; } @@ -87,7 +87,7 @@ int SCRIPT_Init() { } else if (rsc_len % R_S_LUT_ENTRYLEN_ITEDISK == 0) { ScriptModule.script_lut_entrylen = R_S_LUT_ENTRYLEN_ITEDISK; } else { - R_printf(R_STDERR, "Error: Invalid script lookup table length.\n"); + warning("Error: Invalid script lookup table length"); return R_FAILURE; } @@ -97,7 +97,7 @@ int SCRIPT_Init() { // Allocate space for logical LUT ScriptModule.script_lut = (R_SCRIPT_LUT_ENTRY *)malloc(ScriptModule.script_lut_max * sizeof(R_SCRIPT_LUT_ENTRY)); if (ScriptModule.script_lut == NULL) { - R_printf(R_STDERR, "Error: Couldn't allocate memory for script resource look-up table.\n"); + warning("Error: Couldn't allocate memory for script resource look-up table"); return R_MEM; } @@ -144,7 +144,7 @@ int SCRIPT_Shutdown() { return R_FAILURE; } - R_printf(R_STDOUT, "Shutting down scripting subsystem.\n"); + debug(0, "Shutting down scripting subsystem."); // Free script lookup table free(ScriptModule.script_lut); @@ -182,7 +182,7 @@ int SCRIPT_Load(int script_num) { // Validate script number if ((script_num < 0) || (script_num > ScriptModule.script_lut_max)) { - R_printf(R_STDERR, "SCRIPT_Load(): Invalid script number!\n"); + warning("SCRIPT_Load(): Invalid script number"); return R_FAILURE; } @@ -190,11 +190,11 @@ int SCRIPT_Load(int script_num) { SCRIPT_Free(); // Initialize script data structure - R_printf(R_STDOUT, "Loading script data for script #%d.\n", script_num); + debug(0, "Loading script data for script #%d", script_num); script_data = (R_SCRIPTDATA *)malloc(sizeof *script_data); if (script_data == NULL) { - R_printf(R_STDERR, "Memory allocation failed.\n"); + warning("Memory allocation failed"); return R_MEM; } @@ -210,7 +210,7 @@ int SCRIPT_Load(int script_num) { result = RSC_LoadResource(ScriptModule.script_ctxt, scriptl_rn, &bytecode_p, &bytecode_len); if (result != R_SUCCESS) { - R_printf(R_STDERR, "Error loading script bytecode resource.\n"); + warning("Error loading script bytecode resource"); free(script_data); return R_FAILURE; } @@ -218,7 +218,7 @@ int SCRIPT_Load(int script_num) { script_data->bytecode = SCRIPT_LoadBytecode(bytecode_p, bytecode_len); if (script_data->bytecode == NULL) { - R_printf(R_STDERR, "Error interpreting script bytecode resource.\n"); + warning("Error interpreting script bytecode resource"); free(script_data); RSC_FreeResource(bytecode_p); return R_FAILURE; @@ -230,7 +230,7 @@ int SCRIPT_Load(int script_num) { // Load dialogue list resource result = RSC_LoadResource(ScriptModule.script_ctxt, diagl_rn, &diagl_p, &diagl_len); if (result != R_SUCCESS) { - R_printf(R_STDERR, "Error loading dialogue list resource.\n"); + warning("Error loading dialogue list resource"); free(script_data); RSC_FreeResource(bytecode_p); return R_FAILURE; @@ -239,7 +239,7 @@ int SCRIPT_Load(int script_num) { // Convert dialogue list resource to logical dialogue list script_data->diag = SCRIPT_LoadDialogue(diagl_p, diagl_len); if (script_data->diag == NULL) { - R_printf(R_STDERR, "Error interpreting dialogue list resource.\n"); + warning("Error interpreting dialogue list resource"); free(script_data); RSC_FreeResource(bytecode_p); RSC_FreeResource(diagl_p); @@ -253,7 +253,7 @@ int SCRIPT_Load(int script_num) { // Load voice LUT resource result = RSC_LoadResource(ScriptModule.script_ctxt, voicelut_rn, &voicelut_p, &voicelut_len); if (result != R_SUCCESS) { - R_printf(R_STDERR, "Error loading voice LUT resource.\n"); + warning("Error loading voice LUT resource"); free(script_data); RSC_FreeResource(bytecode_p); RSC_FreeResource(diagl_p); @@ -263,7 +263,7 @@ int SCRIPT_Load(int script_num) { // Convert voice LUT resource to logical voice LUT script_data->voice = SCRIPT_LoadVoiceLUT(voicelut_p, voicelut_len, script_data); if (script_data->voice == NULL) { - R_printf(R_STDERR, "Error interpreting voice LUT resource.\n"); + warning("Error interpreting voice LUT resource"); free(script_data); RSC_FreeResource(bytecode_p); RSC_FreeResource(diagl_p); @@ -289,7 +289,7 @@ int SCRIPT_Free() { return R_FAILURE; } - R_printf(R_STDOUT, "Releasing script data.\n"); + debug(0, "Releasing script data."); // Finish initialization if (ScriptModule.current_script->diag != NULL) { @@ -327,7 +327,7 @@ R_SCRIPT_BYTECODE *SCRIPT_LoadBytecode(byte *bytecode_p, size_t bytecode_len) { size_t ep_tbl_offset; // Offset of bytecode entrypoint table unsigned long i; - R_printf(R_STDOUT, "Loading script bytecode...\n"); + debug(0, "Loading script bytecode..."); MemoryReadStream *readS = new MemoryReadStream(bytecode_p, bytecode_len); @@ -338,12 +338,12 @@ R_SCRIPT_BYTECODE *SCRIPT_LoadBytecode(byte *bytecode_p, size_t bytecode_len) { // Check that the entrypoint table offset is valid. if ((bytecode_len - ep_tbl_offset) < (n_entrypoints * R_SCRIPT_TBLENTRY_LEN)) { - R_printf(R_STDERR, "Invalid table offset.\n"); + warning("Invalid table offset"); return NULL; } if (n_entrypoints > R_SCRIPT_MAX) { - R_printf(R_STDERR, "Script limit exceeded.\n"); + warning("Script limit exceeded"); return NULL; } @@ -352,13 +352,13 @@ R_SCRIPT_BYTECODE *SCRIPT_LoadBytecode(byte *bytecode_p, size_t bytecode_len) { bc_new_data = (R_SCRIPT_BYTECODE *)malloc(sizeof *bc_new_data); if (bc_new_data == NULL) { - R_printf(R_STDERR, "Memory allocation failure loading script bytecode.\n"); + warning("Memory allocation failure loading script bytecode"); return NULL; } bc_ep_tbl = (R_PROC_TBLENTRY *)malloc(n_entrypoints * sizeof *bc_ep_tbl); if (bc_ep_tbl == NULL) { - R_printf(R_STDERR, "Memory allocation failure creating script entrypoint table.\n"); + warning("Memory allocation failure creating script entrypoint table"); free(bc_new_data); return NULL; } @@ -377,7 +377,7 @@ R_SCRIPT_BYTECODE *SCRIPT_LoadBytecode(byte *bytecode_p, size_t bytecode_len) { // Perform a simple range check on offset values if ((bc_ep_tbl[i].name_offset > bytecode_len) || (bc_ep_tbl[i].offset > bytecode_len)) { - R_printf(R_STDERR, "Invalid offset encountered in script entrypoint table.\n"); + warning("Invalid offset encountered in script entrypoint table"); free(bc_new_data); free(bc_ep_tbl); return NULL; @@ -402,7 +402,7 @@ R_DIALOGUE_LIST *SCRIPT_LoadDialogue(const byte *dialogue_p, size_t dialogue_len uint16 i; size_t offset; - R_printf(R_STDOUT, "Loading dialogue list...\n"); + debug(0, "Loading dialogue list..."); // Allocate dialogue list structure dialogue_list = (R_DIALOGUE_LIST *)malloc(sizeof *dialogue_list); @@ -415,7 +415,7 @@ R_DIALOGUE_LIST *SCRIPT_LoadDialogue(const byte *dialogue_p, size_t dialogue_len // First uint16 is the offset of the first string offset = readS->readUint16LE(); if (offset > dialogue_len) { - R_printf(R_STDERR, "Error, invalid string offset.\n"); + warning("Error, invalid string offset"); return NULL; } @@ -443,7 +443,7 @@ R_DIALOGUE_LIST *SCRIPT_LoadDialogue(const byte *dialogue_p, size_t dialogue_len for (i = 0; i < n_dialogue; i++) { offset = readS->readUint16LE(); if (offset > dialogue_len) { - R_printf(R_STDERR, "Error, invalid string offset.\n"); + warning("Error, invalid string offset"); free(dialogue_list->str); free(dialogue_list->str_off); free(dialogue_list); @@ -471,7 +471,7 @@ R_VOICE_LUT *SCRIPT_LoadVoiceLUT(const byte *voicelut_p, size_t voicelut_len, R_ n_voices = voicelut_len / 2; if (n_voices != script->diag->n_dialogue) { - R_printf(R_STDERR, "Error: Voice LUT entries do not match dialogue entries.\n"); + warning("Error: Voice LUT entries do not match dialogue entries"); return NULL; } diff --git a/saga/sdata.cpp b/saga/sdata.cpp index 542a7c8169..40151cf166 100644 --- a/saga/sdata.cpp +++ b/saga/sdata.cpp @@ -38,11 +38,11 @@ int SDATA_Init() { unsigned int i; void *alloc_ptr; - R_printf(R_STDOUT, "Initializing script data buffers.\n"); + debug(0, "Initializing script data buffers."); for (i = 0; i < R_SCRIPT_DATABUF_NUM; i++) { alloc_ptr = malloc(sizeof *ScriptModule.data_buf[0]); if (alloc_ptr == NULL) { - R_printf(R_STDERR, "Error allocating memory for script data buffer %d.\n", i); + warning("Error allocating memory for script data buffer %d", i); return R_MEM; } @@ -50,7 +50,7 @@ int SDATA_Init() { alloc_ptr = calloc(R_SCRIPT_DATABUF_LEN, sizeof(SDataWord_T)); if (alloc_ptr == NULL) { - R_printf(R_STDERR, "Error allocating memory for script data buffer %d.\n", i); + warning("Error allocating memory for script data buffer %d", i); return R_MEM; } diff --git a/saga/sprite.cpp b/saga/sprite.cpp index 5ab962e285..be31d6e0e4 100644 --- a/saga/sprite.cpp +++ b/saga/sprite.cpp @@ -47,7 +47,7 @@ int SPRITE_Init() { return R_FAILURE; } - R_printf(R_STDOUT, "Initializing sprite subsystem...\n"); + debug(0, "Initializing sprite subsystem..."); // Load sprite module resource context result = GAME_GetFileContext(&SpriteModule.sprite_ctxt, R_GAME_RESOURCEFILE, 0); @@ -72,7 +72,7 @@ int SPRITE_Shutdown() { return R_FAILURE; } - R_printf(R_STDOUT, "Shutting down sprite subsystem...\n"); + debug(0, "Shutting down sprite subsystem..."); free(SpriteModule.decode_buf); @@ -305,7 +305,7 @@ int SPRITE_DrawOccluded(R_SURFACE *ds, R_SPRITELIST *sprite_list, int sprite_num } if (sprite_num >= sprite_list->sprite_count) { - R_printf(R_STDOUT, "Invalid sprite number (%d) for sprite list %d.\n", sprite_num, sprite_list->slist_rn); + warning("Invalid sprite number (%d) for sprite list %d", sprite_num, sprite_list->slist_rn); return R_FAILURE; } diff --git a/saga/sthread.cpp b/saga/sthread.cpp index 61869d65a4..9a09dc3ca5 100644 --- a/saga/sthread.cpp +++ b/saga/sthread.cpp @@ -220,9 +220,7 @@ int STHREAD_Run(R_SCRIPT_THREAD *thread, int instr_limit, int msec) { } saved_offset = thread->i_offset; -#if 0 - R_printf(R_STDOUT, "Executing thread offset: %lu", thread->i_offset); -#endif + debug(2, "Executing thread offset: %lu", thread->i_offset); MemoryReadStream *readS = new MemoryReadStream(GetReadPtr(thread), GetReadLen(thread)); in_char = readS->readByte(); |