From: Holger Schemel Date: Wed, 16 Sep 2020 21:28:23 +0000 (+0200) Subject: changed simple "printf()" debug output to new debug log function X-Git-Tag: 4.2.0.3~32 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=343ecd1bed93fa862903ff981ede342825f14401;p=rocksndiamonds.git changed simple "printf()" debug output to new debug log function --- diff --git a/src/anim.c b/src/anim.c index dec9d18e..01434554 100644 --- a/src/anim.c +++ b/src/anim.c @@ -494,13 +494,15 @@ static void InitGlobalAnimControls(void) continue; #if 0 - printf("::: mode == %d, anim = %d, part = %d [%d, %d, %d] [%d]\n", - m, a, p, mode_nr, anim_nr, part_nr, control); + Debug("anim:InitGlobalAnimControls", + "mode == %d, anim = %d, part = %d [%d, %d, %d] [%d]", + m, a, p, mode_nr, anim_nr, part_nr, control); #endif #if 0 - printf("::: mode == %d, anim = %d, part = %d [%d, %d, %d] [%d]\n", - m, a, p, mode_nr, anim_nr, part_nr, sound); + Debug("anim:InitGlobalAnimControls", + "mode == %d, anim = %d, part = %d [%d, %d, %d] [%d]", + m, a, p, mode_nr, anim_nr, part_nr, sound); #endif part->old_nr = p; @@ -981,7 +983,7 @@ static void PlayGlobalAnimSound(struct GlobalAnimPartControlInfo *part) PlaySound(sound); #if 0 - printf("::: PLAY SOUND %d.%d.%d: %d\n", + Debug("anim:PlayGlobalAnimSound", "PLAY SOUND %d.%d.%d: %d", part->anim_nr, part->nr, part->mode_nr, sound); #endif } @@ -996,8 +998,8 @@ static void StopGlobalAnimSound(struct GlobalAnimPartControlInfo *part) StopSound(sound); #if 0 - printf("::: STOP SOUND %d.%d.%d: %d\n", - part->anim_nr, part->nr, part->mode_nr, sound); + Debug("anim:StopGlobalAnimSound", "STOP SOUND %d.%d.%d: %d", + part->anim_nr, part->nr, part->mode_nr, sound); #endif } @@ -1017,8 +1019,8 @@ static void PlayGlobalAnimMusic(struct GlobalAnimPartControlInfo *part) PlayMusic(music); #if 0 - printf("::: PLAY MUSIC %d.%d.%d: %d\n", - part->anim_nr, part->nr, part->mode_nr, music); + Debug("anim:PlayGlobalAnimMusic", "PLAY MUSIC %d.%d.%d: %d", + part->anim_nr, part->nr, part->mode_nr, music); #endif } @@ -1032,8 +1034,8 @@ static void StopGlobalAnimMusic(struct GlobalAnimPartControlInfo *part) StopMusic(); #if 0 - printf("::: STOP MUSIC %d.%d.%d: %d\n", - part->anim_nr, part->nr, part->mode_nr, music); + Debug("anim:StopGlobalAnimMusic", "STOP MUSIC %d.%d.%d: %d", + part->anim_nr, part->nr, part->mode_nr, music); #endif } @@ -1190,13 +1192,15 @@ static void InitGlobalAnim_Triggered(struct GlobalAnimPartControlInfo *part, *click_consumed |= clickConsumed(part); // click was on "part"! #if DEBUG_ANIM_EVENTS - printf("::: => %d.%d TRIGGERED BY %s OF %d.%d\n", - part2->old_anim_nr + 1, part2->old_nr + 1, info_text, - part->old_anim_nr + 1, part->old_nr + 1); + Debug("anim:InitGlobalAnim_Triggered", + "%d.%d TRIGGERED BY %s OF %d.%d", + part2->old_anim_nr + 1, part2->old_nr + 1, info_text, + part->old_anim_nr + 1, part->old_nr + 1); #endif #if 0 - printf("::: %d.%d TRIGGER CLICKED [%d]\n", anim2_nr, part2_nr, - part2->control_info.anim_event_action); + Debug("anim:InitGlobalAnim_Triggered", + "%d.%d TRIGGER CLICKED [%d]", anim2_nr, part2_nr, + part2->control_info.anim_event_action); #endif // after executing event action, ignore any further actions @@ -1207,14 +1211,15 @@ static void InitGlobalAnim_Triggered(struct GlobalAnimPartControlInfo *part, #if 0 struct GraphicInfo *c = &part2->control_info; - printf("::: - %d.%d: 0x%08x, 0x%08x [0x%08x]", - anim2_nr, part2_nr, c->init_event, c->anim_event, mask); - if (isClickablePart(part2, mask)) - printf(" <--- TRIGGERED BY %d.%d", - anim_nr, part_nr); - - printf("\n"); + Debug("anim:InitGlobalAnim_Triggered", + "%d.%d: 0x%08x, 0x%08x [0x%08x] <--- TRIGGERED BY %d.%d", + anim2_nr, part2_nr, c->init_event, c->anim_event, mask, + anim_nr, part_nr); + else + Debug("anim:InitGlobalAnim_Triggered", + "%d.%d: 0x%08x, 0x%08x [0x%08x]", + anim2_nr, part2_nr, c->init_event, c->anim_event, mask); #endif } } @@ -1224,7 +1229,8 @@ static void HandleGlobalAnimDelay(struct GlobalAnimPartControlInfo *part, int delay_type, char *info_text) { #if DEBUG_ANIM_DELAY - printf("::: %d.%d %s\n", part->old_anim_nr + 1, part->old_nr + 1, info_text); + Debug("anim:HandleGlobalAnimDelay", "%d.%d %s", + part->old_anim_nr + 1, part->old_nr + 1, info_text); #endif DoGlobalAnim_DelayAction(part, delay_type); @@ -1234,7 +1240,8 @@ static void HandleGlobalAnimEvent(struct GlobalAnimPartControlInfo *part, int event_value, char *info_text) { #if DEBUG_ANIM_EVENTS - printf("::: %d.%d %s\n", part->old_anim_nr + 1, part->old_nr + 1, info_text); + Debug("anim:HandleGlobalAnimEvent", "%d.%d %s", + part->old_anim_nr + 1, part->old_nr + 1, info_text); #endif boolean click_consumed = FALSE; @@ -1508,8 +1515,8 @@ static int HandleGlobalAnim_Part(struct GlobalAnimPartControlInfo *part, static unsigned int last_counter = -1; unsigned int counter = Counter(); - printf("::: NEXT ANIM PART [%d, %d]\n", - anim_sync_frame, counter - last_counter); + Debug("anim:HandleGlobalAnim_Part", "NEXT ANIM PART [%d, %d]", + anim_sync_frame, counter - last_counter); last_counter = counter; } @@ -1534,21 +1541,22 @@ static void HandleGlobalAnim_Main(struct GlobalAnimMainControlInfo *anim, int i; #if 0 - printf("::: HandleGlobalAnim_Main: %d, %d => %d\n", + Debug("anim:HandleGlobalAnim_Main", "%d, %d => %d", anim->mode_nr, anim->nr, anim->num_parts); - printf("::: %d, %d, %d\n", global.num_toons, setup.toons, num_toons); + Debug("anim:HandleGlobalAnim_Main", + "%d, %d, %d", global.num_toons, setup.toons, num_toons); #endif #if 0 - printf("::: %s(%d): %d, %d, %d [%d]\n", - (action == ANIM_START ? "ANIM_START" : - action == ANIM_CONTINUE ? "ANIM_CONTINUE" : - action == ANIM_STOP ? "ANIM_STOP" : "(should not happen)"), - anim->nr, - anim->state & ANIM_STATE_RESTART, - anim->state & ANIM_STATE_WAITING, - anim->state & ANIM_STATE_RUNNING, - anim->num_parts); + Debug("anim:HandleGlobalAnim_Main", "%s(%d): %d, %d, %d [%d]", + (action == ANIM_START ? "ANIM_START" : + action == ANIM_CONTINUE ? "ANIM_CONTINUE" : + action == ANIM_STOP ? "ANIM_STOP" : "(should not happen)"), + anim->nr, + anim->state & ANIM_STATE_RESTART, + anim->state & ANIM_STATE_WAITING, + anim->state & ANIM_STATE_RUNNING, + anim->num_parts); #endif switch (action) @@ -1584,8 +1592,8 @@ static void HandleGlobalAnim_Main(struct GlobalAnimMainControlInfo *anim, if (c->anim_mode & ANIM_ALL || anim->num_parts == 0) { #if 0 - printf("::: HandleGlobalAnim_Main: %d, %d => %d\n", - anim->mode_nr, anim->nr, num_parts); + Debug("anim:HandleGlobalAnim_Main", "%d, %d => %d", + anim->mode_nr, anim->nr, num_parts); #endif for (i = 0; i < num_parts; i++) @@ -1682,8 +1690,7 @@ static void HandleGlobalAnim_Mode(struct GlobalAnimControlInfo *ctrl, int action int i; #if 0 - printf("::: HandleGlobalAnim_Mode: %d => %d\n", - ctrl->nr, ctrl->num_anims); + Debug("anim:HandleGlobalAnim_Mode", "%d => %d", ctrl->nr, ctrl->num_anims); #endif for (i = 0; i < ctrl->num_anims; i++) @@ -1693,7 +1700,7 @@ static void HandleGlobalAnim_Mode(struct GlobalAnimControlInfo *ctrl, int action static void HandleGlobalAnim(int action, int game_mode) { #if 0 - printf("::: HandleGlobalAnim [mode == %d]\n", game_status); + Debug("anim:HandleGlobalAnim", "mode == %d", game_status); #endif HandleGlobalAnim_Mode(&global_anim_ctrl[game_mode], action); @@ -1704,7 +1711,7 @@ static void DoAnimationExt(void) int i; #if 0 - printf("::: DoAnimation [%d, %d]\n", anim_sync_frame, Counter()); + Debug("anim:DoAnimationExt", "%d, %d", anim_sync_frame, Counter()); #endif // global animations now synchronized with frame delay of screen update @@ -1828,8 +1835,8 @@ static boolean InitGlobalAnim_Clicked(int mx, int my, int clicked_event) isClickablePart(part, ANIM_EVENT_ANY)) { #if DEBUG_ANIM_EVENTS - printf("::: => %d.%d TRIGGERED BY ANY\n", - part->old_anim_nr + 1, part->old_nr + 1); + Debug("anim:InitGlobalAnim_Clicked", "%d.%d TRIGGERED BY ANY", + part->old_anim_nr + 1, part->old_nr + 1); #endif anything_clicked = part->clicked = TRUE; @@ -1841,8 +1848,8 @@ static boolean InitGlobalAnim_Clicked(int mx, int my, int clicked_event) isClickablePart(part, ANIM_EVENT_UNCLICK_ANY)) { #if DEBUG_ANIM_EVENTS - printf("::: => %d.%d TRIGGERED BY UNCLICK:ANY\n", - part->old_anim_nr + 1, part->old_nr + 1); + Debug("anim:InitGlobalAnim_Clicked", "%d.%d TRIGGERED BY UNCLICK:ANY", + part->old_anim_nr + 1, part->old_nr + 1); #endif anything_clicked = part->clicked = TRUE; @@ -1857,8 +1864,8 @@ static boolean InitGlobalAnim_Clicked(int mx, int my, int clicked_event) isClickedPart(part, mx, my, TRUE)) { #if 0 - printf("::: %d.%d CLICKED [%d]\n", anim_nr, part_nr, - part->control_info.anim_event_action); + Debug("anim:InitGlobalAnim_Clicked", "%d.%d CLICKED [%d]", + anim_nr, part_nr, part->control_info.anim_event_action); #endif // after executing event action, ignore any further actions @@ -1871,8 +1878,8 @@ static boolean InitGlobalAnim_Clicked(int mx, int my, int clicked_event) if (isClickablePart(part, ANIM_EVENT_SELF)) { #if DEBUG_ANIM_EVENTS - printf("::: => %d.%d TRIGGERED BY SELF\n", - part->old_anim_nr + 1, part->old_nr + 1); + Debug("anim:InitGlobalAnim_Clicked", "%d.%d TRIGGERED BY SELF", + part->old_anim_nr + 1, part->old_nr + 1); #endif anything_clicked = part->clicked = TRUE; diff --git a/src/editor.c b/src/editor.c index f2436f9e..0f8b1ba7 100644 --- a/src/editor.c +++ b/src/editor.c @@ -7151,7 +7151,7 @@ void CreateLevelEditorGadgets(void) num_editor_gadgets = NUM_EDITOR_GADGETS; - // printf("::: allocating %d gadgets ...\n", num_editor_gadgets); + // Debug("editor", "allocating %d gadgets ...\n", num_editor_gadgets); level_editor_gadget = checked_calloc(num_editor_gadgets * sizeof(struct GadgetInfo *)); @@ -7189,7 +7189,7 @@ void FreeLevelEditorGadgets(void) { int i; - // printf("::: freeing %d gadgets ...\n", num_editor_gadgets); + // Debug("editor", "freeing %d gadgets ...\n", num_editor_gadgets); for (i = 0; i < num_editor_gadgets; i++) { @@ -12071,7 +12071,7 @@ static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y, mode == CB_BRUSH_TO_CLIPBOARD_SMALL) SDL_SetClipboardText(text); else - printf("%s", text); + printf("%s", text); // print brush data to console return; } @@ -14111,13 +14111,13 @@ static void HandleControlButtons(struct GadgetInfo *gi) } #ifdef DEBUG else if (gi->event.type == GD_EVENT_PRESSED) - printf("default: HandleControlButtons: GD_EVENT_PRESSED(%d)\n", id); + Debug("editor", "default: HandleControlButtons: GD_EVENT_PRESSED(%d)", id); else if (gi->event.type == GD_EVENT_RELEASED) - printf("default: HandleControlButtons: GD_EVENT_RELEASED(%d)\n", id); + Debug("editor", "default: HandleControlButtons: GD_EVENT_RELEASED(%d)", id); else if (gi->event.type == GD_EVENT_MOVING) - printf("default: HandleControlButtons: GD_EVENT_MOVING(%d)\n", id); + Debug("editor", "default: HandleControlButtons: GD_EVENT_MOVING(%d)", id); else - printf("default: HandleControlButtons: ? (id == %d)\n", id); + Debug("editor", "default: HandleControlButtons: ? (id == %d)", id); #endif break; } diff --git a/src/events.c b/src/events.c index b5f83725..24106461 100644 --- a/src/events.c +++ b/src/events.c @@ -1808,7 +1808,7 @@ static void HandleKeysSpecial(Key key) cheat_input[cheat_input_len] = '\0'; #if DEBUG_EVENTS_KEY - Debug("event:key:special", "'%s' [%d]\n", cheat_input, cheat_input_len); + Debug("event:key:special", "'%s' [%d]", cheat_input, cheat_input_len); #endif if (game_status == GAME_MODE_MAIN) diff --git a/src/files.c b/src/files.c index 3882e34d..76aedc60 100644 --- a/src/files.c +++ b/src/files.c @@ -8053,9 +8053,12 @@ void LoadTapeFromFilename(char *filename) tape.length_seconds = GetTapeLengthSeconds(); #if 0 - printf("::: tape file version: %d\n", tape.file_version); - printf("::: tape game version: %d\n", tape.game_version); - printf("::: tape engine version: %d\n", tape.engine_version); + Debug("files:LoadTapeFromFilename", "tape file version: %d", + tape.file_version); + Debug("files:LoadTapeFromFilename", "tape game version: %d", + tape.game_version); + Debug("files:LoadTapeFromFilename", "tape engine version: %d", + tape.engine_version); #endif } @@ -11861,12 +11864,12 @@ void LoadHelpAnimInfo(void) #if 0 for (i = 0; i < num_list_entries; i++) - printf("::: '%s': %d, %d, %d => %d\n", - EL_NAME(helpanim_info[i].element), - helpanim_info[i].element, - helpanim_info[i].action, - helpanim_info[i].direction, - helpanim_info[i].delay); + Debug("files:LoadHelpAnimInfo", "'%s': %d, %d, %d => %d", + EL_NAME(helpanim_info[i].element), + helpanim_info[i].element, + helpanim_info[i].action, + helpanim_info[i].direction, + helpanim_info[i].delay); #endif } @@ -11898,8 +11901,8 @@ void LoadHelpTextInfo(void) #if 0 BEGIN_HASH_ITERATION(helptext_info, itr) { - printf("::: '%s' => '%s'\n", - HASH_ITERATION_TOKEN(itr), HASH_ITERATION_VALUE(itr)); + Debug("files:LoadHelpTextInfo", "'%s' => '%s'", + HASH_ITERATION_TOKEN(itr), HASH_ITERATION_VALUE(itr)); } END_HASH_ITERATION(hash, itr) #endif diff --git a/src/game.c b/src/game.c index a7aa7752..c926738d 100644 --- a/src/game.c +++ b/src/game.c @@ -1769,13 +1769,11 @@ static void InitPlayerField(int x, int y, int element, boolean init_game) StorePlayer[x][y] = Tile[x][y]; #if DEBUG_INIT_PLAYER - if (options.debug) - { - printf("- player element %d activated", player->element_nr); - printf(" (local player is %d and currently %s)\n", - local_player->element_nr, - local_player->active ? "active" : "not active"); - } + Debug("game:init:player", "- player element %d activated", + player->element_nr); + Debug("game:init:player", " (local player is %d and currently %s)", + local_player->element_nr, + local_player->active ? "active" : "not active"); } #endif @@ -2843,16 +2841,16 @@ static void InitGameEngine(void) } #if 0 - printf("level %d: level.game_version == %06d\n", level_nr, - level.game_version); - printf(" tape.file_version == %06d\n", - tape.file_version); - printf(" tape.game_version == %06d\n", - tape.game_version); - printf(" tape.engine_version == %06d\n", - tape.engine_version); - printf(" => game.engine_version == %06d [tape mode: %s]\n", - game.engine_version, (tape.playing ? "PLAYING" : "RECORDING")); + Debug("game:init:level", "level %d: level.game_version == %06d", level_nr, + level.game_version); + Debug("game:init:level", " tape.file_version == %06d", + tape.file_version); + Debug("game:init:level", " tape.game_version == %06d", + tape.game_version); + Debug("game:init:level", " tape.engine_version == %06d", + tape.engine_version); + Debug("game:init:level", " => game.engine_version == %06d [tape mode: %s]", + game.engine_version, (tape.playing ? "PLAYING" : "RECORDING")); #endif // -------------------------------------------------------------------------- @@ -3441,24 +3439,21 @@ static void DebugPrintPlayerStatus(char *message) if (!options.debug) return; - printf("%s:\n", message); + Debug("game:init:player", "%s:", message); for (i = 0; i < MAX_PLAYERS; i++) { struct PlayerInfo *player = &stored_player[i]; - printf("- player %d: present == %d, connected == %d [%d/%d], active == %d", - i + 1, - player->present, - player->connected, - player->connected_locally, - player->connected_network, - player->active); - - if (local_player == player) - printf(" (local player)"); - - printf("\n"); + Debug("game:init:player", + "- player %d: present == %d, connected == %d [%d/%d], active == %d%s", + i + 1, + player->present, + player->connected, + player->connected_locally, + player->connected_network, + player->active, + (local_player == player ? " (local player)" : "")); } } #endif @@ -3934,8 +3929,7 @@ void InitGame(void) #endif #if DEBUG_INIT_PLAYER - if (options.debug) - printf("Reassigning players ...\n"); + Debug("game:init:player", "Reassigning players ..."); #endif // check if any connected player was not found in playfield @@ -3948,8 +3942,8 @@ void InitGame(void) struct PlayerInfo *field_player = NULL; #if DEBUG_INIT_PLAYER - if (options.debug) - printf("- looking for field player for player %d ...\n", i + 1); + Debug("game:init:player", + "- looking for field player for player %d ...", i + 1); #endif // assign first free player found that is present in the playfield @@ -3974,8 +3968,8 @@ void InitGame(void) int jx = field_player->jx, jy = field_player->jy; #if DEBUG_INIT_PLAYER - if (options.debug) - printf("- found player %d\n", field_player->index_nr + 1); + Debug("game:init:player", "- found player %d", + field_player->index_nr + 1); #endif player->present = FALSE; @@ -4005,9 +3999,8 @@ void InitGame(void) field_player->mapped = TRUE; #if DEBUG_INIT_PLAYER - if (options.debug) - printf("- map_player_action[%d] == %d\n", - field_player->index_nr + 1, i + 1); + Debug("game:init:player", "- map_player_action[%d] == %d", + field_player->index_nr + 1, i + 1); #endif } } @@ -4062,7 +4055,8 @@ void InitGame(void) #endif #if 0 - printf("::: local_player->present == %d\n", local_player->present); + Debug("game:init:player", "local_player->present == %d", + local_player->present); #endif // set focus to local player for network games, else to all players @@ -4095,8 +4089,8 @@ void InitGame(void) int jx = player->jx, jy = player->jy; #if DEBUG_INIT_PLAYER - if (options.debug) - printf("Removing player %d at (%d, %d)\n", i + 1, jx, jy); + Debug("game:init:player", "Removing player %d at (%d, %d)", + i + 1, jx, jy); #endif player->active = FALSE; @@ -8776,8 +8770,9 @@ void AmoebaToDiamond(int ax, int ay) #ifdef DEBUG if (group_nr == 0) { - printf("AmoebaToDiamond(): ax = %d, ay = %d\n", ax, ay); - printf("AmoebaToDiamond(): This should never happen!\n"); + Debug("game:playing:AmoebaToDiamond", "ax = %d, ay = %d", ax, ay); + Debug("game:playing:AmoebaToDiamond", "This should never happen!"); + return; } #endif @@ -8834,8 +8829,9 @@ static void AmoebaToDiamondBD(int ax, int ay, int new_element) #ifdef DEBUG if (group_nr == 0) { - printf("AmoebaToDiamondBD(): ax = %d, ay = %d\n", ax, ay); - printf("AmoebaToDiamondBD(): This should never happen!\n"); + Debug("game:playing:AmoebaToDiamondBD", "ax = %d, ay = %d", ax, ay); + Debug("game:playing:AmoebaToDiamondBD", "This should never happen!"); + return; } #endif @@ -9043,8 +9039,10 @@ static void AmoebaReproduce(int ax, int ay) #ifdef DEBUG if (new_group_nr == 0) { - printf("AmoebaReproduce(): newax = %d, neway = %d\n", newax, neway); - printf("AmoebaReproduce(): This should never happen!\n"); + Debug("game:playing:AmoebaReproduce", "newax = %d, neway = %d", + newax, neway); + Debug("game:playing:AmoebaReproduce", "This should never happen!"); + return; } #endif @@ -10660,11 +10658,9 @@ static void HandleElementChange(int x, int y, int page) if (!CAN_CHANGE_OR_HAS_ACTION(element) && !CAN_CHANGE_OR_HAS_ACTION(Back[x][y])) { - printf("\n\n"); - printf("HandleElementChange(): %d,%d: element = %d ('%s')\n", - x, y, element, element_info[element].token_name); - printf("HandleElementChange(): This should never happen!\n"); - printf("\n\n"); + Debug("game:playing:HandleElementChange", "%d,%d: element = %d ('%s')", + x, y, element, element_info[element].token_name); + Debug("game:playing:HandleElementChange", "This should never happen!"); } #endif @@ -11544,7 +11540,7 @@ static void GameActionsExt(void) int skip = WaitUntilDelayReached(&game_frame_delay, game_frame_delay_value); - printf("::: skip == %d\n", skip); + Debug("game:playing:skip", "skip == %d", skip); #else // ---------- main game synchronization point ---------- @@ -11962,8 +11958,9 @@ void GameActions_RND(void) #if DEBUG if (ChangePage[x][y] != -1 && ChangeDelay[x][y] != 1) { - printf("GameActions(): x = %d, y = %d: ChangePage != -1\n", x, y); - printf("GameActions(): This should never happen!\n"); + Debug("game:playing:GameActions_RND", "x = %d, y = %d: ChangePage != -1", + x, y); + Debug("game:playing:GameActions_RND", "This should never happen!"); ChangePage[x][y] = -1; } @@ -11997,10 +11994,10 @@ void GameActions_RND(void) Blocked2Moving(x, y, &oldx, &oldy); if (!IS_MOVING(oldx, oldy)) { - printf("GameActions(): (BLOCKED => MOVING) context corrupted!\n"); - printf("GameActions(): BLOCKED: x = %d, y = %d\n", x, y); - printf("GameActions(): !MOVING: oldx = %d, oldy = %d\n", oldx, oldy); - printf("GameActions(): This should never happen!\n"); + Debug("game:playing:GameActions_RND", "(BLOCKED => MOVING) context corrupted!"); + Debug("game:playing:GameActions_RND", "BLOCKED: x = %d, y = %d", x, y); + Debug("game:playing:GameActions_RND", "!MOVING: oldx = %d, oldy = %d", oldx, oldy); + Debug("game:playing:GameActions_RND", "This should never happen!"); } } #endif @@ -12641,8 +12638,9 @@ boolean MovePlayer(struct PlayerInfo *player, int dx, int dy) int original_move_delay_value = player->move_delay_value; #if DEBUG - printf("THIS SHOULD ONLY HAPPEN WITH PRE-1.2 LEVEL TAPES. [%d]\n", - tape.counter); + Debug("game:playing:MovePlayer", + "THIS SHOULD ONLY HAPPEN WITH PRE-1.2 LEVEL TAPES. [%d]", + tape.counter); #endif // scroll remaining steps with finest movement resolution @@ -13567,8 +13565,9 @@ void KillPlayer(struct PlayerInfo *player) return; #if 0 - printf("::: 0: killed == %d, active == %d, reanimated == %d\n", - player->killed, player->active, player->reanimated); + Debug("game:playing:KillPlayer", + "0: killed == %d, active == %d, reanimated == %d", + player->killed, player->active, player->reanimated); #endif /* the following code was introduced to prevent an infinite loop when calling @@ -13596,15 +13595,17 @@ void KillPlayer(struct PlayerInfo *player) player->shield_deadly_time_left = 0; #if 0 - printf("::: 1: killed == %d, active == %d, reanimated == %d\n", - player->killed, player->active, player->reanimated); + Debug("game:playing:KillPlayer", + "1: killed == %d, active == %d, reanimated == %d", + player->killed, player->active, player->reanimated); #endif Bang(jx, jy); #if 0 - printf("::: 2: killed == %d, active == %d, reanimated == %d\n", - player->killed, player->active, player->reanimated); + Debug("game:playing:KillPlayer", + "2: killed == %d, active == %d, reanimated == %d", + player->killed, player->active, player->reanimated); #endif if (player->reanimated) // killed player may have been reanimated @@ -15536,7 +15537,8 @@ static ListNode *SaveEngineSnapshotBuffers(void) node = node->next; } - printf("::: size of engine snapshot: %d bytes\n", num_bytes); + Debug("game:playing:SaveEngineSnapshotBuffers", + "size of engine snapshot: %d bytes", num_bytes); #endif return buffers; diff --git a/src/game_mm/mm_game.c b/src/game_mm/mm_game.c index e3437a7c..a1577285 100644 --- a/src/game_mm/mm_game.c +++ b/src/game_mm/mm_game.c @@ -771,8 +771,8 @@ static int ScanPixel(void) int hit_mask = 0; #if 0 - printf("ScanPixel: start scanning at (%d, %d) [%d, %d] [%d, %d]\n", - LX, LY, LX / TILEX, LY / TILEY, LX % TILEX, LY % TILEY); + Debug("game:mm:ScanPixel", "start scanning at (%d, %d) [%d, %d] [%d, %d]", + LX, LY, LX / TILEX, LY / TILEY, LX % TILEX, LY % TILEY); #endif // follow laser beam until it hits something (at least the screen border) @@ -785,7 +785,7 @@ static int ScanPixel(void) if (SX + LX < REAL_SX || SX + LX >= REAL_SX + FULL_SXSIZE || SY + LY < REAL_SY || SY + LY >= REAL_SY + FULL_SYSIZE) { - printf("ScanPixel: touched screen border!\n"); + Debug("game:mm:ScanPixel", "touched screen border!"); return HIT_MASK_ALL; } @@ -858,8 +858,9 @@ void ScanLaser(void) DrawLaser(0, DL_LASER_ENABLED); #if 0 - printf("Start scanning with LX == %d, LY == %d, XS == %d, YS == %d\n", - LX, LY, XS, YS); + Debug("game:mm:ScanLaser", + "Start scanning with LX == %d, LY == %d, XS == %d, YS == %d", + LX, LY, XS, YS); #endif while (1) @@ -877,8 +878,9 @@ void ScanLaser(void) hit_mask = ScanPixel(); #if 0 - printf("Hit something at LX == %d, LY == %d, XS == %d, YS == %d\n", - LX, LY, XS, YS); + Debug("game:mm:ScanLaser", + "Hit something at LX == %d, LY == %d, XS == %d, YS == %d", + LX, LY, XS, YS); #endif // hit something -- check out what it was @@ -886,8 +888,8 @@ void ScanLaser(void) ELY = (LY + YS) / TILEY; #if 0 - printf("hit_mask (1) == '%x' (%d, %d) (%d, %d)\n", - hit_mask, LX, LY, ELX, ELY); + Debug("game:mm:ScanLaser", "hit_mask (1) == '%x' (%d, %d) (%d, %d)", + hit_mask, LX, LY, ELX, ELY); #endif if (!IN_LEV_FIELD(ELX, ELY) || !IN_PIX_FIELD(LX, LY)) @@ -919,24 +921,26 @@ void ScanLaser(void) } #if 0 - printf("hit_mask (2) == '%x' (%d, %d) (%d, %d)\n", - hit_mask, LX, LY, ELX, ELY); + Debug("game:mm:ScanLaser", "hit_mask (2) == '%x' (%d, %d) (%d, %d)", + hit_mask, LX, LY, ELX, ELY); #endif element = Tile[ELX][ELY]; laser.dest_element = element; #if 0 - printf("Hit element %d at (%d, %d) [%d, %d] [%d, %d] [%d]\n", - element, ELX, ELY, - LX, LY, - LX % TILEX, LY % TILEY, - hit_mask); + Debug("game:mm:ScanLaser", + "Hit element %d at (%d, %d) [%d, %d] [%d, %d] [%d]", + element, ELX, ELY, + LX, LY, + LX % TILEX, LY % TILEY, + hit_mask); #endif #if 0 if (!IN_LEV_FIELD(ELX, ELY)) - printf("WARNING! (1) %d, %d (%d)\n", ELX, ELY, element); + Debug("game:mm:ScanLaser", "WARNING! (1) %d, %d (%d)", + ELX, ELY, element); #endif if (element == EL_EMPTY) @@ -1002,15 +1006,16 @@ void ScanLaser(void) #if 0 if (laser.dest_element != Tile[ELX][ELY]) { - printf("ALARM: laser.dest_element == %d, Tile[ELX][ELY] == %d\n", - laser.dest_element, Tile[ELX][ELY]); + Debug("game:mm:ScanLaser", + "ALARM: laser.dest_element == %d, Tile[ELX][ELY] == %d", + laser.dest_element, Tile[ELX][ELY]); } #endif if (!end && !laser.stops_inside_element && !StepBehind()) { #if 0 - printf("ScanLaser: Go one step back\n"); + Debug("game:mm:ScanLaser", "Go one step back"); #endif LX -= XS; @@ -1026,7 +1031,7 @@ void ScanLaser(void) #if 0 if (!IN_LEV_FIELD(ELX, ELY)) - printf("WARNING! (2) %d, %d\n", ELX, ELY); + Debug("game:mm:ScanLaser", "WARNING! (2) %d, %d", ELX, ELY); #endif } @@ -1036,8 +1041,8 @@ static void DrawLaserExt(int start_edge, int num_edges, int mode) int elx, ely; #if 0 - printf("DrawLaserExt: start_edge, num_edges, mode == %d, %d, %d\n", - start_edge, num_edges, mode); + Debug("game:mm:DrawLaserExt", "start_edge, num_edges, mode == %d, %d, %d", + start_edge, num_edges, mode); #endif if (start_edge < 0) @@ -1057,7 +1062,7 @@ static void DrawLaserExt(int start_edge, int num_edges, int mode) #if 0 if (mode == DL_LASER_DISABLED) { - printf("DrawLaser: Delete laser from edge %d\n", start_edge); + Debug("game:mm:DrawLaserExt", "Delete laser from edge %d", start_edge); } #endif @@ -1117,11 +1122,12 @@ static void DrawLaserExt(int start_edge, int num_edges, int mode) int i; for (i = 0; i < laser.num_beamers; i++) - printf("-> %d\n", laser.beamer_edge[i]); - printf("DrawLaserExt: IS_BEAMER: [%d]: Hit[%d][%d] == %d [%d]\n", - mode, elx, ely, Hit[elx][ely], start_edge); - printf("DrawLaserExt: IS_BEAMER: %d / %d\n", - get_element_angle(element), laser.damage[damage_start].angle); + Debug("game:mm:DrawLaserExt", "-> %d", laser.beamer_edge[i]); + + Debug("game:mm:DrawLaserExt", "IS_BEAMER: [%d]: Hit[%d][%d] == %d [%d]", + mode, elx, ely, Hit[elx][ely], start_edge); + Debug("game:mm:DrawLaserExt", "IS_BEAMER: %d / %d", + get_element_angle(element), laser.damage[damage_start].angle); } #endif @@ -1161,8 +1167,8 @@ static void DrawLaserExt(int start_edge, int num_edges, int mode) YS = 2 * Step[laser.current_angle].y; #if 0 - printf("DrawLaser: Set (LX, LY) to (%d, %d) [%d]\n", - LX, LY, element); + Debug("game:mm:DrawLaserExt", "Set (LX, LY) to (%d, %d) [%d]", + LX, LY, element); #endif if (start_edge > 0) @@ -1177,7 +1183,7 @@ static void DrawLaserExt(int start_edge, int num_edges, int mode) int step_size; #if 0 - printf("element == %d\n", element); + Debug("game:mm:DrawLaserExt", "element == %d", element); #endif if (IS_22_5_ANGLE(laser.current_angle)) // neither 90° nor 45° angle @@ -1197,10 +1203,9 @@ static void DrawLaserExt(int start_edge, int num_edges, int mode) #if 0 if (IS_BEAMER(element)) - { - printf("start_edge == %d, laser.beamer_edge == %d\n", - start_edge, laser.beamer_edge); - } + Debug("game:mm:DrawLaserExt", + "start_edge == %d, laser.beamer_edge == %d", + start_edge, laser.beamer_edge); #endif LX += step_size * XS; @@ -1215,8 +1220,8 @@ static void DrawLaserExt(int start_edge, int num_edges, int mode) } #if 0 - printf("DrawLaser: Finally: (LX, LY) to (%d, %d) [%d]\n", - LX, LY, element); + Debug("game:mm:DrawLaserExt", "Finally: (LX, LY) to (%d, %d) [%d]", + LX, LY, element); #endif } @@ -1247,8 +1252,8 @@ void DrawLaser(int start_edge, int mode) continue; #if 0 - printf("DrawLaser: DL_LASER_ENABLED: i==%d: %d, %d\n", - i, laser.beamer_edge[i], tmp_start_edge); + Debug("game:mm:DrawLaser", "DL_LASER_ENABLED: i==%d: %d, %d", + i, laser.beamer_edge[i], tmp_start_edge); #endif DrawLaserExt(tmp_start_edge, tmp_num_edges, DL_LASER_ENABLED); @@ -1282,8 +1287,8 @@ void DrawLaser(int start_edge, int mode) #if 0 if (last_num_edges - start_edge <= 0) - printf("DrawLaser: DL_LASER_DISABLED: %d, %d\n", - last_num_edges, start_edge); + Debug("game:mm:DrawLaser", "DL_LASER_DISABLED: %d, %d", + last_num_edges, start_edge); #endif // special case when rotating first beamer: delete laser edge on beamer @@ -1317,14 +1322,16 @@ boolean HitElement(int element, int hit_mask) element = MovingOrBlocked2Element_MM(ELX, ELY); #if 0 - printf("HitElement (1): element == %d\n", element); + Debug("game:mm:HitElement", "(1): element == %d", element); #endif #if 0 if ((ELX * TILEX + 14 - LX) * YS == (ELY * TILEY + 14 - LY) * XS) - printf("HitElement (%d): EXACT MATCH @ (%d, %d)\n", element, ELX, ELY); + Debug("game:mm:HitElement", "(%d): EXACT MATCH @ (%d, %d)", + element, ELX, ELY); else - printf("HitElement (%d): FUZZY MATCH @ (%d, %d)\n", element, ELX, ELY); + Debug("game:mm:HitElement", "(%d): FUZZY MATCH @ (%d, %d)", + element, ELX, ELY); #endif AddDamagedField(ELX, ELY); @@ -1355,7 +1362,7 @@ boolean HitElement(int element, int hit_mask) } #if 0 - printf("HitElement (2): element == %d\n", element); + Debug("game:mm:HitElement", "(2): element == %d", element); #endif if (LX + 5 * XS < 0 || @@ -1368,7 +1375,7 @@ boolean HitElement(int element, int hit_mask) } #if 0 - printf("HitElement (3): element == %d\n", element); + Debug("game:mm:HitElement", "(3): element == %d", element); #endif if (IS_POLAR(element) && @@ -1399,9 +1406,9 @@ boolean HitElement(int element, int hit_mask) { #if 0 if ((ELX * TILEX + 14 - LX) * YS == (ELY * TILEY + 14 - LY) * XS) - printf("EXACT MATCH @ (%d, %d)\n", ELX, ELY); + Debug("game:mm:HitElement", "EXACT MATCH @ (%d, %d)", ELX, ELY); else - printf("FUZZY MATCH @ (%d, %d)\n", ELX, ELY); + Debug("game:mm:HitElement", "FUZZY MATCH @ (%d, %d)", ELX, ELY); #endif LX = ELX * TILEX + 14; @@ -1557,7 +1564,7 @@ boolean HitElement(int element, int hit_mask) } #if 0 - printf("HitElement (4): element == %d\n", element); + Debug("game:mm:HitElement", "(4): element == %d", element); #endif if ((IS_BEAMER(element) || IS_FIBRE_OPTIC(element)) && @@ -1569,7 +1576,7 @@ boolean HitElement(int element, int hit_mask) int step_size; #if 0 - printf("HitElement (BEAMER): element == %d\n", element); + Debug("game:mm:HitElement", "(BEAMER): element == %d", element); #endif laser.num_damages--; @@ -1636,7 +1643,8 @@ boolean HitOnlyAnEdge(int element, int hit_mask) // check if the laser hit only the edge of an element and, if so, go on #if 0 - printf("LX, LY, hit_mask == %d, %d, %d\n", LX, LY, hit_mask); + Debug("game:mm:HitOnlyAnEdge", "LX, LY, hit_mask == %d, %d, %d", + LX, LY, hit_mask); #endif if ((hit_mask == HIT_MASK_TOPLEFT || @@ -1674,14 +1682,14 @@ boolean HitOnlyAnEdge(int element, int hit_mask) LY += YS; #if 0 - printf("[HitOnlyAnEdge() == TRUE]\n"); + Debug("game:mm:HitOnlyAnEdge", "[HitOnlyAnEdge() == TRUE]"); #endif return TRUE; } #if 0 - printf("[HitOnlyAnEdge() == FALSE]\n"); + Debug("game:mm:HitOnlyAnEdge", "[HitOnlyAnEdge() == FALSE]"); #endif return FALSE; @@ -1697,8 +1705,8 @@ boolean HitPolarizer(int element, int hit_mask) int grid_angle = get_element_angle(element); #if 0 - printf("HitPolarizer: angle: grid == %d, laser == %d\n", - grid_angle, laser.current_angle); + Debug("game:mm:HitPolarizer", "angle: grid == %d, laser == %d", + grid_angle, laser.current_angle); #endif AddLaserEdge(LX, LY); @@ -1735,10 +1743,10 @@ boolean HitPolarizer(int element, int hit_mask) LY += YS; #if 0 - printf("HitPolarizer: LX, LY == %d, %d [%d, %d] [%d, %d]\n", - LX, LY, - LX / TILEX, LY / TILEY, - LX % TILEX, LY % TILEY); + Debug("game:mm:HitPolarizer", "LX, LY == %d, %d [%d, %d] [%d, %d]", + LX, LY, + LX / TILEX, LY / TILEY, + LX % TILEX, LY % TILEY); #endif return FALSE; @@ -2905,9 +2913,8 @@ void RotateMirror(int x, int y, int button) if (IS_BEAMER(Tile[x][y])) { #if 0 - printf("TEST (%d, %d) [%d] [%d]\n", - LX, LY, - laser.beamer_edge, laser.beamer[1].num); + Debug("game:mm:RotateMirror", "TEST (%d, %d) [%d] [%d]", + LX, LY, laser.beamer_edge, laser.beamer[1].num); #endif laser.num_edges--; @@ -3166,8 +3173,8 @@ static void GameActions_MM_Ext(struct MouseActionInfo action, boolean warp_mode) #if 0 if (element != Tile[ELX][ELY]) { - printf("element == %d, Tile[ELX][ELY] == %d\n", - element, Tile[ELX][ELY]); + Debug("game:mm:GameActions_MM_Ext", "element == %d, Tile[ELX][ELY] == %d", + element, Tile[ELX][ELY]); } #endif @@ -3425,7 +3432,7 @@ static void GameActions_MM_Ext(struct MouseActionInfo action, boolean warp_mode) DrawField_MM(ELX, ELY); #if 0 - printf("NEW ELEMENT: (%d, %d)\n", ELX, ELY); + Debug("game:mm:GameActions_MM_Ext", "NEW ELEMENT: (%d, %d)", ELX, ELY); #endif // above stuff: GRAY BALL -> PRISM !!! @@ -3457,10 +3464,6 @@ static void GameActions_MM_Ext(struct MouseActionInfo action, boolean warp_mode) #endif ScanLaser(); - - /* - printf("TEST ELEMENT: %d\n", Tile[0][0]); - */ #endif return; diff --git a/src/game_mm/mm_tools.c b/src/game_mm/mm_tools.c index f5853b88..c104791c 100644 --- a/src/game_mm/mm_tools.c +++ b/src/game_mm/mm_tools.c @@ -65,8 +65,10 @@ void DrawGraphic_MM(int x, int y, int graphic) #if DEBUG if (!IN_SCR_FIELD(x,y)) { - printf("DrawGraphic_MM(): x = %d, y = %d, graphic = %d\n",x,y,graphic); - printf("DrawGraphic_MM(): This should never happen!\n"); + Debug("game:mm:DrawGraphic_MM", "x = %d, y = %d, graphic = %d", + x, y, graphic); + Debug("game:mm:DrawGraphic_MM", "This should never happen!"); + return; } #endif @@ -91,8 +93,10 @@ void DrawGraphicThruMask_MM(int x, int y, int graphic) #if DEBUG if (!IN_SCR_FIELD(x,y)) { - printf("DrawGraphicThruMask_MM(): x = %d,y = %d, graphic = %d\n",x,y,graphic); - printf("DrawGraphicThruMask_MM(): This should never happen!\n"); + Debug("game:mm:DrawGraphicThruMask_MM", "x = %d,y = %d, graphic = %d", + x, y, graphic); + Debug("game:mm:DrawGraphicThruMask_MM", "This should never happen!"); + return; } #endif @@ -236,8 +240,10 @@ void DrawGraphicShifted_MM(int x,int y, int dx,int dy, int graphic, #if DEBUG if (!IN_SCR_FIELD(x,y)) { - printf("DrawGraphicShifted_MM(): x = %d, y = %d, graphic = %d\n",x,y,graphic); - printf("DrawGraphicShifted_MM(): This should never happen!\n"); + Debug("game:mm:DrawGraphicShifted_MM", "x = %d, y = %d, graphic = %d", + x, y, graphic); + Debug("game:mm:DrawGraphicShifted_MM", "This should never happen!"); + return; } #endif diff --git a/src/init.c b/src/init.c index bbf62e67..41e891cc 100644 --- a/src/init.c +++ b/src/init.c @@ -650,15 +650,14 @@ static void InitGlobalAnimGraphicInfo(void) } #if 0 - printf("::: InitGlobalAnimGraphicInfo\n"); - for (i = 0; i < NUM_GLOBAL_ANIMS; i++) for (j = 0; j < NUM_GLOBAL_ANIM_PARTS_ALL; j++) for (k = 0; k < NUM_SPECIAL_GFX_ARGS; k++) if (global_anim_info[i].graphic[j][k] != IMG_UNDEFINED && graphic_info[global_anim_info[i].graphic[j][k]].bitmap != NULL) - printf("::: - anim %d, part %d, mode %d => %d\n", - i, j, k, global_anim_info[i].graphic[j][k]); + Debug("init:InitGlobalAnimGraphicInfo", + "anim %d, part %d, mode %d => %d", + i, j, k, global_anim_info[i].graphic[j][k]); #endif } @@ -700,14 +699,13 @@ static void InitGlobalAnimSoundInfo(void) } #if 0 - printf("::: InitGlobalAnimSoundInfo\n"); - for (i = 0; i < NUM_GLOBAL_ANIMS; i++) for (j = 0; j < NUM_GLOBAL_ANIM_PARTS_ALL; j++) for (k = 0; k < NUM_SPECIAL_GFX_ARGS; k++) if (global_anim_info[i].sound[j][k] != SND_UNDEFINED) - printf("::: - anim %d, part %d, mode %d => %d\n", - i, j, k, global_anim_info[i].sound[j][k]); + Debug("init:InitGlobalAnimSoundInfo", + "anim %d, part %d, mode %d => %d", + i, j, k, global_anim_info[i].sound[j][k]); #endif } @@ -749,14 +747,13 @@ static void InitGlobalAnimMusicInfo(void) } #if 0 - printf("::: InitGlobalAnimMusicInfo\n"); - for (i = 0; i < NUM_GLOBAL_ANIMS; i++) for (j = 0; j < NUM_GLOBAL_ANIM_PARTS_ALL; j++) for (k = 0; k < NUM_SPECIAL_GFX_ARGS; k++) if (global_anim_info[i].music[j][k] != MUS_UNDEFINED) - printf("::: - anim %d, part %d, mode %d => %d\n", - i, j, k, global_anim_info[i].music[j][k]); + Debug("init:InitGlobalAnimMusicInfo", + "anim %d, part %d, mode %d => %d", + i, j, k, global_anim_info[i].music[j][k]); #endif } @@ -5621,36 +5618,36 @@ static void InitImages(void) print_timestamp_init("InitImages"); #if 0 - printf("::: leveldir_current->identifier == '%s'\n", - leveldir_current == NULL ? "[NULL]" : leveldir_current->identifier); - printf("::: leveldir_current->graphics_path == '%s'\n", - leveldir_current == NULL ? "[NULL]" : leveldir_current->graphics_path); - printf("::: leveldir_current->graphics_set == '%s'\n", - leveldir_current == NULL ? "[NULL]" : leveldir_current->graphics_set); - printf("::: getLevelArtworkSet(ARTWORK_TYPE_GRAPHICS) == '%s'\n", - leveldir_current == NULL ? "[NULL]" : LEVELDIR_ARTWORK_SET(leveldir_current, ARTWORK_TYPE_GRAPHICS)); + Debug("init:InitImages", "leveldir_current->identifier == '%s'", + leveldir_current == NULL ? "[NULL]" : leveldir_current->identifier); + Debug("init:InitImages", "leveldir_current->graphics_path == '%s'", + leveldir_current == NULL ? "[NULL]" : leveldir_current->graphics_path); + Debug("init:InitImages", "leveldir_current->graphics_set == '%s'", + leveldir_current == NULL ? "[NULL]" : leveldir_current->graphics_set); + Debug("init:InitImages", "getLevelArtworkSet(ARTWORK_TYPE_GRAPHICS) == '%s'", + leveldir_current == NULL ? "[NULL]" : LEVELDIR_ARTWORK_SET(leveldir_current, ARTWORK_TYPE_GRAPHICS)); #endif setLevelArtworkDir(artwork.gfx_first); #if 0 - printf("::: leveldir_current->identifier == '%s'\n", - leveldir_current == NULL ? "[NULL]" : leveldir_current->identifier); - printf("::: leveldir_current->graphics_path == '%s'\n", - leveldir_current == NULL ? "[NULL]" : leveldir_current->graphics_path); - printf("::: leveldir_current->graphics_set == '%s'\n", + Debug("init:InitImages", "leveldir_current->identifier == '%s'", + leveldir_current == NULL ? "[NULL]" : leveldir_current->identifier); + Debug("init:InitImages", "leveldir_current->graphics_path == '%s'", + leveldir_current == NULL ? "[NULL]" : leveldir_current->graphics_path); + Debug("init:InitImages", "leveldir_current->graphics_set == '%s'", leveldir_current == NULL ? "[NULL]" : leveldir_current->graphics_set); - printf("::: getLevelArtworkSet(ARTWORK_TYPE_GRAPHICS) == '%s'\n", - leveldir_current == NULL ? "[NULL]" : LEVELDIR_ARTWORK_SET(leveldir_current, ARTWORK_TYPE_GRAPHICS)); + Debug("init:InitImages", "getLevelArtworkSet(ARTWORK_TYPE_GRAPHICS) == '%s'", + leveldir_current == NULL ? "[NULL]" : LEVELDIR_ARTWORK_SET(leveldir_current, ARTWORK_TYPE_GRAPHICS)); #endif #if 0 - printf("::: InitImages for '%s' ['%s', '%s'] ['%s', '%s']\n", - leveldir_current->identifier, - artwork.gfx_current_identifier, - artwork.gfx_current->identifier, - leveldir_current->graphics_set, - leveldir_current->graphics_path); + Debug("init:InitImages", "InitImages for '%s' ['%s', '%s'] ['%s', '%s']", + leveldir_current->identifier, + artwork.gfx_current_identifier, + artwork.gfx_current->identifier, + leveldir_current->graphics_set, + leveldir_current->graphics_path); #endif UPDATE_BUSY_STATE(); @@ -5809,22 +5806,27 @@ static boolean CheckArtworkTypeForRedefinedCustomElements(int type) setLevelArtworkDir(ARTWORK_FIRST_NODE(artwork, type)); #if 0 - printf("::: leveldir_current->identifier == '%s'\n", - leveldir_current == NULL ? "[NULL]" : leveldir_current->identifier); - printf("::: leveldir_current->graphics_path == '%s'\n", - leveldir_current == NULL ? "[NULL]" : leveldir_current->graphics_path); - printf("::: leveldir_current->graphics_set == '%s'\n", - leveldir_current == NULL ? "[NULL]" : leveldir_current->graphics_set); - printf("::: getLevelArtworkSet(ARTWORK_TYPE_GRAPHICS) == '%s'\n", - leveldir_current == NULL ? "[NULL]" : - LEVELDIR_ARTWORK_SET(leveldir_current, type)); + Debug("init:CheckArtworkTypeForRedefinedCustomElements", + "leveldir_current->identifier == '%s'", + leveldir_current == NULL ? "[NULL]" : leveldir_current->identifier); + Debug("init:CheckArtworkTypeForRedefinedCustomElements", + "leveldir_current->graphics_path == '%s'", + leveldir_current == NULL ? "[NULL]" : leveldir_current->graphics_path); + Debug("init:CheckArtworkTypeForRedefinedCustomElements", + "leveldir_current->graphics_set == '%s'", + leveldir_current == NULL ? "[NULL]" : leveldir_current->graphics_set); + Debug("init:CheckArtworkTypeForRedefinedCustomElements", + "getLevelArtworkSet(ARTWORK_TYPE_GRAPHICS) == '%s'", + leveldir_current == NULL ? "[NULL]" : + LEVELDIR_ARTWORK_SET(leveldir_current, type)); #endif // first look for special artwork configured in level series config filename_base = getCustomArtworkLevelConfigFilename(type); #if 0 - printf("::: filename_base == '%s'\n", filename_base); + Debug("init:CheckArtworkTypeForRedefinedCustomElements", + "filename_base == '%s'", filename_base); #endif if (fileExists(filename_base)) @@ -5833,14 +5835,16 @@ static boolean CheckArtworkTypeForRedefinedCustomElements(int type) filename_local = getCustomArtworkConfigFilename(type); #if 0 - printf("::: filename_local == '%s'\n", filename_local); + Debug("init:CheckArtworkTypeForRedefinedCustomElements", + "filename_local == '%s'", filename_local); #endif if (filename_local != NULL && !strEqual(filename_base, filename_local)) redefined_ce_found |= CheckArtworkConfigForCustomElements(filename_local); #if 0 - printf("::: redefined_ce_found == %d\n", redefined_ce_found); + Debug("init:CheckArtworkTypeForRedefinedCustomElements", + "redefined_ce_found == %d", redefined_ce_found); #endif return redefined_ce_found; @@ -5865,7 +5869,8 @@ static void InitOverrideArtwork(void) CheckArtworkTypeForRedefinedCustomElements(ARTWORK_TYPE_MUSIC)); #if 0 - printf("::: redefined_ce_found == %d\n", redefined_ce_found); + Debug("init:InitOverrideArtwork", "redefined_ce_found == %d", + redefined_ce_found); #endif if (redefined_ce_found) @@ -5884,10 +5889,10 @@ static void InitOverrideArtwork(void) } #if 0 - printf("::: => %d, %d, %d\n", - gfx.override_level_graphics, - gfx.override_level_sounds, - gfx.override_level_music); + Debug("init:InitOverrideArtwork", "%d, %d, %d", + gfx.override_level_graphics, + gfx.override_level_sounds, + gfx.override_level_music); #endif } diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 8719e145..b1ea74e0 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -574,10 +574,15 @@ void SkipUntilDelayReached(unsigned int *counter_var, unsigned int delay, #if 0 #if DEBUG - printf("::: %d: %d ms", *loop_var, delay); if (skip_frames) - printf(" -> SKIP %d FRAME(S) [%d ms]", skip_frames, skip_frames * delay); - printf("\n"); + Debug("internal:SkipUntilDelayReached", + "%d: %d ms -> SKIP %d FRAME(S) [%d ms]", + *loop_var, delay, + skip_frames, skip_frames * delay); + else + Debug("internal:SkipUntilDelayReached", + "%d: %d ms", + *loop_var, delay); #endif #endif diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 599bff5d..f42945fb 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -1830,8 +1830,8 @@ static void printSetupFileList(SetupFileList *list) if (!list) return; - printf("token: '%s'\n", list->token); - printf("value: '%s'\n", list->value); + Debug("setup:printSetupFileList", "token: '%s'", list->token); + Debug("setup:printSetupFileList", "value: '%s'", list->value); printSetupFileList(list->next); } @@ -1941,8 +1941,8 @@ static void printSetupFileHash(SetupFileHash *hash) { BEGIN_HASH_ITERATION(hash, itr) { - printf("token: '%s'\n", HASH_ITERATION_TOKEN(itr)); - printf("value: '%s'\n", HASH_ITERATION_VALUE(itr)); + Debug("setup:printSetupFileHash", "token: '%s'", HASH_ITERATION_TOKEN(itr)); + Debug("setup:printSetupFileHash", "value: '%s'", HASH_ITERATION_VALUE(itr)); } END_HASH_ITERATION(hash, itr) } @@ -3830,9 +3830,12 @@ void LoadArtworkInfo(void) artwork.mus_current_identifier = artwork.mus_current->identifier; #if ENABLE_UNUSED_CODE - printf("graphics set == %s\n\n", artwork.gfx_current_identifier); - printf("sounds set == %s\n\n", artwork.snd_current_identifier); - printf("music set == %s\n\n", artwork.mus_current_identifier); + Debug("setup:LoadArtworkInfo", "graphics set == %s", + artwork.gfx_current_identifier); + Debug("setup:LoadArtworkInfo", "sounds set == %s", + artwork.snd_current_identifier); + Debug("setup:LoadArtworkInfo", "music set == %s", + artwork.mus_current_identifier); #endif sortTreeInfo(&artwork.gfx_first); diff --git a/src/libgame/snapshot.c b/src/libgame/snapshot.c index 010db6e6..cd83dc5b 100644 --- a/src/libgame/snapshot.c +++ b/src/libgame/snapshot.c @@ -100,8 +100,8 @@ static void FreeSnapshotList_UpToNode(ListNode *node) while (snapshot_list != node) { #if DEBUG_SNAPSHOTS - printf("::: FreeSnapshotList_*() [%s, %d, %d]\n", - snapshot_list->key, num_snapshot_buffers, num_snapshot_bytes); + Debug("snapshot:FreeSnapshotList_UpToNode", "[%s, %d, %d]", + snapshot_list->key, num_snapshot_buffers, num_snapshot_bytes); #endif deleteNodeFromList(&snapshot_list, snapshot_list->key, FreeSnapshot); @@ -114,7 +114,7 @@ static void FreeSnapshotList_UpToNode(ListNode *node) void FreeSnapshotList(void) { #if DEBUG_SNAPSHOTS - printf("::: FreeSnapshotList()\n"); + Debug("snapshot:FreeSnapshotList", ""); #endif FreeSnapshotList_UpToNode(NULL); @@ -130,8 +130,7 @@ void FreeSnapshotList(void) static void ReduceSnapshotList(void) { #if DEBUG_SNAPSHOTS - printf("::: (Reducing number of snapshots from %d ", - num_snapshots); + int num_snapshots_last = num_snapshots; #endif // maximum number of snapshots exceeded -- thin out list of snapshots @@ -158,13 +157,16 @@ static void ReduceSnapshotList(void) } #if DEBUG_SNAPSHOTS - printf("to %d.)\n", num_snapshots); + Debug("snapshot:ReduceSnapshotList", + "(Reducing number of snapshots from %d to %d.)", + num_snapshots_last, num_snapshots); #if 0 node = snapshot_list; while (node) { - printf("::: key: %s\n", node->key); + Debug("snapshot:ReduceSnapshotList", "key: %s", node->key); + node = node->next; } #endif @@ -185,9 +187,10 @@ void SaveSnapshotToList(ListNode *snapshot_buffers) FreeSnapshotList_UpToNode(snapshot_current); #if DEBUG_SNAPSHOTS - printf("::: SaveSnapshotToList() [%d] [%d snapshots, %d buffers, %d bytes]\n", - next_snapshot_key, num_snapshots, - num_snapshot_buffers, num_snapshot_bytes); + Debug("snapshot:SaveSnapshotToList", + "[%d] [%d snapshots, %d buffers, %d bytes]", + next_snapshot_key, num_snapshots, + num_snapshot_buffers, num_snapshot_bytes); #endif addNodeToList(&snapshot_list, i_to_a(next_snapshot_key), @@ -224,7 +227,7 @@ boolean LoadSnapshotFromList_Older(int steps) LoadSnapshotBuffers(snapshot_current->content); #if DEBUG_SNAPSHOTS - printf("::: LoadSnapshotFromList_Older() [%s]\n", snapshot_current->key); + Debug("snapshot:LoadSnapshotFromList_Older", "[%s]", snapshot_current->key); #endif return TRUE; @@ -243,7 +246,7 @@ boolean LoadSnapshotFromList_Newer(int steps) LoadSnapshotBuffers(snapshot_current->content); #if DEBUG_SNAPSHOTS - printf("::: LoadSnapshotFromList_Newer() [%s]\n", snapshot_current->key); + Debug("snapshot:LoadSnapshotFromList_Newer", "[%s]", snapshot_current->key); #endif return TRUE; diff --git a/src/netserv.c b/src/netserv.c index 0f07ddb0..77ed714a 100644 --- a/src/netserv.c +++ b/src/netserv.c @@ -189,7 +189,7 @@ int receiveNetworkBufferBytes(struct NetworkBuffer *nb, TCPsocket socket, { if (num_bytes > MAX_PACKET_SIZE) { - Error(ERR_NETWORK_SERVER, "protocol error: invalid packet size %d", + Debug("network:server", "protocol error: invalid packet size %d", num_bytes); return -1; @@ -435,9 +435,8 @@ static void SendNetworkBufferToClient(struct NetworkBuffer *nb, static void RemovePlayer(struct NetworkServerPlayerInfo *player) { - if (options.verbose) - Error(ERR_NETWORK_SERVER, "dropping client %d (%s)", - player->number, player->player_name); + Debug("network:server", "dropping client %d (%s)", + player->number, player->player_name); SDLNet_TCP_DelSocket(fds, player->fd); SDLNet_TCP_Close(player->fd); @@ -475,11 +474,8 @@ static void RemovePlayer(struct NetworkServerPlayerInfo *player) #if 0 // do not terminate network server if last player disconnected if (run_server_only_once && num_clients == 0) { - if (options.verbose) - { - Error(ERR_NETWORK_SERVER, "no clients left"); - Error(ERR_NETWORK_SERVER, "aborting"); - } + Debug("network:server", "no clients left"); + Debug("network:server", "aborting"); exit(0); } @@ -545,13 +541,12 @@ static void Handle_OP_PROTOCOL_VERSION(struct NetworkServerPlayerInfo *player) if (protocol_version_major != PROTOCOL_VERSION_MAJOR || protocol_version_minor != PROTOCOL_VERSION_MINOR) { - if (options.verbose) - Error(ERR_NETWORK_SERVER, - "client %d (%s) has wrong protocol version %d.%d.%d", - player->number, player->player_name, - protocol_version_major, - protocol_version_minor, - protocol_version_patch); + Debug("network:server", + "client %d (%s) has wrong protocol version %d.%d.%d", + player->number, player->player_name, + protocol_version_major, + protocol_version_minor, + protocol_version_patch); initNetworkBufferForWriting(write_buffer, OP_BAD_PROTOCOL_VERSION, 0); @@ -565,13 +560,12 @@ static void Handle_OP_PROTOCOL_VERSION(struct NetworkServerPlayerInfo *player) } else { - if (options.verbose) - Error(ERR_NETWORK_SERVER, - "client %d (%s) uses protocol version %d.%d.%d", - player->number, player->player_name, - protocol_version_major, - protocol_version_minor, - protocol_version_patch); + Debug("network:server", + "client %d (%s) uses protocol version %d.%d.%d", + player->number, player->player_name, + protocol_version_major, + protocol_version_minor, + protocol_version_patch); } } @@ -582,9 +576,8 @@ static void Handle_OP_NUMBER_WANTED(struct NetworkServerPlayerInfo *player) boolean nr_is_free = TRUE; struct NetworkServerPlayerInfo *p; - if (options.verbose) - Error(ERR_NETWORK_SERVER, "client %d (%s) wants to switch to # %d", - player->number, player->player_name, nr_wanted); + Debug("network:server", "client %d (%s) wants to switch to # %d", + player->number, player->player_name, nr_wanted); for (p = first_player; p != NULL; p = p->next) { @@ -596,19 +589,16 @@ static void Handle_OP_NUMBER_WANTED(struct NetworkServerPlayerInfo *player) } } - if (options.verbose) - { - if (nr_is_free) - Error(ERR_NETWORK_SERVER, "client %d (%s) switches to # %d", - player->number, player->player_name, nr_wanted); - else if (player->number == nr_wanted) - Error(ERR_NETWORK_SERVER, "client %d (%s) already has # %d", - player->number, player->player_name, nr_wanted); - else - Error(ERR_NETWORK_SERVER, - "client %d (%s) cannot switch (client %d already exists)", - player->number, player->player_name, nr_wanted); - } + if (nr_is_free) + Debug("network:server", "client %d (%s) switches to # %d", + player->number, player->player_name, nr_wanted); + else if (player->number == nr_wanted) + Debug("network:server", "client %d (%s) already has # %d", + player->number, player->player_name, nr_wanted); + else + Debug("network:server", + "client %d (%s) cannot switch (client %d already exists)", + player->number, player->player_name, nr_wanted); if (nr_is_free) player->number = nr_wanted; @@ -649,9 +639,8 @@ static void Handle_OP_PLAYER_NAME(struct NetworkServerPlayerInfo *player) SendNetworkBufferToAllButOne(write_buffer, player); } - if (options.verbose) - Error(ERR_NETWORK_SERVER, "client %d calls itself \"%s\"", - player->number, player->player_name); + Debug("network:server", "client %d calls itself \"%s\"", + player->number, player->player_name); copyNetworkBufferForWriting(read_buffer, write_buffer, player->number); @@ -687,18 +676,17 @@ static void Handle_OP_START_PLAYING(struct NetworkServerPlayerInfo *player) char *new_leveldir_identifier = getNetworkBufferString(read_buffer); int level_nr = getNetworkBuffer16BitInteger(read_buffer); - if (options.verbose) - Error(ERR_NETWORK_SERVER, - "client %d (%s) starts game [level %d from level set '%s']", - player->number, player->player_name, level_nr, - new_leveldir_identifier); + Debug("network:server", + "client %d (%s) starts game [level %d from level set '%s']", + player->number, player->player_name, level_nr, + new_leveldir_identifier); struct NetworkServerPlayerInfo *p; // reset frame counter ServerFrameCounter = 0; - Error(ERR_NETWORK_SERVER, "resetting ServerFrameCounter to 0"); + Debug("network:server", "resetting ServerFrameCounter to 0"); // reset player actions for (p = first_player; p != NULL; p = p->next) @@ -717,9 +705,8 @@ static void Handle_OP_START_PLAYING(struct NetworkServerPlayerInfo *player) static void Handle_OP_PAUSE_PLAYING(struct NetworkServerPlayerInfo *player) { - if (options.verbose) - Error(ERR_NETWORK_SERVER, "client %d (%s) pauses game", - player->number, player->player_name); + Debug("network:server", "client %d (%s) pauses game", + player->number, player->player_name); copyNetworkBufferForWriting(read_buffer, write_buffer, player->number); @@ -728,9 +715,8 @@ static void Handle_OP_PAUSE_PLAYING(struct NetworkServerPlayerInfo *player) static void Handle_OP_CONTINUE_PLAYING(struct NetworkServerPlayerInfo *player) { - if (options.verbose) - Error(ERR_NETWORK_SERVER, "client %d (%s) continues game", - player->number, player->player_name); + Debug("network:server", "client %d (%s) continues game", + player->number, player->player_name); copyNetworkBufferForWriting(read_buffer, write_buffer, player->number); @@ -741,9 +727,8 @@ static void Handle_OP_STOP_PLAYING(struct NetworkServerPlayerInfo *player) { int cause_for_stopping = getNetworkBuffer8BitInteger(read_buffer); - if (options.verbose) - Error(ERR_NETWORK_SERVER, "client %d (%s) stops game [%d]", - player->number, player->player_name, cause_for_stopping); + Debug("network:server", "client %d (%s) stops game [%d]", + player->number, player->player_name, cause_for_stopping); copyNetworkBufferForWriting(read_buffer, write_buffer, player->number); @@ -808,9 +793,8 @@ static void Handle_OP_BROADCAST_MESSAGE(struct NetworkServerPlayerInfo *player) { char *message = getNetworkBufferString(read_buffer); - if (options.verbose) - Error(ERR_NETWORK_SERVER, "client %d (%s) sends message: %s", - player->number, player->player_name, message); + Debug("network:server", "client %d (%s) sends message: %s", + player->number, player->player_name, message); copyNetworkBufferForWriting(read_buffer, write_buffer, player->number); @@ -826,7 +810,7 @@ static void Handle_OP_LEVEL_FILE(struct NetworkServerPlayerInfo *player) static void ExitNetworkServer(int exit_value) { - Error(ERR_NETWORK_SERVER, "exiting network server"); + Debug("network:server", "exiting network server"); exit(exit_value); } @@ -901,14 +885,11 @@ void NetworkServer(int port, int serveronly) Error(ERR_EXIT_NETWORK_SERVER, "SDLNet_TCP_AddSocket() failed: %s"), SDLNet_GetError(); - if (options.verbose) - { - Error(ERR_NETWORK_SERVER, "started up, listening on port %d", port); - Error(ERR_NETWORK_SERVER, "using protocol version %d.%d.%d", - PROTOCOL_VERSION_MAJOR, - PROTOCOL_VERSION_MINOR, - PROTOCOL_VERSION_PATCH); - } + Debug("network:server", "started up, listening on port %d", port); + Debug("network:server", "using protocol version %d.%d.%d", + PROTOCOL_VERSION_MAJOR, + PROTOCOL_VERSION_MINOR, + PROTOCOL_VERSION_PATCH); while (1) { @@ -956,9 +937,8 @@ void NetworkServer(int port, int serveronly) if (num_bytes <= 0) { - if (options.verbose) - Error(ERR_NETWORK_SERVER, "EOF from client %d (%s)", - player->number, player->player_name); + Debug("network:server", "EOF from client %d (%s)", + player->number, player->player_name); RemovePlayer(player); @@ -976,8 +956,7 @@ void NetworkServer(int port, int serveronly) message_type != OP_PLAYER_NAME && message_type != OP_PROTOCOL_VERSION) { - if (options.verbose) - Error(ERR_NETWORK_SERVER, "got opcode %d for client %d which is not introduced yet (expected OP_PLAYER_NAME or OP_PROTOCOL_VERSION)", message_type, player->number); + Debug("network:server", "got opcode %d for client %d which is not introduced yet (expected OP_PLAYER_NAME or OP_PROTOCOL_VERSION)", message_type, player->number); RemovePlayer(player); @@ -1027,10 +1006,8 @@ void NetworkServer(int port, int serveronly) break; default: - if (options.verbose) - Error(ERR_NETWORK_SERVER, - "unknown opcode %d from client %d (%s)", - message_type, player->number, player->player_name); + Debug("network:server", "unknown opcode %d from client %d (%s)", + message_type, player->number, player->player_name); } } } diff --git a/src/network.c b/src/network.c index b4ee83c3..b61f861a 100644 --- a/src/network.c +++ b/src/network.c @@ -355,7 +355,7 @@ boolean ConnectToServer(char *hostname, int port) else DrawNetworkText_Failed("No local network server found!"); - printf("SDLNet_TCP_Open(): %s\n", SDLNet_GetError()); + Debug("network:client", "SDLNet_TCP_Open(): %s", SDLNet_GetError()); } if (hostname) // connect to specified server failed @@ -394,7 +394,7 @@ void SendToServer_PlayerName(char *player_name) SendNetworkBufferToServer(write_buffer); - Error(ERR_NETWORK_CLIENT, "you set your player name to \"%s\"", player_name); + Debug("network:client", "you set your player name to \"%s\"", player_name); } void SendToServer_ProtocolVersion(void) @@ -443,15 +443,15 @@ void SendToServer_LevelFile(void) network_level.use_network_level_files = FALSE; #if 0 - printf("::: '%s'\n", leveldir_current->identifier); - printf("::: '%d'\n", level.file_info.nr); - printf("::: '%d'\n", level.file_info.type); - printf("::: '%d'\n", level.file_info.packed); - printf("::: '%s'\n", level.file_info.basename); - printf("::: '%s'\n", level.file_info.filename); + Debug("network:client", "'%s'", leveldir_current->identifier); + Debug("network:client", "'%d'", level.file_info.nr); + Debug("network:client", "'%d'", level.file_info.type); + Debug("network:client", "'%d'", level.file_info.packed); + Debug("network:client", "'%s'", level.file_info.basename); + Debug("network:client", "'%s'", level.file_info.filename); if (level.use_custom_template) - printf("::: '%s'\n", level_template.file_info.filename); + Debug("network:client", "'%s'", level_template.file_info.filename); #endif } @@ -531,7 +531,8 @@ static void Handle_OP_YOUR_NUMBER(void) struct PlayerInfo *old_local_player = local_player; struct PlayerInfo *new_local_player = &stored_player[new_index_nr]; - printf("OP_YOUR_NUMBER: %d\n", old_client_nr); + Debug("network:client", "OP_YOUR_NUMBER: %d", old_client_nr); + first_player.nr = new_client_nr; if (old_local_player != new_local_player) @@ -550,7 +551,7 @@ static void Handle_OP_YOUR_NUMBER(void) if (first_player.nr > MAX_PLAYERS) Error(ERR_EXIT, "sorry, more than %d players not allowed", MAX_PLAYERS); - Error(ERR_NETWORK_CLIENT, "you get client # %d", new_client_nr); + Debug("network:client", "you get client # %d", new_client_nr); stored_player[new_index_nr].connected_network = TRUE; } @@ -566,17 +567,17 @@ static void Handle_OP_NUMBER_WANTED(void) struct PlayerInfo *old_player = &stored_player[old_index_nr]; struct PlayerInfo *new_player = &stored_player[new_index_nr]; - printf("OP_NUMBER_WANTED: %d\n", old_client_nr); + Debug("network:client", "OP_NUMBER_WANTED: %d", old_client_nr); if (new_client_nr == client_nr_wanted) // switching succeeded { struct NetworkClientPlayerInfo *player; if (old_client_nr != client_nr_wanted) // client's nr has changed - Error(ERR_NETWORK_CLIENT, "client %d switches to # %d", + Debug("network:client", "client %d switches to # %d", old_client_nr, new_client_nr); else if (old_client_nr == first_player.nr) // local player keeps his nr - Error(ERR_NETWORK_CLIENT, "keeping client # %d", new_client_nr); + Debug("network:client", "keeping client # %d", new_client_nr); if (old_client_nr != new_client_nr) { @@ -606,7 +607,7 @@ static void Handle_OP_NUMBER_WANTED(void) Request(request, REQ_CONFIRM); - Error(ERR_NETWORK_CLIENT, "cannot switch -- you keep client # %d", + Debug("network:client", "cannot switch -- you keep client # %d", new_client_nr); } @@ -620,12 +621,12 @@ static void Handle_OP_PLAYER_NAME(void) char *player_name = getNetworkBufferString(read_buffer); struct NetworkClientPlayerInfo *player = getNetworkPlayer(player_nr); - printf("OP_PLAYER_NAME: %d\n", player_nr); + Debug("network:client", "OP_PLAYER_NAME: %d", player_nr); strncpy(player->name, player_name, MAX_PLAYER_NAME_LEN); player->name[MAX_PLAYER_NAME_LEN] = '\0'; - Error(ERR_NETWORK_CLIENT, "client %d calls itself \"%s\"", + Debug("network:client", "client %d calls itself \"%s\"", player_nr, player->name); } @@ -635,8 +636,8 @@ static void Handle_OP_PLAYER_CONNECTED(void) int new_client_nr = getNetworkBuffer8BitInteger(read_buffer); int new_index_nr = new_client_nr - 1; - printf("OP_PLAYER_CONNECTED: %d\n", new_client_nr); - Error(ERR_NETWORK_CLIENT, "new client %d connected", new_client_nr); + Debug("network:client", "OP_PLAYER_CONNECTED: %d", new_client_nr); + Debug("network:client", "new client %d connected", new_client_nr); for (player = &first_player; player; player = player->next) { @@ -661,11 +662,12 @@ static void Handle_OP_PLAYER_DISCONNECTED(void) int player_nr = getNetworkBuffer8BitInteger(read_buffer); int index_nr = player_nr - 1; - printf("OP_PLAYER_DISCONNECTED: %d\n", player_nr); - player_disconnected = getNetworkPlayer(player_nr); - Error(ERR_NETWORK_CLIENT, "client %d (%s) disconnected", + Debug("network:client", "OP_PLAYER_DISCONNECTED: %d", player_nr); + Debug("network:client", "client %d (%s) disconnected", player_nr, getNetworkPlayerName(player_nr)); + player_disconnected = getNetworkPlayer(player_nr); + for (player = &first_player; player; player = player->next) if (player->next == player_disconnected) player->next = player_disconnected->next; @@ -709,9 +711,9 @@ static void Handle_OP_START_PLAYING(void) return; } - printf("OP_START_PLAYING: %d\n", player_nr); - Error(ERR_NETWORK_CLIENT, - "client %d starts game [level %d from level identifier '%s']\n", + Debug("network:client", "OP_START_PLAYING: %d", player_nr); + Debug("network:client", + "client %d starts game [level %d from level identifier '%s']", player_nr, new_level_nr, new_leveldir_identifier); LevelDirTree *new_leveldir = @@ -740,8 +742,8 @@ static void Handle_OP_PAUSE_PLAYING(void) { int player_nr = getNetworkBuffer8BitInteger(read_buffer); - printf("OP_PAUSE_PLAYING: %d\n", player_nr); - Error(ERR_NETWORK_CLIENT, "client %d pauses game", player_nr); + Debug("network:client", "OP_PAUSE_PLAYING: %d", player_nr); + Debug("network:client", "client %d pauses game", player_nr); if (game_status == GAME_MODE_PLAYING) { @@ -754,8 +756,8 @@ static void Handle_OP_CONTINUE_PLAYING(void) { int player_nr = getNetworkBuffer8BitInteger(read_buffer); - printf("OP_CONTINUE_PLAYING: %d\n", player_nr); - Error(ERR_NETWORK_CLIENT, "client %d continues game", player_nr); + Debug("network:client", "OP_CONTINUE_PLAYING: %d", player_nr); + Debug("network:client", "client %d continues game", player_nr); if (game_status == GAME_MODE_PLAYING) { @@ -769,8 +771,9 @@ static void Handle_OP_STOP_PLAYING(void) int client_nr = getNetworkBuffer8BitInteger(read_buffer); int cause_for_stopping = getNetworkBuffer8BitInteger(read_buffer); - printf("OP_STOP_PLAYING: %d [%d]\n", client_nr, cause_for_stopping); - Error(ERR_NETWORK_CLIENT, "client %d stops game [%d]", + Debug("network:client", "OP_STOP_PLAYING: %d [%d]", + client_nr, cause_for_stopping); + Debug("network:client", "client %d stops game [%d]", client_nr, cause_for_stopping); if (game_status == GAME_MODE_PLAYING) @@ -830,8 +833,8 @@ static void Handle_OP_BROADCAST_MESSAGE(void) { int player_nr = getNetworkBuffer8BitInteger(read_buffer); - printf("OP_BROADCAST_MESSAGE: %d\n", player_nr); - Error(ERR_NETWORK_CLIENT, "client %d sends message", player_nr); + Debug("network:client", "OP_BROADCAST_MESSAGE: %d", player_nr); + Debug("network:client", "client %d sends message", player_nr); } static void Handle_OP_LEVEL_FILE(void) @@ -849,7 +852,7 @@ static void Handle_OP_LEVEL_FILE(void) setString(&network_level.tmpl_info.basename, NULL); setString(&network_level.tmpl_info.filename, NULL); - printf("OP_LEVEL_FILE: %d\n", player_nr); + Debug("network:client", "OP_LEVEL_FILE: %d", player_nr); leveldir_identifier = getStringCopy(getNetworkBufferString(read_buffer)); @@ -900,15 +903,15 @@ static void Handle_OP_LEVEL_FILE(void) network_level.use_network_level_files = TRUE; #if 0 - printf("::: '%s'\n", leveldir_identifier); - printf("::: '%d'\n", file_info->nr); - printf("::: '%d'\n", file_info->type); - printf("::: '%d'\n", file_info->packed); - printf("::: '%s'\n", file_info->basename); - printf("::: '%s'\n", file_info->filename); + Debug("network:client", "'%s'", leveldir_identifier); + Debug("network:client", "'%d'", file_info->nr); + Debug("network:client", "'%d'", file_info->type); + Debug("network:client", "'%d'", file_info->packed); + Debug("network:client", "'%s'", file_info->basename); + Debug("network:client", "'%s'", file_info->filename); if (use_custom_template) - printf("::: '%s'\n", tmpl_info->filename); + Debug("network:client", "'%s'", tmpl_info->filename); #endif } @@ -975,9 +978,7 @@ static void HandleNetworkingMessage(void) break; default: - if (options.verbose) - Error(ERR_NETWORK_CLIENT, - "unknown opcode %d from server", message_type); + Debug("network:client", "unknown opcode %d from server", message_type); } fflush(stdout); diff --git a/src/tools.c b/src/tools.c index b27c0112..3a4072e1 100644 --- a/src/tools.c +++ b/src/tools.c @@ -1611,8 +1611,9 @@ void DrawGraphic(int x, int y, int graphic, int frame) #if DEBUG if (!IN_SCR_FIELD(x, y)) { - printf("DrawGraphic(): x = %d, y = %d, graphic = %d\n", x, y, graphic); - printf("DrawGraphic(): This should never happen!\n"); + Debug("draw:DrawGraphic", "x = %d, y = %d, graphic = %d", x, y, graphic); + Debug("draw:DrawGraphic", "This should never happen!"); + return; } #endif @@ -1628,8 +1629,10 @@ void DrawFixedGraphic(int x, int y, int graphic, int frame) #if DEBUG if (!IN_SCR_FIELD(x, y)) { - printf("DrawGraphic(): x = %d, y = %d, graphic = %d\n", x, y, graphic); - printf("DrawGraphic(): This should never happen!\n"); + Debug("draw:DrawFixedGraphic", "x = %d, y = %d, graphic = %d", + x, y, graphic); + Debug("draw:DrawFixedGraphic", "This should never happen!"); + return; } #endif @@ -1665,8 +1668,10 @@ void DrawGraphicThruMask(int x, int y, int graphic, int frame) #if DEBUG if (!IN_SCR_FIELD(x, y)) { - printf("DrawGraphicThruMask(): x = %d,y = %d, graphic = %d\n",x,y,graphic); - printf("DrawGraphicThruMask(): This should never happen!\n"); + Debug("draw:DrawGraphicThruMask", "x = %d,y = %d, graphic = %d", + x, y, graphic); + Debug("draw:DrawGraphicThruMask", "This should never happen!"); + return; } #endif @@ -1682,8 +1687,10 @@ void DrawFixedGraphicThruMask(int x, int y, int graphic, int frame) #if DEBUG if (!IN_SCR_FIELD(x, y)) { - printf("DrawGraphicThruMask(): x = %d,y = %d, graphic = %d\n",x,y,graphic); - printf("DrawGraphicThruMask(): This should never happen!\n"); + Debug("draw:DrawFixedGraphicThruMask", "x = %d,y = %d, graphic = %d", + x, y, graphic); + Debug("draw:DrawFixedGraphicThruMask", "This should never happen!"); + return; } #endif @@ -1844,8 +1851,10 @@ static void DrawGraphicShiftedNormal(int x, int y, int dx, int dy, #if DEBUG if (!IN_SCR_FIELD(x, y)) { - printf("DrawGraphicShifted(): x = %d, y = %d, graphic = %d\n",x,y,graphic); - printf("DrawGraphicShifted(): This should never happen!\n"); + Debug("draw:DrawGraphicShiftedNormal", "x = %d, y = %d, graphic = %d", + x, y, graphic); + Debug("draw:DrawGraphicShiftedNormal", "This should never happen!"); + return; } #endif @@ -3869,8 +3878,8 @@ static void DrawPlayerExt(struct PlayerInfo *player, int drawing_stage) #if DEBUG if (!IN_LEV_FIELD(player->jx, player->jy)) { - printf("DrawPlayerField(): x = %d, y = %d\n", player->jx, player->jy); - printf("DrawPlayerField(): This should never happen!\n"); + Debug("draw:DrawPlayerExt", "x = %d, y = %d", player->jx, player->jy); + Debug("draw:DrawPlayerExt", "This should never happen!"); draw_player[pnr] = FALSE;