From a5ee4e1ffdfc59aa41d4db09b079165e47a8ba43 Mon Sep 17 00:00:00 2001 From: Louis Gombert Date: Tue, 20 May 2025 18:36:49 +0200 Subject: [PATCH 01/24] Fix warning -Wlogical-op-parentheses by adding parentheses --- Descent3/AImain.cpp | 2 +- Descent3/BOA.cpp | 4 ++-- Descent3/Player.cpp | 4 ++-- Descent3/terrainrender.cpp | 2 +- Descent3/viseffect.cpp | 2 +- lib/vecmat_external.h | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Descent3/AImain.cpp b/Descent3/AImain.cpp index 64d8a84f1..73870a670 100644 --- a/Descent3/AImain.cpp +++ b/Descent3/AImain.cpp @@ -4606,7 +4606,7 @@ void ai_move(object *obj) { } else { // Determine movement stuff if (obj->movement_type == MT_PHYSICS || obj->movement_type == MT_WALKING) { - if (targetptr && IsTargetLocal(obj, targetptr) || (ai_info->awareness >= AWARE_BARELY) || + if ((targetptr && IsTargetLocal(obj, targetptr)) || (ai_info->awareness >= AWARE_BARELY) || (ai_info->flags & AIF_PERSISTANT)) { for (i = NUM_ACTIVATION_LEVELS; i < MAX_GOALS; i++) { if (ai_info->goals[i].used) { diff --git a/Descent3/BOA.cpp b/Descent3/BOA.cpp index 6991bef04..237680cdd 100644 --- a/Descent3/BOA.cpp +++ b/Descent3/BOA.cpp @@ -241,8 +241,8 @@ bool BOA_PassablePortal(int room, int portal_index, bool f_for_sound, bool f_mak return false; } - if ((Rooms[room].portals[portal_index].flags & PF_RENDER_FACES) && - !(Rooms[room].portals[portal_index].flags & PF_RENDERED_FLYTHROUGH) || + if (((Rooms[room].portals[portal_index].flags & PF_RENDER_FACES) && + !(Rooms[room].portals[portal_index].flags & PF_RENDERED_FLYTHROUGH)) || (Rooms[room].portals[portal_index].flags & PF_BLOCK)) { return false; } diff --git a/Descent3/Player.cpp b/Descent3/Player.cpp index 78a6c1290..5b94a61c6 100644 --- a/Descent3/Player.cpp +++ b/Descent3/Player.cpp @@ -1803,7 +1803,7 @@ void DoPlayerFrameForOne(int slot) { obj->mtype.phys_info = observed->mtype.phys_info; } - if (obj->type == OBJ_PLAYER || obj->type == OBJ_OBSERVER && obj->id == Player_num) { + if (obj->type == OBJ_PLAYER || (obj->type == OBJ_OBSERVER && obj->id == Player_num)) { // Do camera stuff if needed SetupPlayerCamera(); } @@ -3923,7 +3923,7 @@ void ThiefStealItem(int player_object_handle, int item) { } break; case THIEFITEM_CLOAK: { - if ((pobj->effect_info) && (pobj->effect_info->type_flags & EF_FADING_OUT) || + if ((pobj->effect_info && pobj->effect_info->type_flags & EF_FADING_OUT) || (pobj->effect_info->type_flags & EF_CLOAKED)) { MakeObjectVisible(pobj); } diff --git a/Descent3/terrainrender.cpp b/Descent3/terrainrender.cpp index 8f29adc2b..c03369f6d 100644 --- a/Descent3/terrainrender.cpp +++ b/Descent3/terrainrender.cpp @@ -2599,7 +2599,7 @@ void DisplayTerrainList(int cellcount, bool from_automap) { cx = t % TERRAIN_WIDTH; cz = t / TERRAIN_WIDTH; - if (cx < TERRAIN_WIDTH - simplemul && cz < TERRAIN_DEPTH - simplemul || lod != (MAX_TERRAIN_LOD - 1)) { + if ((cx < TERRAIN_WIDTH - simplemul && cz < TERRAIN_DEPTH - simplemul) || lod != (MAX_TERRAIN_LOD - 1)) { int ul, lr; // upper_left,lower_right if (Terrain_seg[t].flags & TF_INVISIBLE) if (!Show_invisible_terrain) diff --git a/Descent3/viseffect.cpp b/Descent3/viseffect.cpp index 37cbdca22..ffdefc128 100644 --- a/Descent3/viseffect.cpp +++ b/Descent3/viseffect.cpp @@ -2218,7 +2218,7 @@ void AttachRandomNapalmEffectsToObject(object *obj) { vm_NormalizeVector(&velocity_norm); vector pos = obj->pos - (velocity_norm * (obj->size / 2)); - if (obj->movement_type == MT_PHYSICS && (OBJECT_OUTSIDE(obj) && (ps_rand() % 3) == 0) || (ps_rand() % 3) == 0) + if ((obj->movement_type == MT_PHYSICS && (OBJECT_OUTSIDE(obj) && (ps_rand() % 3) == 0)) || (ps_rand() % 3) == 0) CreateFireball(&pos, BLACK_SMOKE_INDEX, obj->roomnum, VISUAL_FIREBALL); float size_scalar = obj->size / 7.0; diff --git a/lib/vecmat_external.h b/lib/vecmat_external.h index 217b8fc4a..5291cb8d7 100644 --- a/lib/vecmat_external.h +++ b/lib/vecmat_external.h @@ -88,7 +88,7 @@ enum class align }; template -struct alignas(N==N_POW2 && A != align::scalar || A == align::vector ? alignof(T) * N_POW2 : alignof(T)) vec : std::array { +struct alignas((N==N_POW2 && A != align::scalar) || A == align::vector ? alignof(T) * N_POW2 : alignof(T)) vec : std::array { template operator vec() { return *reinterpret_cast*>(this); } From 077b754796deb5b1d67b04a7a16ea6b7552f05c0 Mon Sep 17 00:00:00 2001 From: Louis Gombert Date: Tue, 20 May 2025 18:39:15 +0200 Subject: [PATCH 02/24] Fix warning -Wmissing-braces --- Descent3/Controls.cpp | 146 +++++++++++++++++++------------------- lib/vecmat_external.h | 8 +-- scripts/osiris_vector.cpp | 4 +- vecmat/vector.cpp | 4 +- 4 files changed, 81 insertions(+), 81 deletions(-) diff --git a/Descent3/Controls.cpp b/Descent3/Controls.cpp index 4011a0c84..ccdead900 100644 --- a/Descent3/Controls.cpp +++ b/Descent3/Controls.cpp @@ -473,80 +473,80 @@ static void ToggleHeadlightControlState(); // LIST OF NEEDS ct_function Controller_needs[NUM_CONTROLLER_FUNCTIONS] = { - {ctfFORWARD_THRUSTAXIS, ctAnalog, ctAxis, ctAxis, 0, 0, 0, 0}, - {ctfFORWARD_THRUSTKEY, ctTime, ctKey, ctKey, KEY_A, 0, 0, 0}, - {ctfREVERSE_THRUSTKEY, ctTime, ctKey, ctKey, KEY_Z, 0, 0, 0}, - {ctfFORWARD_BUTTON, ctTime, ctButton, ctButton, 0, 0, 0, 0}, - {ctfREVERSE_BUTTON, ctTime, ctButton, ctButton, 0, 0, 0, 0}, - {ctfUP_THRUSTAXIS, ctAnalog, ctAxis, ctAxis, CT_V_AXIS, 0, 0, 0}, - {ctfUP_BUTTON, ctDigital, ctPOV, ctButton, JOYPOV_UP, 0, 0, 0}, - {ctfUP_THRUSTKEY, ctTime, ctKey, ctKey, KEY_PADMINUS, 0, 0, 0}, - {ctfDOWN_BUTTON, ctDigital, ctPOV, ctButton, JOYPOV_DOWN, 0, 0, 0}, - {ctfDOWN_THRUSTKEY, ctTime, ctKey, ctKey, KEY_PADPLUS, 0, 0, 0}, - {ctfRIGHT_THRUSTAXIS, ctAnalog, ctAxis, ctAxis, CT_U_AXIS, 0, 0, 0}, - {ctfRIGHT_BUTTON, ctDigital, ctPOV, ctButton, JOYPOV_RIGHT, 0, 0, 0}, - {ctfRIGHT_THRUSTKEY, ctTime, ctKey, ctKey, KEY_PAD3, 0, 0, 0}, - {ctfLEFT_BUTTON, ctDigital, ctPOV, ctButton, JOYPOV_LEFT, 0, 0, 0}, - {ctfLEFT_THRUSTKEY, ctTime, ctKey, ctKey, KEY_PAD1, 0, 0, 0}, - {ctfPITCH_DOWNAXIS, ctAnalog, ctAxis, ctMouseAxis, CT_Y_AXIS, CT_Y_AXIS, 0, 0}, - {ctfPITCH_DOWNKEY, ctTime, ctKey, ctKey, KEY_UP, KEY_PAD8, 0, 0}, - {ctfPITCH_DOWNBUTTON, ctDigital, ctButton, ctButton, 0, 0, 0, 0}, - {ctfPITCH_UPKEY, ctTime, ctKey, ctKey, KEY_DOWN, KEY_PAD2, 0, 0}, - {ctfPITCH_UPBUTTON, ctDigital, ctButton, ctButton, 0, 0, 0, 0}, - {ctfBANK_RIGHTAXIS, ctAnalog, ctAxis, ctAxis, CT_R_AXIS, 0, 0, 0}, - {ctfBANK_RIGHTKEY, ctTime, ctKey, ctKey, KEY_E, KEY_PAD9, 0, 0}, - {ctfBANK_RIGHTBUTTON, ctDigital, ctButton, ctButton, 0, 0, 0, 0}, - {ctfBANK_LEFTKEY, ctTime, ctKey, ctKey, KEY_Q, KEY_PAD7, 0, 0}, - {ctfBANK_LEFTBUTTON, ctDigital, ctButton, ctButton, 0, 0, 0, 0}, - {ctfHEADING_RIGHTAXIS, ctAnalog, ctAxis, ctMouseAxis, CT_X_AXIS, CT_X_AXIS, 0, 0}, - {ctfHEADING_RIGHTKEY, ctTime, ctKey, ctKey, KEY_RIGHT, KEY_PAD6, 0, 0}, - {ctfHEADING_RIGHTBUTTON, ctDigital, ctButton, ctButton, 0, 0, 0, 0}, - {ctfHEADING_LEFTKEY, ctTime, ctKey, ctKey, KEY_LEFT, KEY_PAD4, 0, 0}, - {ctfHEADING_LEFTBUTTON, ctDigital, ctButton, ctButton, 0, 0, 0, 0}, - {ctfFIREPRIMARY_BUTTON, ctTime, ctButton, ctMouseButton, 1, 1, 0, 0}, - {ctfFIREPRIMARY_KEY, ctTime, ctKey, ctKey, KEY_LCTRL, KEY_RCTRL, 0, 0}, - {ctfFIREPRIMARY_KEY2, ctTime, ctKey, ctKey, 0, 0, 0, 0}, - {ctfFIRESECONDARY_BUTTON, ctTime, ctButton, ctMouseButton, 2, 2, 0, 0}, - {ctfFIRESECONDARY_KEY, ctTime, ctKey, ctKey, KEY_SPACEBAR, 0, 0, 0}, - {ctfTOGGLE_SLIDEBUTTON, ctTime, ctButton, ctButton, 0, 0, 0, 0}, - {ctfTOGGLE_SLIDEKEY, ctTime, ctKey, ctKey, KEY_LALT, 0, 0, 0}, - {ctfTOGGLE_BANKBUTTON, ctTime, ctButton, ctButton, 0, 0, 0, 0}, - {ctfTOGGLE_BANKKEY, ctTime, ctKey, ctKey, 0, 0, 0, 0}, - {ctfFIREFLARE_BUTTON, ctTime, ctButton, ctMouseButton, 3, 3, 0, 0}, - {ctfFIREFLARE_KEY, ctDownCount, ctKey, ctKey, KEY_F, 0, 0, 0}, - {ctfAFTERBURN_BUTTON, ctTime, ctButton, ctButton, 0, 0, 0, 0}, - {ctfAFTERBURN_KEY, ctTime, ctKey, ctKey, KEY_S, 0, 0, 0}, - {ctfAUTOMAP_KEY, ctDownCount, ctKey, ctKey, KEY_TAB, 0, 0, 0}, - {ctfPREV_INVKEY, ctDownCount, ctKey, ctKey, KEY_LBRACKET, 0, 0, 0}, - {ctfNEXT_INVKEY, ctDownCount, ctKey, ctKey, KEY_RBRACKET, 0, 0, 0}, - {ctfINV_USEKEY, ctDownCount, ctKey, ctKey, KEY_BACKSLASH, 0, 0, 0}, - {ctfPREV_CNTMSKEY, ctDownCount, ctKey, ctKey, KEY_SEMICOL, 0, 0, 0}, - {ctfNEXT_CNTMSKEY, ctDownCount, ctKey, ctKey, KEY_RAPOSTRO, 0, 0, 0}, - {ctfCNTMS_USEKEY, ctDownCount, ctKey, ctKey, KEY_ENTER, 0, 0, 0}, - {ctfHEADLIGHT_KEY, ctDownCount, ctKey, ctKey, KEY_H, 0, 0, 0}, - {ctfHEADLIGHT_BUTTON, ctDownCount, ctButton, ctButton, 0, 0, 0, 0}, - {ctfAUTOMAP_BUTTON, ctDownCount, ctButton, ctButton, 0, 0, 0, 0}, - {ctfPREV_INVBTN, ctDownCount, ctButton, ctButton, 0, 0, 0, 0}, - {ctfNEXT_INVBTN, ctDownCount, ctButton, ctButton, 0, 0, 0, 0}, - {ctfINV_USEBTN, ctDownCount, ctButton, ctButton, 0, 0, 0, 0}, - {ctfPREV_CNTMSBTN, ctDownCount, ctButton, ctButton, 0, 0, 0, 0}, - {ctfNEXT_CNTMSBTN, ctDownCount, ctButton, ctButton, 0, 0, 0, 0}, - {ctfCNTMS_USEBTN, ctDownCount, ctButton, ctMouseButton, 4, 4, 0, 0}, - {ctfWPNSEL_PCYCLEKEY, ctDownCount, ctKey, ctKey, KEY_COMMA, 0, 0, 0}, - {ctfWPNSEL_PCYCLEBTN, ctDownCount, ctButton, ctMouseButton, 0, 5, 0, 0}, - {ctfWPNSEL_SCYCLEKEY, ctDownCount, ctKey, ctKey, KEY_PERIOD, 0, 0, 0}, - {ctfWPNSEL_SCYCLEBTN, ctDownCount, ctButton, ctMouseButton, 0, 6, 0, 0}, - {ctfREARVIEW_KEY, ctDownCount, ctKey, ctKey, KEY_R, 0, 0, 0}, - {ctfREARVIEW_BTN, ctDownCount, ctButton, ctButton, 0, 0, 0, 0}, - {ctfAUDIOTAUNT1_KEY, ctDownCount, ctKey, ctKey, 0, 0, 0, 0}, - {ctfAUDIOTAUNT1_BTN, ctDownCount, ctButton, ctButton, 0, 0, 0, 0}, - {ctfAUDIOTAUNT2_KEY, ctDownCount, ctKey, ctKey, 0, 0, 0, 0}, - {ctfAUDIOTAUNT2_BTN, ctDownCount, ctButton, ctButton, 0, 0, 0, 0}, - {ctfAUDIOTAUNT3_KEY, ctDownCount, ctKey, ctKey, 0, 0, 0, 0}, - {ctfAUDIOTAUNT3_BTN, ctDownCount, ctButton, ctButton, 0, 0, 0, 0}, - {ctfAUDIOTAUNT4_KEY, ctDownCount, ctKey, ctKey, 0, 0, 0, 0}, - {ctfAUDIOTAUNT4_BTN, ctDownCount, ctButton, ctButton, 0, 0, 0, 0}}; + {ctfFORWARD_THRUSTAXIS, ctAnalog, {ctAxis, ctAxis}, {0, 0}, {0, 0}}, + {ctfFORWARD_THRUSTKEY, ctTime, {ctKey, ctKey}, {KEY_A, 0}, {0, 0}}, + {ctfREVERSE_THRUSTKEY, ctTime, {ctKey, ctKey}, {KEY_Z, 0}, {0, 0}}, + {ctfFORWARD_BUTTON, ctTime, {ctButton, ctButton}, {0, 0}, {0, 0}}, + {ctfREVERSE_BUTTON, ctTime, {ctButton, ctButton}, {0, 0}, {0, 0}}, + {ctfUP_THRUSTAXIS, ctAnalog, {ctAxis, ctAxis}, {0, 0}, {0, 0}}, + {ctfUP_BUTTON, ctDigital, {ctPOV, ctButton}, {JOYPOV_UP, 0}, {0, 0}}, + {ctfUP_THRUSTKEY, ctTime, {ctKey, ctKey}, {KEY_PADMINUS, 0}, {0, 0}}, + {ctfDOWN_BUTTON, ctDigital, {ctPOV, ctButton}, {JOYPOV_DOWN, 0}, {0, 0}}, + {ctfDOWN_THRUSTKEY, ctTime, {ctKey, ctKey}, {KEY_PADPLUS, 0}, {0, 0}}, + {ctfRIGHT_THRUSTAXIS, ctAnalog, {ctAxis, ctAxis}, {0, 0}, {0, 0}}, + {ctfRIGHT_BUTTON, ctDigital, {ctPOV, ctButton}, {JOYPOV_RIGHT, 0}, {0, 0}}, + {ctfRIGHT_THRUSTKEY, ctTime, {ctKey, ctKey}, {KEY_PAD3, 0}, {0, 0}}, + {ctfLEFT_BUTTON, ctDigital, {ctPOV, ctButton}, {JOYPOV_LEFT, 0}, {0, 0}}, + {ctfLEFT_THRUSTKEY, ctTime, {ctKey, ctKey}, {KEY_PAD1, 0}, {0, 0}}, + {ctfPITCH_DOWNAXIS, ctAnalog, {ctAxis, ctMouseAxis}, {0, CT_Y_AXIS}, {0, 0}}, + {ctfPITCH_DOWNKEY, ctTime, {ctKey, ctKey}, {KEY_UP, KEY_PAD8}, {0, 0}}, + {ctfPITCH_DOWNBUTTON, ctDigital, {ctButton, ctButton}, {0, 0}, {0, 0}}, + {ctfPITCH_UPKEY, ctTime, {ctKey, ctKey}, {KEY_DOWN, KEY_PAD2}, {0, 0}}, + {ctfPITCH_UPBUTTON, ctDigital, {ctButton, ctButton}, {0, 0}, {0, 0}}, + {ctfBANK_RIGHTAXIS, ctAnalog, {ctAxis, ctAxis}, {0, 0}, {0, 0}}, + {ctfBANK_RIGHTKEY, ctTime, {ctKey, ctKey}, {KEY_E, KEY_PAD9}, {0, 0}}, + {ctfBANK_RIGHTBUTTON, ctDigital, {ctButton, ctButton}, {0, 0}, {0, 0}}, + {ctfBANK_LEFTKEY, ctTime, {ctKey, ctKey}, {KEY_Q, KEY_PAD7}, {0, 0}}, + {ctfBANK_LEFTBUTTON, ctDigital, {ctButton, ctButton}, {0, 0}, {0, 0}}, + {ctfHEADING_RIGHTAXIS, ctAnalog, {ctAxis, ctMouseAxis}, {0, CT_X_AXIS}, {0, 0}}, + {ctfHEADING_RIGHTKEY, ctTime, {ctKey, ctKey}, {KEY_RIGHT, KEY_PAD6}, {0, 0}}, + {ctfHEADING_RIGHTBUTTON, ctDigital, {ctButton, ctButton}, {0, 0}, {0, 0}}, + {ctfHEADING_LEFTKEY, ctTime, {ctKey, ctKey}, {KEY_LEFT, KEY_PAD4}, {0, 0}}, + {ctfHEADING_LEFTBUTTON, ctDigital, {ctButton, ctButton}, {0, 0}, {0, 0}}, + {ctfFIREPRIMARY_BUTTON, ctTime, {ctButton, ctMouseButton}, {1, 1}, {0, 0}}, + {ctfFIREPRIMARY_KEY, ctTime, {ctKey, ctKey}, {KEY_LCTRL, KEY_RCTRL}, {0, 0}}, + {ctfFIREPRIMARY_KEY2, ctTime, {ctKey, ctKey}, {0, 0}, {0, 0}}, + {ctfFIRESECONDARY_BUTTON, ctTime, {ctButton, ctMouseButton}, {2, 2}, {0, 0}}, + {ctfFIRESECONDARY_KEY, ctTime, {ctKey, ctKey}, {KEY_SPACEBAR, 0}, {0, 0}}, + {ctfTOGGLE_SLIDEBUTTON, ctTime, {ctButton, ctButton}, {0, 0}, {0, 0}}, + {ctfTOGGLE_SLIDEKEY, ctTime, {ctKey, ctKey}, {KEY_LALT, 0}, {0, 0}}, + {ctfTOGGLE_BANKBUTTON, ctTime, {ctButton, ctButton}, {0, 0}, {0, 0}}, + {ctfTOGGLE_BANKKEY, ctTime, {ctKey, ctKey}, {0, 0}, {0, 0}}, + {ctfFIREFLARE_BUTTON, ctTime, {ctButton, ctMouseButton}, {3, 3}, {0, 0}}, + {ctfFIREFLARE_KEY, ctDownCount, {ctKey, ctKey}, {KEY_F, 0}, {0, 0}}, + {ctfAFTERBURN_BUTTON, ctTime, {ctButton, ctButton}, {0, 0}, {0, 0}}, + {ctfAFTERBURN_KEY, ctTime, {ctKey, ctKey}, {KEY_S, 0}, {0, 0}}, + {ctfAUTOMAP_KEY, ctDownCount, {ctKey, ctKey}, {KEY_TAB, 0}, {0, 0}}, + {ctfPREV_INVKEY, ctDownCount, {ctKey, ctKey}, {KEY_LBRACKET, 0}, {0, 0}}, + {ctfNEXT_INVKEY, ctDownCount, {ctKey, ctKey}, {KEY_RBRACKET, 0}, {0, 0}}, + {ctfINV_USEKEY, ctDownCount, {ctKey, ctKey}, {KEY_BACKSLASH, 0}, {0, 0}}, + {ctfPREV_CNTMSKEY, ctDownCount, {ctKey, ctKey}, {KEY_SEMICOL, 0}, {0, 0}}, + {ctfNEXT_CNTMSKEY, ctDownCount, {ctKey, ctKey}, {KEY_RAPOSTRO, 0}, {0, 0}}, + {ctfCNTMS_USEKEY, ctDownCount, {ctKey, ctKey}, {KEY_ENTER, 0}, {0, 0}}, + {ctfHEADLIGHT_KEY, ctDownCount, {ctKey, ctKey}, {KEY_H, 0}, {0, 0}}, + {ctfHEADLIGHT_BUTTON, ctDownCount, {ctButton, ctButton}, {0, 0}, {0, 0}}, + {ctfAUTOMAP_BUTTON, ctDownCount, {ctButton, ctButton}, {0, 0}, {0, 0}}, + {ctfPREV_INVBTN, ctDownCount, {ctButton, ctButton}, {0, 0}, {0, 0}}, + {ctfNEXT_INVBTN, ctDownCount, {ctButton, ctButton}, {0, 0}, {0, 0}}, + {ctfINV_USEBTN, ctDownCount, {ctButton, ctButton}, {0, 0}, {0, 0}}, + {ctfPREV_CNTMSBTN, ctDownCount, {ctButton, ctButton}, {0, 0}, {0, 0}}, + {ctfNEXT_CNTMSBTN, ctDownCount, {ctButton, ctButton}, {0, 0}, {0, 0}}, + {ctfCNTMS_USEBTN, ctDownCount, {ctButton, ctMouseButton}, {4, 4}, {0, 0}}, + {ctfWPNSEL_PCYCLEKEY, ctDownCount, {ctKey, ctKey}, {KEY_COMMA, 0}, {0, 0}}, + {ctfWPNSEL_PCYCLEBTN, ctDownCount, {ctButton, ctMouseButton}, {0, 5}, {0, 0}}, + {ctfWPNSEL_SCYCLEKEY, ctDownCount, {ctKey, ctKey}, {KEY_PERIOD, 0}, {0, 0}}, + {ctfWPNSEL_SCYCLEBTN, ctDownCount, {ctButton, ctMouseButton}, {0, 6}, {0, 0}}, + {ctfREARVIEW_KEY, ctDownCount, {ctKey, ctKey}, {KEY_R, 0}, {0, 0}}, + {ctfREARVIEW_BTN, ctDownCount, {ctButton, ctButton}, {0, 0}, {0, 0}}, + {ctfAUDIOTAUNT1_KEY, ctDownCount, {ctKey, ctKey}, {0, 0}, {0, 0}}, + {ctfAUDIOTAUNT1_BTN, ctDownCount, {ctButton, ctButton}, {0, 0}, {0, 0}}, + {ctfAUDIOTAUNT2_KEY, ctDownCount, {ctKey, ctKey}, {0, 0}, {0, 0}}, + {ctfAUDIOTAUNT2_BTN, ctDownCount, {ctButton, ctButton}, {0, 0}, {0, 0}}, + {ctfAUDIOTAUNT3_KEY, ctDownCount, {ctKey, ctKey}, {0, 0}, {0, 0}}, + {ctfAUDIOTAUNT3_BTN, ctDownCount, {ctButton, ctButton}, {0, 0}, {0, 0}}, + {ctfAUDIOTAUNT4_KEY, ctDownCount, {ctKey, ctKey}, {0, 0}, {0, 0}}, + {ctfAUDIOTAUNT4_BTN, ctDownCount, {ctButton, ctButton}, {0, 0}, {0, 0}}}; // ramping macros static inline float ramp_control_value(float val, float limit, float &ramp_state, float &old_ramp_delta) { float sign = val / fabs(val), old_sign = old_ramp_delta / fabs(old_ramp_delta); diff --git a/lib/vecmat_external.h b/lib/vecmat_external.h index 5291cb8d7..90f75bd98 100644 --- a/lib/vecmat_external.h +++ b/lib/vecmat_external.h @@ -328,11 +328,11 @@ struct { }; constexpr static inline const matrix id() { - return matrix{ vector::id(0), vector::id(1), vector::id(2) }; + return matrix{ {{vector::id(0), vector::id(1), vector::id(2)}} }; } constexpr static inline const matrix ne() { - return matrix{ vector::ne(), vector::ne(), vector::ne() }; + return matrix{ {{vector::ne(), vector::ne(), vector::ne()}} }; } }; @@ -355,11 +355,11 @@ struct { }; constexpr static inline const matrix4 id() { - return matrix4{ vector4::id(0), vector4::id(1), vector4::id(2), vector4::id(3) }; + return matrix4{ {{vector4::id(0), vector4::id(1), vector4::id(2), vector4::id(3)}} }; } constexpr static inline const matrix4 ne() { - return matrix4{ vector4::ne(), vector4::ne(), vector4::ne(), vector4::ne() }; + return matrix4{ {{vector4::ne(), vector4::ne(), vector4::ne(), vector4::ne()}} }; } }; diff --git a/scripts/osiris_vector.cpp b/scripts/osiris_vector.cpp index 06595d9ef..c72b3f1ec 100644 --- a/scripts/osiris_vector.cpp +++ b/scripts/osiris_vector.cpp @@ -116,10 +116,10 @@ scalar vm_GetMagnitude(const vector *a) { void vm_ClearMatrix(matrix *dest) { memset(dest, 0, sizeof(matrix)); } void vm_MakeIdentity(matrix *dest) { - *dest = { vector::id(0), vector::id(1), vector::id(2) }; + *dest = { {{vector::id(0), vector::id(1), vector::id(2)}} }; } void vm_MakeInverseMatrix(matrix *dest) { - *dest = { -vector::id(0), -vector::id(1), -vector::id(2) }; + *dest = { {{-vector::id(0), -vector::id(1), -vector::id(2)}} }; } void vm_TransposeMatrix(matrix *m) { diff --git a/vecmat/vector.cpp b/vecmat/vector.cpp index 3aa2d0b62..893513a2b 100644 --- a/vecmat/vector.cpp +++ b/vecmat/vector.cpp @@ -212,8 +212,8 @@ scalar vm_DotProduct(const vector *u, const vector *v) { return vector::dot(*u,* void vm_CrossProduct(vector *dest, const vector *u, const vector *v) { *dest = vector::cross3(*u,*v); } scalar vm_GetMagnitude(const vector *a) { return (scalar)sqrt(vector::dot(*a,*a)); } void vm_ClearMatrix(matrix *dest) { memset(dest, 0, sizeof(matrix)); } -void vm_MakeIdentity(matrix *dest) { *dest = { vector::id(0), vector::id(1), vector::id(2) }; } -void vm_MakeInverseMatrix(matrix *dest) { *dest = { -vector::id(0), -vector::id(1), vector::id(2) }; } +void vm_MakeIdentity(matrix *dest) { *dest = { {{vector::id(0), vector::id(1), vector::id(2)}} }; } +void vm_MakeInverseMatrix(matrix *dest) { *dest = { {{-vector::id(0), -vector::id(1), vector::id(2)}} }; } void vm_TransposeMatrix(matrix *m) { // Transposes a matrix in place From 0607971a58fc66c7ef669a6cde643936f8e3f74c Mon Sep 17 00:00:00 2001 From: Louis Gombert Date: Tue, 20 May 2025 18:47:43 +0200 Subject: [PATCH 03/24] Fix warning -Wunknown-pragmas These pragmas were not useful or considered by any compilre, so we can safely remove them now. --- Descent3/BOA.cpp | 5 ----- fix/fix.cpp | 3 --- scripts/osiris_vector.h | 3 --- stream_audio/streamaudio.cpp | 8 ++------ 4 files changed, 2 insertions(+), 17 deletions(-) diff --git a/Descent3/BOA.cpp b/Descent3/BOA.cpp index 237680cdd..e4477f343 100644 --- a/Descent3/BOA.cpp +++ b/Descent3/BOA.cpp @@ -1194,9 +1194,6 @@ void compute_blockage_info() { // Goes through all the valid points in the indoor engine and returns a unique // checksum - -#pragma optimize("", off) - int BOAGetMineChecksum() { int i, t, k; int total = 0; @@ -1283,8 +1280,6 @@ int BOAGetRoomChecksum(int i) { return (int)total; } -#pragma optimize("", on) - bool IsPathPointValid(int room, vector *pos) { // vector c_pnt = Rooms[room].path_pnt; int i; diff --git a/fix/fix.cpp b/fix/fix.cpp index 7b9da0147..e72147bc6 100644 --- a/fix/fix.cpp +++ b/fix/fix.cpp @@ -125,9 +125,6 @@ scalar FixCos(angle a) { return (scalar)(c0 + ((c1 - c0) * (double)f / 256.0)); } -// Get rid of the "no return value" warnings in the next three functions -#pragma warning(disable : 4035) - // compute inverse sine angle FixAsin(scalar v) { fix vv; diff --git a/scripts/osiris_vector.h b/scripts/osiris_vector.h index 5a46007c4..20d8e0fc7 100644 --- a/scripts/osiris_vector.h +++ b/scripts/osiris_vector.h @@ -24,9 +24,6 @@ const vector Zero_vector = vector::ne(); -// Disable the "possible loss of data" warning -#pragma warning(disable : 4244) - // Used for debugging. It is used in printf's so we do not have to write out the structure 3 times // to print all the coordinates. #define XYZ(v) (v)->x(), (v)->y(), (v)->z() diff --git a/stream_audio/streamaudio.cpp b/stream_audio/streamaudio.cpp index 90a058d83..e23e23347 100644 --- a/stream_audio/streamaudio.cpp +++ b/stream_audio/streamaudio.cpp @@ -747,7 +747,6 @@ void AudioStream::Reset() { } ////////////////////////////////////////////////////////////////////////////// // invoked by AudioStreamCB. -#pragma optimize("", off) void *AudioStream::StreamCallback(int *size) { uint8_t nextbuffer = (m_sbufidx + 1) % STRM_BUFCOUNT; void *data = NULL; @@ -810,7 +809,7 @@ void *AudioStream::StreamCallback(int *size) { } return data; } -#pragma optimize("", on) + // reads in decompressed raw data. int AudioStream::ReadFileData(int buf, int len) { if (!m_archive.Opened()) @@ -831,9 +830,7 @@ int AudioStream::ReadFileData(int buf, int len) { return m_archive.Read(m_buffer[buf].data, len); } -// TURN OFF OPTIMIZATIONS HERE. Placement of instructions is VERY IMPORTANT here. synched with StreamCallback, -// which also has optimizations off. -#pragma optimize("", off) + // updates file buffers void AudioStream::UpdateData() { int nextbuffer = ((m_fbufidx + 1) % STRM_BUFCOUNT); @@ -888,7 +885,6 @@ void AudioStream::UpdateData() { } } -#pragma optimize("", on) /////////////////////////////////////////////////////////////////////////////// // decoder int ADecodeFileRead(void *data, void *buf, uint32_t qty) { From 27a308efd048101a859979a7e5e7cc3e019b3671 Mon Sep 17 00:00:00 2001 From: Louis Gombert Date: Tue, 20 May 2025 18:50:48 +0200 Subject: [PATCH 04/24] Fix warning -Wunused-const-variable --- AudioEncode/aencode.cpp | 4 ---- Descent3/LoadLevel.cpp | 4 +--- physics/findintersection.cpp | 3 ++- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/AudioEncode/aencode.cpp b/AudioEncode/aencode.cpp index f1562fcb3..94a113a72 100644 --- a/AudioEncode/aencode.cpp +++ b/AudioEncode/aencode.cpp @@ -143,10 +143,6 @@ float std_hi_filter[] = { 0.0012475221f, -0.0024950907f, -0.0087309526f, 0.019957958f, 0.050528999f, -0.12055097f, -0.29304558f, 0.70617616f, }; -const float T911 = -32767.0f; -const float T913 = 32767.0f; -const float T1266 = 0.0f; - void WriteBand_Fmt0(Encoder &enc, int32_t colIndex, uint32_t formatId) {} void WriteBand_Fmt3_16(Encoder &enc, int32_t colIndex, uint32_t formatId) { diff --git a/Descent3/LoadLevel.cpp b/Descent3/LoadLevel.cpp index 16a9e40e4..07a3e7787 100644 --- a/Descent3/LoadLevel.cpp +++ b/Descent3/LoadLevel.cpp @@ -1455,8 +1455,6 @@ const tConvertObject object_convert[] = { {OBJ_POWERUP, -2, "ProxMinepowerup", CONV_MULTI}, {OBJ_POWERUP, -2, "energy", 0}}; -static constexpr int object_convert_size = std::size(object_convert); - uint32_t chunk_start, chunk_size, filelen; int CountDataToPageIn(); @@ -1512,7 +1510,7 @@ void ConvertObject(int *type, int *id) { // look at even numbered items, they are the object to convert // odd number items are destination - for (int i = 0; i < object_convert_size; i += 2) { + for (int i = 0; i < std::size(object_convert); i += 2) { if (*type == object_convert[i].type) { // type match, check id's if (object_convert[i].id == -2) { diff --git a/physics/findintersection.cpp b/physics/findintersection.cpp index bda4a06a7..dc92ee284 100644 --- a/physics/findintersection.cpp +++ b/physics/findintersection.cpp @@ -2975,9 +2975,10 @@ int sphere_intersects_wall(vector *pnt, int segnum, float rad) { static const int bbox_edges[12][2] = {{0, 1}, {1, 2}, {2, 3}, {3, 0}, {3, 4}, {2, 5}, {5, 4}, {4, 7}, {5, 6}, {7, 6}, {7, 0}, {6, 1}}; +/* static const int bbox_faces[6][4] = {{4, 5, 2, 3}, {7, 6, 5, 4}, {0, 1, 6, 7}, {0, 3, 2, 1}, {7, 4, 3, 0}, {1, 2, 5, 3}}; -/* + bool BBoxPlaneIntersection(bool fast_exit, vector *collision_point, vector *collision_normal, object *obj, vector *new_pos, int nv, vector **vertex_ptr_list, vector *face_normal) { From 35a1e2adc37fe3f730242e93835b3099a8acad04 Mon Sep 17 00:00:00 2001 From: Louis Gombert Date: Tue, 20 May 2025 18:59:06 +0200 Subject: [PATCH 05/24] Fix warning -Wsometimes-uninitialized Initialize variables that may not be assigned before being used --- Descent3/AImain.cpp | 2 +- Descent3/BOA.cpp | 4 ++-- Descent3/mission_download.cpp | 5 ++--- Descent3/pilot.cpp | 2 +- md5/md5.cpp | 2 +- netgames/dmfc/dmfcui.cpp | 5 ++--- networking/networking.cpp | 2 +- scripts/Merc3.cpp | 2 +- 8 files changed, 11 insertions(+), 13 deletions(-) diff --git a/Descent3/AImain.cpp b/Descent3/AImain.cpp index 73870a670..b799d2a72 100644 --- a/Descent3/AImain.cpp +++ b/Descent3/AImain.cpp @@ -4900,7 +4900,7 @@ void ai_move(object *obj) { int subtype = cur_goal->subtype; int vec_id = (subtype & 0xFFFFFFFE); bool f_toward = (subtype & 0x00000001); - vector *vec; + vector *vec = nullptr; // mprintf(0, "Moving relative a type %d\n", obj->type); diff --git a/Descent3/BOA.cpp b/Descent3/BOA.cpp index e4477f343..032f13857 100644 --- a/Descent3/BOA.cpp +++ b/Descent3/BOA.cpp @@ -995,7 +995,7 @@ void FindPath(int i, int j) { ASSERT(next_room <= Highest_room_index + BOA_num_terrain_regions); } - int next_portal; + int next_portal = 0; if (BOA_INDEX(next_room) != BOA_INDEX(cur_node->roomnum)) { next_portal = BOA_DetermineStartRoomPortal(next_room, NULL, cur_node->roomnum, NULL); } @@ -1053,7 +1053,7 @@ void FindPath(int i, int j) { next_room = Highest_room_index + TERRAIN_REGION(cell) + 1; } - int next_portal; + int next_portal = 0; if (BOA_INDEX(next_room) != BOA_INDEX(cur_node->roomnum)) { next_portal = BOA_DetermineStartRoomPortal(next_room, NULL, cur_node->roomnum, NULL); } diff --git a/Descent3/mission_download.cpp b/Descent3/mission_download.cpp index f494abe96..b93e8fc7a 100644 --- a/Descent3/mission_download.cpp +++ b/Descent3/mission_download.cpp @@ -516,7 +516,6 @@ void msn_DoAskForURL(uint8_t *indata, network_address *net_addr) { static msn_urls *url; int count = 0; int size; - int i; uint8_t data[MAX_GAME_DATA_SIZE]; int num_urls = 0; @@ -525,7 +524,7 @@ void msn_DoAskForURL(uint8_t *indata, network_address *net_addr) { url = msn_GetURL(Netgame.mission); if (url) { - for (i = 0; i < MAX_MISSION_URL_COUNT; i++) { + for (int i = 0; i < MAX_MISSION_URL_COUNT; i++) { if (url->URL[0]) { num_urls++; } @@ -547,7 +546,7 @@ void msn_DoAskForURL(uint8_t *indata, network_address *net_addr) { // Number of URLs MultiAddByte(num_urls, data, &count); - for (i = 0; i < num_urls; i++) { + for (int i = 0; i < num_urls; i++) { uint16_t urllen = strlen(url->URL[i]) + 1; if ((count + urllen) >= MAX_GAME_DATA_SIZE) { // if for some reason the URLS exceed what a packet can send diff --git a/Descent3/pilot.cpp b/Descent3/pilot.cpp index 2a0448b52..d4eebcb95 100644 --- a/Descent3/pilot.cpp +++ b/Descent3/pilot.cpp @@ -2269,7 +2269,7 @@ bool PltSelectShip(pilot *Pilot) { int old_bmhandle; int old_flags; bool exit_menu = false; - bool ret; + bool ret = false; // pre-initialize all variables diff --git a/md5/md5.cpp b/md5/md5.cpp index f33c05c45..c1844fe2d 100644 --- a/md5/md5.cpp +++ b/md5/md5.cpp @@ -51,7 +51,7 @@ void MD5::round(std::array &sums, const uint8_t *block) const // 64 rounds... for (uint32_t r = 0; r < 64; ++r) { - std::uint32_t f, g; + std::uint32_t f = 0, g = 0; uint32_t s = md5_round_shifts[((r >> 2) & ~3) | (r & 3)]; switch (r >> 4) { case 0: diff --git a/netgames/dmfc/dmfcui.cpp b/netgames/dmfc/dmfcui.cpp index 2c2e05859..31f87ecf6 100644 --- a/netgames/dmfc/dmfcui.cpp +++ b/netgames/dmfc/dmfcui.cpp @@ -619,8 +619,7 @@ void DMFCBase::DoDMFCUITeamPlacement(bool clients_wait, bool called_by_level_sta if (TeamDlgFinalTeamSettings[i] != TS_NOTINGAME) { // we've changed his team though - int new_team; - new_team = TeamDlgFinalTeamSettings[i]; + int new_team = TeamDlgFinalTeamSettings[i]; RequestTeamChange(new_team, i, false); // no need to spew his stuff } else { // we haven't changed his team, so he's ok on the team he's on @@ -629,7 +628,7 @@ void DMFCBase::DoDMFCUITeamPlacement(bool clients_wait, bool called_by_level_sta // this player was in the game when we brought up the dialog if (TeamDlgInitialTeamSettings[i] != TeamDlgFinalTeamSettings[i]) { // he has changed teams!! - int new_team; + int new_team = 0; if (TeamDlgFinalTeamSettings[i] != TS_NOTINGAME) { new_team = TeamDlgFinalTeamSettings[i]; } else { diff --git a/networking/networking.cpp b/networking/networking.cpp index 5343b9174..084bf150c 100644 --- a/networking/networking.cpp +++ b/networking/networking.cpp @@ -2294,7 +2294,7 @@ int nw_SendWithID(uint8_t id, uint8_t *data, int len, network_address *who_to) { SOCKET send_sock; SOCKADDR_IN sock_addr; // UDP/TCP socket structure - int ret, send_len; + int ret = 0, send_len = 0; uint8_t iaddr[6], *send_data; int16_t port; fd_set wfds; diff --git a/scripts/Merc3.cpp b/scripts/Merc3.cpp index d598eb0f7..6235cd9ed 100644 --- a/scripts/Merc3.cpp +++ b/scripts/Merc3.cpp @@ -2145,7 +2145,7 @@ void cEndSequenceInit() { /////////////////////////////////////////////////////////////////////////////// void do_endsequence_fx(char fx_type, int handle) { uint16_t id; - float time, size, speed, bloblife, blobint; + float time = 0.0f, size = 0.0f, speed = 0.0f, bloblife = 0.0f, blobint = 0.0f; int killflags = 0x60; // fireballs and breaks apart on death // do fx based on type From f537a139f8a0d917d4a10b3a1766b860b9b51bed Mon Sep 17 00:00:00 2001 From: Louis Gombert Date: Tue, 20 May 2025 19:00:42 +0200 Subject: [PATCH 06/24] Fix -W#pragma-messages Using a pragma message here is not very useful --- mem/mem.cpp | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/mem/mem.cpp b/mem/mem.cpp index 542d14cb2..38860cea9 100644 --- a/mem/mem.cpp +++ b/mem/mem.cpp @@ -212,19 +212,6 @@ #include "mem.h" #include "pserror.h" -// #define MEM_DEBUG - -#ifdef MEM_USE_RTL -#pragma message("mem.cpp: Compiling For Run-Time Library usage") -#endif - -#ifdef MEM_DEBUG -#pragma message("mem.cpp: Compiling with Debug Settings") -#endif - -#ifdef MEM_LOGFILE -#pragma message("mem.cpp: Compiling with logfile support") -#endif int Total_mem_used = 0; int Mem_high_water_mark = 0; From 5dcb35cfce8226a769fb9a5544dba2bc098d4c50 Mon Sep 17 00:00:00 2001 From: Louis Gombert Date: Tue, 20 May 2025 19:01:21 +0200 Subject: [PATCH 07/24] Fix warning -Wunused-lambda-capture --- cfile/cfile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cfile/cfile.cpp b/cfile/cfile.cpp index 16183b16b..c9d865dc0 100644 --- a/cfile/cfile.cpp +++ b/cfile/cfile.cpp @@ -136,7 +136,7 @@ std::filesystem::path cf_LocatePathCaseInsensitiveHelper(const std::filesystem:: // Search component in search_path auto const &it = std::filesystem::directory_iterator(search_path); - auto found = std::find_if(it, end(it), [&search_file, &search_path, &result](const auto& dir_entry) { + auto found = std::find_if(it, end(it), [&search_file](const auto& dir_entry) { return stricmp((const char*)dir_entry.path().filename().u8string().c_str(), (const char*)search_file.u8string().c_str()) == 0; }); From 7c004ef8b00b1edb3b5fb8558454854d92b28748 Mon Sep 17 00:00:00 2001 From: Louis Gombert Date: Tue, 20 May 2025 19:07:47 +0200 Subject: [PATCH 08/24] Fix warning -Wunused-private-field --- Descent3/hud.h | 1 - Descent3/newui_core.h | 1 - Descent3/pilot.cpp | 1 - Descent3/sdlmain.cpp | 1 - sndlib/mixer.h | 2 -- stream_audio/streamaudio.h | 2 -- 6 files changed, 8 deletions(-) diff --git a/Descent3/hud.h b/Descent3/hud.h index 75502b51a..084c4fbec 100644 --- a/Descent3/hud.h +++ b/Descent3/hud.h @@ -660,7 +660,6 @@ class MsgListConsole { char m_title[32]; char **m_conlines = nullptr; int n_conlines = 0; - int m_keydownstate; // -1 for up key, 1 for down key, 0 for none. float m_keydowntime; public: diff --git a/Descent3/newui_core.h b/Descent3/newui_core.h index 447cc21c0..ed8e8bd61 100644 --- a/Descent3/newui_core.h +++ b/Descent3/newui_core.h @@ -612,7 +612,6 @@ class newuiMenu : public UIWindow { tAlignment m_align; // alignment of text int16_t m_newoptionid; // tells that a new option has been selected. int16_t m_cursheetidx; - bool m_refreshgadgets; // refreshes gadgets on current sheet. void (*m_activate_sheet_cb)(newuiMenu *, int16_t, int16_t, void *); void (*m_option_focus_cb)(newuiMenu *, int16_t, void *); diff --git a/Descent3/pilot.cpp b/Descent3/pilot.cpp index d4eebcb95..014839654 100644 --- a/Descent3/pilot.cpp +++ b/Descent3/pilot.cpp @@ -1824,7 +1824,6 @@ class UIBmpWindow final : public UIStatic { int bm_handle = -1; float start_time; UIText text; - bool created = false; }; // struct ship_pos diff --git a/Descent3/sdlmain.cpp b/Descent3/sdlmain.cpp index 92974f5d1..929221174 100644 --- a/Descent3/sdlmain.cpp +++ b/Descent3/sdlmain.cpp @@ -130,7 +130,6 @@ void install_signal_handlers() { SetUnhandledExceptionFilter(RecordExceptionInfo // --------------------------------------------------------------------------- class oeD3LnxApp final : public oeLnxApplication { bool shutdown, final_shutdown; - int old_screen_mode; public: oeD3LnxApp(unsigned flags) : oeLnxApplication(flags) { diff --git a/sndlib/mixer.h b/sndlib/mixer.h index 890b3b36b..1bd23db74 100644 --- a/sndlib/mixer.h +++ b/sndlib/mixer.h @@ -105,8 +105,6 @@ class software_mixer { llsSystem *m_ll_sound_ptr; bool m_init; sound_buffer *m_primary_buffer; - int *Fast_mixer; - int Fast_mixer_len; int m_primary_alignment; int m_BufferSize; diff --git a/stream_audio/streamaudio.h b/stream_audio/streamaudio.h index 1679555aa..d2aee280a 100644 --- a/stream_audio/streamaudio.h +++ b/stream_audio/streamaudio.h @@ -247,7 +247,6 @@ class AudioStream { float m_last_frametime; uint8_t m_sbufidx; // stream position markers uint8_t m_fbufidx; // file position markers - uint8_t m_curbufidx; // current buffer in measure index uint8_t m_playcount; bool m_readahead; // if stream is currently reading from disk bool m_readahead_finished_loop; // if a loop's readahead has finished @@ -264,7 +263,6 @@ class AudioStream { int m_playbytesleft, m_playbytestotal; int m_curid; // stream's id # int *m_stopflag; // location of stop flag used in stop function - bool m_loop; // are we looping? bool m_stopnextmeasure; // stop on next measure. bool m_start_on_frame; // we will play this stream on the next ::Frame call. bool m_start_on_frame_looped; // the stream that will play on next frame is looped. From c97f7b76e2b30a3c1032116e61131fca00fa24be Mon Sep 17 00:00:00 2001 From: Louis Gombert Date: Tue, 20 May 2025 19:09:09 +0200 Subject: [PATCH 09/24] Fix warning -Wunused-label --- scripts/aigame2.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/aigame2.cpp b/scripts/aigame2.cpp index 34704f3ef..57d4a0600 100644 --- a/scripts/aigame2.cpp +++ b/scripts/aigame2.cpp @@ -1332,7 +1332,6 @@ void aiCreeper::set_state(int me_handle, int state) { float circle_dist; char cenable; -retry_set_state: switch (state) { case STATE_IDLE: // stay at one position until ready. note that if attacked , it will flee in this state. From 6a3e3a4d879053fa3caeeb5266e4cd64b996c940 Mon Sep 17 00:00:00 2001 From: Louis Gombert Date: Tue, 20 May 2025 19:34:25 +0200 Subject: [PATCH 10/24] Fix warning -Wunused-value Comment single values following an expression, that may or may not be part of it. --- Descent3/ObjInit.cpp | 2 +- Descent3/hud.cpp | 1 - cfile/cfile.cpp | 6 +++--- scripts/AIGame.cpp | 8 ++++---- sndlib/mixer.cpp | 2 +- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Descent3/ObjInit.cpp b/Descent3/ObjInit.cpp index 1f6c0c44d..b1bc04fef 100644 --- a/Descent3/ObjInit.cpp +++ b/Descent3/ObjInit.cpp @@ -734,7 +734,7 @@ int ObjInitGeneric(object *objp, bool reinit) { // Deal with deleted type if (obj_info->type == OBJ_NONE) { int i; - for (i = 0, obj_info = Object_info; i < MAX_OBJECT_IDS; i++, obj_info) { // find other object of same type + for (i = 0, obj_info = Object_info; i < MAX_OBJECT_IDS; i++) { // find other object of same type if (Object_info[i].type == objp->type) break; } diff --git a/Descent3/hud.cpp b/Descent3/hud.cpp index 319aaff82..2513d024f 100644 --- a/Descent3/hud.cpp +++ b/Descent3/hud.cpp @@ -915,7 +915,6 @@ void UpdateCustomtext2HUDItem(char *text) { if (HUD_array[i].stat && (HUD_array[i].type == HUD_ITEM_CUSTOMTEXT2)) { ASSERT(HUD_array[i].data.text != NULL); strncpy(HUD_array[i].data.text, text, HUD_array[i].buffer_size); - HUD_array[i].data.text[HUD_array[i].buffer_size - 1]; break; } } diff --git a/cfile/cfile.cpp b/cfile/cfile.cpp index c9d865dc0..f7251f855 100644 --- a/cfile/cfile.cpp +++ b/cfile/cfile.cpp @@ -155,14 +155,14 @@ std::filesystem::path cf_LocatePathCaseInsensitiveHelper(const std::filesystem:: std::vector cf_LocatePathMultiplePathsHelper(const std::filesystem::path &relative_path, bool stop_after_first_result) { - ASSERT(("realative_path should be a relative path.", relative_path.is_relative())); + ASSERT("relative_path should be a relative path." && relative_path.is_relative()); std::vector return_value = { }; for (auto base_directories_iterator = Base_directories.rbegin(); base_directories_iterator != Base_directories.rend(); ++base_directories_iterator) { - ASSERT(("base_directory should be an absolute path.", base_directories_iterator->is_absolute())); + ASSERT("base_directory should be an absolute path." && base_directories_iterator->is_absolute()); auto to_append = cf_LocatePathCaseInsensitiveHelper(relative_path, *base_directories_iterator); - ASSERT(("to_append should be either empty or an absolute path.", to_append.empty() || to_append.is_absolute())); + ASSERT("to_append should be either empty or an absolute path." && (to_append.empty() || to_append.is_absolute())); if (std::filesystem::exists(to_append)) { return_value.push_back(to_append); if (stop_after_first_result) { diff --git a/scripts/AIGame.cpp b/scripts/AIGame.cpp index a052848f4..13eb77b2c 100644 --- a/scripts/AIGame.cpp +++ b/scripts/AIGame.cpp @@ -10155,7 +10155,7 @@ void Sniper::SetMode(int me, char mode) { AI_Value(me, VF_SET, AIV_F_MAX_SPEED, &memory->base_speed); AI_Value(me, VF_SET, AIV_F_MAX_DELTA_SPEED, &memory->base_acc); memory->time_till_next_mode = 5.0f * (float)rand() / (float)RAND_MAX; - +6.0f; + // +6.0f; LGT: Highlighted by formatter. Should be part of the previous statement? } break; } @@ -10286,7 +10286,7 @@ void SniperNoRun::SetMode(int me, char mode) { AI_Value(me, VF_SET, AIV_F_MAX_SPEED, &memory->base_speed); AI_Value(me, VF_SET, AIV_F_MAX_DELTA_SPEED, &memory->base_acc); memory->time_till_next_mode = 5.0f * (float)rand() / (float)RAND_MAX; - +4.0f; + // +4.0f; LGT: Highlighted by formatter. Should be part of the previous statement? } break; } @@ -10411,7 +10411,7 @@ void EvaderModA::SetMode(int me, char mode) { } memory->time_till_next_mode = 4.0f * (float)rand() / (float)RAND_MAX; - +6.0f; + // +6.0f; LGT: Highlighted by formatter. Should be part of the previous statement? } break; } @@ -10526,7 +10526,7 @@ void FlameRAS::SetMode(int me, char mode) { } memory->time_till_next_mode = 4.0f * (float)rand() / (float)RAND_MAX; - +6.0f; + // +6.0f; LGT: Highlighted by formatter. Should be part of the previous statement? } break; } diff --git a/sndlib/mixer.cpp b/sndlib/mixer.cpp index 4ec47df1e..8074dcf9d 100644 --- a/sndlib/mixer.cpp +++ b/sndlib/mixer.cpp @@ -620,6 +620,6 @@ inline void opti_16s_mix(int16_t *cur_sample_16bit, const int num_write, int &sa *mb = (int16_t)l_sample; mb++; *mb = (int16_t)r_sample; - *mb++; + // *mb++; LGT: Statement has not effect. Should be mb++? } } From 2e7c78e8a69d55f34d58ae986405be502da7b34c Mon Sep 17 00:00:00 2001 From: Louis Gombert Date: Tue, 20 May 2025 20:07:12 +0200 Subject: [PATCH 11/24] Fix warning -Wunused-but-set-variable Remove unused but set variables, keep code when it makes sense --- Descent3/BOA.cpp | 24 ++++++++---------------- Descent3/BriefingParse.cpp | 10 ++-------- Descent3/bnode.cpp | 2 -- Descent3/bsp.cpp | 4 +--- Descent3/mission_download.cpp | 7 ++----- bitmap/iff.cpp | 4 ++-- bitmap/tga.cpp | 10 ++-------- cfile/cfile.cpp | 9 ++++----- ddio/lnxmouse.cpp | 2 -- ddio/sdlcontroller.cpp | 4 ---- grtext/grtext.cpp | 2 -- physics/collide.cpp | 6 +----- sndlib/ddsoundload.cpp | 4 +--- sndlib/sdlsound.cpp | 29 +---------------------------- stream_audio/streamaudio.cpp | 5 +---- 15 files changed, 25 insertions(+), 97 deletions(-) diff --git a/Descent3/BOA.cpp b/Descent3/BOA.cpp index 032f13857..cd3b15a0a 100644 --- a/Descent3/BOA.cpp +++ b/Descent3/BOA.cpp @@ -702,7 +702,6 @@ void add_terrain_cell(int cell, int t_region, char *checked) { void compute_terrain_region_info() { int i; bool done = false; - bool f_warning = false; char checked[TERRAIN_WIDTH * TERRAIN_DEPTH]; for (i = 0; i < TERRAIN_WIDTH * TERRAIN_DEPTH; i++) { @@ -776,10 +775,14 @@ void compute_terrain_region_info() { int region = TERRAIN_REGION(cell); - if (!(BOA_num_connect[region] < MAX_PATH_PORTALS)) { - f_warning = true; - break; - } +#ifdef EDITOR + if (!(BOA_num_connect[region] < MAX_PATH_PORTALS)) { + OutrageMessageBox( + "This terrain has too many fly through\nterrain-mine connections!\n\nAI will not work correctly outside!\nIf " + "you really cannot fly outside\nignore this message.\n\nSee Chris for specific instructions!"); + } + break; +#endif // if(region != 0) // { @@ -798,14 +801,6 @@ void compute_terrain_region_info() { } } } - -#ifdef EDITOR - if (f_warning) { - OutrageMessageBox( - "This terrain has too many fly through\nterrain-mine connections!\n\nAI will not work correctly outside!\nIf " - "you really cannot fly outside\nignore this message.\n\nSee Chris for specific instructions!"); - } -#endif } #define MAX_SOUND_PROP_DIST 400.0f @@ -2390,7 +2385,6 @@ void ComputeAABB(bool f_full) { vector min_xyz; vector max_xyz; int pamount[6]; - int nonpart = 0; if (rp->num_bbf_regions != 0) { for (x = 0; x < rp->num_bbf_regions; x++) { @@ -2511,8 +2505,6 @@ void ComputeAABB(bool f_full) { rp->bbf_list[27 + r_struct_list[i][count] - 1][rp->num_bbf[27 + r_struct_list[i][count] - 1]++] = count; } - - nonpart++; } else { // bool f_found = false; // int best; diff --git a/Descent3/BriefingParse.cpp b/Descent3/BriefingParse.cpp index 0dfbdcd04..c23b0d551 100644 --- a/Descent3/BriefingParse.cpp +++ b/Descent3/BriefingParse.cpp @@ -311,7 +311,6 @@ int CBriefParse::ParseBriefing(const char *filename) { title_buf[0] = 0; // Read & parse lines - int bytes_read; const char *p; linebuf = NULL; @@ -327,7 +326,7 @@ int CBriefParse::ParseBriefing(const char *filename) { } // Read the line - bytes_read = ReadFullLine(&linebuf, ifile); + ReadFullLine(&linebuf, ifile); linenum++; if (!linebuf) { @@ -424,19 +423,16 @@ int CBriefParse::ParseBriefing(const char *filename) { char buffer[_MAX_PATH]; char token[30]; - int vflags = 0; bool bitdepthset = false; while (!play) { PARSE_TOKEN(token); if (!stricmp(token, "play")) play = true; else if (!stricmp(token, "8bit")) { - vflags |= VF_8BIT; bitdepthset = true; + // LGT: Values unused } else if (!stricmp(token, "compressed")) { - vflags |= VF_COMPRESSED; } else if (!stricmp(token, "stereo")) { - vflags |= VF_STEREO; } else if (!stricmp(buffer, "isset")) { int value, bit = 0x01; PARSE_INT(value); @@ -456,8 +452,6 @@ int CBriefParse::ParseBriefing(const char *filename) { } else ParseError("Illegal parameter in $VOICE"); } - if (!bitdepthset) - vflags |= VF_16BIT | VF_INTERUPT | VF_FORCE; PARSE_STRING(buffer); diff --git a/Descent3/bnode.cpp b/Descent3/bnode.cpp index d722fa884..83adf240b 100644 --- a/Descent3/bnode.cpp +++ b/Descent3/bnode.cpp @@ -302,7 +302,6 @@ static char BNode_vis[MAX_BNODES_PER_ROOM]; int BNode_FindDirLocalVisibleBNode(int roomnum, vector *pos, vector *fvec, float rad) { int i; - float best_dot = -1.01f; float closest_dist = 800.0f; int closest_node = -1; bool f_retry = false; @@ -355,7 +354,6 @@ int BNode_FindDirLocalVisibleBNode(int roomnum, vector *pos, vector *fvec, float if (fvi_FindIntersection(&fq, &hit_info) == HIT_NONE) { BNode_vis[i] = VIS_OK; - best_dot = dot; closest_node = i; } else { if (!f_retry) { diff --git a/Descent3/bsp.cpp b/Descent3/bsp.cpp index 9a29b4868..a99a70342 100644 --- a/Descent3/bsp.cpp +++ b/Descent3/bsp.cpp @@ -535,7 +535,7 @@ int BuildBSPNode(bspnode *tree, listnode **polylist, int numpolys) { bspnode *frontnode, *backnode; listnode *frontlist = NULL, *backlist = NULL; bspplane partition_plane; - int numfront = 0, numback = 0, numsplits = 0; + int numfront = 0, numback = 0; ASSERT(numpolys > 0); partition_poly = SelectPlane(polylist); @@ -672,8 +672,6 @@ int BuildBSPNode(bspnode *tree, listnode **polylist, int numpolys) { ASSERT(fate == BSP_SPANNING); bsppolygon *frontpoly, *backpoly; - numsplits++; - SplitPolygon(&partition_plane, testpoly, &frontpoly, &backpoly); numfront++; diff --git a/Descent3/mission_download.cpp b/Descent3/mission_download.cpp index b93e8fc7a..cdd9e9867 100644 --- a/Descent3/mission_download.cpp +++ b/Descent3/mission_download.cpp @@ -307,7 +307,6 @@ int msn_ShowDownloadChoices(msn_urls *urls) { #define MSN_MAX_STRING_LEN 100 bool msn_DownloadWithStatus(const char *url, const std::filesystem::path &filename) { - float last_refresh; uint64_t total_bytes = 0; uint64_t received_bytes = 0; int time_elapsed = 0; @@ -389,8 +388,6 @@ bool msn_DownloadWithStatus(const char *url, const std::filesystem::path &filena MSN_DWNLD_STATUS_H - OKCANCEL_YOFFSET, 0, 0, UIF_FIT | UIF_CENTER); menu_wnd.Open(); - last_refresh = timer_GetTime() - MSN_REFRESH_INTERVAL; - std::string download_uri = "/" + StringJoin(std::vector(url_parts.begin() + 3, url_parts.end()), "/"); D3::HttpClient http_client(download_url); @@ -457,7 +454,6 @@ bool msn_DownloadWithStatus(const char *url, const std::filesystem::path &filena } } - last_refresh = timer_GetTime(); time_elapsed = timer_GetTime() - starttime; if (total_bytes) { @@ -522,9 +518,10 @@ void msn_DoAskForURL(uint8_t *indata, network_address *net_addr) { if (Netgame.local_role == LR_SERVER) { size = START_DATA(MP_CUR_MSN_URLS, data, &count); + int i = 0; url = msn_GetURL(Netgame.mission); if (url) { - for (int i = 0; i < MAX_MISSION_URL_COUNT; i++) { + for (i = 0; i < MAX_MISSION_URL_COUNT; i++) { if (url->URL[0]) { num_urls++; } diff --git a/bitmap/iff.cpp b/bitmap/iff.cpp index acc875709..09d7a9828 100644 --- a/bitmap/iff.cpp +++ b/bitmap/iff.cpp @@ -549,7 +549,7 @@ int bm_iff_read_animbrush(const char *ifilename, int *bm_list) { CFILE *ifile; iff_bitmap_header bm_headers[40]; iff_bitmap_header *temp_bm_head; - int32_t sig, form_len; + int32_t sig; int32_t form_type; int num_bitmaps = 0; int ret, i; @@ -562,7 +562,7 @@ int bm_iff_read_animbrush(const char *ifilename, int *bm_list) { return -1; sig = bm_iff_get_sig(ifile); - form_len = cf_ReadInt(ifile, false); + cf_ReadInt(ifile, false); // form_len if (sig != IFF_SIG_FORM) { LOG_ERROR << "Not a valid IFF file."; diff --git a/bitmap/tga.cpp b/bitmap/tga.cpp index 515a7b1ff..5a67e2216 100644 --- a/bitmap/tga.cpp +++ b/bitmap/tga.cpp @@ -326,7 +326,7 @@ int bm_tga_alloc_file(CFILE *infile, char *name, int format) { uint8_t upside_down = 0; uint16_t width, height; uint32_t pixel; - int i, t, n, data8bit = 0, savepos = 0; + int i, t, n, savepos = 0; int mipped = 0; int num_mips = 1; int read_ok = 1; @@ -343,9 +343,6 @@ int bm_tga_alloc_file(CFILE *infile, char *name, int format) { return -1; } - if (image_type == OUTRAGE_COMPRESSED_OGF_8BIT) - data8bit = 1; - if (image_type == OUTRAGE_4444_COMPRESSED_MIPPED || image_type == OUTRAGE_1555_COMPRESSED_MIPPED || image_type == OUTRAGE_NEW_COMPRESSED_MIPPED || image_type == OUTRAGE_TGA_TYPE || image_type == OUTRAGE_COMPRESSED_MIPPED || image_type == OUTRAGE_COMPRESSED_OGF || @@ -538,7 +535,7 @@ int bm_page_in_file(int n) { uint8_t image_id_len, color_map_type, image_type, pixsize, descriptor; uint8_t upside_down = 0; uint16_t width, height; - int i, data8bit = 0, savepos = 0; + int i, savepos = 0; int mipped = 0, file_mipped = 0; int num_mips = 1; char name[BITMAP_NAME_LEN]; @@ -566,9 +563,6 @@ int bm_page_in_file(int n) { return -1; } - if (image_type == OUTRAGE_COMPRESSED_OGF_8BIT) - data8bit = 1; - if (image_type == OUTRAGE_4444_COMPRESSED_MIPPED || image_type == OUTRAGE_1555_COMPRESSED_MIPPED || image_type == OUTRAGE_NEW_COMPRESSED_MIPPED || image_type == OUTRAGE_TGA_TYPE || image_type == OUTRAGE_COMPRESSED_MIPPED || image_type == OUTRAGE_COMPRESSED_OGF || diff --git a/cfile/cfile.cpp b/cfile/cfile.cpp index f7251f855..18194c9b3 100644 --- a/cfile/cfile.cpp +++ b/cfile/cfile.cpp @@ -713,18 +713,17 @@ int cfexist(const std::filesystem::path &filename) { // Returns the number of bytes read. // Throws an exception of type (cfile_error *) if the OS returns an error on read int cf_ReadBytes(uint8_t *buf, int count, CFILE *cfp) { - int i; - const char *error_msg = eof_error; // default error ASSERT(!(cfp->flags & CFF_TEXT)); if (cfp->position + count <= cfp->size) { - i = fread(buf, 1, count, cfp->file); + int i = fread(buf, 1, count, cfp->file); if (i == count) { cfp->position += i; return i; } // if not EOF, then get the error message - if (!feof(cfp->file)) - error_msg = strerror(errno); + if (!feof(cfp->file)) { + ThrowCFileError(CFE_READING, cfp, strerror(errno)); + } } LOG_ERROR.printf("Error reading %d bytes from position %d of file <%s>; errno=%d.", count, cfp->position, cfp->name, errno); diff --git a/ddio/lnxmouse.cpp b/ddio/lnxmouse.cpp index ba70b9b8d..8b70db8e4 100644 --- a/ddio/lnxmouse.cpp +++ b/ddio/lnxmouse.cpp @@ -422,9 +422,7 @@ bool sdlMouseMotionFilter(SDL_Event const *event) { // This function will handle all mouse events. void ddio_InternalMouseFrame(void) { - static unsigned frame_count = 0; SDL_PumpEvents(); - frame_count++; } /* x, y = absolute mouse position diff --git a/ddio/sdlcontroller.cpp b/ddio/sdlcontroller.cpp index 33ff22de3..9fadbbc9e 100644 --- a/ddio/sdlcontroller.cpp +++ b/ddio/sdlcontroller.cpp @@ -954,15 +954,11 @@ int8_t sdlgameController::get_pov_controller(uint8_t pov) { } int8_t sdlgameController::get_button_controller(uint8_t btn) { - unsigned mask; - // buttons range from 1-CT_MAX_BUTTONS ASSERT(btn <= CT_MAX_BUTTONS); if (btn == NULL_BINDING) return NULL_LNXCONTROLLER; - mask = 1 << (btn - 1); - // start from controller 2 because 0, and 1 are reserved for keyboard and mouse for (int i = 2; i < m_NumControls; i++) //@@ if (((unsigned)btn < m_ControlList[i].buttons) && !(m_ControlList[i].btnmask & mask) && diff --git a/grtext/grtext.cpp b/grtext/grtext.cpp index 968169cdd..c6c206205 100644 --- a/grtext/grtext.cpp +++ b/grtext/grtext.cpp @@ -947,10 +947,8 @@ void grtext_DrawTextLine(int x, int y, char *str) { cur_x = x; for (i = 0; i < strsize; i++) { uint8_t ch, ch2; - int w; ch = (uint8_t)str[i]; ch2 = (uint8_t)str[i + 1]; - w = GRCHAR_WIDTH(Grtext_font, ch); if (ch == GR_COLOR_CHAR) { ddgr_color col; diff --git a/physics/collide.cpp b/physics/collide.cpp index eb99539cd..7194f037c 100644 --- a/physics/collide.cpp +++ b/physics/collide.cpp @@ -1047,9 +1047,8 @@ extern void DeformTerrain(vector *pos, int depth, scalar size); // Check for lava, volatile, or water surface. If contact, make special sound & kill the weapon void check_for_special_surface(object *weapon, int surface_tmap, vector *surface_normal, float hit_dot) { - bool f_forcefield, f_volatile, f_lava, f_water; + bool f_volatile, f_lava, f_water; - f_forcefield = (GameTextures[surface_tmap].flags & TF_FORCEFIELD) != 0; f_volatile = (GameTextures[surface_tmap].flags & TF_VOLATILE) != 0; f_lava = (GameTextures[surface_tmap].flags & TF_LAVA) != 0; f_water = (GameTextures[surface_tmap].flags & TF_WATER) != 0; @@ -1707,21 +1706,18 @@ void bump_obj_against_fixed(object *obj, vector *collision_point, vector *collis void bump_two_objects(object *object0, object *object1, vector *collision_point, vector *collision_normal, int damage_flag) { object *t = nullptr; - object *other = nullptr; // Determine if a moving object hits a non-moving object if ((object0->movement_type != MT_PHYSICS && object0->movement_type != MT_WALKING) || (object0->movement_type == MT_PHYSICS && object0->mtype.phys_info.velocity == Zero_vector && (object0->mtype.phys_info.flags & PF_LOCK_MASK) && (object0->mtype.phys_info.flags & PF_POINT_COLLIDE_WALLS))) { t = object1; - other = object0; *collision_normal *= -1.0f; } if ((object1->movement_type != MT_PHYSICS && object1->movement_type != MT_WALKING) || (object1->movement_type == MT_PHYSICS && object1->mtype.phys_info.velocity == Zero_vector && (object1->mtype.phys_info.flags & PF_LOCK_MASK) && (object1->mtype.phys_info.flags & PF_POINT_COLLIDE_WALLS))) { t = object0; - other = object1; } // If we hit a non-moving object... diff --git a/sndlib/ddsoundload.cpp b/sndlib/ddsoundload.cpp index 800ae19ba..a32e70c6e 100644 --- a/sndlib/ddsoundload.cpp +++ b/sndlib/ddsoundload.cpp @@ -130,7 +130,7 @@ char SoundLoadWaveFile(const char *filename, float percent_volume, int sound_fil uint32_t temp_long; // Flags for if we previously read data or a format - char f_data, f_fmt = 0; + char f_fmt = 0; // Loop counter int count; @@ -345,7 +345,6 @@ char SoundLoadWaveFile(const char *filename, float percent_volume, int sound_fil // We did find a new format type f_fmt = 1; - f_data = 0; break; // Data Chunk @@ -401,7 +400,6 @@ char SoundLoadWaveFile(const char *filename, float percent_volume, int sound_fil } // We found data, clear format flag - f_data = 1; f_fmt = 0; // Multiple waveforms, per file, are allowed break; diff --git a/sndlib/sdlsound.cpp b/sndlib/sdlsound.cpp index 1b9211395..32ebf77c1 100644 --- a/sndlib/sdlsound.cpp +++ b/sndlib/sdlsound.cpp @@ -640,38 +640,11 @@ void lnxsound::SoundStartFrame() { m_in_sound_frame = true; m_pending_actions = false; - int counter = 0, loop_counter = 0, stream_counter = 0, buf_loop_counter = 0; - -#ifdef _DEBUG - int n_p5 = 0, n_p4 = 0, n_p3 = 0, n_p2 = 0, n_p1 = 0, n_p0 = 0; -#endif - + int counter = 0; for (auto ¤t_slot : sound_cache) { sound_buffer_info *sb = ¤t_slot; if (sb->m_status != SSF_UNUSED) { counter++; - if (sb->m_status & SSF_PLAY_LOOPING) { - if (sb->m_status & SSF_BUFFERED_LOOP) - buf_loop_counter++; - loop_counter++; - } - if (sb->m_status & SSF_PLAY_STREAMING) - stream_counter++; - -#ifdef _DEBUG - if (sb->play_info->priority == SND_PRIORITY_CRITICAL) - n_p5++; - else if (sb->play_info->priority == SND_PRIORITY_HIGHEST) - n_p4++; - else if (sb->play_info->priority == SND_PRIORITY_HIGH) - n_p3++; - else if (sb->play_info->priority == SND_PRIORITY_NORMAL) - n_p2++; - else if (sb->play_info->priority == SND_PRIORITY_LOW) - n_p1++; - else if (sb->play_info->priority == SND_PRIORITY_LOWEST) - n_p0++; -#endif } } diff --git a/stream_audio/streamaudio.cpp b/stream_audio/streamaudio.cpp index e23e23347..44f96115d 100644 --- a/stream_audio/streamaudio.cpp +++ b/stream_audio/streamaudio.cpp @@ -461,22 +461,19 @@ bool AudioStream::ReopenDigitalStream(uint8_t fbufidx, int nbufs) { } // convert bufsize to true bufsize (bufsize = samples per measure for now.) - int bytesize, granularity; + int granularity = 0; switch (m_archive.StreamFormat()) { case SAF_8BIT_M: granularity = 1; break; case SAF_8BIT_S: granularity = 2; - bytesize = digihdr->measure << 1; break; case SAF_16BIT_M: granularity = 2; - bytesize = digihdr->measure << 1; break; case SAF_16BIT_S: granularity = 4; - bytesize = digihdr->measure << 2; break; } From f96576c6f6530b3f616e59dcf3352d3cdcd039e6 Mon Sep 17 00:00:00 2001 From: Louis Gombert Date: Tue, 20 May 2025 20:41:13 +0200 Subject: [PATCH 12/24] Fix warning -Woverloaded-virtual Add a missing const qualifier in parent class --- ui/uires.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/uires.h b/ui/uires.h index bd5372ea8..069b4f1c6 100644 --- a/ui/uires.h +++ b/ui/uires.h @@ -106,7 +106,7 @@ class UIItem { virtual bool draw(int x, int y, int w, int h) { return false; }; virtual int width() { return 0; }; virtual int height() { return 0; }; - virtual tUIResClass class_type() { return uiItem; }; + virtual tUIResClass class_type() const { return uiItem; }; virtual void set_alpha(uint8_t alpha){}; virtual uint8_t get_alpha() const { return 0; }; virtual void set_color(ddgr_color col){}; From cedb7688f9c6c7c142d9e92546c05d750ec4a26b Mon Sep 17 00:00:00 2001 From: Louis Gombert Date: Tue, 20 May 2025 20:52:18 +0200 Subject: [PATCH 13/24] Fix warning -Wself-assign --- Descent3/hotspotmap.cpp | 4 ---- Descent3/localization.cpp | 5 ----- Descent3/multi.cpp | 1 - bitmap/iff.cpp | 2 -- netgames/dmfc/dmfcpackets.cpp | 2 +- 5 files changed, 1 insertion(+), 13 deletions(-) diff --git a/Descent3/hotspotmap.cpp b/Descent3/hotspotmap.cpp index 8f605a40e..9b04f0712 100644 --- a/Descent3/hotspotmap.cpp +++ b/Descent3/hotspotmap.cpp @@ -295,10 +295,6 @@ void CreateWindowMap(const char *map, int width, int height, windowmap_t *wndmap working_window = -1; for (x = 0; x < width; x++) { alpha = (unsigned)map[y * width + x]; - if (alpha != 255) { - if (alpha >= 130) - alpha = alpha; - } if ((alpha >= MAX_HOTSPOTS) && (alpha != NO_ALPHA)) { // set the working_window value (needed so we know which window to work with for the writeable if (alpha != WRITEABLE_ALPHA) { diff --git a/Descent3/localization.cpp b/Descent3/localization.cpp index 711c7863b..32290011f 100644 --- a/Descent3/localization.cpp +++ b/Descent3/localization.cpp @@ -359,8 +359,6 @@ bool CreateStringTable(const char *filename, char ***table, int *size) { while (!cfeof(file)) { cf_ReadString(tempbuffer, MAX_STRING_LENGTH, file); - if (scount >= 198) - scount = scount; line_info = _parse_line_information(tempbuffer); @@ -492,9 +490,6 @@ int LoadStringFile(const char *filename, int starting_offset) { while (!cfeof(file)) { cf_ReadString(buffer, MAX_STRING_LENGTH, file); - if (scount >= 198) - scount = scount; - line_info = _parse_line_information(buffer); switch (line_info) { diff --git a/Descent3/multi.cpp b/Descent3/multi.cpp index 5cc07f12b..4a6c6abd4 100644 --- a/Descent3/multi.cpp +++ b/Descent3/multi.cpp @@ -9420,7 +9420,6 @@ void MultiDoMSafePowerup(uint8_t *data); // Takes the individual packet types and passes their data to the appropriate routines void MultiProcessData(uint8_t *data, int len, int slot, network_address *from_addr) { uint8_t type = data[0]; - len = len; int sequence = -1; // HEY!!!!! These packets are the only ones that are accepted by non-connected machines diff --git a/bitmap/iff.cpp b/bitmap/iff.cpp index 09d7a9828..efdfdcc4a 100644 --- a/bitmap/iff.cpp +++ b/bitmap/iff.cpp @@ -174,8 +174,6 @@ int bm_iff_get_sig(CFILE *f) { return (IFF_SIG_UNKNOWN); } int bm_iff_parse_bmhd(CFILE *ifile, uint32_t len, iff_bitmap_header *bmheader) { - len = len; - bmheader->w = cf_ReadShort(ifile, false); bmheader->h = cf_ReadShort(ifile, false); bmheader->x = cf_ReadShort(ifile, false); diff --git a/netgames/dmfc/dmfcpackets.cpp b/netgames/dmfc/dmfcpackets.cpp index 1eabec8f9..0a767fcb4 100644 --- a/netgames/dmfc/dmfcpackets.cpp +++ b/netgames/dmfc/dmfcpackets.cpp @@ -593,7 +593,7 @@ void DMFCBase::ReceiveControlMessage(uint8_t *data) { uint8_t src = MultiGetByte(data, &count); uint8_t dst = MultiGetByte(data, &count); - if ((GetLocalRole() == LR_SERVER) && (dst != SP_SERVER || dst != GetPlayerNum())) { + if ((GetLocalRole() == LR_SERVER) && dst != GetPlayerNum()) { // forward this packet to the correct player uint8_t fdata[MAX_GAME_DATA_SIZE]; count = 0; From 35d828811868978357e79a169514de8f8064789e Mon Sep 17 00:00:00 2001 From: Louis Gombert Date: Tue, 20 May 2025 21:37:18 +0200 Subject: [PATCH 14/24] Fix warning -Wtautological-constant-out-of-range-compare Remove test if it does not make sens or is indeed trivial, fix it by changing variable type when it makes sense --- Descent3/CtlCfgElem.cpp | 1 - Descent3/WeaponFire.cpp | 2 +- Descent3/demofile.cpp | 4 ++-- Descent3/loadstate.cpp | 2 +- Descent3/multi.cpp | 8 +++----- Descent3/multi_client.cpp | 7 ++++--- Descent3/object.cpp | 2 +- Descent3/osiris_predefs.cpp | 4 ++-- Descent3/render.cpp | 5 +++-- Descent3/viseffect_external.h | 2 +- lib/demofile.h | 2 +- netgames/ctf/ctf.cpp | 2 +- netgames/dmfc/dmfcprecord.cpp | 8 ++++++-- 13 files changed, 26 insertions(+), 23 deletions(-) diff --git a/Descent3/CtlCfgElem.cpp b/Descent3/CtlCfgElem.cpp index e5f7ae154..5cf3daff6 100644 --- a/Descent3/CtlCfgElem.cpp +++ b/Descent3/CtlCfgElem.cpp @@ -482,7 +482,6 @@ const char *cfg_binding_text(ct_type ctype, uint8_t ctrl, uint8_t binding) { switch (ctype) { case ctKey: { - ASSERT(binding < NUM_KEYBINDSTRINGS); str = Ctltext_KeyBindings[binding]; break; } diff --git a/Descent3/WeaponFire.cpp b/Descent3/WeaponFire.cpp index 9b2c59d61..9d5bda376 100644 --- a/Descent3/WeaponFire.cpp +++ b/Descent3/WeaponFire.cpp @@ -1885,7 +1885,7 @@ int FireWeaponFromObject(object *obj, int weapon_num, int gun_num, bool f_force_ } } if (Demo_flags == DF_RECORDING) { - DemoWriteWeaponFire(obj->handle & HANDLE_OBJNUM_MASK, &laser_pos, &laser_dir, (uint16_t)weapon_num, objnum, + DemoWriteWeaponFire(obj->handle & HANDLE_OBJNUM_MASK, &laser_pos, &laser_dir, weapon_num, objnum, gun_num); } diff --git a/Descent3/demofile.cpp b/Descent3/demofile.cpp index 46aed3f28..f6b9f4507 100644 --- a/Descent3/demofile.cpp +++ b/Descent3/demofile.cpp @@ -480,7 +480,7 @@ void DemoWriteChangedObj(object *op) { } } -void DemoWriteWeaponFire(uint16_t objectnum, vector *pos, vector *dir, uint16_t weaponnum, uint16_t weapobjnum, +void DemoWriteWeaponFire(uint16_t objectnum, vector *pos, vector *dir, uint16_t weaponnum, int16_t weapobjnum, int16_t gunnum) { uint32_t uniqueid = MultiGetMatchChecksum(OBJ_WEAPON, weaponnum); if (weapobjnum == -1) @@ -649,7 +649,7 @@ void DemoReadKillObject(void) { return; // bail if invalid object type ps_srand(seed); - KillObject(&Objects[hit_objnum], (killer != 65535) ? &Objects[killer] : NULL, damage, death_flags, delay); + KillObject(&Objects[hit_objnum], &Objects[killer], damage, death_flags, delay); } void DemoWritePlayerDeath(object *player, bool melee, int fate) { diff --git a/Descent3/loadstate.cpp b/Descent3/loadstate.cpp index 971d2bd02..e9b072f10 100644 --- a/Descent3/loadstate.cpp +++ b/Descent3/loadstate.cpp @@ -1291,7 +1291,7 @@ int LGSObjects(CFILE *fp, int version) { int num_wbs = pm->num_wbs; int count = 0; for (int j = 0; j < num_wbs; j++) { - ASSERT(pm->poly_wb[j].num_turrets >= 0 && pm->poly_wb[j].num_turrets <= 6400); + ASSERT(pm->poly_wb[j].num_turrets >= 0); count += pm->poly_wb[j].num_turrets; } diff --git a/Descent3/multi.cpp b/Descent3/multi.cpp index 4a6c6abd4..73692feff 100644 --- a/Descent3/multi.cpp +++ b/Descent3/multi.cpp @@ -4458,7 +4458,6 @@ void MultiDoWorldStates(uint8_t *data) { spew.speed = MultiGetFloat(data, &count); uint16_t local_spewnum = SpewCreate(&spew); - ASSERT(local_spewnum != -1); // DAJ -1FIX local_spewnum &= 0xFF; // Adjust for handle Server_spew_list[spewnum] = local_spewnum; LOG_DEBUG.printf("Got spew of type %d. Server=%d local=%d", spew.effect_type, spewnum, local_spewnum); @@ -5074,8 +5073,8 @@ void MultiDoExecuteDLL(uint8_t *data) { } } - int16_t local_me_objnum; - int16_t local_it_objnum; + int32_t local_me_objnum; + int32_t local_it_objnum; if (me_objnum == -1) local_me_objnum = -1; @@ -8077,7 +8076,6 @@ void MultiDoGhostObject(uint8_t *data) { return; } - MULTI_ASSERT_NOMESSAGE(objnum != -1); MULTI_ASSERT_NOMESSAGE(Objects[objnum].type != OBJ_NONE); if (ghost) { @@ -8332,7 +8330,7 @@ void MultiDoAiWeaponFlags(uint8_t *data) { int flags; int wb_index; - int16_t obj_num = Server_object_list[MultiGetUshort(data, &count)]; + uint16_t obj_num = Server_object_list[MultiGetUshort(data, &count)]; flags = MultiGetInt(data, &count); wb_index = MultiGetByte(data, &count); if (obj_num == 65535) { diff --git a/Descent3/multi_client.cpp b/Descent3/multi_client.cpp index 37771bdeb..8fe3cd980 100644 --- a/Descent3/multi_client.cpp +++ b/Descent3/multi_client.cpp @@ -146,6 +146,7 @@ #include "Mission.h" #include "stringtable.h" #include "ship.h" +#include #define WEAPONS_LOAD_UPDATE_INTERVAL 2.0 @@ -436,9 +437,9 @@ void MultiDoClientFrame() { } } - uint8_t data[MAX_GAME_DATA_SIZE], count = 0, add_count = 0; - - count = MultiStuffPosition(Player_num, data); + uint8_t data[MAX_GAME_DATA_SIZE]; + int32_t add_count = 0; + int32_t count = MultiStuffPosition(Player_num, data); // Send firing if needed if (Player_fire_packet[Player_num].fired_on_this_frame == PFP_FIRED) diff --git a/Descent3/object.cpp b/Descent3/object.cpp index 205dbd6c6..0ed5aa55a 100644 --- a/Descent3/object.cpp +++ b/Descent3/object.cpp @@ -3356,7 +3356,7 @@ void SetObjectControlType(object *obj, int control_type) { memset(obj->ai_info, 0x00, sizeof(ai_frame)); // DAJ clear the baby for (i = 0; i < num_wbs; i++) { - ASSERT(pm->poly_wb[i].num_turrets >= 0 && pm->poly_wb[i].num_turrets <= 6400); + ASSERT(pm->poly_wb[i].num_turrets >= 0); count += pm->poly_wb[i].num_turrets; } diff --git a/Descent3/osiris_predefs.cpp b/Descent3/osiris_predefs.cpp index c41d3468d..21ca18156 100644 --- a/Descent3/osiris_predefs.cpp +++ b/Descent3/osiris_predefs.cpp @@ -2792,7 +2792,7 @@ void osipf_ObjWBValue(int obj_handle, char wb_index, char op, char vtype, void * // flag is which mission flag to set/clear (1-32) // value is 0 to clear, or 1 to set void osipf_MissionFlagSet(int flag, uint8_t value) { - if (flag < 1 && flag > 32) { + if (flag < 1 || flag > 32) { LOG_ERROR.printf("Invalid flag passed to osipf_MissionFlagSet(%d)", flag); return; } @@ -2811,7 +2811,7 @@ void osipf_MissionFlagSet(int flag, uint8_t value) { // Gets a mission flag // flag is what mission flag to get. Returns 1 if set, 0 if not. int osipf_MissionFlagGet(int flag) { - if (flag < 1 && flag > 32) { + if (flag < 1 || flag > 32) { LOG_ERROR.printf("Invalid flag passed to osipf_MissionFlagGet(%d)\n", flag); return 0; } diff --git a/Descent3/render.cpp b/Descent3/render.cpp index 788886409..5e760f5bd 100644 --- a/Descent3/render.cpp +++ b/Descent3/render.cpp @@ -30,6 +30,7 @@ */ #include +#include #include #include @@ -139,7 +140,7 @@ static int Render_width, Render_height; int Clear_window_color = -1; int Clear_window = 2; // 1 = Clear whole background window, 2 = clear view portals into rest of world, 0 = no clear #define MAX_RENDER_ROOMS 100 -char Rooms_visited[MAX_ROOMS + MAX_PALETTE_ROOMS]; +uint8_t Rooms_visited[MAX_ROOMS + MAX_PALETTE_ROOMS]; int Facing_visited[MAX_ROOMS + MAX_PALETTE_ROOMS]; // For keeping track of portal recursion uint8_t Room_depth_list[MAX_ROOMS + MAX_PALETTE_ROOMS]; @@ -3458,7 +3459,7 @@ void RenderMine(int viewer_roomnum, int flag_automap, int called_from_terrain) { RenderRoomOutline(&Rooms[roomnum]); } RenderRoom(&Rooms[roomnum]); - Rooms_visited[roomnum] = (char)255; + Rooms_visited[roomnum] = 255; // Stuff objects into our postrender list CheckToRenderMineObjects(roomnum); } diff --git a/Descent3/viseffect_external.h b/Descent3/viseffect_external.h index ea0bc2943..42f9bb3d1 100644 --- a/Descent3/viseffect_external.h +++ b/Descent3/viseffect_external.h @@ -80,7 +80,7 @@ struct vis_attach_info { uint16_t modelnum; uint16_t vertnum; - uint16_t end_vertnum; + int32_t end_vertnum; uint8_t subnum, subnum2; }; diff --git a/lib/demofile.h b/lib/demofile.h index 67eadf0d1..5cf2dbbf8 100644 --- a/lib/demofile.h +++ b/lib/demofile.h @@ -170,7 +170,7 @@ void DemoWriteHudMessage(uint32_t color, bool blink, char *msg); void DemoWriteChangedObjects(); void DemoWriteWeaponFire(uint16_t objectnum, vector *pos, vector *dir, uint16_t weaponnum, - uint16_t weapobjnum, int16_t gunnum); + int16_t weapobjnum, int16_t gunnum); void DemoWriteObjCreate(uint8_t type, uint16_t id, int roomnum, vector *pos, const matrix *orient, int parent_handle, object *obj); diff --git a/netgames/ctf/ctf.cpp b/netgames/ctf/ctf.cpp index c3b1779ce..bf0ae69b3 100644 --- a/netgames/ctf/ctf.cpp +++ b/netgames/ctf/ctf.cpp @@ -2422,7 +2422,7 @@ void ReceiveGameState(uint8_t *data) { for (i = 0; i < DLLMAX_TEAMS; i++) { if (server_objnums[i] != 65535) { // we should have a real object here - uint16_t our_objnum = DMFCBase->ConvertServerToLocalObjnum(server_objnums[i]); + int32_t our_objnum = DMFCBase->ConvertServerToLocalObjnum(server_objnums[i]); if (our_objnum == -1) { // fatal error diff --git a/netgames/dmfc/dmfcprecord.cpp b/netgames/dmfc/dmfcprecord.cpp index d12fafc41..4c3fcdb6f 100644 --- a/netgames/dmfc/dmfcprecord.cpp +++ b/netgames/dmfc/dmfcprecord.cpp @@ -85,6 +85,7 @@ #include "gamedll_header.h" #include "DMFC.h" #include "dmfcinternal.h" +#include #include #include @@ -592,9 +593,12 @@ void PRec_ReceivePRecFromServer(uint8_t *data) { pr->callsign[callsignlen] = '\0'; MultiUnpackNetworkAddress(&pr->net_addr, data, &count); // unpack bytes (network address) pr->pnum = MultiGetByte(data, &count); // unpack byte (pnum) - pr->team = MultiGetByte(data, &count); - if (pr->team == 255) // unpack byte (team) + uint8_t team = MultiGetByte(data, &count); + if (team == 255) { pr->team = -1; + } else { + pr->team = team; + } if (MultiGetByte(data, &count)) { ASSERT(basethis->IsMasterTrackerGame() != 0); From 25762b560c637fe04ff419cb8b27cfcea1d0767e Mon Sep 17 00:00:00 2001 From: Louis Gombert Date: Tue, 20 May 2025 21:38:34 +0200 Subject: [PATCH 15/24] Fix warning -Wmacro-redefined --- Descent3/dedicated_server.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/Descent3/dedicated_server.cpp b/Descent3/dedicated_server.cpp index 15e11b8fe..24ed77d77 100644 --- a/Descent3/dedicated_server.cpp +++ b/Descent3/dedicated_server.cpp @@ -795,7 +795,6 @@ void PrintDedicatedMessage(const char *fmt, ...) { #endif #define SOCKADDR_IN sockaddr_in #define SOCKADDR sockaddr -#define INVALID_SOCKET -1 // Winsock = sockets error translation @@ -807,8 +806,6 @@ void PrintDedicatedMessage(const char *fmt, ...) { #define WSAGetLastError() errno #endif -#define SOCKET_ERROR -1 - #endif struct dedicated_socket { From b46edb55253235529b7ea73d091563a08754c612 Mon Sep 17 00:00:00 2001 From: Louis Gombert Date: Tue, 20 May 2025 21:44:48 +0200 Subject: [PATCH 16/24] Fix warning -Wshift-negative-value --- Descent3/procedurals.cpp | 2 +- netcon/descent3onlineclient/odtclient.cpp | 4 ++-- netcon/mtclient/mtclient.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Descent3/procedurals.cpp b/Descent3/procedurals.cpp index c1316a8c6..84c809d74 100644 --- a/Descent3/procedurals.cpp +++ b/Descent3/procedurals.cpp @@ -777,7 +777,7 @@ void AddProcFallLeft(int handle, static_proc_element *proc) { DynamicProcElements[index].x1 = IntToFix(proc->x1 + ((ps_rand() % 5) - 2)); DynamicProcElements[index].y1 = IntToFix(proc->y1 + ((ps_rand() % 5) - 2)); DynamicProcElements[index].color = BRIGHT_COLOR; - DynamicProcElements[index].dx = IntToFix(-1); + DynamicProcElements[index].dx = -65536; DynamicProcElements[index].dy = FloatToFix((-(prand() % 100)) / 300.0); DynamicProcElements[index].frames_left = (prand() % 15) + 25; } diff --git a/netcon/descent3onlineclient/odtclient.cpp b/netcon/descent3onlineclient/odtclient.cpp index 3f2de5be2..61919d1e5 100644 --- a/netcon/descent3onlineclient/odtclient.cpp +++ b/netcon/descent3onlineclient/odtclient.cpp @@ -709,7 +709,7 @@ int MainMultiplayerMenu() { while (DLLgrtext_GetTextLineWidth(fmtchan) < LIST_ROW1) { endpos = strlen(fmtchan); fmtchan[endpos] = chan_name[charpos]; - fmtchan[endpos + 1] = NULL; + fmtchan[endpos + 1] = '\0'; charpos++; } strcat(fmtchan, "\t\0"); @@ -717,7 +717,7 @@ int MainMultiplayerMenu() { while (DLLgrtext_GetTextLineWidth(fmtchan) < LIST_ROW2) { endpos = strlen(fmtchan); fmtchan[endpos] = count_list[charpos]; - fmtchan[endpos + 1] = NULL; + fmtchan[endpos + 1] = '\0'; charpos++; } strcat(fmtchan, "\t\0"); diff --git a/netcon/mtclient/mtclient.cpp b/netcon/mtclient/mtclient.cpp index 84035c5d3..309978d46 100644 --- a/netcon/mtclient/mtclient.cpp +++ b/netcon/mtclient/mtclient.cpp @@ -1384,7 +1384,7 @@ int MainMultiplayerMenu() { while (DLLgrtext_GetTextLineWidth(fmtchan) < LIST_ROW1) { endpos = strlen(fmtchan); fmtchan[endpos] = chan_name[charpos]; - fmtchan[endpos + 1] = NULL; + fmtchan[endpos + 1] = '\0'; charpos++; } strcat(fmtchan, "\t\0"); @@ -1392,7 +1392,7 @@ int MainMultiplayerMenu() { while (DLLgrtext_GetTextLineWidth(fmtchan) < LIST_ROW2) { endpos = strlen(fmtchan); fmtchan[endpos] = count_list[charpos]; - fmtchan[endpos + 1] = NULL; + fmtchan[endpos + 1] = '\0'; charpos++; } strcat(fmtchan, "\t\0"); From 18e76bb77396b93d98827af1ad264564134ef374 Mon Sep 17 00:00:00 2001 From: Louis Gombert Date: Tue, 20 May 2025 21:56:04 +0200 Subject: [PATCH 17/24] Fix warning -Wpointer-bool-conversion --- Descent3/gamesequence.cpp | 12 +++++------- Descent3/osiris_predefs.cpp | 2 +- netgames/dmfc/dmfcprecord.cpp | 2 +- netgames/dmfc/dmfcremote.cpp | 2 +- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Descent3/gamesequence.cpp b/Descent3/gamesequence.cpp index c71beccd9..544af0eb1 100644 --- a/Descent3/gamesequence.cpp +++ b/Descent3/gamesequence.cpp @@ -2347,13 +2347,11 @@ void PageInShip(int id) { LoadLevelProgress(LOAD_PROGRESS_PAGING_DATA, PAGED_IN_CALC); // Try and load the various weapons int j; - if (shippointer->static_wb) { - for (i = 0; i < MAX_PLAYER_WEAPONS; i++) { - for (j = 0; j < MAX_WB_GUNPOINTS; j++) { - if (shippointer->static_wb[i].gp_weapon_index[j] != LASER_INDEX) { - PageInWeapon(shippointer->static_wb[i].gp_weapon_index[j]); - LoadLevelProgress(LOAD_PROGRESS_PAGING_DATA, PAGED_IN_CALC); - } + for (i = 0; i < MAX_PLAYER_WEAPONS; i++) { + for (j = 0; j < MAX_WB_GUNPOINTS; j++) { + if (shippointer->static_wb[i].gp_weapon_index[j] != LASER_INDEX) { + PageInWeapon(shippointer->static_wb[i].gp_weapon_index[j]); + LoadLevelProgress(LOAD_PROGRESS_PAGING_DATA, PAGED_IN_CALC); } } } diff --git a/Descent3/osiris_predefs.cpp b/Descent3/osiris_predefs.cpp index 21ca18156..f96b4a80c 100644 --- a/Descent3/osiris_predefs.cpp +++ b/Descent3/osiris_predefs.cpp @@ -3366,7 +3366,7 @@ int osipf_FindRoomName(const char *name) { int osipf_FindTriggerName(const char *name) { for (int i = 0; i < Num_triggers; i++) { - if (Triggers[i].name) { + if (Triggers[i].name[0]) { if (!stricmp(name, Triggers[i].name)) return i; } diff --git a/netgames/dmfc/dmfcprecord.cpp b/netgames/dmfc/dmfcprecord.cpp index 4c3fcdb6f..11162f2ee 100644 --- a/netgames/dmfc/dmfcprecord.cpp +++ b/netgames/dmfc/dmfcprecord.cpp @@ -360,7 +360,7 @@ bool PRec_AssignPlayerToSlot(int pnum, int slot, player *players_array, netplaye Player_records[slot].total_time_in_game = 0; Player_records[slot].team = players_array[pnum].team; - if (basethis->IsMasterTrackerGame() && (basethis->Players[pnum].tracker_id)) { + if (basethis->IsMasterTrackerGame() && basethis->Players[pnum].tracker_id[0]) { // we are in a master tracker game, so save the tracker ID mprintf(0, "PREC: Got a PXO Player ID of %s\n", basethis->Players[pnum].tracker_id); Player_records[slot].tracker_id = strdup(basethis->Players[pnum].tracker_id); diff --git a/netgames/dmfc/dmfcremote.cpp b/netgames/dmfc/dmfcremote.cpp index 702500e8c..6c48f6ce3 100644 --- a/netgames/dmfc/dmfcremote.cpp +++ b/netgames/dmfc/dmfcremote.cpp @@ -152,7 +152,7 @@ void Remote_ProcessFrame(void) { // make sure they are in the game if (!pr || pr->state != STATE_INGAME) { // the player is no longer in the game - mprintf(0, "REMOTE: Removing authorization for %s\n", (pr->callsign) ? (pr->callsign) : ""); + mprintf(0, "REMOTE: Removing authorization for %s\n", pr->callsign[0] ? (pr->callsign) : ""); Remote_Logout(p); // change the key for the slot From 55db7b9d32dbb847d83ee9eb83fcd9e904adee16 Mon Sep 17 00:00:00 2001 From: Louis Gombert Date: Tue, 20 May 2025 21:56:54 +0200 Subject: [PATCH 18/24] Fix warning -Winconsistent-missing-override --- ddio/sdlcontroller.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddio/sdlcontroller.h b/ddio/sdlcontroller.h index e5ec94c97..cabe6a547 100644 --- a/ddio/sdlcontroller.h +++ b/ddio/sdlcontroller.h @@ -61,7 +61,7 @@ class sdlgameController final : public gameController { // this functions polls the controllers if needed. some systems may not need to implement // this function. - void poll(); + void poll() override; // flushes all controller information void flush() override; From d4c71d4bb11ac2183272b3f73daba69b229ad316 Mon Sep 17 00:00:00 2001 From: Louis Gombert Date: Tue, 20 May 2025 21:59:49 +0200 Subject: [PATCH 19/24] Fix warning -Wlogical-not-parentheses --- bitmap/iff.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bitmap/iff.cpp b/bitmap/iff.cpp index efdfdcc4a..0676956af 100644 --- a/bitmap/iff.cpp +++ b/bitmap/iff.cpp @@ -344,7 +344,7 @@ int bm_iff_parse_delta(CFILE *ifile, int len, iff_bitmap_header *bmheader) { } if (cnt == -1) { - if (!bmheader->w & 1) + if (!bmheader->w) return IFF_CORRUPT; } else if (cnt) return IFF_CORRUPT; From d2a564558ceee1434e9c45b5e3d001999e25789f Mon Sep 17 00:00:00 2001 From: Louis Gombert Date: Tue, 20 May 2025 22:05:49 +0200 Subject: [PATCH 20/24] Fix warning -Wunused-variable --- Descent3/GameLoop.cpp | 1 - Descent3/SLEW.cpp | 3 ++- mem/mem.cpp | 3 ++- renderer/HardwareOpenGL.cpp | 4 ---- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Descent3/GameLoop.cpp b/Descent3/GameLoop.cpp index 473371d74..f4c711f68 100644 --- a/Descent3/GameLoop.cpp +++ b/Descent3/GameLoop.cpp @@ -1545,7 +1545,6 @@ extern bool Cinematics_enabled; // Deal with keys that only work for testing & debugging (eg., slew) void ProcessTestKeys(int key) { - static int ffret = -1; int i; // Debug break diff --git a/Descent3/SLEW.cpp b/Descent3/SLEW.cpp index e5cf68168..b1cbc4695 100644 --- a/Descent3/SLEW.cpp +++ b/Descent3/SLEW.cpp @@ -262,7 +262,6 @@ void SlewResetOrient(object *obj) { // Moves the object for one frame int SlewFrame(object *obj, int movement_limitations) { - static int16_t old_joy_x = 0, old_joy_y = 0; // position last time around int ret_flags = 0; vector svel, movement; // scaled velocity (per this frame) matrix rotmat, new_pm; @@ -322,6 +321,8 @@ int SlewFrame(object *obj, int movement_limitations) { // joystick movement #ifdef EDITOR + static int16_t old_joy_x = 0, old_joy_y = 0; // position last time around + if (Joystick_active != -1) { int joy_x, joy_y, btns; tJoyPos joystate; diff --git a/mem/mem.cpp b/mem/mem.cpp index 38860cea9..c8e145e94 100644 --- a/mem/mem.cpp +++ b/mem/mem.cpp @@ -228,7 +228,9 @@ struct mem_alloc_info { char file[17]; }; +#if !defined(POSIX) static void *Mem_failsafe_block = nullptr; +#endif bool Mem_low_memory_mode = false; bool Mem_superlow_memory_mode = false; @@ -294,7 +296,6 @@ int mem_size_sub(void *memblock) { bool mem_dumpmallocstofile(char *filename) { return false; } -#pragma mark - #else // defined(POSIX) // Windows memory management diff --git a/renderer/HardwareOpenGL.cpp b/renderer/HardwareOpenGL.cpp index 3f50525d0..02db7ff9b 100644 --- a/renderer/HardwareOpenGL.cpp +++ b/renderer/HardwareOpenGL.cpp @@ -413,10 +413,6 @@ int opengl_Setup(oeApplication *app, const int *width, const int *height) { SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); if (!GSDLWindow) { - int display_num = 0; - int display_arg = FindArg("-display"); - int display_count = 0; - // High-DPI support { float scale = SDL_GetDisplayContentScale(Display_id); From 18a3a95474c555720165fc8353409984b2ab9947 Mon Sep 17 00:00:00 2001 From: Louis Gombert Date: Wed, 21 May 2025 19:55:27 +0200 Subject: [PATCH 21/24] Fix -Winteger-overflow RAND_MAX+1 overflows, so divide by RAND_MAX --- scripts/AIGame.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/AIGame.cpp b/scripts/AIGame.cpp index 13eb77b2c..0aeb537c3 100644 --- a/scripts/AIGame.cpp +++ b/scripts/AIGame.cpp @@ -1905,7 +1905,7 @@ bool SuperThief::DoSteal(int me, int it) { max = (14 - SuperThiefableItems[i].index) / 2.5f + 1; } - int new_amount = (rand() / (float)(RAND_MAX + 1)) * max + 1; + int new_amount = (rand() / (float)(RAND_MAX)) * max + 1; if (new_amount < amount) amount = new_amount; @@ -6287,7 +6287,7 @@ bool Thief::DoSteal(int me, int it, int attempt_num, bool f_last_success) { max = (14 - ThiefableItems[i].index) / 2.5f + 1; } - int new_amount = (rand() / (float)(RAND_MAX + 1)) * max + 1; + int new_amount = (rand() / (float)RAND_MAX) * max + 1; if (new_amount < amount) amount = new_amount; @@ -7541,7 +7541,7 @@ bool OldScratch::DoSteal(int me, int it) { max = (14 - SuperThiefableItems[i].index) / 2.5f + 1; } - int new_amount = (rand() / (float)(RAND_MAX + 1)) * max + 1; + int new_amount = (rand() / (float)(RAND_MAX)) * max + 1; if (new_amount < amount) amount = new_amount; From fb200ec9934f782b1ff7e3d24148495477e38b9f Mon Sep 17 00:00:00 2001 From: Louis Gombert Date: Wed, 21 May 2025 20:05:51 +0200 Subject: [PATCH 22/24] Fix warning -Wformat-security use std::cout instead of fprintf, treat string as an argument in snprintf --- Descent3/config.cpp | 4 ++-- linux/lnxcon_raw.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Descent3/config.cpp b/Descent3/config.cpp index bb63cb7c8..5c64003b3 100644 --- a/Descent3/config.cpp +++ b/Descent3/config.cpp @@ -785,7 +785,7 @@ struct video_menu { constexpr int RES_BUFFER_SIZE = 15; resolution_string = sheet->AddChangeableText(RES_BUFFER_SIZE); std::string res = Video_res_list[Current_video_resolution_id].getName(); - snprintf(resolution_string, res.size() + 1, res.c_str()); + snprintf(resolution_string, res.size() + 1, "%s", res.c_str()); sheet->AddLongButton("Change", IDV_CHANGE_RES_WINDOW); fullscreen = sheet->AddLongCheckBox("Fullscreen", Game_fullscreen); @@ -905,7 +905,7 @@ struct video_menu { resolution_changed = true; Current_video_resolution_id = newindex; std::string res = Video_res_list[Current_video_resolution_id].getName(); - snprintf(resolution_string, res.size() + 1, res.c_str()); + snprintf(resolution_string, res.size() + 1, "%s", res.c_str()); } } diff --git a/linux/lnxcon_raw.cpp b/linux/lnxcon_raw.cpp index f205d01c6..5d06c71ec 100644 --- a/linux/lnxcon_raw.cpp +++ b/linux/lnxcon_raw.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include "AppConsole.h" #include "ddio_common.h" @@ -174,6 +175,5 @@ void con_raw_Destroy() { // put some data up on the screen void con_raw_Puts(int window, const char *str) { - fprintf(stdout, str); - fflush(stdout); + std::cout << str << std::flush; } From 0db48c6d380d2efdde95c6dc9cd8c9eba2265346 Mon Sep 17 00:00:00 2001 From: Louis Gombert Date: Wed, 21 May 2025 20:14:49 +0200 Subject: [PATCH 23/24] Fix warning -Wconstant-conversion use value 32767 instead of 65535 for undefined to fit a short --- Descent3/demofile.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Descent3/demofile.cpp b/Descent3/demofile.cpp index f6b9f4507..310a5f398 100644 --- a/Descent3/demofile.cpp +++ b/Descent3/demofile.cpp @@ -630,7 +630,7 @@ void DemoReadObjAnimChanged(void) { void DemoWriteKillObject(object *hit_obj, object *killer, float damage, int death_flags, float delay, int seed) { cf_WriteByte(Demo_cfp, DT_OBJ_EXPLODE); cf_WriteShort(Demo_cfp, OBJNUM(hit_obj)); - cf_WriteShort(Demo_cfp, killer ? OBJNUM(killer) : 65535); + cf_WriteShort(Demo_cfp, killer ? OBJNUM(killer) : 32767); cf_WriteFloat(Demo_cfp, damage); cf_WriteInt(Demo_cfp, death_flags); cf_WriteFloat(Demo_cfp, delay); @@ -649,8 +649,7 @@ void DemoReadKillObject(void) { return; // bail if invalid object type ps_srand(seed); - KillObject(&Objects[hit_objnum], &Objects[killer], damage, death_flags, delay); -} +KillObject(&Objects[hit_objnum], (killer != 32767) ? &Objects[killer] : NULL, damage, death_flags, delay);} void DemoWritePlayerDeath(object *player, bool melee, int fate) { cf_WriteByte(Demo_cfp, DT_PLAYER_DEATH); From 2543dc35c3e4d38b59e1b82ca97ef7f785cad769 Mon Sep 17 00:00:00 2001 From: Louis Gombert Date: Wed, 21 May 2025 20:15:50 +0200 Subject: [PATCH 24/24] Fix warning -Wint-in-bool-context --- Descent3/GameCheat.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Descent3/GameCheat.cpp b/Descent3/GameCheat.cpp index 2235b197a..85dcf8775 100644 --- a/Descent3/GameCheat.cpp +++ b/Descent3/GameCheat.cpp @@ -523,7 +523,7 @@ void DemoCheats(int key) { int i; for (i = 0; i < MAX_PLAYER_WEAPONS; i++) { - if (HAS_FLAG(i)) { + if (HAS_FLAG(i) != 0) { Players[Player_num].weapon_ammo[i] = Ships[Players[Player_num].ship_index].max_ammo[i]; } }