From 466a142ba33252ee54607b612aae3ed37c07b468 Mon Sep 17 00:00:00 2001 From: Louis Gombert Date: Sat, 20 Apr 2024 14:54:54 +0200 Subject: [PATCH 1/6] Fix -Wcomment --- ddvid_lnx/video_lnx.cpp | 2 +- physics/physics.cpp | 4 ++-- scripts/DallasFuncs.cpp | 1 - scripts/level14.cpp | 1 - scripts/orbital.cpp | 1 - 5 files changed, 3 insertions(+), 6 deletions(-) diff --git a/ddvid_lnx/video_lnx.cpp b/ddvid_lnx/video_lnx.cpp index e250cec85..1c60645cd 100644 --- a/ddvid_lnx/video_lnx.cpp +++ b/ddvid_lnx/video_lnx.cpp @@ -201,7 +201,7 @@ void ddvid_LockFrameBuffer(ubyte **data, int *pitch) { return; } - //*data = vga_getgraphmem(); + // *data = vga_getgraphmem(); *pitch = DDVideo_info.info->linewidth; */ } diff --git a/physics/physics.cpp b/physics/physics.cpp index 283fd9924..4a328076f 100644 --- a/physics/physics.cpp +++ b/physics/physics.cpp @@ -1603,7 +1603,7 @@ void do_physics_sim(object *obj) { w1 = Zero_vector; } - vector p1 = obj->mtype.phys_info.velocity + w1; //*((2.0f*(float)PI)/65535.0f); + vector p1 = obj->mtype.phys_info.velocity + w1; // *((2.0f*(float)PI)/65535.0f); if(p1.y < 0.0) { @@ -2681,7 +2681,7 @@ void do_walking_sim(object *obj) { w1 = Zero_vector; } - vector p1 = obj->mtype.phys_info.velocity + w1; //*((2.0f*(float)PI)/65535.0f); + vector p1 = obj->mtype.phys_info.velocity + w1; // *((2.0f*(float)PI)/65535.0f); if(p1.y < 0.0) { diff --git a/scripts/DallasFuncs.cpp b/scripts/DallasFuncs.cpp index 33f1b953a..e6c1a410f 100644 --- a/scripts/DallasFuncs.cpp +++ b/scripts/DallasFuncs.cpp @@ -1954,7 +1954,6 @@ Death info 524288:Debris Death: Remains $$END -/* $$ACTION Objects Kill object [o:Object]; delay type = [e:DeathDelayType], explosion size = [e:DeathExplosionSize], death flags = diff --git a/scripts/level14.cpp b/scripts/level14.cpp index 2496dd3d7..335b7b200 100644 --- a/scripts/level14.cpp +++ b/scripts/level14.cpp @@ -706,7 +706,6 @@ tMatcenInfo matcen_info[NUM_MATCENS] = {{"StartingDock Matcen", 0}, {"West Dock" Custom $$END -/* $$ACTION Custom Set texture on monitors to [u:Texture] diff --git a/scripts/orbital.cpp b/scripts/orbital.cpp index cad5d8386..84b0ff068 100644 --- a/scripts/orbital.cpp +++ b/scripts/orbital.cpp @@ -185,7 +185,6 @@ tMatcenInfo matcen_info[NUM_MATCENS] = {{"StartingDock Matcen", 0}, {"West Dock" Custom $$END -/* $$ACTION Custom Set texture on monitors to [u:Texture] From 04e8aeb2478809522fb49ce3bd5ad466053acb4c Mon Sep 17 00:00:00 2001 From: Louis Gombert Date: Sat, 20 Apr 2024 15:11:24 +0200 Subject: [PATCH 2/6] Fix -Wswitch --- Descent3/CtlCfgElem.cpp | 6 +++++- Descent3/gamesequence.cpp | 10 ++++++++++ Descent3/mmItem.cpp | 2 ++ ddio_lnx/lnxkey.cpp | 2 ++ lnxcontroller/lnxcontroller.cpp | 2 ++ netgames/dmfc/dmfcstats.cpp | 4 ++++ 6 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Descent3/CtlCfgElem.cpp b/Descent3/CtlCfgElem.cpp index 6ec4ce12e..380a0e898 100644 --- a/Descent3/CtlCfgElem.cpp +++ b/Descent3/CtlCfgElem.cpp @@ -296,7 +296,7 @@ char Ctltext_KeyBindings[][16] = {"", "", "", "", - "pad�\0\0\0\0\0\0", + "pad�\0\0\0\0\0\0", #ifdef MACINTOSH "ctrl\0\0\0\0\0", #else @@ -828,6 +828,8 @@ bool cfg_element::Configure(ct_type *new_elem_type, ubyte *controller, ubyte *ne // check if we can configure this slot. switch (ctype_fn[slot]) { + case ctNone: + break; case ctKey: configure = true; break; @@ -886,6 +888,8 @@ void cfg_element_ui::Create(const char *title, ct_type type, ubyte controller, u newuiSheet *sheet = newuiMessageBox::GetSheet(); switch (type) { + case ctNone: + break; case ctKey: sheet->AddText(TXT_CTLBINDHELP1); break; diff --git a/Descent3/gamesequence.cpp b/Descent3/gamesequence.cpp index c0626a159..65fe44ae0 100644 --- a/Descent3/gamesequence.cpp +++ b/Descent3/gamesequence.cpp @@ -1161,6 +1161,14 @@ bool GameSequencer() { // interpret current function mode. switch (GetFunctionMode()) { + case INIT_MODE: + case GAME_MODE: + case EDITOR_MODE: + case EDITOR_GAME_MODE: + case MENU_MODE: + case QUIT_MODE: + case CREDITS_MODE: + break; case RESTORE_GAME_MODE: case LOADDEMO_MODE: case GAMEGAUGE_MODE: @@ -1173,6 +1181,8 @@ bool GameSequencer() { old_game_state = Game_state; switch (Game_state) { + case GAMESTATE_IDLE: + break; case GAMESTATE_NEW: StartNewGame(); SetGameState(GAMESTATE_LVLSTART); diff --git a/Descent3/mmItem.cpp b/Descent3/mmItem.cpp index a5275a2fd..f6111c5b4 100644 --- a/Descent3/mmItem.cpp +++ b/Descent3/mmItem.cpp @@ -258,6 +258,8 @@ void mmItem::OnDraw() { if ((UI_TIME() - m_last_frametime) >= m_process_speed) { // process special fx. switch (m_curfx) { + case mmItemFXNull: + break; case mmItemFXNormal: m_alpha = MMITEM_ALPHA; m_satcount = MMITEM_SAT; diff --git a/ddio_lnx/lnxkey.cpp b/ddio_lnx/lnxkey.cpp index 1d8a10f3f..f1f80a070 100644 --- a/ddio_lnx/lnxkey.cpp +++ b/ddio_lnx/lnxkey.cpp @@ -319,6 +319,8 @@ void ddio_InternalResetKey(ubyte key) { bool ddio_KeyFrame() { switch (Keyboard_mode) { + case Input_sdl: + break; case Input_normal: return ddio_normal_KeyFrame(); case Input_null: diff --git a/lnxcontroller/lnxcontroller.cpp b/lnxcontroller/lnxcontroller.cpp index 192210828..e1e4486f1 100644 --- a/lnxcontroller/lnxcontroller.cpp +++ b/lnxcontroller/lnxcontroller.cpp @@ -273,6 +273,8 @@ ct_config_data lnxgameController::get_controller_value(ct_type type_req) { switch (type_req) { int pov_n; + case ctNone: + break; case ctKey: val = makeword(0, ddio_KeyInKey()); break; diff --git a/netgames/dmfc/dmfcstats.cpp b/netgames/dmfc/dmfcstats.cpp index 05264781d..29ebac471 100644 --- a/netgames/dmfc/dmfcstats.cpp +++ b/netgames/dmfc/dmfcstats.cpp @@ -644,6 +644,8 @@ void CDmfcStats::Render() { if (!is_dedicated_server || m_PLColInfo[c].type == DSCOL_PILOT_NAME || m_PLColInfo[c].type == DSCOL_BLANK) { switch (m_PLColInfo[c].type) { + case DSCOL_BMP: + break; case DSCOL_KILLS_LEVEL: snprintf(buffer, sizeof(buffer), "%d", pr->dstats.kills[DSTAT_LEVEL]); break; @@ -1081,6 +1083,8 @@ void CDmfcStats::Render() { buffer[0] = '\0'; if (!is_dedicated_server || m_DColInfo[c].type == DSCOL_PILOT_NAME || m_DColInfo[c].type == DSCOL_BLANK) { switch (m_DColInfo[c].type) { + case DSCOL_BMP: + break; case DSCOL_KILLS_LEVEL: snprintf(buffer, sizeof(buffer), "%d", pr->dstats.kills[DSTAT_LEVEL]); break; From a807c992839d546d4603ff69e42dd54dd19b7f44 Mon Sep 17 00:00:00 2001 From: Louis Gombert Date: Sat, 20 Apr 2024 15:15:48 +0200 Subject: [PATCH 3/6] Fix -Wparentheses-equality --- Descent3/matcen.cpp | 2 +- Descent3/object.cpp | 2 +- Descent3/osiris_predefs.cpp | 2 +- grtext/textaux.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Descent3/matcen.cpp b/Descent3/matcen.cpp index 38df6cb39..bf5167b0e 100644 --- a/Descent3/matcen.cpp +++ b/Descent3/matcen.cpp @@ -409,7 +409,7 @@ bool matcen::DoObjProd() { if (Game_mode & GM_MULTI) { // ASSERT (Netgame.local_role==LR_SERVER); - if ((Netgame.local_role == LR_SERVER)) { + if (Netgame.local_role == LR_SERVER) { MultiSendObject(&Objects[objnum], 0); } } diff --git a/Descent3/object.cpp b/Descent3/object.cpp index c0f9bf7ae..399f51ba0 100644 --- a/Descent3/object.cpp +++ b/Descent3/object.cpp @@ -1591,7 +1591,7 @@ int FreeObjectSlots(int num_used) { return original_num_to_free; for (i = 0; i < num_to_free; i++) - if ((Objects[obj_list[i]].type == OBJ_WEAPON)) { + if (Objects[obj_list[i]].type == OBJ_WEAPON) { num_to_free--; mprintf((0, "Freeing WEAPON object %3i\n", obj_list[i])); SetObjectDeadFlag(&Objects[obj_list[i]]); diff --git a/Descent3/osiris_predefs.cpp b/Descent3/osiris_predefs.cpp index c04aefaa9..6aeb6d922 100644 --- a/Descent3/osiris_predefs.cpp +++ b/Descent3/osiris_predefs.cpp @@ -2597,7 +2597,7 @@ int osipf_ObjCreate(ubyte type, ushort id, int roomnum, vector *pos, const matri if (Game_mode & GM_MULTI) { // ASSERT (Netgame.local_role==LR_SERVER); - if ((Netgame.local_role == LR_SERVER)) { + if (Netgame.local_role == LR_SERVER) { MultiSendObject(obj, 0); } } diff --git a/grtext/textaux.cpp b/grtext/textaux.cpp index ee9517a86..7ab040f31 100644 --- a/grtext/textaux.cpp +++ b/grtext/textaux.cpp @@ -132,7 +132,7 @@ char *textaux_CopyTextLine(char *src, char *dest) { if (!dest) return NULL; // see if we are at the end of the src - if ((src[0] == '\0')) { + if (src[0] == '\0') { dest[0] = '\0'; return NULL; } From 43af64482774eb4a6d4398dfeecd740413e79642 Mon Sep 17 00:00:00 2001 From: Louis Gombert Date: Sat, 20 Apr 2024 15:29:12 +0200 Subject: [PATCH 4/6] Fix -Wparentheses --- Descent3/AImain.cpp | 2 +- Descent3/BOA.cpp | 2 +- Descent3/aipath.cpp | 2 +- Descent3/bnode.cpp | 4 ++-- Descent3/osiris_predefs.cpp | 2 +- music/sequencer.cpp | 2 +- scripts/aigame2.cpp | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Descent3/AImain.cpp b/Descent3/AImain.cpp index dbf3660cb..09b16ecd3 100644 --- a/Descent3/AImain.cpp +++ b/Descent3/AImain.cpp @@ -4152,7 +4152,7 @@ inline bool IsTargetLocal(object *obj, object *target) { int i; // If they are in the same room - if (target_room = obj->roomnum) { + if ((target_room = obj->roomnum)) { return true; } diff --git a/Descent3/BOA.cpp b/Descent3/BOA.cpp index 702cd2269..bfa3aa850 100644 --- a/Descent3/BOA.cpp +++ b/Descent3/BOA.cpp @@ -948,7 +948,7 @@ void FindPath(int i, int j) { PQPath.push(start_node); ASSERT(start_node->roomnum <= Highest_room_index + BOA_num_terrain_regions); - while (cur_node = PQPath.pop()) { + while ((cur_node = PQPath.pop())) { node_list[BOA_INDEX(cur_node->roomnum)] = cur_node; ASSERT(BOA_INDEX(cur_node->roomnum) >= 0 && BOA_INDEX(cur_node->roomnum) <= Highest_room_index + MAX_BOA_TERRAIN_REGIONS); diff --git a/Descent3/aipath.cpp b/Descent3/aipath.cpp index 0e1fc32e3..15229e4ea 100644 --- a/Descent3/aipath.cpp +++ b/Descent3/aipath.cpp @@ -84,7 +84,7 @@ bool AIFindAltPath(object *obj, int i, int j, float *dist) { PQPath.push(start_node); - while (cur_node = PQPath.pop()) { + while ((cur_node = PQPath.pop())) { node_list[BOA_INDEX(cur_node->roomnum)] = cur_node; ASSERT(BOA_INDEX(cur_node->roomnum) >= 0 && BOA_INDEX(cur_node->roomnum) <= Highest_room_index + 8); diff --git a/Descent3/bnode.cpp b/Descent3/bnode.cpp index 39eeb6d0b..02a547502 100644 --- a/Descent3/bnode.cpp +++ b/Descent3/bnode.cpp @@ -234,7 +234,7 @@ bool BNode_FindPath(int start_room, int i, int j, float rad) { PQPath.push(start_node); - while (cur_node = PQPath.pop()) { + while ((cur_node = PQPath.pop())) { node_list[cur_node->node] = cur_node; if (cur_node->node == j) { @@ -255,7 +255,7 @@ bool BNode_FindPath(int start_room, int i, int j, float rad) { // if(!BOA_PassablePortal(cur_node->roomnum, counter, false, false)) // continue; - if (next_node = bnlist->nodes[cur_node->node].edges[counter].end_room != start_room) + if ((next_node = bnlist->nodes[cur_node->node].edges[counter].end_room != start_room)) continue; next_node = bnlist->nodes[cur_node->node].edges[counter].end_index; diff --git a/Descent3/osiris_predefs.cpp b/Descent3/osiris_predefs.cpp index 6aeb6d922..957d5e997 100644 --- a/Descent3/osiris_predefs.cpp +++ b/Descent3/osiris_predefs.cpp @@ -1931,7 +1931,7 @@ int osipf_AIFindObjOfType(int objhandle, int type, int id, bool f_ignore_init_ro return OBJECT_HANDLE_NONE; } - if (f_obj = AIFindObjOfType(obj, type, id, f_ignore_init_room, parent_handle)) + if ((f_obj = AIFindObjOfType(obj, type, id, f_ignore_init_room, parent_handle))) return f_obj->handle; return OBJECT_HANDLE_NONE; diff --git a/music/sequencer.cpp b/music/sequencer.cpp index 6e9e056c9..79c9c9357 100644 --- a/music/sequencer.cpp +++ b/music/sequencer.cpp @@ -674,7 +674,7 @@ OutrageMusicSeq::music_stream *OutrageMusicSeq::AddToList(short region, short th void OutrageMusicSeq::FreeList() { tListNode *node; - while (node = m_music_list.start()) { + while ((node = m_music_list.start())) { node = m_music_list.unlink(); delete[] node; } diff --git a/scripts/aigame2.cpp b/scripts/aigame2.cpp index 5c46f8723..2197da041 100644 --- a/scripts/aigame2.cpp +++ b/scripts/aigame2.cpp @@ -946,7 +946,7 @@ void aiBlackStormTrooper::OnInterval(tOSIRISEventInfo *data) { int roll = (rand() % 100); if (roll <= 50) { find_targets(data->me_handle, false); - memory->timer = Game_GetTime() + (memory->target_handle == OBJECT_HANDLE_NONE) ? 5.0f : 2.0f; + memory->timer = Game_GetTime() + ((memory->target_handle == OBJECT_HANDLE_NONE) ? 5.0f : 2.0f); } } } From 491db4254a999d89112a5addef69029fbbed5986 Mon Sep 17 00:00:00 2001 From: Louis Gombert Date: Sat, 20 Apr 2024 15:37:22 +0200 Subject: [PATCH 5/6] Fix -Wdangling-else --- Descent3/BriefingParse.cpp | 10 ++++++---- Descent3/WeaponFire.cpp | 9 ++++++--- physics/Collide.cpp | 8 +++++--- physics/FindIntersection.cpp | 16 ++++++++++------ 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/Descent3/BriefingParse.cpp b/Descent3/BriefingParse.cpp index fdfa274d2..91284edac 100644 --- a/Descent3/BriefingParse.cpp +++ b/Descent3/BriefingParse.cpp @@ -820,13 +820,15 @@ int CBriefParse::ParseBriefing(char *filename) { done_parsing:; - if (abort) + if (abort) { mprintf((0, "Parse aborted\n")); - else if (!parse_error) - if (reading_text) + } else if (!parse_error) { + if (reading_text) { ParseError("Missing '$endtext'"); - else + } else { mprintf((0, "Parse sucessful\n")); + } + } // Close the file cfclose(ifile); diff --git a/Descent3/WeaponFire.cpp b/Descent3/WeaponFire.cpp index 267ee9367..a70fdc811 100644 --- a/Descent3/WeaponFire.cpp +++ b/Descent3/WeaponFire.cpp @@ -1051,11 +1051,14 @@ bool ObjectsAreRelated(int o1, int o2) { // Here is the 09/07/94 change -- Siblings must be identical, others can hurt each other // See if they're siblings... - if (obj1->parent_handle == obj2->parent_handle) - if ((obj1->mtype.phys_info.flags & PF_HITS_SIBLINGS) || (obj2->mtype.phys_info.flags & PF_HITS_SIBLINGS)) + if (obj1->parent_handle == obj2->parent_handle) { + if ((obj1->mtype.phys_info.flags & PF_HITS_SIBLINGS) || (obj2->mtype.phys_info.flags & PF_HITS_SIBLINGS)) { return false; // if either is proximity, then can blow up, so say not related - else + } + else { return true; + } + } // Otherwise, it is two weapons and by default, they should not collide return true; diff --git a/physics/Collide.cpp b/physics/Collide.cpp index 7227ca23e..1b8e2c8ca 100644 --- a/physics/Collide.cpp +++ b/physics/Collide.cpp @@ -1133,11 +1133,13 @@ bool collide_weapon_and_wall(object *weapon, fix hitspeed, int hitseg, int hitwa // #ifndef RELEASE if ((stricmp(Weapons[weapon->id].name, "Yellow flare") == 0) && (weapon->parent_handle == Player_object->handle) && - (KEY_STATE(KEY_LAPOSTRO))) - if (ROOMNUM_OUTSIDE(hitseg)) + (KEY_STATE(KEY_LAPOSTRO))) { + if (ROOMNUM_OUTSIDE(hitseg)) { AddHUDMessage("Terrain cell %d", CELLNUM(hitseg)); - else + } else { AddHUDMessage("Room %d face %d", hitseg, hitwall); + } + } // #endif // Check if forcefield diff --git a/physics/FindIntersection.cpp b/physics/FindIntersection.cpp index 699d13440..ebf6b5000 100644 --- a/physics/FindIntersection.cpp +++ b/physics/FindIntersection.cpp @@ -4280,11 +4280,13 @@ int do_fvi_terrain() { // Check the current node for collisions -- chrishack -- This can be made iterative cur_node = y * TERRAIN_DEPTH + new_x; - if ((fvi_terrain_visit_list[cur_node >> 3] & (0x01 << (cur_node % 8))) == 0) - if (counter < -delta_ter_check || counter > delta_ter_check) + if ((fvi_terrain_visit_list[cur_node >> 3] & (0x01 << (cur_node % 8))) == 0) { + if (counter < -delta_ter_check || counter > delta_ter_check) { check_terrain_node(cur_node, false, false); - else + } else { check_terrain_node(cur_node, false, true); + } + } } i++; @@ -4320,11 +4322,13 @@ int do_fvi_terrain() { // Check the current node for collisions -- chrishack -- This can be made iterative cur_node = new_y * TERRAIN_DEPTH + x; - if ((fvi_terrain_visit_list[cur_node >> 3] & (0x01 << (cur_node % 8))) == 0) - if (counter < -delta_ter_check || counter > delta_ter_check) + if ((fvi_terrain_visit_list[cur_node >> 3] & (0x01 << (cur_node % 8))) == 0) { + if (counter < -delta_ter_check || counter > delta_ter_check) { check_terrain_node(cur_node, false, false); - else + } else { check_terrain_node(cur_node, false, true); + } + } } i++; From c486919477228c62e44dedf052c06481fe06fb4b Mon Sep 17 00:00:00 2001 From: Louis Gombert Date: Sat, 20 Apr 2024 15:53:21 +0200 Subject: [PATCH 6/6] Fix -Wtautological-pointer-compare --- physics/FindIntersection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/physics/FindIntersection.cpp b/physics/FindIntersection.cpp index ebf6b5000..21bd88287 100644 --- a/physics/FindIntersection.cpp +++ b/physics/FindIntersection.cpp @@ -4829,7 +4829,7 @@ int fvi_room(int room_index, int from_portal, int room_obj) { fvi_query_ptr = temp_query; // Make sure we register the hit - if (hit_data_terrain.hit_type != HIT_NONE) + if (hit_data_terrain.hit_type[0] != HIT_NONE) *fvi_hit_data_ptr = hit_data_terrain; } }