From e19bb71cf7a2b792c0a43722733f5c2e7fca0859 Mon Sep 17 00:00:00 2001 From: "Azamat H. Hackimov" Date: Tue, 20 Aug 2024 18:54:47 +0300 Subject: [PATCH] Convert core game to use new logging facility --- Descent3/AIGoal.cpp | 32 ++- Descent3/AIMain.h | 2 - Descent3/AImain.cpp | 160 ++++--------- Descent3/BOA.cpp | 86 +++---- Descent3/Briefing.cpp | 15 +- Descent3/BriefingParse.cpp | 24 +- Descent3/ConfigItem.cpp | 33 ++- Descent3/Controls.cpp | 26 +-- Descent3/D3ForceFeedback.cpp | 18 +- Descent3/DllWrappers.cpp | 12 +- Descent3/Game2DLL.cpp | 37 ++- Descent3/GameLoop.cpp | 112 ++++------ Descent3/Inventory.cpp | 37 ++- Descent3/LoadLevel.cpp | 91 ++++---- Descent3/Mission.cpp | 35 ++- Descent3/OsirisLoadandBind.cpp | 152 ++++++------- Descent3/PilotPicsAPI.cpp | 26 +-- Descent3/Player.cpp | 53 ++--- Descent3/SLEW.cpp | 38 +--- Descent3/TelCom.cpp | 47 ++-- Descent3/TelComEffects.cpp | 26 +-- Descent3/TelcomEffectsRender.cpp | 50 ++--- Descent3/TerrainSearch.cpp | 9 +- Descent3/WeaponFire.cpp | 27 +-- Descent3/aipath.cpp | 72 +----- Descent3/args.cpp | 19 +- Descent3/attach.cpp | 26 +-- Descent3/audiotaunts.cpp | 69 +++--- Descent3/bsp.cpp | 55 +++-- Descent3/buddymenu.cpp | 17 +- Descent3/cinematics.cpp | 7 +- Descent3/cockpit.cpp | 17 +- Descent3/config.cpp | 31 +-- Descent3/credits.cpp | 18 +- Descent3/ctlconfig.cpp | 12 +- Descent3/d3movie.cpp | 15 +- Descent3/d3music.cpp | 14 +- Descent3/damage.cpp | 12 +- Descent3/dedicated_server.cpp | 21 +- Descent3/demofile.cpp | 51 ++--- Descent3/descent.cpp | 7 +- Descent3/doorway.cpp | 5 +- Descent3/fireball.cpp | 46 ++-- Descent3/game.cpp | 27 +-- Descent3/gamecinematics.cpp | 68 +++--- Descent3/gameevent.cpp | 9 +- Descent3/gamefont.cpp | 7 +- Descent3/gamepath.cpp | 11 +- Descent3/gamepath.h | 10 +- Descent3/gamesave.cpp | 14 +- Descent3/gamesave.h | 3 +- Descent3/gamesequence.cpp | 26 +-- Descent3/gametexture.cpp | 21 +- Descent3/hotspotmap.cpp | 66 +++--- Descent3/hud.cpp | 36 ++- Descent3/hudmessage.cpp | 14 +- Descent3/init.cpp | 44 ++-- Descent3/levelgoal.cpp | 10 +- Descent3/lighting.cpp | 53 ++--- Descent3/list.cpp | 8 +- Descent3/loadstate.cpp | 18 +- Descent3/localization.cpp | 23 +- Descent3/marker.cpp | 7 +- Descent3/matcen.cpp | 20 +- Descent3/menu.cpp | 29 +-- Descent3/mission_download.cpp | 27 ++- Descent3/multi.cpp | 371 +++++++++++++------------------ Descent3/multi_client.cpp | 18 +- Descent3/multi_connect.cpp | 45 ++-- Descent3/multi_dll_mgr.cpp | 27 ++- Descent3/multi_save_setting.cpp | 6 +- Descent3/multi_server.cpp | 76 +++---- Descent3/multi_ui.cpp | 9 +- Descent3/multisafe.cpp | 16 +- Descent3/multisafe_server.cpp | 9 +- Descent3/newui.cpp | 11 +- Descent3/newui_core.cpp | 18 +- Descent3/newui_filedlg.cpp | 12 +- Descent3/object.cpp | 59 ++--- Descent3/object_lighting.cpp | 20 +- Descent3/objinfo.cpp | 16 +- Descent3/osiris_predefs.cpp | 96 ++++---- Descent3/pilot.cpp | 148 +++++------- Descent3/pilot_class.cpp | 55 +++-- Descent3/procedurals.cpp | 12 +- Descent3/render.cpp | 12 +- Descent3/renderobject.cpp | 16 +- Descent3/robotfire.cpp | 10 +- Descent3/room.cpp | 33 ++- Descent3/screens.cpp | 3 +- Descent3/sdlmain.cpp | 1 + Descent3/spew.cpp | 31 +-- Descent3/subtitles.cpp | 11 +- Descent3/terrain.cpp | 15 +- Descent3/terrainrender.cpp | 5 - Descent3/trigger.cpp | 10 +- Descent3/vclip.cpp | 30 +-- Descent3/viseffect.cpp | 5 +- Descent3/voice.cpp | 23 +- module/CMakeLists.txt | 2 +- module/module.cpp | 2 +- 101 files changed, 1430 insertions(+), 2016 deletions(-) diff --git a/Descent3/AIGoal.cpp b/Descent3/AIGoal.cpp index d075c7eb..893f7805 100644 --- a/Descent3/AIGoal.cpp +++ b/Descent3/AIGoal.cpp @@ -463,12 +463,14 @@ * $NoKeywords: $ */ -#include +#include + #include "AIGoal.h" #include "aistruct.h" #include "aipath.h" #include "object.h" #include "game.h" +#include "log.h" #include "terrain.h" #include "objinfo.h" #include "AIMain.h" @@ -561,11 +563,7 @@ void GoalClearGoal(object *obj, goal *cur_goal, int reason) { cur_goal->used = false; if (obj->ai_info->path.goal_uid == cur_goal->goal_uid) { -#ifdef _DEBUG - if (AI_debug_robot_do && OBJNUM(obj) == AI_debug_robot_index) { - mprintf(0, "AI Note: In free path\n"); - } -#endif + LOG_DEBUG_IF(AI_debug_robot_do && (OBJNUM(obj) == AI_debug_robot_index)) << "AI Note: In free path"; AIPathFreePath(&ai_info->path); } @@ -610,11 +608,7 @@ void GoalDoFrame(object *obj) { goal *cur_task_goal = GoalGetCurrentGoal(obj); if (ai_info->path.num_paths > 0 && (cur_task_goal == NULL || (cur_task_goal->goal_uid != ai_info->path.goal_uid))) { -#ifdef _DEBUG - if (AI_debug_robot_do && OBJNUM(obj) == AI_debug_robot_index) { - mprintf(0, "AI Note: In free path\n"); - } -#endif + LOG_DEBUG_IF(AI_debug_robot_do && (OBJNUM(obj) == AI_debug_robot_index)) << "AI Note: In free path"; AIPathFreePath(&ai_info->path); } @@ -774,7 +768,7 @@ void GoalDoFrame(object *obj) { fq.flags = FQ_CHECK_OBJS | FQ_NO_RELINK | FQ_IGNORE_NON_LIGHTMAP_OBJECTS; if (fvi_FindIntersection(&fq, &hit_info) == HIT_NONE) { - mprintf(0, "AI OBJ Path: No need to update the path for obj %d\n", OBJNUM(obj)); + LOG_DEBUG.printf("AI OBJ Path: No need to update the path for obj %d", OBJNUM(obj)); f_make_path = false; } } @@ -811,7 +805,7 @@ void GoalDoFrame(object *obj) { fq.flags = FQ_CHECK_OBJS | FQ_NO_RELINK | FQ_IGNORE_NON_LIGHTMAP_OBJECTS; if (fvi_FindIntersection(&fq, &hit_info) == HIT_NONE) { - mprintf(0, "AI POS Path: No need to update the path for obj %d\n", OBJNUM(obj)); + LOG_DEBUG.printf("AI POS Path: No need to update the path for obj %d", OBJNUM(obj)); f_make_path = false; } } @@ -880,10 +874,10 @@ int GoalAllocSlot(object *obj, int level, float influence) { ASSERT((level >= 0 && level < NUM_ACTIVATION_LEVELS) || (level == ACTIVATION_BLEND_LEVEL)); if (influence > MAX_INFLUENCE) { - mprintf(0, "Goal added with too much influence -- bashing down\n"); + LOG_DEBUG << "Goal added with too much influence -- bashing down"; influence = MAX_INFLUENCE; } else if (influence < 0.0f) { - mprintf(0, "Goal added with negative influence -- bashing to zero\n"); + LOG_DEBUG << "Goal added with negative influence -- bashing to zero"; influence = 0.0f; } @@ -891,7 +885,7 @@ int GoalAllocSlot(object *obj, int level, float influence) { cur_slot = level; if (level < 0) { - mprintf(0, "AI: Bashed an invalid activation level to zero\n"); + LOG_DEBUG << "AI: Bashed an invalid activation level to zero"; level = 0; } @@ -906,7 +900,7 @@ int GoalAllocSlot(object *obj, int level, float influence) { goal *cur_goal = &ai_info->goals[cur_slot]; if (level != ACTIVATION_BLEND_LEVEL) { - mprintf(0, "AI: Bashed an invalid activation blend level to blend level\n"); + LOG_DEBUG << "AI: Bashed an invalid activation blend level to blend level"; level = ACTIVATION_BLEND_LEVEL; } @@ -1075,7 +1069,7 @@ int GoalAddGoal(object *obj, uint32_t goal_type, void *arg_struct, int level, fl case AIG_FIRE_AT_OBJ: { gi_fire *attack_info = (gi_fire *)arg_struct; if (attack_info->cur_wb > MAX_WBS_PER_OBJ) { // DAJ - mprintf(2, "GoalAddGoal wb_index %d > MAX_WBS_PER_OBJ\n", attack_info->cur_wb); + LOG_DEBUG.printf("GoalAddGoal wb_index %d > MAX_WBS_PER_OBJ", attack_info->cur_wb); return 0; } if ((ai_info->animation_type == AS_ALERT && !(ai_info->next_animation_type == AS_FLINCH)) || @@ -1239,7 +1233,7 @@ int GoalAddEnabler(object *obj, int goal_index, uint8_t enabler_type, void *arg_ int enabler_index = ai_info->goals[goal_index].num_enablers; if (ai_info->goals[goal_index].num_enablers >= MAX_ENABLERS_PER_GOAL) { - mprintf(0, "Object %d with goal %d has to many enablers\n", OBJNUM(obj), goal_index); + LOG_DEBUG.printf("Object %d with goal %d has to many enablers", OBJNUM(obj), goal_index); return AI_INVALID_INDEX; } diff --git a/Descent3/AIMain.h b/Descent3/AIMain.h index db66b3c7..f4bcb662 100644 --- a/Descent3/AIMain.h +++ b/Descent3/AIMain.h @@ -161,10 +161,8 @@ extern int AI_RenderedList[MAX_OBJECTS]; extern int AI_NumHostileAlert; // A rough number of alert/hostile robots // that have seen the player recently -#ifdef _DEBUG extern bool AI_debug_robot_do; extern int AI_debug_robot_index; -#endif // Is my buddy in the level? (no if the handle is invalid) extern int Buddy_handle[MAX_PLAYERS]; diff --git a/Descent3/AImain.cpp b/Descent3/AImain.cpp index 1ae4e45a..ef3c1839 100644 --- a/Descent3/AImain.cpp +++ b/Descent3/AImain.cpp @@ -1507,7 +1507,8 @@ * $NoKeywords: $ */ -#include +#include + #include "AIMain.h" #include "mono.h" #include "game.h" @@ -1519,22 +1520,19 @@ #include "hlsoundlib.h" #include "sounds.h" #include "aiterrain.h" -#include "weapon.h" #include "objinfo.h" #include "polymodel.h" #include "robotfire.h" #include "BOA.h" #include "player.h" -#include "memory.h" #include "gamepath.h" #include "soundload.h" #include "damage.h" #include "aipath.h" -#include "robot.h" +#include "log.h" #include "attach.h" #include "demofile.h" #include "matcen.h" -#include "physics.h" #include "difficulty.h" #include "osiris_dll.h" #include "multi.h" @@ -1542,7 +1540,6 @@ #include "room.h" #include "psrand.h" #include "gametexture.h" -#include "difficulty.h" // Define's #define MAX_SEE_TARGET_DIST 500.0f @@ -1558,10 +1555,8 @@ float AI_last_time_room_noise_alert_time[MAX_ROOMS + 8]; int AI_unique_goal_id = 0; -#ifdef _DEBUG bool AI_debug_robot_do = false; int AI_debug_robot_index = -2; -#endif static bool compute_dodge_dir(vector *movement_dir, object *obj, object *dodge_obj); static float AIDetermineObjVisLevel(object *obj, object *target); @@ -2066,11 +2061,8 @@ bool goal_do_avoid_walls(object *obj, vector *mdir) { if (GameTextures[Terrain_tex_seg[tseg->texseg_index].tex_index].flags & (TF_VOLATILE | TF_FORCEFIELD | TF_LAVA)) { -#ifdef _DEBUG - if (AI_debug_robot_do && OBJNUM(obj) == AI_debug_robot_index) { - mprintf(0, "AI Note: Danger - NEAR FORCEFIELD, VOLATILE, OR LAVA\n"); - } -#endif + LOG_DEBUG_IF(AI_debug_robot_do && (OBJNUM(obj) == AI_debug_robot_index)) + << "AI Note: Danger - NEAR FORCEFIELD, VOLATILE, OR LAVA"; f_danger = true; } @@ -2103,11 +2095,7 @@ bool goal_do_avoid_walls(object *obj, vector *mdir) { } } -#ifdef _DEBUG - if (AI_debug_robot_do && OBJNUM(obj) == AI_debug_robot_index) { - mprintf(0, "AI Note: Avoid wall %f\n", scale); - } -#endif + LOG_DEBUG_IF(AI_debug_robot_do && (OBJNUM(obj) == AI_debug_robot_index)).printf("AI Note: Avoid wall %f", scale); return true; } @@ -2519,7 +2507,7 @@ void AIUpdateAnim(object *obj) { p_info->anim_flags &= ~AIAF_NOTIFY; if (!(p_info->multi_anim_info.flags & FMA_VALID)) { - mprintf(0, "Update Anim: Earily bail\n"); + LOG_DEBUG << "Update Anim: Early bail"; return; } @@ -3264,7 +3252,7 @@ bool AINotify(object *obj, uint8_t notify_type, void *info) { ei.extra_info = info; break; default: - mprintf(0, "Warning, %d has been notified with an unhandled notification %d\n", OBJNUM(obj), notify_type); + LOG_WARNING.printf("%d has been notified with an unhandled notification %d", OBJNUM(obj), notify_type); return true; } @@ -3440,7 +3428,7 @@ start_loop: ASSERT(from <= to); if (*anim_frame < from || *anim_frame > to) { - mprintf(0, "AI/Animation: Correcting for an incorrect frame number\n"); + LOG_DEBUG << "AI/Animation: Correcting for an incorrect frame number"; *anim_frame = from; } @@ -3475,7 +3463,7 @@ start_loop: } if (obj->rtype.pobj_info.anim_frame + 0.001 < from || obj->rtype.pobj_info.anim_frame > to) { - mprintf(2, "AI ANIM from %0.6f (%0.6f) to %0.6f\n", from, obj->rtype.pobj_info.anim_frame, to); + LOG_DEBUG.printf("AI ANIM from %0.6f (%0.6f) to %0.6f", from, obj->rtype.pobj_info.anim_frame, to); } if (obj->rtype.pobj_info.anim_frame < from) { obj->rtype.pobj_info.anim_frame = from; @@ -3571,7 +3559,7 @@ int AIFindRandomRoom(object *obj, ai_frame *ai_info, goal *goal_ptr, int avoid_r } if (!valid) { - mprintf(0, "AI: Wander is generating the same room :(\n"); + LOG_DEBUG << "AI: Wander is generating the same room :("; random_room = obj->roomnum; } } @@ -3592,11 +3580,7 @@ int AIFindRandomRoom(object *obj, ai_frame *ai_info, goal *goal_ptr, int avoid_r void AIDestroyObj(object *obj) { ai_frame *ai_info = obj->ai_info; -#ifdef _DEBUG - if (AI_debug_robot_do && OBJNUM(obj) == AI_debug_robot_index) { - mprintf(0, "AI Note: In free path\n"); - } -#endif + LOG_DEBUG_IF(AI_debug_robot_do && (OBJNUM(obj) == AI_debug_robot_index)) << "AI Note: In free path"; AIPathFreePath(&ai_info->path); } @@ -3825,22 +3809,20 @@ bool AIInit(object *obj, uint8_t ai_class, uint8_t ai_type, uint8_t ai_movement) void AISetDefault(t_ai_info *ai_info_ptr) {} void AIInitAll() { - int i; - - mprintf(0, "Initializing AI systems\n"); + LOG_DEBUG << "Initializing AI systems"; // Initialize the terrain AI system ait_Init(); // Make sure that the buddies are located - for (i = 0; i < MAX_PLAYERS; i++) { - Buddy_handle[i] = OBJECT_HANDLE_NONE; + for (int &i : Buddy_handle) { + i = OBJECT_HANDLE_NONE; } // Initialize the room AI system // Now, initialize each AI object - for (i = 0; i <= Highest_object_index; i++) + for (int i = 0; i <= Highest_object_index; i++) if (Objects[i].type != OBJ_NONE && Objects[i].control_type == CT_AI) { ASSERT(Objects[i].ai_info); AIInit(&Objects[i], Objects[i].ai_info->ai_class, Objects[i].ai_info->ai_type, Objects[i].ai_info->movement_type); @@ -3857,9 +3839,7 @@ void AIInitAll() { ObjGhostObject(objnum); } } else if (Netgame.flags & NF_ALLOWGUIDEBOT) { - int i; - - for (i = 0; i < MAX_PLAYERS; i++) { + for (int i = 0; i < MAX_PLAYERS; i++) { if (Netgame.local_role == LR_CLIENT) { Buddy_handle[i] = OBJECT_HANDLE_NONE; } else { @@ -3883,18 +3863,14 @@ void AIInitAll() { } } - mprintf(0, "Done Initializing AI systems\n"); + LOG_DEBUG << "Done Initializing AI systems"; } void AICheckTargetVis(object *obj) { ai_frame *ai_info = obj->ai_info; object *target = ObjGet(ai_info->target_handle); -#ifdef _DEBUG - if (AI_debug_robot_do && OBJNUM(obj) == AI_debug_robot_index) { - mprintf(0, "AI Note: Vis 1\n"); - } -#endif + LOG_DEBUG_IF(AI_debug_robot_do && (OBJNUM(obj) == AI_debug_robot_index)) << "AI Note: Vis 1"; #ifdef _DEBUG if (!Game_do_ai_vis) { @@ -3910,22 +3886,14 @@ void AICheckTargetVis(object *obj) { return; } -#ifdef _DEBUG - if (AI_debug_robot_do && OBJNUM(obj) == AI_debug_robot_index) { - mprintf(0, "AI Note: Vis 2\n"); - } -#endif + LOG_DEBUG_IF(AI_debug_robot_do && (OBJNUM(obj) == AI_debug_robot_index)) << "AI Note: Vis 2"; if (!BOA_IsVisible(obj->roomnum, target->roomnum)) { ai_info->status_reg &= ~AISR_SEES_GOAL; return; } -#ifdef _DEBUG - if (AI_debug_robot_do && OBJNUM(obj) == AI_debug_robot_index) { - mprintf(0, "AI Note: Vis 3\n"); - } -#endif + LOG_DEBUG_IF(AI_debug_robot_do && (OBJNUM(obj) == AI_debug_robot_index)) << "AI Note: Vis 3"; vector pos; AIDetermineAimPoint(obj, target, &pos); @@ -3943,11 +3911,7 @@ void AICheckTargetVis(object *obj) { return; } -#ifdef _DEBUG - if (AI_debug_robot_do && OBJNUM(obj) == AI_debug_robot_index) { - mprintf(0, "AI Note: Vis 4\n"); - } -#endif + LOG_DEBUG_IF(AI_debug_robot_do && (OBJNUM(obj) == AI_debug_robot_index)) << "AI Note: Vis 4"; if (ai_info->dist_to_target_actual > MAX_TRACK_TARGET_DIST * Diff_ai_vis_dist[DIFF_LEVEL] && (!ObjGet(ai_info->target_handle) || (obj->roomnum != ObjGet(ai_info->target_handle)->roomnum))) { @@ -3955,11 +3919,7 @@ void AICheckTargetVis(object *obj) { return; } -#ifdef _DEBUG - if (AI_debug_robot_do && OBJNUM(obj) == AI_debug_robot_index) { - mprintf(0, "AI Note: Vis 5\n"); - } -#endif + LOG_DEBUG_IF(AI_debug_robot_do && (OBJNUM(obj) == AI_debug_robot_index)) << "AI Note: Vis 5"; if (ai_info->awareness == AWARE_NONE && (target->roomnum != obj->roomnum) && ai_info->dist_to_target_actual > MAX_SEE_TARGET_DIST * Diff_ai_vis_dist[DIFF_LEVEL]) { @@ -3967,11 +3927,7 @@ void AICheckTargetVis(object *obj) { return; } -#ifdef _DEBUG - if (AI_debug_robot_do && OBJNUM(obj) == AI_debug_robot_index) { - mprintf(0, "AI Note: Vis 6\n"); - } -#endif + LOG_DEBUG_IF(AI_debug_robot_do && (OBJNUM(obj) == AI_debug_robot_index)) << "AI Note: Vis 6"; if ((ai_info->dist_to_target_actual > MAX_SEE_TARGET_DIST * Diff_ai_vis_dist[DIFF_LEVEL] && ai_info->awareness <= AWARE_BARELY && (target->roomnum != obj->roomnum)) || @@ -3982,11 +3938,7 @@ void AICheckTargetVis(object *obj) { return; } -#ifdef _DEBUG - if (AI_debug_robot_do && OBJNUM(obj) == AI_debug_robot_index) { - mprintf(0, "AI Note: Vis 7\n"); - } -#endif + LOG_DEBUG_IF(AI_debug_robot_do && (OBJNUM(obj) == AI_debug_robot_index)) << "AI Note: Vis 7"; // Can I see the target? if (Gametime - ai_info->last_see_target_time > MIN_VIS_RECENT_CHECK_INTERVAL) { @@ -4033,11 +3985,7 @@ void AICheckTargetVis(object *obj) { fate = fvi_FindIntersection(&fq, &hit_info); -#ifdef _DEBUG - if (AI_debug_robot_do && OBJNUM(obj) == AI_debug_robot_index) { - mprintf(0, "AI Note: Vis 8\n"); - } -#endif + LOG_DEBUG_IF(AI_debug_robot_do && (OBJNUM(obj) == AI_debug_robot_index)) << "AI Note: Vis 8"; if (((fate == HIT_OBJECT || fate == HIT_SPHERE_2_POLY_OBJECT) && hit_info.hit_object[0] == OBJNUM(target)) || (fate == HIT_NONE)) { @@ -4046,11 +3994,7 @@ void AICheckTargetVis(object *obj) { AINotify(obj, AIN_SEE_TARGET, target); -#ifdef _DEBUG - if (AI_debug_robot_do && OBJNUM(obj) == AI_debug_robot_index) { - mprintf(0, "AI Note: Vis SEE TARGET\n"); - } -#endif + LOG_DEBUG_IF(AI_debug_robot_do && (OBJNUM(obj) == AI_debug_robot_index)) << "AI Note: Vis SEE TARGET"; } if ((ai_info->status_reg & AISR_SEES_GOAL) || @@ -4676,22 +4620,14 @@ void ai_move(object *obj) { f_dodge = true; AIDetermineSpeed(obj, ai_info->goals[i].flags, &highest_speed); -#ifdef _DEBUG - if (AI_debug_robot_do && OBJNUM(obj) == AI_debug_robot_index) { - mprintf(0, "AI Note: Dodging\n"); - } -#endif + LOG_DEBUG_IF(AI_debug_robot_do && (OBJNUM(obj) == AI_debug_robot_index)) << "AI Note: Dodging"; } } else if (ai_info->goals[i].type == AIG_MELEE_TARGET) { f_goal_found = true; AiMelee(obj); AIDetermineSpeed(obj, ai_info->goals[i].flags, &highest_speed); -#ifdef _DEBUG - if (AI_debug_robot_do && OBJNUM(obj) == AI_debug_robot_index) { - mprintf(0, "AI Note: Melee\n"); - } -#endif + LOG_DEBUG_IF(AI_debug_robot_do && (OBJNUM(obj) == AI_debug_robot_index)) << "AI Note: Melee"; } else if (ai_info->goals[i].type == AIG_GET_AROUND_OBJ) { f_goal_found = true; @@ -4716,11 +4652,7 @@ void ai_move(object *obj) { float scale = cur_goal->influence * ((dist - cur_dist) / dist); if (AiGoalAvoid(&adir, obj, g_obj, dist)) { -#ifdef _DEBUG - if (AI_debug_robot_do && OBJNUM(obj) == AI_debug_robot_index) { - mprintf(0, "AI Note: Avoiding object\n"); - } -#endif + LOG_DEBUG_IF(AI_debug_robot_do && (OBJNUM(obj) == AI_debug_robot_index)) << "AI Note: Avoiding object"; ai_info->movement_dir += (adir * scale); f_avoid = true; @@ -4775,11 +4707,7 @@ void ai_move(object *obj) { f_avoid = true; AIDetermineSpeed(obj, GF_SPEED_NORMAL, &highest_speed); -#ifdef _DEBUG - if (AI_debug_robot_do && OBJNUM(obj) == AI_debug_robot_index) { - mprintf(0, "AI Note: Auto avoid friends.\n"); - } -#endif + LOG_DEBUG_IF(AI_debug_robot_do && (OBJNUM(obj) == AI_debug_robot_index)) << "AI Note: Auto avoid friends"; } } } @@ -4789,11 +4717,7 @@ void ai_move(object *obj) { f_avoid = true; AIDetermineSpeed(obj, GF_SPEED_NORMAL, &highest_speed); -#ifdef _DEBUG - if (AI_debug_robot_do && OBJNUM(obj) == AI_debug_robot_index) { - mprintf(0, "AI Note: Avoiding walls\n"); - } -#endif + LOG_DEBUG_IF(AI_debug_robot_do && (OBJNUM(obj) == AI_debug_robot_index)) << "AI Note: Avoiding walls"; } } @@ -4968,10 +4892,10 @@ void ai_move(object *obj) { AIMoveTowardsPosition(obj, &g_obj->pos, 1.0f, false, &goal_mdir, &goal_f_moved); goal_mset = true; } else { - mprintf(0, "AIG Warning: No obj for GetToObj.\n"); + LOG_DEBUG << "AIG Warning: No obj for GetToObj."; } } else if (cur_goal->type == AIG_FOLLOW_PATH) { - mprintf(0, "AIG Warning: Follow path has no path\n"); + LOG_DEBUG << "AIG Warning: Follow path has no path"; } } break; @@ -4998,7 +4922,7 @@ void ai_move(object *obj) { vec = &goal_obj->orient.uvec; break; default: - mprintf(0, "Invalid vec in AIG_MOVE_RELATIVE_OBJ_VEC bashing to fvec\n"); + LOG_DEBUG << "Invalid vec in AIG_MOVE_RELATIVE_OBJ_VEC bashing to fvec"; cur_goal->subtype = GST_FVEC | (int)f_toward; vec_id = GST_FVEC; } @@ -5141,7 +5065,7 @@ void ai_move(object *obj) { } break; default: { - mprintf(0, "AI ERROR: Object %d trying a non-implemented goal\n", OBJNUM(obj)); + LOG_WARNING.printf("AI ERROR: Object %d trying a non-implemented goal", OBJNUM(obj)); AIMoveTowardsPosition(obj, &ai_info->last_see_target_pos, 1.0f, true, &goal_mdir, &goal_f_moved); goal_mset = true; } @@ -5587,11 +5511,7 @@ static inline void ai_decrease_awareness(object *obj) { ai_frame *ai_info = obj->ai_info; if (ai_info->awareness == AWARE_NONE && !(ai_info->flags & AIF_PERSISTANT)) { -#ifdef _DEBUG - if (AI_debug_robot_do && OBJNUM(obj) == AI_debug_robot_index) { - mprintf(0, "AI Note: In free path\n"); - } -#endif + LOG_DEBUG_IF(AI_debug_robot_do && (OBJNUM(obj) == AI_debug_robot_index)) << "AI Note: In free path"; AIPathFreePath(&ai_info->path); } @@ -6014,7 +5934,7 @@ void AIDoFreud(object *obj) { GoalAddGoal(obj, AIG_WANDER_AROUND, NULL, 3, 2.0f, GF_SPEED_FLEE | GF_ORIENT_VELOCITY | GF_NONFLUSHABLE); GoalAddEnabler(obj, 3, AIE_CLEAR_TIME, (void *)&time, 1.0, 0.0); - mprintf(0, "Fear!!!!\n"); + LOG_DEBUG << "Fear!!!!"; return; } @@ -6028,7 +5948,7 @@ void AIDoFreud(object *obj) { GoalAddGoal(obj, AIG_WANDER_AROUND, NULL, 3, 2.0f, GF_SPEED_FLEE | GF_ORIENT_VELOCITY | GF_NONFLUSHABLE); GoalAddEnabler(obj, 3, AIE_CLEAR_TIME, (void *)&time, 1.0, 0.0); - mprintf(0, "Fear!!!!\n"); + LOG_DEBUG << "Fear!!!!"; return; } @@ -6040,7 +5960,7 @@ void AIDoFreud(object *obj) { GoalAddGoal(obj, AIG_WANDER_AROUND, NULL, 3, 2.0f, GF_SPEED_FLEE | GF_ORIENT_VELOCITY | GF_NONFLUSHABLE); GoalAddEnabler(obj, 3, AIE_CLEAR_TIME, (void *)&time, 1.0, 0.0); - mprintf(0, "Fear!!!!\n"); + LOG_DEBUG << "Fear!!!!"; return; } } diff --git a/Descent3/BOA.cpp b/Descent3/BOA.cpp index 8e967697..b21e26e3 100644 --- a/Descent3/BOA.cpp +++ b/Descent3/BOA.cpp @@ -119,6 +119,9 @@ * $NoKeywords: $ */ +#include +#include + #ifdef EDITOR #include "editor\d3edit.h" #endif @@ -129,15 +132,12 @@ #include "BOA.h" #include "vecmat.h" #include "room.h" -#include -#include #include "object.h" -#include "bsp.h" #include "pserror.h" #include "findintersection.h" +#include "log.h" #include "mem.h" #include "doorway.h" -#include "string.h" #define BOA_VERSION 25 @@ -932,8 +932,6 @@ void FindPath(int i, int j) { q_item *node_list[MAX_ROOMS + MAX_BOA_TERRAIN_REGIONS]; - // mprintf(0, "Find path for %d to %d\n", i, j); - if (i == -1 || j == -1) { delete start_node; return; @@ -1079,8 +1077,6 @@ void FindPath(int i, int j) { // Mark as an impossible path. BOA_Array[i][j] = BOA_NO_PATH; - // mprintf(0, "Found an impossible path\n"); - done: for (counter = 0; counter <= Highest_room_index + MAX_BOA_TERRAIN_REGIONS; counter++) { if (node_list[counter]) @@ -1246,7 +1242,7 @@ int BOAGetMineChecksum() { total += BOA_VERSION << 24; - mprintf(0, "Computed Checksum is %d\n", (int)total); + LOG_INFO.printf("Computed Checksum is %d", (int)total); return total; } @@ -1357,7 +1353,7 @@ void ValidateRoomPathPoint(int room, char *message, int len) { } if (!message) - mprintf(0, "Room %d has a bad center point\n", room); + LOG_WARNING.printf("Room %d has a bad center point", room); else { char new_message[300]; snprintf(new_message, sizeof(new_message), "Room %d has a bad center point\n", room); @@ -1585,7 +1581,7 @@ void MakeBOAVisTable(bool from_lighting) { // Now compute all room to room visibility stuff int i, t, j; - mprintf(0, "Computing visibility for %d rooms.\n", Highest_room_index); + LOG_DEBUG.printf("Computing visibility for %d rooms.", Highest_room_index); for (i = 0; i <= Highest_room_index + MAX_BOA_TERRAIN_REGIONS; i++) { for (t = 0; t <= Highest_room_index + MAX_BOA_TERRAIN_REGIONS; t++) { @@ -1609,8 +1605,6 @@ void MakeBOAVisTable(bool from_lighting) { #ifdef NEWEDITOR DoBOAVisProgressDialog((float)(i + 1) / (float)(Highest_room_index + 1), 1); #endif - mprintf_at(2, 4, 0, "Room=%d ", i); - if (rp->flags & RF_EXTERNAL) continue; @@ -1966,7 +1960,7 @@ void find_small_portals() { } } - mprintf(0, " Found %d small portals... :)\n", counter); + LOG_DEBUG.printf(" Found %d small portals... :)\n", counter); } void compute_robot_path_info() { @@ -2038,46 +2032,46 @@ void MakeBOA(void) { BOA_mine_checksum = cur_check; BOA_f_making_boa = true; - mprintf(0, "Making BOA and friends\n"); + LOG_INFO << "Making BOA and friends"; - mprintf(0, "Finding small portals\n"); + LOG_DEBUG << "Finding small portals"; find_small_portals(); - mprintf(0, "Done Finding small portals\n"); + LOG_DEBUG << "Done Finding small portals"; - mprintf(0, " Start computing path points.\n"); + LOG_DEBUG << " Start computing path points."; BOA_ComputePathPoints(); - mprintf(0, " Done computing path points.\n"); + LOG_DEBUG << " Done computing path points."; clear_BOA(); compute_costs(); - mprintf(0, " Start computing mines.\n"); + LOG_DEBUG << " Start computing mines."; compute_mine_info(); - mprintf(0, " Done computing %d mines.\n", BOA_num_mines); + LOG_DEBUG.printf(" Done computing %d mines.", BOA_num_mines); - mprintf(0, " Start computing terrain regions.\n"); + LOG_DEBUG << " Start computing terrain regions."; compute_terrain_region_info(); - mprintf(0, " Done computing %d terrain regions.\n", BOA_num_terrain_regions); + LOG_DEBUG.printf(" Done computing %d terrain regions.", BOA_num_terrain_regions); - mprintf(0, " Making designers wait for no particular reason...\n"); + LOG_DEBUG << " Making designers wait for no particular reason..."; compute_next_segs(); - mprintf(0, " Done with the sodomy...\n"); + LOG_DEBUG << " Done with the sodomy..."; - mprintf(0, " Start computing blockage info.\n"); + LOG_DEBUG << " Start computing blockage info."; compute_blockage_info(); - mprintf(0, " Done computing blockage info.\n"); + LOG_DEBUG << " Done computing blockage info."; - mprintf(0, " Start computing sound prop.\n"); + LOG_DEBUG << " Start computing sound prop."; compute_sound_dist_info(); - mprintf(0, " Done computing sound prop.\n"); + LOG_DEBUG << " Done computing sound prop."; - mprintf(0, " Start computing invalid robot path info.\n"); + LOG_DEBUG << " Start computing invalid robot path info."; compute_robot_path_info(); - mprintf(0, " Done computing invalid robot path info.\n"); + LOG_DEBUG << " Done computing invalid robot path info."; - mprintf(0, " Verifying connections\n"); + LOG_DEBUG << " Verifying connections"; verify_connections(); - mprintf(0, " Done with verification\n"); + LOG_DEBUG << " Done with verification"; // { // int cur_seg = 0; @@ -2095,7 +2089,7 @@ void MakeBOA(void) { // } BOA_f_making_boa = false; - mprintf(0, "BOA is done\n"); + LOG_INFO << "BOA is done"; } static int Current_sort_room; @@ -2127,13 +2121,11 @@ void ComputeAABB(bool f_full) { int computed_room_check[MAX_ROOMS]; - mprintf(0, "Computing AABB's"); - // Determines the room and face min/max information int cur_check = BOAGetMineChecksum(); if (cur_check == BOA_AABB_checksum && !f_full) { - mprintf(0, " (partial)!\n"); + LOG_DEBUG << "Computing AABB's (partial)!"; } else { for (i = 0; i < MAX_ROOMS; i++) { if (Rooms[i].used) { @@ -2160,7 +2152,7 @@ void ComputeAABB(bool f_full) { int16_t count; BOA_AABB_checksum = cur_check; - mprintf(0, " (full)!\n"); + LOG_DEBUG << "Computing AABB's (full)!"; for (i = 0; i <= Highest_room_index; i++) { Current_sort_room = i; @@ -2306,7 +2298,6 @@ void ComputeAABB(bool f_full) { ASSERT(num_struct < MAX_REGIONS_PER_ROOM); // get chris num_structs_per_room[i] = num_struct; - // mprintf(0, "%d structs in r %d\n", num_struct, i); } } @@ -2373,7 +2364,6 @@ void ComputeAABB(bool f_full) { } } - // mprintf(0, "Room %d Best Shell is %d\n", i, best); if (best != 0) { for (count = 0; count < rp->num_faces; count++) { if (r_struct_list[i][count] == 0) { @@ -2694,16 +2684,11 @@ void ComputeAABB(bool f_full) { // Remove unnecessary groups for (count = 0; count <= Highest_room_index; count++) { if (Rooms[count].used) { - // mprintf(0, "==================\n", count); - // mprintf(0, "Room %d\n", count); - if (BOA_AABB_ROOM_checksum[count] != 0 && BOA_AABB_ROOM_checksum[count] == computed_room_check[count]) continue; room *rp = &Rooms[count]; for (i = 0; i < rp->num_bbf_regions; i++) { - // mprintf(0, "Region %d has %d faces in it.\n", i, rp->num_bbf[i]); - if (rp->num_bbf[i] == 0) { for (j = i + 1; j < rp->num_bbf_regions; j++) { int16_t *temp = rp->bbf_list[j - 1]; @@ -2764,10 +2749,7 @@ void ComputeAABB(bool f_full) { } int diff[3]; - // mprintf(0, "Split plane results r %d s %d n %d\n", i, j, rp->num_bbf[j]); for (sp = 0; sp < 3; sp++) { - // mprintf(0, "%d %d %d\n", num_faces[sp][0], num_faces[sp][1], num_faces[sp][2]); - if (abs(num_faces[sp][0] - num_faces[sp][1]) > abs(num_faces[sp][1] - num_faces[sp][2])) diff[sp] = abs(num_faces[sp][0] - num_faces[sp][1]); else @@ -2784,8 +2766,6 @@ void ComputeAABB(bool f_full) { } } - // mprintf(0, "Split Plane is %d\n", best); - if (rp->num_bbf_regions <= MAX_REGIONS_PER_ROOM - 2) { rp->num_bbf[rp->num_bbf_regions] = 0; rp->num_bbf[rp->num_bbf_regions + 1] = 0; @@ -2828,15 +2808,11 @@ void ComputeAABB(bool f_full) { // Remove unnecessary groups for (count = 0; count <= Highest_room_index; count++) { if (Rooms[count].used) { - // mprintf(0, "==================\n", count); - // mprintf(0, "Room %d\n", count); if (BOA_AABB_ROOM_checksum[count] != 0 && BOA_AABB_ROOM_checksum[count] == computed_room_check[count]) continue; room *rp = &Rooms[count]; for (i = 0; i < rp->num_bbf_regions; i++) { - // mprintf(0, "Region %d has %d faces in it.\n", i, rp->num_bbf[i]); - if (rp->num_bbf[i] == 0) { for (j = i + 1; j < rp->num_bbf_regions; j++) { int16_t *temp = rp->bbf_list[j - 1]; @@ -3042,5 +3018,5 @@ void ComputeAABB(bool f_full) { } } - mprintf(0, "Done Computing AABB's.\n"); + LOG_DEBUG << "Done Computing AABB's."; } diff --git a/Descent3/Briefing.cpp b/Descent3/Briefing.cpp index a9cb57a4..9edaa83e 100644 --- a/Descent3/Briefing.cpp +++ b/Descent3/Briefing.cpp @@ -202,17 +202,14 @@ * $NoKeywords: $ */ +#include +#include + #include "Briefing.h" #include "BriefingParse.h" -#include -#include -#include -#include "game.h" +#include "log.h" #include "mem.h" #include "hlsoundlib.h" -#include "voice.h" -#include "streamaudio.h" -#include "pserror.h" #include "ddio.h" #include "descent.h" #include "TelCom.h" @@ -352,7 +349,7 @@ bool ParseForHotTags(const char *src, char **dest) { if (!strnicmp(curr_ptr, HotTags[i].name, HotTags[i].length)) { // this is a hot tag!!!!! - mprintf(0, "Found Embedded HotTag: %s\n", HotTags[i].name); + LOG_DEBUG.printf("Found Embedded HotTag: %s", HotTags[i].name); is_hot_tag = i; ret = true; break; @@ -481,7 +478,7 @@ void PBAddMovieEffect(TCMOVIEDESC* desc, char *description) { void PBAddBkgEffect(TCBKGDESC* desc, char *description) { if (IsMissionMaskOK(desc->mission_mask_set, desc->mission_mask_unset) && ok_to_parse_screen) { - mprintf(0, "PB: Add Bkg\n"); + LOG_DEBUG.printf("PB: Add Bkg"); } } diff --git a/Descent3/BriefingParse.cpp b/Descent3/BriefingParse.cpp index 2495f770..d356d0c0 100644 --- a/Descent3/BriefingParse.cpp +++ b/Descent3/BriefingParse.cpp @@ -60,18 +60,18 @@ * * $NoKeywords: $ */ + +#include +#include +#include + #include "BriefingParse.h" #include "TelComEffects.h" -#include -#include -#include #include "cfile.h" -#include "pserror.h" -#include "game.h" +#include "log.h" #include "mem.h" +#include "pserror.h" #include "voice.h" -#include "streamaudio.h" -#include "ddio.h" // constructor CBriefParse::CBriefParse() { @@ -323,7 +323,7 @@ int CBriefParse::ParseBriefing(const char *filename) { strcpy(title, " "); - mprintf(0, "Parsing <%s>\n", filename); + LOG_DEBUG << "Parsing " << filename; // Open the file ifile = cfopen(filename, "rt"); @@ -822,12 +822,12 @@ int CBriefParse::ParseBriefing(const char *filename) { done_parsing:; if (abort) { - mprintf(0, "Parse aborted\n"); + LOG_WARNING << "Parse aborted"; } else if (!parse_error) { if (reading_text) { ParseError("Missing '$endtext'"); } else { - mprintf(0, "Parse sucessful\n"); + LOG_DEBUG << "Parse successful"; } } @@ -1185,9 +1185,9 @@ done_parsing: // Generates an parsing error void CBriefParse::ParseError(const char *msg, const char *p) { - mprintf(0, "ERROR, line %d: %s\n", linenum, msg); + LOG_WARNING.printf("ERROR, line %d: %s", linenum, msg); if (p) { - mprintf(0, " %s\n", p); + LOG_WARNING.printf(" %s", p); } parse_error = 1; diff --git a/Descent3/ConfigItem.cpp b/Descent3/ConfigItem.cpp index 4c900dc5..e7965b16 100644 --- a/Descent3/ConfigItem.cpp +++ b/Descent3/ConfigItem.cpp @@ -86,23 +86,16 @@ * $NoKeywords: $ */ -#include "ConfigItem.h" -#include "ddio.h" -#include "newui.h" -#include "application.h" -#include "descent.h" -#include "mono.h" -#include "ddio.h" -#include "gamefont.h" -#include "multi_ui.h" -#include "cfile.h" -#include "mem.h" -#include "game.h" -#include "stringtable.h" +#include +#include +#include -#include -#include -#include +#include "ConfigItem.h" +#include "newui.h" +#include "descent.h" +#include "log.h" +#include "gamefont.h" +#include "mem.h" #include "stringtable.h" #define UI_CHECKBOX_OFF_CHAR 28 @@ -166,7 +159,7 @@ bool ConfigItem::Create(NewUIGameWindow *parentwnd, int type, int flags, int x, m_iType = type; break; default: - mprintf(0, "Bad config item type in Create\n"); + LOG_WARNING << "Bad config item type in Create"; return false; } if (!label) @@ -177,7 +170,7 @@ bool ConfigItem::Create(NewUIGameWindow *parentwnd, int type, int flags, int x, if ((m_iFlags & CIF_USEGROUP) && (type != CIT_RADIOBUTTON)) { // only radiobutton items support the CIF_USEGROUP - mprintf(0, "CONFIGITEM: Only CIT_RADIOBUTTON supports CIF_USEGROUP flag\n"); + LOG_DEBUG << "CONFIGITEM: Only CIT_RADIOBUTTON supports CIF_USEGROUP flag"; m_iFlags &= ~CIF_USEGROUP; Int3(); } @@ -558,7 +551,7 @@ void ConfigItem::Update(int result) { UpdateCheckBox(index); break; default: - mprintf(0, "Bad ConfigItem Type in Update\n"); + LOG_WARNING << "Bad ConfigItem Type in Update"; } } @@ -1012,7 +1005,7 @@ void ConfigItem::Add(int count, ...) { m_rbList[m_iInitial]->Activate(); break; default: - mprintf(0, "Bad ConfigItem Type in Add\n"); + LOG_WARNING << "Bad ConfigItem Type in Add"; } va_end(marker); } diff --git a/Descent3/Controls.cpp b/Descent3/Controls.cpp index 554af095..2852892d 100644 --- a/Descent3/Controls.cpp +++ b/Descent3/Controls.cpp @@ -404,6 +404,8 @@ * $NoKeywords: $ */ +#include + #include "controls.h" #include "object.h" @@ -412,26 +414,18 @@ #include "ddio.h" #include "joystick.h" #include "descent.h" -#include "mono.h" +#include "log.h" #include "weapon.h" #include "Controller.h" -#include "Macros.h" #include "gamesequence.h" #include "pilot.h" #include "hud.h" #include "stringtable.h" -#include "TelCom.h" #include "multi.h" #include "args.h" - #include "player.h" - #include "hlsoundlib.h" #include "sounds.h" -#include "soundload.h" - -#include -#include float Key_ramp_speed = 0.5f; @@ -620,7 +614,7 @@ void InitControls() { Key_ramp.oz = Key_ramp.z = 0.0f; // Initialize preemptive controller system for non-positonal data. - mprintf(0, "Initialized control system.\n"); + LOG_INFO << "Initialized control system."; } void CloseControls() { @@ -629,7 +623,7 @@ void CloseControls() { ResumeControls(); DestroyController(Controller); Controller = NULL; - mprintf(0, "Closing control system.\n"); + LOG_INFO << "Closing control system."; Control_system_init = false; } @@ -805,11 +799,6 @@ void DoMovement(game_controls *controls) { controls->afterburn_thrust = LIMIT_FORWARD; if (controls->afterburn_thrust < -LIMIT_FORWARD) controls->afterburn_thrust = -LIMIT_FORWARD; - - mprintf_at(1, 5, 30, "ch:%.2f ", controls->heading_thrust); - - // if (controls->pitch_thrust || controls->heading_thrust) - // mprintf(0, "p:%.2f h:%.2f\n", controls->pitch_thrust, controls->heading_thrust); } void DoKeyboardMovement(game_controls *controls) { @@ -911,10 +900,6 @@ void DoControllerMovement(game_controls *controls) { Controller->get_packet(ctfBANK_LEFTBUTTON, &ctl_blb); Controller->get_packet(ctfBANK_RIGHTBUTTON, &ctl_brb); - // check for joystick movement - // mprintf(0, "p:%f h:%f b:%f\n", ctl_p.value, ctl_h.value, ctl_b.value); - // mprintf(0, "u:%d d:%d l:%d r:%d\n", (int)ctl_povu.value, (int)ctl_povd.value, (int)ctl_povl.value, (int)ctl_povr.value); - // do x and y thrust controls->sideways_thrust += ctl_x.value; controls->vertical_thrust += -ctl_y.value; @@ -947,7 +932,6 @@ void DoControllerMovement(game_controls *controls) { // do afterburn button control if (!controls->afterburn_thrust) { - // mprintf(0, "aft=%.4f\n", ctl_afterburn.value); controls->afterburn_thrust = ((ctl_afterburn.value) / Frametime); } diff --git a/Descent3/D3ForceFeedback.cpp b/Descent3/D3ForceFeedback.cpp index ea91d6f9..ab842c67 100644 --- a/Descent3/D3ForceFeedback.cpp +++ b/Descent3/D3ForceFeedback.cpp @@ -88,12 +88,12 @@ * $NoKeywords: $ */ -#include +#include #include "forcefeedback.h" #include "D3ForceFeedback.h" #include "pserror.h" -#include "mono.h" +#include "log.h" #include "weapon.h" #include "ddio.h" #include "psrand.h" @@ -143,12 +143,12 @@ void ForceInit(void) { D3Force_init = true; D3Force_pause = false; - mprintf(0, "Force: High Level Force Feedback system initialized\n"); + LOG_INFO << "Force: High Level Force Feedback system initialized"; } else { D3Force_init = false; D3Force_pause = false; - mprintf(0, "Force: Force Feedback System Not Found\n"); + LOG_WARNING << "Force: Force Feedback System Not Found"; } for (int i = 0; i < DDIO_FF_MAXEFFECTS; i++) { @@ -195,7 +195,7 @@ void ForceClose(void) { D3Force_pause = false; D3Force_init = false; - mprintf(0, "Force: Shutting down high level force feedback\n"); + LOG_INFO << "Force: Shutting down high level force feedback"; ForceEffectsClose(); for (int i = 0; i < DDIO_FF_MAXEFFECTS; i++) { @@ -214,7 +214,7 @@ void ForceShutdown(void) { ForceClose(); if (D3Force_init) { - mprintf(0, "Force: Shutting down Force Feedback System\n"); + LOG_INFO << "Force: Shutting down Force Feedback System"; ddio_ffb_Pause(kJoy1); } } @@ -229,7 +229,7 @@ void ForceRestart(void) { D3Force_pause = false; if (D3Force_init) { - mprintf(0, "Force: Restarting Force Feedback System\n"); + LOG_INFO << "Force: Restarting Force Feedback System"; ddio_ff_Acquire(kJoy1); ddio_ffb_Continue(kJoy1); @@ -262,7 +262,7 @@ void ForceRestart(void) { // ------------------------------------------------------------------ void ForceDisable(void) { if (D3Force_init) { - mprintf(0, "Force: Disabling Force Feedback System\n"); + LOG_INFO << "Force: Disabling Force Feedback System"; //@@ddio_ffb_Disable(kJoy1); D3Use_force_feedback = false; } @@ -275,7 +275,7 @@ void ForceDisable(void) { // ------------------------------------------------------------------ void ForceEnable(void) { if (D3Force_init) { - mprintf(0, "Force: Enabling Force Feedback System\n"); + LOG_INFO << "Force: Enabling Force Feedback System"; //@@ddio_ffb_Enable(kJoy1); D3Use_force_feedback = true; } diff --git a/Descent3/DllWrappers.cpp b/Descent3/DllWrappers.cpp index 7e5628a7..a21c438e 100644 --- a/Descent3/DllWrappers.cpp +++ b/Descent3/DllWrappers.cpp @@ -16,28 +16,20 @@ * along with this program. If not, see . */ -#include -#include - #include "DllWrappers.h" #include "pserror.h" #include "cfile.h" -#include "gamefont.h" #include "grdefs.h" #include "descent.h" -#include "ddio.h" -#include "d3movie.h" -#include "program.h" #include "object.h" -#include "objinit.h" #include "player.h" +#include "log.h" #include "newui.h" #include "hlsoundlib.h" #include "appdatabase.h" #include "attach.h" #include "game.h" #include "demofile.h" -#include "pilot.h" #include "audiotaunts.h" #include "ship.h" #include "hud.h" @@ -114,7 +106,7 @@ void SetObjectDeadFlagDLL(object *obj, bool tell_clients_to_remove, bool tell_cl void assertdll(int x, const char *expression, const char *file, int line) { #ifndef RELEASE if (!(unsigned)(x)) { - mprintf(0, "Assertion failed (%s) in %s line %d.\n", expression, file, line); + LOG_ERROR.printf("Assertion failed (%s) in %s line %d.", expression, file, line); if (Debug_break) DEBUG_BREAK(); else diff --git a/Descent3/Game2DLL.cpp b/Descent3/Game2DLL.cpp index 5b5304b9..229aa581 100644 --- a/Descent3/Game2DLL.cpp +++ b/Descent3/Game2DLL.cpp @@ -16,6 +16,8 @@ * along with this program. If not, see . */ +#include + #include "pstypes.h" #include "pserror.h" #include "game.h" @@ -24,7 +26,7 @@ #include "object.h" #include "terrain.h" #include "player.h" -#include "mono.h" +#include "log.h" #include "hud.h" #include "Inventory.h" #include "multi_server.h" @@ -36,7 +38,6 @@ #include "module.h" #include "localization.h" #include "weapon.h" -#include "voice.h" #include "gametexture.h" #include "Mission.h" #include "damage.h" @@ -47,7 +48,6 @@ #include "gameloop.h" #include "gamesequence.h" #include "dedicated_server.h" -#include "attach.h" #include "PilotPicsAPI.h" #include "vclip.h" #include "osiris_dll.h" @@ -62,8 +62,6 @@ #include "ObjScript.h" #include "args.h" -#include - void SelectNextCameraView(int window); #define NUM_CAMERA_VIEWS 3 extern int Camera_view_mode[NUM_CAMERA_VIEWS]; @@ -556,7 +554,7 @@ void CloseGameModule(module *mod) { if (Multi_game_dll_name[0] != '\0') { // Try deleting the file now! if (!ddio_DeleteFile(Multi_game_dll_name)) { - mprintf(0, "Couldn't delete the tmp dll"); + LOG_WARNING << "Couldn't delete the tmp dll"; } } mod->handle = NULL; @@ -591,7 +589,7 @@ bool InitGameModule(const char *name, module *mod) { } // Copy the DLL if (!cf_CopyFile(tmp_dll_name, dll_name)) { - mprintf(0, "DLL copy failed!\n"); + LOG_WARNING << "DLL copy failed!"; return false; } strcpy(Multi_game_dll_name, tmp_dll_name); @@ -600,7 +598,7 @@ loaddll: mod_GetLastError(); if (!mod_LoadModule(mod, tmp_dll_name)) { int err = mod_GetLastError(); - mprintf(0, "You are missing the DLL %s!\n", name); + LOG_WARNING.printf("You are missing the DLL %s!", name); return false; } return true; @@ -639,7 +637,7 @@ int LoadGameDLL(const char *name, int num_teams_to_use) { num_teams_to_use = 1; } } - mprintf(0, "Loading '%s', setting up for %d teams\n", name, num_teams_to_use); + LOG_DEBUG.printf("Loading '%s', setting up for %d teams", name, num_teams_to_use); if (!InitGameModule(name, &GameDLLHandle)) return 0; @@ -648,7 +646,7 @@ int LoadGameDLL(const char *name, int num_teams_to_use) { DLLGameInit = (DLLGameInit_fp)mod_GetSymbol(&GameDLLHandle, "DLLGameInit", 12); if (!DLLGameInit) { int err = mod_GetLastError(); - mprintf(0, "Couldn't get a handle to the dll function DLLGameInit!\n"); + LOG_FATAL << "Couldn't get a handle to the dll function DLLGameInit!"; Int3(); FreeGameDLL(); return 0; @@ -658,7 +656,7 @@ int LoadGameDLL(const char *name, int num_teams_to_use) { DLLGameCall = (DLLGameCall_fp)mod_GetSymbol(&GameDLLHandle, "DLLGameCall", 8); if (!DLLGameCall) { int err = mod_GetLastError(); - mprintf(0, "Couldn't get a handle to the dll function DLLGameCall!\n"); + LOG_FATAL << "Couldn't get a handle to the dll function DLLGameCall!"; Int3(); FreeGameDLL(); return 0; @@ -668,7 +666,7 @@ int LoadGameDLL(const char *name, int num_teams_to_use) { DLLGameClose = (DLLGameClose_fp)mod_GetSymbol(&GameDLLHandle, "DLLGameClose", 0); if (!DLLGameClose) { int err = mod_GetLastError(); - mprintf(0, "Couldn't get a handle to the dll function DLLGameClose!\n"); + LOG_FATAL << "Couldn't get a handle to the dll function DLLGameClose!"; Int3(); FreeGameDLL(); return 0; @@ -678,7 +676,7 @@ int LoadGameDLL(const char *name, int num_teams_to_use) { DLLGetGameInfo = (DLLGetGameInfo_fp)mod_GetSymbol(&GameDLLHandle, "DLLGetGameInfo", 4); if (!DLLGetGameInfo) { int err = mod_GetLastError(); - mprintf(0, "Couldn't get a handle to the dll function DLLGetGameInfo!\n"); + LOG_FATAL << "Couldn't get a handle to the dll function DLLGetGameInfo!"; Int3(); FreeGameDLL(); return 0; @@ -697,7 +695,7 @@ int LoadGameDLL(const char *name, int num_teams_to_use) { DLLGameInit((int *)api_fp, &ok, num_teams_to_use); if (!ok) { // The DLL said no to the load - mprintf(0, "DLLGameInit returned false, couldn't init DLL\n"); + LOG_FATAL << "DLLGameInit returned false, couldn't init DLL"; Int3(); FreeGameDLL(); return 0; @@ -709,10 +707,7 @@ int LoadGameDLL(const char *name, int num_teams_to_use) { // If this function is called than the DLL is to be closed, because there was an error running it // if reason is not NULL than that is the reason why void DLLFatalError(const char *reason) { - mprintf(0, "============================\n"); - mprintf(0, "= DLL Fatal Error =\n"); - mprintf(0, "============================\n"); - mprintf(0, "%s\n", (reason) ? reason : ""); + LOG_FATAL.printf("DLL Fatal Error: %s", (reason) ? reason : ""); Netgame.flags |= NF_EXIT_NOW; Int3(); } @@ -764,7 +759,7 @@ bool GetDLLGameInfo(const char *name, tDLLOptions *options) { modGetGameInfo = (DLLGetGameInfo_fp)mod_GetSymbol(&mod, "DLLGetGameInfo", 4); if (!modGetGameInfo) { int err = mod_GetLastError(); - mprintf(0, "Couldn't get a handle to the dll function DLLGetGameInfo!\n"); + LOG_FATAL << "Couldn't get a handle to the dll function DLLGetGameInfo!"; Int3(); CloseGameModule(&mod); return false; @@ -780,7 +775,7 @@ int GetDLLRequirements(const char *name, char *requirements, int buflen) { ASSERT(requirements); tDLLOptions opt; if (!GetDLLGameInfo(name, &opt)) { - mprintf(0, "Unable to get %s's requirements\n", name); + LOG_WARNING.printf("Unable to get %s's requirements", name); return -1; } strncpy(requirements, opt.requirements, buflen - 1); @@ -788,7 +783,7 @@ int GetDLLRequirements(const char *name, char *requirements, int buflen) { uint32_t opt_req_len = strlen(opt.requirements); if (opt_req_len > strlen(requirements)) { // too small of a buffer! - mprintf(0, "Too small of a buffer to fill in all requirements!...need %d\n", opt_req_len + 1); + LOG_FATAL.printf("Too small of a buffer to fill in all requirements!...need %d", opt_req_len + 1); Int3(); // cut off last requirement (which is shortened) char *p = strrchr(requirements, ','); diff --git a/Descent3/GameLoop.cpp b/Descent3/GameLoop.cpp index 5f91a03d..c7d57ce1 100644 --- a/Descent3/GameLoop.cpp +++ b/Descent3/GameLoop.cpp @@ -807,7 +807,7 @@ #include "render.h" #include "descent.h" #include "slew.h" -#include "mono.h" +#include "log.h" #include "doorway.h" #include "weapon.h" #include "hlsoundlib.h" @@ -1119,12 +1119,12 @@ void ProcessButtons() { PollControls(); if (Controller->get_joy_raw_values(&x, &y) || Controller->get_mouse_raw_values(&x, &y)) { // death. - mprintf(0, "here?"); + LOG_DEBUG << "here?"; if (Total_time_dead < DEATH_RESPAWN_TIME) return; - mprintf(0, "Respawning joystick death. Death time=%f\n", Total_time_dead); + LOG_DEBUG.printf("Respawning joystick death. Death time=%f", Total_time_dead); if (Game_mode & GM_MULTI) MultiSendEndPlayerDeath(); // couldn't this be called from withing EndPlayerDeath()? @@ -1161,7 +1161,7 @@ void ProcessGuidebotKeys(int key) { object *buddy = ObjGet(Buddy_handle[Player_num]); if (!buddy || buddy->type != OBJ_ROBOT) { // not out of the ship - mprintf(0, "Guidebot: mrmph mmrump..mrmph...LET ME OUT OF YOUR SHIP!\n"); + LOG_DEBUG << "Guidebot: mrmph mmrump..mrmph...LET ME OUT OF YOUR SHIP!"; return; } int command_id = -1; @@ -1304,7 +1304,7 @@ void ProcessNormalKey(int key) { if (Game_mode & GM_MULTI) { char str[80]; - mprintf(0, "Printing message %d!\n", index); + LOG_DEBUG.printf("Printing message %d!", index); int save_do = Doing_input_message; int save_len = HudInputMessageLen; @@ -1330,7 +1330,7 @@ void ProcessNormalKey(int key) { case KEY_PRINT_SCREEN: case KEY_SHIFTED + KEY_PRINT_SCREEN: - mprintf(0, "Doing screenshot!\n"); + LOG_DEBUG << "Doing screenshot!"; DoScreenshot(); return; @@ -1942,7 +1942,7 @@ void ProcessTestKeys(int key) { for (i = 0; i < MAX_OBJECTS; i++) { if (Objects[i].type == OBJ_DUMMY && Objects[i].dummy_type == OBJ_POWERUP && Objects[i].id == id) { // here's a betty - mprintf(0, "Killing a betty\n"); + LOG_DEBUG << "Killing a betty"; SetObjectDeadFlag(&Objects[i], true); } } @@ -1958,64 +1958,64 @@ void ProcessTestKeys(int key) { Game_update_attach = 1 - Game_update_attach; if (Game_update_attach) { - mprintf(0, "Update attach on\n"); + LOG_DEBUG << "Update attach on"; } else { - mprintf(0, "Update attach off\n"); + LOG_DEBUG << "Update attach off"; } } break; case KEY_PAD1: { Game_do_flying_sim = 1 - Game_do_flying_sim; if (Game_do_flying_sim) { - mprintf(0, "Game_do_flying_sim on\n"); + LOG_DEBUG << "Game_do_flying_sim on"; } else { - mprintf(0, "Game_do_flying_sim off\n"); + LOG_DEBUG << "Game_do_flying_sim off"; } } break; case KEY_PAD2: { Game_do_walking_sim = 1 - Game_do_walking_sim; if (Game_do_walking_sim) { - mprintf(0, "Game_do_walking_sim on\n"); + LOG_DEBUG << "Game_do_walking_sim on"; } else { - mprintf(0, "Game_do_walking_sim off\n"); + LOG_DEBUG << "Game_do_walking_sim off"; } } break; case KEY_PAD3: { Game_do_vis_sim = 1 - Game_do_vis_sim; if (Game_do_vis_sim) { - mprintf(0, "Game_do_vis_sim on\n"); + LOG_DEBUG << "Game_do_vis_sim on"; } else { - mprintf(0, "Game_do_vis_sim off\n"); + LOG_DEBUG << "Game_do_vis_sim off"; } } break; case KEY_PAD4: { Game_do_ai_movement = 1 - Game_do_ai_movement; if (Game_do_ai_movement) { - mprintf(0, "Game_do_ai_movement on\n"); + LOG_DEBUG << "Game_do_ai_movement on"; } else { - mprintf(0, "Game_do_ai_movement off\n"); + LOG_DEBUG << "Game_do_ai_movement off"; } } break; case KEY_PAD5: { Game_do_ai_vis = 1 - Game_do_ai_vis; if (Game_do_ai_vis) { - mprintf(0, "Game_do_ai_vis on\n"); + LOG_DEBUG << "Game_do_ai_vis on"; } else { - mprintf(0, "Game_do_ai_vis off\n"); + LOG_DEBUG << "Game_do_ai_vis off"; } } break; case KEY_PAD6: { if (AI_debug_robot_do) { AI_debug_robot_do = false; - mprintf(0, "AI Debug Info Off\n"); + LOG_DEBUG << "AI Debug Info Off"; } else { AI_debug_robot_do = true; - mprintf(0, "AI Debug Info On\n"); + LOG_DEBUG << "AI Debug Info On"; } } break; @@ -2048,7 +2048,7 @@ void ProcessTestKeys(int key) { if (!killed_something) AddHUDMessage("Nothing to kill!"); else - mprintf(0, "Killed %d objects of type %s!\n", killed_count, Object_info[Objects[i].id].name); + LOG_DEBUG.printf("Killed %d objects of type %s!", killed_count, Object_info[Objects[i].id].name); } break; /* ************************************************** @@ -2158,25 +2158,25 @@ void ProcessTestKeys(int key) { switch (fate) { case HIT_NONE: - mprintf(0, "Hit nothing\n"); + LOG_DEBUG << "Hit nothing"; break; case HIT_WALL: - mprintf(0, "Hit wall\n"); + LOG_DEBUG << "Hit wall"; break; case HIT_OBJECT: - mprintf(0, "Hit Object %d\n", hit_info.hit_object); + LOG_DEBUG.printf("Hit Object %d", hit_info.hit_object); break; case HIT_TERRAIN: - mprintf(0, "Hit Terrain %d\n", CELLNUM(hit_info.hit_room)); + LOG_DEBUG.printf("Hit Terrain %d", CELLNUM(hit_info.hit_room)); break; case HIT_OUT_OF_TERRAIN_BOUNDS: - mprintf(0, "Hit nothing: Leaving Terrain\n"); + LOG_DEBUG << "Hit nothing: Leaving Terrain"; break; case HIT_SPHERE_2_POLY_OBJECT: - mprintf(0, "Hit Poly_object\n"); + LOG_DEBUG << "Hit Poly_object"; break; default: - mprintf(0, "Hit %d not printed, add to list\n", fate); + LOG_DEBUG.printf("Hit %d not printed, add to list", fate); break; } @@ -2209,9 +2209,9 @@ void ProcessTestKeys(int key) { case KEY_F9: { vector vec = Player_object->pos + (Player_object->orient.fvec * 20); if (BSPRayOccluded(&Player_object->pos, &vec, MineBSP.root)) - mprintf(0, "Occluded!\n"); + LOG_DEBUG << "Occluded!"; else - mprintf(0, "NOT occluded!\n"); + LOG_DEBUG << "NOT occluded!"; } break; case KEY_F10: @@ -2263,7 +2263,7 @@ void ProcessTestKeys(int key) { float t = 5.0f; int m = 5; - mprintf(0, "Matcen alive!\n"); + LOG_DEBUG << "Matcen alive!"; vector centerPt = Player_object->pos + (Player_object->orient.fvec * 2.0f); Matcen[m_id]->SetAttachType(MT_ROOM); @@ -2283,7 +2283,7 @@ void ProcessTestKeys(int key) { Matcen[m_id]->SetStatus(MSTAT_ACTIVE | MSTAT_RANDOM_PROD_ORDER, true); } else { - mprintf(0, "Nope!\n"); + LOG_DEBUG << "Nope!"; } } break; @@ -2338,17 +2338,17 @@ void ProcessTestKeys(int key) { Game_show_portal_vis_pnts = 1 - Game_show_portal_vis_pnts; - mprintf(0, "Vis info for room %d\n", Player_object->roomnum); + LOG_DEBUG.printf("Vis info for room %d", Player_object->roomnum); for (i = 0; i <= Highest_room_index; i++) { if (BOA_IsVisible(i, Player_object->roomnum)) { - mprintf(0, "%d can see you in %d\n", i, Player_object->roomnum); + LOG_DEBUG.printf("%d can see you in %d", i, Player_object->roomnum); } } for (i = Highest_room_index + 1; i <= Highest_room_index + 8; i++) { if (BOA_IsVisible(i, Player_object->roomnum)) { - mprintf(0, "Terrain %d can see you in %d\n", i - Highest_room_index - 1, Player_object->roomnum); + LOG_DEBUG.printf("Terrain %d can see you in %d", i - Highest_room_index - 1, Player_object->roomnum); } } } @@ -2745,10 +2745,10 @@ void CalcFrameTime(void) { last_timer = current_timer; if (Min_frametime > Frametime) { - mprintf(0, "This was the fastest frame yet!\n"); + LOG_DEBUG << "This was the fastest frame yet!"; Min_frametime = Frametime - Demo_frame_ofs; } else if (Max_frametime < Frametime) { - mprintf(0, "This was the slowest frame yet!\n"); + LOG_DEBUG << "This was the slowest frame yet!"; Max_frametime = Frametime - Demo_frame_ofs; } Frames_counted++; @@ -2759,7 +2759,7 @@ void CalcFrameTime(void) { void InitFrameTime(void) { if (timer_paused) { - mprintf(1, "Timer paused in InitFrameTime()\n"); + LOG_DEBUG << "Timer paused in InitFrameTime()"; } last_timer = timer_GetMSTime(); timer_paused = 0; @@ -2767,7 +2767,7 @@ void InitFrameTime(void) { // Pauses game void PauseGame() { - mprintf(0, "Game paused.\n"); + LOG_INFO << "Game paused."; Game_paused = true; D3MusicPause(); @@ -2781,7 +2781,7 @@ void ResumeGame() { Game_paused = false; Sound_system.ResumeSounds(); D3MusicResume(); - mprintf(0, "Game resumed.\n"); + LOG_INFO << "Game resumed."; } // Data for terrain sound @@ -2873,7 +2873,7 @@ void GameFrame(void) { bool is_game_idle = !Descent->active(); if (Tracking_FVI) { - mprintf(0, "Beginning frame!\n"); + LOG_DEBUG << "Beginning frame!"; } // Begin Gameloop stuff @@ -2894,12 +2894,6 @@ void GameFrame(void) { static float netstat_time = 0; nw_GetNetworkStats(&netstat); - mprintf_at(5, 0, 0, "TCP/IP Network Stats:"); - mprintf_at(5, 1, 0, "TCP: tx: %d/%d rtx: %d/%d rx: %d/%d", netstat.tcp_total_packets_sent, - netstat.tcp_total_bytes_sent, netstat.tcp_total_packets_resent, netstat.tcp_total_bytes_resent, - netstat.tcp_total_packets_rec, netstat.tcp_total_bytes_rec); - mprintf_at(5, 2, 0, "UDP: tx: %d/%d rx: %d/%d", netstat.udp_total_packets_sent, netstat.udp_total_bytes_sent, - netstat.udp_total_packets_rec, netstat.udp_total_bytes_rec); if (!netstat_init) { netstat_time = timer_GetTime(); @@ -2921,9 +2915,6 @@ void GameFrame(void) { udp_rx = ((float)(netstat.udp_total_bytes_rec - old_netstat.udp_total_bytes_rec)) / time_diff; udp_tx = ((float)(netstat.udp_total_bytes_sent - old_netstat.udp_total_bytes_sent)) / time_diff; - mprintf_at(5, 3, 0, "TCP/s: TX: % 5.1f RTX: % 5.1f RX: % 5.1f", tcp_tx, tcp_rtx, tcp_rx); - mprintf_at(5, 4, 0, "UDP/s: TX: % 5.1f RX: % 5.1f", udp_tx, udp_rx); - old_netstat = netstat; netstat_time = newt; } @@ -3075,7 +3066,6 @@ void GameFrame(void) { current_timer = timer_GetMSTime(); if ((current_timer - last_timer) < Min_allowed_frametime) { sleeptime = (uint32_t)Min_allowed_frametime - (current_timer - last_timer); - // mprintf(0,"Sleeping for %d ms\n",sleeptime); D3::ChronoTimer::SleepMS(sleeptime); } @@ -3117,24 +3107,8 @@ void GameFrame(void) { #ifdef USE_RTP RTP_RECORDVALUE(frame_time, Frametime); rtp_RecordFrame(); - - /* - if (frame_info.ai_time>.1) - mprintf(0,"NOTE: AI frame took longer than .1 seconds! %f\n",frame_info.ai_time); - if (frame_info.render_time>.1) - mprintf(0,"NOTE: Render frame took longer than .1 seconds! %f\n",frame_info.render_time); - if (frame_info.multi_time>.1) - mprintf(0,"NOTE: Multi frame took longer than .1 seconds! %f\n",frame_info.multi_time); - if (frame_info.obj_time>.1) - mprintf(0,"NOTE: Object frame took longer than .1 seconds! %f\n",frame_info.obj_time); - */ #endif - mprintf_at(1, 0, 39, "Pn %05d, L %05d", Physics_normal_counter, Physics_normal_looping_counter); - mprintf_at(1, 1, 39, "Pw %05d, L %05d", Physics_walking_counter, Physics_walking_looping_counter); - mprintf_at(1, 2, 39, "Pv %05d", Physics_vis_counter); - mprintf_at(1, 3, 39, "Fc %05d, R %05d", FVI_counter, FVI_room_counter); - #ifdef D3_FAST if (FrameCount > 20) SetFunctionMode(MENU_MODE); @@ -3157,7 +3131,7 @@ void GameFrame(void) { #endif if (Tracking_FVI) { - mprintf(0, "Ending frame!\n"); + LOG_DEBUG << "Ending frame!"; } if (!is_game_idle) { diff --git a/Descent3/Inventory.cpp b/Descent3/Inventory.cpp index b03afe5a..d89cc164 100644 --- a/Descent3/Inventory.cpp +++ b/Descent3/Inventory.cpp @@ -290,7 +290,7 @@ #include "Inventory.h" -#include "mono.h" +#include "log.h" #include "player.h" #include "pserror.h" #include "objinfo.h" @@ -311,7 +311,6 @@ // constructor Inventory::Inventory(void) { - // mprintf(0,"Inventory System: Initialize\n"); root = NULL; count = 0; pos = NULL; @@ -395,13 +394,13 @@ void Inventory::Reset(bool in_game, int reset_stage) { bool Inventory::AddObject(int object_handle, int flags, const char *description) { // make sure we can fit another object if (count >= MAX_UNIQUE_INVEN_ITEMS) { - mprintf(0, "Max unique count hit on add to inventory\n"); + LOG_DEBUG << "Max unique count hit on add to inventory"; return false; } object *obj = ObjGet(object_handle); if (!obj) { - mprintf(0, "INVEN: Invalid object trying to be added\n"); + LOG_DEBUG << "INVEN: Invalid object trying to be added"; return false; } @@ -503,12 +502,12 @@ bool Inventory::AddObject(int object_handle, int flags, const char *description) bool Inventory::Add(int type, int id, object *parent, int aux_type, int aux_id, int flags, const char *description) { // make sure we can fit another object if (count >= MAX_UNIQUE_INVEN_ITEMS) { - mprintf(0, "Max unique count hit on add to inventory\n"); + LOG_WARNING << "Max unique count hit on add to inventory"; return false; } if ((type < 0) || (type == OBJ_NONE)) { - mprintf(0, "Invalid type on add to inventory\n"); + LOG_WARNING << "Invalid type on add to inventory"; return false; } @@ -528,7 +527,7 @@ bool Inventory::Add(int type, int id, object *parent, int aux_type, int aux_id, bool Inventory::AddCounterMeasure(int id, int aux_type, int aux_id, int flags, const char *description) { // make sure we can fit another object if (count >= MAX_UNIQUE_INVEN_ITEMS) { - mprintf(0, "Hit max unique in counter measure add\n"); + LOG_WARNING << "Hit max unique in counter measure add"; return false; } @@ -560,7 +559,6 @@ bool Inventory::AddCounterMeasure(int id, int aux_type, int aux_id, int flags, c } else { // there is an item of that type/id already, just increase its count newnode->count++; - // mprintf(0,"Inventory: Item #%d (%s) Count increased to %d\n",count,newnode->name,newnode->count); } } @@ -596,7 +594,6 @@ bool Inventory::AddCounterMeasure(int id, int aux_type, int aux_id, int flags, c } count++; - // mprintf(0,"Inventory: Item #%d Added Countermeasure (%s) ID=%d\n",count,newnode->name,newnode->id); } pos = newnode; @@ -744,13 +741,13 @@ bool Inventory::Use(int type, int id, object *parent) { // if type is OBJ_WEAPON then it's a countermeasure if (type == OBJ_WEAPON) { - mprintf(0, "CounterMeasures: Use\n"); + LOG_DEBUG << "CounterMeasures: Use"; // countermeasure CreateCountermeasureFromObject(player, id); Remove(node->type, node->id); ret = true; } else { - mprintf(0, "Inventory: Use\n"); + LOG_DEBUG << "Inventory: Use"; // regular // recreate the object int objnum; @@ -838,12 +835,11 @@ bool Inventory::Use(int type, int id, object *parent) { // sends a request to the server to use a particular item in the inventory void Inventory::SendRequestToServerToUse(int type, int id) { - // mprintf(0,"Sending request to server for T=%d ID=%d\n",type,id); inven_item *node = FindItem(type, id); if (node) { MultiSendClientInventoryUseItem(type, id); } else { - mprintf(0, "Sorry couldn't find it in your inventory\n"); + LOG_DEBUG << "Sorry couldn't find it in your inventory"; } } @@ -899,7 +895,7 @@ bool Inventory::Remove(int type, int id) { RemoveNode(node); } else { node->count--; - mprintf(0, "Inventory System: Remove\n"); + LOG_DEBUG << "Inventory System: Remove"; if (node->count <= 0) RemoveNode(node); @@ -969,7 +965,6 @@ inven_item *Inventory::FindItem(int type, int id) { while (counter) { if ((current->type == type) && (current->id == id)) // we got a match { - // mprintf(0,"Inventory: FindItem found Type(%d) ID(%d)\n",type,id); return current; } @@ -977,19 +972,16 @@ inven_item *Inventory::FindItem(int type, int id) { counter--; } - // mprintf(0,"Inventory: FindItem couldn't find Type(%d) ID(%d)\n",type,id); return NULL; } // returns how many items are in the inventory int Inventory::Size(void) { - // mprintf(0,"Inventory System: Size\n"); return count; } // returns true if there is an item in the inventory with the given type/id bool Inventory::CheckItem(int type, int id) { - // mprintf(0,"Inventory System: CheckItem\n"); if (FindItem(type, id)) return true; else @@ -1020,7 +1012,7 @@ int Inventory::SaveInventory(CFILE *file) { object *obj = ObjGet(curr->type); ASSERT(obj); if (!obj) { - mprintf(0, "Invalid object saving inventory\n"); + LOG_DEBUG << "Invalid object saving inventory"; curr = curr->next; num_items--; pos_count++; @@ -1089,7 +1081,7 @@ int Inventory::ReadInventory(CFILE *file) { object *obj = ObjGet(t); ASSERT(obj); if (!obj) { - mprintf(0, "Invalid object restoring inventory\n"); + LOG_WARNING << "Invalid object restoring inventory"; // skip this object cf_ReadInt(file); cf_ReadInt(file); @@ -1240,7 +1232,6 @@ bool Inventory::GetAuxPosTypeID(int &type, int &id) { // returns the description of the item at the current position char *Inventory::GetPosDescription(void) { - // mprintf(0,"Getting Pos Description (%s)\n",pos->description); if (!pos) return NULL; return pos->description; @@ -1262,7 +1253,6 @@ char *Inventory::GetPosIconName(void) { // returns the count of the item at the current position int Inventory::GetPosCount(void) { - // mprintf(0,"Getting Pos Count (%d)\n",pos->count); if (!pos) return 0; @@ -1293,7 +1283,6 @@ bool Inventory::GetPosInfo(uint16_t &iflags, int &flags) { // goes to a position in the list void Inventory::GotoPos(int newpos) { - // mprintf(0,"Going to Pos (%d)\n",newpos); ResetPos(); int i; for (i = 0; i < newpos; i++) { @@ -1538,7 +1527,7 @@ void InventoryRemoveObject(int objhandle) { for (int i = 0; i < MAX_PLAYERS; i++) { if (Players[i].inventory.CheckItem(objhandle, -1)) { // this player has it!! - mprintf(0, "INVEN: Removing dead object from %d\n", i); + LOG_DEBUG.printf("INVEN: Removing dead object from %d", i); Players[i].inventory.Remove(objhandle, -1); return; } diff --git a/Descent3/LoadLevel.cpp b/Descent3/LoadLevel.cpp index cee185ac..48852b26 100644 --- a/Descent3/LoadLevel.cpp +++ b/Descent3/LoadLevel.cpp @@ -1237,29 +1237,17 @@ * $NoKeywords: $ */ -#ifdef NEWEDITOR -#include "..\neweditor\stdafx.h" -#endif - -#include -#include -#include +#include +#include +#include #include #include "LoadLevel.h" #include "cfile.h" - #include "descent.h" #include "object.h" #include "gametexture.h" - -#ifdef NEWEDITOR -#include "..\neweditor\ned_gametexture.h" -#include "..\neweditor\ned_Object.h" -#include "editor\Erooms.h" -#endif - #include "trigger.h" #include "doorway.h" #include "terrain.h" @@ -1270,6 +1258,7 @@ #include "objinfo.h" #include "lightmap.h" #include "lightmap_info.h" +#include "log.h" #include "findintersection.h" #include "polymodel.h" #include "object_lighting.h" @@ -1291,7 +1280,6 @@ #include "levelgoal.h" #include "aiambient.h" #include "args.h" -#include "ddio.h" #include "ship.h" #include "fireball.h" #include "sounds.h" @@ -1299,17 +1287,22 @@ #include "bnode.h" #include "localization.h" -#ifdef EDITOR -#include "editor\d3edit.h" -#include "editor\HFile.h" -#include "editor\Erooms.h" -#include "editor\moveworld.h" -#include "editor\editor_lighting.h" -#endif - #ifdef NEWEDITOR +#include "ddio.h" +#include "../neweditor/stdafx.h" +#include "../neweditor/ned_gametexture.h" +#include "../neweditor/ned_Object.h" #include "..\neweditor\neweditor.h" -#include "..\neweditor\globals.h" +#include "../neweditor/globals.h" +#include "editor/Erooms.h" +#endif +#ifdef EDITOR +#include "ddio.h" +#include "editor/d3edit.h" +#include "editor/HFile.h" +#include "editor/Erooms.h" +#include "editor/moveworld.h" +#include "editor/editor_lighting.h" #endif MD5 *Level_md5 = NULL; @@ -1551,7 +1544,7 @@ void ConvertObject(int *type, int *id) { ASSERT(object_convert[convert_to].id >= 0); if (object_convert[convert_to].id >= 0) { - mprintf(0, "LEVELLOAD: Converting: '%s' -> '%s'\n", object_convert[i].name, object_convert[convert_to].name); + LOG_DEBUG.printf("LEVELLOAD: Converting: '%s' -> '%s'", object_convert[i].name, object_convert[convert_to].name); new_id = object_convert[convert_to].id; new_type = object_convert[convert_to].type; @@ -1796,7 +1789,7 @@ int ReadObject(CFILE *ifile, object *objp, int handle, int fileversion) { num_models = cf_ReadByte(ifile); if (pm->n_models != num_models) { model_changed = 1; - mprintf(0, "Polymodel %s has changed since this level was lit!\n", pm->name); + LOG_DEBUG.printf("Polymodel %s has changed since this level was lit!", pm->name); } if (!model_changed) @@ -1885,7 +1878,7 @@ int ReadObject(CFILE *ifile, object *objp, int handle, int fileversion) { } if (clear_lightmaps) { - mprintf(0, "Freeing lightmaps because model %s has changed since this level was saved!\n", pm->name); + LOG_DEBUG.printf("Freeing lightmaps because model %s has changed since this level was saved!\n", pm->name); ClearObjectLightmaps(objp); } } @@ -2211,7 +2204,7 @@ void RemoveDegenerateFaces(room *rp) { face *fp = &rp->faces[f]; if ((fp->normal.x == 0.0) && (fp->normal.y == 0.0) && (fp->normal.z == 0.0)) { - mprintf(0, "Deleting face %d from room %d\n", f, ROOMNUM(rp)); + LOG_DEBUG.printf("Deleting face %d from room %d", f, ROOMNUM(rp)); DeleteRoomFace(rp, f); n_degenerate_faces_removed++; } @@ -2499,7 +2492,7 @@ int ReadRoom(CFILE *ifile, room *rp, int version) { // Check for bad normal if (!t) { - mprintf(1, "WARNING: Room %d face %d has bad normal!\n", rp - Rooms, i); + LOG_WARNING.printf("WARNING: Room %d face %d has bad normal!", rp - Rooms, i); } } @@ -2672,7 +2665,7 @@ void ReadNewLightmapChunk(CFILE *fp, int version) { nummaps = cf_ReadInt(fp); - mprintf(0, "Reading %d unique lightmaps\n", nummaps); + LOG_DEBUG.printf("Reading %d unique lightmaps", nummaps); for (i = 0; i < nummaps; i++) { int w, h; @@ -3047,7 +3040,7 @@ void ReadBOAChunk(CFILE *fp, int version) { if (version < 62) { cfseek(fp, sizeof(int16_t) * max_rooms * max_rooms, SEEK_CUR); - mprintf(0, "We will need to remake boa. New cost structure added\n"); + LOG_DEBUG << "We will need to remake boa. New cost structure added"; BOA_AABB_checksum = BOA_mine_checksum = 0; } else { max_path_portals = cf_ReadInt(fp); @@ -3062,7 +3055,7 @@ void ReadBOAChunk(CFILE *fp, int version) { cfseek(fp, max_rooms * sizeof(float), SEEK_CUR); } - mprintf(0, "We will need to remake boa. Data size changed\n"); + LOG_DEBUG << "We will need to remake boa. Data size changed"; BOA_AABB_checksum = BOA_mine_checksum = 0; } else { for (i = 0; i <= max_rooms; i++) { @@ -3081,11 +3074,9 @@ void ReadBOAChunk(CFILE *fp, int version) { BOA_num_terrain_regions = cf_ReadInt(fp); if (version < 112) { - mprintf(0, "We will need to remake boa.\n"); + LOG_DEBUG << "We will need to remake boa."; BOA_AABB_checksum = BOA_mine_checksum = 0; } else { - int i, j; - for (i = 0; i < BOA_num_terrain_regions; i++) { BOA_num_connect[i] = cf_ReadInt(fp); @@ -3732,7 +3723,8 @@ int LoadLevel(char *filename, void (*cb_fn)(const char *, int, int)) { cf_ReadBytes((uint8_t *)chunk_name, 4, ifile); chunk_start = cftell(ifile); chunk_size = cf_ReadInt(ifile); - mprintf(0, "Chunk: %c%c%c%c, size=%d\n", chunk_name[0], chunk_name[1], chunk_name[2], chunk_name[3], chunk_size); + LOG_DEBUG.printf("Chunk: %c%c%c%c, size=%d", + chunk_name[0], chunk_name[1], chunk_name[2], chunk_name[3], chunk_size); if (ISCHUNK(CHUNK_TEXTURE_NAMES)) ReadTextureList(ifile); @@ -3772,7 +3764,7 @@ int LoadLevel(char *filename, void (*cb_fn)(const char *, int, int)) { roomnum = (version >= 96) ? cf_ReadShort(ifile) : i; ReadRoom(ifile, &Rooms[roomnum], version); } - mprintf(1, "%d degenerate faces removed\n", n_degenerate_faces_removed); + LOG_DEBUG.printf("%d degenerate faces removed", n_degenerate_faces_removed); Highest_room_index = roomnum; ASSERT(Highest_room_index < MAX_ROOMS); @@ -3835,7 +3827,8 @@ int LoadLevel(char *filename, void (*cb_fn)(const char *, int, int)) { Objects[objnum].type = OBJ_NONE; // kill the object } else { if (!ROOMNUM_OUTSIDE(roomnum) && Rooms[roomnum].flags & RF_EXTERNAL) { - mprintf(0, "Internal object %d linked to external room %d (type = %d)!!!\n", objnum, roomnum, Objects[objnum].type); + LOG_ERROR.printf("Internal object %d linked to external room %d (type = %d)!!!", + objnum, roomnum, Objects[objnum].type); if (Objects[objnum].type == OBJ_VIEWER) Objects[objnum].type = OBJ_NONE; // kill the object else { @@ -4036,7 +4029,8 @@ int LoadLevel(char *filename, void (*cb_fn)(const char *, int, int)) { } #endif // ifdef EDITOR else { // unknown chunk - mprintf(0, " Unknown chunk: %c%c%c%c, size=%d\n", chunk_name[0], chunk_name[1], chunk_name[2], chunk_name[3], chunk_size); + LOG_WARNING.printf(" Unknown chunk: %c%c%c%c, size=%d", + chunk_name[0], chunk_name[1], chunk_name[2], chunk_name[3], chunk_size); } // Go to end of chunk @@ -4047,7 +4041,7 @@ int LoadLevel(char *filename, void (*cb_fn)(const char *, int, int)) { } // try catch (cfile_error *cfe) { - mprintf(0, "Error reading: file = <%s>, error = \"%s\"\n", cfe->file->name, cfe->msg); + LOG_FATAL.printf("Error reading: file = <%s>, error = \"%s\"", cfe->file->name, cfe->msg); ASSERT(cfe->read_write == CFE_READING); #if (defined(EDITOR) || defined(NEWEDITOR)) if (GetFunctionMode() == EDITOR_MODE) @@ -4144,7 +4138,6 @@ int LoadLevel(char *filename, void (*cb_fn)(const char *, int, int)) { #ifndef NEWEDITOR CountDataToPageIn(); #endif - // mprintf(0,"%d bytes of data to page in...\n",total); end_loadlevel: #ifdef EDITOR @@ -4161,7 +4154,7 @@ end_loadlevel: } // Debug log the current sum - mprintf(0, "End of load level checksum = %s\n", GetCurrentSumString()); + LOG_INFO.printf("End of load level checksum = %s", GetCurrentSumString()); // Done return retval; } @@ -4230,7 +4223,7 @@ int WriteObject(CFILE *ofile, object *objp) { // If there is lightmap data for this object, write it out. if (objp->lighting_render_type == LRT_LIGHTMAPS) { if (objp->lm_object.used == 0) { - mprintf(0, "Warning: Object %d is set for lightmaps but has no lightmap data!\n", objp - Objects); + LOG_WARNING.printf("Warning: Object %d is set for lightmaps but has no lightmap data!", objp - Objects); cf_WriteByte(ofile, 0); } else { cf_WriteByte(ofile, 1); @@ -4302,7 +4295,7 @@ int WriteFace(CFILE *ofile, face *fp) { if ((fp->flags & FF_LIGHTMAP) && (fp->lmi_handle == BAD_LMI_INDEX || LightmapInfoRemap[fp->lmi_handle] == BAD_LMI_INDEX)) { fp->flags &= ~FF_LIGHTMAP; - mprintf(0, "Almost saved a bogus lightmap!\n"); + LOG_DEBUG << "Almost saved a bogus lightmap!"; } cf_WriteShort(ofile, fp->flags); @@ -4323,7 +4316,7 @@ int WriteFace(CFILE *ofile, face *fp) { if (fp->light_multiple == 186) { fp->light_multiple = 4; // Get Jason, I'm looking for this bug! Its safe to go past it, but I'm just on the lookout - mprintf(0, "Bogus light multiple detected...bashing!\n"); + LOG_DEBUG << "Bogus light multiple detected...bashing!"; } cf_WriteByte(ofile, fp->light_multiple); @@ -5305,7 +5298,7 @@ int SaveLevel(char *filename, bool f_save_room_AABB) { EndChunk(ofile, chunk_start_pos); } catch (cfile_error *cfe) { - mprintf(0, "Error writing: file = <%s>, msg = \"%s\"\n", cfe->file->name, cfe->msg); + LOG_FATAL.printf("Error writing: file = <%s>, msg = \"%s\"", cfe->file->name, cfe->msg); ASSERT(cfe->read_write == CFE_WRITING); EditorMessageBox("Error writing file %s: %s", cfe->file->name, cfe->msg); cfclose(ofile); @@ -5744,7 +5737,7 @@ char *LocalizeLevelName(char *level) { Localization_SetLanguage(LANGUAGE_ENGLISH); // Save the current language, then bash it to english if (!CreateStringTable("level_names.str", &english_names, &num_english_names)) { - mprintf(0, "Couldn't open level_names stringtable!\n"); + LOG_WARNING << "Couldn't open level_names stringtable!"; Localization_SetLanguage(save_lang); strcpy(local_name, level); return local_name; @@ -5754,7 +5747,7 @@ char *LocalizeLevelName(char *level) { Localization_SetLanguage(save_lang); if (!CreateStringTable("level_names.str", &local_names, &num_local_names)) { - mprintf(0, "Couldn't open level_names stringtable!\n"); + LOG_WARNING << "Couldn't open level_names stringtable!"; // destroy the english stringtable... DestroyStringTable(english_names, num_english_names); diff --git a/Descent3/Mission.cpp b/Descent3/Mission.cpp index b60cba98..1d200e23 100644 --- a/Descent3/Mission.cpp +++ b/Descent3/Mission.cpp @@ -652,19 +652,16 @@ #include "ddio.h" #include "d3movie.h" #include "program.h" -#include "object.h" -#include "objinit.h" #include "ObjScript.h" -#include "application.h" #include "TelCom.h" #include "game.h" #include "cinematics.h" #include "player.h" #include "gamesequence.h" +#include "log.h" #include "mem.h" #include "newui.h" #include "stringtable.h" -#include "AppConsole.h" #include "pstring.h" #include "dedicated_server.h" #include "osiris_dll.h" @@ -730,7 +727,7 @@ static inline char *MN3_TO_MSN_NAME(const char *mn3name, char *msnname) { // High level mission stuff /////////////////////////////////////////////////////////////////////////////// void InitMission() { - mprintf(0, "In InitMission()\n"); + LOG_INFO << "In InitMission()"; Current_mission.num_levels = 0; Current_mission.cur_level = 0; memset(Current_mission.desc, 0, sizeof(Current_mission.desc)); @@ -754,7 +751,7 @@ void InitMission() { } // reset all states for a mission void ResetMission() { - mprintf(0, "In ResetMission()\n"); + LOG_INFO << "In ResetMission()"; FreeMission(); Current_mission.num_levels = 0; Current_mission.cur_level = 0; @@ -883,7 +880,7 @@ bool DemoMission(int mode = 0) { bool LoadMission(const char *mssn) { Times_game_restored = 0; - mprintf(0, "In LoadMission()\n"); + LOG_INFO << "In LoadMission()"; // ShowProgressScreen(TXT_LOADINGLEVEL); #if (defined(OEM) || defined(DEMO)) #ifdef OEM @@ -1007,7 +1004,7 @@ bool LoadMission(const char *mssn) { if (Net_msn_URLs.URL[a][0] == '\0') { strncpy(Net_msn_URLs.URL[a], operand, MAX_MISSION_URL_LEN - 1); Net_msn_URLs.URL[a][MAX_MISSION_URL_LEN - 1] = '\0'; - mprintf(0, "Found a Mission URL: %s\n", operand); + LOG_INFO.printf("Found a Mission URL: %s", operand); break; } } @@ -1023,7 +1020,7 @@ bool LoadMission(const char *mssn) { // ok the ship exists, make this guy the new default ship PlayerResetShipPermissions(-1, false); PlayerSetShipPermission(-1, operand, true); - mprintf(0, "MAKING %s THE NEW DEFAULT SHIP!\n", operand); + LOG_INFO.printf("MAKING %s THE NEW DEFAULT SHIP!", operand); } else { Int3(); } @@ -1377,7 +1374,7 @@ void LoadLevelProgress(int step, float percent, const char *chunk) { } lvl_percent_loaded = 1.0f; pag_percent_loaded = 1.0f; - mprintf(0, "Prepare for Descent goes here...\n"); + LOG_INFO << "Prepare for Descent goes here..."; // ShowProgressScreen(TXT_PREPARE_FOR_DESCENT,NULL,true); // return; break; @@ -1394,7 +1391,7 @@ void LoadLevelProgress(int step, float percent, const char *chunk) { return; } break; default: - mprintf(0, "Unknown step in LoadLevelProgress()\n"); + LOG_FATAL << "Unknown step in LoadLevelProgress()"; Int3(); } if (Dedicated_server) { @@ -1640,7 +1637,7 @@ extern bool FirstGame; // play movie void DoMissionMovie(const char *movie) { if (PROGRAM(windowed)) { - mprintf(0, "Skipping movie...can't do in windowed mode!\n"); + LOG_WARNING << "Skipping movie...can't do in windowed mode!"; return; } @@ -1724,7 +1721,7 @@ bool GetMissionInfo(const char *msnfile, tMissionInfo *msn) { } fp = cfopen(msnfile, "rt"); if (!fp) { - mprintf(0, "Failed to open mission file %s in GetMissionInfo.\n", msnfile); + LOG_WARNING.printf("Failed to open mission file %s in GetMissionInfo.", msnfile); return false; } msn->multi = true; @@ -1789,7 +1786,7 @@ const char *GetMissionName(const char *mission) { if (GetMissionInfo(mission, &msninfo)) { strcpy(msnname, msninfo.name); } else { - mprintf(0, "MISSION:GetMissionName failed from call to GetMissionInfo\n"); + LOG_WARNING << "MISSION: GetMissionName failed from call to GetMissionInfo"; } return msnname; } @@ -1861,7 +1858,7 @@ bool mn3_GetInfo(const char *mn3file, tMissionInfo *msn) { ddio_MakePath(pathname, D3MissionsDir, mn3file, nullptr); handle = cf_OpenLibrary(pathname); if (handle == 0) { - mprintf(0, "MISSION: MN3 failed to open.\n"); + LOG_ERROR << "MISSION: MN3 failed to open."; return false; } MN3_TO_MSN_NAME(mn3file, filename); @@ -1911,7 +1908,7 @@ int MissionGetKeywords(const char *mission, char *keywords) { memset(msn_keywords, 0, sizeof(msn_keywords)); memset(mod_keywords, 0, sizeof(mod_keywords)); - mprintf(0, "MissionGetKeywords(%s,%s)\n", mission, keywords); + LOG_DEBUG.printf("MissionGetKeywords(%s,%s)", mission, keywords); if (!GetMissionInfo(mission, &msn_info)) { return -1; } @@ -1973,7 +1970,7 @@ int MissionGetKeywords(const char *mission, char *keywords) { } // We never found one we needed, so return -1; if (!found_keyword) { - mprintf(0, "%s keyword needed in %s not found!\n", mod_keywords[i], mission); + LOG_WARNING.printf("%s keyword needed in %s not found!", mod_keywords[i], mission); return -1; } } @@ -1982,11 +1979,11 @@ int MissionGetKeywords(const char *mission, char *keywords) { teams = goals; } if (teams < goalsneeded) { - mprintf(0, "Not enough goals in this level!\n"); + LOG_WARNING << "Not enough goals in this level!"; teams = -1; } if (goals < goalsneeded) { - mprintf(0, "Not enough goals in this level!\n"); + LOG_WARNING << "Not enough goals in this level!"; teams = -1; } return teams; diff --git a/Descent3/OsirisLoadandBind.cpp b/Descent3/OsirisLoadandBind.cpp index 0a498f6a..5f56ca10 100644 --- a/Descent3/OsirisLoadandBind.cpp +++ b/Descent3/OsirisLoadandBind.cpp @@ -399,13 +399,14 @@ * $NoKeywords: $ */ +#include + #include "osiris_dll.h" #include "pserror.h" -#include "mono.h" #include "cfile.h" #include "ddio.h" +#include "log.h" #include "manage.h" -#include #include "mem.h" #include "DllWrappers.h" #include "objinfo.h" @@ -567,7 +568,7 @@ static bool Osiris_level_script_loaded = false; // Purpose: // Closes down the OSIRIS module loader and handling system void Osiris_ShutdownModuleLoader(void) { - mprintf(0, "OSIRIS: Shutting down module manager\n"); + LOG_DEBUG << "OSIRIS: Shutting down module manager"; int i; for (i = 0; i < MAX_LOADED_MODULES; i++) { Osiris_FreeModule(i); @@ -578,7 +579,7 @@ void Osiris_ShutdownModuleLoader(void) { // Purpose: // Initializes the OSIRIS module loader and handling system void Osiris_InitModuleLoader(void) { - mprintf(0, "OSIRIS: Initializing module manager\n"); + LOG_DEBUG << "OSIRIS: Initializing module manager"; int i; for (i = 0; i < MAX_LOADED_MODULES; i++) { OSIRIS_loaded_modules[i].flags = 0; @@ -796,9 +797,8 @@ void Osiris_UnloadModule(int module_id) { return; if (OSIRIS_loaded_modules[module_id].flags & OSIMF_INUSE) { // the module is in use - if (Show_osiris_debug) { - mprintf(0, "OSIRIS: Decrementing reference count for module (%s)\n", OSIRIS_loaded_modules[module_id].module_name); - } + LOG_DEBUG_IF(Show_osiris_debug).printf("OSIRIS: Decrementing reference count for module (%s)", + OSIRIS_loaded_modules[module_id].module_name); OSIRIS_loaded_modules[module_id].reference_count--; ASSERT(OSIRIS_loaded_modules[module_id].reference_count >= 0); @@ -811,19 +811,17 @@ void Osiris_UnloadModule(int module_id) { ASSERT(!(OSIRIS_loaded_modules[module_id].flags & OSIMF_DLLELSEWHERE)); // mission modules cannot be set static // do not unload this module, due to the forced stay in memory - mprintf(0, "OSIRIS: Module (%s) staying in memory due to static flag\n", - OSIRIS_loaded_modules[module_id].module_name); + LOG_VERBOSE.printf("OSIRIS: Module (%s) staying in memory due to static flag", + OSIRIS_loaded_modules[module_id].module_name); } else { // time to unload this module - if (Show_osiris_debug) { - mprintf(0, "OSIRIS: Module (%s) reference count is at 0, unloading\n", - OSIRIS_loaded_modules[module_id].module_name); - } + LOG_DEBUG_IF(Show_osiris_debug).printf("OSIRIS: Module (%s) reference count is at 0, unloading", + OSIRIS_loaded_modules[module_id].module_name); Osiris_FreeModule(module_id); } } } else { - mprintf(0, "OSIRIS: Trying to unload a module (%d) that is not in use!\n", module_id); + LOG_FATAL.printf("OSIRIS: Trying to unload a module (%d) that is not in use!", module_id); Int3(); } } @@ -866,7 +864,7 @@ void Osiris_UnloadLevelModule(void) { if (OSIRIS_loaded_modules[j].flags & OSIMF_INUSE && OSIRIS_loaded_modules[j].flags & OSIMF_NOUNLOAD) { // unload this module - mprintf(0, "OSIRIS: Unloading static module (%s) due to level end\n", OSIRIS_loaded_modules[j].module_name); + LOG_DEBUG.printf("OSIRIS: Unloading static module (%s) due to level end\n", OSIRIS_loaded_modules[j].module_name); Osiris_FreeModule(j); } @@ -957,7 +955,7 @@ int Osiris_LoadLevelModule(char *module_name) { ASSERT(!tOSIRISCurrentLevel.level_loaded); if (tOSIRISCurrentLevel.level_loaded) { - mprintf(0, "OSIRIS: Trying to load a level dll, when one has already been loaded\n"); + LOG_DEBUG << "OSIRIS: Trying to load a level dll, when one has already been loaded"; return tOSIRISCurrentLevel.dll_id; } @@ -966,10 +964,8 @@ int Osiris_LoadLevelModule(char *module_name) { if (loaded_id != -1) { // the module is already loaded OSIRIS_loaded_modules[loaded_id].reference_count++; - if (Show_osiris_debug) { - mprintf(0, "OSIRIS: Level Module (%s) reference count increased to %d\n", module_name, - OSIRIS_loaded_modules[loaded_id].reference_count); - } + LOG_DEBUG_IF(Show_osiris_debug).printf("OSIRIS: Level Module (%s) reference count increased to %d", + module_name, OSIRIS_loaded_modules[loaded_id].reference_count); return loaded_id; } @@ -983,7 +979,7 @@ int Osiris_LoadLevelModule(char *module_name) { if (loaded_id >= MAX_LOADED_MODULES) { // no slots available - mprintf(0, "OSIRIS: Osiris_LoadLevelModule(%s): No available slots\n", module_name); + LOG_FATAL.printf("OSIRIS: Osiris_LoadLevelModule(%s): No available slots\n", module_name); Int3(); return -4; } @@ -995,7 +991,7 @@ int Osiris_LoadLevelModule(char *module_name) { switch (ret_val) { case -2: // the module does not exist - mprintf(0, "OSIRIS: Osiris_LoadLevelModule(%s): Module doesn't exist\n", module_name); + LOG_ERROR.printf("OSIRIS: Osiris_LoadLevelModule(%s): Module doesn't exist", module_name); return -1; break; case -1: @@ -1003,7 +999,7 @@ int Osiris_LoadLevelModule(char *module_name) { break; default: // the module was an extracted file - mprintf(0, "OSIRIS: Found module (%s) in a temp file\n", basename); + LOG_DEBUG.printf("OSIRIS: Found module (%s) in a temp file", basename); OSIRIS_loaded_modules[loaded_id].flags |= OSIMF_INTEMPDIR; OSIRIS_loaded_modules[loaded_id].extracted_id = ret_val; break; @@ -1012,7 +1008,7 @@ int Osiris_LoadLevelModule(char *module_name) { // the module exists, now attempt to load it if (!mod_LoadModule(&OSIRIS_loaded_modules[loaded_id].mod, fullpath)) { // there was an error trying to load the module - mprintf(0, "OSIRIS: Osiris_LoadLevelModule(%s): Unable to load module\n", module_name); + LOG_FATAL.printf("OSIRIS: Osiris_LoadLevelModule(%s): Unable to load module", module_name); Int3(); return -3; } @@ -1056,7 +1052,7 @@ int Osiris_LoadLevelModule(char *module_name) { !osm->GetCOScriptList || !osm->CreateInstance || !osm->DestroyInstance || !osm->SaveRestoreState || !osm->CallInstanceEvent) { // there was an error importing a function - mprintf(0, "OSIRIS: Osiris_LoadLevelModule(%s) couldn't import function.\n", module_name); + LOG_ERROR.printf("OSIRIS: Osiris_LoadLevelModule(%s) couldn't import function.", module_name); Int3(); osm->flags = 0; if (osm->module_name) @@ -1075,7 +1071,7 @@ int Osiris_LoadLevelModule(char *module_name) { // there is a string table, load it up bool ret = CreateStringTable(stringtablename, &osm->string_table, &osm->strings_loaded); if (!ret) { - mprintf(0, "OSIRIS: Unable to load string table (%s) for (%s)\n", stringtablename, basename); + LOG_ERROR.printf("OSIRIS: Unable to load string table (%s) for (%s)\n", stringtablename, basename); Int3(); osm->string_table = NULL; osm->strings_loaded = 0; @@ -1094,7 +1090,7 @@ int Osiris_LoadLevelModule(char *module_name) { // when we get to this point we nearly have a loaded module, we just need to initialize it if (!osm->InitializeDLL(&Osiris_module_init)) { // there was an error initializing the module - mprintf(0, "OSIRIS: Osiris_LoadLevelModule(%s) error initializing module.\n", basename); + LOG_ERROR.printf("OSIRIS: Osiris_LoadLevelModule(%s) error initializing module.", basename); if (osm->string_table) { DestroyStringTable(osm->string_table, osm->strings_loaded); } @@ -1121,7 +1117,7 @@ int Osiris_LoadLevelModule(char *module_name) { // the trigger was found instance = osm->CreateInstance(script_id); if (!instance) { - mprintf(0, "OSIRIS: Unable to create instance for trigger script (%d)\n", i); + LOG_ERROR.printf("OSIRIS: Unable to create instance for trigger script (%d)", i); } else { Triggers[i].osiris_script.script_id = script_id; Triggers[i].osiris_script.script_instance = instance; @@ -1137,7 +1133,7 @@ int Osiris_LoadLevelModule(char *module_name) { tOSIRISCurrentLevel.instance = OSIRIS_loaded_modules[loaded_id].CreateInstance(0); // level scripts always have id of 0 in a level dll - mprintf(0, "OSIRIS: Level Module (%s) loaded successfully (%d custom handles)\n", basename, + LOG_INFO.printf("OSIRIS: Level Module (%s) loaded successfully (%d custom handles)", basename, tOSIRISCurrentLevel.num_customs); Osiris_level_script_loaded = true; return loaded_id; @@ -1161,7 +1157,7 @@ int Osiris_LoadGameModule(char *module_name) { // the module is already loaded OSIRIS_loaded_modules[loaded_id].reference_count++; if (Show_osiris_debug) { - mprintf(0, "OSIRIS: Game Module (%s) reference count increased to %d\n", module_name, + LOG_DEBUG.printf("OSIRIS: Game Module (%s) reference count increased to %d", module_name, OSIRIS_loaded_modules[loaded_id].reference_count); } return loaded_id; @@ -1177,7 +1173,7 @@ int Osiris_LoadGameModule(char *module_name) { if (loaded_id >= MAX_LOADED_MODULES) { // no slots available - mprintf(0, "OSIRIS: Osiris_LoadGameModule(%s): No available slots\n", module_name); + LOG_FATAL.printf("OSIRIS: Osiris_LoadGameModule(%s): No available slots", module_name); Int3(); return -4; } @@ -1189,7 +1185,7 @@ int Osiris_LoadGameModule(char *module_name) { switch (ret_val) { case -2: // the module does not exist - mprintf(0, "OSIRIS: Osiris_LoadLevelModule(%s): Module doesn't exist\n", module_name); + LOG_WARNING.printf("OSIRIS: Osiris_LoadLevelModule(%s): Module doesn't exist", module_name); return -1; break; case -1: @@ -1197,7 +1193,7 @@ int Osiris_LoadGameModule(char *module_name) { break; default: // the module was an extracted file - mprintf(0, "OSIRIS: Found module (%s) in a temp file\n", basename); + LOG_INFO.printf("OSIRIS: Found module (%s) in a temp file", basename); OSIRIS_loaded_modules[loaded_id].flags |= OSIMF_INTEMPDIR; OSIRIS_loaded_modules[loaded_id].extracted_id = ret_val; break; @@ -1206,7 +1202,7 @@ int Osiris_LoadGameModule(char *module_name) { // the module exists, now attempt to load it if (!mod_LoadModule(&OSIRIS_loaded_modules[loaded_id].mod, fullpath)) { // there was an error trying to load the module - mprintf(0, "OSIRIS: Osiris_LoadGameModule(%s): Unable to load module\n", module_name); + LOG_FATAL.printf("OSIRIS: Osiris_LoadGameModule(%s): Unable to load module", module_name); Int3(); return -3; } @@ -1247,7 +1243,7 @@ int Osiris_LoadGameModule(char *module_name) { if (!osm->InitializeDLL || !osm->ShutdownDLL || !osm->GetGOScriptID || !osm->CreateInstance || !osm->DestroyInstance || !osm->SaveRestoreState || !osm->CallInstanceEvent) { // there was an error importing a function - mprintf(0, "OSIRIS: Osiris_LoadGameModule(%s) couldn't import function.\n", basename); + LOG_WARNING.printf("OSIRIS: Osiris_LoadGameModule(%s) couldn't import function.", basename); Int3(); osm->flags = 0; if (osm->module_name) @@ -1266,7 +1262,7 @@ int Osiris_LoadGameModule(char *module_name) { // there is a string table, load it up bool ret = CreateStringTable(stringtablename, &osm->string_table, &osm->strings_loaded); if (!ret) { - mprintf(0, "OSIRIS: Unable to load string table (%s) for (%s)\n", stringtablename, basename); + LOG_FATAL.printf("OSIRIS: Unable to load string table (%s) for (%s)", stringtablename, basename); Int3(); osm->string_table = NULL; osm->strings_loaded = 0; @@ -1284,7 +1280,7 @@ int Osiris_LoadGameModule(char *module_name) { // when we get to this point we nearly have a loaded module, we just need to initialize it if (!osm->InitializeDLL(&Osiris_module_init)) { // there was an error initializing the module - mprintf(0, "OSIRIS: Osiris_LoadGameModule(%s) error initializing module.\n", basename); + LOG_ERROR.printf("OSIRIS: Osiris_LoadGameModule(%s) error initializing module.", basename); if (osm->string_table) { DestroyStringTable(osm->string_table, osm->strings_loaded); } @@ -1300,12 +1296,12 @@ int Osiris_LoadGameModule(char *module_name) { if (Osiris_module_init.module_is_static) { // the module is requesting to be static - mprintf(0, "OSIRIS: Module (%s) is requesting to be static\n", osm->module_name); + LOG_DEBUG.printf("OSIRIS: Module (%s) is requesting to be static", osm->module_name); osm->flags |= OSIMF_NOUNLOAD; } // we have a successful module load - mprintf(0, "OSIRIS: Game Module (%s) loaded successfully\n", basename); + LOG_INFO.printf("OSIRIS: Game Module (%s) loaded successfully", basename); return loaded_id; } @@ -1340,7 +1336,7 @@ int Osiris_LoadMissionModule(module *module_handle, const char *filename) { if (loaded_id >= MAX_LOADED_MODULES) { // no slots available - mprintf(0, "OSIRIS: Osiris_LoadMissionModule(%s): No available slots\n", filename); + LOG_FATAL.printf("OSIRIS: Osiris_LoadMissionModule(%s): No available slots", filename); Int3(); return -4; } @@ -1348,7 +1344,7 @@ int Osiris_LoadMissionModule(module *module_handle, const char *filename) { // make sure the module exists so we can load it if (!module_handle->handle) { // the module does not exist - mprintf(0, "OSIRIS: Osiris_LoadMissionModule(%s): Module doesn't exist\n", filename); + LOG_ERROR.printf("OSIRIS: Osiris_LoadMissionModule(%s): Module doesn't exist", filename); // Int3(); return -1; } @@ -1388,7 +1384,7 @@ int Osiris_LoadMissionModule(module *module_handle, const char *filename) { if (!osm->GetGOScriptID || !osm->CreateInstance || !osm->DestroyInstance || !osm->SaveRestoreState || !osm->CallInstanceEvent) { // there was an error importing a function - mprintf(0, "OSIRIS: Osiris_LoadMissionModule(%s) couldn't import function.\n", filename); + LOG_FATAL.printf("OSIRIS: Osiris_LoadMissionModule(%s) couldn't import function.", filename); osm->flags = 0; tOSIRISCurrentMission.mission_loaded = false; Int3(); @@ -1400,7 +1396,7 @@ int Osiris_LoadMissionModule(module *module_handle, const char *filename) { tOSIRISCurrentMission.mission_loaded = true; tOSIRISCurrentMission.dll_id = loaded_id; if (Show_osiris_debug) { - mprintf(0, "OSIRIS: Mission Game Module (%s) loaded successfully\n", filename); + LOG_INFO.printf("OSIRIS: Mission Game Module (%s) loaded successfully", filename); } return loaded_id; } @@ -1501,16 +1497,13 @@ bool Osiris_BindScriptsToObject(object *obj) { // load up the dllname associated with the object and get the id dll_id = Osiris_LoadGameModule(default_module_name); if (dll_id < 0) { - // there was an error finding this object's dll - if (Show_osiris_debug) { - mprintf(0, "OSIRIS: Unable to load module (%s) to bind to object (%s)\n", default_module_name, page_name); - } + LOG_ERROR.printf("OSIRIS: Unable to load module (%s) to bind to object (%s)", default_module_name, page_name); } else { // allocate the memory for the object's scripts obj->osiris_script = (tOSIRISScript *)mem_malloc(sizeof(tOSIRISScript)); if (!obj->osiris_script) { // out of memory - mprintf(0, "OSIRIS: Out of memory trying to bind script\n"); + LOG_ERROR << "OSIRIS: Out of memory trying to bind script"; return false; } @@ -1525,7 +1518,7 @@ bool Osiris_BindScriptsToObject(object *obj) { if (gos_id == -1) { // the default script for this object does not exist in the dll set for it - mprintf(0, "OSIRIS: Unable to find GOS ID for (%s) in (%s)!\n", page_name, default_module_name); + LOG_FATAL.printf("OSIRIS: Unable to find GOS ID for (%s) in (%s)!", page_name, default_module_name); Int3(); Osiris_UnloadModule(dll_id); } else { @@ -1535,7 +1528,7 @@ bool Osiris_BindScriptsToObject(object *obj) { gos_instance = OSIRIS_loaded_modules[dll_id].CreateInstance(gos_id); if (!gos_instance) { // we had an error obtaining the instance of the GOS...ugh - mprintf(0, "OSIRIS: Unable to create GOS instance for (%s)\n", page_name); + LOG_FATAL.printf("OSIRIS: Unable to create GOS instance for (%s)", page_name); Int3(); Osiris_UnloadModule(dll_id); } else { @@ -1588,7 +1581,7 @@ bool Osiris_BindScriptsToObject(object *obj) { obj->osiris_script = (tOSIRISScript *)mem_malloc(sizeof(tOSIRISScript)); if (!obj->osiris_script) { // out of memory - mprintf(0, "OSIRIS: Out of memory trying to bind script\n"); + LOG_ERROR << "OSIRIS: Out of memory trying to bind script"; return false; } @@ -1603,7 +1596,7 @@ bool Osiris_BindScriptsToObject(object *obj) { gos_instance = OSIRIS_loaded_modules[dll_id].CreateInstance(gos_id); if (!gos_instance) { // we had an error obtaining the instance of the GOS...ick - mprintf(0, "OSIRIS: Unable to create GOS instance from level dll for (%s)\n", page_name); + LOG_FATAL.printf("OSIRIS: Unable to create GOS instance from level dll for (%s)", page_name); Int3(); } else { // ok, we got a valid instance @@ -1645,7 +1638,7 @@ bool Osiris_BindScriptsToObject(object *obj) { obj->osiris_script = (tOSIRISScript *)mem_malloc(sizeof(tOSIRISScript)); if (!obj->osiris_script) { // out of memory - mprintf(0, "OSIRIS: Out of memory trying to bind script\n"); + LOG_ERROR << "OSIRIS: Out of memory trying to bind script"; return false; } @@ -1659,7 +1652,7 @@ bool Osiris_BindScriptsToObject(object *obj) { gos_instance = OSIRIS_loaded_modules[dll_id].CreateInstance(gos_id); if (!gos_instance) { // we had an error obtaining the instance of the COS...doh! - mprintf(0, "OSIRIS: Unable to create COS instance from level dll for (%s)\n", + LOG_FATAL.printf("OSIRIS: Unable to create COS instance from level dll for (%s)", (page_name) ? (page_name) : ""); Int3(); } else { @@ -1687,7 +1680,7 @@ bool Osiris_BindScriptsToObject(object *obj) { #endif if (iscustomonly) { - mprintf(0, "OSIRIS: Attached custom script to 'custom only' object 0x%x\n", obj->handle); + LOG_DEBUG.printf("OSIRIS: Attached custom script to 'custom only' object 0x%x", obj->handle); } } } @@ -1715,7 +1708,7 @@ bool Osiris_BindScriptsToObject(object *obj) { obj->osiris_script = (tOSIRISScript *)mem_malloc(sizeof(tOSIRISScript)); if (!obj->osiris_script) { // out of memory - mprintf(0, "OSIRIS: Out of memory trying to bind script\n"); + LOG_ERROR << "OSIRIS: Out of memory trying to bind script"; return false; } @@ -1730,7 +1723,7 @@ bool Osiris_BindScriptsToObject(object *obj) { gos_instance = OSIRIS_loaded_modules[dll_id].CreateInstance(gos_id); if (!gos_instance) { // we had an error obtaining the instance of the GOS...ick - mprintf(0, "OSIRIS: Unable to create GOS instance from mission dll for (%s)\n", page_name); + LOG_FATAL.printf("OSIRIS: Unable to create GOS instance from mission dll for (%s)", page_name); Int3(); } else { // ok, we got a valid instance @@ -2325,7 +2318,7 @@ void Osiris_ProcessTimers(void) { Osiris_CallEvent(obj, EVT_TIMERCANCEL, &ei); } - mprintf(0, "OSIRIS TIMER: Cancelling Timer (%d/%d)\n", OsirisTimers[i].handle, i); + LOG_DEBUG.printf("OSIRIS TIMER: Cancelling Timer (%d/%d)", OsirisTimers[i].handle, i); continue; } } @@ -2672,7 +2665,7 @@ void Osiris_SaveSystemState(CFILE *file) { int save_end = cftell(file); - mprintf(0, "Osiris: Save state, %d bytes written\n", save_end - save_start); + LOG_INFO.printf("Osiris: Save state, %d bytes written", save_end - save_start); cfseek(file, checksum_pos, SEEK_SET); cf_WriteInt(file, save_end - save_start); // write out 'checksum' @@ -2691,7 +2684,7 @@ bool Osiris_RestoreSystemState(CFILE *file) { cf_ReadString(tag, 256, file); if (strcmp(tag, "OSIRIS")) { // Things aren't right...our tag is not here - mprintf(0, "Missing OSIRIS tag\n"); + LOG_FATAL << "Missing OSIRIS tag"; Int3(); return false; } @@ -2747,10 +2740,9 @@ bool Osiris_RestoreSystemState(CFILE *file) { // when the state was saved. This means that things are not going to be restored exactly for // sure. We'll skip over those that are not loaded. We're int3 here because I want to know // when this happens. - mprintf(0, - "OSIRIS: Restoring global state, the number of loaded modules is not the same as the restored count (%d " - "vs. %d)\n", - loaded_module_count, read_module_count); + LOG_ERROR.printf( + "OSIRIS: Restoring global state, the number of loaded modules is not the same as the restored count (%d vs. %d)", + loaded_module_count, read_module_count); if (Demo_flags != DF_PLAYBACK) { Int3(); } @@ -2773,7 +2765,7 @@ bool Osiris_RestoreSystemState(CFILE *file) { module_handle = Osiris_FindLoadedModule(read_module_name); if (module_handle == -1) { - mprintf(0, "OSIRIS: The module (%s) was not found while trying to restore the state\n", read_module_name); + LOG_ERROR.printf("OSIRIS: The module (%s) was not found while trying to restore the state", read_module_name); if (Demo_flags != DF_PLAYBACK) { Int3(); } @@ -2806,7 +2798,7 @@ bool Osiris_RestoreSystemState(CFILE *file) { int restore_end = cftell(file); - mprintf(0, "Osiris: Restore state, %d bytes read\n", restore_end - restore_start); + LOG_INFO.printf("Osiris: Restore state, %d bytes read", restore_end - restore_start); ASSERT(num_bytes_to_be_restored == (restore_end - restore_start)); if (num_bytes_to_be_restored == (restore_end - restore_start)) @@ -3124,7 +3116,7 @@ int Osiris_ExtractScriptsFromHog(int library_handle, bool is_mission_hog) { if (library_handle == 0) return 0; - mprintf(0, "OSIRIS: Extracting Scripts From Hog\n"); + LOG_INFO << "OSIRIS: Extracting Scripts From Hog"; char filename[_MAX_PATH], temp_filename[_MAX_PATH]; char tempdir[_MAX_PATH], temp_file[_MAX_PATH], temp_fileext[_MAX_EXT]; @@ -3155,15 +3147,13 @@ int Osiris_ExtractScriptsFromHog(int library_handle, bool is_mission_hog) { int index; index = _getfreeextractslot(); if (index == -1) { - mprintf(0, "OSIRIS: Out of slots extracting scripts!!!!!!!!\n"); + LOG_FATAL << "OSIRIS: Out of slots extracting scripts!"; Int3(); goto ex_error; } - mprintf(0, "Search started\n"); + LOG_DEBUG << "Search started"; if (cf_LibraryFindFirst(library_handle, script_extension, filename)) { - - mprintf(0, " Found: %s...", filename); if (!ddio_GetTempFileName(tempdir, "d3s", temp_filename)) Int3(); else { @@ -3181,18 +3171,15 @@ int Osiris_ExtractScriptsFromHog(int library_handle, bool is_mission_hog) { } // extract it out - mprintf(0, "Extracting..."); _extractscript(filename, temp_filename); - mprintf(0, "Done\n"); + LOG_DEBUG.printf("Extracted %s as %s", filename, temp_filename); count++; while (cf_LibraryFindNext(filename)) { - mprintf(0, " Found: %s...", filename); - index = _getfreeextractslot(); if (index == -1) { - mprintf(0, "OSIRIS: Out of slots extracting scripts!!!!!!!!\n"); + LOG_FATAL << "OSIRIS: Out of slots extracting scripts!"; Int3(); goto ex_error; } @@ -3215,9 +3202,8 @@ int Osiris_ExtractScriptsFromHog(int library_handle, bool is_mission_hog) { } // extract it out - mprintf(0, "Extracting..."); _extractscript(filename, temp_filename); - mprintf(0, "Done\n"); + LOG_DEBUG.printf("Extracted %s as %s", filename, temp_filename); count++; } @@ -3225,7 +3211,7 @@ int Osiris_ExtractScriptsFromHog(int library_handle, bool is_mission_hog) { } } - mprintf(0, "Done Extracting\n"); + LOG_DEBUG << "Done Extracting"; ex_error: cf_LibraryFindClose(); @@ -3241,7 +3227,7 @@ ex_error: } void Osiris_ClearExtractedScripts(bool mission_only) { - mprintf(0, "OSIRIS: Removing Extracted DLLs\n"); + LOG_DEBUG << "OSIRIS: Removing Extracted DLLs"; char fullpath[_MAX_PATH]; if (!OSIRIS_Extracted_script_dir) { @@ -3421,7 +3407,7 @@ void Osiris_InitOMMS(void) { } void Osiris_CloseOMMS(void) { - mprintf(0, "OSIRIS: Reseting OMMS memory\n"); + LOG_DEBUG << "OSIRIS: Reseting OMMS memory"; tOMMSHashNode *curr = OMMS_Hash_node_root; @@ -3700,7 +3686,7 @@ free_mem: if (!node_to_free) return; - mprintf(0, "OMMS: deleting uid 0x%x\n", node_to_free->unique_id); + LOG_DEBUG.printf("OMMS: deleting uid 0x%x", node_to_free->unique_id); if (node_to_free->memory_ptr) mem_free(node_to_free->memory_ptr); mem_free(node_to_free); @@ -3800,7 +3786,7 @@ OMMSHANDLE Osiris_OMMS_Malloc(size_t amount_of_memory, uint32_t unique_identifie node->size_of_memory = amount_of_memory; node->unique_id = unique_identifier; - mprintf(0, "OMMS: malloc handle (0x%x%x) size = %d\n", hash->base_id, node->id, node->size_of_memory); + LOG_DEBUG.printf("OMMS: malloc handle (0x%x%x) size = %d", hash->base_id, node->id, node->size_of_memory); return ((hash->base_id << 16) | (node->id)); } diff --git a/Descent3/PilotPicsAPI.cpp b/Descent3/PilotPicsAPI.cpp index 80645436..8eb83c2e 100644 --- a/Descent3/PilotPicsAPI.cpp +++ b/Descent3/PilotPicsAPI.cpp @@ -58,20 +58,20 @@ * $NoKeywords: $ */ -#include -#include +#include +#include +#include + #include "bitmap.h" #include "player.h" #include "pilot.h" #include "cfile.h" -#include "mono.h" +#include "log.h" #include "ddio.h" #include "manage.h" #include "PilotPicsAPI.h" #include "mem.h" -#include - #define PILOTPIC_DATABASE_HOG "PPics.Hog" #define PILOTPIC_DATABASE_INDEX "PPics.idx" @@ -126,7 +126,7 @@ static int PPic_GetOffsetByID(uint16_t pilot_id); // --------------------------------------------------------- bool PPic_InitDatabase(void) { if (PilotPic_init) { - mprintf(0, "PPIC: InitDatabase already called\n"); + LOG_DEBUG << "PPIC: InitDatabase already called"; return true; } @@ -139,7 +139,7 @@ bool PPic_InitDatabase(void) { if (PilotPic_database_hog_handle == 0) { // there was an error opening the hog database // ----------------------------------------- - mprintf(0, "PPIC: Error opening %s database\n", PILOTPIC_DATABASE_HOG); + LOG_WARNING.printf("PPIC: Error opening %s database", PILOTPIC_DATABASE_HOG); PilotPic_database_index_handle = NULL; return false; } @@ -151,7 +151,7 @@ bool PPic_InitDatabase(void) { if (PilotPic_database_index_handle == NULL) { // there was an error opening the database index // --------------------------------------------- - mprintf(0, "PPIC: Error opening database index '%s'\n", PILOTPIC_DATABASE_INDEX); + LOG_WARNING.printf("PPIC: Error opening database index '%s'", PILOTPIC_DATABASE_INDEX); cf_CloseLibrary(PilotPic_database_hog_handle); PilotPic_database_hog_handle = 0; return false; @@ -163,7 +163,7 @@ bool PPic_InitDatabase(void) { if (!PPic_BuildDatabases()) { // there was an error building the databases // ----------------------------------------- - mprintf(0, "PPIC: Error building databases\n"); + LOG_WARNING << "PPIC: Error building databases"; cfclose(PilotPic_database_index_handle); PilotPic_database_index_handle = NULL; cf_CloseLibrary(PilotPic_database_hog_handle); @@ -499,7 +499,7 @@ bool PPic_BuildDatabases(void) { PilotPic_count = cf_ReadInt(file); if (PilotPic_count < 0) { // hmm a negative! - mprintf(0, "PPIC: Invalid number of pilot pictures (%d)\n", PilotPic_count); + LOG_FATAL.printf("PPIC: Invalid number of pilot pictures (%d)", PilotPic_count); Int3(); PilotPic_count = 0; cf_Rewind(file); @@ -507,7 +507,7 @@ bool PPic_BuildDatabases(void) { } if (PilotPic_count > 65535) { // too many!!!! - mprintf(0, "PPIC: Invalid number of pilot pictures (%d)\n", PilotPic_count); + LOG_FATAL.printf("PPIC: Invalid number of pilot pictures (%d)", PilotPic_count); Int3(); PilotPic_count = 0; cf_Rewind(file); @@ -520,7 +520,7 @@ bool PPic_BuildDatabases(void) { Sorted_Pilot_id_to_offset = (uint16_t *)mem_malloc(sizeof(uint16_t) * PilotPic_count); if (!Pilot_id_to_offset) { // out of memory!!! - mprintf(0, "PPIC: Out of memory allocating index database\n"); + LOG_FATAL << "PPIC: Out of memory allocating index database"; Int3(); PilotPic_count = 0; cf_Rewind(file); @@ -547,7 +547,7 @@ bool PPic_BuildDatabases(void) { cf_ReadBytes((uint8_t *)name_buffer, name_size, file); name_buffer[name_size] = '\0'; if (name_size >= PILOT_STRING_SIZE) { - mprintf(0, "PPIC: Too big: (%s)%d %d", name_buffer, count, name_size); + LOG_DEBUG.printf("PPIC: Too big: (%s)%d %d", name_buffer, count, name_size); } // next read in pilot_id diff --git a/Descent3/Player.cpp b/Descent3/Player.cpp index 6bf574e9..b0b517a1 100644 --- a/Descent3/Player.cpp +++ b/Descent3/Player.cpp @@ -1084,29 +1084,27 @@ * $NoKeywords: $ */ +#include #include +#include #include "pserror.h" #include "player.h" #include "game.h" #include "hud.h" -#include "gauges.h" -#include "Mission.h" #include "vecmat.h" #include "fireball.h" #include "polymodel.h" #include "findintersection.h" -#include "hud.h" -#include "splinter.h" #include "physics.h" #include "viseffect.h" #include "damage.h" +#include "log.h" #include "multi.h" #include "ship.h" #include "gameevent.h" #include "gameloop.h" #include "descent.h" -#include "cockpit.h" #include "game2dll.h" #include "robotfire.h" #include "robot.h" @@ -1120,9 +1118,6 @@ #include "stringtable.h" #include "pilot.h" #include "vclip.h" -#include -#include "objinit.h" -#include "difficulty.h" #include "ddio.h" #include "ObjScript.h" #include "gamecinematics.h" @@ -1134,8 +1129,6 @@ #include "gamesequence.h" #include "init.h" -#include - player Players[MAX_PLAYERS]; int Player_num; @@ -1238,7 +1231,7 @@ void FindPlayerStarts() { unique++; } - mprintf(0, "There are %d unique start positions in this level\n", unique); + LOG_DEBUG.printf("There are %d unique start positions in this level", unique); // Now create the extra players if (Game_mode & GM_MULTI) { @@ -1307,7 +1300,7 @@ int PlayerGetRandomStartPosition(int slot) { if (Team_game) { int team = PlayerGetTeam(slot); - mprintf(0, "Picking team start position, team=%d.\n", team); + LOG_DEBUG.printf("Picking team start position, team=%d.", team); int num_avail = 0; int avail_array[MAX_PLAYERS]; @@ -1333,7 +1326,7 @@ int PlayerGetRandomStartPosition(int slot) { int num; int done = 0; int badcount = 0; - mprintf(0, "Picking non-team start position.\n"); + LOG_DEBUG << "Picking non-team start position."; while (!done) { num = ps_rand() % (Highest_player_start + 1); if (Players[num].start_roomnum != -1) { @@ -1355,7 +1348,7 @@ int PlayerGetRandomStartPosition(int slot) { badcount++; if (badcount >= 15) // give up after fifteen tries { - mprintf(0, "Stopping cuz I couldn't find a valid player position!\n"); + LOG_WARNING << "Stopping cuz I couldn't find a valid player position!"; done = 1; } } else @@ -1363,7 +1356,7 @@ int PlayerGetRandomStartPosition(int slot) { } } - mprintf(0, "Picked index for start position %d\n", num); + LOG_DEBUG.printf("Picked index for start position %d", num); return num; } @@ -2047,13 +2040,13 @@ static tDeathSeq Death[MAX_NET_PLAYERS]; void debug_deathtype(int slot, int damage) { if (Death[slot].fate == DEATH_INSTANT) - mprintf(0, "INSTANT DEATH "); + LOG_DEBUG << "INSTANT DEATH "; else if (Death[slot].fate == DEATH_FALL) - mprintf(0, "FALLING DEATH "); + LOG_DEBUG << "FALLING DEATH "; else if (Death[slot].fate == DEATH_BREAKUP) - mprintf(0, "BREAKUP DEATH "); + LOG_DEBUG << "BREAKUP DEATH "; else - mprintf(0, "UNKNOWN DEATH "); + LOG_DEBUG << "UNKNOWN DEATH "; } float MoveDeathCam(int slot, vector *vec, float distance); @@ -2137,7 +2130,7 @@ void StartPlayerDeath(int slot, float damage, bool melee, int fate) { if (slot == Player_num) { objnum = ObjCreate(OBJ_CAMERA, 0, playerobj->roomnum, &playerobj->pos, &playerobj->orient); if (objnum == -1) { - mprintf(0, "Failed to create death cam.\n"); + LOG_FATAL << "Failed to create death cam."; Int3(); } else { Death[slot].camera = &Objects[objnum]; @@ -2185,7 +2178,6 @@ void StartPlayerDeath(int slot, float damage, bool melee, int fate) { Death[slot].dying_model = GetPolymodelPointer(playerobj->rtype.pobj_info.model_num); playerobj->rtype.pobj_info.subobj_flags = 0xffffffff; // playerobj->rtype.pobj_info.subobj_flags = ~(0xffffffff << (Death[slot].dying_model->n_models)); - // mprintf(0, "initflags=%08x\n", playerobj->rtype.pobj_info.subobj_flags); } else { // This ship has no dying model so dont break up if (Death[slot].fate == DEATH_BREAKUP) @@ -2341,7 +2333,6 @@ void DoNewPlayerDeathFrame(int slot) { if (hit_data.hit_type[0] == HIT_WALL) { // death camera's view is obstructed, move the death cam - // mprintf(0, "Death cam view obstructed, changing view...\n"); vm_MakeRandomVector(&directional); MoveDeathCam(slot, &directional, MEDIAN_DEATHCAM_DIST); } @@ -2369,7 +2360,6 @@ void DoNewPlayerDeathFrame(int slot) { } else { PlayerShipBreakup(playerobj, 20.0f + (ps_rand() % 10)); Death[slot].breakup_count++; - // mprintf(0, "Breakup!\n"); } } } @@ -2412,7 +2402,6 @@ void DoNewPlayerDeathFrame(int slot) { } } - // mprintf(0,"Playerobj size=%f\n",playerobj->size); } #define TARGET_DEGREE (170 / 2) @@ -2754,7 +2743,7 @@ void PlayerSpewGuidebot(object *parent, int type, int id) { objnum = ObjCreate(OBJ_DEBRIS, 0, parent->roomnum, &parent->pos, &parent->orient); if (objnum < 0 || objnum > Highest_object_index) { - mprintf(0, "WARNING: No object slots. Dead GB not created!\n"); + LOG_WARNING.printf("WARNING: No object slots. Dead GB not created!"); return; } @@ -2845,7 +2834,7 @@ int PlayerSpewObject(object *parent, int type, int id, int timed, void *sinfo) { int objnum = ObjCreate(type, id, parent->roomnum, &parent->pos, NULL, parent->handle); if (objnum < 0) { - mprintf(0, "Couldn't spew object!\n"); + LOG_DEBUG.printf("Couldn't spew object!"); return -1; } @@ -3229,13 +3218,11 @@ void PlayerShipSpewPartSub(object *obj, bsp_info *submodel, float magnitude) { VisEffects[visnum].lifeleft *= 2.0f; rand_vec = (-rand_vec) * (magnitude * 25.0f); phys_apply_force(obj, &rand_vec); - // mprintf(0, "Breakoff fireball size: %f, lifeleft: %f\n", Objects[objnum].size, Objects[objnum].lifeleft); } } // mark subobject dead obj->rtype.pobj_info.subobj_flags &= (~(1 << subobjnum)); - // mprintf(0, "%d:sobj=%08x\n", subobjnum, obj->rtype.pobj_info.subobj_flags); } // Moves death camera a certain distance based off of direction from vec from @@ -3544,7 +3531,7 @@ void PlayerSwitchToObserver(int slot, int observer_mode, int piggy_objnum) { SetObjectControlType(obj, CT_NONE); Players[slot].piggy_objnum = piggy_objnum; Players[slot].piggy_sig = Objects[piggy_objnum].handle & HANDLE_COUNT_MASK; - mprintf(0, "Object %d is observing object %d!\n", obj - Objects, piggy_objnum); + LOG_DEBUG.printf("Object %d is observing object %d!", obj - Objects, piggy_objnum); } } @@ -3668,7 +3655,7 @@ bool PlayerResetShipPermissions(int pnum, bool set_default) { int perm; - mprintf(0, "Reseting ship permissions\n"); + LOG_DEBUG << "Reseting ship permissions"; if (set_default) perm = Default_ship_permission; @@ -3759,7 +3746,7 @@ void DoEnergyToShields(int pnum) { // Sets the start position that the player will respawn at void PlayerAddWaypoint(int index) { ASSERT(Players[index].start_roomnum != -1); // Invalid start position specified - mprintf(0, "Current waypoint is now %d\n", index); + LOG_DEBUG.printf("Current waypoint is now %d", index); Current_waypoint = index; // A manual waypoint blows away all auto-waypoints @@ -3828,7 +3815,7 @@ void SetAutoWaypoint(object *objp) { if (!OBJECT_OUTSIDE(objp)) { // delete the next two lines if (pp->current_auto_waypoint_room != objp->roomnum) { - mprintf(0, "Setting auto-waypoint in room %d\n", objp->roomnum); + LOG_DEBUG.printf("Setting auto-waypoint in room %d", objp->roomnum); } pp->current_auto_waypoint_room = objp->roomnum; } @@ -3855,7 +3842,7 @@ void MovePlayerToWaypoint(object *objp) { } else { ASSERT(Current_waypoint != -1); - mprintf(0, "Resetting player ship to waypoint %d\n", Current_waypoint); + LOG_DEBUG.printf("Resetting player ship to waypoint %d", Current_waypoint); ObjSetPos(objp, &Players[Current_waypoint].start_pos, Players[Current_waypoint].start_roomnum, &Players[Current_waypoint].start_orient, false); } diff --git a/Descent3/SLEW.cpp b/Descent3/SLEW.cpp index ed7a6499..a7d8a133 100644 --- a/Descent3/SLEW.cpp +++ b/Descent3/SLEW.cpp @@ -199,13 +199,13 @@ #include "editor\d3edit.h" #endif -#include -#include "descent.h" +#include + #include "slew.h" #include "vecmat.h" #include "ddio.h" #include "object.h" -#include "mono.h" +#include "log.h" #include "game.h" #include "joystick.h" #include "findintersection.h" @@ -307,18 +307,11 @@ int SlewFrame(object *obj, int movement_limitations) { if (key_timep1 || key_timep0 || key_timeh1 || key_timeh0 || key_timeb1 || key_timeb0) ret_flags |= SLEW_KEY; - if (key_timez0 || key_timez1) { - mprintf_at(1, 0, 0, "Timez0: %.2f ", key_timez0); - mprintf_at(1, 1, 0, "Timez1: %.2f ", key_timez1); - } - // adjust physics info of object accordingly to keyboard input. obj->mtype.phys_info.velocity.x += VEL_SPEED * (key_timex1 - key_timex0) * Slew_key_speed; obj->mtype.phys_info.velocity.y += VEL_SPEED * (key_timey1 - key_timey0) * Slew_key_speed; obj->mtype.phys_info.velocity.z += VEL_SPEED * (key_timez1 - key_timez0) * Slew_key_speed; - // mprintf(0,"<%x %x %x>",obj->mtype.phys_info.velocity.x,obj->mtype.phys_info.velocity.y,obj->mtype.phys_info.velocity.z)); - rottime.x = key_timep1 - key_timep0; rottime.y = key_timeh1 - key_timeh0; rottime.z = key_timeb1 - key_timeb0; @@ -339,8 +332,6 @@ int SlewFrame(object *obj, int movement_limitations) { joy_x = joystate.x; joy_y = joystate.y; btns = joystate.buttons; - mprintf_at(2, 1, 0, "JoyX: %d ", joy_x); - mprintf_at(2, 2, 0, "JoyY: %d ", joy_y); if (abs(joy_x) < JOY_NULL) joy_x = 0; @@ -350,11 +341,6 @@ int SlewFrame(object *obj, int movement_limitations) { joyx_moved = (abs(joy_x - old_joy_x) > JOY_NULL); joyy_moved = (abs(joy_y - old_joy_y) > JOY_NULL); - //@@ if (joyx_moved) - //@@ mprintf(1,"SLEW: Joy X moved\n"); - //@@ if (joyy_moved) - //@@ mprintf(1,"SLEW: Joy Y moved\n"); - if (btns) { if (!rotang.p) rotang.p = -joy_y * 256 * Frametime; @@ -401,7 +387,7 @@ int SlewFrame(object *obj, int movement_limitations) { if (ret_flags & SLEW_MOVE) { // Get the new room bool outside_mine = ((obj->flags & OF_OUTSIDE_MINE) != 0); - mprintf(1, "SLEW: Moved\n"); + LOG_DEBUG << "SLEW: Moved"; #ifdef EDITOR if (Editor_view_mode == VM_ROOM) { @@ -417,7 +403,7 @@ int SlewFrame(object *obj, int movement_limitations) { if (new_room != -1) { // back in the mine outside_mine = 0; - mprintf(0, "SLEW: Re-entered mine at room %d\n", new_room); + LOG_DEBUG.printf("SLEW: Re-entered mine at room %d", new_room); } else // not back in the mine new_room = obj->roomnum; } else { @@ -456,30 +442,30 @@ int SlewFrame(object *obj, int movement_limitations) { if (fate == HIT_WALL) { int t; - mprintf(0, "SLEW: hit wall\n"); + LOG_DEBUG << "SLEW: hit wall"; // Check if we're in a room t = FindPointRoom(&new_pos); if (t != -1) { // We're in a room new_room = t; - mprintf(0, "SLEW: still in mine in room %d\n", new_room); + LOG_DEBUG.printf("SLEW: still in mine in room %d", new_room); } else { // Not in a room. Set a special flag outside_mine = 1; - mprintf(0, "SLEW: left mine from room %d\n", new_room); + LOG_DEBUG.printf("SLEW: left mine from room %d", new_room); } } if (new_room != obj->roomnum) { // if we've changed rooms, say so if (ROOMNUM_OUTSIDE(new_room)) if (was_outside) - mprintf(0, "SLEW: Moved to cell %d, BOA TR %d\n", CELLNUM(new_room), TERRAIN_REGION(new_room)); + LOG_DEBUG.printf("SLEW: Moved to cell %d, BOA TR %d", CELLNUM(new_room), TERRAIN_REGION(new_room)); else - mprintf(0, "SLEW: Moved outside to cell %d\n", CELLNUM(new_room)); + LOG_DEBUG.printf("SLEW: Moved outside to cell %d", CELLNUM(new_room)); else if (was_outside) - mprintf(0, "SLEW: Moved inside to room %d\n", new_room); + LOG_DEBUG.printf("SLEW: Moved inside to room %d", new_room); else - mprintf(0, "SLEW: Moved into room %d\n", new_room); + LOG_DEBUG.printf("SLEW: Moved into room %d", new_room); } } diff --git a/Descent3/TelCom.cpp b/Descent3/TelCom.cpp index 3c1c8ab2..c5fc3abd 100644 --- a/Descent3/TelCom.cpp +++ b/Descent3/TelCom.cpp @@ -496,14 +496,13 @@ #include #include "chrono_timer.h" -#include "mono.h" +#include "log.h" #include "renderer.h" #include "render.h" #include "ddio.h" #include "descent.h" #include "game.h" #include "cfile.h" -#include "application.h" #include "TelCom.h" #include "TelComEffects.h" #include "Briefing.h" @@ -565,11 +564,11 @@ static int Telcom_mouse_x, Telcom_mouse_y; // Initializes the TelCom system, only to be called once during game initialization void TelComInit(void) { - mprintf(0, "Initializing TelCom System\n"); + LOG_DEBUG << "Initializing TelCom System"; // load background screens if (!(cfexist(TELCOM_DISPLAY_OGF))) { - mprintf(0, "%s file not found, exiting TelCom Init\n", TELCOM_DISPLAY_OGF); + LOG_WARNING.printf("%s file not found, exiting TelCom Init", TELCOM_DISPLAY_OGF); return; } @@ -801,7 +800,7 @@ bool TelComShow(bool ingame, bool ShipSelect) { uint8_t oldbil = Render_preferred_state.filtering; if (!TelCom_init) { - mprintf(0, "TELCOM SYSTEM WARNING: TelComInit() error!\n"); + LOG_WARNING << "TELCOM SYSTEM WARNING: TelComInit() error!"; return false; } @@ -813,9 +812,9 @@ bool TelComShow(bool ingame, bool ShipSelect) { int TelCom_bitmap = bm_AllocLoadFileBitmap(IGNORE_TABLE(TELCOM_DISPLAY_OGF), 0); if (!cfexist(HOTSPOT_DISPLAY)) { - mprintf(0, "Couldn't find HotSpot map, so I'm going to make one\n"); + LOG_DEBUG << "Couldn't find HotSpot map, so I'm going to make one"; if (!cfexist(TELCOM_DISPLAY_TGA)) { - mprintf(0, "Unable to find %s to extract HotSqpots...skipping TelCom System\n", TELCOM_DISPLAY_TGA); + LOG_DEBUG.printf("Unable to find %s to extract HotSqpots...skipping TelCom System", TELCOM_DISPLAY_TGA); FreeViewports(); if (windowmap.wm) mem_free(windowmap.wm); @@ -941,7 +940,7 @@ void FreeTelComOnBitmaps(chunked_bitmap *array) { // This deactivates the TelCom system void TelComDeactivate(void) { - mprintf(0, "TelCom System being deactivated\n"); + LOG_DEBUG << "TelCom System being deactivated"; FreeTelComOnBitmaps(hotspot_bitmaps); FreeHotSpotMapInternals(&hotspotmap); FreeViewports(); @@ -1555,7 +1554,7 @@ void TelcomRenderSetScreen(int screen) { ASSERT(screen >= 0 && screen < MAX_TELCOM_SCREENS); if (Telcom_system.Screen_state[screen] != SS_READY) { - mprintf(0, "Telcom Warning: Trying to set screen %d active when it isn't ready\n", screen); + LOG_DEBUG.printf("Telcom Warning: Trying to set screen %d active when it isn't ready", screen); return; } TC_current_screen = screen; @@ -1973,7 +1972,7 @@ void TelcomLoadHiLites(const char *filelist[], int monitor, int xoff, int yoff) TelcomHiLites[monitor] = (int *)mem_malloc(sizeof(int) * TelcomHiLiteCount[monitor]); if (!TelcomHiLites[monitor]) { - mprintf(0, "Unable to allocate memory for hilights monitor=%d\n", monitor); + LOG_DEBUG.printf("Unable to allocate memory for hilights monitor=%d", monitor); TelcomHiLiteCount[monitor] = 0; return; } @@ -2471,7 +2470,7 @@ void TelComSendEvent(int event_num, int parm1, int parm2) { } } - mprintf(0, "Warning: TelCom Event Queue Overflow\n"); + LOG_WARNING << "Warning: TelCom Event Queue Overflow"; } /* @@ -2572,7 +2571,7 @@ void TelComHandleAllEvents(tTelComInfo *tcs) { // handle the event switch (event.id) { case -1: - mprintf(0, "TelCom Error: Trying to process an event of type -1\n"); + LOG_FATAL << "TelCom Error: Trying to process an event of type -1"; Int3(); // Hey!! How'd we pop off a -1!!! Get Jeff break; case TEVT_TCQUIT: { @@ -2581,7 +2580,7 @@ void TelComHandleAllEvents(tTelComInfo *tcs) { } break; case TEVT_SCREENSHOT: { // take a screenshot - mprintf(0, "Taking Screenshot\n"); + LOG_INFO << "Taking Screenshot"; DoScreenshot(); } break; case TEVT_TCNEXT: { @@ -2606,7 +2605,7 @@ void TelComHandleAllEvents(tTelComInfo *tcs) { TelComHandleKeyPress(event.parms[0], true, TC_current_screen); } break; default: - mprintf(0, "TelCom System Warning: Unhandled event %d\n", event.id); + LOG_WARNING.printf("TelCom System Warning: Unhandled event %d", event.id); break; } } @@ -3078,7 +3077,7 @@ void TelComHandleKeyPress(int key, bool click, int screen_id) { break; } default: - mprintf(0, "TelCom Warning: Keypressed not valid\n"); + LOG_WARNING << "TelCom Warning: Keypressed not valid"; } } @@ -3315,11 +3314,11 @@ void TelcomStartSound(int sid) { // make sure the handle is there if (TelcomSounds[sid].handle == -1) { - mprintf(0, "TelCom Sound Warning: '%s' hasn't been loaded yet, trying to load\n", TCSoundFiles[sid]); + LOG_DEBUG.printf("TelCom Sound Warning: '%s' hasn't been loaded yet, trying to load", TCSoundFiles[sid]); TelcomSounds[sid].handle = FindSoundName(IGNORE_TABLE(TCSoundFiles[sid])); if (TelcomSounds[sid].handle == -1) { - mprintf(0, "TelCom Sound Warning: 2nd try failed, bailing\n"); + LOG_WARNING << "TelCom Sound Warning: 2nd try failed, bailing"; return; } } @@ -3475,7 +3474,7 @@ void TelComSingleShipSelect(tTelComInfo *tcs) { int found_ships = TCSSCollectInfo(); if (found_ships < 2 || found_ships > 3) { // not supported - mprintf(0, "Skipping Single Player Ship Selecting, %d ships found\n", found_ships); + LOG_DEBUG.printf("Skipping Single Player Ship Selecting, %d ships found", found_ships); int ship_index_to_use = 0; int bit = 0x01; @@ -3566,7 +3565,7 @@ void TelComSingleShipSelect(tTelComInfo *tcs) { int focus_ship = -1; for (int j = 0; j < MAX_NUM_SHIPS; j++) { if (SSShips[j].found && SSShips[j].ship_index == Players[Player_num].ship_index) { - mprintf(0, "Current Ship: %s\n", Ships[SSShips[j].ship_index].name); + LOG_DEBUG.printf("Current Ship: %s", Ships[SSShips[j].ship_index].name); focus_ship = SSShips[j].efxnum; break; } @@ -3626,7 +3625,7 @@ void TelComSingleShipSelect(tTelComInfo *tcs) { TelcomRenderSetCallback(NULL); int ship_index_to_use = TCSSGetSelectedShipIndex(); - mprintf(0, "Selected: %s\n", Ships[ship_index_to_use].name); + LOG_DEBUG.printf("Selected: %s", Ships[ship_index_to_use].name); Players[Player_num].ship_index = ship_index_to_use; TelCom_ClearCustomKeyEvents(); @@ -3675,7 +3674,7 @@ int TCSSCollectInfo(void) { } } - mprintf(0, "Collecting Ship Info: %d ships available\n", found); + LOG_DEBUG.printf("Collecting Ship Info: %d ships available", found); TCShipSelect.ShipCount = found; return found; @@ -3708,7 +3707,7 @@ void TCSSButtonCallback(int efxnum) { } if (selected_id == -1) { - mprintf(0, "Invalid selected id for efxnum %d\n", efxnum); + LOG_WARNING.printf("Invalid selected id for efxnum %d", efxnum); return; } @@ -3728,7 +3727,7 @@ void TCSSButtonCallback(int efxnum) { float size; TCShipSelect.ship_model = Ships[SSShips[selected_id].ship_index].model_handle; if (TCShipSelect.ship_model == -1) { - mprintf(0, "ship_model is -1\n"); + LOG_FATAL << "ship_model is -1"; Int3(); } @@ -4008,7 +4007,7 @@ void TelCom_SendSystemEvent(int event_num, int parm1, int parm2) { } } - mprintf(0, "Warning: TelCom System Event Queue Overflow\n"); + LOG_WARNING << "Warning: TelCom System Event Queue Overflow"; } /* diff --git a/Descent3/TelComEffects.cpp b/Descent3/TelComEffects.cpp index 70ba72d7..f1941b86 100644 --- a/Descent3/TelComEffects.cpp +++ b/Descent3/TelComEffects.cpp @@ -135,11 +135,12 @@ #include #include +#include #include "TelComEffects.h" +#include "log.h" #include "mem.h" #include "vecmat.h" -#include #include "textaux.h" #include "hlsoundlib.h" #include "soundload.h" @@ -554,7 +555,6 @@ void RenderScreen(int screen, tTelComInfo *tsys, float Frametime) { node = TCEffects[node].next; } - // mprintf(0,"Effect Count: %d effects\n",count); } // Renders an effect @@ -623,7 +623,7 @@ void SendEventToEffect(int effect, int event, int parm1, int parm2) { } // if we got here than the event queue is filled up - mprintf(0, "Warning: Event queue filled up for effect %d\n", effect); + LOG_WARNING.printf("Warning: Event queue filled up for effect %d", effect); } // Pops off an event for processesing, returns -1 if no event available @@ -962,7 +962,7 @@ int CreateButtonEffect(TCBUTTONDESC* desc, int monitor, int screen, int id) { if (tce->buttoninfo.bm_handle == -1) { desc->w = desc->h = 0; tce->buttoninfo.bm_handle = BAD_BITMAP_HANDLE; - mprintf(0, "Unable to load bmp '%s'\n", desc->filename); + LOG_WARNING.printf("Unable to load bmp '%s'", desc->filename); } else { desc->w = bm_w(tce->buttoninfo.bm_handle, 0); desc->h = bm_h(tce->buttoninfo.bm_handle, 0); @@ -973,7 +973,7 @@ int CreateButtonEffect(TCBUTTONDESC* desc, int monitor, int screen, int id) { tce->buttoninfo.bmfocus_handle = bm_AllocLoadFileBitmap(IGNORE_TABLE(desc->filename_focus), 0); if (tce->buttoninfo.bmfocus_handle == -1) { tce->buttoninfo.bmfocus_handle = BAD_BITMAP_HANDLE; - mprintf(0, "Unable to load bmp '%s'\n", desc->filename_focus); + LOG_WARNING.printf("Unable to load bmp '%s'", desc->filename_focus); } else { bm_CreateChunkedBitmap(tce->buttoninfo.bmfocus_handle, &tce->buttoninfo.chunkfocus_bmp); } @@ -983,7 +983,7 @@ int CreateButtonEffect(TCBUTTONDESC* desc, int monitor, int screen, int id) { if (desc->flasher) { tce->buttoninfo.flash_handle = bm_AllocLoadFileBitmap(IGNORE_TABLE(desc->flash_filename), 0); if (tce->buttoninfo.flash_handle == -1) { - mprintf(0, "Unable to load bmp '%s'\n", desc->flash_filename); + LOG_WARNING.printf("Unable to load bmp '%s'", desc->flash_filename); } else { bm_CreateChunkedBitmap(tce->buttoninfo.flash_handle, &tce->buttoninfo.flash_chunk); } @@ -995,7 +995,7 @@ int CreateButtonEffect(TCBUTTONDESC* desc, int monitor, int screen, int id) { if (desc->flasher) { tce->buttoninfo.flashfocus_handle = bm_AllocLoadFileBitmap(IGNORE_TABLE(desc->flash_filename_focus), 0); if (tce->buttoninfo.flashfocus_handle == -1) { - mprintf(0, "Unable to load bmp '%s'\n", desc->flash_filename_focus); + LOG_WARNING.printf("Unable to load bmp '%s'", desc->flash_filename_focus); } else { bm_CreateChunkedBitmap(tce->buttoninfo.flashfocus_handle, &tce->buttoninfo.flashfocus_chunk); } @@ -1109,7 +1109,7 @@ bool CreateBmpStatic(tceffect *tce, const char *filename) { tce->bmpinfo.bm_handle = bm_AllocLoadFileBitmap(IGNORE_TABLE(filename), 0); if (tce->bmpinfo.bm_handle == -1) { tce->bmpinfo.bm_handle = BAD_BITMAP_HANDLE; - mprintf(0, "Unable to load bmp '%s'\n", filename); + LOG_WARNING.printf("Unable to load bmp '%s'", filename); } else bm_CreateChunkedBitmap(tce->bmpinfo.bm_handle, &tce->bmpinfo.chunk_bmp); return true; @@ -1122,7 +1122,7 @@ bool CreateBmpBlur(tceffect *tce, const char *filename) { tce->bmpinfo.bm_handle = bm_AllocLoadFileBitmap(IGNORE_TABLE(filename), 0); if (tce->bmpinfo.bm_handle == -1) { tce->bmpinfo.bm_handle = BAD_BITMAP_HANDLE; - mprintf(0, "Unable to load bmp '%s'\n", filename); + LOG_WARNING.printf("Unable to load bmp '%s'", filename); } else { tce->bmpinfo.temp_bmhandle = bm_AllocBitmap(bm_w(tce->bmpinfo.bm_handle, 0), bm_h(tce->bmpinfo.bm_handle, 0), 0); if (tce->bmpinfo.temp_bmhandle == -1) @@ -1147,7 +1147,7 @@ bool CreateBmpScanline(tceffect *tce, const char *filename) { tce->bmpinfo.temp_bmhandle = BAD_BITMAP_HANDLE; if (tce->bmpinfo.bm_handle == -1) { tce->bmpinfo.bm_handle = BAD_BITMAP_HANDLE; - mprintf(0, "Unable to load bmp '%s'\n", filename); + LOG_WARNING.printf("Unable to load bmp '%s'", filename); } else { tce->bmpinfo.temp_bmhandle = bm_AllocBitmap(bm_w(tce->bmpinfo.bm_handle, 0), bm_h(tce->bmpinfo.bm_handle, 0), 0); if (tce->bmpinfo.temp_bmhandle == -1) @@ -1167,7 +1167,7 @@ bool CreateBmpInvert(tceffect *tce, const char *filename) { tce->bmpinfo.temp_bmhandle = BAD_BITMAP_HANDLE; if (tce->bmpinfo.bm_handle == -1) { tce->bmpinfo.bm_handle = BAD_BITMAP_HANDLE; - mprintf(0, "Unable to load bmp '%s'\n", filename); + LOG_WARNING.printf("Unable to load bmp '%s'", filename); } else { tce->bmpinfo.temp_bmhandle = bm_AllocBitmap(bm_w(tce->bmpinfo.bm_handle, 0), bm_h(tce->bmpinfo.bm_handle, 0), 0); if (tce->bmpinfo.temp_bmhandle == -1) @@ -1188,7 +1188,7 @@ bool CreateBmpStretch(tceffect *tce, const char *filename) { tce->bmpinfo.bm_count = 0; if (tce->bmpinfo.bm_handle == -1) { tce->bmpinfo.bm_handle = BAD_BITMAP_HANDLE; - mprintf(0, "Unable to load bmp '%s'\n", filename); + LOG_WARNING.printf("Unable to load bmp '%s'", filename); } else { // determine how many wide we need int src_w = bm_w(tce->bmpinfo.bm_handle, 0); @@ -1267,7 +1267,7 @@ bool CreateBackground(tceffect *tce) { return true; } bool CreateSound(tceffect *tce, const char *filename) { tce->soundinfo.handle = FindSoundName(IGNORE_TABLE(filename)); if (tce->soundinfo.handle == -1) { - mprintf(0, "Unable to find sound '%s'\n", filename); + LOG_WARNING.printf("Unable to find sound '%s'", filename); } return true; } diff --git a/Descent3/TelcomEffectsRender.cpp b/Descent3/TelcomEffectsRender.cpp index 9061f1be..9c2a269a 100644 --- a/Descent3/TelcomEffectsRender.cpp +++ b/Descent3/TelcomEffectsRender.cpp @@ -48,13 +48,15 @@ * * $NoKeywords: $ */ -#include "TelComEffects.h" -#include "textaux.h" -#include "mem.h" -#include "hlsoundlib.h" -#include -#include +#include +#include + +#include "TelComEffects.h" +#include "hlsoundlib.h" +#include "log.h" +#include "mem.h" +#include "textaux.h" int glitch_dx = 0, glitch_dy = 0; #define DISABLED_TEXT_COLOR GR_RGB(180, 180, 180); @@ -83,21 +85,16 @@ void RenderTextStatic(tceffect *tce, float frametime, int xoff, int yoff, bool o switch (evt.id) { case TEVT_SCROLLDOWN: if (tce->textinfo.scroll_d) { - // mprintf(0,"Down Baby Down!\n"); tce->textinfo.line_index++; } break; case TEVT_SCROLLUP: if (tce->textinfo.line_index > 0) { - // mprintf(0,"Up Baby Up!\n"); tce->textinfo.line_index--; } break; - case TEVT_GAINFOCUS: { - // mprintf(0,"Text %d Gain Focus\n",tce-TCEffects); - } break; + case TEVT_GAINFOCUS: case TEVT_LOSTFOCUS: { - // mprintf(0,"Text %d Lost Focus\n",tce-TCEffects); } break; } } @@ -159,21 +156,16 @@ void RenderTextType(tceffect *tce, float frametime, int xoff, int yoff, bool ok_ switch (evt.id) { case TEVT_SCROLLDOWN: if (tce->textinfo.scroll_d) { - // mprintf(0,"Down Baby Down!\n"); tce->textinfo.line_index++; } break; case TEVT_SCROLLUP: if (tce->textinfo.line_index > 0) { - // mprintf(0,"Up Baby Up!\n"); tce->textinfo.line_index--; } break; - case TEVT_GAINFOCUS: { - // mprintf(0,"Text %d Gain Focus\n",tce-TCEffects); - } break; + case TEVT_GAINFOCUS: case TEVT_LOSTFOCUS: { - // mprintf(0,"Text %d Lost Focus\n",tce-TCEffects); } break; } } @@ -300,21 +292,16 @@ void RenderTextFade(tceffect *tce, float frametime, int xoff, int yoff, bool ok_ switch (evt.id) { case TEVT_SCROLLDOWN: if (tce->textinfo.scroll_d) { - // mprintf(0,"Down Baby Down!\n"); tce->textinfo.line_index++; } break; case TEVT_SCROLLUP: if (tce->textinfo.line_index > 0) { - // mprintf(0,"Up Baby Up!\n"); tce->textinfo.line_index--; } break; - case TEVT_GAINFOCUS: { - // mprintf(0,"Text %d Gain Focus\n",tce-TCEffects); - } break; + case TEVT_GAINFOCUS: case TEVT_LOSTFOCUS: { - // mprintf(0,"Text %d Lost Focus\n",tce-TCEffects); } break; } } @@ -634,7 +621,7 @@ void RenderBmpInvert(tceffect *tce, float frametime, int xoff, int yoff, bool ok k = 1.0; changed = false; } else if (k < 0) { - mprintf(0, "k<0 on inverse bitmap...bashing (%.2f/%.2f)\n", tce->age, tce->speed); + LOG_WARNING.printf("k<0 on inverse bitmap...bashing (%.2f/%.2f)", tce->age, tce->speed); if (tce->age < 0) Int3(); if (tce->speed < 0) @@ -896,11 +883,9 @@ void RenderButton(tceffect *tce, float frametime, int xoff, int yoff, bool ok_to switch (evt.id) { case TEVT_GAINFOCUS: { int num = tce - TCEffects; - // mprintf(0,"Button: Recv'd GAIN FOCUS Event (%d)\n",num); } break; case TEVT_LOSTFOCUS: { int num = tce - TCEffects; - // mprintf(0,"Button: Recv'd LOST FOCUS Event (%d)\n",num); } break; case TEVT_MOUSEOVER: { if (tce->flags & OBF_GLOW) { @@ -931,48 +916,41 @@ void RenderButton(tceffect *tce, float frametime, int xoff, int yoff, bool ok_to // send out the event to the appropriate system/effect switch (tce->buttoninfo.button_type) { case BUTT_UPARROW: { - // mprintf(0,"Button: Telling Text to Scroll Up\n"); int efxnum = GetEfxNumFromID(tce->buttoninfo.parent, tce->screen); if (efxnum != -1) { SendEventToEffect(efxnum, TEVT_SCROLLUP); } } break; case BUTT_DOWNARROW: { - // mprintf(0,"Button: Telling Text to Scroll Down\n"); int efxnum = GetEfxNumFromID(tce->buttoninfo.parent, tce->screen); if (efxnum != -1) { SendEventToEffect(efxnum, TEVT_SCROLLDOWN); } } break; case BUTT_NEXTPAGE: - // mprintf(0,"Button: Telling TelCom to go to Next Page\n"); TelComSendEvent(TEVT_TCNEXT); break; case BUTT_PREVPAGE: - // mprintf(0,"Button: Telling TelCom to go to Prev Page\n"); TelComSendEvent(TEVT_TCPREV); break; case BUTT_QUIT: - // mprintf(0,"Button: Telling TelCom to go to Quit\n"); TelComSendEvent(TEVT_TCQUIT); break; case BUTT_JUMP: - // mprintf(0,"Button: Telling TelCom to jump to %d\n",tce->buttoninfo.jump_page); TelComSendEvent(TEVT_TCJUMP, tce->buttoninfo.jump_page); break; case BUTT_INTERNAL: - // mprintf(0,"Button: Calling internal callback\n"); if (tce->buttoninfo.internal) tce->buttoninfo.internal((int)(tce - TCEffects)); break; default: - mprintf(0, "Button: Invalid Button Type\n"); + LOG_FATAL << "Button: Invalid Button Type"; Int3(); // invalid button type // missing JUMP!!!!!!!!!!!!!!!! }; } break; default: { - mprintf(0, "Button: Recv'd Evt %d\n", evt.id); + LOG_WARNING.printf("Button: Recv'd Evt %d", evt.id); } break; }; } diff --git a/Descent3/TerrainSearch.cpp b/Descent3/TerrainSearch.cpp index a70a003d..2d240399 100644 --- a/Descent3/TerrainSearch.cpp +++ b/Descent3/TerrainSearch.cpp @@ -216,17 +216,16 @@ * $NoKeywords: $ */ +#include + #include "terrain.h" #include "3d.h" -#include "mono.h" +#include "log.h" #include "vecmat.h" #include "pserror.h" -#include "pstypes.h" #include "descent.h" #include "game.h" #include "gameloop.h" -#include -#include #include "config.h" #include "dedicated_server.h" @@ -437,7 +436,7 @@ __inline void CheckCellOccupancy(int x, int y, int *ccount, uint8_t lod) { int n, simplemul, i; if (*ccount >= MAX_CELLS_TO_RENDER) { - mprintf(0, "Trying to render too many cells! Cell limit=%d\n", MAX_CELLS_TO_RENDER); + LOG_WARNING.printf("Trying to render too many cells! Cell limit=%d", MAX_CELLS_TO_RENDER); #ifndef NEWEDITOR Detail_settings.Terrain_render_distance = 80.0 * TERRAIN_SIZE; #endif diff --git a/Descent3/WeaponFire.cpp b/Descent3/WeaponFire.cpp index 6d1bebbf..3e0c2eec 100644 --- a/Descent3/WeaponFire.cpp +++ b/Descent3/WeaponFire.cpp @@ -901,32 +901,29 @@ * $NoKeywords: $ */ +#include +#include +#include + #include "weapon.h" #include "descent.h" -#include "weapon.h" #include "polymodel.h" #include "room.h" #include "object.h" -#include "terrain.h" #include "player.h" #include "hud.h" #include "hlsoundlib.h" #include "gameevent.h" -#include "polymodel.h" -#include "lighting.h" #include "fireball.h" -#include -#include #include "findintersection.h" +#include "log.h" #include "robotfire.h" #include "AIMain.h" -#include "controls.h" #include "damage.h" #include "sounds.h" #include "viseffect.h" #include "vclip.h" #include "SmallViews.h" -#include "hlsoundlib.h" #include "soundload.h" #include "stringtable.h" #include "multi.h" @@ -942,7 +939,6 @@ #include "psrand.h" #include "BOA.h" -#include static bool AreObjectsAttached(const object *obj1, const object *obj2) { const bool f_o1_a = (obj1->flags & OF_ATTACHED) != 0; @@ -1242,14 +1238,15 @@ int CreateAndFireWeapon(vector *pos, vector *dir, object *parent, int weapon_num fate = fvi_FindIntersection(&fq, &hit_data); if (fate != HIT_NONE) { - mprintf(0, "Warning: Laser from parent=%d weapon point is in a wall or object, didn't fire!\n", OBJNUM(parent)); + LOG_WARNING.printf("Warning: Laser from parent=%d weapon point is in a wall or object, didn't fire!", + OBJNUM(parent)); return -1; } objnum = ObjCreate(OBJ_WEAPON, weapon_num, hit_data.hit_room, pos, NULL, parent->handle); if (objnum < 0) { - mprintf(1, "Can't create laser - Out of objects!\n"); + LOG_WARNING << "Can't create laser - Out of objects!"; return -1; } @@ -1751,7 +1748,7 @@ bool WeaponCalcGun(vector *gun_point, vector *gun_normal, object *obj, int gun_n pm = &Poly_models[obj->rtype.pobj_info.model_num]; if (pm->n_guns == 0) { - mprintf(0, "WARNING: Object with no weapons is firing.\n", gun_num); + LOG_WARNING.printf("WARNING: Object with no weapons is firing.", gun_num); if (gun_point) *gun_point = obj->pos; @@ -1765,7 +1762,7 @@ bool WeaponCalcGun(vector *gun_point, vector *gun_normal, object *obj, int gun_n SetModelAnglesAndPos(pm, normalized_time); if (gun_num < 0 || gun_num >= pm->n_guns) { - mprintf(0, "WARNING: Bashing gun num %d to 0.\n", gun_num); + LOG_WARNING.printf("WARNING: Bashing gun num %d to 0.", gun_num); if (gun_point) *gun_point = obj->pos; if (gun_normal) @@ -1841,7 +1838,7 @@ int FireWeaponFromObject(object *obj, int weapon_num, int gun_num, bool f_force_ if (gun_num >= pm->n_guns) { // We don't have a gun point for this gun! - mprintf(0, "Trying to fire from gun %d...we don't have that gun!\n", gun_num); + LOG_WARNING.printf("Trying to fire from gun %d...we don't have that gun!", gun_num); laser_pos = obj->pos; laser_dir = obj->orient.fvec; } else { @@ -3220,7 +3217,7 @@ void CreateRobotSpawnFromWeapon(object *obj) { return; // clients do not create robots without the servers permission if (wp->robot_spawn_handle == -1) { - mprintf(0, "Trying to create an invalid robot spawn!\n"); + LOG_WARNING << "Trying to create an invalid robot spawn!"; return; } object *parent_obj = ObjGetUltimateParent(obj); diff --git a/Descent3/aipath.cpp b/Descent3/aipath.cpp index a10ad9ad..21b92eed 100644 --- a/Descent3/aipath.cpp +++ b/Descent3/aipath.cpp @@ -21,9 +21,9 @@ #include "AIGoal.h" #include "BOA.h" #include "AIMain.h" +#include "log.h" #include "object.h" #include "objinfo.h" -#include "memory.h" #include "doorway.h" #include "aistruct.h" #include "terrain.h" @@ -43,12 +43,10 @@ static void AIUpdatePathInfo(q_item **node_list, int start, int end) { AIAltPathNumNodes = 0; - // mprintf(0, "start crash loop\n"); while (cur_room != -1) { AIAltPath[AIAltPathNumNodes++] = cur_room; cur_room = node_list[cur_room]->parent; } - // mprintf(0, "end crash loop\n"); // Reverse the list (so it is what we want) for (i = 0; i < (AIAltPathNumNodes >> 1); i++) { @@ -73,8 +71,6 @@ bool AIFindAltPath(object *obj, int i, int j, float *dist) { q_item *node_list[MAX_ROOMS + 8]; - // mprintf(0, "AI: Finding an alternate path from %d to %d\n", i, j); - if (i == -1 || j == -1) { delete start_node; return false; @@ -171,10 +167,6 @@ bool AIFindAltPath(object *obj, int i, int j, float *dist) { } } - // Mark as an impossible path. - - // mprintf(0, "Found an impossible path\n"); - done: for (counter = 0; counter < MAX_ROOMS + 8; counter++) { if (node_list[counter]) @@ -201,7 +193,6 @@ done: } } - // mprintf(0, "Done\n"); return f_found; } @@ -356,14 +347,6 @@ void AIPathMoveTurnTowardsNode(object *obj, vector *mdir, bool *f_moved) { vector cur_pos; AIPathGetCurrentNodePos(aip, &cur_pos); - // mprintf(0, "Cur pos = %f,%f,%f\n", XYZ(&cur_pos)); - - // mprintf(0, "1 R %d, Goal p %d, n %d\n", f_reverse, p, n); - - // mprintf(0, "s %f, %f, %f\n", XYZ(&obj->pos)); - // mprintf(0, "l %f, %f, %f\n", XYZ(&obj->last_pos)); - - // mprintf(0, "%d is at Node %d\n", OBJNUM(obj), n); bool f_force_complete_stopping = false; @@ -387,19 +370,6 @@ void AIPathMoveTurnTowardsNode(object *obj, vector *mdir, bool *f_moved) { *f_moved = false; // AIMoveTowardsDir(obj, &dir); } - // removed check if(f_reverse && (path_info->next_node < path_info->start_node)) - // removed check { - // removed check mprintf(0, "AI ERROR: Fixed a bad predefined path next_node to goal_node"); - // removed check path_info->next_node = path_info->start_node; - // removed check Int3(); - // removed check } - // removed check - // removed check if(!(f_reverse) && path_info->next_node > path_info->end_node) - // removed check { - // removed check mprintf(0, "AI ERROR: Fixed a bad predefined path next_node to goal_node"); - // removed check path_info->next_node = path_info->end_node; - // removed check Int3(); - // removed check } bool f_pass_node; int last_n; @@ -490,33 +460,27 @@ pass_node: } if (f_pass_node) { - // mprintf(0, "f_pass_node\n"); if (((f_reverse) && AIPathAtStart(aip)) || ((!f_reverse) && AIPathAtEnd(aip))) { - // mprintf(0, "At end node: "); switch (g_ptr->flags & GFM_END_OF_PATH) { case GF_PATH_REVERSE_AT_END: - // mprintf(0, "End reverse dir\n"); if (f_reverse) g_ptr->flags &= ~GF_PATH_MOVE_REVERSE_DIR; else g_ptr->flags |= GF_PATH_MOVE_REVERSE_DIR; return; case GF_PATH_CIRCLE_AT_END: - // mprintf(0, "End circle dir\n"); if (f_reverse) AIPathSetAtEnd(aip); else AIPathSetAtStart(aip); return; default: - // mprintf(0, "End kill goal\n"); AIPathComplete(obj); return; } } else { - // mprintf(0, "Passed node\n"); if (g_ptr->flags & GF_PATH_MOVE_REVERSE_DIR) AIPathMoveToPrevNode(aip); else @@ -568,7 +532,7 @@ static bool AIPathGetDPathSlot(int *slot, int handle) { } } - mprintf(0, "Out of dynamic paths"); + LOG_ERROR << "Out of dynamic paths"; ASSERT(0); // -- get chris return false; } @@ -605,7 +569,7 @@ static bool AIPathAddDPath(ai_path_info *aip, int handle) { bool status; if (aip->num_paths >= MAX_JOINED_PATHS) { - mprintf(0, "AI ERROR: Tried to join too many paths (Adding dpath)\n"); + LOG_ERROR << "AI ERROR: Tried to join too many paths (Adding dpath)"; return false; } @@ -630,7 +594,7 @@ static bool AIPathAddStaticPath(ai_path_info *aip, int path_id, int start_index, // chrishack -- validation code is needed if (aip->num_paths >= MAX_JOINED_PATHS) { - mprintf(0, "AI ERROR: Tried to join too many paths (Adding spath)\n"); + LOG_ERROR << "AI ERROR: Tried to join too many paths (Adding spath)"; return false; } @@ -1017,11 +981,9 @@ bool AIPathAllocPath(object *obj, ai_frame *ai_info, void *goal_ptr, int *start_ ai_path_info *aip = &ai_info->path; -#ifdef _DEBUG if (AI_debug_robot_do && OBJNUM(obj) == AI_debug_robot_index) { - mprintf(0, "AI Note: In free path\n"); + LOG_DEBUG << "AI Note: In free path"; } -#endif AIPathFreePath(aip); // if(ai_info->awareness <= AWARE_NONE && !(ai_info->flags & AIF_PERSISTANT)) // chrishack -- scalar max_nodes in @@ -1105,7 +1067,7 @@ bool AIPathAllocPath(object *obj, ai_frame *ai_info, void *goal_ptr, int *start_ AIGenerateAltBOAPath(start_pos, end_pos, aip, &slot, &cur_node, handle); if (!f_path_exists) { - mprintf(0, "Warning Alt path from %d to %d failed.\n", *start_room, *end_room); + LOG_WARNING.printf("Warning Alt path from %d to %d failed.", *start_room, *end_room); } } } else if (!f_bline_ok) { @@ -1136,29 +1098,23 @@ bool AIPathAllocPath(object *obj, ai_frame *ai_info, void *goal_ptr, int *start_ } } else { f_path_exists = false; - // if(!(0x80000000 & *start_room) || !(0x80000000 & *end_room)) - // mprintf(0, "No path available from %d to %d\n", *start_room, *end_room); -#ifdef _DEBUG if (AI_debug_robot_do && OBJNUM(obj) == AI_debug_robot_index) { - mprintf(0, "AI Note: In free path\n"); + LOG_DEBUG.printf("AI Note: In free path"); } -#endif AIPathFreePath(aip); return false; } } else { f_path_exists = false; - mprintf(0, "No dynamic paths left\n"); + LOG_DEBUG << "No dynamic paths left"; } if (!f_path_exists) { -#ifdef _DEBUG if (AI_debug_robot_do && OBJNUM(obj) == AI_debug_robot_index) { - mprintf(0, "AI Note: In free path\n"); + LOG_DEBUG << "AI Note: In free path"; } -#endif AIPathFreePath(aip); return false; @@ -1172,11 +1128,9 @@ bool AIPathSetAsStaticPath(object *obj, void *goal_ptr, int path_id, int start_n ai_frame *ai_info = obj->ai_info; ai_path_info *aip = &ai_info->path; -#ifdef _DEBUG if (AI_debug_robot_do && OBJNUM(obj) == AI_debug_robot_index) { - mprintf(0, "AI Note: In free path\n"); + LOG_DEBUG << "AI Note: In free path"; } -#endif AIPathFreePath(aip); aip->goal_index = (goal *)goal_ptr - ai_info->goals; @@ -1227,12 +1181,6 @@ bool MakeTestPath(int *start_room, vector *pos) { AddHUDMessage("The test path has %d nodes.", count); - // #ifdef _DEBUG - // if(AI_debug_robot_do && OBJNUM(obj) == AI_debug_robot_index) - // { - // mprintf(0, "AI Note: In free path\n"); - // } - // #endif AIPathFreePath(&ai_info.path); return true; diff --git a/Descent3/args.cpp b/Descent3/args.cpp index 79614a2c..f3a38193 100644 --- a/Descent3/args.cpp +++ b/Descent3/args.cpp @@ -16,9 +16,10 @@ * along with this program. If not, see . */ +#include + #include "args.h" -#include "mono.h" -#include +#include "log.h" #if defined(_WIN32) #define strcasecmp stricmp @@ -30,7 +31,7 @@ char GameArgs[MAX_ARGS][MAX_CHARS_PER_ARG]; const char *GetArg(int index) { if (index >= TotalArgs || index == 0) - return NULL; + return nullptr; return GameArgs[index]; } @@ -71,19 +72,19 @@ void GatherArgs(const char *str) { TotalArgs = curarg; for (int q = 0; q < TotalArgs; q++) - mprintf(0, "GatherArgs: Arg (%d) is [%s].", q, GameArgs[q]); + LOG_DEBUG.printf("GatherArgs: Arg (%d) is [%s].", q, GameArgs[q]); } void GatherArgs(char **argv) { TotalArgs = 0; - for (int i = 0; ((i < MAX_ARGS) && (argv[i] != NULL)); i++) { + for (int i = 0; ((i < MAX_ARGS) && (argv[i] != nullptr)); i++) { TotalArgs++; strncpy(GameArgs[i], argv[i], MAX_CHARS_PER_ARG); } // for for (int q = 0; q < TotalArgs; q++) - mprintf(0, "GatherArgs: Arg (%d) is [%s].", q, GameArgs[q]); + LOG_DEBUG.printf("GatherArgs: Arg (%d) is [%s].", q, GameArgs[q]); } // GatherArgs // Strip '-', '--', and '+' flag prefix, so --foo, -foo, +foo => foo, but pass through - -- + ++ @@ -113,12 +114,12 @@ int FindArg(const char *which) { for (int i = 1; i <= TotalArgs; i++) { if (which_matches(GameArgs[i])) { - mprintf(0, "FindArg: Found [%s] at argument index (%d).", which, i); + LOG_INFO.printf("FindArg: Found [%s] at argument index (%d).", which, i); return i; } } - mprintf(0, "FindArg: Did not find [%s] on command line.", which); + LOG_VERBOSE.printf("FindArg: Did not find [%s] on command line.", which); return 0; } @@ -127,7 +128,7 @@ int FindArgChar(const char *which, char singleCharArg) { for (int i = 1; i <= TotalArgs; i++) { char *str = GameArgs[i]; if (str[0] == '-' && str[1] == singleCharArg && str[2] == '\0') { - mprintf(0, "FindArg: Found [-%c] at argument index (%d).", singleCharArg, i); + LOG_INFO.printf("FindArg: Found [-%c] at argument index (%d).", singleCharArg, i); return i; } } diff --git a/Descent3/attach.cpp b/Descent3/attach.cpp index da442d40..eb7ea8f9 100644 --- a/Descent3/attach.cpp +++ b/Descent3/attach.cpp @@ -16,10 +16,9 @@ * along with this program. If not, see . */ - - #include "attach.h" #include "terrain.h" +#include "log.h" #include "multi.h" #include "game.h" #include "demofile.h" @@ -155,7 +154,7 @@ static bool AttachPointPos(object *obj, char ap, bool f_compute_pos, vector *att pm = &Poly_models[obj->rtype.pobj_info.model_num]; if (ap < 0 || ap >= pm->n_attach) { - mprintf(0, "WARNING: No ap %d on object %d.\n", ap, OBJNUM(obj)); + LOG_WARNING.printf("WARNING: No ap %d on object %d.", ap, OBJNUM(obj)); return false; } @@ -167,14 +166,11 @@ static bool AttachPointPos(object *obj, char ap, bool f_compute_pos, vector *att if (f_compute_fvec) { normal = pm->attach_slots[ap].norm; - // mprintf(0, "Original fvec is %f long.\n", vm_GetMagnitude(&normal)); } if (pm->attach_slots[ap].f_uvec && attach_uvec && f_computed_uvec) { *f_computed_uvec = true; uvec = pm->attach_slots[ap].uvec; - - // mprintf(0, "Original uvec is %f long.\n", vm_GetMagnitude(&uvec)); } else if (f_computed_uvec) { *f_computed_uvec = false; } @@ -213,12 +209,10 @@ static bool AttachPointPos(object *obj, char ap, bool f_compute_pos, vector *att if (f_compute_fvec) { *attach_fvec = normal * m; - // mprintf(0, "Rotated fvec is %f long.\n", vm_GetMagnitude(attach_fvec)); } if (f_computed_uvec && *f_computed_uvec) { *attach_uvec = uvec * m; - // mprintf(0, "Rotated uvec is %f long.\n", vm_GetMagnitude(attach_uvec)); } if (f_compute_pos) @@ -478,12 +472,12 @@ bool AttachObject(object *parent, char parent_ap, object *child, char child_ap, poly_model *child_pm = &Poly_models[child->rtype.pobj_info.model_num]; if (parent_ap < 0 || parent_ap >= parent_pm->n_attach) { - mprintf(0, "ATTACH: Parent AP invalid\n"); + LOG_WARNING << "ATTACH: Parent AP invalid"; return false; } if (child->flags & OF_ATTACHED) { - mprintf(0, "ATTACH: Child already attached to someone\n"); + LOG_WARNING << "ATTACH: Child already attached to someone"; return false; } @@ -511,11 +505,11 @@ bool AttachObject(object *parent, char parent_ap, object *child, char child_ap, return true; } - mprintf(0, "ATTACH: AP attach failed\n"); + LOG_WARNING << "ATTACH: AP attach failed"; return false; } - mprintf(0, "ATTACH: Child AP (%d) - child only has %d attach points\n", child_ap, child_pm->n_attach); + LOG_DEBUG.printf("ATTACH: Child AP (%d) - child only has %d attach points", child_ap, child_pm->n_attach); return false; } @@ -529,12 +523,12 @@ bool AttachObject(object *parent, char parent_ap, object *child, float percent_r poly_model *child_pm = &Poly_models[parent->rtype.pobj_info.model_num]; if (parent_ap < 0 || parent_ap >= parent_pm->n_attach) { - mprintf(0, "ATTACH: Parent AP invalid\n"); + LOG_WARNING << "ATTACH: Parent AP invalid"; return false; } if (child->flags & OF_ATTACHED) { - mprintf(0, "ATTACH: Child already attached to someone\n"); + LOG_WARNING << "ATTACH: Child already attached to someone"; return false; } @@ -573,11 +567,11 @@ bool AttachObject(object *parent, char parent_ap, object *child, float percent_r return true; } - mprintf(0, "ATTACH: RAD attach failed\n"); + LOG_WARNING << "ATTACH: RAD attach failed"; return false; } - mprintf(0, "ATTACH: Child percent rad is invalid\n"); + LOG_WARNING << "ATTACH: Child percent rad is invalid"; return false; } diff --git a/Descent3/audiotaunts.cpp b/Descent3/audiotaunts.cpp index c8183cfa..1238706c 100644 --- a/Descent3/audiotaunts.cpp +++ b/Descent3/audiotaunts.cpp @@ -16,17 +16,16 @@ * along with this program. If not, see . */ -#include -#include +#include +#include -#include "mono.h" #include "debug.h" #include "pserror.h" -#include "pstypes.h" #include "audiotaunts.h" #include "cfile.h" #include "audio_encode.h" #include "byteswap.h" +#include "log.h" #include "mem.h" #include "ddio.h" #include "manage.h" @@ -109,7 +108,7 @@ bool taunt_PlayPlayerTaunt(int pnum, int index) { return false; if (index < 0 || index > 3) { - mprintf(0, "TAUNT: invalid index %d\n", index); + LOG_WARNING.printf("TAUNT: invalid index %d", index); return false; } @@ -134,7 +133,7 @@ bool taunt_PlayPlayerTaunt(int pnum, int index) { ddio_MakePath(fullpath, LocalCustomSoundsDir, file, NULL); if (!cfexist(fullpath)) { - mprintf(0, "TAUNT: file %s doesn't exist (pnum=%d)\n", fullpath, pnum); + LOG_WARNING.printf("TAUNT: file %s doesn't exist (pnum=%d)", fullpath, pnum); return false; } @@ -238,14 +237,14 @@ bool taunt_ImportWave(const char *wave_filename, const char *outputfilename) { // first make sure the wave file exists if (!cfexist(wave_filename)) { - mprintf(0, "AudioTaunt: Can't Import wav, missing %s\n", wave_filename); + LOG_WARNING.printf("AudioTaunt: Can't Import wav, missing %s", wave_filename); TauntLastError = TAUNTIMPERR_NOTFOUND; return false; } // make sure the output file doesn't exist so we don't overwrite if (cfexist(outputfilename)) { - mprintf(0, "AudioTaunt: Can't Import wav, %s already exists\n", outputfilename); + LOG_WARNING.printf("AudioTaunt: Can't Import wav, %s already exists", outputfilename); TauntLastError = TAUNTIMPERR_OSFEXISTS; return false; } @@ -253,7 +252,7 @@ bool taunt_ImportWave(const char *wave_filename, const char *outputfilename) { // Open the file and import char wave_ret = taunt_LoadWaveFile(wave_filename, &wavdata); if (wave_ret != 0) { - mprintf(0, "TAUNT: Unable to load wave\n"); + LOG_WARNING << "TAUNT: Unable to load wave"; switch (wave_ret) { case 1: TauntLastError = TAUNTIMPERR_NOTFOUND; @@ -293,7 +292,7 @@ bool taunt_ImportWave(const char *wave_filename, const char *outputfilename) { // file. if (!ddio_GetTempFileName(Descent3_temp_directory, "d3o", temp_filename)) { - mprintf(0, "TAUNT: Unable to create temp filename\n"); + LOG_WARNING << "TAUNT: Unable to create temp filename"; ret = false; TauntLastError = TAUNTIMPERR_INTERNALERR; goto error; @@ -301,7 +300,7 @@ bool taunt_ImportWave(const char *wave_filename, const char *outputfilename) { file = cfopen(temp_filename, "wb"); if (!file) { - mprintf(0, "TAUNT: Unable to open temp filename\n"); + LOG_WARNING << "TAUNT: Unable to open temp filename"; ret = false; TauntLastError = TAUNTIMPERR_INTERNALERR; goto error; @@ -348,7 +347,7 @@ bool taunt_ImportWave(const char *wave_filename, const char *outputfilename) { chan = wavdata.number_channels; if (!ddio_GetTempFileName(Descent3_temp_directory, "d3o", osftemp_filename)) { - mprintf(0, "TAUNT: Unable to create osftemp filename\n"); + LOG_WARNING << "TAUNT: Unable to create osftemp filename"; TauntLastError = TAUNTIMPERR_INTERNALERR; ret = false; goto error; @@ -356,7 +355,7 @@ bool taunt_ImportWave(const char *wave_filename, const char *outputfilename) { if (!aenc_Compress(temp_filename, osftemp_filename, NULL, &samples, &rate, &chan, NULL, NULL)) { // unable to compress - mprintf(0, "Unable to compress\n"); + LOG_WARNING << "Unable to compress"; ret = false; TauntLastError = TAUNTIMPERR_COMPRESSIONFAILURE; goto error; @@ -372,14 +371,14 @@ bool taunt_ImportWave(const char *wave_filename, const char *outputfilename) { StaticFileBuffer = (uint8_t *)mem_malloc(FILEBUFFER_LENGTH); if (!StaticFileBuffer) { ret = false; - mprintf(0, "Out of memory\n"); + LOG_ERROR << "Out of memory"; TauntLastError = TAUNTIMPERR_OUTOFMEM; goto error; } fpin = cfopen(osftemp_filename, "rb"); if (!fpin) { - mprintf(0, "Unable to open temp file to make osf\n"); + LOG_WARNING << "Unable to open temp file to make osf"; ret = false; TauntLastError = TAUNTIMPERR_INTERNALERR; goto error; @@ -390,7 +389,7 @@ bool taunt_ImportWave(const char *wave_filename, const char *outputfilename) { if (!osf.Open(outputfilename, true)) { ret = false; - mprintf(0, "Unable to open osf to write\n"); + LOG_WARNING << "Unable to open osf to write"; TauntLastError = TAUNTIMPERR_NOOPENOSF; goto error; } @@ -399,13 +398,13 @@ bool taunt_ImportWave(const char *wave_filename, const char *outputfilename) { // write out data. for (i = 0; i < nblocks; i++) { if (!cf_ReadBytes(StaticFileBuffer, FILEBUFFER_LENGTH, fpin)) { - mprintf(0, "Error reading from osf temp\n"); + LOG_WARNING << "Error reading from osf temp"; ret = false; TauntLastError = TAUNTIMPERR_INTERNALERR; goto error; } if (!osf.WriteBlock(StaticFileBuffer, FILEBUFFER_LENGTH)) { - mprintf(0, "Error writing to osf\n"); + LOG_WARNING << "Error writing to osf"; TauntLastError = TAUNTIMPERR_INTERNALERR; ret = false; goto error; @@ -414,13 +413,13 @@ bool taunt_ImportWave(const char *wave_filename, const char *outputfilename) { if (filelen % FILEBUFFER_LENGTH) { if (!cf_ReadBytes(StaticFileBuffer, filelen % FILEBUFFER_LENGTH, fpin)) { - mprintf(0, "Error reading from osf temp\n"); + LOG_WARNING << "Error reading from osf temp"; TauntLastError = TAUNTIMPERR_INTERNALERR; ret = false; goto error; } if (!osf.WriteBlock(StaticFileBuffer, filelen % FILEBUFFER_LENGTH)) { - mprintf(0, "Error writing to osf\n"); + LOG_WARNING << "Error writing to osf"; TauntLastError = TAUNTIMPERR_INTERNALERR; ret = false; goto error; @@ -447,7 +446,7 @@ bool taunt_ImportWave(const char *wave_filename, const char *outputfilename) { ddio_SplitPath(outputfilename, NULL, osftitle, NULL); if (!osf.SaveHeader(OSF_DIGITAL_STRM, OSF_DIGIACM_STRM, format, samples, filelen, &digihdr, osftitle)) { - mprintf(0, "Failed to write out OSF header info."); + LOG_WARNING << "Failed to write out OSF header info."; TauntLastError = TAUNTIMPERR_INTERNALERR; ret = false; goto error; @@ -525,7 +524,7 @@ char taunt_LoadWaveFile(const char *filename, tWaveFile *wave) { // Open the wave file if ((cfptr = cfopen(filename, "rb")) == NULL) { error_code = 1; - mprintf(0, "TAUNT: Wav %s not found\n", filename); + LOG_WARNING.printf("TAUNT: Wav %s not found", filename); goto error_state; } @@ -533,7 +532,7 @@ char taunt_LoadWaveFile(const char *filename, tWaveFile *wave) { temp_long = (uint32_t)cf_ReadInt(cfptr); if (temp_long != 0x46464952) { error_code = 2; - mprintf(0, "TAUNT: Wav Load: %s is not a RIFF format file\n", filename); + LOG_WARNING.printf("TAUNT: Wav Load: %s is not a RIFF format file", filename); goto error_state; } @@ -545,7 +544,7 @@ char taunt_LoadWaveFile(const char *filename, tWaveFile *wave) { temp_long = (uint32_t)cf_ReadInt(cfptr); if (temp_long != 0x45564157) { error_code = 3; - mprintf(0, "TAUNT: Wav Load: %s is not a WAVE file\n", filename); + LOG_WARNING.printf("TAUNT: Wav Load: %s is not a WAVE file", filename); goto error_state; } nextseek = cftell(cfptr); @@ -561,7 +560,7 @@ char taunt_LoadWaveFile(const char *filename, tWaveFile *wave) { cksize = cf_ReadInt(cfptr); if (cksize <= 0) { error_code = 4; - mprintf(0, "TAUNT: Wav Load: %s has an invalid block length\n", filename); + LOG_WARNING.printf("TAUNT: Wav Load: %s has an invalid block length", filename); goto error_state; } @@ -574,7 +573,7 @@ char taunt_LoadWaveFile(const char *filename, tWaveFile *wave) { // Make sure that this format was not preceeded by another format without data inbetween them. if (f_fmt) { error_code = 5; - mprintf(0, "TAUNT: Wav Load: Found 2 formats in a row in file %s\n", filename); + LOG_WARNING.printf("TAUNT: Wav Load: Found 2 formats in a row in file %s", filename); goto error_state; } @@ -646,8 +645,8 @@ char taunt_LoadWaveFile(const char *filename, tWaveFile *wave) { // Currently, we only support PCM wave files if (fmttag != 0x0001) { error_code = 6; - mprintf(0, "TAUNT Wav Load: %s is a type %s wavefile, we only support WAVE_FORMAT_PCM waves.\n", - filename,format_type); + LOG_WARNING.printf("TAUNT Wav Load: %s is a type %s wavefile, we only support WAVE_FORMAT_PCM waves.", + filename,format_type); goto error_state; } @@ -655,8 +654,8 @@ char taunt_LoadWaveFile(const char *filename, tWaveFile *wave) { number_channels = cf_ReadShort(cfptr); if (number_channels != 1) { error_code = 7; - mprintf(0, "TAUNT Wav Load: Invalid number of channels(%d)in %s, we want mono samples only.\n", - number_channels, filename); + LOG_WARNING.printf("TAUNT Wav Load: Invalid number of channels(%d)in %s, we want mono samples only.", + number_channels, filename); goto error_state; } @@ -664,8 +663,8 @@ char taunt_LoadWaveFile(const char *filename, tWaveFile *wave) { samples_per_second = cf_ReadInt(cfptr); if (samples_per_second != 22050) { error_code = 8; - mprintf(0, "TAUNT Wav Load: Invalid sample per second(%d)in %s, we want 22k samples only.\n", - samples_per_second, filename); + LOG_WARNING.printf("TAUNT Wav Load: Invalid sample per second(%d)in %s, we want 22k samples only.", + samples_per_second, filename); goto error_state; } @@ -679,8 +678,8 @@ char taunt_LoadWaveFile(const char *filename, tWaveFile *wave) { bits_per_sample = cf_ReadShort(cfptr); if (bits_per_sample != 8 && bits_per_sample != 16) { error_code = 9; - mprintf(0, "TAUNT Wav Load: Invalid bits per sample(%d)in %s, we want 8 or 16 bit samples only.\n", - bits_per_sample, filename); + LOG_WARNING.printf("TAUNT Wav Load: Invalid bits per sample(%d)in %s, we want 8 or 16 bit samples only.", + bits_per_sample, filename); goto error_state; } @@ -693,7 +692,7 @@ char taunt_LoadWaveFile(const char *filename, tWaveFile *wave) { case 0x61746164: if (!f_fmt) { error_code = 5; - mprintf(0, "TAUNT Wav Load: Format Chunk not defined before Data Chunk\n"); + LOG_WARNING << "TAUNT Wav Load: Format Chunk not defined before Data Chunk"; goto error_state; } diff --git a/Descent3/bsp.cpp b/Descent3/bsp.cpp index 62e06752..327bbbde 100644 --- a/Descent3/bsp.cpp +++ b/Descent3/bsp.cpp @@ -44,12 +44,13 @@ * Added SourceSafe headers * */ +#include #include "bsp.h" #include "room.h" +#include "log.h" #include "mem.h" #include "polymodel.h" -#include #include "object.h" #include "psrand.h" @@ -166,7 +167,7 @@ bsppolygon *NewPolygon(int roomnum, int facenum, int numverts) { newpoly = (bsppolygon *)mem_malloc(sizeof(bsppolygon)); if (newpoly == NULL) { - mprintf(0, "NewPolygon: Couldn't allocate polygon\n"); + LOG_ERROR << "NewPolygon: Couldn't allocate polygon"; return NULL; } @@ -470,8 +471,6 @@ bsppolygon *SelectPlane(listnode **polylist) { * the other polygons. But don't check it against itself */ - mprintf_at(2, 4, 0, "Plane = %c", Twirly[(Plane_twirl++) % 4]); - for (outer = *polylist; outer != NULL; outer = outer->next) { outerpoly = (bsppolygon *)outer->data; splits = front = back = planar = 0; @@ -540,8 +539,6 @@ int BuildBSPNode(bspnode *tree, listnode **polylist, int numpolys) { ASSERT(numpolys > 0); partition_poly = SelectPlane(polylist); - mprintf_at(2, 5, 0, "Node = %c", Twirly[(Node_twirl++) % 4]); - if (partition_poly == NULL) { // We hit a leaf! Fill in the appropriate leaf stuff @@ -688,16 +685,14 @@ int BuildBSPNode(bspnode *tree, listnode **polylist, int numpolys) { } } - // mprintf(0,"BuildBSPNode: Incoming=%d numfront=%d numback=%d splits=%d\n",numpolys,numfront,numback,numsplits); - if (frontlist != NULL) { if ((frontnode = NewBSPNode()) == NULL) { - mprintf(0, "BuildBSPNode: Error, can't allocate front node\n"); + LOG_ERROR << "BuildBSPNode: Error, can't allocate front node"; return 0; } if (!BuildBSPNode((bspnode *)frontnode, &frontlist, numfront)) { - mprintf(0, "BuildBSPNode: Error building front node\n"); + LOG_ERROR << "BuildBSPNode: Error building front node"; return 0; } @@ -705,7 +700,7 @@ int BuildBSPNode(bspnode *tree, listnode **polylist, int numpolys) { DestroyList(&frontlist); } else { if ((frontnode = NewBSPNode()) == NULL) { - mprintf(0, "BuildBSPNode: Error, can't allocate front node\n"); + LOG_ERROR << "BuildBSPNode: Error, can't allocate front node"; return 0; } frontnode->type = BSP_EMPTY_LEAF; @@ -714,12 +709,12 @@ int BuildBSPNode(bspnode *tree, listnode **polylist, int numpolys) { if (backlist != NULL) { if ((backnode = NewBSPNode()) == NULL) { - mprintf(0, "BuildBSPNode: Error, can't allocate front node\n"); + LOG_ERROR << "BuildBSPNode: Error, can't allocate front node"; return 0; } if (!BuildBSPNode((bspnode *)backnode, &backlist, numback)) { - mprintf(0, "BuildBSPNode: Error building back node\n"); + LOG_ERROR << "BuildBSPNode: Error building back node"; return 0; } @@ -727,7 +722,7 @@ int BuildBSPNode(bspnode *tree, listnode **polylist, int numpolys) { DestroyList(&backlist); } else { if ((backnode = NewBSPNode()) == NULL) { - mprintf(0, "BuildBSPNode: Error, can't allocate front node\n"); + LOG_ERROR << "BuildBSPNode: Error, can't allocate front node"; return 0; } @@ -764,7 +759,7 @@ void DestroyBSPTree(bsptree *tree) { if (BSP_initted == 0) return; - mprintf(0, "Destroying bsptree!\n"); + LOG_INFO << "Destroying bsptree!"; DestroyBSPNode(tree->root); BSP_initted = 0; } @@ -789,7 +784,7 @@ void BuildBSPTree() { check = BSPGetMineChecksum(); if (check == BSPChecksum) { - mprintf(0, "BSP tree already built!\n"); + LOG_INFO << "BSP tree already built!"; return; // The BSP tree has already been built for this mine } @@ -801,9 +796,9 @@ void BuildBSPTree() { MineBSP.root = NewBSPNode(); ASSERT(MineBSP.root); - mprintf(0, "Building BSP Tree...\n"); + LOG_INFO << "Building BSP Tree..."; - mprintf(0, "Adding polygons to tree\n"); + LOG_DEBUG << "Adding polygons to tree"; // Go through the whole mine and add each polygon to the possible BSP // partition list. Don't include portals... @@ -841,7 +836,7 @@ void BuildBSPTree() { newpoly = NewPolygon(i, t, sm->faces[j].nverts); if (!newpoly) { - mprintf(0, "Couldn't get a new polygon!\n"); + LOG_FATAL << "Couldn't get a new polygon!"; Int3(); return; } @@ -890,7 +885,7 @@ void BuildBSPTree() { // Construct a new polygon newpoly = NewPolygon(i, t, Rooms[i].faces[t].num_verts); if (!newpoly) { - mprintf(0, "Couldn't get a new polygon!\n"); + LOG_FATAL << "Couldn't get a new polygon!"; Int3(); return; } @@ -923,16 +918,16 @@ void BuildBSPTree() { Solids = 0; Empty = 0; - mprintf(0, "%d polygons added, starting node building...\n", numpolys); + LOG_DEBUG.printf("%d polygons added, starting node building...", numpolys); // Build the BSP tree! BuildBSPNode(MineBSP.root, &MineBSP.polylist, numpolys); DestroyList(&MineBSP.polylist); // Print some stats - mprintf(0, "Total number of convex subspaces=%d\n", ConvexSubspaces); - mprintf(0, "Total number of convex polys=%d\n", ConvexPolys); - mprintf(0, "Solid=%d Empty=%d\n", Solids, Empty); + LOG_DEBUG.printf("Total number of convex subspaces=%d", ConvexSubspaces); + LOG_DEBUG.printf("Total number of convex polys=%d", ConvexPolys); + LOG_DEBUG.printf("Solid=%d Empty=%d", Solids, Empty); } // Builds a bsp tree for a single room @@ -949,7 +944,7 @@ void BuildSingleBSPTree(int roomnum) { MineBSP.root = NewBSPNode(); ASSERT(MineBSP.root); - mprintf(0, "Building BSP Tree...\n"); + LOG_INFO << "Building BSP Tree..."; // Go through the whole mine and add each polygon to the possible BSP // partition list. Don't include portals... @@ -983,7 +978,7 @@ void BuildSingleBSPTree(int roomnum) { vector world_verts[64]; newpoly = NewPolygon(i, t, sm->faces[j].nverts); if (!newpoly) { - mprintf(0, "Couldn't get a new polygon!\n"); + LOG_FATAL << "Couldn't get a new polygon!"; Int3(); return; } @@ -1023,7 +1018,7 @@ void BuildSingleBSPTree(int roomnum) { // Construct a new polygon newpoly = NewPolygon(i, t, Rooms[i].faces[t].num_verts); if (!newpoly) { - mprintf(0, "Couldn't get a new polygon!\n"); + LOG_FATAL << "Couldn't get a new polygon!"; Int3(); return; } @@ -1054,9 +1049,9 @@ void BuildSingleBSPTree(int roomnum) { DestroyList(&MineBSP.polylist); // Print some stats - mprintf(0, "Total number of convex subspaces=%d\n", ConvexSubspaces); - mprintf(0, "Total number of convex polys=%d\n", ConvexPolys); - mprintf(0, "Solid=%d Empty=%d\n", Solids, Empty); + LOG_DEBUG.printf("Total number of convex subspaces=%d", ConvexSubspaces); + LOG_DEBUG.printf("Total number of convex polys=%d", ConvexPolys); + LOG_DEBUG.printf("Solid=%d Empty=%d", Solids, Empty); BSPChecksum = -1; } diff --git a/Descent3/buddymenu.cpp b/Descent3/buddymenu.cpp index 4b4939a2..47a55510 100644 --- a/Descent3/buddymenu.cpp +++ b/Descent3/buddymenu.cpp @@ -52,22 +52,16 @@ * $NoKeywords: $ */ -#include "help.h" -#include "mono.h" -#include "renderer.h" -#include "render.h" +#include + +#include "log.h" #include "ddio.h" -#include "descent.h" #include "game.h" -#include "cfile.h" -#include "application.h" -#include -#include -#include #include "newui.h" #include "grtext.h" #include "gamefont.h" #include "AIMain.h" +#include "pserror.h" #include "robot.h" #include "hud.h" #include "stringtable.h" @@ -75,7 +69,6 @@ #include "multi.h" #include "osiris_share.h" -#include "multi.h" #define GB_MENU_REQ_TEXT 1 #define GB_MENU_REQ_SELECT 2 @@ -363,7 +356,7 @@ void MultiDoGuidebotMenuData(uint8_t *data) { Guidebot_data_download_status = 1; Multi_bail_ui_menu = true; - mprintf(0, "Recieved Guidebot data from server\n"); + LOG_DEBUG << "Received Guidebot data from server"; } // downloads data for the buddybot diff --git a/Descent3/cinematics.cpp b/Descent3/cinematics.cpp index b4766aa6..06d0b752 100644 --- a/Descent3/cinematics.cpp +++ b/Descent3/cinematics.cpp @@ -16,6 +16,8 @@ * along with this program. If not, see . */ +#include + #include "cinematics.h" #include "d3movie.h" #include "game.h" @@ -23,13 +25,12 @@ #include "descent.h" #include "gamefont.h" #include "hlsoundlib.h" +#include "log.h" #include "subtitles.h" #include "dedicated_server.h" #include "appdatabase.h" #include "bitmap.h" -#include - static bool Cinematic_lib_init = false; static int Cinematic_x = 0, Cinematic_y = 0, Cinematic_w = 0, Cinematic_h = 0; @@ -91,7 +92,7 @@ bool PlayMovie(const std::filesystem::path &moviename) { bool retval = true; if (mveerr != MVELIB_NOERROR) { - mprintf(1, "Movie error %d.\n", mveerr); + LOG_ERROR.printf("Movie error %d.", mveerr); retval = false; } diff --git a/Descent3/cockpit.cpp b/Descent3/cockpit.cpp index 3898a7b8..65c2f416 100644 --- a/Descent3/cockpit.cpp +++ b/Descent3/cockpit.cpp @@ -188,22 +188,22 @@ // activate cockpit // render cockpit // deactivate cockpit. + +#include +#include + #include "cockpit.h" #include "game.h" #include "polymodel.h" #include "hud.h" #include "gauges.h" +#include "log.h" #include "ship.h" #include "player.h" #include "room.h" #include "hlsoundlib.h" -#include "soundload.h" #include "sounds.h" -#include - -#include - #define COCKPIT_ANIM_TIME 2.0f #define COCKPIT_DORMANT_FRAME 0.0 #define COCKPIT_START_FRAME 3.0 @@ -252,7 +252,7 @@ static void LoadCockpitInfo(const char *ckt_file, tCockpitCfgInfo *info); void InitCockpit(int ship_index) { tCockpitCfgInfo cfginfo; int i; - mprintf(0, "Initializing cockpit.\n"); + LOG_INFO << "Initializing cockpit."; LoadCockpitInfo(Ships[ship_index].cockpit_name, &cfginfo); // initialize special hud/cockpit images unique to this ship for (i = 0; i < NUM_SHIELD_GAUGE_FRAMES; i++) { @@ -265,7 +265,7 @@ void InitCockpit(int ship_index) { HUD_resources.invpulse_bmp = bm_AllocLoadFileBitmap(IGNORE_TABLE(cfginfo.invpulseimg), 0); if (cfginfo.modelname[0] == 0) { Cockpit_info.model_num = -1; - mprintf(0, "No cockpit found for ship.\n"); + LOG_WARNING << "No cockpit found for ship."; return; } // initialize cockpit. @@ -458,7 +458,7 @@ void RenderCockpit() { // position cockpit correctly. bsp_info *viewer_subobj = CockpitGetMonitorSubmodel(SOF_VIEWER); if (!viewer_subobj) { - mprintf(0, "Cockpit missing viewer!\n"); + LOG_WARNING << "Cockpit missing viewer!"; return; } view_z = @@ -552,7 +552,6 @@ float KeyframeAnimateCockpit() { newkeyframe = Cockpit_info.this_keyframe + (Cockpit_info.next_keyframe - Cockpit_info.this_keyframe) * (Cockpit_info.frame_time / COCKPIT_ANIM_TIME); - // mprintf(0, "this=%.1f next=%.1f ft=%.1f\n", Cockpit_info.this_keyframe, Cockpit_info.next_keyframe, Cockpit_info.frame_time)); // going up in keyframes if (Cockpit_info.this_keyframe < Cockpit_info.next_keyframe) { if (newkeyframe >= Cockpit_info.next_keyframe) { Cockpit_info.frame_time = 0.0f; diff --git a/Descent3/config.cpp b/Descent3/config.cpp index 9b9cfce5..8d69d709 100644 --- a/Descent3/config.cpp +++ b/Descent3/config.cpp @@ -279,48 +279,30 @@ * $NoKeywords: $ */ -#include "ConfigItem.h" -#include "player.h" +#include + #include "config.h" -#include "ddio.h" #include "newui.h" #include "3d.h" -#include "polymodel.h" -#include "application.h" #include "descent.h" -#include "mono.h" -#include "Mission.h" -#include "ddio.h" -#include "gamefont.h" -#include "multi_ui.h" +#include "log.h" #include "cinematics.h" #include "hlsoundlib.h" #include "terrain.h" -#include "cfile.h" -#include "mem.h" -#include "lighting.h" #include "physics.h" #include "pilot.h" #include "hud.h" -#include "voice.h" #include "bitmap.h" #include "game.h" -#include "render.h" #include "stringtable.h" #include "SmallViews.h" #include "D3ForceFeedback.h" -#include "descent.h" #include "appdatabase.h" -#include "hlsoundlib.h" #include "soundload.h" #include "sounds.h" #include "ctlconfig.h" #include "d3music.h" -#include -#include -#include - #define STAT_SCORE STAT_TIMER tVideoResolution Video_res_list[N_SUPPORTED_VIDRES] = { @@ -899,7 +881,7 @@ struct sound_menu { D3MusicSetVolume((*musicvolume) / 10.0f); if (fxquantity) { - mprintf(1, "oldquant %d newquant %d\n", old_fxquantity, *fxquantity); + LOG_DEBUG.printf("oldquant %d newquant %d", old_fxquantity, *fxquantity); if (old_fxquantity != (*fxquantity)) { Sound_system.SetLLSoundQuantity((*fxquantity) + MIN_SOUNDS_MIXED); } @@ -1162,9 +1144,6 @@ struct hud_menu { Current_pilot.set_hud_data(NULL, &hud_new_stat, &hud_new_grstat); - // mprintf(0, "pilot hud stat=%x\n", Current_pilot.hud_stat); - // mprintf(0, "pilot hud grstat=%x\n", Current_pilot.hud_graphical_stat); - // modify current hud stats if in game. if ((GetFunctionMode() == EDITOR_GAME_MODE || GetFunctionMode() == GAME_MODE) && GetHUDMode() == HUD_FULLSCREEN) { SetHUDState(hud_new_stat | STAT_SCORE | (Hud_stat_mask & STAT_FPS), hud_new_grstat); @@ -1365,7 +1344,7 @@ void OptionsMenu() { while (state != 2) { if (state == 1) { // enter controller config menu - mprintf(0, "CONTROLLER CONFIG MENU HERE!\n"); + LOG_DEBUG << "CONTROLLER CONFIG MENU HERE!"; CtlConfig(CTLCONFIG_KEYBOARD); state = 0; // goto options menu. } else { diff --git a/Descent3/credits.cpp b/Descent3/credits.cpp index 307e3aa4..bb7a37d0 100644 --- a/Descent3/credits.cpp +++ b/Descent3/credits.cpp @@ -79,7 +79,7 @@ #include -#include "mono.h" +#include "log.h" #include "pstypes.h" #include "crossplat.h" #include "ddio.h" @@ -158,7 +158,7 @@ static int Credits_ParseLine(char *line, creditline *credit) { int num_found = sscanf(line, "*%d %d %d %d %f", &x1, &y1, &x2, &y2, &timedelay); if (num_found != 5) { - mprintf(0, "Bad movement data in credit text (%s)\n", line); + LOG_WARNING.printf("Bad movement data in credit text (%s)", line); return 0; } else { CreditStartX = x1; @@ -182,7 +182,7 @@ static int Credits_ParseLine(char *line, creditline *credit) { credit->endx = CreditEndX; credit->endy = CreditEndY; credit->displaytime = CreditDisplayTime; - mprintf(0, "Read header %s\n", line); + LOG_DEBUG.printf("Read header %s", line); credit->color = CreditHeadingColor; credit->type = CLTYPE_HEADING; @@ -193,7 +193,7 @@ static int Credits_ParseLine(char *line, creditline *credit) { int r, g, b; int num_found = sscanf(line, "$%d %d %d", &r, &g, &b); if (num_found != 3) { - mprintf(0, "Bad color in credit text (%s)\n", line); + LOG_WARNING.printf("Bad color in credit text (%s)", line); return 0; } else { CreditTextColor = GR_RGB(r, g, b); @@ -204,7 +204,7 @@ static int Credits_ParseLine(char *line, creditline *credit) { int r, g, b; int num_found = sscanf(line, "^%d %d %d", &r, &g, &b); if (num_found != 3) { - mprintf(0, "Bad color in credit text (%s)\n", line); + LOG_WARNING.printf("Bad color in credit text (%s)", line); return 0; } else { CreditHeadingColor = GR_RGB(r, g, b); @@ -252,7 +252,7 @@ static bool Credits_LoadCredits(const char *filename) { infile = cfopen(filename, "rt"); if (!infile) { - mprintf(0, "Couldn't open credit file to read credits!\n"); + LOG_ERROR << "Couldn't open credit file to read credits!"; return false; } @@ -314,7 +314,7 @@ void Credits_Display(void) { int bm_handle = bm_AllocLoadFileBitmap("CreditsBackground.tga", 0); if (bm_handle < 0) { - mprintf(0, "Failed to load background credit screen!\n"); + LOG_WARNING << "Failed to load background credit screen!"; return; } @@ -328,11 +328,11 @@ void Credits_Display(void) { D3MusicStart("credits.omf"); D3MusicSetRegion(CREDITS1_MUSIC_REGION); - mprintf(0, "Chillin in credits\n"); + LOG_INFO << "Chillin in credits"; // Load our credits if (!Credits_LoadCredits("GameCredits.txt")) { - mprintf(0, "There was an error loading game credits!\n"); + LOG_WARNING << "There was an error loading game credits!"; } else { // First count how many headers there are so we know how many to allocate int count = 0; diff --git a/Descent3/ctlconfig.cpp b/Descent3/ctlconfig.cpp index 9bb9e3b9..0338d0f6 100644 --- a/Descent3/ctlconfig.cpp +++ b/Descent3/ctlconfig.cpp @@ -277,20 +277,22 @@ * * $NoKeywords: $ */ + +#include + #include "ctlconfig.h" #include "CtlCfgElem.h" #include "ctlconfigtxt.h" #include "game.h" +#include "log.h" #include "weapon.h" #include "pilot.h" -#include "bitmap.h" -#include "multi.h" #include "gameloop.h" #include "gamefont.h" #include "D3ForceFeedback.h" #include "hlsoundlib.h" #include "ddio.h" -#include + ////////////////////////////////////////////////////////////////////////////// #define IDV_KCONFIG 10 #define IDV_CCONFIG 11 @@ -693,7 +695,7 @@ void wpnsel_cfg_screen::finish() {} void wpnsel_cfg_screen::process(int res) { int slot, i; bool is_secondary = false, do_swap_ui = false, do_disable_ui = false, update_buttons = false; - mprintf(0, "res=%d\n", res); + LOG_DEBUG.printf("res=%d", res); if (m_selection_status == -1) { if (res == UID_RESETDEFAULTS) { for (i = 0; i < MAX_PRIMARY_WEAPONS; i++) @@ -732,7 +734,7 @@ void wpnsel_cfg_screen::process(int res) { is_secondary = true; do_disable_ui = true; } - mprintf(0, "slot=%d\n", slot); + LOG_DEBUG.printf("slot=%d", slot); // do different uis if (do_disable_ui) { diff --git a/Descent3/d3movie.cpp b/Descent3/d3movie.cpp index 7db51d84..891af1a2 100644 --- a/Descent3/d3movie.cpp +++ b/Descent3/d3movie.cpp @@ -27,6 +27,7 @@ #include "game.h" #include "gamefont.h" #include "grtext.h" +#include "log.h" #include "mem.h" #include "mvelib.h" #include "pserror.h" @@ -108,7 +109,7 @@ int mve_PlayMovie(const std::filesystem::path &pMovieName, oeApplication *pApp) #if defined(POSIX) real_name = mve_FindMovieFileRealName(pMovieName); if (real_name.empty()) { - mprintf(0, "MOVIE: No such file %s\n", pMovieName.u8string().c_str()); + LOG_WARNING.printf("MOVIE: No such file %s", pMovieName.u8string().c_str()); return MVELIB_FILE_ERROR; } #else @@ -117,7 +118,7 @@ int mve_PlayMovie(const std::filesystem::path &pMovieName, oeApplication *pApp) // open movie file. FILE *hFile = fopen(real_name.u8string().c_str(), "rb"); if (hFile == nullptr) { - mprintf(0, "MOVIE: Unable to open %s\n", real_name.u8string().c_str()); + LOG_ERROR.printf("MOVIE: Unable to open %s", real_name.u8string().c_str()); return MVELIB_FILE_ERROR; } @@ -130,14 +131,14 @@ int mve_PlayMovie(const std::filesystem::path &pMovieName, oeApplication *pApp) Movie_bm_handle = -1; if (!mve_InitSound()) { - mprintf(0, "Failed to initialize sound\n"); + LOG_ERROR << "Failed to initialize sound"; fclose(hFile); return MVELIB_INIT_ERROR; } MVESTREAM *mve = MVE_rmPrepMovie(hFile, -1, -1, 0); if (mve == nullptr) { - mprintf(0, "Failed to prepMovie %s\n", pMovieName.u8string().c_str()); + LOG_ERROR.printf("Failed to prepMovie %s", pMovieName.u8string().c_str()); fclose(hFile); mve_CloseSound(); return MVELIB_INIT_ERROR; @@ -360,7 +361,7 @@ intptr_t mve_SequenceStart(const char *mvename, void *fhandle, oeApplication *ap #if defined(POSIX) real_name = mve_FindMovieFileRealName(mvename); if (real_name.empty()) { - mprintf(0, "MOVIE: No such file %s\n", mvename); + LOG_WARNING.printf("MOVIE: No such file %s", mvename); fhandle = nullptr; return 0; } @@ -370,7 +371,7 @@ intptr_t mve_SequenceStart(const char *mvename, void *fhandle, oeApplication *ap fhandle = fopen(real_name.u8string().c_str(), "rb"); if (fhandle == nullptr) { - mprintf(1, "MOVIE: Unable to open %s\n", real_name.u8string().c_str()); + LOG_WARNING.printf("MOVIE: Unable to open %s", real_name.u8string().c_str()); return 0; } @@ -388,7 +389,7 @@ intptr_t mve_SequenceStart(const char *mvename, void *fhandle, oeApplication *ap MVESTREAM *mve = MVE_rmPrepMovie(fhandle, -1, -1, 0); if (mve == nullptr) { - mprintf(0, "Failed to PrepMovie %s\n", mvename); + LOG_ERROR.printf("Failed to PrepMovie %s", mvename); fclose((FILE *)fhandle); return MVELIB_INIT_ERROR; } diff --git a/Descent3/d3music.cpp b/Descent3/d3music.cpp index aadc6429..63783c21 100644 --- a/Descent3/d3music.cpp +++ b/Descent3/d3music.cpp @@ -17,6 +17,7 @@ */ #include "d3music.h" +#include "log.h" #include "music.h" // generic constants @@ -357,7 +358,7 @@ void D3MusicSongSelector() { switch (MusicAI.cur_song) { case OMS_THEME_TYPE_NONE: if (MusicAI.pending_region > -1) { - mprintf(0, "D3MUSIC: new region request processed.\n"); + LOG_DEBUG << "D3MUSIC: new region request processed."; MusicAI.cur_song = OMS_THEME_TYPE_IDLE; Music_seq.SetCurrentRegion(MusicAI.pending_region); Music_seq.StartSong(MusicAI.cur_song, true); @@ -368,19 +369,10 @@ void D3MusicSongSelector() { case OMS_THEME_TYPE_IDLE: // IDLE MUSIC CURRENTLY PLAYING if (evt.cmd == OMS_EVT_SONGENDED) { MusicAI.cur_song = OMS_THEME_TYPE_NONE; - // if (Music_seq.GetCurrentRegion() == 0) { - // mprintf(0, "Ending Region 0.\n"); - // MusicAI.cur_song = OMS_THEME_TYPE_IDLE; - // Music_seq.SetCurrentRegion(1); - // Music_seq.StartSong(MusicAI.cur_song, true); - // } - // else { - // mprintf(0, "D3MUSIC: Song ended normally?\n"); - // } } else if (evt.cmd == OMS_EVT_LOOPENDING) { // shall we switch regions? if (MusicAI.pending_region > -1) { - mprintf(0, "D3MUSIC: new region request processed.\n"); + LOG_DEBUG << "D3MUSIC: new region request processed."; MusicAI.cur_song = OMS_THEME_TYPE_IDLE; Music_seq.SetCurrentRegion(MusicAI.pending_region); Music_seq.StartSong(MusicAI.cur_song, true); diff --git a/Descent3/damage.cpp b/Descent3/damage.cpp index b8ef9837..76af8c9b 100644 --- a/Descent3/damage.cpp +++ b/Descent3/damage.cpp @@ -558,8 +558,9 @@ * $NoKeywords: $ */ -#include +#include #include + #include "damage.h" #include "object.h" #include "objinfo.h" @@ -572,9 +573,9 @@ #include "sounds.h" #include "soundload.h" #include "game2dll.h" +#include "log.h" #include "weapon.h" #include "ship.h" -#include "attach.h" #include "difficulty.h" #include "demofile.h" #include "d3music.h" @@ -587,7 +588,6 @@ #include "viseffect.h" #include "psrand.h" -#include static void SetDeformDamageEffect(object *obj); static void ApplyFreezeDamageEffect(object *obj); @@ -1063,7 +1063,7 @@ void KillObject(object *objp, object *killer, float damage) { delay_time = delay_min + (delay_max - delay_min) * ps_rand() / D3_RAND_MAX; - mprintf(0, "Using %d\n", i); + LOG_DEBUG.printf("Using %d", i); break; } r -= p; @@ -1155,7 +1155,7 @@ float GetDeathAnimTime(object *objp) { (objp->rtype.pobj_info.anim_end_frame - objp->rtype.pobj_info.anim_frame) / (objp->rtype.pobj_info.anim_end_frame - objp->rtype.pobj_info.anim_start_frame); extra_time = std::min(extra_time, 3.0); // limit extra time to 3 seconds - mprintf(0, "extra_time = %2f\n", extra_time); + LOG_DEBUG.printf("extra_time = %2f", extra_time); death_time = Object_info[objp->id].anim[objp->ai_info->movement_type].elem[AS_DEATH].spc + 0.25 + extra_time; } @@ -1258,7 +1258,7 @@ void KillObject(object *objp, object *killer, float damage, int death_flags, flo SetObjectControlType(objp, CT_DYING_AND_AI); int next_anim = AS_DEATH; GoalAddGoal(objp, AIG_SET_ANIM, (void *)&next_anim, ACTIVATION_BLEND_LEVEL); - mprintf(0, "Start dying anim "); + LOG_DEBUG << "Start dying anim"; } } diff --git a/Descent3/dedicated_server.cpp b/Descent3/dedicated_server.cpp index 9b133ab6..4325f21f 100644 --- a/Descent3/dedicated_server.cpp +++ b/Descent3/dedicated_server.cpp @@ -104,13 +104,8 @@ #include #include - -#include -#include - -#if !defined(POSIX) -typedef int socklen_t; -#endif +#include +#include #include "crossplat.h" #include "pserror.h" @@ -121,6 +116,7 @@ typedef int socklen_t; #include "args.h" #include "AppConsole.h" #include "ddio.h" +#include "log.h" #include "multi_dll_mgr.h" #include "multi_ui.h" #include "Mission.h" @@ -136,6 +132,9 @@ typedef int socklen_t; #include "hud.h" #include "networking.h" +#if !defined(POSIX) +typedef int socklen_t; +#endif bool Dedicated_server = false; @@ -839,15 +838,15 @@ void InitDedicatedSocket(uint16_t port) { dedicated_listen_socket = socket(AF_INET, SOCK_STREAM, 0); if (INVALID_SOCKET == dedicated_listen_socket) { - mprintf(0, "Unable to create listen socket for dedicated server!\n"); + LOG_ERROR << "Unable to create listen socket for dedicated server!"; return; } if (SOCKET_ERROR == bind(dedicated_listen_socket, (SOCKADDR *)&sock_addr, sizeof(sock_addr))) { - mprintf(0, "Unable to bind listen socket for dedicated server!\n"); + LOG_ERROR << "Unable to bind listen socket for dedicated server!"; return; } if (listen(dedicated_listen_socket, 1)) { - mprintf(0, "Unable to listen on dedicated server socket!\n"); + LOG_ERROR << "Unable to listen on dedicated server socket!"; return; } make_nonblocking(dedicated_listen_socket); @@ -868,7 +867,7 @@ void ListenDedicatedSocket(void) { // Check to see if this came in from the local address uint32_t localhost = inet_addr("127.0.0.1"); if (memcmp(&localhost, &conn_addr.sin_addr, sizeof(localhost)) != 0) { - mprintf(0, "Rejecting connection from remote host!\n"); + LOG_WARNING << "Rejecting connection from remote host!"; PrintDedicatedMessage(TXT_DS_REJECTREMOTE, inet_ntoa(conn_addr.sin_addr)); PrintDedicatedMessage("\n"); shutdown(incoming_socket, 2); diff --git a/Descent3/demofile.cpp b/Descent3/demofile.cpp index 17185b31..86f7924f 100644 --- a/Descent3/demofile.cpp +++ b/Descent3/demofile.cpp @@ -275,19 +275,18 @@ #include "newui.h" #include "hud.h" #include "stringtable.h" -#include "program.h" #include "Mission.h" #include "game.h" #include "gamesequence.h" #include "weapon.h" #include "damage.h" +#include "log.h" #include "mem.h" #include "ObjScript.h" #include "hlsoundlib.h" #include "viseffect.h" #include "collide.h" #include "sounds.h" -#include "fireball.h" #include "attach.h" #include "gameloop.h" #include "multi.h" @@ -361,7 +360,7 @@ void DemoToggleRecording() { strcat(szfile, ".dem"); } Demo_fname = std::filesystem::path(Base_directory) / "demo" / szfile; - mprintf(0, "Saving demo to file: %s\n", Demo_fname.u8string().c_str()); + LOG_INFO.printf("Saving demo to file: %s", Demo_fname.u8string().c_str()); // Try to create the file Demo_cfp = cfopen(Demo_fname, "wb"); if (Demo_cfp) { @@ -509,14 +508,11 @@ void DemoWriteChangedObjects() { (Objects[i].type == OBJ_CAMERA)) { if ((Objects[i].flags & OF_MOVED_THIS_FRAME)) //||(Objects[i].mtype.phys_info.velocity!=Zero_vector)) { - // mprintf(0,"Object moved this frame! type = %d\n",Objects[i].type); DemoWriteChangedObj(&Objects[i]); // num_changed++; } } } - // if(num_changed) - // mprintf(0,"%d Objects moved this frame!\n",num_changed); } } @@ -573,7 +569,6 @@ void DemoReadTurretChanged(void) { } if (Objects[objnum].type != OBJ_NONE) { - // mprintf(0,"Updating turret %d!\n",objnum); ObjSetTurretUpdate(objnum, &multi_turret_info); } } @@ -701,7 +696,7 @@ int DemoFrameCount = 0; int DemoPlaybackFile(const std::filesystem::path &filename) { is_multi_demo = false; - mprintf(0, "Playing back demo file!\n"); + LOG_INFO << "Playing back demo file!"; MultiBuildMatchTables(); if (FindArg("-makemovie")) { Demo_make_movie = true; @@ -744,14 +739,14 @@ int DemoReadHeader() { int level_num; int frame_count; float demo_gametime; - mprintf(0, "Reading demo header...\n"); + LOG_DEBUG << "Reading demo header..."; ASSERT(Demo_flags == DF_PLAYBACK); cf_ReadString((char *)szsig, 10, Demo_cfp); ver = cf_ReadShort(Demo_cfp); if (strcmp(szsig, D3_DEMO_SIG) != 0) { if (strcmp(szsig, D3_DEMO_SIG_NEW) != 0) { - mprintf(0, "Bad demo header signature!\n"); + LOG_WARNING << "Bad demo header signature!"; return 0; } } @@ -774,12 +769,12 @@ int DemoReadHeader() { SetCurrentLevel(level_num); if (!LoadAndStartCurrentLevel()) { - mprintf(0, "Couldn't start new level to play back the demo!\n"); + LOG_WARNING << "Couldn't start new level to play back the demo!"; Osiris_EnableCreateEvents(); return 0; } } else { - mprintf(0, "Couldn't load the level to play back the demo!\n"); + LOG_WARNING << "Couldn't load the level to play back the demo!"; Osiris_EnableCreateEvents(); return 0; } @@ -823,7 +818,7 @@ int DemoReadHeader() { LGSSpew(Demo_cfp); if (!Osiris_RestoreSystemState(Demo_cfp)) { - mprintf(0, "Error restoring Osiris\n"); + LOG_ERROR << "Error restoring Osiris"; return 0; } @@ -846,7 +841,7 @@ int DemoReadHeader() { Camera_view_mode[0] = Camera_view_mode[2] = 0; //(0==CV_NONE) Force reinitialization RestoreCameraRearviews(); } catch (...) { - mprintf(0, "Someone threw an exception while reading the demo header!\n"); + LOG_ERROR << "Someone threw an exception while reading the demo header!"; return 0; } @@ -1005,8 +1000,8 @@ void DemoReadWeaponFire() { } Objects[new_weap_objnum].ctype.laser_info.src_gun_num = gunnum; - mprintf(0, "Player %d Firing weapon (%d) -- using objnum %d (old num = %d)\n", obj->id, weaponnum, new_weap_objnum, - weapobjnum); + LOG_DEBUG.printf("Player %d Firing weapon (%d) -- using objnum %d (old num = %d)", + obj->id, weaponnum, new_weap_objnum, weapobjnum); Demo_obj_map[weapobjnum] = new_weap_objnum; int16_t weapon_num = weaponnum; @@ -1118,7 +1113,6 @@ void DemoReadObjCreate() { parent_handle = cf_ReadInt(Demo_cfp); if (use_orient) gs_ReadMatrix(Demo_cfp, orient); - // mprintf(0,"Creating object ype: %d id: %d room: %d\n",type,id,roomnum); // xlate id to new id. switch (type) { @@ -1171,17 +1165,12 @@ void DemoFrame() { if (!Demo_play_fast) { float tdelta = timer_GetTime(); - // if(Gametime= 0) && (obj->type != OBJ_NONE) && (obj->type != OBJ_WEAPON) && (obj->flags & OF_POLYGON_OBJECT) && (p_info->multi_turret_info.num_turrets)) { - mprintf(0, "Turret %d updated!\n", a); + LOG_DEBUG.printf("Turret %d updated!", a); multi_turret_info.keyframes = (float *)&turret_holder; ObjGetTurretUpdate(a, &multi_turret_info); diff --git a/Descent3/descent.cpp b/Descent3/descent.cpp index bdebffc8..4a1b4f88 100644 --- a/Descent3/descent.cpp +++ b/Descent3/descent.cpp @@ -388,7 +388,7 @@ #include "pserror.h" #include "grdefs.h" -#include "mono.h" +#include "log.h" #include "cfile.h" #include "init.h" @@ -403,7 +403,6 @@ #include "networking.h" #include "hlsoundlib.h" #include "player.h" -#include "newui.h" #include "credits.h" #include "cinematics.h" #include "args.h" @@ -509,7 +508,7 @@ void Descent3() { // delete the lock file in the temp directory (as long as it belongs to us) if (!ddio_DeleteLockFile(std::filesystem::path(Descent3_temp_directory))) { - mprintf(0, "Cannot delete lock file in temp dir %s!\n", Descent3_temp_directory); + LOG_WARNING << "Cannot delete lock file in temp dir " << Descent3_temp_directory; }; // Save settings to registry @@ -642,7 +641,7 @@ void ShowStaticScreen(char *bitmap_filename, bool timed, float delay_time) { bm_DestroyChunkedBitmap(&splash_bm); } else { - mprintf(0, "Couldn't load %s.\n", bitmap_filename); + LOG_WARNING << "Couldn't load " << bitmap_filename; } ui_SetScreenMode(Max_window_w, Max_window_h); diff --git a/Descent3/doorway.cpp b/Descent3/doorway.cpp index 023f9ca6..f970a35a 100644 --- a/Descent3/doorway.cpp +++ b/Descent3/doorway.cpp @@ -129,6 +129,7 @@ #include "doorway.h" #include "door.h" #include "pserror.h" +#include "log.h" #include "mem.h" #include "room.h" #include "polymodel.h" @@ -174,7 +175,7 @@ void RemoveActiveDoorway(int adway) { Num_active_doorways--; - mprintf(0, "ActiveDoorways = %d\n", Num_active_doorways); + LOG_DEBUG.printf("ActiveDoorways = %d", Num_active_doorways); } void AddActiveDoorway(int roomnum) { @@ -193,7 +194,7 @@ void AddActiveDoorway(int roomnum) { dp->activenum = Num_active_doorways++; } - mprintf(0, "ActiveDoorways = %d\n", Num_active_doorways); + LOG_DEBUG.printf("ActiveDoorways = %d", Num_active_doorways); } // Given an object handle, returns the doorway number diff --git a/Descent3/fireball.cpp b/Descent3/fireball.cpp index 98c37110..5b51c729 100644 --- a/Descent3/fireball.cpp +++ b/Descent3/fireball.cpp @@ -578,8 +578,12 @@ * rid of the object flag which used to indicate terrain. * */ -#include -#include "pstypes.h" + +#include +#include +#include + + #include "pserror.h" #include "fireball.h" #include "vclip.h" @@ -587,12 +591,10 @@ #include "cockpit.h" #include "game.h" #include "3d.h" -#include "mono.h" -#include "room.h" +#include "log.h" #include "polymodel.h" #include "objinfo.h" #include "gametexture.h" -#include "splinter.h" #include "physics.h" #include "damage.h" #include "gameevent.h" @@ -603,18 +605,12 @@ #include "sounds.h" #include "gameloop.h" #include "multi.h" -#include "AIGoal.h" -#include "AIMain.h" #include "ship.h" #include "BOA.h" #include "demofile.h" #include "ObjScript.h" -#include -#include #include "psrand.h" -#include - static object *CreateSubobjectDebris(object *parent, int subobj_num, float explosion_mag, int death_flags); static void DrawSmolderingObject(object *obj); static int GetRandomExplosion(float size); @@ -849,7 +845,7 @@ int CreateFireball(vector *pos, int fireball_num, int roomnum, int realtype) { else { objnum = ObjCreate(OBJ_FIREBALL, fireball_num, roomnum, pos, NULL); if (objnum < 0) { - mprintf(0, "Couldn't create fireball object!\n"); + LOG_WARNING << "Couldn't create fireball object!"; return -1; } Objects[objnum].size = Fireballs[fireball_num].size; @@ -871,7 +867,7 @@ int CreateCustomFireballObject(vector *pos, int fireball_num, int tex_handle, in return -1; objnum = ObjCreate(OBJ_FIREBALL, fireball_num, roomnum, pos, NULL); if (objnum < 0) { - mprintf(0, "Couldn't create fireball object!\n"); + LOG_WARNING << "Couldn't create fireball object!"; return -1; } Objects[objnum].size = Fireballs[fireball_num].size; @@ -902,7 +898,7 @@ object *CreateSubobjectDebrisDirected(object *parent, int subobj_num, vector *di objnum = ObjCreate(OBJ_DEBRIS, 0, parent->roomnum, &parent->pos, &parent->orient); if (objnum < 0 || objnum > Highest_object_index) { - mprintf(0, "WARNING: Debris not created!\n"); + LOG_WARNING << "WARNING: Debris not created!"; return NULL; } obj = &Objects[objnum]; @@ -982,7 +978,6 @@ void CreateExtraFireballs(object *obj, float size_scale) { extras += 4; // Cap at 12 extras = std::min(12, extras); - // mprintf(0,"Creating %d extra explosions\n",extras); CreateRandomSparks(extras, &obj->pos, obj->roomnum); for (i = 0; i < extras; i++) { vector pos = obj->pos; @@ -1093,7 +1088,7 @@ void CreateSplintersFromBody(object *obj, float explosion_mag, float lifetime) { // Now create splinter with that faces center position int s_objnum = ObjCreate(OBJ_SPLINTER, pm - Poly_models, obj->roomnum, &dest, NULL); if (s_objnum < 0) { - mprintf(0, "Couldn't create splinter object!\n"); + LOG_WARNING << "Couldn't create splinter object!"; return; } else { // Fill in relevant info @@ -1186,7 +1181,7 @@ void DoDeathSpew(object *parent) { int objnum = ObjCreate(type, id, parent->roomnum, &parent->pos, NULL); num_last_type++; if (objnum < 0) { - mprintf(0, "Couldn't spew object!\n"); + LOG_WARNING << "Couldn't spew object!"; return; } object *obj = &Objects[objnum]; @@ -1278,7 +1273,7 @@ void CreateElectricalBolts(object *objp, int num_bolts) { vis->flags = VF_USES_LIFELEFT | VF_EXPAND | VF_ATTACHED; } } else { - mprintf(0, "VIS: Submodel %s has 0 vertices!!!\n", sm->name); + LOG_WARNING.printf("VIS: Submodel %s has 0 vertices!!!", sm->name); } } } @@ -1861,7 +1856,6 @@ void DoConcussiveForce(object *explode_obj_ptr, int parent_handle, float player_ dist = 0.0f; // Make damage be from 'maxdamage' to 0.0, where 0.0 is 'maxdistance' away; if (dist <= effect_distance) { - // mprintf(0, "Distance = %f\n", dist); if (1 /*object_to_object_visibility(obj, hit_obj_ptr, FQ_TRANSWALL)*/) { fvi_query fq; fvi_info hit_info; @@ -1902,7 +1896,6 @@ void DoConcussiveForce(object *explode_obj_ptr, int parent_handle, float player_ damage = max_generic_damage - (dist / maxdistance) * max_generic_damage; force = maxforce - (dist / maxdistance) * maxforce; - // mprintf(0, "f %f d %f\n", force, damage); // Find the force vector on the object vm_GetNormalizedDirFast(&vforce, &hit_obj_ptr->pos, &explode_obj_ptr->pos); vforce *= force; @@ -1917,7 +1910,7 @@ void DoConcussiveForce(object *explode_obj_ptr, int parent_handle, float player_ if (hit_obj_ptr->type == OBJ_PLAYER) { if (Demo_flags != DF_PLAYBACK) { ApplyDamageToPlayer(hit_obj_ptr, parent_obj, PD_CONCUSSIVE_FORCE, damage * player_scalar); - mprintf(0, "Applying %f damage to player from force.\n", damage); + LOG_DEBUG.printf("Applying %f damage to player from force.", damage); } // shake player cockpit if damage is pretty bad. @@ -1925,7 +1918,6 @@ void DoConcussiveForce(object *explode_obj_ptr, int parent_handle, float player_ float mag = damage / 200.0f; vector vec = vforce; vm_NormalizeVector(&vec); - // mprintf(0, "force: %.1f,%.1f,%.1f mag=%.2f\n", vec.x,vec.y,vec.z,mag); StartCockpitShake(mag, &vec); } } else if (IS_GENERIC(hit_obj_ptr->type) || (hit_obj_ptr->type == OBJ_DOOR)) { @@ -1933,9 +1925,7 @@ void DoConcussiveForce(object *explode_obj_ptr, int parent_handle, float player_ ApplyDamageToGeneric(hit_obj_ptr, parent_obj, GD_CONCUSSIVE, damage); } } - } else { - // mprintf(0, "No badass: robot=%2i, dist=%7.3f, maxdistance=%7.3f .\n", i, f2fl(dist), f2fl(maxdistance)); - } // end if (object_to_object_visibility... + } } // end if (dist < maxdistance) } // end for } @@ -1951,7 +1941,7 @@ void CreateBlueBlastRing(vector *pos, int index, float lifetime, float max_size, objnum = ObjCreate(OBJ_FIREBALL, index, roomnum, pos, NULL); if (objnum < 0) // DAJ -1FIX { - mprintf(0, "Couldn't create blast object!\n"); + LOG_WARNING << "Couldn't create blast object!"; return; } Objects[objnum].size = 1.0; @@ -2007,7 +1997,7 @@ int CreateBlastRing(vector *pos, int index, float lifetime, float max_size, int objnum = ObjCreate(OBJ_FIREBALL, index, roomnum, pos, NULL); if (objnum < 0) { - mprintf(0, "Couldn't create blast object!\n"); + LOG_WARNING << "Couldn't create blast object!"; return -1; } Objects[objnum].size = max_size; @@ -2040,7 +2030,7 @@ int CreateSmolderingObject(vector *pos, int index, float lifetime, float max_siz objnum = ObjCreate(OBJ_FIREBALL, index, roomnum, &new_pos, NULL); if (objnum < 0) { - mprintf(0, "Couldn't create blast object!\n"); + LOG_WARNING << "Couldn't create blast object!"; return -1; } Objects[objnum].size = 1.0; diff --git a/Descent3/game.cpp b/Descent3/game.cpp index f5ba8a82..03358be1 100644 --- a/Descent3/game.cpp +++ b/Descent3/game.cpp @@ -655,13 +655,13 @@ * $NoKeywords: $ */ +#include + #include "game.h" #include "ddvid.h" #include "ddio.h" #include "pserror.h" -#include "program.h" #include "descent.h" -#include "object.h" #include "trigger.h" #include "player.h" #include "slew.h" @@ -669,6 +669,7 @@ #include "renderer.h" #include "doorway.h" #include "hud.h" +#include "log.h" #include "multi.h" #include "gamefont.h" #include "newui.h" @@ -682,18 +683,10 @@ #include "game2dll.h" #include "config.h" #include "stringtable.h" -#include "ship.h" #include "pilot.h" #include "args.h" -#include "gamepath.h" -#include "AIGoal.h" -#include "aipath.h" #include "dedicated_server.h" -#include "objinfo.h" -#include -#include "osiris_share.h" #include "demofile.h" - #include /////////////////////////////////////////////////////////////////////////////// @@ -989,7 +982,7 @@ void SetScreenMode(int sm, bool force_res_change) { if (rend_initted == -1) { // We're using the default, so change some values for the menus rend_initted = 1; - mprintf(0, "Changing menu settings to default!\n"); + LOG_INFO << "Changing menu settings to default!"; Game_video_resolution = RES_640X480; Render_preferred_state.bit_depth = 32; scr_width = 640; @@ -1001,13 +994,13 @@ void SetScreenMode(int sm, bool force_res_change) { Render_preferred_state.height = scr_height; Render_preferred_state.bit_depth = scr_bitdepth; - mprintf(0, "Setting rend_width=%d height=%d\n", scr_width, scr_height); + LOG_INFO.printf("Setting rend_width=%d height=%d", scr_width, scr_height); int retval = rend_SetPreferredState(&Render_preferred_state); if (retval == -1) { // We're using the default, so change some values for the menus rend_initted = 1; - mprintf(0, "Changing menu settings to default!\n"); + LOG_INFO << "Changing menu settings to default!"; Game_video_resolution = RES_640X480; Render_preferred_state.bit_depth = 32; scr_width = 640; @@ -1052,7 +1045,7 @@ void SetScreenMode(int sm, bool force_res_change) { // initialize ui system again ui_SetScreenMode(Max_window_w, Max_window_h); - mprintf(0, "rend_width=%d height=%d\n", Max_window_w, Max_window_h); + LOG_INFO.printf("rend_width=%d height=%d", Max_window_w, Max_window_h); } // assign current screen mode @@ -1095,7 +1088,7 @@ void SetScreenMode(int sm, bool force_res_change) { } } - mprintf(0, "NEW rend_width=%d height=%d\n", Max_window_w, Max_window_h); + LOG_INFO.printf("NEW rend_width=%d height=%d", Max_window_w, Max_window_h); // mark res change as false. @@ -1159,14 +1152,14 @@ void FramePush(int x1, int y1, int x2, int y2, bool clear) { FrameStackDepth++; // DAJ if (FrameStackDepth > 7) { - mprintf(2, "FrameStack Overflow\n"); + LOG_FATAL << "FrameStack Overflow"; Int3(); } } void FramePop(int *x1, int *y1, int *x2, int *y2, bool *clear) { if (!FrameStackRoot || !FrameStackPtr) { - mprintf(0, "StartFrame/EndFrame mismatch\n"); + LOG_FATAL << "StartFrame/EndFrame mismatch"; Int3(); *clear = true; *x1 = Game_window_x; diff --git a/Descent3/gamecinematics.cpp b/Descent3/gamecinematics.cpp index c930b23d..bb05e53e 100644 --- a/Descent3/gamecinematics.cpp +++ b/Descent3/gamecinematics.cpp @@ -187,7 +187,10 @@ * $NoKeywords: $ */ -#include "pstypes.h" +#include +#include +#include + #include "pserror.h" #include "grtext.h" #include "renderer.h" @@ -195,13 +198,10 @@ #include "vecmat.h" #include "mem.h" #include "gamepath.h" -#include -#include -#include #include "game.h" +#include "log.h" #include "AIGoal.h" #include "aipath.h" -#include "objinfo.h" #include "player.h" #include "ddio.h" #include "gamefont.h" @@ -214,8 +214,6 @@ #include "multi.h" #include "weapon.h" -#include - #if (defined(_DEBUG) || defined(EDITOR)) bool Cinematics_enabled = true; extern int DoAI; @@ -428,10 +426,10 @@ static inline void verify_percentranage(PercentageRange *range) { // this would do what's needed. void Cinematic_PerformFake(void) { Cinematic_fake_queued = false; - mprintf(0, "Cinematics: Faking Cinematic\n"); + LOG_DEBUG << "Cinematics: Faking Cinematic"; object *target = ObjGet(Cinematic_fake_info.target_objhandle); if (!target) { - mprintf(0, "Cinematics: Invalid target...can't fake\n"); + LOG_WARNING << "Cinematics: Invalid target...can't fake"; return; } @@ -575,7 +573,7 @@ bool Cinematic_StartCine(tGameCinematic *info, const char *text_string, int came if (c) { objnum = OBJNUM(c); } else { - mprintf(0, "Unable to create camera\n"); + LOG_WARNING << "Unable to create camera"; return false; } @@ -588,13 +586,13 @@ bool Cinematic_StartCine(tGameCinematic *info, const char *text_string, int came } else { GameCinema.pathnum = info->pathid; if (GameCinema.pathnum == -1) { - mprintf(0, "Invalid Path given\n"); + LOG_WARNING << "Invalid Path given"; return false; } // Abort if not a good path if (((info->flags & GCF_CAMERAPLACEMENT) == GCF_USEPOINT)) { if (GamePaths[GameCinema.pathnum].num_nodes < 2) { - mprintf(0, "Not a good path passed to Cinematic_Start\n"); + LOG_WARNING << "Not a good path passed to Cinematic_Start"; return false; } } @@ -605,14 +603,6 @@ bool Cinematic_StartCine(tGameCinematic *info, const char *text_string, int came NULL, false); } - /* - if(objnum==-1){ - //couldn't create camera - mprintf(0,"Unable to create camera\n"); - return false; - } - */ - GameCinema.camera_objhandle = Objects[objnum].handle; GameCinema.target_triggered = false; object *camera = &Objects[objnum]; @@ -667,7 +657,7 @@ bool Cinematic_StartCine(tGameCinematic *info, const char *text_string, int came // The structs are setup, time to setup the camera and objects - mprintf(0, "Cinematic_Start\n"); + LOG_INFO << "Cinematic_Start"; Player_object->flags &= ~OF_DESTROYABLE; Players[Player_num].flags &= ~PLAYER_FLAGS_AFTERBURN_ON; @@ -847,13 +837,13 @@ bool Cinematic_StartCine(tGameCinematic *info, const char *text_string, int came vm_NormalizeVector(&turn_to); if (turn_to == Zero_vector) { - mprintf(0, "Cine: No turn_to or less than 1 degree off goal\n"); + LOG_WARNING << "Cine: No turn_to or less than 1 degree off goal"; goto continue_start; } goal_angle = vm_DeltaAngVecNorm(&camera->orient.fvec, &turn_to, &u_axis); if (goal_angle == 0) { - mprintf(0, "Cine: Goal angle is zero\n"); + LOG_WARNING << "Cine: Goal angle is zero"; goto continue_start; } @@ -920,7 +910,7 @@ void Cinematic_Stop(void) { // reset things back to normal, anything that might be messed up bool dont_restore_viewer = false; if (GameCinema.flags & GCF_DONTRESTOREVIEWER) { - mprintf(0, "********NOT RESTORING VIEW TO PLAYER*************\n"); + LOG_DEBUG << "********NOT RESTORING VIEW TO PLAYER*************"; dont_restore_viewer = true; } @@ -1124,13 +1114,13 @@ void Cinematic_Frame(void) { vm_NormalizeVector(&turn_to); if (turn_to == Zero_vector) { - mprintf(0, "Cine: No turn_to or less than 1 degree off goal\n"); + LOG_WARNING << "Cine: No turn_to or less than 1 degree off goal"; goto continue_frame; } goal_angle = vm_DeltaAngVecNorm(&camera->orient.fvec, &turn_to, &u_axis); if (goal_angle == 0) { - mprintf(0, "Cine: Goal angle is zero\n"); + LOG_WARNING << "Cine: Goal angle is zero"; goto continue_frame; } @@ -1692,7 +1682,7 @@ void CannedCinematicIntroCallback(int type) { switch (type) { case GCCT_START: { // start the player on the path - mprintf(0, "START PLAYER ON PATH\n"); + LOG_INFO << "START PLAYER ON PATH"; // determine how fast they need to travel int pathnum = CannedCinematicIntro.player_path; @@ -1717,7 +1707,7 @@ void CannedCinematicIntroCallback(int type) { int next_node; if (pathnum == -1) { - mprintf(0, "ILLEGAL PATH FOR PLAYER\n"); + LOG_WARNING << "ILLEGAL PATH FOR PLAYER"; break; } @@ -1731,19 +1721,19 @@ void CannedCinematicIntroCallback(int type) { if (fabs(vm_VectorDistance(&GamePaths[pathnum].pathnodes[1].pos, &GamePaths[pathnum].pathnodes[0].pos)) > 30.0f) { CannedCinematicIntro.should_thrust = true; - mprintf(0, "Player should thrust\n"); + LOG_WARNING << "Player should thrust"; } else { CannedCinematicIntro.should_thrust = false; - mprintf(0, "Player should NOT thrust\n"); + LOG_WARNING << "Player should NOT thrust"; } } else { CannedCinematicIntro.should_thrust = true; - mprintf(0, "Player should thrust\n"); + LOG_WARNING << "Player should thrust"; } } else { next_node = 0; CannedCinematicIntro.should_thrust = false; - mprintf(0, "Player should NOT thrust\n"); + LOG_WARNING << "Player should NOT thrust"; vm_VectorToMatrix(&orient, &GamePaths[pathnum].pathnodes[0].fvec, &GamePaths[pathnum].pathnodes[0].uvec, NULL); } pos = GamePaths[pathnum].pathnodes[0].pos; @@ -1765,7 +1755,7 @@ void CannedCinematicIntroCallback(int type) { } break; case GCCT_STOP: { // stop the player on the path - mprintf(0, "STOP PLAYER ON PATH\n"); + LOG_DEBUG << "STOP PLAYER ON PATH"; ResetPlayerControlType(Player_num); ResumeControls(); @@ -1824,7 +1814,7 @@ void CannedCinematicEndLevelCallback(int type) { // if the player is dead, bring them back from the dead if ((Players[Player_num].flags & PLAYER_FLAGS_DYING) || (Players[Player_num].flags & PLAYER_FLAGS_DEAD)) { // the player is currently dead - mprintf(0, "Bringing player back from the dead\n"); + LOG_INFO << "Bringing player back from the dead"; Players[Player_num].flags &= ~(PLAYER_FLAGS_DYING | PLAYER_FLAGS_DEAD); Player_object->shields = 1.0f; } @@ -1833,13 +1823,13 @@ void CannedCinematicEndLevelCallback(int type) { MakePlayerInvulnerable(Player_num, CannedCinematicEndLevel.cinematic_time, false); // start the player on the path - mprintf(0, "START PLAYER ON PATH\n"); + LOG_INFO << "START PLAYER ON PATH"; // determine how fast they need to travel int pathnum = CannedCinematicEndLevel.player_path; if (pathnum == -1) { - mprintf(0, "ILLEGAL PATH FOR PLAYER\n"); + LOG_WARNING << "ILLEGAL PATH FOR PLAYER"; break; } @@ -1902,7 +1892,7 @@ void CannedCinematicEndLevelCallback(int type) { } break; case GCCT_STOP: { // stop the player on the path - mprintf(0, "STOP PLAYER ON PATH\n"); + LOG_INFO << "STOP PLAYER ON PATH"; ResetPlayerControlType(Player_num); ResumeControls(); @@ -2180,7 +2170,7 @@ void Cinematic_StartCanned(tCannedCinematicInfo *info, int camera_handle) { CannedCinematic_EndLevelPoint(&cam->pos, cam->roomnum, info->text_to_display, info->target_pathid, info->time, camera_handle); } else { - mprintf(0, "Passed in object handle for canned cinematic (level end) for camera position does not exist\n"); + LOG_WARNING << "Passed in object handle for canned cinematic (level end) for camera position does not exist"; Cinematic_DeleteCamera(camera_handle); SetGameState(GAMESTATE_LVLEND); } @@ -2188,7 +2178,7 @@ void Cinematic_StartCanned(tCannedCinematicInfo *info, int camera_handle) { case CANNED_MOVE_PLAYER_FADE: { object *player = ObjGet(info->target_objhandle); if (!player || player->type != OBJ_PLAYER) { - mprintf(0, "Invalid player passed to CANNED_MOVE_PLAYER_FADE\n"); + LOG_INFO << "Invalid player passed to CANNED_MOVE_PLAYER_FADE"; Cinematic_DeleteCamera(camera_handle); return; } diff --git a/Descent3/gameevent.cpp b/Descent3/gameevent.cpp index 9b9ada2a..db5c1491 100644 --- a/Descent3/gameevent.cpp +++ b/Descent3/gameevent.cpp @@ -62,14 +62,15 @@ * $NoKeywords: $ */ +#include + #include "object.h" #include "game.h" #include "gameevent.h" +#include "log.h" #include "descent.h" #include "gameloop.h" #include "spew.h" -#include -// #include #include "mem.h" #include "player.h" @@ -155,7 +156,7 @@ void ProcessNormalEvents() { // the object has died, kill the event FreeEvent(i); skip_event = true; - mprintf(0, "Game Event %d cancelled\n", i); + LOG_DEBUG.printf("Game Event %d cancelled", i); } } @@ -208,7 +209,7 @@ int CreateNewEvent(int type, int id, float length, void *data, int size, void (* num = AllocEvent(); if (num == -1) { - mprintf(0, "WARNING: Event (type %d, id %d) did not get allocated\n", type, id); + LOG_WARNING.printf("WARNING: Event (type %d, id %d) did not get allocated", type, id); return -1; // couldn't do this event, no slots free } diff --git a/Descent3/gamefont.cpp b/Descent3/gamefont.cpp index efe66408..e4f90e40 100644 --- a/Descent3/gamefont.cpp +++ b/Descent3/gamefont.cpp @@ -113,10 +113,11 @@ * $NoKeywords: $ */ -#include +#include + #include "gamefont.h" -#include "game.h" #include "grtext.h" +#include "log.h" #include "pserror.h" #include "stringtable.h" @@ -149,7 +150,7 @@ int LoadFont(const char *font_name) { if (handle == -1) Error(TXT_ERRNOFONT, font_name); - mprintf(0, "Font <%s> height = %d\n", font_name, grfont_GetHeight(handle)); + LOG_INFO.printf("Font <%s> height = %d", font_name, grfont_GetHeight(handle)); return handle; } diff --git a/Descent3/gamepath.cpp b/Descent3/gamepath.cpp index 8ae28d44..ca71dc07 100644 --- a/Descent3/gamepath.cpp +++ b/Descent3/gamepath.cpp @@ -68,11 +68,12 @@ * $NoKeywords: $ */ +#include +#include + #include "gamepath.h" -#include -#include -#include "pserror.h" -#include "pstypes.h" +#include "log.h" +#include "mem.h" game_path GamePaths[MAX_GAME_PATHS]; int Num_game_paths = 0; @@ -83,7 +84,7 @@ void FreeGamePath(int n) { return; mem_free(GamePaths[n].pathnodes); - mprintf(0, "Path %d lost some\n", n); + LOG_DEBUG.printf("Path %d lost some", n); GamePaths[n].num_nodes = 0; GamePaths[n].used = 0; diff --git a/Descent3/gamepath.h b/Descent3/gamepath.h index 0923638f..d988cb33 100644 --- a/Descent3/gamepath.h +++ b/Descent3/gamepath.h @@ -38,13 +38,15 @@ #ifndef GAME_PATH_H #define GAME_PATH_H -#include "stdlib.h" -#include "pstypes.h" -#include "pserror.h" -#include "vecmat.h" +#include + #include "3d.h" #include "manage.h" #include "mem.h" +#include "pstypes.h" +#include "pserror.h" +#include "vecmat.h" + // chrishack -- this could be dynamically allocated at the beginning of a level // MAX_NODES_PER_PATH is big and so is MAX_GAME_PATHS diff --git a/Descent3/gamesave.cpp b/Descent3/gamesave.cpp index e84fd6db..7209d292 100644 --- a/Descent3/gamesave.cpp +++ b/Descent3/gamesave.cpp @@ -272,7 +272,6 @@ #include "cfile.h" #include "Mission.h" #include "gamesequence.h" -#include "gameevent.h" #include "gameloop.h" #include "game.h" #include "stringtable.h" @@ -284,8 +283,8 @@ #include "door.h" #include "doorway.h" #include "ship.h" -#include "soar.h" #include "hud.h" +#include "log.h" #include "weapon.h" #include "viseffect.h" #include "room.h" @@ -295,7 +294,6 @@ #include "levelgoal.h" #include "aistruct.h" #include "matcen.h" -#include "hud.h" #include "marker.h" #include "d3music.h" #include "weather.h" @@ -543,7 +541,7 @@ void __cdecl LoadGameDialogCB(newuiTiledWindow *wnd, void *data) bm_DestroyChunkedBitmap(&cb_data->chunk); } - mprintf(0, "savegame slot=%d\n", id - SAVE_HOTSPOT_ID); + LOG_DEBUG.printf("savegame slot=%d", id - SAVE_HOTSPOT_ID); ddio_MakePath(savegame_dir, Base_directory, "savegame", NULL); snprintf(filename, sizeof(filename), "saveg00%d", (id - SAVE_HOTSPOT_ID)); @@ -1120,17 +1118,17 @@ void SGSObjects(CFILE *fp) { gs_WriteInt(fp, op->attach_ultimate_handle); gs_WriteInt(fp, op->attach_parent_handle); if ((op->attach_ultimate_handle) && (OBJECT_HANDLE_NONE != op->attach_ultimate_handle)) { - mprintf(0, "Object %d has an ultimate parent of %d (%d)\n", i, OBJNUM(ObjGet(op->attach_ultimate_handle)), + LOG_DEBUG.printf("Object %d has an ultimate parent of %d (%d)", i, OBJNUM(ObjGet(op->attach_ultimate_handle)), op->attach_parent_handle); } if ((op->attach_ultimate_handle) && (OBJECT_HANDLE_NONE != op->attach_parent_handle)) { - mprintf(0, "Object %d has a parent of %d (%d)\n", i, OBJNUM(ObjGet(op->attach_parent_handle)), + LOG_DEBUG.printf("Object %d has a parent of %d (%d)", i, OBJNUM(ObjGet(op->attach_parent_handle)), op->attach_parent_handle); } gs_WriteInt(fp, pm->n_attach); if (pm->n_attach) { - mprintf(0, "Object %d has %d attach points.\n", i, pm->n_attach); + LOG_DEBUG.printf("Object %d has %d attach points.", i, pm->n_attach); if (op->attach_children) { gs_WriteInt(fp, 1); @@ -1219,7 +1217,7 @@ void SGSObjects(CFILE *fp) { // special things local to object SGSObjSpecial(fp, op); } - mprintf(0, "highest obj index = %d, ", Highest_object_index); + LOG_DEBUG.printf("highest obj index = %d", Highest_object_index); END_VERIFY_SAVEFILE(fp, "Objects save"); } diff --git a/Descent3/gamesave.h b/Descent3/gamesave.h index ebf278e4..5e164c12 100644 --- a/Descent3/gamesave.h +++ b/Descent3/gamesave.h @@ -86,6 +86,7 @@ #include "pstypes.h" #include "cfile.h" +#include "log.h" #include "object.h" #include "objinfo.h" @@ -165,7 +166,7 @@ int LoadGameState(const char *pathname); #define gs_WriteBool(_f, _b) cf_WriteByte(_f, _b) #define START_VERIFY_SAVEFILE(f) int cur_file_pos = cftell(f) -#define END_VERIFY_SAVEFILE(f, s) mprintf(0, "%s =%d bytes\n", s, cftell(f) - cur_file_pos) +#define END_VERIFY_SAVEFILE(f, s) LOG_DEBUG.printf("%s = %d bytes", s, cftell(f) - cur_file_pos) #define gs_ReadVector(_f, _v) \ do { \ diff --git a/Descent3/gamesequence.cpp b/Descent3/gamesequence.cpp index 44996109..04e6f352 100644 --- a/Descent3/gamesequence.cpp +++ b/Descent3/gamesequence.cpp @@ -1035,16 +1035,13 @@ #include "BOA.h" #include "gameevent.h" #include "AIMain.h" - #include "soar_helpers.h" - #include "terrain.h" #include "hlsoundlib.h" #include "SmallViews.h" #include "polymodel.h" #include "gametexture.h" #include "hud.h" -#include "findintersection.h" #include "menu.h" #include "newui.h" #include "cockpit.h" @@ -1069,8 +1066,8 @@ #include "doorway.h" #include "matcen.h" #include "dedicated_server.h" -#include "networking.h" #include "levelgoal.h" +#include "log.h" #include "demofile.h" #include "lightmap_info.h" #include "lightmap.h" @@ -1086,11 +1083,8 @@ #include "multi_dll_mgr.h" #include "multi_ui.h" #include "gamepath.h" -#include "vclip.h" #include "bsp.h" - #include "args.h" -void ResetHudMessages(void); // Variables tGameState Game_state = GAMESTATE_IDLE; // current game state. @@ -1302,7 +1296,7 @@ bool GameSequencer() { // Make sure we have the correct hogfile void CheckHogfile() { char hogpath[_MAX_PATH * 2]; - mprintf(0, "Checking to see if we need to open another hog off of disk or CDROM\n"); + LOG_DEBUG << "Checking to see if we need to open another hog off of disk or CDROM"; if (Current_mission.filename && (stricmp(Current_mission.filename, "d3.mn3") == 0) && (Current_mission.cur_level > 4)) { @@ -1387,7 +1381,7 @@ bool StartNewGame() { bool DoLevelIntro() { tLevelNode *lvl = Current_level; - mprintf(0, "In DoLevelIntro()\n"); + LOG_DEBUG << "In DoLevelIntro()"; // multiplayer stuff (we skip the movie and briefings) if (Game_mode & GM_MULTI) { @@ -1440,7 +1434,7 @@ void ClearViewerObjects() { for (i = 0, objp = Objects; i <= Highest_object_index; i++, objp++) if (objp->type == OBJ_VIEWER) { - mprintf(0, "Deleting viewer object %d\n", i); + LOG_DEBUG.printf("Deleting viewer object %d", i); ObjDelete(i); } } @@ -1542,7 +1536,7 @@ void StartLevel() { Players[Player_num].ship_index = FindShipName(ship_model); ASSERT(Players[Player_num].ship_index != -1); // DAJ -1FIX } else { - mprintf(0, "Player %d wanted to use a ship (%s) which wasn't allowed.\n", Player_num, ship_model); + LOG_DEBUG.printf("Player %d wanted to use a ship (%s) which wasn't allowed.", Player_num, ship_model); int i; bool found_one = false; @@ -1877,7 +1871,7 @@ void FlushDataCache() { } } - mprintf(0, "Freed %d textures, %d models, and %d sounds.\n", texfreed, modelsfreed, soundsfreed); + LOG_DEBUG.printf("Freed %d textures, %d models, and %d sounds.", texfreed, modelsfreed, soundsfreed); // the renderer is never initialized in dedicated server mode, so don't try to reset things either if (!Dedicated_server) { rend_ResetCache(); @@ -1947,7 +1941,7 @@ void EndLevel(int state) { if ((NetPlayers[i].flags & NPF_CONNECTED) && (NetPlayers[i].sequence >= NETSEQ_PLAYING)) { // check to see if player is dying if ((Players[i].flags & PLAYER_FLAGS_DYING) || (Players[i].flags & PLAYER_FLAGS_DEAD)) { - mprintf(0, "Prematurely ending death for player %d\n", i); + LOG_DEBUG.printf("Prematurely ending death for player %d", i); EndPlayerDeath(i); } } @@ -1956,7 +1950,7 @@ void EndLevel(int state) { } else { // in single player, check Player_num if ((Players[Player_num].flags & PLAYER_FLAGS_DYING) || (Players[Player_num].flags & PLAYER_FLAGS_DEAD)) { - mprintf(0, "Prematurely ending death for player\n"); + LOG_DEBUG.printf("Prematurely ending death for player"); EndPlayerDeath(Player_num); } } @@ -1984,7 +1978,7 @@ void SetNextLevel() { Multi_next_level = -1; } else if (lvl->flags & LVLFLAG_BRANCH) { // jump to brached level - mprintf(0, "Branching...\n"); + LOG_DEBUG << "Branching..."; Current_mission.cur_level = lvl->lvlbranch0; SetCurrentLevel(Current_mission.cur_level); } else if ((Current_mission.cur_level == Current_mission.num_levels) || (lvl->flags & LVLFLAG_FINAL)) { @@ -2351,7 +2345,7 @@ void PageInShip(int id) { // Create bumps if neccessary if (rend_SupportsBumpmapping()) { if (GameTextures[pm->textures[t]].bumpmap == -1) { - mprintf(0, "Trying to make bumpmap!\n"); + LOG_DEBUG << "Trying to make bumpmap!"; BuildTextureBumpmaps(pm->textures[t]); } } diff --git a/Descent3/gametexture.cpp b/Descent3/gametexture.cpp index ea59c00a..47389563 100644 --- a/Descent3/gametexture.cpp +++ b/Descent3/gametexture.cpp @@ -265,17 +265,16 @@ * $NoKeywords: $ */ -#include "grdefs.h" -#include "pstypes.h" +#include +#include + #include "gametexture.h" -#include "mono.h" +#include "log.h" #include "bitmap.h" #include "pserror.h" #include "vclip.h" #include "game.h" #include "bumpmap.h" -#include -#include #include "procedurals.h" #include "ddio.h" #include "config.h" @@ -302,7 +301,7 @@ int InitTextures() { int i, tex; - mprintf(0, "Initializing texture system.\n"); + LOG_INFO << "Initializing texture system."; for (i = 0; i < MAX_TEXTURES; i++) GameTextures[i].used = 0; @@ -592,8 +591,8 @@ int LoadTextureImage(const char *filename, int *type, int texture_size, int mipp if (!pageable && (w != bm_w(bm_handle, 0) || h != bm_h(bm_handle, 0))) { int dest_bm; - mprintf(0, "WARNING: Resizing bitmap %s from %d x %d to %d x %d!\n", GameBitmaps[bm_handle].name, - bm_w(bm_handle, 0), bm_h(bm_handle, 0), w, h); + LOG_WARNING.printf("WARNING: Resizing bitmap %s from %d x %d to %d x %d!", + GameBitmaps[bm_handle].name, bm_w(bm_handle, 0), bm_h(bm_handle, 0), w, h); dest_bm = bm_AllocBitmap(w, h, mipped * ((w * h * 2) / 3)); ASSERT(dest_bm >= 0); @@ -696,8 +695,8 @@ void PageInTexture(int n, bool resize) { Total_memory_saved += saved; - mprintf(0, "Low mem: Resizing bitmap %s to %d x %d!\n", GameBitmaps[bm_handle].name, w, h); - mprintf(0, "Total memory saved=%d\n", Total_memory_saved); + LOG_DEBUG.printf("Low mem: Resizing bitmap %s to %d x %d!", GameBitmaps[bm_handle].name, w, h); + LOG_DEBUG.printf("Total memory saved=%d", Total_memory_saved); dest_bm = bm_AllocBitmap(w, h, mipped * ((w * h * 2) / 3)); ASSERT(dest_bm >= 0); @@ -743,7 +742,7 @@ void BuildTextureBumpmaps(int texhandle) { if (GameTextures[texhandle].flags & TF_ANIMATED) return; // No bumps for animated textures - mprintf(0, "Calculating bumpmap for texture named %s.\n", GameTextures[texhandle].name); + LOG_DEBUG.printf("Calculating bumpmap for texture named %s.", GameTextures[texhandle].name); // Make sure there is no bump already ASSERT(GameTextures[texhandle].bumpmap == -1); diff --git a/Descent3/hotspotmap.cpp b/Descent3/hotspotmap.cpp index cd2729eb..466e1cb2 100644 --- a/Descent3/hotspotmap.cpp +++ b/Descent3/hotspotmap.cpp @@ -98,17 +98,14 @@ * $NoKeywords: $ */ -#include "mono.h" -#include "renderer.h" -#include "render.h" +#include +#include + +#include "log.h" #include "grdefs.h" #include "ddio.h" -#include "descent.h" #include "game.h" #include "cfile.h" -#include "application.h" -#include -#include #include "hotspotmap.h" #include "mem.h" #include "bitmap.h" @@ -242,10 +239,10 @@ int CreateHotSpotMap(const char *map, int width, int height, hotspotmap_t *hsmap } // end ifelse (hotspot_there) } // end for (count) - mprintf(0, "Hunting down empty hotspots....\n"); + LOG_DEBUG << "Hunting down empty hotspots...."; for (count = 0; count < num_hs; count++) { if (whats_there[count] == NOTHING_THERE) { - mprintf(0, "Notice: HotSpot %d is empty\n", count); + LOG_DEBUG.printf("Notice: HotSpot %d is empty", count); hsmap->hs[count].scanlines = 0; hsmap->hs[count].starting_y = 0; if (hsmap->hs[count].x) { @@ -255,18 +252,18 @@ int CreateHotSpotMap(const char *map, int width, int height, hotspotmap_t *hsmap } } - mprintf(0, "Finding window count..."); + LOG_DEBUG << "Finding window count..."; window_count = 0; for (count = 0; count < 256; count++) { if (whats_there[count] == WINDOW_THERE) window_count++; } - mprintf(0, "%d windows found\n", window_count); + LOG_DEBUG.printf("%d windows found", window_count); return window_count; } void CreateWindowMap(const char *map, int width, int height, windowmap_t *wndmap) { - mprintf(0, "Processing %d windows\n", wndmap->num_of_windows); + LOG_DEBUG.printf("Processing %d windows", wndmap->num_of_windows); int x, y, count; uint8_t alpha; bool newline = true; @@ -493,16 +490,16 @@ void CreateWindowMap(const char *map, int width, int height, windowmap_t *wndmap } for (count = 0; count < wndmap->num_of_windows; count++) { - mprintf(0, "Window #%d: Left/Top=(%d,%d) Width=%d Height=%d\n", count, wndmap->wm[count].x, wndmap->wm[count].y, - wndmap->wm[count].width, wndmap->wm[count].height); - mprintf(0, "---L.T. (%d,%d)->(%d,%d)\n", wndmap->wm[count].l_start_x, wndmap->wm[count].t_top_y, - wndmap->wm[count].l_end_x, wndmap->wm[count].t_bottom_y); - mprintf(0, "---R.T. (%d,%d)->(%d,%d)\n", wndmap->wm[count].r_start_x, wndmap->wm[count].t_top_y, - wndmap->wm[count].r_end_x, wndmap->wm[count].t_bottom_y); - mprintf(0, "---L.B. (%d,%d)->(%d,%d)\n", wndmap->wm[count].l_start_x, wndmap->wm[count].b_top_y, - wndmap->wm[count].l_end_x, wndmap->wm[count].b_bottom_y); - mprintf(0, "---R.B. (%d,%d)->(%d,%d)\n", wndmap->wm[count].r_start_x, wndmap->wm[count].b_top_y, - wndmap->wm[count].r_end_x, wndmap->wm[count].b_bottom_y); + LOG_DEBUG.printf("Window #%d: Left/Top=(%d,%d) Width=%d Height=%d", count, wndmap->wm[count].x, + wndmap->wm[count].y, wndmap->wm[count].width, wndmap->wm[count].height); + LOG_DEBUG.printf("---L.T. (%d,%d)->(%d,%d)", wndmap->wm[count].l_start_x, wndmap->wm[count].t_top_y, + wndmap->wm[count].l_end_x, wndmap->wm[count].t_bottom_y); + LOG_DEBUG.printf("---R.T. (%d,%d)->(%d,%d)", wndmap->wm[count].r_start_x, wndmap->wm[count].t_top_y, + wndmap->wm[count].r_end_x, wndmap->wm[count].t_bottom_y); + LOG_DEBUG.printf("---L.B. (%d,%d)->(%d,%d)", wndmap->wm[count].l_start_x, wndmap->wm[count].b_top_y, + wndmap->wm[count].l_end_x, wndmap->wm[count].b_bottom_y); + LOG_DEBUG.printf("---R.B. (%d,%d)->(%d,%d)", wndmap->wm[count].r_start_x, wndmap->wm[count].b_top_y, + wndmap->wm[count].r_end_x, wndmap->wm[count].b_bottom_y); } } @@ -530,7 +527,7 @@ int menutga_alloc_file(const char *name, char *hsmap[1], int *w, int *h) { image_type = cf_ReadByte(infile); if (color_map_type != 0 || (image_type != 2)) { - mprintf(0, "menutga: Can't read this type of TGA.\n"); + LOG_DEBUG << "menutga: Can't read this type of TGA."; return -1; } @@ -546,13 +543,13 @@ int menutga_alloc_file(const char *name, char *hsmap[1], int *w, int *h) { ASSERT(hsmap); if (pixsize != 32) { - mprintf(0, "menutga: This file has a pixsize of field of %d, it should be 32. ", pixsize); + LOG_DEBUG.printf("menutga: This file has a pixsize of field of %d, it should be 32. ", pixsize); return -1; } descriptor = cf_ReadByte(infile); if ((descriptor & 0x0F) != 8) { - mprintf(0, "menutga: Descriptor field & 0x0F must be 8, but this is %d.", descriptor & 0x0F); + LOG_DEBUG.printf("menutga: Descriptor field & 0x0F must be 8, but this is %d.", descriptor & 0x0F); return -1; } @@ -562,7 +559,7 @@ int menutga_alloc_file(const char *name, char *hsmap[1], int *w, int *h) { n = bm_AllocBitmap(width, height, 0); if (n < 0) { - mprintf(0, "menutga: Failed to allocate memory.\n"); + LOG_FATAL << "menutga: Failed to allocate memory."; Int3(); } @@ -596,7 +593,7 @@ int menutga_alloc_file(const char *name, char *hsmap[1], int *w, int *h) { // Given a filename and a hotspotmap structure, it saves it to disk (.HSM) void menutga_SaveHotSpotMap(const std::filesystem::path &filename, hotspotmap_t *hsmap, windowmap_t *wndmap) { CFILE *file; - mprintf(0, "Saving HotSpotMap %s ", filename.u8string().c_str()); + LOG_DEBUG.printf("Saving HotSpotMap %s", filename.u8string().c_str()); file = (CFILE *)cfopen(filename, "wb"); if (!file) { Int3(); // get jeff! @@ -604,7 +601,7 @@ void menutga_SaveHotSpotMap(const std::filesystem::path &filename, hotspotmap_t } int curr_hs, curr_sl; - mprintf(0, "Number of HotSpots=%d\n", hsmap->num_of_hotspots); + LOG_DEBUG.printf("Number of HotSpots=%d", hsmap->num_of_hotspots); cf_WriteByte(file, hsmap->num_of_hotspots); for (curr_hs = 0; curr_hs < hsmap->num_of_hotspots; curr_hs++) { @@ -673,8 +670,6 @@ void menutga_LoadHotSpotMap(int back_bmp, const char *filename, hotspotmap_t *hs FreeHotSpotMapInternals(hsmap); } - mprintf(0, "Loading hotspotmap %s ", filename); - CFILE *infile; infile = (CFILE *)cfopen(filename, "rb"); if (!infile) { @@ -684,8 +679,6 @@ void menutga_LoadHotSpotMap(int back_bmp, const char *filename, hotspotmap_t *hs hsmap->num_of_hotspots = cf_ReadByte(infile); - mprintf(0, "Contains: (%d hotspots) ", hsmap->num_of_hotspots); - int curr_hs, curr_sl, num_sl; hsmap->hs = (hotspot *)mem_malloc(sizeof(hotspot) * hsmap->num_of_hotspots); @@ -707,7 +700,8 @@ void menutga_LoadHotSpotMap(int back_bmp, const char *filename, hotspotmap_t *hs int count, index, size; wndmap->num_of_windows = cf_ReadInt(infile); - mprintf(0, "(%d Windows)\n", wndmap->num_of_windows); + LOG_DEBUG.printf("Loading hotspotmap %s Contains: (%d hotspots) (%d Windows)", + filename, hsmap->num_of_hotspots, wndmap->num_of_windows); wndmap->wm = (window_box *)mem_malloc(sizeof(window_box) * wndmap->num_of_windows); for (count = 0; count < wndmap->num_of_windows; count++) { wndmap->wm[count].x = cf_ReadInt(infile); @@ -828,7 +822,7 @@ void makecorner(int corner_bmp, int back_bmp, const char *tmap, int l, int t, in // This function frees up the allocated memory within a hotspotmap struct. It does not free up the struct though. void FreeHotSpotMapInternals(hotspotmap_t *hsmap) { - mprintf(0, "Freeing HSM internals\n"); + LOG_DEBUG << "Freeing HSM internals"; ASSERT(hsmap); @@ -857,7 +851,7 @@ void FreeHotSpotMapInternals(hotspotmap_t *hsmap) { bool menutga_ConvertTGAtoHSM(const char *fpath) { char path[255], filename[255], ext[8]; ddio_SplitPath(fpath, path, filename, ext); - mprintf(0, "Extracting hotspots from %s\n", filename); + LOG_DEBUG.printf("Extracting hotspots from %s", filename); // strip file name int index, width = 0, height = 0; @@ -881,7 +875,7 @@ bool menutga_ConvertTGAtoHSM(const char *fpath) { menu_filename = (char *)mem_malloc(size); strcpy(menu_filename, filename); strcat(menu_filename, ".HSM"); // Hot Spot Map - mprintf(0, "HSM=%s\n", menu_filename); + LOG_DEBUG.printf("HSM=%s", menu_filename); std::filesystem::path save_path = LocalManageGraphicsDir / menu_filename; diff --git a/Descent3/hud.cpp b/Descent3/hud.cpp index 87e1c19b..f6b90bf8 100644 --- a/Descent3/hud.cpp +++ b/Descent3/hud.cpp @@ -410,16 +410,18 @@ * $NoKeywords: $ */ +#include +#include +#include + #include "hud.h" -#include "gauges.h" #include "grdefs.h" #include "game.h" -#include "ddio.h" #include "player.h" #include "renderer.h" -#include "descent.h" #include "object.h" #include "gamefont.h" +#include "log.h" #include "polymodel.h" #include "cockpit.h" #include "game2dll.h" @@ -431,11 +433,6 @@ #include "stringtable.h" #include "pstring.h" #include "config.h" - -#include -#include -#include -#include #include "gamecinematics.h" #include "CtlCfgElem.h" #include "ctlconfig.h" @@ -625,7 +622,7 @@ void AddHUDItem(tHUDItem *item) { } if (i == MAX_HUD_ITEMS) { - mprintf(0, "Unable to add hud item (type=%d).\n", item->type); + LOG_DEBUG.printf("Unable to add hud item (type=%d).", item->type); } } @@ -761,7 +758,7 @@ redo_hud_switch: if ((Hud_mode == HUD_FULLSCREEN && mode == HUD_COCKPIT) || (Hud_mode == HUD_COCKPIT && mode == HUD_FULLSCREEN)) { uint8_t bmode = mode; // DAJ MAC using enums always int Current_pilot.set_hud_data((uint8_t *)&bmode); - mprintf(0, "Saving new hud mode to pilot\n"); + LOG_DEBUG << "Saving new hud mode to pilot"; PltWriteFile(&Current_pilot); } @@ -943,7 +940,7 @@ void SGSHudState(CFILE *fp) { cf_WriteShort(fp, (int16_t)huditem->buffer_size); cf_WriteString(fp, huditem->data.text); - mprintf(0, "sg: saved customtext2 (%x,%x,bufsize=%d)\n", huditem->x, huditem->y, huditem->buffer_size); + LOG_DEBUG.printf("sg: saved customtext2 (%x,%x,bufsize=%d)", huditem->x, huditem->y, huditem->buffer_size); } else if (huditem->type == HUD_ITEM_TIMER) { cf_WriteShort(fp, (int16_t)huditem->stat); cf_WriteByte(fp, (int8_t)huditem->type); @@ -954,7 +951,7 @@ void SGSHudState(CFILE *fp) { cf_WriteByte(fp, (int8_t)huditem->alpha); cf_WriteInt(fp, huditem->data.timer_handle); - mprintf(0, "sg: restored timer (%x,%x,timer_hndl=%d)\n", huditem->x, huditem->y, huditem->data.timer_handle); + LOG_DEBUG.printf("sg: restored timer (%x,%x,timer_hndl=%d)", huditem->x, huditem->y, huditem->data.timer_handle); } else if (huditem->type == HUD_ITEM_CUSTOMTEXT) { // commented out because persistent hud messages are custom text, and it is a mess to save the current // state of hud persistent messages. @@ -1005,7 +1002,7 @@ bool LGSHudState(CFILE *fp) { cf_ReadString(buffer, huditem.buffer_size, fp); UpdateCustomtext2HUDItem(buffer); mem_free(buffer); - mprintf(0, "lg: restored customtext2 (%x,%x,bufsize=%d)\n", huditem.x, huditem.y, huditem.buffer_size); + LOG_DEBUG.printf("lg: restored customtext2 (%x,%x,bufsize=%d)", huditem.x, huditem.y, huditem.buffer_size); break; case HUD_ITEM_TIMER: @@ -1018,7 +1015,7 @@ bool LGSHudState(CFILE *fp) { huditem.data.timer_handle = cf_ReadInt(fp); huditem.render_fn = RenderHUDTimer; // use pointer to function void (*fn)(struct tHUDItem *) AddHUDItem(&huditem); - mprintf(0, "lg: restored timer (%x,%x,timer_hndl=%d)\n", huditem.x, huditem.y, huditem.data.timer_handle); + LOG_DEBUG.printf("lg: restored timer (%x,%x,timer_hndl=%d)", huditem.x, huditem.y, huditem.data.timer_handle); break; // case HUD_ITEM_CUSTOMTEXT: @@ -1074,7 +1071,7 @@ void LoadHUDConfig(const char *filename, bool (*fn)(const char *, const char *, // open file fp = cfopen(filename, "rt"); if (!fp) { - mprintf(0, "Unable to find hud.inf file.\n"); + LOG_WARNING << "Unable to find hud.inf file."; return; } @@ -1181,14 +1178,14 @@ void LoadHUDConfig(const char *filename, bool (*fn)(const char *, const char *, } else if (fn && (*fn)(command, operand, ext_data)) { continue; } else { - mprintf(0, "Error reading hud file.\n"); + LOG_FATAL << "Error reading hud file."; Int3(); // contact samir. break; } } } } else { - mprintf(0, "Not a valid hud file.\n"); + LOG_WARNING << "Not a valid hud file."; } // use any reticle specified. @@ -1258,7 +1255,6 @@ void RenderHUDFrame() { CallGameDLL(EVT_CLIENT_HUD_INTERVAL, &DLLInfo); rend_SetZBufferState(1); - mprintf_at(2, 0, 0, "FPS: %f", GetFPS()); } // renders hud frame before any graphics are drawn @@ -1827,7 +1823,7 @@ void InitReticle(int primary_slots, int secondary_slots) { Reticle_elem_array[i].bmp_off = bm_AllocLoadFileBitmap(IGNORE_TABLE(filename), 0); if (Reticle_elem_array[i].bmp_off <= BAD_BITMAP_HANDLE) { Reticle_elem_array[i].bmp_off = -1; - mprintf(0, "Unable to load %s reticle image.\n", filename); + LOG_WARNING.printf("Unable to load %s reticle image.", filename); } } else { Reticle_elem_array[i].bmp_off = -1; @@ -1837,7 +1833,7 @@ void InitReticle(int primary_slots, int secondary_slots) { snprintf(filename, sizeof(filename), "%s%s", Reticle_prefix, Reticle_image_names[i][1]); Reticle_elem_array[i].bmp_on = bm_AllocLoadFileBitmap(IGNORE_TABLE(filename), 0); if (Reticle_elem_array[i].bmp_on <= BAD_BITMAP_HANDLE) { - mprintf(0, "Unable to load %s reticle image.\n", filename); + LOG_WARNING.printf("Unable to load %s reticle image.", filename); Reticle_elem_array[i].bmp_on = -1; } } else { diff --git a/Descent3/hudmessage.cpp b/Descent3/hudmessage.cpp index c5042baf..0d4cc85c 100644 --- a/Descent3/hudmessage.cpp +++ b/Descent3/hudmessage.cpp @@ -324,22 +324,22 @@ #include #include +#include +#include +#include -#include -#include -#include #include "grdefs.h" #include "hud.h" #include "game.h" #include "ddio.h" #include "gamefont.h" #include "newui.h" +#include "log.h" #include "multi.h" #include "player.h" #include "game2dll.h" #include "stringtable.h" #include "dedicated_server.h" -#include "AppConsole.h" #include "demofile.h" #include "mem.h" #include "textaux.h" @@ -689,7 +689,7 @@ void CorrectHudMessage(char *str) { if (grtext_GetTextLineWidth(str) <= Game_window_w) return; - mprintf(0, "Message '%s' is too long!\n", str); + LOG_WARNING.printf("Message '%s' is too long!", str); // the line is too long, we need to shorten it, but when we do, we need to make sure that it isn't in the middle // of a color (0x01 0xFF 0xFF 0xFF) str[HUD_MESSAGE_LENGTH - 1] = '\0'; @@ -1826,7 +1826,7 @@ void MsgListConsole::DoInput() { m_bufline = m_bufline + offset_count; if (offset_count < 0) { - mprintf(0, "bufline=%d\n", m_bufline); + LOG_DEBUG.printf("bufline=%d", m_bufline); } while (offset_count < 0) { @@ -1847,7 +1847,7 @@ void MsgListConsole::DoInput() { m_bufline = m_bufline + offset_count; if (offset_count > 0) { - mprintf(0, "bufline=%d\n", m_bufline); + LOG_DEBUG.printf("bufline=%d", m_bufline); } while (offset_count > 0) { diff --git a/Descent3/init.cpp b/Descent3/init.cpp index e41d15ea..ccfff435 100644 --- a/Descent3/init.cpp +++ b/Descent3/init.cpp @@ -959,6 +959,7 @@ #include "special_face.h" #include "voice.h" #include "localization.h" +#include "log.h" #include "stringtable.h" #include "player.h" #include "psrand.h" @@ -1076,7 +1077,7 @@ void PreInitD3Systems() { int iframelmtarg = FindArg("-limitframe"); if (iframelmtarg) { Min_allowed_frametime = atoi(GameArgs[iframelmtarg + 1]); - mprintf(0, "Using %d as a minimum frametime\n", Min_allowed_frametime); + LOG_INFO.printf("Using %d as a minimum frametime", Min_allowed_frametime); } else { if (FindArg("-dedicated")) Min_allowed_frametime = 30; @@ -1086,25 +1087,25 @@ void PreInitD3Systems() { iframelmtarg = FindArg("-framecap"); if (iframelmtarg) { Min_allowed_frametime = ((float)1.0 / (float)atoi(GameArgs[iframelmtarg + 1])) * 1000; - mprintf(0, "Using %d as a minimum frametime\n", Min_allowed_frametime); + LOG_INFO.printf("Using %d as a minimum frametime", Min_allowed_frametime); } else { // Default to a framecap of 60 Min_allowed_frametime = (1.0 / 60.0) * 1000; - mprintf(0, "Using default framecap of 60\n"); + LOG_INFO.printf("Using default framecap of 60"); } // Mouselook sensitivity! int msensearg = FindArg("-mlooksens"); if (msensearg) { Mouselook_sensitivity = kAnglesPerDegree * atof(GameArgs[msensearg + 1]); - mprintf(0, "Using mouselook sensitivity of %f\n", Mouselook_sensitivity); + LOG_INFO.printf("Using mouselook sensitivity of %f", Mouselook_sensitivity); } // Mouse sensitivity (non-mouselook) msensearg = FindArg("-mousesens"); if (msensearg) { Mouse_sensitivity = atof(GameArgs[msensearg + 1]); - mprintf(0, "Using mouse sensitivity of %f\n", Mouse_sensitivity); + LOG_INFO.printf("Using mouse sensitivity of %f", Mouse_sensitivity); } grtext_Init(); @@ -1408,7 +1409,7 @@ void InitIOSystems(bool editor) { std::string baseDirectoryString = executablePath.parent_path().string(); strncpy(Base_directory, baseDirectoryString.c_str(), sizeof(Base_directory) - 1); Base_directory[sizeof(Base_directory) - 1] = '\0'; - mprintf(0, "Using working directory of %s\n", Base_directory); + LOG_INFO << "Using working directory of " << Base_directory; } } else { ddio_GetWorkingDir(Base_directory, sizeof(Base_directory)); @@ -1453,7 +1454,7 @@ void InitIOSystems(bool editor) { // Setup temp directory INIT_MESSAGE(("Setting up temp directory.")); SetupTempDirectory(); - mprintf(0, "Removing any temp files left over from last execution\n"); + LOG_DEBUG << "Removing any temp files left over from last execution"; DeleteTempFiles(); // create directory system. @@ -1565,7 +1566,7 @@ void InitStringTable() { if (string_count == 0) Error("Couldn't find the string table."); else - mprintf(0, "%d strings loaded from the string tables\n", string_count); + LOG_INFO.printf("%d strings loaded from the string tables", string_count); } void InitGraphics(bool editor) { @@ -1751,7 +1752,7 @@ void IntroScreen() { #else int bm_handle = bm_AllocLoadFileBitmap("oemmenu.ogf", 0); #endif - mprintf(0, "Intro screen!.\n"); + LOG_INFO << "Intro screen!"; if (bm_handle > -1) { if (!bm_CreateChunkedBitmap(bm_handle, &Title_bitmap)) @@ -1762,7 +1763,7 @@ void IntroScreen() { Title_bitmap_init = true; InitMessage(NULL); } else { - mprintf(1, "Unable to find d3.tga.\n"); + LOG_WARNING << "Unable to find d3.tga."; } } @@ -1963,7 +1964,7 @@ void SetupTempDirectory(void) { // NOTE: No string tables are available at this point //-------------------------------------------------- - mprintf(0, "Setting up temp directory\n"); + LOG_INFO << "Setting up temp directory"; int t_arg = FindArg("-tempdir"); if (t_arg) { @@ -1996,7 +1997,7 @@ void SetupTempDirectory(void) { // verify that we can write to the temp directory if (!ddio_GetTempFileName(Descent3_temp_directory, "d3t", tempfilename)) { - mprintf(0, "Unable to get temp file name\n"); + LOG_WARNING << "Unable to get temp file name"; Error("Unable to set temporary directory to: \"%s\"", Descent3_temp_directory); exit(1); } @@ -2005,7 +2006,7 @@ void SetupTempDirectory(void) { CFILE *file = cfopen(tempfilename, "wb"); if (!file) { // unable to open file for writing - mprintf(0, "Unable to open temp file name for writing\n"); + LOG_WARNING << "Unable to open temp file name for writing"; Error("Unable to set temporary directory to: \"%s\"", Descent3_temp_directory); exit(1); } @@ -2017,7 +2018,7 @@ void SetupTempDirectory(void) { file = cfopen(tempfilename, "rb"); if (!file) { // unable to open file for reading - mprintf(0, "Unable to open temp file name for reading\n"); + LOG_WARNING << "Unable to open temp file name for reading"; ddio_DeleteFile(tempfilename); Error("Unable to set temporary directory to: \"%s\"", Descent3_temp_directory); exit(1); @@ -2025,7 +2026,7 @@ void SetupTempDirectory(void) { if (cf_ReadInt(file) != 0x56) { // verify failed - mprintf(0, "Temp file verify failed\n"); + LOG_WARNING << "Temp file verify failed"; cfclose(file); ddio_DeleteFile(tempfilename); Error("Unable to set temporary directory to: \"%s\"", Descent3_temp_directory); @@ -2037,11 +2038,11 @@ void SetupTempDirectory(void) { // temp directory is valid! ddio_DeleteFile(tempfilename); - mprintf(0, "Temp Directory Set To: \"%s\"\n", Descent3_temp_directory); + LOG_INFO << "Temp directory set to: " << Descent3_temp_directory; // Lock the directory if (!ddio_CreateLockFile(std::filesystem::path(Descent3_temp_directory))) { - mprintf(0, "Lock file NOT created in temp dir %s!\n", Descent3_temp_directory); + LOG_WARNING << "Lock file NOT created in temp dir " << Descent3_temp_directory; Error("Unable to set temporary directory to: \"%s\"\nUnable to create lock file", Descent3_temp_directory); exit(1); } @@ -2053,9 +2054,8 @@ void DeleteTempFiles() { ddio_DoForeachFile(Descent3_temp_directory, std::regex("d3[smocti].+\\.tmp"), [](const std::filesystem::path &path) { std::error_code ec; std::filesystem::remove(path, ec); - if (ec) { - mprintf(0, "Unable to remove temporary file %s: %s\n", path.u8string().c_str(), ec.message().c_str()); - } + LOG_WARNING_IF(ec).printf("Unable to remove temporary file %s: %s\n", + path.u8string().c_str(), ec.message().c_str()); }); } @@ -2077,7 +2077,7 @@ void ShutdownD3() { if (!Init_systems_init) return; - mprintf(0, "Shutting down D3...\n"); + LOG_INFO << "Shutting down D3..."; // Close forcefeedback effects ForceShutdown(); @@ -2124,7 +2124,7 @@ void RestartD3() { if (!Init_systems_init) return; - mprintf(0, "Restarting D3...\n"); + LOG_INFO << "Restarting D3..."; if (!FindArg("-windowed")) { if (Dedicated_server) { diff --git a/Descent3/levelgoal.cpp b/Descent3/levelgoal.cpp index 3d7a6445..d5cd687f 100644 --- a/Descent3/levelgoal.cpp +++ b/Descent3/levelgoal.cpp @@ -155,16 +155,15 @@ * */ +#include + #include "levelgoal.h" +#include "log.h" #include "mem.h" -#include "string.h" #include "hud.h" #include "game.h" -#include "gamesequence.h" #include "stringtable.h" -#include #include "pstring.h" -#include "hlsoundlib.h" #include "sounds.h" #include "osiris_dll.h" #include "room.h" @@ -175,7 +174,6 @@ #include "demofile.h" #include "osiris_share.h" #include "multisafe.h" -#include "multi.h" #include "multi_world_state.h" #define GOAL_MESSAGE_TIME 10.0 @@ -561,7 +559,7 @@ void lgoal::SendStateToPlayer(int index, int pnum) { if (!(NetPlayers[pnum].flags & NPF_CONNECTED && NetPlayers[pnum].sequence == NETSEQ_PLAYING)) return; - mprintf(0, "Sending modified LevelGoal %d to player %d\n", index, pnum); + LOG_DEBUG.printf("Sending modified LevelGoal %d to player %d", index, pnum); // now update the buddy handle list of the clients int count = 0; diff --git a/Descent3/lighting.cpp b/Descent3/lighting.cpp index af892579..c0a86796 100644 --- a/Descent3/lighting.cpp +++ b/Descent3/lighting.cpp @@ -24,15 +24,17 @@ * $NoKeywords: $ */ +#include +#include +#include + #include "3d.h" #include "gametexture.h" #include "lighting.h" #include "lightmap.h" -#include "descent.h" +#include "log.h" #include "game.h" #include "room.h" -#include -#include #include "findintersection.h" #include "lightmap_info.h" #include "polymodel.h" @@ -41,9 +43,6 @@ #include "config.h" #include "dedicated_server.h" #include "objinfo.h" -#include "Macros.h" - -#include #define NUM_DYNAMIC_CLASSES 7 #define MAX_DYNAMIC_FACES 2000 @@ -118,7 +117,7 @@ void FreeLighting() { void InitDynamicLighting() { int i, cl, size; - mprintf(0, "Initting dynamic lighting.\n"); + LOG_INFO << "Initializing dynamic lighting."; memset(Lmi_spoken_for, 0, MAX_LIGHTMAP_INFOS / 8); @@ -153,7 +152,7 @@ void InitDynamicLighting() { Ubyte_to_float[i] = (float)i / 255.0; // Setup specular tables - mprintf(0, "Building specular tables.\n"); + LOG_DEBUG << "Building specular tables."; for (i = 0; i < MAX_SPECULAR_INCREMENTS; i++) { float val = (float)i / (float)(MAX_SPECULAR_INCREMENTS - 1); @@ -177,7 +176,7 @@ uint8_t Float_to_ubyte(float fnum) { int i; if (fnum < 0 || fnum > 1.0) { - mprintf(0, "ERROR: Trying to get value in Float_to_ubyte that is %f!\n", fnum); + LOG_WARNING.printf("ERROR: Trying to get value in Float_to_ubyte that is %f!", fnum); return 0; } @@ -197,7 +196,7 @@ int GetFreeDynamicLightmap(int w, int h) { return -1; if (total + Cur_dynamic_mem_ptr > DYNAMIC_LIGHTMAP_MEMORY) { - mprintf(0, "Ran out of lightmap memory (%d)\n", DYNAMIC_LIGHTMAP_MEMORY); + LOG_WARNING.printf("Ran out of lightmap memory (%d)", DYNAMIC_LIGHTMAP_MEMORY); return -1; } @@ -295,7 +294,7 @@ void ApplyLightingToExternalRoom(vector *pos, int roomnum, float light_dist, flo continue; if (Num_dynamic_faces >= MAX_DYNAMIC_FACES) { - mprintf(0, "Too many dynamic faces!\n"); + LOG_WARNING << "Too many dynamic faces!"; return; } @@ -415,7 +414,7 @@ void ApplyLightingToExternalRoom(vector *pos, int roomnum, float light_dist, flo int dynamic_handle = GetFreeDynamicLightmap(xres, yres); if (dynamic_handle < 0) { - mprintf(0, "No free dynamic maps!\n"); + LOG_WARNING << "No free dynamic maps!"; return; // None free! } @@ -642,7 +641,7 @@ void ApplyLightingToSubmodel(object *obj, poly_model *pm, bsp_info *sm, float li // Ok, now we know that this light touches this face if (Num_dynamic_faces >= MAX_DYNAMIC_FACES) { - mprintf(0, "Too many dynamic faces!\n"); + LOG_WARNING << "Too many dynamic faces!"; DoneLightingInstance(); return; } @@ -762,7 +761,7 @@ void ApplyLightingToSubmodel(object *obj, poly_model *pm, bsp_info *sm, float li int dynamic_handle = GetFreeDynamicLightmap(xres, yres); if (dynamic_handle < 0) { - mprintf(0, "No free dynamic maps!\n"); + LOG_WARNING << "No free dynamic maps!"; DoneLightingInstance(); return; // None free! @@ -972,7 +971,6 @@ void ApplyVolumeLightToObject(vector *pos, object *obj, float light_dist, float // See if this specular light source is greater than our current one if ((light_dist - mag) > obj->effect_info->spec_mag && Detail_settings.Specular_lighting && !(Object_info[obj->id].lighting_info.flags & OLF_NO_SPECULARITY)) { - // mprintf(0,"Setting specular!\n"); obj->effect_info->type_flags |= EF_SPECULAR; obj->effect_info->spec_mag = light_dist - mag; obj->effect_info->spec_pos = *pos; @@ -1069,12 +1067,8 @@ void ApplyLightingToRooms(vector *pos, int roomnum, float light_dist, float red_ num_faces = fvi_QuickDistFaceList(roomnum, pos, light_dist, facelist, MAX_DYNAMIC_FACES); -#ifdef _DEBUG - if (num_faces == MAX_DYNAMIC_FACES) { - mprintf(0, "Dynamic light from 1 object is touching %d faces! dist=%f\n", MAX_DYNAMIC_FACES, light_dist); - } -#endif - + LOG_DEBUG_IF(num_faces == MAX_DYNAMIC_FACES).printf("Dynamic light from 1 object is touching %d faces! dist=%f", + MAX_DYNAMIC_FACES, light_dist); if (num_faces < 1) return; @@ -1094,7 +1088,7 @@ void ApplyLightingToRooms(vector *pos, int roomnum, float light_dist, float red_ continue; if (Num_dynamic_faces >= MAX_DYNAMIC_FACES) { - mprintf(0, "Too many dynamic faces!\n"); + LOG_WARNING << "Too many dynamic faces!"; return; } @@ -1220,7 +1214,7 @@ void ApplyLightingToRooms(vector *pos, int roomnum, float light_dist, float red_ int dynamic_handle = GetFreeDynamicLightmap(xres, yres); if (dynamic_handle < 0) { - mprintf(0, "No free dynamic maps!\n"); + LOG_WARNING << "No free dynamic maps!"; return; // None free! } @@ -1479,9 +1473,8 @@ void ApplyLightingToTerrain(vector *pos, int cellnum, float light_dist, float re if (num_cells < 1) return; - if (num_cells == MAX_DYNAMIC_CELLS) { - mprintf(0, "One object has hit %d terrain cells in lighting!\n", MAX_DYNAMIC_CELLS); - } + LOG_WARNING_IF(num_cells == MAX_DYNAMIC_CELLS).printf("One object has hit %d terrain cells in lighting!", + MAX_DYNAMIC_CELLS); int red_limit = 255; int green_limit = 255; @@ -1505,7 +1498,7 @@ void ApplyLightingToTerrain(vector *pos, int cellnum, float light_dist, float re // continue; if (Num_dynamic_cells >= MAX_DYNAMIC_CELLS) { - mprintf(0, "Too many dynamic cells!\n"); + LOG_WARNING << "Too many dynamic cells!"; return; } @@ -2023,7 +2016,7 @@ void DestroyLight(int roomnum, int facenum) { // green_scale/=30; // blue_scale/=30; - mprintf(0, "r=%f g=%f b=%f\n", red_scale, green_scale, blue_scale); + LOG_DEBUG.printf("r=%f g=%f b=%f", red_scale, green_scale, blue_scale); // Get center and area of light face for (i = 0; i < destroy_fp->num_verts; i++) @@ -2224,11 +2217,11 @@ void DestroyLight(int roomnum, int facenum) { // Adds to our list of destroyable lights that got destroyed this frame void AddToDestroyableLightList(int roomnum, int facenum) { if (Num_destroyed_lights_this_frame >= MAX_DESTROYED_LIGHTS_PER_FRAME) { - mprintf(0, "Ran out of destroyable light slots!\n"); + LOG_WARNING << "Ran out of destroyable light slots!"; return; } - mprintf(0, "Destroying light. Room=%d face=%d\n", roomnum, facenum); + LOG_INFO.printf("Destroying light. Room=%d face=%d", roomnum, facenum); Destroyed_light_rooms_this_frame[Num_destroyed_lights_this_frame] = roomnum; Destroyed_light_faces_this_frame[Num_destroyed_lights_this_frame++] = facenum; diff --git a/Descent3/list.cpp b/Descent3/list.cpp index c6d2902b..8713fd58 100644 --- a/Descent3/list.cpp +++ b/Descent3/list.cpp @@ -17,7 +17,7 @@ */ #include "list.h" -// #include +#include "log.h" #include "mem.h" // Allocates space for a new list node, returning the pointer to it @@ -26,7 +26,7 @@ listnode *NewListNode(void) { node = (listnode *)mem_malloc(sizeof(listnode)); if (node == NULL) { - mprintf(0, "Not enough memory for a new listnode!\n"); + LOG_FATAL << "Not enough memory for a new listnode!"; Int3(); return NULL; } @@ -46,7 +46,7 @@ int AddListItem(listnode **listp, void *item) { newnode = NewListNode(); if (newnode == NULL) { - mprintf(0, "There was a problem mallocing list node memory!\n"); + LOG_FATAL << "There was a problem mallocing list node memory!"; Int3(); return 0; } @@ -88,7 +88,7 @@ int RemoveListItem(listnode **listp, void *item) { } if (!inlist) { - mprintf(0, "RemoveItem: Warning, item not found in list\n"); + LOG_WARNING << "RemoveItem: Warning, item not found in list"; return 0; } diff --git a/Descent3/loadstate.cpp b/Descent3/loadstate.cpp index 54780087..d009ba15 100644 --- a/Descent3/loadstate.cpp +++ b/Descent3/loadstate.cpp @@ -179,14 +179,17 @@ * $NoKeywords: $ */ +#include +#include + #include "gamesave.h" -#include "descent.h" #include "cfile.h" #include "Mission.h" #include "gamesequence.h" #include "gameevent.h" #include "gameloop.h" #include "game.h" +#include "log.h" #include "object.h" #include "objinfo.h" #include "gametexture.h" @@ -194,7 +197,6 @@ #include "ship.h" #include "door.h" #include "stringtable.h" -#include "soar.h" #include "weapon.h" #include "vclip.h" #include "viseffect.h" @@ -206,7 +208,6 @@ #include "mem.h" #include "osiris_dll.h" #include "terrain.h" -#include #include "levelgoal.h" #include "aistruct.h" #include "matcen.h" @@ -217,8 +218,6 @@ #include "cockpit.h" #include "hud.h" -#include - extern void PageInAllData(); // dynamically allocated to be efficient (only needed during save/load) @@ -1294,7 +1293,7 @@ int LGSObjects(CFILE *fp, int version) { poly_model *pm = &Poly_models[op->rtype.pobj_info.model_num]; if (pm->n_attach) { - mprintf(0, "*Object %d has %d attach points.\n", i, pm->n_attach); + LOG_DEBUG.printf("*Object %d has %d attach points.", i, pm->n_attach); } polyobj_info *p_info = &op->rtype.pobj_info; @@ -1399,7 +1398,8 @@ int LGSObjects(CFILE *fp, int version) { ObjLink(OBJNUM(op), newroom); ObjSetOrient(op, &objmat[i]); if (op->type == OBJ_ROOM) { - mprintf(0, "Object %d is a room and Is%s a big object. Size=%f\n", i, (op->flags & OF_BIG_OBJECT) ? "" : "n't", op->size); + LOG_DEBUG.printf("Object %d is a room and Is%s a big object. Size=%f", + i, (op->flags & OF_BIG_OBJECT) ? "" : "n't", op->size); if ((op->size >= ((TERRAIN_SIZE * (float)1))) && !(op->flags & OF_BIG_OBJECT)) { BigObjAdd(i); } @@ -1424,9 +1424,9 @@ int LGSObjects(CFILE *fp, int version) { } */ } - mprintf(0, "Objects[121].prev=%d\n", Objects[121].prev); + LOG_DEBUG.printf("Objects[121].prev=%d", Objects[121].prev); ResetFreeObjects(); - mprintf(0, "highest obj index = %d, ", Highest_object_index); + LOG_DEBUG.printf("highest obj index = %d, ", Highest_object_index); ObjReInitPositionHistory(); END_VERIFY_SAVEFILE(fp, "Objects load"); diff --git a/Descent3/localization.cpp b/Descent3/localization.cpp index 03766c00..dd5badc7 100644 --- a/Descent3/localization.cpp +++ b/Descent3/localization.cpp @@ -84,17 +84,18 @@ * $NoKeywords: $ */ -#include -#include -#include -#include -#include "game.h" -#include "descent.h" -#include "mono.h" +#include +#include +#include +#include + #include "cfile.h" -#include "localization.h" -#include "mem.h" #include "ddio.h" +#include "descent.h" +#include "game.h" +#include "localization.h" +#include "log.h" +#include "mem.h" struct tLangTag { const char *tag; @@ -313,7 +314,7 @@ try_english: // no strings found Localization_language = old_language; - mprintf(0, "Localization: Warning, 0 strings found in %s\n", filename); + LOG_WARNING << "Localization: Warning, 0 strings found in " << filename; *table = NULL; *size = 0; return true; @@ -418,7 +419,7 @@ try_english: cfclose(file); - mprintf(0, "String Table (%s) loaded with %d strings\n", filename, *size); + LOG_INFO.printf("String Table (%s) loaded with %d strings", filename, *size); Localization_language = old_language; return (scount == (*size)); diff --git a/Descent3/marker.cpp b/Descent3/marker.cpp index 3cd66841..40fac4aa 100644 --- a/Descent3/marker.cpp +++ b/Descent3/marker.cpp @@ -17,6 +17,7 @@ */ #include "object.h" +#include "log.h" #include "marker.h" #include "polymodel.h" #include "player.h" @@ -42,7 +43,7 @@ void DropMarker(char *message) { if (strcmp("ai debug", teststring) == 0) { sscanf(message, "ai debug %d", &AI_debug_robot_index); - mprintf(0, "Debug robot is object index %d\n", AI_debug_robot_index); + LOG_DEBUG.printf("Debug robot is object index %d", AI_debug_robot_index); } #endif @@ -81,10 +82,10 @@ void DropMarker(char *message) { int objnum = ObjCreate(OBJ_MARKER, cur_marker_num, Player_object->roomnum, &Player_object->pos, &Player_object->orient, Player_object->handle); if (objnum >= 0) { - mprintf(0, "Marker %d created!\n", cur_marker_num); + LOG_DEBUG.printf("Marker %d created!", cur_marker_num); strcpy(MarkerMessages[(Player_num * 2) + cur_marker_num], message); } else - mprintf(0, "Marker NOT created!\n"); + LOG_WARNING << "Marker NOT created!"; } // Resets markers before a level stars diff --git a/Descent3/matcen.cpp b/Descent3/matcen.cpp index 2cbbc0b3..a0004a4a 100644 --- a/Descent3/matcen.cpp +++ b/Descent3/matcen.cpp @@ -144,11 +144,15 @@ #include "globals.h" #endif +#include +#include +#include + +#include "log.h" #include "matcen.h" #include "game.h" #include "sounds.h" #include "ssl_lib.h" -#include "string.h" #include "soundload.h" #include "room.h" #include "object.h" @@ -156,8 +160,9 @@ #include "findintersection.h" #ifndef NEWEDITOR #include "multi.h" +#include "player.h" +#include "osiris_dll.h" #endif -#include #include "fireball.h" #include "weapon.h" #include "polymodel.h" @@ -168,16 +173,9 @@ #include "physics.h" #include "mem.h" #include "ObjScript.h" -#ifndef NEWEDITOR -#include "player.h" -#include "osiris_dll.h" -#endif #include "psrand.h" #include "demofile.h" - -#include - // Beginning of the real file #define LEVEL_DATA_MATCEN_VERSION 1 #define GAME_DATA_MATCEN_VERSION 1 @@ -285,7 +283,7 @@ bool matcen::StartObjProd() { return false; if (m_max_prod <= m_num_prod && m_max_prod != -1) { - mprintf(0, "MATCEN: Done\n"); + LOG_DEBUG << "MATCEN: Done"; m_status |= MSTAT_DONE_PROD; return false; } @@ -1056,7 +1054,7 @@ bool matcen::ComputeNextProdInfo() { m_status &= ~MSTAT_DONE_PROD; if (m_max_prod <= m_num_prod && m_max_prod != -1) { - mprintf(0, "MATCEN: Done\n"); + LOG_DEBUG << "MATCEN: Done"; m_status |= MSTAT_DONE_PROD; return false; } diff --git a/Descent3/menu.cpp b/Descent3/menu.cpp index d5338717..352ace25 100644 --- a/Descent3/menu.cpp +++ b/Descent3/menu.cpp @@ -655,6 +655,7 @@ #include #include +#include "log.h" #include "menu.h" #include "mmItem.h" #include "game.h" @@ -785,7 +786,7 @@ int MainMenu() { } else if (MultiDLLGameStarting) { // Go back into the multiplayer DLL @ the game list - mprintf(0, "Returning to Multiplayer!\n"); + LOG_DEBUG << "Returning to Multiplayer!"; if (ReturnMultiplayerGameMenu()) { exit_menu = 1; @@ -860,9 +861,9 @@ int MainMenu() { case IDV_MULTIPLAYER: { IsCheater = false; main_menu.SetMusicRegion(MULTI_MUSIC_REGION); - mprintf(0, "Multiplayer!\n"); + LOG_DEBUG << "Multiplayer!"; // make all ships available - mprintf(0, "Making all ships available\n"); + LOG_DEBUG << "Making all ships available"; for (int i = 0; i < MAX_SHIPS; i++) { if (Ships[i].used) PlayerSetShipPermission(-1, Ships[i].name, true); @@ -928,13 +929,13 @@ bool ProcessCommandLine() { szurl[strlen("d3demo2://") - 1] = '\0'; // Should make the string "d3demo:/" p = szurl + strlen("d3demo2://"); // pointer to the first character of the url after the // if (stricmp(szurl, "d3demo2:/") == 0) { - mprintf(0, "Got a url passed: %s\n", p); + LOG_DEBUG.printf("Got a url passed: %s", p); } #else szurl[strlen("descent3://") - 1] = '\0'; // Should make the string "descent3:/" p = szurl + strlen("descent3://"); // pointer to the first character of the url after the // if (stricmp(szurl, "descent3:/") == 0) { - mprintf(0, "Got a url passed: %s\n", p); + LOG_DEBUG.printf("Got a url passed: %s", p); } #endif tokp = strtok(p, "/"); @@ -947,13 +948,13 @@ bool ProcessCommandLine() { if (LoadMultiDLL("Direct TCP~IP")) { CallMultiDLL(MT_AUTO_LOGIN); if (MultiDLLGameStarting) { - mprintf(0, "Successfully connected to server at specified url.\n"); + LOG_DEBUG << "Successfully connected to server at specified url."; exit_menu = 1; } else { - mprintf(0, "Couldn't connect to server at specified url.\n"); + LOG_DEBUG << "Couldn't connect to server at specified url."; } } else { - mprintf(0, "Couldn't load DLL.\n"); + LOG_WARNING << "Couldn't load DLL."; } } else if (stricmp(tokp, "pxo") == 0) { tokp = strtok(NULL, "/"); @@ -964,13 +965,13 @@ bool ProcessCommandLine() { if (LoadMultiDLL("parallax online")) { CallMultiDLL(MT_AUTO_LOGIN); if (MultiDLLGameStarting) { - mprintf(0, "Successfully connected to server at specified url.\n"); + LOG_INFO << "Successfully connected to server at specified url."; exit_menu = 1; } else { - mprintf(0, "Couldn't connect to server at specified url.\n"); + LOG_WARNING << "Couldn't connect to server at specified url."; } } else { - mprintf(0, "Couldn't load DLL.\n"); + LOG_WARNING << "Couldn't load DLL."; } } } else if ((!Auto_connected) && (FindArg("-pxo"))) { @@ -1070,17 +1071,17 @@ static inline int count_missions(const std::filesystem::path &base_directory) { ddio_DoForeachFile(base_directory, std::regex(".*\\.mn3"), [&c](const std::filesystem::path &path) { if (stricmp(path.filename().u8string().c_str(), "d3_2.mn3") == 0) return; - mprintf(0, "Mission path: %s\n", path.u8string().c_str()); + LOG_DEBUG.printf("Mission path: %s", path.u8string().c_str()); tMissionInfo msninfo{}; GetMissionInfo(path.filename().u8string().c_str(), &msninfo); if (msninfo.name[0] && msninfo.single) { - mprintf(0, "Name: %s\n", msninfo.name); + LOG_DEBUG.printf("Name: %s", msninfo.name); c++; if (!(c % 2)) DoWaitMessage(true); } else { - mprintf(0, "Illegal or multiplayer mission: %s\n", path.u8string().c_str()); + LOG_DEBUG.printf("Illegal or multiplayer mission: %s", path.u8string().c_str()); } }); diff --git a/Descent3/mission_download.cpp b/Descent3/mission_download.cpp index dacfcc4d..5df68603 100644 --- a/Descent3/mission_download.cpp +++ b/Descent3/mission_download.cpp @@ -118,7 +118,7 @@ * */ -#include +#include #include "pstypes.h" #include "mem.h" @@ -126,17 +126,16 @@ #include "descent.h" #include "networking.h" #include "multi.h" +#include "log.h" #include "ui.h" #include "newui.h" #include "ddio.h" #include "stringtable.h" #include "multi_dll_mgr.h" -// #include "inetgetfile.h" #include "grtext.h" #include "Mission.h" #include "mission_download.h" #include "renderer.h" - #include "unzip.h" int Got_url; @@ -615,7 +614,7 @@ int msn_CheckGetMission(network_address *net_addr, char *filename) { int sel = msn_ShowDownloadChoices(murls); if (sel != -1) { // Get the item that was selected! - mprintf(0, "Downloading missions file from %s\n", murls->URL[sel]); + LOG_DEBUG.printf("Downloading missions file from %s", murls->URL[sel]); if (msn_DownloadWithStatus(murls->URL[sel], filename)) { return 1; } @@ -691,9 +690,9 @@ void _get_zipfilename(char *output, char *directory, char *zipfilename) { // return 1 on success int msn_ExtractZipFile(char *zipfilename, char *mn3name) { - mprintf(0, "Extracting ZIP File (%s) to missions directory\n", zipfilename); + LOG_DEBUG.printf("Extracting ZIP File (%s) to missions directory", zipfilename); if (!cfexist(zipfilename)) { - mprintf(0, "Zip file doesn't exist\n"); + LOG_WARNING << "Zip file doesn't exist"; return 0; } @@ -708,7 +707,7 @@ int msn_ExtractZipFile(char *zipfilename, char *mn3name) { zipentry *ze; if (!zfile.OpenZip(zipfilename)) { - mprintf(0, "Unable to open zip file\n"); + LOG_WARNING << "Unable to open zip file"; return 0; } @@ -730,7 +729,7 @@ int msn_ExtractZipFile(char *zipfilename, char *mn3name) { Descent->defer(); process_file = true; - mprintf(0, "Processesing: %s\n", ze->name); + LOG_DEBUG.printf("Processesing: %s", ze->name); if (ze->compression_method == 0x0000 || ze->compression_method == 0x0008) { char *rfile = strrchr(ze->name, '/'); @@ -750,7 +749,7 @@ int msn_ExtractZipFile(char *zipfilename, char *mn3name) { snprintf(buffer, sizeof(buffer), "%s already exists. Overwrite?", output_filename); if (DoMessageBox("Confirm", buffer, MSGBOX_YESNO, UICOL_WINDOW_TITLE, UICOL_TEXT_NORMAL)) { // delete the file - mprintf(0, "Deleting %s\n", zipfilename); + LOG_DEBUG.printf("Deleting %s", zipfilename); if (!ddio_DeleteFile(output_filename)) { process_file = false; console.puts(GR_GREEN, "[Unable to Write] "); @@ -772,10 +771,10 @@ int msn_ExtractZipFile(char *zipfilename, char *mn3name) { int ret = zfile.ExtractFile(ze, output_filename); if (ret < 0) { if (ret == -9) { - mprintf(0, " Error writing to file\n"); + LOG_WARNING << " Error writing to file"; snprintf(buffer, sizeof(buffer), "\nError writing to file (Out of space?)"); } else { - mprintf(0, " Error %d extracting file\n", ret); + LOG_WARNING.printf(" Error %d extracting file", ret); snprintf(buffer, sizeof(buffer), "\nError %d extracting file", ret); } console.puts(GR_GREEN, buffer); @@ -800,7 +799,7 @@ int msn_ExtractZipFile(char *zipfilename, char *mn3name) { } } else { - mprintf(0, "Unsupported compression for file (%s)\n", ze->name); + LOG_WARNING.printf("Unsupported compression for file (%s)", ze->name); console.puts(GR_GREEN, "Unsupported compression!!"); } @@ -813,7 +812,7 @@ int msn_ExtractZipFile(char *zipfilename, char *mn3name) { if (DoMessageBox("Confirm", "Do you want to delete the zip file? It is no longer needed.", MSGBOX_YESNO, UICOL_WINDOW_TITLE, UICOL_TEXT_NORMAL)) { // delete the file - mprintf(0, "Deleting %s\n", zipfilename); + LOG_DEBUG.printf("Deleting %s", zipfilename); ddio_DeleteFile(zipfilename); } @@ -872,7 +871,7 @@ int CheckGetD3M(char *d3m) { strcat(modurl, fixedd3m); lowurl = mem_strdup(_strlwr(modurl)); - mprintf(0, "Downloading mod file from %s\n", modurl); + LOG_DEBUG.printf("Downloading mod file from %s", modurl); if (ModDownloadWithStatus(modurl, d3m)) { mem_free(fixedd3m); diff --git a/Descent3/multi.cpp b/Descent3/multi.cpp index fb43f030..25b39c87 100644 --- a/Descent3/multi.cpp +++ b/Descent3/multi.cpp @@ -1655,6 +1655,7 @@ #include "ddio.h" #include "init.h" #include "hud.h" +#include "log.h" #include "robotfire.h" #include "ship.h" #include "descent.h" @@ -1671,7 +1672,6 @@ #include "fireball.h" #include "Mission.h" #include "LoadLevel.h" -#include "init.h" #include "sounds.h" #include "weapon.h" #include "stringtable.h" @@ -1935,8 +1935,6 @@ int MultiStuffPosition(int slot, uint8_t *data) { vector *vel = &obj->mtype.phys_info.velocity; vector *rotvel = &obj->mtype.phys_info.rotvel; - // mprintf(0,"Outvel x=%f y=%f z=%f\n",vel->x,vel->y,vel->z); - MultiAddShort((vel->x * 128.0), data, &count); MultiAddShort((vel->y * 128.0), data, &count); MultiAddShort((vel->z * 128.0), data, &count); @@ -1965,7 +1963,8 @@ void DoNextPlayerFile(int playernum) { NetPlayers[playernum].custom_file_seq++; if (NetPlayers[playernum].custom_file_seq > NETFILE_ID_LAST_FILE) { NetPlayers[playernum].custom_file_seq = NETFILE_ID_DONE; - mprintf(0, "Setting %s's custom ship logo to %s\n", Players[playernum].callsign, NetPlayers[playernum].ship_logo); + LOG_INFO.printf("Setting %s's custom ship logo to %s", + Players[playernum].callsign, NetPlayers[playernum].ship_logo); PlayerSetCustomTexture(playernum, NetPlayers[playernum].ship_logo); // If we are the server, we need to tell everyone about this guy's custom data if ((Netgame.local_role == LR_SERVER) && (Use_file_xfer)) { @@ -1987,7 +1986,6 @@ int MultiStuffRobotPosition(uint16_t objectnum, uint8_t *data) { int count = 0; //@@multi_orientation mat; - // mprintf(0,"!");//KBTEST object *obj = &Objects[objectnum]; ASSERT(obj->flags & OF_CLIENT_KNOWS); @@ -2034,14 +2032,12 @@ int MultiSendRobotFireWeapon(uint16_t objectnum, vector *pos, vector *dir, uint1 int size; int count = 0; uint8_t data[MAX_GAME_DATA_SIZE]; - // mprintf(0,"Sending Robot %d fired.\n",objectnum); // Check to make sure we're the server if (Netgame.local_role != LR_SERVER) { BailOnMultiplayer(NULL); return 0; } - // mprintf(0,"@");//KBTEST object *obj = &Objects[objectnum]; ASSERT(obj->flags & OF_CLIENT_KNOWS); @@ -2092,7 +2088,6 @@ void MultiDoRobotFire(uint8_t *data) { return; } - // mprintf(0,"*"); SKIP_HEADER(data, &count); int serv_objnum = MultiGetUshort(data, &count); obj_num = Server_object_list[serv_objnum]; @@ -2262,7 +2257,6 @@ int MultiMatchPlayerToAddress(network_address *from_addr) { return i; } } - // mprintf(0,"Got a packet from unconnected player?!\n"); return -1; } @@ -2280,7 +2274,7 @@ void MultiDoMyInfo(uint8_t *data) { uint8_t slot = MultiGetByte(data, &count); if (!(NetPlayers[slot].flags & NPF_CONNECTED)) { - mprintf(1, "ERROR! We got a MY_INFO packet from a disconnected player!\n"); + LOG_FATAL << "ERROR! We got a MY_INFO packet from a disconnected player!"; Int3(); // Get Jason return; } @@ -2337,7 +2331,8 @@ void MultiDoMyInfo(uint8_t *data) { if (mt_sig != MASTER_TRACKER_SIG) { NetPlayers[slot].flags &= ~NPF_CONNECTED; - mprintf(0, "Invalid master tracker signature! Someone tried to join a master tracker game through the local net screen!\n"); + LOG_WARNING << "Invalid master tracker signature! " + << "Someone tried to join a master tracker game through the local net screen!"; } NetPlayers[slot].flags |= NPF_MT_READING_PILOT; len = MultiGetByte(data, &count); @@ -2353,7 +2348,7 @@ void MultiDoMyInfo(uint8_t *data) { int ser = 0; ser = MultiGetInt(data, &count); if (ser) { - mprintf(0, "Serialized user joining game: %d\n", ser); + LOG_INFO.printf("Serialized user joining game: %d", ser); } // Get packets per second for this player @@ -2388,7 +2383,7 @@ void MultiDoMyInfo(uint8_t *data) { NetPlayers[slot].sequence = NETSEQ_NEED_GAMETIME; - mprintf(0, "Got a myinfo packet from %s len=%d!\n", Players[slot].callsign, len); + LOG_DEBUG.printf("Got a myinfo packet from %s len=%d!", Players[slot].callsign, len); } // Tell a client about the players connected @@ -2401,7 +2396,7 @@ void MultiDoRequestPlayers(uint8_t *data) { uint8_t slot = MultiGetByte(data, &count); if (!(NetPlayers[slot].flags & NPF_CONNECTED)) { - mprintf(1, "ERROR! We got a MY_INFO packet from a disconnected player!\n"); + LOG_FATAL << "ERROR! We got a MY_INFO packet from a disconnected player!"; Int3(); // Get Jason return; } @@ -2419,7 +2414,7 @@ void MultiDoRequestBuildings(uint8_t *data) { uint8_t slot = MultiGetByte(data, &count); if (!(NetPlayers[slot].flags & NPF_CONNECTED)) { - mprintf(1, "ERROR! We got a request buildings packet from a disconnected player!\n"); + LOG_FATAL << "ERROR! We got a request buildings packet from a disconnected player!"; Int3(); // Get Jason return; } @@ -2437,7 +2432,7 @@ void MultiDoRequestObjects(uint8_t *data) { uint8_t slot = MultiGetByte(data, &count); if (!(NetPlayers[slot].flags & NPF_CONNECTED)) { - mprintf(1, "ERROR! We got a request object packet from a disconnected player!\n"); + LOG_FATAL << "ERROR! We got a request object packet from a disconnected player!"; Int3(); // Get Jason return; } @@ -2484,7 +2479,7 @@ void MultiDoRequestWorldStates(uint8_t *data) { } } if (!(NetPlayers[slot].flags & NPF_CONNECTED)) { - mprintf(1, "ERROR! We got a request world states packet from a disconnected player!\n"); + LOG_FATAL << "ERROR! We got a request world states packet from a disconnected player!"; Int3(); // Get Jason return; } @@ -2498,7 +2493,7 @@ void MultiDoPlayer(uint8_t *data) { int count = 0; char ship_name[PAGENAME_LEN]; - mprintf(0, "Got player packet!\n"); + LOG_DEBUG << "Got player packet!"; // Skip header stuff SKIP_HEADER(data, &count); @@ -2571,7 +2566,7 @@ void MultiDoPlayer(uint8_t *data) { memcpy(&NetPlayers[slot].addr, data + count, sizeof(network_address)); char dbg_output[50]; nw_GetNumbersFromHostAddress(&NetPlayers[slot].addr, dbg_output); - mprintf(0, "Got player address of: %s\n", dbg_output); + LOG_DEBUG.printf("Got player address of: %s", dbg_output); count += sizeof(network_address); @@ -2604,10 +2599,10 @@ void MultiDoPlayer(uint8_t *data) { if (slot != Player_num) { obj->shields = shields; if (Players[slot].flags & PLAYER_FLAGS_DEAD) { - mprintf(0, "Incoming %d player is dead!\n", slot); + LOG_DEBUG.printf("Incoming %d player is dead!", slot); MultiMakePlayerGhost(slot); } else if (Players[slot].flags & PLAYER_FLAGS_DYING) { - mprintf(0, "Incoming %d player is dying!\n", slot); + LOG_DEBUG.printf("Incoming %d player is dying!", slot); int save_flags = Players[slot].flags; Players[slot].flags &= ~(PLAYER_FLAGS_DEAD | PLAYER_FLAGS_DYING); InitiatePlayerDeath(&Objects[Players[slot].objnum], false, 0); @@ -2635,7 +2630,7 @@ void MultiDoPlayerEnteredGame(uint8_t *data) { char ship_name[PAGENAME_LEN]; int length; - mprintf(0, "Got player entered game packet!\n"); + LOG_DEBUG << "Got player entered game packet!"; // Skip header stuff SKIP_HEADER(data, &count); @@ -2802,7 +2797,7 @@ void MultiDoEnteringGame(uint8_t *data) { return; } - mprintf(0, "Client %d (%s) entering game.\n", slot, Players[slot].callsign); + LOG_DEBUG.printf("Client %d (%s) entering game.", slot, Players[slot].callsign); MultiSendPlayerEnteredGame(slot); @@ -2837,7 +2832,7 @@ void MultiSendEnteringGame() { uint8_t data[MAX_GAME_DATA_SIZE]; int count = 0; - mprintf(0, "Sending entering game\n"); + LOG_DEBUG << "Sending entering game"; size = START_DATA(MP_ENTERING_GAME, data, &count); MultiAddByte(Player_num, data, &count); @@ -2938,7 +2933,7 @@ void MultiDoDonePlayers(uint8_t *data) { uint8_t num = MultiGetByte(data, &count); if (MultiCountPlayers() != num) { - mprintf(1, "ERROR! We don't have the correct number of players!"); + LOG_FATAL << "ERROR! We don't have the correct number of players!"; Int3(); // Get Jason return; } @@ -3090,8 +3085,6 @@ void MultiDoPlayerPos(uint8_t *data) { vel.y = ((float)MultiGetShort(data, &count)) / 128.0; vel.z = ((float)MultiGetShort(data, &count)) / 128.0; - // mprintf(0,"INCOMING x=%f y=%f z=%f dist=%f\n",vel.x,vel.y,vel.z,dist); - // Get rotational velocity if (Netgame.flags & NF_SENDROTVEL) { rotvel.x = MultiGetShort(data, &count) * 4; @@ -3232,7 +3225,7 @@ void MultiDoRobotPos(uint8_t *data) { uint16_t server_objnum = MultiGetUshort(data, &count); uint16_t objectnum = Server_object_list[server_objnum]; if (objectnum == 65535 || !(Objects[objectnum].flags & OF_SERVER_OBJECT)) { - mprintf(0, "Bad robotposition object number!\n"); + LOG_WARNING << "Bad robotposition object number!"; return; } object *obj = &Objects[objectnum]; @@ -3373,7 +3366,7 @@ void MultiDoFirePlayerWB(uint8_t *data) { // Check to see if this player is firing a weapon he doesn't have player *playp = &Players[pnum]; if (!(playp->weapon_flags & (1 << wb_index))) { - mprintf(0, "Can't fire client weapon...flags=%d wb_index=%d\n", playp->weapon_flags, wb_index); + LOG_WARNING.printf("Can't fire client weapon...flags=%d wb_index=%d", playp->weapon_flags, wb_index); ok_to_fire = 0; } @@ -3414,7 +3407,7 @@ void MultiSendLeaveGame() { int count = 0; int size_offset; - mprintf(0, "Sending leave game!\n"); + LOG_DEBUG << "Sending leave game!"; if (Netgame.local_role == LR_SERVER) { size_offset = START_DATA(MP_SERVER_QUIT, data, &count, 1); @@ -3437,7 +3430,7 @@ void MultiSendLeaveGame() { // Called whenever I want to leave the game void MultiLeaveGame() { - mprintf(0, "I'm leaving the netgame!\n"); + LOG_DEBUG << "I'm leaving the netgame!"; CallGameDLL(EVT_GAME_DISCONNECTED, &DLLInfo); @@ -3485,7 +3478,7 @@ void MultiSendReleaseTimeoutMissile() { ASSERT(Players[Player_num].user_timeout_obj != NULL); - mprintf(0, "Sending timeout weapon packet!\n"); + LOG_DEBUG << "Sending timeout weapon packet!"; size_offset = START_DATA(MP_TIMEOUT_WEAPON, data, &count); MultiAddByte(Player_num, data, &count); @@ -3564,7 +3557,7 @@ void MultiDoLevelEnded(uint8_t *data) { if (Multi_next_level < 1 || Multi_next_level > Current_mission.num_levels) Multi_next_level = -1; - mprintf(0, "Doing level ended! Next level=%d\n", Multi_next_level); + LOG_DEBUG.printf("Doing level ended! Next level=%d", Multi_next_level); if (success) SetGameState(GAMESTATE_LVLEND); @@ -3588,7 +3581,7 @@ void MultiSendLevelEnded(int success, int next_level) { int count = 0; int size_offset; - mprintf(0, "Sending level ended!\n"); + LOG_DEBUG << "Sending level ended!"; size_offset = START_DATA(MP_LEVEL_ENDED, data, &count, 1); MultiAddByte(success, data, &count); @@ -3626,7 +3619,7 @@ extern void MultiClearPlayerMarkers(int slot); void MultiDoLeaveGame(uint8_t *data) { int count = 0; - mprintf(0, "In MultiDoLeaveGame!\n"); + LOG_DEBUG << "In MultiDoLeaveGame!"; // Skip header stuff SKIP_HEADER(data, &count); @@ -3642,7 +3635,7 @@ void MultiDoLeaveGame(uint8_t *data) { NetPlayers[slot].flags &= ~NPF_CONNECTED; NetPlayers[slot].secret_net_id = 0; } else - mprintf(0, "Got a leave game from a non-connected player!\n"); + LOG_DEBUG << "Got a leave game from a non-connected player!"; // Now clear any files this guy might be receiving if (NetPlayers[slot].file_xfer_flags != NETFILE_NONE) { @@ -3699,7 +3692,7 @@ void MultiDoServerQuit(uint8_t *data) { NetPlayers[i].custom_file_seq = NETFILE_ID_NOFILE; } } - mprintf(0, "Server quitting!\n"); + LOG_DEBUG << "Server quitting!"; MultiLeaveGame(); D3::ChronoTimer::SleepMS(2000); } @@ -3733,7 +3726,7 @@ void MultiDoDisconnect(uint8_t *data) { NetPlayers[slot].flags &= ~NPF_CONNECTED; NetPlayers[slot].secret_net_id = 0; } else - mprintf(0, "Got a disconnect from a non-connected player!\n"); + LOG_DEBUG << "Got a disconnect from a non-connected player!"; ScoreAPIPlayerLeft(slot); } @@ -3797,7 +3790,7 @@ void MultiDoAskToJoin(uint8_t *data, network_address *from_addr) { MULTI_ASSERT(slot > 0, "FindFreeSlot returned -1!"); if (Players[slot].start_roomnum != -1) { - mprintf(0, "Sending OK to join!\n"); + LOG_DEBUG << "Sending OK to join!"; MultiAddByte(JOIN_ANSWER_OK, outdata, &count); } else { MultiAddByte(JOIN_ANSWER_NO_ROOM, outdata, &count); @@ -3822,7 +3815,6 @@ void MultiDoGetGameInfo(uint8_t *data, network_address *from_addr) { network_address my_addr; float ping_time; - // mprintf(0,"Got a request for knowledge about my game!\n"); // Get the time and stuff it back in the packet SKIP_HEADER(data, &count); @@ -3909,7 +3901,6 @@ void MultiDoGetPXOGameInfo(uint8_t *data, network_address *from_addr) { float ping_time; network_address my_addr; - // mprintf(0,"Got a request for knowledge about my game!\n"); if (!Game_is_master_tracker_game) { return; @@ -4009,7 +4000,6 @@ void MultiDoGameInfo(uint8_t *data, network_address *from_addr) { if (Num_network_games_known >= MAX_NETWORK_GAMES) return; - // mprintf(0,"Got game info packet!!\n"); SKIP_HEADER(data, &count); @@ -4092,7 +4082,6 @@ void MultiDoGameInfo(uint8_t *data, network_address *from_addr) { Network_games[n].difficulty = diff; // This handle is used to make the game list update nicely Network_games[n].handle = Netgame_curr_handle++; - // mprintf(0,"Got new game called %s!\n",name); Num_network_games_known++; @@ -4160,7 +4149,7 @@ void MultiDoBuilding(uint8_t *data) { for (int i = 0; i < num; i++) { uint16_t objnum = MultiGetUshort(data, &count); if (Objects[objnum].type != OBJ_BUILDING) { - mprintf(0, "Error! Server says objnum %d is a building and it is not!\n", objnum); + LOG_WARNING.printf("Error! Server says objnum %d is a building and it is not!", objnum); } else { Multi_building_states[objnum] = 1; @@ -4188,7 +4177,7 @@ void MultiDoWorldStates(uint8_t *data) { SKIP_HEADER(data, &count); - mprintf(0, "Got a world state packet!\n"); + LOG_DEBUG << "Got a world state packet!"; while ((world_type = MultiGetByte(data, &count)) != WS_END) { switch (world_type) { @@ -4200,7 +4189,7 @@ void MultiDoWorldStates(uint8_t *data) { Rooms[roomnum].wind.y = MultiGetFloat(data, &count); Rooms[roomnum].wind.z = MultiGetFloat(data, &count); - mprintf(0, "Got room wind packet! Room=%d wind=%f %f %f\n", + LOG_DEBUG.printf("Got room wind packet! Room=%d wind=%f %f %f", roomnum, Rooms[roomnum].wind.x, Rooms[roomnum].wind.y, @@ -4417,7 +4406,7 @@ void MultiDoWorldStates(uint8_t *data) { int flags = MultiGetInt(data, &count); int temp = 0xFFFFFFFF; - mprintf(0, "Recieved Level Goal World State: %d\n", goal_index); + LOG_DEBUG.printf("Received Level Goal World State: %d", goal_index); Level_goals.GoalSetName(goal_index, name); Level_goals.GoalStatus(goal_index, LO_CLEAR_SPECIFIED, &temp); Level_goals.GoalStatus(goal_index, LO_SET_SPECIFIED, &flags, false); @@ -4427,7 +4416,7 @@ void MultiDoWorldStates(uint8_t *data) { } case WS_SPEW: { spewinfo spew; - mprintf(0, "Got a spew packet!\n"); + LOG_DEBUG << "Got a spew packet!"; uint16_t spewnum = MultiGetShort(data, &count); @@ -4476,7 +4465,7 @@ void MultiDoWorldStates(uint8_t *data) { ASSERT(local_spewnum != -1); // DAJ -1FIX local_spewnum &= 0xFF; // Adjust for handle Server_spew_list[spewnum] = local_spewnum; - mprintf(0, "Got spew of type %d. Server=%d local=%d\n", spew.effect_type, spewnum, local_spewnum); + LOG_DEBUG.printf("Got spew of type %d. Server=%d local=%d", spew.effect_type, spewnum, local_spewnum); break; } @@ -4549,7 +4538,7 @@ void MultiDoJoinDemoObjects(uint8_t *data) { int local_objnum; Multi_Expect_demo_object_flags = true; - mprintf(0, "Processing DoJoinDemoObjects...\n"); + LOG_DEBUG << "Processing DoJoinDemoObjects..."; for (int i = 0; i < num_demo_objects; i++) { objnum = MultiGetUshort(data, &count); @@ -4572,7 +4561,7 @@ void MultiDoJoinObjects(uint8_t *data) { SKIP_HEADER(data, &count); uint8_t num_objects = MultiGetByte(data, &count); - mprintf(0, "Got join object packet. Num objects=%d\n", num_objects); + LOG_DEBUG.printf("Got join object packet. Num objects=%d", num_objects); for (int i = 0; i < num_objects; i++) { bool obj_is_dummy = false; @@ -4581,8 +4570,6 @@ void MultiDoJoinObjects(uint8_t *data) { uint16_t server_objnum = MultiGetUshort(data, &count); uint8_t type = MultiGetByte(data, &count); - //@@mprintf(0,"Got join objnum %d from server. Type=%d\n",server_objnum,type); - if (type == OBJ_DUMMY) { obj_is_dummy = true; type = MultiGetByte(data, &count); @@ -4616,7 +4603,7 @@ void MultiDoJoinObjects(uint8_t *data) { id = MultiMatchGeneric(checksum); if (id == -1) { - mprintf(0, "Server data doesn't match client data!\n"); + LOG_ERROR << "Server data doesn't match client data!"; ASSERT(1); // Error ("Server data doesn't match client data!"); MultiMatchGeneric(checksum); @@ -4734,9 +4721,8 @@ void MultiSendPlayerDead(int slot, uint8_t fate) { MultiSendReliablyToAllExcept(Player_num, data, count, NETSEQ_PLAYERS); MultiDoPlayerDead(data); if (Game_is_master_tracker_game) { - mprintf(0, "Adding kill and death to player stats. Killer = %d Killee = %d\n", - Objects[Players[slot].killer_objnum].id, - slot); + LOG_DEBUG.printf("Adding kill and death to player stats. Killer = %d Killee = %d", + Objects[Players[slot].killer_objnum].id, slot); if (Objects[Players[slot].killer_objnum].id == slot) { Players[slot].suicides++; } else { @@ -4776,7 +4762,7 @@ void MultiDoRenewPlayer(uint8_t *data) { // add guidebot if needed if (add_guidebot) { - mprintf(0, "MULTI: Adding guidebot to respawned player (%s)\n", Players[slot].callsign); + LOG_DEBUG.printf("MULTI: Adding guidebot to respawned player (%s)", Players[slot].callsign); if (!Players[slot].inventory.CheckItem(OBJ_ROBOT, ROBOT_GUIDEBOT)) Players[slot].inventory.Add(OBJ_ROBOT, ROBOT_GUIDEBOT); } @@ -4843,7 +4829,7 @@ void GetServerGameTime() { uint8_t outdata[MAX_GAME_DATA_SIZE]; int count = 0; int size; - mprintf(0, "Requesting gametime from server\n"); + LOG_DEBUG << "Requesting gametime from server"; Got_new_game_time = 0; size = START_DATA(MP_GET_GAMETIME, outdata, &count); MultiAddFloat(timer_GetTime(), outdata, &count); @@ -4857,7 +4843,7 @@ void MultiDoGameTimeReq(uint8_t *data, network_address *from_addr) { int size; MULTI_ASSERT_NOMESSAGE(Netgame.local_role == LR_SERVER); - mprintf(0, "Processing request for gametime\n"); + LOG_DEBUG << "Processing request for gametime"; SKIP_HEADER(data, &incount); float client_time = MultiGetFloat(data, &incount); @@ -4875,7 +4861,7 @@ void MultiDoSetGameTime(uint8_t *data) { float server_latency; float server_game_time; int count = 0; - mprintf(0, "Processing and setting new for gametime\n"); + LOG_DEBUG << "Processing and setting new for gametime"; MULTI_ASSERT_NOMESSAGE(Netgame.local_role != LR_SERVER); // Now get the latency. We calculate this by comparing the current timer to the time we got back // Which was the time that we sent the request. @@ -4885,10 +4871,10 @@ void MultiDoSetGameTime(uint8_t *data) { // Half of the ping time is the latency server_latency = (timer_GetTime() - req_time) / 2; - mprintf(0, "Server Latency = %f\n", server_latency); + LOG_DEBUG.printf("Server Latency = %f", server_latency); Gametime = (server_game_time + server_latency); - mprintf(0, "New gametime = %f\n", Gametime); + LOG_DEBUG.printf("New gametime = %f", Gametime); Got_new_game_time = 1; } @@ -4898,7 +4884,7 @@ void MultiSendEndPlayerDeath() { uint8_t data[MAX_GAME_DATA_SIZE]; int size_offset; - mprintf(0, "Sending end player death packet!\n"); + LOG_DEBUG << "Sending end player death packet!"; size_offset = START_DATA(MP_END_PLAYER_DEATH, data, &count); @@ -5102,7 +5088,7 @@ void MultiDoExecuteDLL(uint8_t *data) { else { local_me_objnum = Server_object_list[me_objnum]; if (local_me_objnum == 65535) { - mprintf(0, "Invalid object in DoExecuteDLL!\n"); + LOG_FATAL << "Invalid object in DoExecuteDLL"; Int3(); return; } @@ -5113,15 +5099,12 @@ void MultiDoExecuteDLL(uint8_t *data) { else { local_it_objnum = Server_object_list[it_objnum]; if (local_it_objnum == 65535) { - mprintf(0, "Invalid object in DoExecuteDLL!\n"); + LOG_FATAL << "Invalid object in DoExecuteDLL!"; Int3(); return; } } - // mprintf(0,"Received MP_EXECUTE_DLL packet! type=%d - // id=%d\n",Objects[local_me_objnum].type,Objects[local_me_objnum].id); - int mehandle; int ithandle; @@ -5158,11 +5141,7 @@ void MultiDoObject(uint8_t *data) { if (parent_objnum == server_objnum) self_parent = true; -/* - mprintf(0,"MultiDoObject() got a new object. Server's objnum = %d Parent objnum = %d\n", - server_objnum, - parent_objnum); - */ + if (self_parent || parent_objnum == 65535) parent_handle = OBJECT_HANDLE_NONE; else { @@ -5196,7 +5175,7 @@ void MultiDoObject(uint8_t *data) { id = MultiMatchGeneric(checksum); if (id == -1) { - mprintf(0, "Server data doesn't match!\n"); + LOG_ERROR << "Server data doesn't match!"; MULTI_ASSERT(id != -1, "Server data doesn't match!"); if (type == OBJ_WEAPON) @@ -5261,7 +5240,7 @@ void MultiDoObject(uint8_t *data) { } if (local_objnum < 0) { - mprintf(0, "Ran out of objects!\n"); + LOG_FATAL << "Ran out of objects!"; Int3(); // Get Jason return; } @@ -5321,12 +5300,10 @@ void MultiDoObject(uint8_t *data) { obj->flags |= OF_CLIENTDEMOOBJECT; if (Demo_flags == DF_RECORDING) { - mprintf(0, "Recording object created on server\n"); + LOG_DEBUG << "Recording object created on server"; // DemoWriteObjCreate(obj->type,obj->id,obj->roomnum,&obj->pos,&obj->orient,obj->parent_handle,obj); } } - - // mprintf(0,"MultiDoObject() Local objnum = %d\n",Server_object_list[server_objnum]); } // Sends an object from the server to the client @@ -5343,8 +5320,6 @@ void MultiSendObject(object *obj, uint8_t announce, uint8_t demo_record) { if (demo_record) obj->flags |= OF_CLIENTDEMOOBJECT; - // mprintf(0,"Telling clients to CREATE object %d type=%d\n",obj-Objects,obj->type); - object *parent_obj = ObjGetUltimateParent(obj); size_offset = START_DATA(MP_OBJECT, data, &count, 1); @@ -5425,7 +5400,6 @@ void MultiSendObject(object *obj, uint8_t announce, uint8_t demo_record) { MultiAnnounceEffect(obj, obj->size * 3, .7f); } - // mprintf(0,"Sending object %d to clients.\n",OBJNUM(obj)); MultiSendReliablyToAllExcept(Player_num, data, count, NETSEQ_OBJECTS, true); } @@ -5544,7 +5518,7 @@ void MultiDoMissileRelease(int slot, uint8_t *data) { if (Netgame.local_role == LR_SERVER) { // verify that slot and player match up if (pnum_release != slot) { - mprintf(0, "%s Release: Packet pnum does not match real pnum\n", (is_guided) ? "Guided" : "Timeout"); + LOG_DEBUG.printf("%s Release: Packet pnum does not match real pnum", (is_guided) ? "Guided" : "Timeout"); return; } @@ -5559,7 +5533,7 @@ void MultiDoMissileRelease(int slot, uint8_t *data) { } else { // make sure we got this packet from the server if (slot != 0) { - mprintf(0, "%s Release: got packet from non-server!?!\n", (is_guided) ? "Guided" : "Timeout"); + LOG_WARNING.printf("%s Release: got packet from non-server!?!", (is_guided) ? "Guided" : "Timeout"); return; } @@ -5692,33 +5666,25 @@ void MultiDoRemoveObject(uint8_t *data) { count+=len; #endif*/ - // mprintf(0,"Server says to remove object %d\n",server_objnum); - int local_objnum = Server_object_list[server_objnum]; if (local_objnum == 65535) { - mprintf(0, "Client/Server object lists don't match. Something is wrong!\n"); + LOG_WARNING << "Client/Server object lists don't match. Something is wrong!"; // Error ("Bad object 1"); return; } if (!(Objects[local_objnum].flags & OF_SERVER_OBJECT)) { - mprintf(0, "Client/Server object lists don't match. Something is wrong!\n"); + LOG_FATAL << "Client/Server object lists don't match. Something is wrong!"; ASSERT(1); Objects[local_objnum].flags |= OF_SERVER_OBJECT; } -/* - if (Objects[local_objnum].type != type) { - mprintf(0, "Client/Server object types don't match. Something is wrong!\n"); - // mprintf (0,"Object to be removed was type %d, I thought it was %d name: - // %s\n",type,Objects[local_objnum].type,name)); Error ("Bad object 2"); ASSERT (1); return; - } -*/ + if (sound) Sound_system.Play3dSound(SOUND_POWERUP_PICKUP, &Objects[local_objnum]); if (Objects[local_objnum].flags & OF_CLIENTDEMOOBJECT) { if (Demo_flags == DF_RECORDING) { - mprintf(0, "Recording object deleted on server\n"); + LOG_DEBUG << "Recording object deleted on server"; DemoWriteSetObjDead(&Objects[local_objnum]); } } @@ -5750,9 +5716,6 @@ void MultiSendRemoveObject(object *obj, uint8_t playsound) { size_offset = START_DATA(MP_REMOVE_OBJECT, data, &count, 1); - // mprintf(0,"Telling clients to remove object %d type=%d - // name=%s\n",obj-Objects,obj->type,Object_info[obj->id].name); - ASSERT(obj->flags & OF_CLIENT_KNOWS); MultiAddUshort(obj - Objects, data, &count); @@ -5938,7 +5901,7 @@ void MultiSendAdditionalDamage(int slot, int type, float amount) { END_DATA(count, data, size_offset); - mprintf(0, "Sending additional damage packet of type=%d amount=%f!\n", type, amount); + LOG_DEBUG.printf("Sending additional damage packet of type=%d amount=%f!", type, amount); MultiSendReliablyToAllExcept(Player_num, data, count, NETSEQ_PLAYING, false); } @@ -5949,8 +5912,6 @@ void MultiDoAdditionalDamage(uint8_t *data) { MULTI_ASSERT_NOMESSAGE(Netgame.local_role == LR_CLIENT); - // mprintf(0,"Got additional damage packet!\n"); - SKIP_HEADER(data, &count); uint8_t slot = MultiGetByte(data, &count); @@ -6058,7 +6019,7 @@ void MultiDoRequestDamage(uint8_t *data) { void MultiDoRequestCountermeasure(uint8_t *data) { int count = 0; - mprintf(0, "Got request for countermeasure!\n"); + LOG_DEBUG << "Got request for countermeasure!"; SKIP_HEADER(data, &count); @@ -6074,7 +6035,7 @@ void MultiDoRequestCountermeasure(uint8_t *data) { int id = MultiMatchWeapon(checksum); if (id == -1) { - mprintf(0, "Server data doesn't match!\n"); + LOG_FATAL << "Server data doesn't match!"; Int3(); MultiMatchWeapon(checksum); @@ -6109,7 +6070,7 @@ void MultiSendRequestCountermeasure(int16_t objnum, int weapon_index) { else MultiDoRequestCountermeasure(data); - mprintf(0, "Sending out request for countermeasure!\n"); + LOG_DEBUG << "Sending out request for countermeasure!"; } // Server is telling us about a player who is changing his observer mode @@ -6149,7 +6110,7 @@ void MultiDoRequestToObserve(uint8_t *data) { int count = 0; int objnum; - mprintf(0, "Got request to observe!\n"); + LOG_DEBUG << "Got request to observe!"; MULTI_ASSERT_NOMESSAGE(Netgame.local_role == LR_SERVER); @@ -6316,7 +6277,7 @@ void MultiSendRequestPeerDamage(object *killer, int weapon_id, int damage_type, if (Netgame.local_role == LR_SERVER) return; - mprintf(0, "Sending request peer damage of %f\n", amount); + LOG_DEBUG.printf("Sending request peer damage of %f", amount); size = START_DATA(MP_REQUEST_PEER_DAMAGE, data, &count); MultiAddByte(Player_num, data, &count); @@ -6347,7 +6308,7 @@ void MultiMassageAllObjects(int kill_powerups, int kill_robots) { Num_powerup_timer = 0; Num_client_lm_objects = 0; Num_server_lm_objects = 0; - mprintf(0, "Massaging all objects!\n"); + LOG_DEBUG << "Massaging all objects!"; for (i = 0; i <= Highest_object_index; i++) { // If client, delete all robots and powerups @@ -6520,7 +6481,6 @@ void MultiSendFullReliablePacket(int slot, int flags) { // We're sending to the server if (slot == SERVER_PLAYER) { - // mprintf(0,"Sending full packet of size %d to slot%d!\n",Multi_cur_send_size,slot); nw_SendReliable(NetPlayers[Player_num].reliable_socket, Multi_reliable_send_buffer[Player_num], Multi_reliable_send_size[Player_num], false); Multi_reliable_send_size[Player_num] = 0; @@ -6632,7 +6592,7 @@ int MultiMatchWeapon(uint32_t unique_id) { void MultiBuildMatchTables() { int i; - mprintf(0, "Building match tables for multiplayer.\n"); + LOG_DEBUG << "Building match tables for multiplayer."; memset(Multi_generic_match_table, 0, MAX_OBJECT_IDS * sizeof(int)); memset(Multi_weapon_match_table, 0, MAX_WEAPONS * sizeof(int)); @@ -6646,7 +6606,7 @@ void MultiBuildMatchTables() { // See if there is a hash collision. If so, increment the value and retry while ((MultiMatchGeneric(val)) != -1) { - mprintf(0, "Match collision!\n"); + LOG_FATAL << "Match collision!"; Int3(); val++; } @@ -6663,7 +6623,7 @@ void MultiBuildMatchTables() { // See if there is a hash collision. If so, increment the value and retry while ((MultiMatchWeapon(val)) != -1) { - mprintf(0, "Match collision!\n"); + LOG_FATAL << "Match collision!"; Int3(); val++; } @@ -6730,7 +6690,6 @@ void MultiSendKillObject(object *hit_obj, object *killer, float damage, int deat uint8_t data[MAX_GAME_DATA_SIZE]; uint16_t hit_objnum, killer_objnum; - // mprintf(0,"MultiSendExplodeObject Hit obj:%d Killer Obj: %d\n",OBJNUM(hit_obj),OBJNUM(killer)); MULTI_ASSERT_NOMESSAGE(Netgame.local_role == LR_SERVER); ASSERT(hit_obj->flags & OF_CLIENT_KNOWS); @@ -6768,7 +6727,7 @@ void MultiDoRobotExplode(uint8_t *data) { hit_objnum = Server_object_list[MultiGetUshort(data, &count)]; if (hit_objnum == 65535) { - mprintf(0, "Bad hit_objnum(%d) MultiDoRobotExplode\n", hit_objnum); + LOG_FATAL.printf("Bad hit_objnum(%d) MultiDoRobotExplode", hit_objnum); ASSERT(1); return; } @@ -6779,7 +6738,7 @@ void MultiDoRobotExplode(uint8_t *data) { killer_objnum = Server_object_list[killer_objnum]; if (killer_objnum == 65535) { - mprintf(0, "Bad killer_objnum(%d) in MultiDoRobotExplode()\n", killer_objnum); + LOG_WARNING.printf("Bad killer_objnum(%d) in MultiDoRobotExplode()", killer_objnum); } } @@ -6808,10 +6767,8 @@ void MultiSendDamageObject(object *hit_obj, object *killer, float damage, int we uint8_t data[MAX_GAME_DATA_SIZE]; uint16_t hit_objnum, killer_objnum; - // mprintf(0,"MultiSendDamageObject Hit obj:%d Killer Obj: %d\n",OBJNUM(hit_obj),OBJNUM(killer)); MULTI_ASSERT_NOMESSAGE(Netgame.local_role == LR_SERVER); ASSERT(hit_obj->flags & OF_CLIENT_KNOWS); - // mprintf(0,"$");//KBTEST size = START_DATA(MP_ROBOT_DAMAGE, data, &count, 1); // Get the dying objnum hit_objnum = OBJNUM(hit_obj); @@ -6839,8 +6796,7 @@ void MultiDoRobotDamage(uint8_t *data) { if (hit_objnum == 65535 || killer_objnum == 65535 || !(Objects[hit_objnum].flags & OF_SERVER_OBJECT) || !(Objects[killer_objnum].flags & OF_SERVER_OBJECT)) { - mprintf(0, "Bad hit_objnum(%d) or killer_objnum(%d) in MultiDoRobotDamage()\n", hit_objnum, killer_objnum); - // Int3(); // Get Jason, bad object number + LOG_WARNING.printf("Bad hit_objnum(%d) or killer_objnum(%d) in MultiDoRobotDamage()", hit_objnum, killer_objnum); return; } @@ -6858,7 +6814,6 @@ void MultiDoRobotDamage(uint8_t *data) { void MultiAddObjAnimUpdate(int objnum) { MULTI_ASSERT_NOMESSAGE(Netgame.local_role == LR_SERVER); ASSERT(Objects[objnum].flags & OF_CLIENT_KNOWS); - // mprintf(0,"D`"); for (int i = 0; i < MAX_NET_PLAYERS; i++) { if (i == Player_num) continue; @@ -6892,7 +6847,6 @@ int MultiStuffObjAnimUpdate(uint16_t objnum, uint8_t *data) { return 0; } - // mprintf(0,"MultiStuffObjAnimUpdate Sending object %d\n",objnum); if (ObjGetAnimUpdate(objnum, &multi_anim_info)) // Checks if obj is still alive and all { ASSERT(Objects[objnum].flags & OF_CLIENT_KNOWS); @@ -6917,7 +6871,6 @@ void MultiDoObjAnimUpdate(uint8_t *data) { int objnum; int count = 0; MULTI_ASSERT_NOMESSAGE(Netgame.local_role != LR_SERVER); - // mprintf(0,"R`"); SKIP_HEADER(data, &count); int serverobjnum = MultiGetUshort(data, &count); objnum = Server_object_list[serverobjnum]; @@ -6931,8 +6884,7 @@ void MultiDoObjAnimUpdate(uint8_t *data) { multi_anim_info.anim_sound_index = MultiGetShort(data, &count); if (objnum == 65535) { - mprintf(0, "bad objnum in MultiDoObjAnimUpdate() server=%d\n", serverobjnum); - // Int3(); // Get Jason, bad object number + LOG_WARNING.printf("bad objnum in MultiDoObjAnimUpdate() server=%d", serverobjnum); return; } @@ -6955,8 +6907,7 @@ void MultiDoPlay3dSound(uint8_t *data) { uint8_t priority = MultiGetByte(data, &count); if (objnum == 65535 || !(Objects[objnum].flags & OF_SERVER_OBJECT)) { - mprintf(0, "Bad server objnum(%d) in MultiDoPlay3dSound().\n", serverobjnum); - // Int3(); // Get Jason, bad object number + LOG_WARNING.printf("Bad server objnum(%d) in MultiDoPlay3dSound().", serverobjnum); return; } @@ -6969,7 +6920,6 @@ void MultiPlay3dSound(int16_t soundidx, uint16_t objnum, int priority) { int size = 0; MULTI_ASSERT_NOMESSAGE(Netgame.local_role == LR_SERVER); ASSERT(Objects[objnum].flags & OF_CLIENT_KNOWS); - // mprintf(0,"^");//KBTEST size = START_DATA(MP_PLAY_3D_SOUND_FROM_OBJ, data, &count); MultiAddUshort(objnum, data, &count); MultiAddShort(soundidx, data, &count); @@ -6996,9 +6946,7 @@ void MultiSendRobotFireSound(int16_t soundidx, uint16_t objnum) { int size; int count = 0; uint8_t data[MAX_GAME_DATA_SIZE]; - // mprintf(0,"&");//KBTEST MULTI_ASSERT_NOMESSAGE(Netgame.local_role == LR_SERVER); - // mprintf(0,"Sending Robot %d fire sound.\n",objnum); object *obj = &Objects[objnum]; ASSERT(obj->flags & OF_CLIENT_KNOWS); @@ -7038,8 +6986,7 @@ void MultiDoRobotFireSound(uint8_t *data) { soundidx = MultiGetShort(data, &count); if (objnum == 65535 || !(Objects[objnum].flags & OF_SERVER_OBJECT)) { - mprintf(0, "Bad server objnum(%d) in MultiDoRobotFireSound().Objnum = %d\n", serverobjnum, objnum); - // Int3(); // Get Jason, bad object number + LOG_WARNING.printf("Bad server objnum(%d) in MultiDoRobotFireSound().Objnum = %d", serverobjnum, objnum); return; } Sound_system.Play3dSound(soundidx, &Objects[objnum]); @@ -7077,7 +7024,6 @@ int MultiStuffTurretUpdate(uint16_t objnum, uint8_t *data) { int count = 0; int size = 0; multi_turret multi_turret_info; - // mprintf(0,"MultiStuffTurretUpdate Sending object %d\n",objnum); if (Netgame.local_role != LR_SERVER) { BailOnMultiplayer(NULL); return 0; @@ -7123,8 +7069,7 @@ void MultiDoTurretUpdate(uint8_t *data) { objnum = Server_object_list[serverobjnum]; if (objnum == 65535 || !(Objects[objnum].flags & OF_SERVER_OBJECT)) { - mprintf(0, "Bad server objnum(%d) in MultiDoTurretUpdate().\n", serverobjnum); - // Int3(); // Get Jason , bad object number + LOG_WARNING.printf("Bad server objnum(%d) in MultiDoTurretUpdate().", serverobjnum); return; } @@ -7144,9 +7089,9 @@ void MultiDoTurretUpdate(uint8_t *data) { void MultiSendClientInventoryUseItem(int type, int id) { if (id == -1) { - mprintf(0, "Asking server to use objnum %d\n", OBJNUM(ObjGet(type))); + LOG_DEBUG.printf("Asking server to use objnum %d", OBJNUM(ObjGet(type))); } else { - mprintf(0, "Asking server to use T=%d ID=%d\n", type, id); + LOG_DEBUG.printf("Asking server to use T=%d ID=%d", type, id); } int size = 0; @@ -7174,7 +7119,7 @@ void MultiSendClientInventoryUseItem(int type, int id) { int server_objnum = Local_object_list[OBJNUM(local_obj)]; ASSERT(server_objnum != 65535); - mprintf(0, "Inven Use: Requesting to use server objnum %d. T=%d i=%d\n", + LOG_DEBUG.printf("Inven Use: Requesting to use server objnum %d. T=%d i=%d", server_objnum, local_obj->type, local_obj->id); @@ -7208,13 +7153,13 @@ void MultiDoClientInventoryUseItem(int slot, uint8_t *data) { int server_objnum; server_objnum = type; - mprintf(0, "Inven: use request objnum %d\n", server_objnum); + LOG_DEBUG.printf("Inven: use request objnum %d", server_objnum); // the objnum coming in better be in our object list ASSERT(server_objnum >= 0 && server_objnum < MAX_OBJECTS); ASSERT(Objects[server_objnum].type != OBJ_NONE); - mprintf(0, "Client is asking me to use objnum %d\n", server_objnum); + LOG_DEBUG.printf("Client is asking me to use objnum %d", server_objnum); // convert type to objhandle type = Objects[server_objnum].handle; @@ -7228,25 +7173,25 @@ void MultiDoClientInventoryUseItem(int slot, uint8_t *data) { id = MultiMatchGeneric(hash); } - mprintf(0, "Client is asking me to use T=%d ID=%d\n", type, id); + LOG_DEBUG.printf("Client is asking me to use T=%d ID=%d", type, id); } if (is_counter_measure) { if (Players[slot].counter_measures.FindPos(type, id)) { - mprintf(0, "I found it, so I'm going to use it\n"); + LOG_DEBUG << "I found it, so I'm going to use it"; if (Players[slot].counter_measures.UsePos(&Objects[Players[slot].objnum])) { // Tell clients to remove this item MultiSendInventoryRemoveItem(slot, type, id); } } else { - mprintf(0, "But I couldn't find it in my copy of his inventory\n"); + LOG_DEBUG << "But I couldn't find it in my copy of his inventory"; } } else { if (Players[slot].inventory.FindPos(type, id)) { if (id == -1) { - mprintf(0, "I found it, so I'm going to use it, type=%d id=%d\n", type, id); + LOG_DEBUG.printf("I found it, so I'm going to use it, type=%d id=%d", type, id); } else { - mprintf(0, "I found it, so I'm going to use it, handle=0x%x id=%d\n", type, id); + LOG_DEBUG.printf("I found it, so I'm going to use it, handle=0x%x id=%d", type, id); } if (Players[slot].inventory.UsePos(&Objects[Players[slot].objnum])) { @@ -7254,7 +7199,7 @@ void MultiDoClientInventoryUseItem(int slot, uint8_t *data) { MultiSendInventoryRemoveItem(slot, type, id); } } else { - mprintf(0, "But I couldn't find it in my copy of his inventory\n"); + LOG_DEBUG << "But I couldn't find it in my copy of his inventory"; } } } @@ -7286,7 +7231,7 @@ void MultiDoClientInventoryRemoveItem(int slot, uint8_t *data) { ASSERT(type >= 0 && type < MAX_OBJECTS); ASSERT(Objects[type].type != OBJ_NONE); - mprintf(0, "Server is telling me to remove objnum %d\n", type); + LOG_DEBUG.printf("Server is telling me to remove objnum %d", type); // convert type to objhandle type = Objects[type].handle; @@ -7297,11 +7242,11 @@ void MultiDoClientInventoryRemoveItem(int slot, uint8_t *data) { if (type == OBJ_WEAPON) { id = MultiMatchWeapon(hash); - mprintf(0, "Server is telling me to remove T=%d ID=%d from %d\n", type, id, pnum); + LOG_DEBUG.printf("Server is telling me to remove T=%d ID=%d from %d", type, id, pnum); Players[pnum].counter_measures.Remove(type, id); } else { id = MultiMatchGeneric(hash); - mprintf(0, "Server is telling me to remove T=%d ID=%d from %d\n", type, id, pnum); + LOG_DEBUG.printf("Server is telling me to remove T=%d ID=%d from %d", type, id, pnum); Players[pnum].inventory.Remove(type, id); } } @@ -7310,9 +7255,9 @@ void MultiDoClientInventoryRemoveItem(int slot, uint8_t *data) { // Tell the clients to remove an item from a player's inventory void MultiSendInventoryRemoveItem(int slot, int type, int id) { if (id == -1) { - mprintf(0, "Telling clients to remove objnum %d from %d\n", OBJNUM(ObjGet(type)), slot); + LOG_DEBUG.printf("Telling clients to remove objnum %d from %d", OBJNUM(ObjGet(type)), slot); } else { - mprintf(0, "Telling clients to remove inven item T=%d ID=%d from %d\n", type, id, slot); + LOG_DEBUG.printf("Telling clients to remove inven item T=%d ID=%d from %d", type, id, slot); } int size = 0; @@ -7383,7 +7328,6 @@ void MultiDoAudioTauntTime(uint8_t *data) { void MultiAddObjWBAnimUpdate(int objnum) { MULTI_ASSERT_NOMESSAGE(Netgame.local_role == LR_SERVER); ASSERT(Objects[objnum].flags & OF_CLIENT_KNOWS); - // mprintf(0,"D`"); for (int i = 0; i < MAX_NET_PLAYERS; i++) { if (i == Player_num) continue; @@ -7418,7 +7362,6 @@ int MultiStuffObjWBAnimUpdate(uint16_t objnum, uint8_t *data) { } ASSERT(Objects[objnum].flags & OF_CLIENT_KNOWS); - // mprintf(0,"%");//KBTEST /* if(ObjGetAnimUpdate(objnum, &multi_anim_info)) // Checks if obj is still alive and all { @@ -7444,7 +7387,6 @@ void MultiDoObjWBAnimUpdate(uint8_t *data) { // int objnum; int count = 0; MULTI_ASSERT_NOMESSAGE(Netgame.local_role != LR_SERVER); - // mprintf(0,"R`"); SKIP_HEADER(data, &count); /* objnum = Server_object_list[MultiGetUshort (data,&count)]; @@ -7511,9 +7453,7 @@ void MultiDoBytesSent(uint8_t *data) { Bandwidth_throttle--; Bandwidth_throttle--; } - // mprintf_at(2,1,0,"Packet Loss: %d%% ",pct_loss); } else { - // mprintf_at(2,1,0,"Packet Loss: 0%% "); NetPlayers[Player_num].percent_loss = 0; Bandwidth_throttle--; } @@ -7543,7 +7483,7 @@ void MultiSendPPSSet(int pps) { MULTI_ASSERT_NOMESSAGE(Netgame.local_role != LR_SERVER); size = START_DATA(MP_CLIENT_SET_PPS, data, &count, 1); MultiAddByte(pps, data, &count); - mprintf(0, "Telling the server we want a PPS of %d\n", pps); + LOG_DEBUG.printf("Telling the server we want a PPS of %d", pps); END_DATA(count, data, size); nw_SendReliable(NetPlayers[Player_num].reliable_socket, data, count, false); } @@ -7552,7 +7492,7 @@ void MultiDoPPSSet(uint8_t *data, int slot) { int count = 0; SKIP_HEADER(data, &count); NetPlayers[slot].pps = MultiGetByte(data, &count); - mprintf(0, "%s changed his PPS to %d\n", Players[slot].callsign, NetPlayers[slot].pps); + LOG_DEBUG.printf("%s changed his PPS to %d", Players[slot].callsign, NetPlayers[slot].pps); } void MultiSendGreetings(uint32_t id) { @@ -7563,7 +7503,7 @@ void MultiSendGreetings(uint32_t id) { MULTI_ASSERT_NOMESSAGE(Netgame.local_role != LR_SERVER); size = START_DATA(MP_GREETINGS_FROM_CLIENT, data, &count); MultiAddUint(id, data, &count); - mprintf(0, "Saying hello to the server\n"); + LOG_DEBUG << "Saying hello to the server"; END_DATA(count, data, size); nw_Send(&Netgame.server_address, data, count, 0); } @@ -7573,9 +7513,7 @@ void MultiDoGreetings(uint8_t *data, network_address *addr) { SKIP_HEADER(data, &count); uint32_t id = MultiGetUint(data, &count); int i; - // mprintf(0,"Got a greeting packet with an id of %d\n"); for (i = 0; i < MAX_NET_PLAYERS; i++) { - // mprintf(0,"Netplayer[%d] has an id of %d\n",i,NetPlayers[i].secret_net_id); if (NetPlayers[i].secret_net_id == id) { // Get the address memcpy(&NetPlayers[i].addr, addr, sizeof(network_address)); @@ -7593,14 +7531,13 @@ void MultiAskForFile(uint16_t file_id, uint16_t file_who, uint16_t who) { int size = 0; uint8_t data[MAX_GAME_DATA_SIZE]; int count = 0; - //@@mprintf(0,"Asking player %d for a file (%d) from player %d\n",who,file_id,file_who); if (NetPlayers[who].file_xfer_flags != NETFILE_NONE) { - mprintf(0, "File already in progress, can't start another one!\n"); + LOG_FATAL << "File already in progress, can't start another one!"; Int3(); return; // Make sure a file isn't in progress } if (who == Player_num) { - mprintf(0, "Can't send a file to myself!\n"); + LOG_WARNING << "Can't send a file to myself!"; return; } // Check to see if this file exists already @@ -7616,18 +7553,18 @@ void MultiAskForFile(uint16_t file_id, uint16_t file_who, uint16_t who) { snprintf(szcrc, sizeof(szcrc), "_%.8x", cf_GetfileCRC(p)); // See if the the CRC is already in the filename if (strnicmp(szcrc, file + (strlen(file) - 9), 9) != 0) { - mprintf(0, "Bad CRC on file %s! It must be corrupt! File will not be used, and is being deleted!\n", p); + LOG_WARNING.printf("Bad CRC on file %s! It must be corrupt! File will not be used, and is being deleted!", p); ddio_DeleteFile(p); } else { // Hey hey, we already have this file - mprintf(0, "Using existing file: %s\n", p); + LOG_DEBUG.printf("Using existing file: %s", p); DoNextPlayerFile(file_who); return; } } } else { // No file - mprintf(0, "No custom file %d for player %d\n", file_id, file_who); + LOG_WARNING.printf("No custom file %d for player %d", file_id, file_who); DoNextPlayerFile(file_who); return; } @@ -7639,7 +7576,7 @@ void MultiAskForFile(uint16_t file_id, uint16_t file_who, uint16_t who) { END_DATA(count, data, size); if (Netgame.local_role == LR_SERVER) { // If we are a server, send a request to the client asking for a file of theirs - mprintf(0, "Asking client %d for a file.\n", who); + LOG_DEBUG.printf("Asking client %d for a file.", who); nw_SendReliable(NetPlayers[who].reliable_socket, data, count); NetPlayers[who].file_xfer_flags = NETFILE_ASKING; NetPlayers[who].file_xfer_pos = 0; @@ -7647,7 +7584,7 @@ void MultiAskForFile(uint16_t file_id, uint16_t file_who, uint16_t who) { NetPlayers[who].file_xfer_who = file_who; } else { // If we are a client, ask the server for a file - mprintf(0, "Asking server for a file.\n"); + LOG_DEBUG << "Asking server for a file."; nw_SendReliable(NetPlayers[Player_num].reliable_socket, data, count); NetPlayers[file_who].file_xfer_flags = NETFILE_ASKING; NetPlayers[file_who].file_xfer_pos = 0; @@ -7670,28 +7607,28 @@ void MultiDoFileReq(uint8_t *data) { char filewithpath[_MAX_PATH * 2]; strcpy(filewithpath, GetFileNameFromPlayerAndID(filewho, filenum)); if (filewithpath[0] == 0) { - mprintf(0, "Got a file request for a file that doesn't exist (%s).\n", filewithpath); + LOG_DEBUG.printf("Got a file request for a file that doesn't exist (%s).", filewithpath); DenyFile(playernum, filenum, NetPlayers[playernum].file_xfer_who); } else { cfp = cfopen(filewithpath, "rb"); if (!cfp) { - mprintf(0, "Couldn't open a file (%s) for transfer.\n", filewithpath); + LOG_WARNING.printf("Couldn't open a file (%s) for transfer.", filewithpath); DenyFile(playernum, filenum, NetPlayers[playernum].file_xfer_who); return; // We couldn't create the file, so cancel the attempt to transfer it. } - mprintf(0, "Sending first data chunk!\n"); + LOG_DEBUG << "Sending first data chunk!"; NetPlayers[playernum].file_xfer_who = filewho; NetPlayers[playernum].file_xfer_cfile = cfp; NetPlayers[playernum].file_xfer_pos = 0; NetPlayers[playernum].file_xfer_flags = NETFILE_SENDING; NetPlayers[playernum].file_xfer_total_len = cfp->size; NetPlayers[playernum].file_xfer_id = filenum; - mprintf(0, "File size = %d\n", cfp->size); + LOG_DEBUG.printf("File size = %d", cfp->size); SendDataChunk(playernum); } } else { - mprintf(0, "Got a file request while one was already in progress!\n"); + LOG_WARNING.printf("Got a file request while one was already in progress!"); DenyFile(playernum, filenum, NetPlayers[playernum].file_xfer_who); } } @@ -7743,7 +7680,7 @@ void MultiDoFileDenied(uint8_t *data) { uint16_t filenum = MultiGetUshort(data, &count); uint16_t playernum = MultiGetUshort(data, &count); uint16_t filewho = MultiGetUshort(data, &count); - mprintf(0, "Got a file denied packet from %d\n", playernum); + LOG_DEBUG.printf("Got a file denied packet from %d", playernum); DoNextPlayerFile(filewho); } @@ -7768,13 +7705,12 @@ void MultiDoFileData(uint8_t *data) { playernum = MultiGetUshort(data, &count); // file_who = MultiGetUshort (data,&count); data_len = MultiGetUshort(data, &count); - // mprintf(0,"Got a data packet from %d\n",playernum); if ((NetPlayers[playernum].file_xfer_flags == NETFILE_RECEIVING) || (NetPlayers[playernum].file_xfer_flags == NETFILE_ASKING)) { // Find out if this is the first packet of this file. if so, create and open the file if (NetPlayers[playernum].file_xfer_pos == 0) { - mprintf(0, "Creating file...\n"); + LOG_DEBUG << "Creating file..."; CFILE *cfp; // char filename[_MAX_PATH]; char filewithpath[_MAX_PATH * 2]; @@ -7782,7 +7718,7 @@ void MultiDoFileData(uint8_t *data) { cfp = cfopen(filewithpath, "wb"); if (!cfp) { - mprintf(0, "Can't create file %s\n", filewithpath); + LOG_WARNING.printf("Can't create file %s", filewithpath); // We couldn't create the file, so cancel the attempt to transfer it. MultiCancelFile(playernum, file_id, NetPlayers[playernum].file_xfer_who); return; @@ -7795,7 +7731,7 @@ void MultiDoFileData(uint8_t *data) { // Write the data to the file int data_wrote = cf_WriteBytes(data + count, data_len, NetPlayers[playernum].file_xfer_cfile); if (data_wrote != data_len) { - mprintf(0, "cf_WriteBytes() should have written %d bytes, but only wrote %d!\n", data_len, data_wrote); + LOG_FATAL.printf("cf_WriteBytes() should have written %d bytes, but only wrote %d!", data_len, data_wrote); Int3(); } @@ -7807,7 +7743,7 @@ void MultiDoFileData(uint8_t *data) { NetPlayers[playernum].file_xfer_cfile = NULL; NetPlayers[playernum].file_xfer_pos = 0; DoNextPlayerFile(playernum); - mprintf(0, "Finished downloading file!\n"); + LOG_DEBUG << "Finished downloading file!"; return; // Don't ack the last packet } // Ack the sender @@ -7821,7 +7757,7 @@ void MultiDoFileData(uint8_t *data) { nw_SendReliable(NetPlayers[Player_num].reliable_socket, outdata, outcount, true); } } else { - mprintf(0, "Received file transfer data from someone who we aren't expecting data from!\n"); + LOG_WARNING << "Received file transfer data from someone who we aren't expecting data from!"; } } @@ -7834,7 +7770,6 @@ void MultiDoFileAck(uint8_t *data) { SKIP_HEADER(data, &count); playernum = MultiGetUshort(data, &count); len_recvd = MultiGetUint(data, &count); - // mprintf(0,"Got a ACK packet from %d\n",playernum); if (NetPlayers[playernum].file_xfer_flags == NETFILE_SENDING) { if (NetPlayers[playernum].file_xfer_pos == len_recvd) { SendDataChunk(playernum); @@ -7842,7 +7777,7 @@ void MultiDoFileAck(uint8_t *data) { Int3(); // This shouldn't happen because the reliable network code should handle it } } else { - mprintf(0, "Received an ACK from someone we weren't sending a file to!\n"); + LOG_WARNING << "Received an ACK from someone we weren't sending a file to!"; } } @@ -7853,13 +7788,12 @@ void SendDataChunk(int playernum) { int size; int dataread; int done = 0; - // mprintf(0,"Sending a data chunk to %d.\n",playernum); // Read the next chunk of the file and send it! if ((DATA_CHUNK_SIZE + NetPlayers[playernum].file_xfer_pos) > (uint32_t)NetPlayers[playernum].file_xfer_cfile->size) { dataread = NetPlayers[playernum].file_xfer_cfile->size - NetPlayers[playernum].file_xfer_pos; // This is the end of the file - mprintf(0, "End of file detected!\n"); + LOG_WARNING << "End of file detected!"; done = 1; } else { dataread = DATA_CHUNK_SIZE; @@ -7911,7 +7845,7 @@ void MultiDoFileCancelled(uint8_t *data) { SKIP_HEADER(data, &count); playernum = MultiGetUshort(data, &count); filewho = MultiGetUshort(data, &count); - mprintf(0, "Got a cancelled packet from %d for %d\n", playernum, filewho); + LOG_DEBUG.printf("Got a cancelled packet from %d for %d", playernum, filewho); if (NetPlayers[filewho].file_xfer_cfile) { char delfile[_MAX_PATH * 2]; strcpy(delfile, NetPlayers[filewho].file_xfer_cfile->name); @@ -7934,8 +7868,6 @@ void MultiSendClientCustomData(int slot, int whoto) { int count = 0; int size_offset; - //@@mprintf(0,"Sending player %d's data to %d.\n",slot,whoto); - size_offset = START_DATA(MP_PLAYER_CUSTOM_DATA, data, &count); // Who we are talking about MultiAddShort(slot, data, &count); @@ -8027,12 +7959,12 @@ void MultiDoCustomPlayerData(uint8_t *data) { playernum = MultiGetUshort(data, &count); if (playernum == Player_num) return; - mprintf(0, "Got custom data in MultiDoCustomPlayerData()\n"); + LOG_DEBUG << "Got custom data in MultiDoCustomPlayerData()"; NetPlayers[playernum].custom_file_seq = NETFILE_ID_SHIP_TEX; // First in the sequence of files we will request int16_t logo_len = MultiGetUshort(data, &count); memcpy(NetPlayers[playernum].ship_logo, data + count, logo_len); count += logo_len; - mprintf(0, "%s uses custom ship logo %s\n", Players[playernum].callsign, NetPlayers[playernum].ship_logo); + LOG_DEBUG.printf("%s uses custom ship logo %s", Players[playernum].callsign, NetPlayers[playernum].ship_logo); for (int t = 0; t < 4; t++) { char *filename; @@ -8065,11 +7997,11 @@ char *GetFileNameFromPlayerAndID(int16_t playernum, int16_t id) { rval[0] = '\0'; if (playernum >= MAX_NET_PLAYERS) { - mprintf(0, "Invalid playernum (%d) passed to GetFileNameFromPlayerAndID()\n", playernum); + LOG_WARNING.printf("Invalid playernum (%d) passed to GetFileNameFromPlayerAndID()", playernum); return rval; } if (id > NETFILE_ID_LAST_FILE) { - mprintf(0, "Invalid file id (%d) passed to GetFileNameFromPlayerAndID()\n", id); + LOG_WARNING.printf("Invalid file id (%d) passed to GetFileNameFromPlayerAndID()", id); return rval; } switch (id) { @@ -8097,7 +8029,7 @@ char *GetFileNameFromPlayerAndID(int16_t playernum, int16_t id) { ddio_MakePath(rval, Base_directory, "custom", "sounds", NetPlayers[playernum].voice_taunt4, NULL); break; default: - mprintf(0, "Unknown id (%d) passed to GetFileNameFromPlayerAndID()\n", id); + LOG_FATAL.printf("Unknown id (%d) passed to GetFileNameFromPlayerAndID()", id); Int3(); break; } @@ -8105,10 +8037,10 @@ char *GetFileNameFromPlayerAndID(int16_t playernum, int16_t id) { CFILE *cfp; cfp = cfopen(rval, "rb"); if (!cfp) { - mprintf(0, "Multiplayer file xfer File does not exist, not using file %d for player %d!\n", id, playernum); + LOG_WARNING.printf("Multiplayer file xfer File does not exist, not using file %d for player %d!", id, playernum); // rval[0] = '\0'; } else if (32768 < cfilelength(cfp)) { - mprintf(0, "Multiplayer file xfer File to long, not using file %d for player %d!\n", id, playernum); + LOG_WARNING.printf("Multiplayer file xfer File to long, not using file %d for player %d!", id, playernum); rval[0] = '\0'; } if (cfp) @@ -8299,7 +8231,7 @@ void MultiSendRequestPlayTaunt(int index) { } if (!cfexist(audio_file)) { - mprintf(0, "Ignoring request to play audio taunt...it does not exist\n"); + LOG_DEBUG << "Ignoring request to play audio taunt...it does not exist"; return; } @@ -8339,10 +8271,10 @@ void MultiDoTypeIcon(uint8_t *data) { bit = bit << pnum; if (typing) { - mprintf(0, "%s is typing\n", Players[pnum].callsign); + LOG_DEBUG.printf("%s is typing", Players[pnum].callsign); Players_typing |= bit; } else { - mprintf(0, "%s is done typing\n", Players[pnum].callsign); + LOG_DEBUG.printf("%s is done typing", Players[pnum].callsign); Players_typing &= ~bit; } } @@ -8416,7 +8348,7 @@ void MultiDoAiWeaponFlags(uint8_t *data) { flags = MultiGetInt(data, &count); wb_index = MultiGetByte(data, &count); if (obj_num == 65535) { - mprintf(0, "Client/Server object lists don't match! (Server num %d)\n", obj_num); + LOG_FATAL.printf("Client/Server object lists don't match! (Server num %d)", obj_num); Int3(); return; } @@ -8465,12 +8397,12 @@ void MultiDoAttach(uint8_t *data) { f_aligned = MultiGetByte(data, &count) ? true : false; if (parent_num == 65535) { - mprintf(0, "Client/Server object lists don't match! (Server num %d)\n", parent_num); + LOG_FATAL.printf("Client/Server object lists don't match! (Server num %d)", parent_num); Int3(); return; } if (child_num == 65535) { - mprintf(0, "Client/Server object lists don't match! (Server num %d)\n", child_num); + LOG_FATAL.printf("Client/Server object lists don't match! (Server num %d)", child_num); Int3(); return; } @@ -8512,12 +8444,12 @@ void MultiDoAttachRad(uint8_t *data) { child = &Objects[child_num]; if (parent_num == 65535) { - mprintf(0, "Client/Server object lists don't match! (Server num %d)\n", parent_num); + LOG_FATAL.printf("Client/Server object lists don't match! (Server num %d)", parent_num); Int3(); return; } if (child_num == 65535) { - mprintf(0, "Client/Server object lists don't match! (Server num %d)\n", child_num); + LOG_FATAL.printf("Client/Server object lists don't match! (Server num %d)", child_num); Int3(); return; } @@ -8551,7 +8483,7 @@ void MultiDoUnattach(uint8_t *data) { uint16_t child_num = Server_object_list[server_objnum]; child = &Objects[child_num]; if (child_num == 65535) { - mprintf(0, "Client/Server object lists don't match! (Server num %d)\n", child_num); + LOG_FATAL.printf("Client/Server object lists don't match! (Server num %d)", child_num); Int3(); return; } @@ -8585,7 +8517,7 @@ void MultiDoThiefSteal(uint8_t *data) { // Sets whether or not we want the logos to be displayed on ships void MultiSetLogoState(bool state) { Multi_logo_state = state; - mprintf(0, "Setting multi_logo_state to %d\n", state); + LOG_DEBUG.printf("Setting multi_logo_state to %d", state); } void MultiDoPermissionToFire(uint8_t *data) { @@ -9035,7 +8967,7 @@ void MultiDoRequestToMove(uint8_t *data) { // If there is too much client error then adjust if (client_error) { - mprintf(0, "Correcting, deltatime=%f dist=%f\n", delta_time, vm_VectorDistance(&pos, &obj->pos)); + LOG_DEBUG.printf("Correcting, deltatime=%f dist=%f", delta_time, vm_VectorDistance(&pos, &obj->pos)); MultiSendAdjustPosition(slot, timestamp); Last_update_time[slot] = Gametime; } @@ -9176,7 +9108,7 @@ void MultiDoStripPlayer(int slot, uint8_t *data) { return; } - mprintf(0, "I'm stripping %d bare! (of weapons)\n", slot); + LOG_DEBUG.printf("I'm stripping %d bare! (of weapons)", slot); object *pobj = &Objects[Players[slot].objnum]; @@ -9263,7 +9195,7 @@ void MultiDoInitialRank(uint8_t *data) { int pnum = MultiGetByte(data, &count); float rank = MultiGetFloat(data, &count); - mprintf(0, "Got initial rank for player %d (%f)\n", pnum, rank); + LOG_DEBUG.printf("Got initial rank for player %d (%f)", pnum, rank); Players[pnum].rank = rank; } @@ -9279,7 +9211,7 @@ void MultiSendInitialRank(int pnum) { MultiAddByte(pnum, data, &count); MultiAddFloat(Players[pnum].rank, data, &count); - mprintf(0, "Sending initial rank for player %d\n", pnum); + LOG_DEBUG.printf("Sending initial rank for player %d", pnum); END_DATA(count, data, size_offset); @@ -9333,7 +9265,7 @@ void MultiClearGuidebot(int slot) { int size_offset; uint8_t data[MAX_GAME_DATA_SIZE]; - mprintf(0, "Sending Buddy_handle update to clients for Buddy#%d\n", slot); + LOG_DEBUG.printf("Sending Buddy_handle update to clients for Buddy#%d", slot); size_offset = START_DATA(MP_WORLD_STATES, data, &count); @@ -9395,7 +9327,7 @@ bool Multi_got_player_list = false; void DoPlayerListData(uint8_t *data, int len) { int count = 0; if (Multi_recieved_player_list == NULL) { - mprintf(0, "Received a player list packet when we weren't expecting one. Ignoring.\n"); + LOG_DEBUG << "Received a player list packet when we weren't expecting one. Ignoring."; return; } SKIP_HEADER(data, &count); @@ -9438,7 +9370,7 @@ void MultiDoBashPlayerShip(uint8_t *data) { AddHUDMessage("Switching to %s", Ships[ship_index].name); PlayerChangeShip(Player_num, ship_index); - mprintf(0, "Server told us to switch ships to the %s\n", (char *)data + count); + LOG_DEBUG.printf("Server told us to switch ships to the %s", (char *)data + count); FreeCockpit(); CloseShipHUD(); @@ -9474,10 +9406,10 @@ void MultiSendHeartbeat() { if (Netgame.local_role == LR_SERVER) { - mprintf(0, "Server sending heartbeat.\n"); + LOG_DEBUG << "Server sending heartbeat."; MultiSendToAllExcept(Player_num, outdata, count, -1); } else { - mprintf(0, "Client sending heartbeat.\n"); + LOG_DEBUG << "Client sending heartbeat."; nw_Send(&Netgame.server_address, outdata, count, 0); } @@ -9909,9 +9841,9 @@ void MultiProcessData(uint8_t *data, int len, int slot, network_address *from_ad case MP_HEARTBEAT: if (Netgame.local_role == LR_CLIENT) { Got_heartbeat = true; - mprintf(0, "Got heartbeat from server.\n"); + LOG_DEBUG << "Got heartbeat from server."; } else - mprintf(0, "Got heartbeat from slot %d.\n", slot); + LOG_DEBUG.printf("Got heartbeat from slot %d.", slot); break; case MP_INITIAL_RANK: MultiDoInitialRank(data); @@ -9928,7 +9860,7 @@ void MultiProcessData(uint8_t *data, int len, int slot, network_address *from_ad ACCEPT_CONDITION(-1, -1); MultiDoServerRejectedChecksum(data); default: - mprintf(0, "Invalid packet type %d!\n", type); + LOG_FATAL.printf("Invalid packet type %d!", type); Int3(); // Invalid packet type!!!! break; } @@ -9958,7 +9890,7 @@ void MultiProcessBigData(uint8_t *buf, int len, network_address *from_addr) { // We aren't going to process this packet because otherwise they // might try to join which wouldn't work and they would be credited // with sending a packet and the server wouldn't disconnect them. - mprintf(0, "Ignoring game info request from a currently connected user (%s)\n", Players[slot].callsign); + LOG_DEBUG.printf("Ignoring game info request from a currently connected user (%s)", Players[slot].callsign); return; } } @@ -9969,13 +9901,14 @@ void MultiProcessBigData(uint8_t *buf, int len, network_address *from_addr) { sub_len = INTEL_SHORT((*(int16_t *)(buf + bytes_processed + 1))); if (sub_len < 3 || type == 0 || (len - bytes_processed) < 2) { - mprintf(0, "Got a corrupted packet!\n"); + LOG_FATAL << "Got a corrupted packet!"; Int3(); return; // just throw the rest out } if ((bytes_processed + sub_len) > len) { - mprintf(1, "multi_process_bigdata: packet type %d too int16_t (%d>%d)!\n", type, (bytes_processed + sub_len), len); + LOG_FATAL.printf("multi_process_bigdata: packet type %d too int16_t (%d>%d)!", + type, (bytes_processed + sub_len), len); Int3(); return; } diff --git a/Descent3/multi_client.cpp b/Descent3/multi_client.cpp index 2a388804..c44ae29c 100644 --- a/Descent3/multi_client.cpp +++ b/Descent3/multi_client.cpp @@ -135,6 +135,7 @@ */ #include "chrono_timer.h" +#include "log.h" #include "multi.h" #include "multi_client.h" #include "game.h" @@ -161,7 +162,7 @@ void MultiSendMyInfo() { uint8_t data[MAX_GAME_DATA_SIZE]; int count = 0; - mprintf(0, "Sending my info\n"); + LOG_DEBUG << "Sending my info"; char pshipmodel[PAGENAME_LEN]; Current_pilot.get_ship(pshipmodel); @@ -227,7 +228,7 @@ void MultiSendRequestForPlayers() { uint8_t data[MAX_GAME_DATA_SIZE]; int count = 0; - mprintf(0, "Sending request for players\n"); + LOG_DEBUG << "Sending request for players"; size = START_DATA(MP_REQUEST_PLAYERS, data, &count); MultiAddByte(Player_num, data, &count); @@ -242,7 +243,7 @@ void MultiSendRequestForBuildings() { uint8_t data[MAX_GAME_DATA_SIZE]; int count = 0; - mprintf(0, "Sending request for buildings\n"); + LOG_DEBUG << "Sending request for buildings"; size = START_DATA(MP_REQUEST_BUILDINGS, data, &count); MultiAddByte(Player_num, data, &count); @@ -257,7 +258,7 @@ void MultiSendRequestForWorldStates() { uint8_t data[MAX_GAME_DATA_SIZE]; int count = 0; - mprintf(0, "Sending request for world states\n"); + LOG_DEBUG << "Sending request for world states"; size = START_DATA(MP_REQUEST_WORLD_STATES, data, &count); MultiAddByte(Player_num, data, &count); @@ -278,7 +279,7 @@ void MultiSendRequestForObjects() { uint8_t data[MAX_GAME_DATA_SIZE]; int count = 0; - mprintf(0, "Sending request for objects\n"); + LOG_DEBUG << "Sending request for objects"; size = START_DATA(MP_REQUEST_OBJECTS, data, &count); MultiAddByte(Player_num, data, &count); @@ -296,7 +297,7 @@ int ServerTimedOut() { return 0; if (!nw_CheckReliableSocket(NetPlayers[Player_num].reliable_socket)) { - mprintf(0, "Reliable connection to the server was broken. Disconnecting.\n"); + LOG_WARNING << "Reliable connection to the server was broken. Disconnecting."; ShowProgressScreen(TXT_RELIABLE_OVERRUN); D3::ChronoTimer::SleepMS(1000); return 1; @@ -343,7 +344,7 @@ void MultiDoClientFrame() { // Wait for server response if ((timer_GetTime() - First_gametime_req) > NET_CLIENT_GAMETIME_REQ_TIMEOUT) { // Giving up, we waited too long. - mprintf(0, "Server disconnected while waiting for gametime!\n"); + LOG_DEBUG << "Server disconnected while waiting for gametime!"; MultiLeaveGame(); ShowProgressScreen(TXT_MLTDISCFRMSERV); D3::ChronoTimer::SleepMS(2000); @@ -472,7 +473,6 @@ void MultiDoClientFrame() { // TODO: SEND RELIABLE WEAPON FIRE if (Player_fire_packet[Player_num].fired_on_this_frame == PFP_FIRED_RELIABLE) { - // mprintf(0,"I NEED TO SEND RELIABLE FIRE\n"); count = MultiStuffPlayerFire(Player_num, data); nw_SendReliable(NetPlayers[Player_num].reliable_socket, data, count, true); } @@ -484,7 +484,7 @@ void MultiDoClientFrame() { } if (ServerTimedOut()) { - mprintf(0, "Server disconnected!\n"); + LOG_DEBUG << "Server disconnected!"; MultiLeaveGame(); ShowProgressScreen(TXT_MLTDISCFRMSERV); D3::ChronoTimer::SleepMS(2000); diff --git a/Descent3/multi_connect.cpp b/Descent3/multi_connect.cpp index af0fdc4c..a7af5b5a 100644 --- a/Descent3/multi_connect.cpp +++ b/Descent3/multi_connect.cpp @@ -254,6 +254,7 @@ */ #include "chrono_timer.h" +#include "log.h" #include "multi.h" #include "multi_server.h" #include "player.h" @@ -378,7 +379,7 @@ int TryToJoinServer(network_address *addr) { } return 0; } else - mprintf(0, "Server says it is ok to join!\n"); + LOG_DEBUG << "Server says it is ok to join!"; nw_ConnectToServer(&sock, addr); if (sock != INVALID_SOCKET && sock != 0) { @@ -393,14 +394,14 @@ int TryToJoinServer(network_address *addr) { { MultiSetServerAddress(addr); } - mprintf(0, "Client mode set! Polling...\n"); + LOG_DEBUG << "Client mode set! Polling..."; MultiPollForConnectionAccepted(); if (NetPlayers[Player_num].flags & NPF_CONNECTED) return 1; else { - mprintf(0, "Couldn't join game for some reason!\n"); + LOG_DEBUG << "Couldn't join game for some reason!"; #ifdef USE_DIRECTPLAY if (!Use_DirectPlay) #endif @@ -409,7 +410,7 @@ int TryToJoinServer(network_address *addr) { } } } else { - mprintf(0, "nw_ConnectToServer says it can't find a good socket!\n"); + LOG_DEBUG << "nw_ConnectToServer says it can't find a good socket!"; } return 0; @@ -427,11 +428,11 @@ void MultiDoConnectionAccepted(uint8_t *data) { server_version = MultiGetShort(data, &count); if (server_version != MULTI_VERSION) { - mprintf(0, "Client and server code versions don't match. Do an update!\n"); + LOG_DEBUG << "Client and server code versions don't match. Do an update!"; return; } else { // Versions match, get info about the game and then connect! - mprintf(0, "Client/server versions match.\n"); + LOG_DEBUG << "Client/server versions match."; // Check if we have the mission needed uint8_t len = MultiGetByte(data, &count); @@ -439,9 +440,9 @@ void MultiDoConnectionAccepted(uint8_t *data) { count += len; if (!LoadMission(Netgame.mission)) { - mprintf(0, "We don't have this mission: %s!\n", Netgame.mission); + LOG_DEBUG.printf("We don't have this mission: %s!", Netgame.mission); } else - mprintf(0, "Using mission %s...\n", Netgame.mission); + LOG_DEBUG.printf("Using mission %s...", Netgame.mission); len = MultiGetByte(data, &count); memcpy(Netgame.name, &data[count], len); @@ -462,14 +463,14 @@ void MultiDoConnectionAccepted(uint8_t *data) { memcpy(&tempplayer, &NetPlayers[Player_num], sizeof(netplayer)); Player_num = player_num; - mprintf(0, "Server tells me that my player num is %d!\n", Player_num); + LOG_DEBUG.printf("Server tells me that my player num is %d!", Player_num); strcpy(Players[Player_num].callsign, name); memcpy(&NetPlayers[Player_num], &tempplayer, sizeof(netplayer)); NetPlayers[Player_num].flags = NPF_CONNECTED; // Hurray! We're connected // Get packets per second Netgame.packets_per_second = MultiGetByte(data, &count); - mprintf(0, "Server is sending %d packets per second\n", Netgame.packets_per_second); + LOG_DEBUG.printf("Server is sending %d packets per second", Netgame.packets_per_second); // Get the secret code we will use to identify ourselves to the server uint32_t secret_code = MultiGetUint(data, &count); @@ -477,9 +478,9 @@ void MultiDoConnectionAccepted(uint8_t *data) { // Get the peer-peer flag int flags = MultiGetInt(data, &count); if (flags & NF_PEER_PEER) - mprintf(0, "Using Peer/Peer model\n"); + LOG_DEBUG << "Using Peer/Peer model"; else - mprintf(0, "Using Client/Server model\n"); + LOG_DEBUG << "Using Client/Server model"; Netgame.flags = flags; @@ -513,7 +514,7 @@ void MultiPollForConnectionAccepted() { } if (!connected) { - mprintf(0, "Couldn't get a connection_accepted packet for some reason!\n"); + LOG_DEBUG << "Couldn't get a connection_accepted packet for some reason!"; } } @@ -526,7 +527,7 @@ void MultiSendConnectionAccepted(int slotnum, SOCKET sock, network_address *addr int count = 0; int size_offset; - mprintf(0, "Sending connection accepted packet to slot %d!\n", slotnum); + LOG_DEBUG.printf("Sending connection accepted packet to slot %d!", slotnum); NetPlayers[slotnum].reliable_socket = sock; memcpy(&NetPlayers[slotnum].addr, addr, sizeof(network_address)); @@ -552,7 +553,7 @@ void MultiSendConnectionAccepted(int slotnum, SOCKET sock, network_address *addr memcpy(&data[count], Netgame.mission, len); count += len; - mprintf(0, "Sending netgame mission %s with length of %d!\n", Netgame.mission, len); + LOG_DEBUG.printf("Sending netgame mission %s with length of %d!", Netgame.mission, len); len = strlen(Netgame.name) + 1; MultiAddByte(len, data, &count); @@ -624,7 +625,7 @@ int MultiPollForLevelInfo() { while ((size = nw_Receive(data, &from_addr)) > 0) { if (data[0] == MP_HEARTBEAT) { - mprintf(0, "Got a heart beat from the server.\n"); + LOG_DEBUG << "Got a heart beat from the server."; Got_heartbeat = true; } } @@ -761,7 +762,7 @@ void MultiSendLevelInfo(int slot) { MultiAddByte(JOIN_ANSWER_NOT_SERVER, data, &count); // Do level number (of the mission) - mprintf(0, "Sending current mission level %d!\n", Current_mission.cur_level); + LOG_DEBUG.printf("Sending current mission level %d!", Current_mission.cur_level); MultiAddByte(Current_mission.cur_level, data, &count); // Send the difficulty @@ -810,7 +811,7 @@ void MultiSendReadyForLevel() { int count = 0; int size_offset; - mprintf(0, "Sending ready for level!\n"); + LOG_DEBUG << "Sending ready for level!"; char pshipmodel[PAGENAME_LEN]; Current_pilot.get_ship(pshipmodel); @@ -839,10 +840,10 @@ extern int Multi_packet_tracking[]; // Clears all connections // Server and Client void MultiCloseGame() { - mprintf(0, "Multi close game!\n"); + LOG_DEBUG << "Multi close game!"; if (!(Game_mode & GM_NETWORK)) { - mprintf(0, "Not network game!\n"); + LOG_DEBUG << "Not network game!"; return; } @@ -851,7 +852,7 @@ void MultiCloseGame() { CFILE *outfile; outfile = cfopen("PacketTracking", "wt"); if (!outfile) { - mprintf(0, "Couldn't open packet tracking file!\n"); + LOG_WARNING << "Couldn't open packet tracking file!"; } else { for (int i = 0; i < 255; i++) { cfprintf(outfile, "Packet %d = %d\n", i, Multi_packet_tracking[i]); @@ -973,6 +974,6 @@ void UpdateAndPackGameList(void) { // Sets whether or not the server answsers to a connection request void MultiSetAcceptState(bool state) { - mprintf(0, "Setting multi_accept_state to %s.\n", state ? "true" : "false"); + LOG_DEBUG.printf("Setting multi_accept_state to %s.", state ? "true" : "false"); Multi_accept_state = state; } diff --git a/Descent3/multi_dll_mgr.cpp b/Descent3/multi_dll_mgr.cpp index 9d0871d5..7f029738 100644 --- a/Descent3/multi_dll_mgr.cpp +++ b/Descent3/multi_dll_mgr.cpp @@ -286,14 +286,13 @@ #include "multi_client.h" #include "Mission.h" #include "pilot.h" -#include "pstypes.h" #include "pserror.h" #include "descent.h" #include "room.h" #include "object.h" #include "terrain.h" #include "player.h" -#include "mono.h" +#include "log.h" #include "hud.h" #include "Inventory.h" #include "multi_server.h" @@ -578,7 +577,7 @@ void FreeMultiDLL() { mod_FreeModule(&MultiDLLHandle); // Try deleting the file now! if (!ddio_DeleteFile(Multi_conn_dll_name)) { - mprintf(0, "Couldn't delete the tmp dll"); + LOG_WARNING << "Couldn't delete the tmp dll"; } DLLMultiCall = NULL; DLLMultiInit = NULL; @@ -601,7 +600,7 @@ int LoadMultiDLL(const char *name) { std::error_code ec; std::filesystem::remove(path, ec); if (ec) { - mprintf(0, "Unable to remove temporary file %s: %s\n", path.u8string().c_str(), ec.message().c_str()); + LOG_ERROR.printf("Unable to remove temporary file %s: %s", path.u8string().c_str(), ec.message().c_str()); } }); @@ -631,7 +630,7 @@ int LoadMultiDLL(const char *name) { // Copy the DLL // ddio_MakePath(dll_path_name,Base_directory,"online",tmp_dll_name,NULL); if (!cf_CopyFile(tmp_dll_name, dll_name)) { - mprintf(0, "DLL copy failed!\n"); + LOG_WARNING << "DLL copy failed!"; return 0; } strcpy(Multi_conn_dll_name, tmp_dll_name); @@ -639,14 +638,14 @@ loaddll: if (!mod_LoadModule(&MultiDLLHandle, tmp_dll_name)) { int err = mod_GetLastError(); - mprintf(0, "You are missing the DLL %s!\n", name); + LOG_WARNING.printf("You are missing the DLL %s!", name); return 0; } DLLMultiInit = (DLLMultiInit_fp)mod_GetSymbol(&MultiDLLHandle, "DLLMultiInit", 4); if (!DLLMultiInit) { int err = mod_GetLastError(); - mprintf(0, "Couldn't get a handle to the dll function DLLMultiInit!\n"); + LOG_FATAL << "Couldn't get a handle to the dll function DLLMultiInit!"; Int3(); FreeMultiDLL(); return 0; @@ -654,7 +653,7 @@ loaddll: DLLMultiCall = (DLLMultiCall_fp)mod_GetSymbol(&MultiDLLHandle, "DLLMultiCall", 4); if (!DLLMultiCall) { int err = mod_GetLastError(); - mprintf(0, "Couldn't get a handle to the dll function DLLMultiCall!\n"); + LOG_FATAL << "Couldn't get a handle to the dll function DLLMultiCall!"; Int3(); FreeMultiDLL(); return 0; @@ -662,7 +661,7 @@ loaddll: DLLMultiClose = (DLLMultiClose_fp)mod_GetSymbol(&MultiDLLHandle, "DLLMultiClose", 0); if (!DLLMultiClose) { int err = mod_GetLastError(); - mprintf(0, "Couldn't get a handle to the dll function DLLMultiClose!\n"); + LOG_FATAL << "Couldn't get a handle to the dll function DLLMultiClose!"; Int3(); FreeMultiDLL(); return 0; @@ -694,7 +693,7 @@ loaddll: if (!DLLMultiScoreCall) { int err = mod_GetLastError(); - mprintf(0, "Couldn't get a handle to the dll function DLLMultiScoreCall!\n"); + LOG_FATAL << "Couldn't get a handle to the dll function DLLMultiScoreCall!"; Int3(); Supports_score_api = false; } @@ -759,7 +758,7 @@ const char *ListGetItem(UIListBox *item, int index) { if (ui_item) return ui_item->GetBuffer(); else { - mprintf(0, "No listbox item found for index %d\n", index); + LOG_WARNING.printf("No listbox item found for index %d", index); return ""; } } @@ -769,10 +768,10 @@ void DatabaseRead(const char *label, char *entry, int *entrylen) { Database->rea void DatabaseWrite(const char *label, const char *entry, int entrylen) { Database->write(label, entry, entrylen); } void DatabaseReadInt(const char *label, int *val) { Database->read_int(label, val); - mprintf(0, "Read int: %s:%d\n", label, *val); + LOG_DEBUG.printf("Read int: %s:%d", label, *val); } void DatabaseWriteInt(const char *label, int val) { - mprintf(0, "Writing int: %s:%d\n", label, val); + LOG_DEBUG.printf("Writing int: %s:%d", label, val); Database->write(label, val); } void DescentDefer(void) { Descent->defer(); } @@ -938,7 +937,7 @@ const char *OldListGetItem(UIListBox *item, int index) { if (ti) return ti->GetBuffer(); else { - mprintf(0, "No listbox item found for index %d\n", index); + LOG_WARNING.printf("No listbox item found for index %d", index); return ""; } } diff --git a/Descent3/multi_save_setting.cpp b/Descent3/multi_save_setting.cpp index 8e725ca3..31a6ed42 100644 --- a/Descent3/multi_save_setting.cpp +++ b/Descent3/multi_save_setting.cpp @@ -71,10 +71,12 @@ #include #include "cfile.h" +#include "log.h" #include "multi.h" +#include "multi_save_settings.h" #include "objinfo.h" #include "ship.h" -#include "multi_save_settings.h" + int MultiSaveSettings(const std::filesystem::path &filename) { CFILE *cf; @@ -263,7 +265,7 @@ int MultiLoadSettings(const std::filesystem::path &filename) { if ((Netgame.difficulty > 4) || (Netgame.difficulty < 0)) Netgame.difficulty = 0; } else { - mprintf(0, "Unknown line in multiplayer config file %s\t%s\n", toklabel, tokval); + LOG_WARNING.printf("Unknown line in multiplayer config file %s\t%s", toklabel, tokval); } }; return 1; diff --git a/Descent3/multi_server.cpp b/Descent3/multi_server.cpp index c1aad0fc..ed5ae8b2 100644 --- a/Descent3/multi_server.cpp +++ b/Descent3/multi_server.cpp @@ -624,12 +624,14 @@ * */ +#include + #include "args.h" #include "multi.h" #include "multi_server.h" #include "player.h" #include "game.h" -#include "mono.h" +#include "log.h" #include "ddio.h" #include "hud.h" #include "pilot.h" @@ -659,7 +661,6 @@ #include "ship.h" #include "pstring.h" #include "audiotaunts.h" - #include "ui.h" #include "newui.h" #include "multi_dll_mgr.h" @@ -667,9 +668,6 @@ #include "psrand.h" #include "polymodel.h" #include "init.h" -#include "../md5/md5.h" - -#include void MultiProcessShipChecksum(MD5 *md5, int ship_index); @@ -783,7 +781,7 @@ void MultiStartServer(int playing, char *scriptname, int dedicated_server_num_te if (t == 0) t = 5.0f; - mprintf(0, "MULTI: Setting audio taunt delay time to %.2f seconds\n", t); + LOG_DEBUG.printf("MULTI: Setting audio taunt delay time to %.2f seconds", t); taunt_SetDelayTime(t); } else { taunt_SetDelayTime(5.0f); @@ -853,7 +851,7 @@ int CheckMissionForScript(char *mission, char *script, int dedicated_server_num_ GetDLLNumTeamInfo(script, &min_teams, &max_teams); if (min_teams > teams) { - mprintf(0, "This multiplayer game requires more teams than the mission supports!\n"); + LOG_DEBUG << "This multiplayer game requires more teams than the mission supports!"; return SCRIPTBADFORMISSION; } // Use whatever is smaller, the dll's max teams, or what the missions supports @@ -927,7 +925,7 @@ void MultiCheckListen() { // if we didn't find a player, close the socket if (i == MAX_NET_PLAYERS) { - mprintf(0, "Got accept on my listen socket, but no free slots. Closing socket.\n"); + LOG_DEBUG << "Got accept on my listen socket, but no free slots. Closing socket."; nw_CloseSocket(&sock); } } @@ -939,7 +937,7 @@ void MultiSendDonePlayers(int slot) { uint8_t data[MAX_GAME_DATA_SIZE]; int count = 0; - mprintf(0, "Sending done players\n"); + LOG_DEBUG << "Sending done players"; size = START_DATA(MP_DONE_PLAYERS, data, &count); int num = MultiCountPlayers(); @@ -955,7 +953,7 @@ void MultiSendDoneBuildings(int slot) { uint8_t data[MAX_GAME_DATA_SIZE]; int count = 0; - mprintf(0, "Sending done buildings\n"); + LOG_DEBUG << "Sending done buildings"; size = START_DATA(MP_DONE_BUILDINGS, data, &count); END_DATA(count, data, size); @@ -969,7 +967,7 @@ void MultiSendDoneObjects(int slot) { uint8_t data[MAX_GAME_DATA_SIZE]; int count = 0; - mprintf(0, "Sending done objects\n"); + LOG_DEBUG << "Sending done objects"; // Take the level checksum and clone it. MD5 playermd5(*Level_md5); @@ -997,7 +995,7 @@ void MultiSendDoneWorldStates(int slot) { uint8_t data[MAX_GAME_DATA_SIZE]; int count = 0; - mprintf(0, "Sending done world states\n"); + LOG_DEBUG << "Sending done world states"; size = START_DATA(MP_DONE_WORLD_STATES, data, &count); END_DATA(count, data, size); @@ -1053,24 +1051,20 @@ void MultiDisconnectDeadPlayers() { float cur_time = timer_GetTime(); if (!nw_CheckReliableSocket(NetPlayers[i].reliable_socket)) { - mprintf(0, "Disconnecting player %d because the reliable socket closed.\n", i); + LOG_DEBUG.printf("Disconnecting player %d because the reliable socket closed.", i); AddHUDMessage("%s (%s)", TXT_RELIABLE_OVERRUN, Players[i].callsign); MultiDisconnectPlayer(i); } else if (NetPlayers[i].sequence > NETSEQ_LEVEL_START && NetPlayers[i].sequence != NETSEQ_LEVEL_END) { if (cur_time - NetPlayers[i].last_packet_time > DISCONNECT_TIME) { - mprintf(0, "8sec disconnecting player %d. Last packet time=%f Sequence=%d\n", - i, - cur_time - NetPlayers[i].last_packet_time, - NetPlayers[i].sequence); + LOG_DEBUG.printf("8sec disconnecting player %d. Last packet time=%f Sequence=%d", + i, cur_time - NetPlayers[i].last_packet_time, NetPlayers[i].sequence); MultiDisconnectPlayer(i); } } else // If not playing (ie joining, give them longer) { if (cur_time - NetPlayers[i].last_packet_time > (DISCONNECT_TIME * 15)) { - mprintf(0, "Too long...disconnecting player %d. Last packet time=%f Sequence=%d\n", - i, - cur_time - NetPlayers[i].last_packet_time, - NetPlayers[i].sequence); + LOG_DEBUG.printf("Too long...disconnecting player %d. Last packet time=%f Sequence=%d", + i, cur_time - NetPlayers[i].last_packet_time, NetPlayers[i].sequence); MultiDisconnectPlayer(i); } } @@ -1087,7 +1081,7 @@ void MultiDisconnectPlayer(int slot) { CallGameDLL(EVT_GAMEPLAYERDISCONNECT, &DLLInfo); if (NetPlayers[slot].flags & NPF_CONNECTED) { - mprintf(0, "Disconnecting player %d (%s)...\n", slot, Players[slot].callsign); + LOG_DEBUG.printf("Disconnecting player %d (%s)...", slot, Players[slot].callsign); if (NetPlayers[slot].file_xfer_flags != NETFILE_NONE) { MultiCancelFile(slot, NetPlayers[slot].custom_file_seq, NetPlayers[slot].file_xfer_who); } @@ -1107,7 +1101,7 @@ void MultiDisconnectPlayer(int slot) { Players[slot].flags = 0; } else - mprintf(0, "Trying to disconnect a non-existant player!\n"); + LOG_DEBUG << "Trying to disconnect a non-existant player!"; } // Sends existing players to a joining player @@ -1120,7 +1114,7 @@ void MultiSendPlayer(int slot, int which) { int count = 0; int size_offset; - mprintf(0, "Sending MP_PLAYER packet to player %d!\n", slot); + LOG_DEBUG.printf("Sending MP_PLAYER packet to player %d!", slot); size_offset = START_DATA(MP_PLAYER, data, &count); @@ -1212,7 +1206,7 @@ void MultiSendBuildings(int slot) { int count = 0; int size_offset; - mprintf(0, "Sending MP_BUILDING packet to player %d!\n", slot); + LOG_DEBUG.printf("Sending MP_BUILDING packet to player %d!", slot); size_offset = START_DATA(MP_BUILDING, data, &count); @@ -1270,7 +1264,7 @@ void MultiSendJoinDemoObjects(int slot) { ASSERT((num_demo_objects * sizeof(uint16_t) + sizeof(uint16_t)) < MAX_GAME_DATA_SIZE); - mprintf(0, "Sending DemoJoinObjects (%d)\n", num_demo_objects); + LOG_DEBUG.printf("Sending DemoJoinObjects (%d)", num_demo_objects); count = 0; size_offset = START_DATA(MP_SEND_DEMO_OBJECT_FLAGS, data, &count); @@ -1367,7 +1361,7 @@ void MultiSendJoinObjects(int slot) { int size_offset; int i; - mprintf(0, "Sending MP_JOIN_OBJECTS packet to player %d!\n", slot); + LOG_DEBUG.printf("Sending MP_JOIN_OBJECTS packet to player %d!", slot); uint16_t total_objects = 0; last_sent_bytes[slot] = timer_GetTime(); @@ -1454,7 +1448,7 @@ void MultiSendJoinObjects(int slot) { void MultiStoreWorldPacket(int slot, uint8_t *big_data, int *big_count, uint8_t *cur_data, int *cur_count, int *size_offset) { if (*big_count + *cur_count >= (MAX_GAME_DATA_SIZE - 3)) { - mprintf(0, "Starting another world packet!\n"); + LOG_DEBUG << "Starting another world packet!"; MultiAddByte(WS_END, big_data, big_count); END_DATA(*big_count, big_data, *size_offset); @@ -1484,7 +1478,7 @@ void MultiSendWorldStates(int slot) { int count = 0; int size_offset; - mprintf(0, "Sending MP_WORLD_STATES packet to player %d!\n", slot); + LOG_DEBUG.printf("Sending MP_WORLD_STATES packet to player %d!", slot); size_offset = START_DATA(MP_WORLD_STATES, data, &count); @@ -1799,7 +1793,7 @@ void MultiSendWorldStates(int slot) { MultiStoreWorldPacket(slot, data, &count, cur_data, &cur_count, &size_offset); } } - mprintf(0, "Send %d spew events\n", spewcount); + LOG_DEBUG.printf("Send %d spew events", spewcount); // Send buddybot handles if needed if (Netgame.flags & NF_ALLOWGUIDEBOT) { @@ -1930,7 +1924,7 @@ void MultiCheckToRepositionPowerups() { } if (changed > 0) { - mprintf(0, "Stopped=%d\n", changed); + LOG_DEBUG.printf("Stopped=%d", changed); } } @@ -1957,13 +1951,13 @@ void MultiCheckToRespawnPowerups() { } if (num_cand == 0) { - mprintf(0, "Couldn't find a good spot to respawn!!!\n"); + LOG_WARNING << "Couldn't find a good spot to respawn!!!"; return; } t = candidates[ps_rand() % num_cand]; - mprintf(0, "Respawning powerup with id of %d.\n", Powerup_timer[i].id); + LOG_DEBUG.printf("Respawning powerup with id of %d.", Powerup_timer[i].id); Powerup_respawn[t].used = 1; int objnum = ObjCreate(OBJ_POWERUP, Powerup_timer[i].id, Powerup_respawn[t].roomnum, &Powerup_respawn[t].pos, NULL); @@ -2141,7 +2135,6 @@ void MultiSendPositionalUpdates(int to_slot) { // TODO: SEND RELIABLE WEAPON FIRE HERE if (Player_fire_packet[i].fired_on_this_frame == PFP_FIRED_RELIABLE) { - // mprintf(0,"NEED TO SEND RELIABLE FIRE FOR %d\n",i); count = MultiStuffPlayerFire(i, data); nw_SendReliable(NetPlayers[to_slot].reliable_socket, data, count, true); } @@ -2165,7 +2158,6 @@ void MultiUpdateRobotMovedList(int slot) { if (MultiIsValidMovedObject(obj)) { if ((obj->flags & OF_MOVED_THIS_FRAME)) { skip_this_obj = false; - // mprintf(0,"Object %d (type=%d) moved this frame!\n",a,obj->type); // Check to see if this robot is on the list already for (int b = 0; b < Num_moved_robots[slot] && !skip_this_obj; b++) { if (Moved_robots[slot][b] == obj->handle) { @@ -2381,7 +2373,7 @@ void MultiDoServerRobotFrame(int slot) { int objnum = Moved_robots[slot][m] & HANDLE_OBJNUM_MASK; if (Moved_robots[slot][m] != Objects[objnum].handle) { - mprintf(0, "Caught handle objnum problem!\n"); + LOG_WARNING << "Caught handle objnum problem!"; continue; } @@ -2413,7 +2405,7 @@ void MultiDoServerRobotFrame(int slot) { object *obj = &Objects[objnum]; if (Changed_anim[m][slot] != obj->handle) { - mprintf(0, "Caught anim handle objnum problem!\n"); + LOG_WARNING << "Caught anim handle objnum problem!"; continue; } @@ -2441,7 +2433,7 @@ void MultiDoServerRobotFrame(int slot) { object *obj = &Objects[objnum]; if (Changed_turret[m][slot] != obj->handle) { - mprintf(0, "Caught turret handle objnum problem!\n"); + LOG_WARNING << "Caught turret handle objnum problem!"; continue; } @@ -2469,7 +2461,7 @@ void MultiDoServerRobotFrame(int slot) { object *obj = &Objects[objnum]; if (Changed_wb_anim[m][slot] != obj->handle) { - mprintf(0, "Caught wb anim handle objnum problem!\n"); + LOG_WARNING << "Caught wb anim handle objnum problem!"; continue; } @@ -2729,8 +2721,6 @@ void MultiDoServerFrame() { for (i = 0; i < MAX_NET_PLAYERS; i++) Player_fire_packet[i].fired_on_this_frame = PFP_NO_FIRED; - mprintf_at(2, 5, 0, "Occ=%d ", Multi_occluded); - // If this is a dedicated server then we should get possible input if (Dedicated_server) DoDedicatedServerFrame(); @@ -2746,8 +2736,6 @@ void MultiSendClientExecuteDLL(int eventnum, int me_objnum, int it_objnum, int t if (to == Player_num) return; - // mprintf(0,"Sending MP_EXECUTE_DLL packet to slot %d! type=%d - // id=%d\n",to,Objects[me_objnum].type,Objects[me_objnum].id); size_offset = START_DATA(MP_EXECUTE_DLL, data, &count, 1); @@ -2968,7 +2956,7 @@ void MultiSendChangeRank(int pnum, char *str, uint8_t goodnews) { uint8_t data[MAX_GAME_DATA_SIZE]; int count = 0; - mprintf(0, "Sending change rank!\n"); + LOG_DEBUG << "Sending change rank!"; size = START_DATA(MP_CHANGE_RANK, data, &count); MultiAddByte(pnum, data, &count); diff --git a/Descent3/multi_ui.cpp b/Descent3/multi_ui.cpp index 59631cb2..8e6ba477 100644 --- a/Descent3/multi_ui.cpp +++ b/Descent3/multi_ui.cpp @@ -317,6 +317,7 @@ #include "args.h" #include "ui.h" +#include "log.h" #include "newui.h" #include "game.h" #include "gamefont.h" @@ -376,7 +377,7 @@ void DisplayNetDLLHelp(const char *topic); int MainMultiplayerMenu() { - mprintf(0, "Entering MainMultiplayerMenu()\n"); + LOG_INFO << "Entering MainMultiplayerMenu()"; #ifdef USE_DIRECTPLAY Num_directplay_games = 0; @@ -1419,7 +1420,7 @@ void MultiGameOptionsMenu(int alloptions) { MULTI_OPT_TOGGLES_X, pcs_y, 180, 30, UIF_FIT); Netgame.flags &= ~NF_PEER_PEER; Netgame.flags &= ~NF_PERMISSABLE; - mprintf(0, "Using Client/Server model\n"); + LOG_INFO << "Using Client/Server model"; } else if (res == PP_MODE_HS_ID) { cs_mode_hs.Destroy(); pp_mode_hs.Destroy(); @@ -1434,7 +1435,7 @@ void MultiGameOptionsMenu(int alloptions) { Netgame.flags |= NF_PEER_PEER; Netgame.flags &= ~NF_PERMISSABLE; - mprintf(0, "Using Peer/Peer model\n"); + LOG_INFO << "Using Peer/Peer model"; } else if (res == PS_MODE_HS_ID) { cs_mode_hs.Destroy(); pp_mode_hs.Destroy(); @@ -1449,7 +1450,7 @@ void MultiGameOptionsMenu(int alloptions) { Netgame.flags |= NF_PERMISSABLE; Netgame.flags &= ~NF_PEER_PEER; - mprintf(0, "Using Permissable model\n"); + LOG_INFO << "Using Permissable model"; } else if (res == ROT_VEL_HS_ID) { rot_vel_hs.Destroy(); diff --git a/Descent3/multisafe.cpp b/Descent3/multisafe.cpp index 0d841ef5..34b2a332 100644 --- a/Descent3/multisafe.cpp +++ b/Descent3/multisafe.cpp @@ -638,6 +638,9 @@ * 24 12/30/98 12:09p Jason * added logfile */ + +#include + #include "multisafe.h" #include "weather.h" #include "room.h" @@ -647,11 +650,10 @@ #include "hud.h" #include "doorway.h" #include "trigger.h" -#include "gamepath.h" -#include "AIGoal.h" #include "weapon.h" #include "spew.h" #include "hlsoundlib.h" +#include "log.h" #include "sounds.h" #include "ship.h" #include "player.h" @@ -659,10 +661,8 @@ #include "soundload.h" #include "streamaudio.h" #include "gamesequence.h" -#include "gameevent.h" #include "SmallViews.h" #include "difficulty.h" -#include "door.h" #include "demofile.h" #include "stringtable.h" #include "d3music.h" @@ -671,8 +671,6 @@ #include "viseffect.h" #include "levelgoal.h" -#include - /* The following functions have been added or modified by Matt and/or someone else other than Jason, and thus Jason should check them out to make sure they're ok for multiplayer. @@ -715,7 +713,7 @@ bool VALIDATE_ROOM_PORTAL(int roomnum, int portalnum) { object *VALIDATE_OBJECT(int handle) { object *objp = ObjGet(handle); if (!objp) { - mprintf(0, "Invalid object passed to multisafe.\n"); + LOG_WARNING << "Invalid object passed to multisafe."; } return objp; } @@ -1314,7 +1312,7 @@ void msafe_CallFunction(uint8_t type, msafe_struct *mstruct) { break; case MSAFE_WEATHER_LIGHTNING_BOLT: { if (mstruct->texnum == -1) { - mprintf(0, "Failing bolt because texnum is -1\n"); + LOG_WARNING << "Failing bolt because texnum is -1"; return; } @@ -1603,7 +1601,7 @@ void msafe_CallFunction(uint8_t type, msafe_struct *mstruct) { if (mstruct->objhandle != OBJECT_HANDLE_NONE) { object *keyobj = ObjGet(mstruct->objhandle); if (keyobj) { - mprintf(0, "Adding key from multisafe to player %d\n", slot); + LOG_DEBUG.printf("Adding key from multisafe to player %d", slot); Sound_system.Play3dSound(SOUND_POWERUP_PICKUP, SND_PRIORITY_HIGH, keyobj); Players[slot].inventory.Add(keyobj->type, keyobj->id, NULL, -1, -1, INVAF_NOTSPEWABLE, mstruct->message); diff --git a/Descent3/multisafe_server.cpp b/Descent3/multisafe_server.cpp index 317e30be..503a42cc 100644 --- a/Descent3/multisafe_server.cpp +++ b/Descent3/multisafe_server.cpp @@ -19,6 +19,7 @@ #include "pstypes.h" #include "pserror.h" #include "game.h" +#include "log.h" #include "multi.h" #include "multisafe.h" #include "multi_server.h" @@ -244,11 +245,11 @@ void MultiDoMSafeFunction(uint8_t *data) { mstruct->lifetime = MultiGetFloat(data, &count); mstruct->size = MultiGetFloat(data, &count); mstruct->speed = MultiGetFloat(data, &count); - mprintf(0, "Got a START SPEW. Index=%d\n", mstruct->id); + LOG_DEBUG.printf("Got a START SPEW. Index=%d", mstruct->id); break; case MSAFE_OBJECT_STOP_SPEW: mstruct->id = MultiGetUbyte(data, &count); - mprintf(0, "Got STOP SPEW. index=%d\n", mstruct->id); + LOG_DEBUG.printf("Got STOP SPEW. index=%d", mstruct->id); mstruct->id = Server_spew_list[mstruct->id]; ASSERT(mstruct->id != 65535); break; @@ -1086,7 +1087,7 @@ void MultiSendMSafeFunction(uint8_t type, msafe_struct *mstruct) { break; default: - mprintf(0, "Type %d is not handled in multisafe server...fix me!!\n", type); + LOG_FATAL.printf("Type %d is not handled in multisafe server...fix me!!", type); Int3(); // Illegal type passed to multisafe function break; } @@ -1157,7 +1158,7 @@ void MultiSendMSafePowerup(msafe_struct *mstruct) { size_offset = START_DATA(MP_MSAFE_POWERUP, data, &count); - mprintf(0, "Sending powerup objnum of %d\n", mstruct->objhandle & HANDLE_OBJNUM_MASK); + LOG_DEBUG.printf("Sending powerup objnum of %d", mstruct->objhandle & HANDLE_OBJNUM_MASK); MultiAddUshort(mstruct->objhandle & HANDLE_OBJNUM_MASK, data, &count); MultiAddUshort(mstruct->ithandle & HANDLE_OBJNUM_MASK, data, &count); diff --git a/Descent3/newui.cpp b/Descent3/newui.cpp index 8ae16a4a..1edf1e19 100644 --- a/Descent3/newui.cpp +++ b/Descent3/newui.cpp @@ -297,6 +297,11 @@ * $NoKeywords: $ */ +#include +#include +#include + +#include "log.h" #include "newui.h" #include "game.h" #include "descent.h" @@ -310,10 +315,6 @@ #include "hlsoundlib.h" #include "dedicated_server.h" -#include -#include -#include - #define MSGBOX_HEIGHT msgbox.H() #define BTN_WIDTH 96 #define NEWUI_FRAMETIME (1.0f / 25.0f) @@ -753,7 +754,7 @@ bool DoEditDialog(const char *title, char *buffer, int buflen, bool showcancel) if (res != UID_CANCEL && res != NEWUIRES_FORCEQUIT) { if (strcmp(edit, NEWUI_EDIT_CANCELED_STR) != 0) { strcpy(buffer, edit); - mprintf(0, "editdialog=%s\n", buffer); + LOG_DEBUG.printf("editdialog=%s", buffer); } else { res = UID_CANCEL; } diff --git a/Descent3/newui_core.cpp b/Descent3/newui_core.cpp index 66b42480..09eb1fab 100644 --- a/Descent3/newui_core.cpp +++ b/Descent3/newui_core.cpp @@ -184,24 +184,23 @@ #include #include +#include #include "newui_core.h" #include "bitmap.h" +#include "log.h" #include "mem.h" #include "pserror.h" #include "game.h" #include "ddio.h" #include "renderer.h" #include "descent.h" -#include "application.h" #include "stringtable.h" #include "gamefont.h" #include "textaux.h" #include "d3music.h" #include "hlsoundlib.h" -#include - extern void ui_DoCursor(); // filenames of ui bitmaps @@ -2242,9 +2241,7 @@ void newuiMenuOptionButton::OnMouseBtnDown(int btn) { if ((m_State != UI_BTS_ACTIVATED) && PT_IN_GADGET(m_Wnd, this, UI_input.mx, UI_input.my)) { m_State = UI_BTS_ACTIVATED; LOCK_FOCUS(this); - // mprintf(0, "mouse down in button gadget (%d)\n", GetID()); if (m_mono_press) { - // mprintf(0, "selected button gadget (%d)\n", GetID()); OnSelect(); m_State = UI_BTS_HILITE; } @@ -2893,7 +2890,7 @@ void newuiListBox::RemoveItem(const char *name) { } } if (found == -1) { - mprintf(0, "newuiListBox:: Didn't find item to remove!\n"); + LOG_WARNING << "newuiListBox:: Didn't find item to remove!"; return; } @@ -3050,7 +3047,7 @@ bool newuiListBox::SetCurrentItem(const char *name) { } if (!found) { - mprintf(0, "newuiListBox::SelectItem item not found!\n"); + LOG_WARNING << "newuiListBox::SelectItem item not found!"; return false; } @@ -3256,9 +3253,7 @@ void newuiListBox::OnMouseBtnDown(int btn) { if (m_nclicks == 0) { LOCK_FOCUS(this); m_nclicks = 1; - // mprintf(0, "click 1\n"); } else if (m_nclicks == 2) { - // mprintf(0, "click 2\n"); LOCK_FOCUS(this); if (((m_click_time - old_click_time) < UI_DBLCLICK_DELAY)) { if (abs(m_mse_x - m_last_mse_x) < UI_DBLCLICK_MSEDELTA && abs(m_mse_y - m_last_mse_y) < UI_DBLCLICK_MSEDELTA) { @@ -3271,7 +3266,6 @@ void newuiListBox::OnMouseBtnDown(int btn) { if (m_mse_y >= y && m_mse_y <= (y + item.height() - 1)) { if (m_mse_x > m_boffs && m_mse_x < (m_W - m_boffs - 12)) { OnSelect(); - // mprintf(0, "select!\n"); m_nclicks = 0; break; } @@ -3634,7 +3628,7 @@ void newuiComboBox::RemoveItem(const char *name) { } } if (found == -1) { - mprintf(0, "newuiComboBox:: Didn't find item to remove!\n"); + LOG_WARNING << "newuiComboBox:: Didn't find item to remove!"; return; } @@ -3761,7 +3755,7 @@ bool newuiComboBox::SetCurrentItem(const char *name) { } if (!found) { - mprintf(0, "newuiComboBox::SelectItem item not found!\n"); + LOG_WARNING << "newuiComboBox::SelectItem item not found!"; return false; } diff --git a/Descent3/newui_filedlg.cpp b/Descent3/newui_filedlg.cpp index 73bdf9e0..0c831afa 100644 --- a/Descent3/newui_filedlg.cpp +++ b/Descent3/newui_filedlg.cpp @@ -107,7 +107,7 @@ #include "cfile.h" #include "ddio.h" #include "game.h" -#include "mono.h" +#include "log.h" #include "newui.h" #include "pstring.h" #include "renderer.h" @@ -195,7 +195,7 @@ void FileSelectCallback(int index) { strncpy(path_edit, (working_listpath / working_filename).u8string().c_str(), _MAX_PATH - 1); path_edit[_MAX_PATH - 1] = '\0'; - mprintf(0, "New Path: %s\n", path_edit); + LOG_DEBUG.printf("New Path: %s", path_edit); fdlg_working_sheet->UpdateChanges(); } @@ -446,14 +446,14 @@ bool DoPathFileDialog(bool save_dialog, std::filesystem::path &path, const char } } break; default: - mprintf(0, "No operation in DoPathFileDialog()!\n"); + LOG_WARNING << "No operation in DoPathFileDialog()!"; } } if (ret) { - mprintf(0, "Selected Filename: %s\n", path.u8string().c_str()); + LOG_DEBUG.printf("Selected Filename: %s", path.u8string().c_str()); } else { - mprintf(0, "Cancel!\n"); + LOG_DEBUG << "Cancel!"; } window.Close(); @@ -498,7 +498,7 @@ void UpdateFileList(newuiListBox *lb, const std::filesystem::path &path, const s } } catch (std::exception &e) { DoMessageBox(TXT_ERROR, TXT_ERRPATHNOTVALID, MSGBOX_OK); - mprintf(0, "Error iterating directory %s: %s\n", path.u8string().c_str(), e.what()); + LOG_ERROR.printf("Error iterating directory %s: %s", path.u8string().c_str(), e.what()); } if (dirs.size() + files.size() == 0) { diff --git a/Descent3/object.cpp b/Descent3/object.cpp index 6a0c7490..b32d51a1 100644 --- a/Descent3/object.cpp +++ b/Descent3/object.cpp @@ -1129,16 +1129,15 @@ * $NoKeywords: $ */ -#include -#include // for memset -#include +#include + +#include +#include // for memset #include "object.h" #include "pserror.h" #include "vecmat.h" -#include "mono.h" - #include "descent.h" #include "player.h" #include "slew.h" @@ -1150,7 +1149,6 @@ #include "controls.h" #include "terrain.h" #include "polymodel.h" -#include "gametexture.h" #include "ship.h" #include "soundload.h" #include "weapon.h" @@ -1163,7 +1161,6 @@ #include "objinfo.h" #include "lighting.h" #include "findintersection.h" -#include "lightmap_info.h" #include "object_lighting.h" #include "soar.h" #include "splinter.h" @@ -1171,7 +1168,6 @@ #include "viseffect.h" #include "multi.h" #include "game2dll.h" -#include "robot.h" #include "damage.h" #include "attach.h" #include "dedicated_server.h" @@ -1180,17 +1176,15 @@ #include "rtperformance.h" #include "osiris_dll.h" #include "gameloop.h" +#include "log.h" #include "mem.h" #include "stringtable.h" #include "levelgoal.h" -#include "psrand.h" #ifdef EDITOR #include "editor\d3edit.h" #endif -#include - /* * Global variables */ @@ -1568,14 +1562,14 @@ int FreeObjectSlots(int num_used) { original_num_to_free = num_to_free; if (num_to_free > olind) { - mprintf(1, "Warning: Asked to free %i objects, but can only free %i.\n", num_to_free, olind); + LOG_DEBUG.printf("Warning: Asked to free %i objects, but can only free %i.", num_to_free, olind); num_to_free = olind; } for (i = 0; i < num_to_free; i++) if (Objects[obj_list[i]].type == OBJ_DEBRIS) { num_to_free--; - mprintf(0, "Freeing DEBRIS object %3i\n", obj_list[i]); + LOG_DEBUG.printf("Freeing DEBRIS object %3i", obj_list[i]); SetObjectDeadFlag(&Objects[obj_list[i]]); } @@ -1597,7 +1591,7 @@ int FreeObjectSlots(int num_used) { for (i = 0; i < num_to_free; i++) if (Objects[obj_list[i]].type == OBJ_WEAPON) { num_to_free--; - mprintf(0, "Freeing WEAPON object %3i\n", obj_list[i]); + LOG_DEBUG.printf("Freeing WEAPON object %3i", obj_list[i]); SetObjectDeadFlag(&Objects[obj_list[i]]); } @@ -1615,11 +1609,11 @@ int ObjAllocate(void) { int num_freed; num_freed = FreeObjectSlots(MAX_OBJECTS - 10); - mprintf(0, " *** Freed %i objects in frame %i\n", num_freed, FrameCount); + LOG_DEBUG.printf(" *** Freed %i objects in frame %i", num_freed, FrameCount); } if (Num_objects >= MAX_OBJECTS) { - mprintf(1, "Object creation failed - too many objects!\n"); + LOG_DEBUG.printf("Object creation failed - too many objects!"); return -1; } @@ -1629,7 +1623,7 @@ int ObjAllocate(void) { Highest_object_index = objnum; if (Highest_object_index > Highest_ever_object_index) { Highest_ever_object_index = Highest_object_index; - mprintf(0, "Highest ever Object %d\n", Highest_ever_object_index); + LOG_DEBUG.printf("Highest ever Object %d", Highest_ever_object_index); } } @@ -1720,11 +1714,9 @@ int ObjCreate(uint8_t type, uint16_t id, int roomnum, vector *pos, const matrix return -1; } -#ifdef _DEBUG if (print_object_info) { - mprintf(0, "Created object %d of type %d\n", objnum, obj->type); + LOG_DEBUG.printf("Created object %d of type %d", objnum, obj->type); } -#endif // Set the object's orietation // THIS MUST BE DONE AFTER ObjInit (as ObjInit could load in a polymodel and set the anim and wall offsets) @@ -1836,16 +1828,11 @@ void ObjDelete(int objnum) { ObjUnGhostObject(objnum); } - /* if ((Game_mode & GM_MULTI) && Netgame.local_role==LR_CLIENT && Objects[objnum].type==OBJ_POWERUP) - { - mprintf(0,"Deleting object number %d type=%d id=%d\n",objnum,obj->type,obj->id); - }*/ - if ((Game_mode & GM_MULTI) && (obj->flags & OF_SERVER_OBJECT)) { if (Netgame.local_role == LR_CLIENT && NetPlayers[Player_num].sequence > NETSEQ_OBJECTS && NetPlayers[Player_num].sequence != NETSEQ_LEVEL_END) { if (!(obj->flags & OF_SERVER_SAYS_DELETE)) { - mprintf(0, "Illegally deleting server object! Objnum=%d type=%d id=%d\n", objnum, obj->type, obj->id); + LOG_FATAL.printf("Illegally deleting server object! Objnum=%d type=%d id=%d", objnum, obj->type, obj->id); Int3(); return; } @@ -1894,17 +1881,15 @@ void ObjDelete(int objnum) { //?? if (obj->attached_obj != -1) //detach all objects from this //?? obj_detach_all(obj); -#ifdef _DEBUG if (print_object_info) { - mprintf(0, "Deleting object %d of type %d\n", objnum, Objects[objnum].type); + LOG_DEBUG.printf("Deleting object %d of type %d", objnum, Objects[objnum].type); } -#endif if (obj->type == OBJ_WEAPON && obj->ctype.laser_info.parent_type == OBJ_PLAYER) { int pnum = Objects[(obj->parent_handle & HANDLE_OBJNUM_MASK)].id; if (Players[pnum].guided_obj == obj) { - mprintf(0, "Deleting a guided missile!"); + LOG_DEBUG << "Deleting a guided missile!"; Players[pnum].guided_obj = NULL; } } @@ -1913,7 +1898,7 @@ void ObjDelete(int objnum) { int pnum = Objects[(obj->parent_handle & HANDLE_OBJNUM_MASK)].id; if (Players[pnum].user_timeout_obj == obj) { - mprintf(0, "Deleting a timeout missile!"); + LOG_DEBUG << "Deleting a timeout missile!"; Players[pnum].user_timeout_obj = NULL; } } @@ -1933,7 +1918,7 @@ void ObjDelete(int objnum) { Gametime + (Netgame.respawn_time * Object_info[obj->id].respawn_scalar); Powerup_timer[Num_powerup_timer].id = obj->id; Num_powerup_timer++; - mprintf(0, "Adding powerup id %d to respawn list! count=%d\n", obj->id, Num_powerup_timer); + LOG_DEBUG.printf("Adding powerup id %d to respawn list! count=%d", obj->id, Num_powerup_timer); } } } @@ -2138,7 +2123,7 @@ void DoCycledAnim(object *obj) { ASSERT(from <= to); if (obj->rtype.pobj_info.anim_frame < from || obj->rtype.pobj_info.anim_frame > to) { - mprintf(0, "NonAI-Animation: Correcting for an incorrect frame number\n"); + LOG_DEBUG << "NonAI-Animation: Correcting for an incorrect frame number"; obj->rtype.pobj_info.anim_frame = from; } @@ -3016,8 +3001,6 @@ void ObjDoFrameAll() { // Blend all lights that are needed BlendAllLightingEdges(); - mprintf_at(1, 5, 40, "Objs=%d ", objs_live); - // Delete everything that died ObjDeleteDead(); } @@ -3231,7 +3214,7 @@ void ClearTransientObjects(int clear_all) { (objp->type == OBJ_FIREBALL) || (objp->type == OBJ_DEBRIS) || (objp->type == OBJ_SHARD) || (objp->type == OBJ_SHOCKWAVE) || (objp->type == OBJ_PARTICLE) || (objp->type == OBJ_SPLINTER) || ((objp->type != OBJ_NONE) && (objp->flags & OF_DYING))) { - mprintf(0, "Clearing object %d type = %d\n", objnum, objp->type); + LOG_DEBUG.printf("Clearing object %d type = %d", objnum, objp->type); ObjDelete(objnum); } } @@ -3445,7 +3428,7 @@ void ObjSetTurretUpdate(uint16_t objnum, multi_turret *multi_turret_info) { p_info->multi_turret_info.flags = FMT_NEW_DATA; } else { - mprintf(0, "Woops, no turret here to update!\n"); + LOG_DEBUG << "Woops, no turret here to update!"; } } @@ -3502,7 +3485,7 @@ void ObjUnGhostObject(int objnum) { //@@if(obj->flags&OF_INPLAYERINVENTORY) //@@ return; if (obj->flags & OF_INPLAYERINVENTORY) { - mprintf(0, "UnGhosting Object in that is currently in a player's inventory!\n"); + LOG_DEBUG << "UnGhosting Object in that is currently in a player's inventory!"; } obj->type = obj->dummy_type; diff --git a/Descent3/object_lighting.cpp b/Descent3/object_lighting.cpp index 9381b6d7..104703bd 100644 --- a/Descent3/object_lighting.cpp +++ b/Descent3/object_lighting.cpp @@ -86,16 +86,18 @@ * */ +#include + #include "object_lighting.h" #include "object.h" #include "lighting.h" +#include "log.h" #include "objinfo.h" #include "weapon.h" #include "descent.h" #include "game.h" #include "polymodel.h" #include "renderobject.h" -#include #include "lightmap_info.h" #include "fireball.h" #include "player.h" @@ -103,6 +105,10 @@ #include "config.h" #include "findintersection.h" #include "psrand.h" +#include "hlsoundlib.h" +#include "soundload.h" +#include "hud.h" +#include "stringtable.h" // How far the headlight casts light #define HEADLIGHT_DISTANCE 150.0f @@ -375,7 +381,7 @@ void DoObjectLight(object *obj) { int factor = li->flicker_distance; if (factor == 0) { - mprintf(0, "You have a flicker_slightly light that has a flicker factor of zero!\n"); + LOG_WARNING << "You have a flicker_slightly light that has a flicker factor of zero!"; return; } @@ -463,12 +469,9 @@ void ClearObjectLightmaps(object *obj) { poly_model *pm = &Poly_models[obj->rtype.pobj_info.model_num]; ASSERT(pm->n_models < MAX_SUBOBJECTS); - mprintf(1, "CLEAR %d %s", obj->handle, obj->name); - int faceCount = 0; for (Mnum = 0; Mnum < pm->n_models; Mnum++) { if (!IsNonRenderableSubmodel(pm, Mnum)) { - mprintf(1, " %X\n", obj->lm_object.lightmap_faces[Mnum][0].u2); mem_free(obj->lm_object.lightmap_faces[Mnum][0].u2); break; } @@ -528,7 +531,6 @@ void SetupObjectLightmapMemory(object *obj) { ASSERT(pm->n_models < MAX_SUBOBJECTS); int uv2size = 0; - mprintf(1, "SETUP %d %s", obj->handle, obj->name); for (Mnum = 0; Mnum < pm->n_models; Mnum++) { if (IsNonRenderableSubmodel(pm, Mnum)) { obj->lm_object.num_faces[Mnum] = 0; @@ -552,7 +554,6 @@ void SetupObjectLightmapMemory(object *obj) { } if (uv2size) { float *uvblock = (float *)mem_malloc(2 * uv2size * sizeof(float)); - mprintf(1, " %X %d\n", uvblock, uv2size); for (Mnum = 0; Mnum < pm->n_models; Mnum++) { if (!IsNonRenderableSubmodel(pm, Mnum)) { @@ -568,10 +569,7 @@ void SetupObjectLightmapMemory(object *obj) { } // SHOULDN'T THE FOLLOWING TWO FUNCTIONS REALLY BE IN OBJECT.CPP? -#include "hlsoundlib.h" -#include "soundload.h" -#include "hud.h" -#include "stringtable.h" + // makes the an object cloaked void MakeObjectInvisible(object *obj, float time, float fade_time, bool no_hud_message) { if (obj->effect_info) { diff --git a/Descent3/objinfo.cpp b/Descent3/objinfo.cpp index 9c9cd877..842cf155 100644 --- a/Descent3/objinfo.cpp +++ b/Descent3/objinfo.cpp @@ -27,21 +27,16 @@ * $NoKeywords: $ */ -#include "pstypes.h" -#include "pserror.h" +#include +#include + +#include "mem.h" #include "object.h" #include "objinfo.h" -#include "3d.h" -#include -#include -#include -#include #include "polymodel.h" +#include "pserror.h" #include "robotfire.h" -#include "AIMain.h" #include "sounds.h" -#include "stringtable.h" -#include "mem.h" // The array with information for robots, powerups, buildings, etc. object_info Object_info[MAX_OBJECT_IDS]; @@ -117,7 +112,6 @@ int AllocObjectID(int type, bool f_anim, bool f_weapons, bool f_ai) { for (int i = NUM_STATIC_OBJECTS; i < MAX_OBJECT_IDS; i++) { if (Object_info[i].type == OBJ_NONE) { - mprintf(1, "%d ", type); memset(&Object_info[i], 0, sizeof(*Object_info)); extern void AISetDefault(t_ai_info * ai_info_ptr); diff --git a/Descent3/osiris_predefs.cpp b/Descent3/osiris_predefs.cpp index 1d2fef4a..55714695 100644 --- a/Descent3/osiris_predefs.cpp +++ b/Descent3/osiris_predefs.cpp @@ -430,10 +430,11 @@ * * $NoKeywords: $ */ -#include +#include + #include "osiris_predefs.h" #include "object.h" -#include "mono.h" +#include "log.h" #include "trigger.h" #include "pstypes.h" #include "pserror.h" @@ -451,7 +452,6 @@ #include "matcen.h" #include "findintersection.h" #include "controls.h" -#include "Controller.h" #include "ship.h" #include "Mission.h" #include "osiris_share.h" @@ -556,19 +556,19 @@ int osipf_AIGoalFollowPathSimple(int objhandle, int path_id, int guid, int flags path_information path_info; if (!obj) { - mprintf(0, "Illegal object passed to AIGoalFollowPathSimple\n"); + LOG_ERROR << "Illegal object passed to AIGoalFollowPathSimple"; return -1; } if (path_id == -1) { - mprintf(0, "Illegal Path Id Passed To AIGoalFollowPathSimple\n"); + LOG_FATAL << "Illegal Path Id Passed To AIGoalFollowPathSimple"; Int3(); return -1; } if (obj->control_type != CT_AI) { // Can happen if e.g. the object died this tick, and Osiris was called with EVT_INTERNAL in the same tick. - mprintf(0, "Object with illegal CT passed to AIGoalFollowPathSimple: handle=%u type=%u name=%s\n", obj->handle, obj->type, obj->name); + LOG_ERROR << "Illegal Object CT Passed To AIGoalFollowPathSimple"; return -1; } @@ -588,7 +588,7 @@ int osipf_AIGoalFollowPathSimple(int objhandle, int path_id, int guid, int flags int osipf_AIPowerSwitch(int objhandle, uint8_t f_power_on) { object *obj = ObjGet(objhandle); if (!obj) { - mprintf(0, "Illegal Object passed to AIPowerSwitch\n"); + LOG_ERROR << "Illegal Object passed to AIPowerSwitch"; return -1; } @@ -605,7 +605,7 @@ void osipf_SoundTouch(char *str) { int id = FindSoundName(IGNORE_TABLE(str)); if (id == -1) { - mprintf(0, "Sound %s was not found. Unable to touch.\n", str); + LOG_FATAL.printf("Sound %s was not found. Unable to touch.", str); Int3(); } else Sound_system.CheckAndForceSoundDataAlloc(id); @@ -617,7 +617,7 @@ void osipf_RoomValue(int roomnum, char op, char vtype, void *ptr, int index) { if (vtype == RMV_C_USED) *(char *)ptr = 0; else - mprintf(0, "RoomValue: Illegal Room Passed\n"); + LOG_ERROR << "RoomValue: Illegal Room Passed"; return; } @@ -742,7 +742,7 @@ void osipf_PlayerValue(int obj_handle, char op, char vhandle, void *ptr, int ind objp = ObjGet(obj_handle); if (!objp || (!(objp->type == OBJ_PLAYER || objp->type == OBJ_GHOST || objp->type == OBJ_OBSERVER))) { - mprintf(0, "Player Value: Illegal Object Passed\n"); + LOG_ERROR << "Player Value: Illegal Object Passed"; return; } @@ -891,7 +891,7 @@ void osipf_ObjectCustomAnim(int handle, float start, float end, float time, char object *objp = ObjGet(handle); if (!objp) { - mprintf(0, "AIValue: Illegal Object Passed\n"); + LOG_ERROR << "AIValue: Illegal Object Passed"; return; } @@ -907,7 +907,7 @@ void osipf_ObjectCustomAnim(int handle, float start, float end, float time, char if (objp->ai_info) objp->ai_info->next_animation_type = AS_CUSTOM; else - mprintf(0, "ERROR: Changing animation for non-AI object.\n"); + LOG_ERROR << "ERROR: Changing animation for non-AI object."; if (flags & AIAF_IMMEDIATE) { AIUpdateAnim(objp); @@ -936,7 +936,7 @@ float osipf_ObjectGetTimeLived(int objhandle) { object *objp = ObjGet(objhandle); if (!objp) { - mprintf(0, "Illegal object passed to ObjectGetTimeLived\n"); + LOG_ERROR << "Illegal object passed to ObjectGetTimeLived"; return 0; } @@ -947,12 +947,12 @@ void osipf_AIValue(int objhandle, char op, char vtype, void *ptr) { object *objp = ObjGet(objhandle); if (!objp) { - mprintf(0, "AIValue: Illegal Object Passed\n"); + LOG_ERROR << "AIValue: Illegal Object Passed"; return; } if ((objp->control_type != CT_AI) && (objp->control_type != CT_DYING_AND_AI)) { - mprintf(0, "AIValue: Illegal Object CT Passed\n"); + LOG_ERROR << "AIValue: Illegal Object CT Passed"; return; } @@ -1636,12 +1636,12 @@ uint8_t osipf_AITurnTowardsVectors(int objhandle, vector *fvec, vector *uvec) { object *objp = ObjGet(objhandle); if (!objp) { - mprintf(0, "AITurnTowardsVectors: Illegal Object Passed\n"); + LOG_ERROR << "AITurnTowardsVectors: Illegal Object Passed"; return 0; } if (objp->control_type != CT_AI) { - mprintf(0, "AITurnTowardsVectors: Illegal Object CT Passed\n"); + LOG_ERROR << "AITurnTowardsVectors: Illegal Object CT Passed"; return 0; } @@ -1655,12 +1655,12 @@ void osipf_AISetType(int objhandle, int type) { object *objp = ObjGet(objhandle); if (!objp) { - mprintf(0, "AISetType: Illegal Object Passed\n"); + LOG_ERROR << "AISetType: Illegal Object Passed"; return; } if (objp->control_type != CT_AI) { - mprintf(0, "AISetType: Illegal Object CT Passed\n"); + LOG_ERROR << "AISetType: Illegal Object CT Passed"; return; } @@ -1678,28 +1678,28 @@ vector osipf_AIFindHidePos(int hideobjhandle, int viewobjhandle, float time, int int hroom; if (hide_obj == NULL) { - mprintf(0, "Illegal Hide Object Passed To AIFindHidePos\n"); + LOG_ERROR << "Illegal Hide Object Passed To AIFindHidePos"; *hide_room = -1; return Zero_vector; } if (hide_obj->control_type != CT_AI) { - mprintf(0, "Illegal Object CT Passed To AIFindHidePos\n"); + LOG_ERROR << "Illegal Object CT Passed To AIFindHidePos"; *hide_room = -1; return Zero_vector; } if (view_obj == NULL) { - mprintf(0, "Illegal View Object Passed To AIFindHidePos\n"); + LOG_ERROR << "Illegal View Object Passed To AIFindHidePos"; *hide_room = hide_obj->roomnum; return hide_obj->pos; } if (time <= 0.0) { - mprintf(0, "AIFindHidePos: Illegal Time Passed bashing to 1sec\n"); + LOG_ERROR << "AIFindHidePos: Illegal Time Passed bashing to 1sec"; time = 1.0f; } else if (time > 15.0) { - mprintf(0, "AIFindHidePos: Illegal Time Passed bashing to 15sec\n"); + LOG_ERROR << "AIFindHidePos: Illegal Time Passed bashing to 15sec"; time = 15.0f; } @@ -1716,7 +1716,7 @@ int osipf_AIGoalAddEnabler(int objhandle, int goal_index, int enabler_type, floa obj = ObjGet(objhandle); if (obj == NULL || obj->ai_info == NULL) { - mprintf(0, "Illegal object passed to AIGoalAddEnabler\n"); + LOG_ERROR << "Illegal object passed to AIGoalAddEnabler"; return -1; } @@ -1733,7 +1733,7 @@ int osipf_AIGoalAdd(int objhandle, int goal_type, int level, float influence, in obj = ObjGet(objhandle); if (obj == NULL || obj->ai_info == NULL) { - mprintf(0, "Illegal object passed to AIGoalAdd\n"); + LOG_ERROR << "Illegal object passed to AIGoalAdd"; return -1; } @@ -1896,7 +1896,7 @@ int osipf_AIGoalAdd(int objhandle, int goal_type, int level, float influence, in } break; default: - mprintf(0, "AIGoalAdd Error: Get chris - goal %d is not available of scripting\n", goal_type); + LOG_ERROR.printf("AIGoalAdd Error: Get chris - goal %d is not available of scripting", goal_type); } return -1; @@ -1906,12 +1906,12 @@ void osipf_AIGoalClear(int objhandle, int goal_index) { object *obj = ObjGet(objhandle); if (obj == NULL) { - mprintf(0, "Invalid Object Passed To AIGoalClear\n"); + LOG_ERROR << "Invalid Object Passed To AIGoalClear"; return; } if (obj->control_type != CT_AI) { - mprintf(0, "AIGoalClear: Illegal Object CT Passed\n"); + LOG_ERROR << "AIGoalClear: Illegal Object CT Passed"; return; } @@ -1927,7 +1927,7 @@ int osipf_AIFindObjOfType(int objhandle, int type, int id, bool f_ignore_init_ro object *f_obj; if (obj == NULL) { - mprintf(0, "Illegal Object Passed To AIFindObjOfType\n"); + LOG_ERROR << "Illegal Object Passed To AIFindObjOfType"; return OBJECT_HANDLE_NONE; } @@ -1945,7 +1945,7 @@ int osipf_ObjMakeListOfType(int objhandle, int type, int id, bool f_ignore_init_ int i; if (obj == NULL) { - mprintf(0, "Illegal Object Passed To Obj_MakeListOfType\n"); + LOG_ERROR << "Illegal Object Passed To Obj_MakeListOfType"; return OBJECT_HANDLE_NONE; } @@ -2001,7 +2001,7 @@ int osipf_AIFindEnergyCenter(int objhandle) { object *obj = ObjGet(objhandle); if (obj == NULL) { - mprintf(0, "Illegal Object Passed To AIFindEnergyCenter\n"); + LOG_ERROR << "Illegal Object Passed To AIFindEnergyCenter"; return -1; } @@ -2016,12 +2016,12 @@ float osipf_AIGetDistToObj(int objhandle, int otherobjhandle) { float dist; if (obj == NULL) { - mprintf(0, "Illegal Object Passed To AIGetDistToObj\n"); + LOG_ERROR << "Illegal Object Passed To AIGetDistToObj"; return 0; } if (fobj == NULL) { - mprintf(0, "Illegal Find Object Passed To AIGetDistToObj\n"); + LOG_ERROR << "Illegal Find Object Passed To AIGetDistToObj"; return 0; } @@ -2034,12 +2034,12 @@ int osipf_AISetGoalFlags(int objhandle, int goal_handle, int flags, uint8_t f_en object *obj = ObjGet(objhandle); if (obj == NULL) { - mprintf(0, "Illegal Object Passed To AISetGoalFlags\n"); + LOG_ERROR << "Illegal Object Passed To AISetGoalFlags"; return 0; } if (obj->control_type != CT_AI) { - mprintf(0, "Non-AI Object Passed To AISetGoalFlags\n"); + LOG_ERROR << "Non-AI Object Passed To AISetGoalFlags"; return 0; } @@ -2059,12 +2059,12 @@ void osipf_AISetGoalCircleDist(int objhandle, int goal_handle, float dist) { object *obj = ObjGet(objhandle); if (obj == NULL) { - mprintf(0, "Illegal Object Passed To AISetGoalCircleDist\n"); + LOG_ERROR << "Illegal Object Passed To AISetGoalCircleDist"; return; } if (obj->control_type != CT_AI) { - mprintf(0, "Non-AI Object Passed To AISetGoalCircleDist\n"); + LOG_ERROR << "Non-AI Object Passed To AISetGoalCircleDist"; return; } @@ -2079,7 +2079,7 @@ void osipf_GetGunPos(int objhandle, int gun_number, vector *gun_pnt, vector *gun object *obj = ObjGet(objhandle); if (obj == NULL) { - mprintf(0, "Illegal Object Passed To AIGetGunPosition\n"); + LOG_ERROR << "Illegal Object Passed To AIGetGunPosition"; *gun_pnt = Zero_vector; *gun_normal = Zero_vector; return; @@ -2092,7 +2092,7 @@ void osipf_GetGroundPos(int objhandle, int ground_number, vector *ground_pnt, ve object *obj = ObjGet(objhandle); if (obj == NULL) { - mprintf(0, "Illegal Object Passed To Obj_GetGroundPos\n"); + LOG_ERROR << "Illegal Object Passed To Obj_GetGroundPos"; *ground_pnt = Zero_vector; *ground_normal = Zero_vector; return; @@ -2402,7 +2402,7 @@ int osipf_RayCast(int objhandle, vector *p0, vector *p1, int start_roomnum, floa int *ilist = hack_ilist; object *obj = ObjGet(objhandle); if (!obj && objhandle != OBJECT_HANDLE_NONE) { - mprintf(0, "Invalid object passed to RayCast\n"); + LOG_ERROR << "Invalid object passed to RayCast"; return 0; } @@ -2638,12 +2638,12 @@ void osipf_ObjWBValue(int obj_handle, char wb_index, char op, char vtype, void * object *objp = ObjGet(obj_handle); if (!objp) { - mprintf(0, "Obj_WBValue: Illegal Object Passed\n"); + LOG_ERROR << "Obj_WBValue: Illegal Object Passed"; return; } if (objp->control_type != CT_AI && objp->type != OBJ_PLAYER && objp->type != OBJ_OBSERVER) { - mprintf(0, "Obj_WBValue: Illegal Object CT Passed\n"); + LOG_ERROR << "Obj_WBValue: Illegal Object CT Passed"; return; } @@ -2794,7 +2794,7 @@ void osipf_ObjWBValue(int obj_handle, char wb_index, char op, char vtype, void * // value is 0 to clear, or 1 to set void osipf_MissionFlagSet(int flag, uint8_t value) { if (flag < 1 && flag > 32) { - mprintf(0, "Invalid flag passed to osipf_MissionFlagSet(%d)\n", flag); + LOG_ERROR.printf("Invalid flag passed to osipf_MissionFlagSet(%d)", flag); return; } @@ -2813,7 +2813,7 @@ void osipf_MissionFlagSet(int flag, uint8_t value) { // flag is what mission flag to get. Returns 1 if set, 0 if not. int osipf_MissionFlagGet(int flag) { if (flag < 1 && flag > 32) { - mprintf(0, "Invalid flag passed to osipf_MissionFlagGet(%d)\n", flag); + LOG_ERROR.printf("Invalid flag passed to osipf_MissionFlagGet(%d)\n", flag); return 0; } @@ -3696,7 +3696,7 @@ void osipf_PathValue(int path_id, int node_id, char op, int changes, void *ptr) } if (path_id < 0 || path_id >= Num_game_paths) { - mprintf(0, "Invalid Path\n"); + LOG_FATAL << "Invalid Path"; Int3(); return; } @@ -3710,7 +3710,7 @@ void osipf_PathValue(int path_id, int node_id, char op, int changes, void *ptr) if (op == VF_GET) { if (changes & PV_ALL) { if (node_id < 0 || node_id >= cpath->num_nodes) { - mprintf(0, "Invalid node on path\n"); + LOG_FATAL << "Invalid node on path"; Int3(); return; } @@ -3752,7 +3752,7 @@ void osipf_PathValue(int path_id, int node_id, char op, int changes, void *ptr) } else if (op == VF_SET) { if (changes & PV_ALL) { if (node_id < 0 || node_id >= cpath->num_nodes) { - mprintf(0, "Invalid node on path\n"); + LOG_FATAL << "Invalid node on path"; Int3(); return; } diff --git a/Descent3/pilot.cpp b/Descent3/pilot.cpp index c9a8e335..284ced02 100644 --- a/Descent3/pilot.cpp +++ b/Descent3/pilot.cpp @@ -591,9 +591,9 @@ #include "gametexture.h" #include "hud.h" #include "init.h" +#include "log.h" #include "manage.h" #include "mem.h" -#include "mono.h" #include "newui.h" #include "pilot.h" #include "polymodel.h" @@ -861,9 +861,9 @@ void PilotListSelectChangeCallback(int index) { Pilot->set_difficulty(difficulty); Pilot->set_audiotaunts(audiotaunts); PltWriteFile(&working_pilot); - mprintf(0, "Pilot saved\n"); + LOG_INFO << "Pilot saved"; } else { - mprintf(0, "Skipping pilot save...has the old pilot been deleted?\n"); + LOG_INFO << "Skipping pilot save...has the old pilot been deleted?"; } working_pilot.clean(true); @@ -884,7 +884,7 @@ void PilotListSelectChangeCallback(int index) { if (in_edit) PilotChooseDialogInfo.edit->sheet->UpdateChanges(); Pilot->get_name(name); - mprintf(0, "Pilot has changed to: %s\n", name); + LOG_INFO.printf("Pilot has changed to: %s", name); if (PilotChooseDialogInfo.edit->pilot_name) { strncpy(PilotChooseDialogInfo.edit->pilot_name, name, 63); @@ -1003,11 +1003,11 @@ void PilotSelect() { char pname[PILOT_STRING_SIZE]; Current_pilot.get_name(pname); - mprintf(0, "Pilot To Use: %s\n", pname); + LOG_INFO.printf("Pilot To Use: %s", pname); if (VerifyPilotData(&Current_pilot)) { // save out updated pilot since it had to be fixed - mprintf(0, "PILOT: Saving out Pilot info due to bad data in pilot file\n"); + LOG_DEBUG.printf("PILOT: Saving out Pilot info due to bad data in pilot file"); PltWriteFile(&Current_pilot); } @@ -1042,10 +1042,10 @@ void PilotSelect() { char pname[PILOT_STRING_SIZE]; Current_pilot.get_name(pname); - mprintf(0, "Pilot To Use: %s\n", pname); + LOG_INFO.printf("Pilot To Use: %s", pname); if (VerifyPilotData(&Current_pilot)) { // save out updated pilot since it had to be fixed - mprintf(0, "PILOT: Saving out Pilot info due to bad data in pilot file\n"); + LOG_DEBUG.printf("PILOT: Saving out Pilot info due to bad data in pilot file"); PltWriteFile(&Current_pilot); } done = true; @@ -1228,7 +1228,7 @@ bool PilotCreate(pilot *Pilot, bool forceselection) { to_ret = false; } } else { - mprintf(0, "Creating Pilot!"); + LOG_INFO << "Creating Pilot!"; // call this to initialize pilot data for player. PilotInitData(Pilot); @@ -1336,7 +1336,7 @@ void PilotCopyDefaultControls(pilot *Pilot) { if (cfexist(spfilename)) { PltCopyKeyConfig(&s_pil, Pilot); } else { - mprintf(0, "%s does not exist...not copying\n", spfilename.c_str()); + LOG_FATAL.printf("%s does not exist... not copying", spfilename.c_str()); Int3(); } } @@ -1447,7 +1447,7 @@ void NewPltUpdate(newuiListBox *list, int selected, const std::string &filename) if (!filename.empty() && (cfexist(filename) != CFES_NOT_FOUND)) { // get the selected pilot from the filename - mprintf(0, "Looking for Pilot: %s\n", filename.c_str()); + LOG_INFO.printf("Looking for Pilot: %s", filename.c_str()); for (int d = 0; d < filecount; d++) { if (stricmp(filelist[d].c_str(), filename.c_str()) == 0) { // ok we found the filename that they want as the pilot @@ -1474,7 +1474,7 @@ void CurrentPilotUpdateMissionStatus(bool just_add_data) { if (index == -1) { // this mission doesn't exist for the pilot yet, so add the mission to the pilot - mprintf(0, "PILOT: New Mission being added to mission data (%s)\n", Current_mission.name); + LOG_INFO.printf("PILOT: New Mission being added to mission data (%s)", Current_mission.name); mission_to_use.highest_level = 0; mission_to_use.finished = false; mission_to_use.num_restores = 0; @@ -1490,7 +1490,7 @@ void CurrentPilotUpdateMissionStatus(bool just_add_data) { } else { // this pilot has flown this mission before, just update it - mprintf(0, "PILOT: Updating previously flown mission data (%s)\n", Current_mission.name); + LOG_INFO.printf("PILOT: Updating previously flown mission data (%s)", Current_mission.name); Current_pilot.get_mission_data(index, &mission_to_use); } @@ -1645,7 +1645,7 @@ void PltReadFile(pilot *Pilot, bool keyconfig, bool missiondata) { filever = cf_ReadInt(file); cfclose(file); } catch (...) { - mprintf(0, "File exception has occured\n"); + LOG_FATAL << "File exception has occurred"; Int3(); Error(TXT_MAJORPLTERROR); return; @@ -1662,7 +1662,7 @@ void PltReadFile(pilot *Pilot, bool keyconfig, bool missiondata) { try { _ReadOldPilotFile(Pilot, keyconfig, missiondata); } catch (...) { - mprintf(0, "File exception has occured\n"); + LOG_FATAL << "File exception has occurred"; Int3(); Error(TXT_MAJORPLTERROR); return; @@ -1704,16 +1704,16 @@ std::vector PltGetPilots(std::string ignore_filename, int display_d ddio_DoForeachFile(search, wildcard, [&ignore_filename, &result](const std::filesystem::path &path) { std::string pilot = path.filename().u8string(); if (!ignore_filename.empty() && stricmp(ignore_filename.c_str(), pilot.c_str()) == 0) { - mprintf(0, "Getting Pilots... found %s, but ignoring\n", pilot.c_str()); + LOG_INFO.printf("Getting Pilots... found %s, but ignoring", pilot.c_str()); } else { - mprintf(0, "Getting Pilots... found %s\n", pilot.c_str()); + LOG_INFO.printf("Getting Pilots... found %s", pilot.c_str()); result.push_back(pilot); filecount++; } }); } - mprintf(0, "Found %d pilots\n", filecount); + LOG_INFO.printf("Found %d pilots", filecount); return result; } @@ -1908,7 +1908,7 @@ bool CreateCRCFileName(const std::filesystem::path &src, std::filesystem::path & uint32_t crc_value = cf_GetfileCRC(src); if (crc_value == 0) { - mprintf(0, "CRC WARNING: A CRC of 0 HAS BEEN GENERATED!\n"); + LOG_WARNING << "CRC WARNING: A CRC of 0 HAS BEEN GENERATED!"; } char hex_string[10]; snprintf(hex_string, sizeof(hex_string), "_%08X", crc_value); @@ -1934,7 +1934,7 @@ bool CreateCRCFileName(const std::filesystem::path &src, std::filesystem::path & uint32_t crc_value = cf_GetfileCRC(src); if (crc_value == 0) { - mprintf(0, "CRC WARNING: A CRC of 0 HAS BEEN GENERATED!\n"); + LOG_WARNING << "CRC WARNING: A CRC of 0 HAS BEEN GENERATED!"; } char hex_string[10]; snprintf(hex_string, sizeof(hex_string), "_%08X", crc_value); @@ -1954,7 +1954,7 @@ bool CreateCRCFileName(const std::filesystem::path &src, std::filesystem::path & bool ImportGraphic(const char *pathname, char *newfile) { ASSERT(pathname); if (cfexist(pathname) != CFES_ON_DISK) { - mprintf(0, "'%s' not found\n", pathname); + LOG_WARNING.printf("'%s' not found", pathname); return false; } @@ -1971,13 +1971,13 @@ bool ImportGraphic(const char *pathname, char *newfile) { if (!ddio_GetTempFileName(Descent3_temp_directory, "d3i", tempfilename)) { // there was an error trying to create a temporary filename bm_FreeBitmap(bm_handle); - mprintf(0, "Error creating temp filename\n"); + LOG_WARNING << "Error creating temp filename"; return false; } // save out the file if (bm_SaveFileBitmap(tempfilename, bm_handle) == -1) { - mprintf(0, "Error importing\n"); + LOG_WARNING << "Error importing"; bm_FreeBitmap(bm_handle); return false; } @@ -1989,7 +1989,7 @@ bool ImportGraphic(const char *pathname, char *newfile) { std::filesystem::path p; if (!CreateCRCFileName(tempfilename, filename, p)) { - mprintf(0, "Error creating CRC File\n"); + LOG_WARNING << "Error creating CRC File"; std::error_code ec; std::filesystem::remove(tempfilename, ec); return false; @@ -2006,13 +2006,13 @@ bool ImportGraphic(const char *pathname, char *newfile) { // tempfilename contains old filename bm_handle = bm_AllocLoadFileBitmap(IGNORE_TABLE(tempfilename), 0); if (bm_handle <= BAD_BITMAP_HANDLE) { - mprintf(0, "Error reloading bitmap for rename\n"); + LOG_WARNING << "Error reloading bitmap for rename"; std::filesystem::remove(tempfilename, ec); return false; } if (bm_SaveFileBitmap(p, bm_handle) == -1) { - mprintf(0, "Error importing\n"); + LOG_WARNING << "Error importing"; bm_FreeBitmap(bm_handle); std::filesystem::remove(tempfilename, ec); return false; @@ -2404,7 +2404,7 @@ bool PltSelectShip(pilot *Pilot) { // find the ship in the page int index = FindShipName(DEFAULT_SHIP); if (index == -1) { - mprintf(0, "WARNING: CAN'T FIND DEFAULT SHIP IN TABLE\n"); + LOG_WARNING << "WARNING: CAN'T FIND DEFAULT SHIP IN TABLE"; } else { // go through all the id's of the ships we found and find the ship (if FindShipName found it, // then we'll have it here somewhere. @@ -2418,7 +2418,7 @@ bool PltSelectShip(pilot *Pilot) { } // end else } else { // NO SHIPS IN THE TABLE!!! - mprintf(0, "WARNING: NO SHIPS IN THE TABLE!?\n"); + LOG_WARNING << "WARNING: NO SHIPS IN THE TABLE!?"; } } @@ -2488,10 +2488,10 @@ bool PltSelectShip(pilot *Pilot) { char audio1[PAGENAME_LEN], audio2[PAGENAME_LEN], audio3[PAGENAME_LEN], audio4[PAGENAME_LEN]; Pilot->get_multiplayer_data(nullptr, audio1, audio2, nullptr, audio3, audio4); - mprintf(0, "Audio #1: '%s'\n", audio1); - mprintf(0, "Audio #2: '%s'\n", audio2); - mprintf(0, "Audio #3: '%s'\n", audio3); - mprintf(0, "Audio #4: '%s'\n", audio4); + LOG_INFO.printf("Audio #1: '%s'", audio1); + LOG_INFO.printf("Audio #2: '%s'", audio2); + LOG_INFO.printf("Audio #3: '%s'", audio3); + LOG_INFO.printf("Audio #4: '%s'", audio4); ret = true; exit_menu = true; @@ -2557,49 +2557,14 @@ bool PltSelectShip(pilot *Pilot) { } } } break; - case ID_PLAY1: { - // Play audio taunt #1 if isn't selected + case ID_PLAY1: + case ID_PLAY2: + case ID_PLAY3: + case ID_PLAY4: { int index = taunts_lists.taunt_a->GetCurrentIndex(); if (index > 0 && !Audio_taunts.empty()) { std::filesystem::path path = LocalCustomSoundsDir / Audio_taunts[index - 1]; - mprintf(0, "Playing: %s\n", path.u8string().c_str()); - bool cenable = taunt_AreEnabled(); - taunt_Enable(true); - taunt_PlayTauntFile(path.u8string().c_str()); - taunt_Enable(cenable); - } - } break; - case ID_PLAY2: { - // Play audio taunt #2 if isn't selected - int index = taunts_lists.taunt_b->GetCurrentIndex(); - if (index > 0 && !Audio_taunts.empty()) { - std::filesystem::path path = LocalCustomSoundsDir / Audio_taunts[index - 1]; - mprintf(0, "Playing: %s\n", path.u8string().c_str()); - bool cenable = taunt_AreEnabled(); - taunt_Enable(true); - taunt_PlayTauntFile(path.u8string().c_str()); - taunt_Enable(cenable); - } - } break; - case ID_PLAY3: { - // Play audio taunt #3 if isn't selected - int index = taunts_lists.taunt_c->GetCurrentIndex(); - if (index > 0 && !Audio_taunts.empty()) { - std::filesystem::path path = LocalCustomSoundsDir / Audio_taunts[index - 1]; - mprintf(0, "Playing: %s\n", path.u8string().c_str()); - bool cenable = taunt_AreEnabled(); - taunt_Enable(true); - taunt_PlayTauntFile(path.u8string().c_str()); - taunt_Enable(cenable); - } - } break; - - case ID_PLAY4: { - // Play audio taunt #4 if isn't selected - int index = taunts_lists.taunt_d->GetCurrentIndex(); - if (index > 0 && !Audio_taunts.empty()) { - std::filesystem::path path = LocalCustomSoundsDir / Audio_taunts[index - 1]; - mprintf(0, "Playing: %s\n", path.u8string().c_str()); + LOG_INFO.printf("Playing: %s", path.u8string().c_str()); bool cenable = taunt_AreEnabled(); taunt_Enable(true); taunt_PlayTauntFile(path.u8string().c_str()); @@ -2621,7 +2586,7 @@ bool PltSelectShip(pilot *Pilot) { std::filesystem::path tempfile = std::filesystem::path(LocalCustomSoundsDir) / filename; // import the sound - mprintf(0, "Importing: '%s'->'%s'\n", path.u8string().c_str(), tempfile.u8string().c_str()); + LOG_INFO.printf("Importing: '%s'->'%s'", path.u8string().c_str(), tempfile.u8string().c_str()); if (taunt_ImportWave(path.u8string().c_str(), tempfile.u8string().c_str())) { // success @@ -2761,7 +2726,7 @@ void CustomCallBack(int c) { if (c == 0) { // None selected custom_texture[0] = '\0'; - mprintf(0, "None selected\n"); + LOG_INFO << "None selected"; bmpwindow->SetInfo(false, -1); GameTextures[ship_pos.texture_id].flags &= ~TF_ANIMATED; GameTextures[ship_pos.texture_id].flags &= ~TF_TEXTURE_32; @@ -2789,7 +2754,8 @@ void CustomCallBack(int c) { bmpwindow->SetInfo(ship_pos.texture_type ? true : false, ship_pos.bm_handle); - mprintf(0, "Loaded texture (%s). Type=%d, ID=%d\n", custom_texture, ship_pos.texture_type, ship_pos.texture_id); + LOG_INFO.printf("Loaded texture (%s). Type=%d, ID=%d", + custom_texture, ship_pos.texture_type, ship_pos.texture_id); } else goto load_texture_err; } @@ -2803,7 +2769,7 @@ load_texture_err: GameTextures[ship_pos.texture_id].flags |= TF_TEXTURE_64; GameTextures[ship_pos.texture_id].bm_handle = BAD_BITMAP_HANDLE; strcpy(custom_texture, ""); - mprintf(0, "Unable to load texture\n"); + LOG_INFO << "Unable to load texture"; bmpwindow->SetInfo(false, -1); } @@ -2815,7 +2781,7 @@ void ShipSelectCallBack(int c) { float size; ship_model = Ships[lp_ship_info->idlist[c]].model_handle; if (ship_model == -1) { - mprintf(0, "ship_model is -1\n"); + LOG_FATAL << "ship_model is -1"; Int3(); } @@ -2839,14 +2805,14 @@ void ShipSelectDeleteLogo(newuiListBox *lb) { // check for None selected if (selected_index == 0) { - mprintf(0, "Listbox selected item is None\n"); + LOG_INFO << "Listbox selected item is None"; return; } lb->GetItem(selected_index, custom_logoname, 384); if ((selected_index - 1) >= (int)Custom_images.size()) { - mprintf(0, "Listbox selected item not found\n"); + LOG_FATAL << "Listbox selected item not found"; Int3(); return; } @@ -2858,14 +2824,14 @@ void ShipSelectDeleteLogo(newuiListBox *lb) { char buffer[512]; snprintf(buffer, sizeof(buffer), TXT_PLTOKDEL, custom_logoname); if (DoMessageBox(TXT_PLTDELCONF, buffer, MSGBOX_YESNO, UICOL_WINDOW_TITLE, UICOL_TEXT_NORMAL)) { - mprintf(0, "Deleting pilot logo %s (%s)\n", custom_logoname, custom_filename); + LOG_INFO.printf("Deleting pilot logo %s (%s)", custom_logoname, custom_filename); std::error_code ec; if (std::filesystem::remove(LocalCustomGraphicsDir / p, ec)) { // Update the list box, select none UpdateGraphicsListbox(lb); } else { - mprintf(0, "Unable to delete file %s\n", custom_filename); + LOG_FATAL.printf("Unable to delete file %s", custom_filename); Int3(); } } @@ -2882,14 +2848,14 @@ void ShipSelectDeleteTaunt(pilot *Pilot, newuiComboBox *lb, tAudioTauntComboBoxe // check for None selected if (selected_index == 0) { - mprintf(0, "Listbox selected item is None\n"); + LOG_INFO << "Listbox selected item is None"; return; } lb->GetItem(selected_index, custom_logoname, 384); if ((selected_index - 1) >= (int)Audio_taunts.size()) { - mprintf(0, "Listbox selected item not found\n"); + LOG_FATAL << "Listbox selected item not found"; Int3(); return; } @@ -2901,7 +2867,7 @@ void ShipSelectDeleteTaunt(pilot *Pilot, newuiComboBox *lb, tAudioTauntComboBoxe char buffer[512]; snprintf(buffer, sizeof(buffer), TXT_PLTOKDEL, custom_logoname); if (DoMessageBox(TXT_PLTDELCONF, buffer, MSGBOX_YESNO, UICOL_WINDOW_TITLE, UICOL_TEXT_NORMAL)) { - mprintf(0, "Deleting audio taunt %s (%s)\n", custom_logoname, custom_filename); + LOG_INFO.printf("Deleting audio taunt %s (%s)", custom_logoname, custom_filename); std::error_code ec; if (std::filesystem::remove(LocalCustomSoundsDir / p, ec)) { @@ -2909,7 +2875,7 @@ void ShipSelectDeleteTaunt(pilot *Pilot, newuiComboBox *lb, tAudioTauntComboBoxe UpdateAudioTauntBoxes(taunt_boxes->taunt_a, taunt_boxes->taunt_b, taunt_boxes->taunt_c, taunt_boxes->taunt_d, Pilot); } else { - mprintf(0, "Unable to delete file %s\n", custom_filename); + LOG_FATAL.printf("Unable to delete file %s", custom_filename); Int3(); } } @@ -2930,7 +2896,7 @@ void UI3DWindow::OnDraw() { rend_SetFlatColor(0); if (ship_model == -1) { - mprintf(0, "Shipmodel is -1\n"); + LOG_WARNING << "Shipmodel is -1"; return; } @@ -3104,7 +3070,7 @@ void ShowPilotPicDialogListCallback(int index) { if (index <= PPicDlgInfo.size) { int handle = PPic_GetBitmapHandle(PPicDlgInfo.id_list[index - 1]); if (handle <= BAD_BITMAP_HANDLE) { - mprintf(0, "Couldn't get ID#%d's bitmap\n", PPicDlgInfo.id_list[index - 1]); + LOG_WARNING.printf("Couldn't get ID#%d's bitmap", PPicDlgInfo.id_list[index - 1]); Int3(); PPicDlgInfo.curr_bmp = PPicDlgInfo.blank_bmp; new_idx = 0; @@ -3112,7 +3078,7 @@ void ShowPilotPicDialogListCallback(int index) { PPicDlgInfo.curr_bmp = handle; } } else { - mprintf(0, "Invalid index\n"); + LOG_FATAL << "Invalid index"; Int3(); PPicDlgInfo.curr_bmp = PPicDlgInfo.blank_bmp; new_idx = 0; @@ -3147,7 +3113,7 @@ void ShowPilotPicDialog(pilot *Pilot) { // only display the dialog if there is a pilot to choose from if (num_pilots == 0) { - mprintf(0, "No Pilot Pics available for %s\n", pname); + LOG_INFO.printf("No Pilot Pics available for %s", pname); uint16_t pid; pid = PPIC_INVALID_ID; Pilot->set_multiplayer_data(nullptr, nullptr, nullptr, &pid); @@ -3162,7 +3128,7 @@ void ShowPilotPicDialog(pilot *Pilot) { pid = PPIC_INVALID_ID; Pilot->set_multiplayer_data(nullptr, nullptr, nullptr, &pid); - mprintf(0, "Couldn't alloc bitmap\n"); + LOG_WARNING << "Couldn't alloc bitmap"; DoMessageBox(TXT_ERROR, TXT_ERRCREATINGDIALOG, MSGBOX_OK, UICOL_WINDOW_TITLE, UICOL_TEXT_NORMAL); return; } @@ -3203,7 +3169,7 @@ void ShowPilotPicDialog(pilot *Pilot) { if (!id_list) { // out of memory - mprintf(0, "Out of memory\n"); + LOG_ERROR << "Out of memory"; goto clean_up; } diff --git a/Descent3/pilot_class.cpp b/Descent3/pilot_class.cpp index 809e613a..3ad2fc6c 100644 --- a/Descent3/pilot_class.cpp +++ b/Descent3/pilot_class.cpp @@ -131,18 +131,19 @@ * $NoKeywords: $ */ +#include +#include +#include + #include "pilot_class.h" #include "ddio.h" #include "hud.h" +#include "log.h" #include "mem.h" #include "pserror.h" -#include "mono.h" #include "config.h" #include "ship.h" -#include -#include -#include "application.h" #include "appdatabase.h" #include "stringtable.h" @@ -151,8 +152,6 @@ #include "difficulty.h" #include "audiotaunts.h" -#include - extern void grtext_SetProfanityFilter(bool enabled); extern float Key_ramp_speed; @@ -420,7 +419,7 @@ int pilot::flush(bool new_file) { if (new_file && cfexist(real_filename)) { // the file already exists, we can't write out - mprintf(0, "PLTW: File (%s) exists, can't create\n", real_filename.u8string().c_str()); + LOG_WARNING.printf("PLTW: File (%s) exists, can't create", real_filename.u8string().c_str()); return PLTW_FILE_EXISTS; } @@ -429,7 +428,7 @@ int pilot::flush(bool new_file) { file = cfopen(real_filename, "wb"); if (!file) { - mprintf(0, "PLTW: File (%s) can't be opened\n", real_filename.u8string().c_str()); + LOG_WARNING.printf("PLTW: File (%s) can't be opened", real_filename.u8string().c_str()); return PLTW_FILE_CANTOPEN; } @@ -455,22 +454,22 @@ int pilot::flush(bool new_file) { } catch (cfile_error) { // catch and handle CFILE errors - mprintf(0, "PLTW: CFILE Exception writing data\n"); + LOG_FATAL << "PLTW: CFILE Exception writing data"; Int3(); try { cfclose(file); } catch (...) { - mprintf(0, "PLTW: Unable to close file due to exception\n"); + LOG_FATAL << "PLTW: Unable to close file due to exception"; } return PLTW_CFILE_FATAL; } catch (...) { // catch all errors - mprintf(0, "PLTW: Unknown exception writing data\n"); + LOG_FATAL << "PLTW: Unknown exception writing data"; Int3(); try { cfclose(file); } catch (...) { - mprintf(0, "PLTW: Unable to close file due to exception\n"); + LOG_FATAL << "PLTW: Unable to close file due to exception"; } return PLTW_UNKNOWN_FATAL; } @@ -502,14 +501,14 @@ int pilot::read(bool skip_config, bool skip_mission_data) { if (!cfexist(real_filename)) { // the file already exists, we can't write out - mprintf(0, "PLTR: File (%s) does not exist\n", real_filename.u8string().c_str()); + LOG_WARNING.printf("PLTR: File (%s) does not exist", real_filename.u8string().c_str()); return PLTR_FILE_NOEXIST; } try { file = cfopen(real_filename, "rb"); if (!file) { - mprintf(0, "PLTR: File (%s) can't be opened\n", real_filename.u8string().c_str()); + LOG_WARNING.printf("PLTR: File (%s) can't be opened", real_filename.u8string().c_str()); return PLTR_FILE_CANTOPEN; } @@ -570,23 +569,23 @@ int pilot::read(bool skip_config, bool skip_mission_data) { cfclose(file); } catch (cfile_error) { // catch and handle CFILE errors - mprintf(0, "PLTR: CFILE Exception reading data\n"); + LOG_FATAL << "PLTR: CFILE Exception reading data"; Int3(); try { cfclose(file); } catch (...) { - mprintf(0, "PLTR: Unable to close file due to exception\n"); + LOG_FATAL << "PLTR: Unable to close file due to exception"; } verify(); return PLTR_CFILE_FATAL; } catch (...) { // catch all errors - mprintf(0, "PLTR: Unknown exception reading data\n"); + LOG_FATAL << "PLTR: Unknown exception reading data"; Int3(); try { cfclose(file); } catch (...) { - mprintf(0, "PLTR: Unable to close file due to exception\n"); + LOG_FATAL << "PLTR: Unable to close file due to exception"; } verify(); return PLTR_UNKNOWN_FATAL; @@ -840,7 +839,7 @@ void pilot::set_hud_data(uint8_t *hmode, uint16_t *hstat, uint16_t *hgraphicalst write_pending = true; break; default: - mprintf(0, "PILOT: Trying to set hode mode to invalid mode (%d)\n", *hmode); + LOG_WARNING.printf("PILOT: Trying to set hode mode to invalid mode (%d)", *hmode); } } @@ -894,15 +893,15 @@ void pilot::add_mission_data(tMissionData *mdata) { if (find_mission_data(mdata->mission_name) != -1) { Int3(); - mprintf(0, "Mission already exists\n"); + LOG_FATAL << "Mission already exists"; return; } - mprintf(0, "Adding new mission data for (%s)\n", mdata->mission_name); + LOG_DEBUG.printf("Adding new mission data for (%s)", mdata->mission_name); tMissionData *new_data = (tMissionData *)mem_malloc((num_missions_flown + 1) * sizeof(tMissionData)); if (!new_data) { - mprintf(0, "Out of memory\n"); + LOG_WARNING << "Out of memory"; return; } @@ -921,14 +920,14 @@ void pilot::add_mission_data(tMissionData *mdata) { } void pilot::edit_mission_data(int index, tMissionData *mdata) { if (index < 0 || index >= num_missions_flown) { - mprintf(0, "Invalid mission index\n"); + LOG_FATAL << "Invalid mission index"; Int3(); return; } if (!mission_data) { Int3(); - mprintf(0, "No mission data\n"); + LOG_FATAL << "No mission data"; return; } @@ -942,14 +941,14 @@ void pilot::edit_mission_data(int index, tMissionData *mdata) { void pilot::get_mission_data(int index, tMissionData *mdata) { if (index < 0 || index >= num_missions_flown) { - mprintf(0, "Invalid mission index\n"); + LOG_FATAL << "Invalid mission index"; Int3(); return; } if (!mission_data) { Int3(); - mprintf(0, "No mission data\n"); + LOG_FATAL << "No mission data"; return; } @@ -1366,7 +1365,7 @@ void pilot::write_controls(CFILE *file) { cf_WriteByte(file, N_MOUSE_AXIS); for (i = 0; i < N_MOUSE_AXIS; i++) { cf_WriteFloat(file, mouse_sensitivity[i]); - mprintf(0, "pilot mousesens[%d]=%f\n", i, mouse_sensitivity[i]); + LOG_DEBUG.printf("pilot mousesens[%d]=%f", i, mouse_sensitivity[i]); } cf_WriteByte(file, N_JOY_AXIS); @@ -1439,7 +1438,7 @@ void pilot::read_controls(CFILE *file, bool skip) { for (i = 0; i < temp_b; i++) { temp_f = cf_ReadFloat(file); mouse_sensitivity[i] = temp_f; - mprintf(0, "pilot mousesens[%d]=%f\n", i, mouse_sensitivity[i]); + LOG_DEBUG.printf("pilot mousesens[%d]=%f", i, mouse_sensitivity[i]); } for (; i < N_MOUSE_AXIS; i++) { mouse_sensitivity[i] = 1.0f; diff --git a/Descent3/procedurals.cpp b/Descent3/procedurals.cpp index 93bce5db..456a7d3a 100644 --- a/Descent3/procedurals.cpp +++ b/Descent3/procedurals.cpp @@ -42,18 +42,18 @@ */ #include +#include +#include #include "procedurals.h" #include "bitmap.h" #include "gr.h" #include "gametexture.h" #include "game.h" +#include "log.h" #include "mem.h" #include "ddio.h" #include "config.h" -#include -#include -#include #include "psrand.h" @@ -154,9 +154,7 @@ void InitProcedurals() { // Load easter egg bitmap Easter_egg_handle = bm_AllocLoadFileBitmap("FreakyEye.ogf", 0); - if (Easter_egg_handle == -1) { - mprintf(0, "Failed to load easter egg!\n"); - } + LOG_WARNING_IF(Easter_egg_handle == -1) << "Failed to load easter egg!"; for (i = 0; i < MAX_PROC_ELEMENTS; i++) { DynamicProcElements[i].type = PROC_NONE; Proc_free_list[i] = i; @@ -1350,7 +1348,7 @@ void EvaluateProcedural(int handle) { int dest_bitmap = procedural->procedural_bitmap; if (bm_w(dest_bitmap, 0) != PROC_SIZE) { - mprintf(0, "Couldn't evaluate procedural because it is not %d x %d!\n", PROC_SIZE, PROC_SIZE); + LOG_WARNING.printf("Couldn't evaluate procedural because it is not %d x %d!", PROC_SIZE, PROC_SIZE); return; } if (GameTextures[handle].flags & TF_WATER_PROCEDURAL) diff --git a/Descent3/render.cpp b/Descent3/render.cpp index 417826ba..3eb636bb 100644 --- a/Descent3/render.cpp +++ b/Descent3/render.cpp @@ -28,9 +28,11 @@ * * $NoKeywords: $ */ + +#include +#include + #include "render.h" -#include -#include #include "3d.h" #include "mono.h" #include "gametexture.h" @@ -42,8 +44,8 @@ #include "room.h" #include "lighting.h" #include "lightmap.h" -#include "limits.h" #include "lightmap_info.h" +#include "log.h" #include "viseffect.h" #include "weapon.h" #include "fireball.h" @@ -753,7 +755,7 @@ void CheckFogPortalExtents(int roomnum, int portalnum) { if (found_room == -1) { // Couldn't find this room in our list, so make a new one if (Num_fogged_rooms_this_frame >= MAX_FOGGED_ROOMS_PER_FRAME) { - mprintf(0, "Too many fogged rooms in view cone!\n"); + LOG_WARNING << "Too many fogged rooms in view cone!"; return; } @@ -3637,7 +3639,7 @@ void SortStates(state_limited_element *state_array, int cellcount) { // Builds a list of mirror faces for each room and allocs memory accordingly void ConsolidateMineMirrors() { int i, t; - mprintf(0, "Consolidating mine mirrors!\n"); + LOG_DEBUG << "Consolidating mine mirrors!"; for (i = 0; i < MAX_ROOMS; i++) { room *rp = &Rooms[i]; if (!rp->used) diff --git a/Descent3/renderobject.cpp b/Descent3/renderobject.cpp index 1a000a42..abf52abc 100644 --- a/Descent3/renderobject.cpp +++ b/Descent3/renderobject.cpp @@ -577,9 +577,14 @@ * * $NoKeywords: $ */ + +#include +#include + #include "object.h" #include "object_lighting.h" #include "3d.h" +#include "log.h" #include "polymodel.h" #include "renderer.h" #include "weapon.h" @@ -589,8 +594,6 @@ #include "AIMain.h" #include "objinfo.h" #include "splinter.h" -#include "fireball.h" -#include "descent.h" #include "render.h" #include "gametexture.h" #include "game.h" @@ -607,13 +610,10 @@ #include "ship.h" #include "psrand.h" -#include #ifdef EDITOR #include "editor\d3edit.h" #endif -#include - // what darkening level to use when cloaked #define CLOAKED_FADE_LEVEL 28 #define CLOAK_FADEIN_DURATION_PLAYER F2_0 @@ -726,7 +726,7 @@ static void DrawNumber(int num, vector pos, float size, ddgr_color c1) { } int num_numbers = (int)(log10f((float)num) + 1); if (num_numbers > 10) { - mprintf(0, "Cannot represent a number with over 10 digits\n"); + LOG_FATAL << "Cannot represent a number with over 10 digits"; Int3(); return; } @@ -1207,7 +1207,7 @@ void RenderObject(object *obj) { float normalized_time[MAX_SUBOBJECTS]; bool render_it = false; if (obj->type == OBJ_NONE) { - mprintf(1, "ERROR!!!! Bogus obj %d in room %d is rendering!\n", OBJNUM(obj), obj->roomnum); + LOG_FATAL.printf("ERROR!!! Bogus obj %d in room %d is rendering!", OBJNUM(obj), obj->roomnum); Int3(); return; } @@ -1447,7 +1447,7 @@ void RenderObject(object *obj) { if (rend_GetPixel(TSearch_x, TSearch_y) != oldcolor) { TSearch_found_type = TSEARCH_FOUND_OBJECT; TSearch_seg = obj - Objects; - mprintf(0, "TR:objnum=%d\n", obj - Objects); + LOG_DEBUG.printf("TR:objnum=%d", obj - Objects); } } #endif diff --git a/Descent3/robotfire.cpp b/Descent3/robotfire.cpp index 45f0aa0c..f42101aa 100644 --- a/Descent3/robotfire.cpp +++ b/Descent3/robotfire.cpp @@ -16,12 +16,14 @@ * along with this program. If not, see . */ +#include + #include "robotfire.h" #include "object.h" #include "objinfo.h" #include "config.h" // for game toggles. -#include "objinfo.h" +#include "log.h" #include "weapon.h" #include "ship.h" #include "game.h" @@ -34,10 +36,8 @@ #include "SmallViews.h" #include "physics.h" #include "AIMain.h" - -#include - #include "psrand.h" + // Fires a multiplayer and AI on/off weapon void FireOnOffWeapon(object *objp) { if (objp->type == OBJ_PLAYER) { @@ -52,7 +52,7 @@ void FireOnOffWeapon(object *objp) { } else if (objp->ai_info) { char wb_index = objp->ai_info->last_special_wb_firing; if (wb_index > MAX_WBS_PER_OBJ) { // DAJ - mprintf(2, "FireOnOffWeapon wb_index %d > MAX_WBS_PER_OBJ\n", wb_index); + LOG_WARNING.printf("FireOnOffWeapon wb_index %d > MAX_WBS_PER_OBJ", wb_index); return; } diff --git a/Descent3/room.cpp b/Descent3/room.cpp index 1ba8769e..47f7d241 100644 --- a/Descent3/room.cpp +++ b/Descent3/room.cpp @@ -397,20 +397,18 @@ */ #include +#include +#include + +#include "bnode.h" #include "room.h" -#include "mono.h" +#include "log.h" #include "vecmat.h" #include "gametexture.h" #include "manage.h" -#include "renderer.h" #include "game.h" -#include "render.h" -#include "grdefs.h" -#include -#include #include "terrain.h" #include "findintersection.h" -#include "lightmap.h" #include "lightmap_info.h" #include "special_face.h" #include "mem.h" @@ -424,7 +422,6 @@ #ifdef NEWEDITOR #include "neweditor\editor_lighting.h" #endif -#include "bnode.h" // Global array of rooms room Rooms[MAX_ROOMS + MAX_PALETTE_ROOMS]; @@ -714,7 +711,7 @@ void FreeRoom(room *rp) { void FreeAllRooms() { int rn; room *rp; - mprintf(1, "Freeing rooms...Higest_room_index %d\n", Highest_room_index); + LOG_DEBUG.printf("Freeing rooms... Higest_room_index %d", Highest_room_index); for (rn = 0, rp = Rooms; rn <= Highest_room_index; rn++, rp++) { if (rp->used) { // mprintf(2, "rn %d\n", rn); @@ -804,7 +801,7 @@ bool ComputeFaceNormal(room *rp, int facenum) { ok = ComputeNormal(&fp->normal, fp->num_verts, fp->face_verts, rp->verts); if (!ok) { - mprintf(1, "Warning: Low precision normal for room:face = %d:%d\n", ROOMNUM(rp), facenum); + LOG_WARNING.printf("Warning: Low precision normal for room:face = %d:%d", ROOMNUM(rp), facenum); } return ok; @@ -840,14 +837,14 @@ bool ComputeNormal(vector *normal, int num_verts, short *vertnum_list, vector *v } if (largest_mag < MIN_NORMAL_MAG) { - mprintf(1, "Warning: Normal has low precision. mag = %f, norm = %f,%f,%f\n", + LOG_WARNING.printf("Warning: Normal has low precision. mag = %f, norm = %f,%f,%f", largest_mag, normal->x, normal->y, normal->z); - return 0; + return false; } else - return 1; + return true; } // Computes the center point on a face by averaging the points in the portal @@ -1096,7 +1093,7 @@ int CheckTransparentPoint(const vector *pnt, const room *rp, const int facenum) // Computes a bounding sphere for the current room // Parameters: center - filled in with the center point of the sphere -// rp - the room we’re bounding +// rp - the room we're bounding // Returns: the radius of the bounding sphere float ComputeRoomBoundingSphere(vector *center, room *rp) { // This algorithm is from Graphics Gems I. There's a better algorithm in Graphics Gems III that @@ -1241,7 +1238,7 @@ int FindFirstUsedRoom() { // returns true on successs bool ChangeRoomFaceTexture(int room_num, int face_num, int texture) { if ((room_num < 0) || (room_num > Highest_room_index) || ROOMNUM_OUTSIDE(room_num) || (!Rooms[room_num].used)) { - mprintf(0, "Invalid room passed to ChangeRoomFaceTexture\n"); + LOG_FATAL << "Invalid room passed to ChangeRoomFaceTexture"; Int3(); return false; } @@ -1249,15 +1246,15 @@ bool ChangeRoomFaceTexture(int room_num, int face_num, int texture) { room *rp = &Rooms[room_num]; if (face_num < 0 || face_num >= rp->num_faces) { - mprintf(0, "Invalid face number passed to ChangeRoomFaceTexture." - " Room=%d, you gave face #%d, there are only %d in the room\n", + LOG_FATAL.printf("Invalid face number passed to ChangeRoomFaceTexture." + " Room=%d, you gave face #%d, there are only %d in the room", room_num, face_num, rp->num_faces); Int3(); return false; } if (texture == -1) { - mprintf(0, "not a valid texture, passed to ChangeRoomFaceTexture\n"); + LOG_FATAL << "not a valid texture, passed to ChangeRoomFaceTexture"; Int3(); return false; } diff --git a/Descent3/screens.cpp b/Descent3/screens.cpp index 8c921bf1..5e67b479 100644 --- a/Descent3/screens.cpp +++ b/Descent3/screens.cpp @@ -200,6 +200,7 @@ #include "stringtable.h" #include "dedicated_server.h" #include "levelgoal.h" +#include "log.h" #include "sounds.h" #include "pilot.h" #include "joystick.h" @@ -600,7 +601,7 @@ void PaintPLRSinglePlayerText() { if (all_done_painting) { if (paint_in_sound_handle != -1) { - mprintf(0, "Stopping paint in sound\n"); + LOG_WARNING << "Stopping paint in sound"; Sound_system.StopSoundImmediate(paint_in_sound_handle); paint_in_sound_handle = -1; } diff --git a/Descent3/sdlmain.cpp b/Descent3/sdlmain.cpp index 86ee4f90..00539174 100644 --- a/Descent3/sdlmain.cpp +++ b/Descent3/sdlmain.cpp @@ -36,6 +36,7 @@ #ifdef WIN32 #include #include +#include "debug.h" #endif #include diff --git a/Descent3/spew.cpp b/Descent3/spew.cpp index 6546bcb2..59ce6cf7 100644 --- a/Descent3/spew.cpp +++ b/Descent3/spew.cpp @@ -120,24 +120,18 @@ * $NoKeywords: $ */ -// ancillary includes +#include + #include "game.h" #include "vecmat.h" -#include "ddio.h" #include "pserror.h" #include "object.h" -#include "damage.h" #include "viseffect.h" #include "fireball.h" +#include "log.h" #include "spew.h" #include "weapon.h" #include "polymodel.h" - -// ANSI C includes -#include -#include -#include - #include "psrand.h" #define MAX_SPEWS_PER_FRAME 5 // maximum number of spews 1 can emit per frame @@ -153,14 +147,14 @@ bool SpewObjectNeedsEveryFrameUpdate(object *obj, int gunpoint); // Initializes the Spew system void SpewInit() { - mprintf(0, "Initializing Spew System\n"); + LOG_INFO << "Initializing Spew System"; int count; spew_count = 0; for (count = 0; count < MAX_SPEW_EFFECTS; count++) { SpewClearEvent(count, true); } - mprintf(0, "Done Initializing Spew System\n"); + LOG_INFO << "Done Initializing Spew System"; } // Creates a Spew effect @@ -251,8 +245,6 @@ int SpewCreate(spewinfo *spew) { veffect->start_time = Gametime; - // mprintf(0,"Creating Spew Effect (%d)\n",veffect->handle); - return veffect->handle; // return the handle } @@ -395,8 +387,6 @@ void SpewEmitAll(void) { } else { vector vel_vector; - // mprintf(0,"Emitting Point based Spew %d\n",count); - // calc velocity vector vel_vector = spew->pt.normal * speed; @@ -411,11 +401,8 @@ void SpewEmitAll(void) { } // end while if (num_spewed == 0) { - mprintf(0, "Max spews per frame hit! Handle=%d Interval=%f Lifetime=%f Longevity=%f\n", - spew->handle, - spew->time_int, - spew->lifetime, - spew->longevity); + LOG_DEBUG.printf("Max spews per frame hit! Handle=%d Interval=%f Lifetime=%f Longevity=%f", + spew->handle, spew->time_int, spew->lifetime, spew->longevity); spew->time_until_next_blob = spew->time_int; } @@ -438,15 +425,11 @@ void SpewClearEvent(int handle, bool force) { if ((slot < 0) || (slot > MAX_SPEW_EFFECTS)) return; - // mprintf(0,"Clearing spew event %d - %d....",handle,slot); - vis = &SpewEffects[slot]; if ((!force) && (handle != vis->handle)) return; - // mprintf(0,"handle OK\n"); - vis->inuse = vis->random = vis->use_gunpoint = vis->real_obj = false; vis->pt.origin.x = vis->pt.origin.y = vis->pt.origin.z = 0.0f; vis->pt.room_num = 0; diff --git a/Descent3/subtitles.cpp b/Descent3/subtitles.cpp index 3fbb0ec5..ea21ff21 100644 --- a/Descent3/subtitles.cpp +++ b/Descent3/subtitles.cpp @@ -55,6 +55,7 @@ #include "args.h" #include "d3movie.h" +#include "log.h" #include "manage.h" #include "mem.h" #include "pserror.h" @@ -171,13 +172,13 @@ void SubtParseSubtitles(CFILE *file) { // starting frame number p = parse_int(p, &first_frame); if (!p) { - mprintf(0, "Couldn't parse first_frame\n"); + LOG_WARNING << "Couldn't parse first_frame"; goto subt_parse_error; } p = parse_int(p, &last_frame); if (!p) { - mprintf(0, "Couldn't parse last_frame\n"); + LOG_WARNING << "Couldn't parse last_frame"; goto subt_parse_error; } @@ -196,7 +197,7 @@ void SubtParseSubtitles(CFILE *file) { } return; subt_parse_error: - mprintf(0, "Error Parsing SubTitle File!\n"); + LOG_WARNING << "Error Parsing SubTitle File!"; SubtResetSubTitles(); } @@ -224,11 +225,11 @@ void SubtInitSubtitles(const std::filesystem::path &filename) { std::filesystem::path subtitle_path = std::filesystem::path(LocalArtDir) / "movies" / filename; subtitle_path.replace_extension(MOVIE_SUBTITLE_EXTENSION); - mprintf(0, "Looking for the subtitle file %s\n", subtitle_path.u8string().c_str()); + LOG_DEBUG << "Looking for the subtitle file " << subtitle_path; CFILE *ifile = cfopen(subtitle_path, "rt"); if (!ifile) { - mprintf(0, "Movie: Couldn't find subtitle file %s\n", subtitle_path.u8string().c_str()); + LOG_WARNING << "Movie: Couldn't find subtitle file " << subtitle_path; return; } diff --git a/Descent3/terrain.cpp b/Descent3/terrain.cpp index 3bbe9860..69030d8f 100644 --- a/Descent3/terrain.cpp +++ b/Descent3/terrain.cpp @@ -19,11 +19,15 @@ #ifdef NEWEDITOR #include "neweditor\globals.h" #else -#include +#include #endif + +#include +#include + #include "vecmat.h" #include "object.h" -#include "mono.h" +#include "log.h" #include "terrain.h" #include "pserror.h" #include "bitmap.h" @@ -31,7 +35,6 @@ #include "lighting.h" #include "lightmap.h" #include "weather.h" -#include #include "mem.h" #include "dedicated_server.h" #include "psrand.h" @@ -39,8 +42,6 @@ #include "editor\d3edit.h" #endif -#include - #define SKY_RADIUS 2500.0 #define DEFAULT_LIGHT_SOURCE \ { 0, TERRAIN_SIZE * 100, 0 } @@ -309,7 +310,7 @@ void BuildMinMaxTerrain() { int row_width, xoffset, yoffset, total_rows; int minheight, maxheight, cellheight; - mprintf(0, "Building min/max terrain table.\n"); + LOG_INFO << "Building min/max terrain table."; // Calculate our integer y positions (0-255) for (i = 0; i < TERRAIN_WIDTH * TERRAIN_DEPTH; i++) { @@ -819,7 +820,7 @@ int LoadPCXTerrain(char *filename) { lando = (uint8_t *)mem_malloc(total); - mprintf(0, "Heightmap is %d x %d\n", width, height); + LOG_DEBUG.printf("Heightmap is %d x %d", width, height); while (run < total) { buf = cf_ReadByte(infile); diff --git a/Descent3/terrainrender.cpp b/Descent3/terrainrender.cpp index be9d525e..3632ba9f 100644 --- a/Descent3/terrainrender.cpp +++ b/Descent3/terrainrender.cpp @@ -1425,7 +1425,6 @@ void RenderTerrain(uint8_t from_mine, int left, int top, int right, int bot) { RenderAllTerrainObjects(); } - mprintf_at(2, 5, 0, "Objs Drawn=%5d", Terrain_objects_drawn); Last_terrain_render_time = Gametime; } @@ -2697,10 +2696,6 @@ void DisplayTerrainList(int cellcount, bool from_automap) { rend_SetOverlayType(OT_NONE); rend_SetWrapType(WT_WRAP); - - mprintf_at(2, 1, 0, "%5d cells", cellcount); - mprintf_at(2, 2, 0, "%5d trans", GlobalTransCount); - mprintf_at(2, 3, 0, "Tdepth=%5d", TotalDepth); } // Arrays for drawing static int src[256]; diff --git a/Descent3/trigger.cpp b/Descent3/trigger.cpp index ce64fd80..c1355f6f 100644 --- a/Descent3/trigger.cpp +++ b/Descent3/trigger.cpp @@ -113,16 +113,16 @@ * $NoKeywords: $ */ +#include +#include + #include "trigger.h" #include "room.h" #include "object.h" -//@$-#include "d3x.h" #include "pserror.h" #include "osiris_dll.h" #include "levelgoal.h" - -#include -#include +#include "log.h" // The maximum number of triggers that can be in the mine #define MAX_TRIGGERS 100 @@ -238,7 +238,7 @@ void CheckTrigger(int roomnum, int facenum, object *objp, int event_type) { // Check if this object is a valid activator for this trigger if (tp->activator & type) { - mprintf(0, "Hit trigger %d\n", tp - Triggers); + LOG_DEBUG.printf("Hit trigger %d", tp - Triggers); // Execute this trigger's script tOSIRISEventInfo ei; diff --git a/Descent3/vclip.cpp b/Descent3/vclip.cpp index cdde06b1..478a8eea 100644 --- a/Descent3/vclip.cpp +++ b/Descent3/vclip.cpp @@ -159,16 +159,16 @@ #include #include -#include "pstypes.h" -#include "pserror.h" #include "bitmap.h" -#include "vclip.h" #include "cfile.h" -#include "mono.h" #include "ddio.h" -#include "gametexture.h" -#include "mem.h" #include "game.h" +#include "gametexture.h" +#include "log.h" +#include "mem.h" +#include "pserror.h" +#include "pstypes.h" +#include "vclip.h" vclip GameVClips[MAX_VCLIPS]; int Num_vclips = 0; @@ -178,7 +178,7 @@ int Num_vclips = 0; #define VCLIP_VERSION 1 // Frees all the memory used by vclips void FreeAllVClips() { - mprintf(0, "Freeing all vclips!\n"); + LOG_DEBUG << "Freeing all vclips!"; for (int i = 0; i < MAX_VCLIPS; i++) { if (GameVClips[i].used > 0) { @@ -250,7 +250,7 @@ int SaveVClip(const std::filesystem::path& filename, int num) { outfile = (CFILE *)cfopen(filename, "wb"); if (!outfile) { - mprintf(0, "Couldn't save vclip %s!\n", filename.u8string().c_str()); + LOG_WARNING << "Couldn't save vclip " << filename << "!"; return 0; } @@ -267,7 +267,7 @@ int SaveVClip(const std::filesystem::path& filename, int num) { // Now save each frame of this vclip for (int i = 0; i < vc->num_frames; i++) { if (bm_SaveBitmap(outfile, vc->frames[i]) != 1) { - mprintf(0, "Couldn't save frame %d of vclip %s!\n", i, filename.u8string().c_str()); + LOG_ERROR.printf("Couldn't save frame %d of vclip %s!", i, filename.u8string().c_str()); Int3(); cfclose(outfile); return 0; @@ -301,7 +301,7 @@ void PageInVClip(int vcnum) { while ((end_ptr >= start_ptr) && (*end_ptr != '\\')) end_ptr--; if (end_ptr < start_ptr) { - mprintf(0, "Couldn't load vclip %s!\n", vc->name); + LOG_WARNING.printf("Couldn't load vclip %s!", vc->name); return; } @@ -310,12 +310,12 @@ void PageInVClip(int vcnum) { infile = (CFILE *)cfopen(end_ptr, "rb"); if (!infile) { - mprintf(0, "Couldn't load vclip %s!\n", vc->name); + LOG_WARNING.printf("Couldn't load vclip %s!", vc->name); return; } } - mprintf(0, "Paging in vclip %s!\n", vc->name); + LOG_DEBUG.printf("Paging in vclip %s!", vc->name); uint8_t start_val = cf_ReadByte(infile); int version = 0; @@ -474,11 +474,11 @@ int AllocLoadIFLVClip(const char *filename, int texture_size, int mipped, int fo infile = (CFILE *)cfopen(filename, "rt"); if (!infile) { - mprintf(0, "Couldn't load IFL vclip %s!\n", filename); + LOG_WARNING.printf("Couldn't load IFL vclip %s!", filename); return -1; } - mprintf(0, "Loading IFL vclip %s\n", name); + LOG_DEBUG.printf("Loading IFL vclip %s", name); int vcnum = AllocVClip(); @@ -595,7 +595,7 @@ int AllocLoadIFLVClip(const char *filename, int texture_size, int mipped, int fo cfclose(infile); if (vc->num_frames == 0) { - mprintf(0, "vclip had no valid bitmap names!\n"); + LOG_WARNING << "vclip had no valid bitmap names!"; FreeVClip(vcnum); return -1; } diff --git a/Descent3/viseffect.cpp b/Descent3/viseffect.cpp index 150611cc..c462bee6 100644 --- a/Descent3/viseffect.cpp +++ b/Descent3/viseffect.cpp @@ -448,6 +448,7 @@ #include "game.h" #include "gametexture.h" #include "lighting.h" +#include "log.h" #include "mem.h" #include "object.h" #include "physics.h" @@ -519,7 +520,7 @@ void InitVisEffects() { // Returns the next free viseffect int VisEffectAllocate() { if (Num_vis_effects == max_vis_effects) { - mprintf(0, "Couldn't allocate vis effect!\n"); + LOG_WARNING << "Couldn't allocate vis effect!"; return -1; } @@ -2161,7 +2162,7 @@ void VisEffectMoveOne(vis_effect *vis) { if (cellnum >= 0 && cellnum < TERRAIN_WIDTH * TERRAIN_DEPTH) ApplyLightingToTerrain(&vis->pos, cellnum, vis->size * scalar * 3, r, g, b); else - mprintf(0, "Vis effect not in world!\n"); + LOG_WARNING << "Vis effect not in world!"; } else { if (vis->roomnum >= 0 && vis->roomnum <= Highest_room_index && Rooms[vis->roomnum].used) ApplyLightingToRooms(&vis->pos, vis->roomnum, vis->size * scalar * 3, r, g, b); diff --git a/Descent3/voice.cpp b/Descent3/voice.cpp index 7dec3c1b..b889df50 100644 --- a/Descent3/voice.cpp +++ b/Descent3/voice.cpp @@ -58,12 +58,15 @@ * * $NoKeywords: $ */ -#include "voice.h" -#include "streamaudio.h" + +#include +#include + #include "hlsoundlib.h" +#include "log.h" +#include "streamaudio.h" #include "soundload.h" -#include -#include +#include "voice.h" #define MOTHERLOAD_STRING "Cheater!" #define MOTHERLOAD_FLAGS VF_POWERUP | VF_PLAYTABLE @@ -104,7 +107,7 @@ VoiceQueue vq; void StartVoice(char *filename, int flags); bool InitVoices(void) { - mprintf(0, "Voice System: Init\n"); + LOG_INFO << "Voice System: Init"; CurrentVoiceHandle.handle = -1; CurrentVoiceHandle.flags = 0; CurrentVoiceHandle.chandle = -1; @@ -116,7 +119,7 @@ bool InitVoices(void) { } void CloseVoices(void) { - mprintf(0, "Voice System: Shutdown\n"); + LOG_INFO << "Voice System: Shutdown"; StopVoice(); } @@ -200,7 +203,7 @@ void UpdateVoices(void) { if (!CurrentVoiceHandle.inuse) { // see if we have something waiting if (vq.GetNextVoice(filename, &flags)) { - mprintf(0, "Playing queued voice %s\n", filename); + LOG_INFO.printf("Playing queued voice %s", filename); StartVoice(filename, flags); return; } @@ -214,7 +217,7 @@ void UpdateVoices(void) { // it isn't, so stop it and play the next voice in the queue if any StopVoice(); if (vq.GetNextVoice(filename, &flags)) { - mprintf(0, "Playing queued voice %s\n", filename); + LOG_INFO.printf("Playing queued voice %s", filename); StartVoice(filename, flags); } } @@ -249,7 +252,7 @@ void VoiceQueue::AddVoice(char *fn, int flg) { int nextpos = (pos + 1) % QUEUE_SIZE; if ((nextpos == currvoice + 1) && (inuse[nextpos])) { // this really shouldn't be since it was reported that the queue isn't full - mprintf(0, "Voice Queue full, missed full bool (this shouldn't happen)\n"); + LOG_WARNING << "Voice Queue full, missed full bool (this shouldn't happen)"; // since the queue is full, remove everything and add just the "mother load" voice Clear(); pos = 1; @@ -317,7 +320,7 @@ void VoiceQueue::Clear(bool onlypowerups) { if (realp == QUEUE_SIZE) { // we're still full :( full = true; - mprintf(0, "Voice Warning: Buffer still full after clean (All Non-powerups voices in queue?)\n"); + LOG_WARNING << "Voice Warning: Buffer still full after clean (All Non-powerups voices in queue?)"; } } else { motherloadat = -1; diff --git a/module/CMakeLists.txt b/module/CMakeLists.txt index 15a6876d..714b4b87 100644 --- a/module/CMakeLists.txt +++ b/module/CMakeLists.txt @@ -4,5 +4,5 @@ set(CPPS add_library(module STATIC ${HEADERS} ${CPPS}) target_link_libraries(module PRIVATE - misc + ddebug ) diff --git a/module/module.cpp b/module/module.cpp index c346444a..72ed0876 100644 --- a/module/module.cpp +++ b/module/module.cpp @@ -103,7 +103,7 @@ #include "crossplat.h" #include "module.h" -#include "pserror.h" +#include "mono.h" /** * Returns fixed case file name to actual case on disk for case-sensitive filesystems (Linux).