Skip to content

Commit

Permalink
Merge pull request #109 from Lgt2x/clang-warnings
Browse files Browse the repository at this point in the history
Fix some clang warnings
  • Loading branch information
winterheart authored Apr 21, 2024
2 parents f1ec3d7 + c486919 commit 9e9b713
Show file tree
Hide file tree
Showing 25 changed files with 68 additions and 36 deletions.
2 changes: 1 addition & 1 deletion Descent3/AImain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion Descent3/BOA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 6 additions & 4 deletions Descent3/BriefingParse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 5 additions & 1 deletion Descent3/CtlCfgElem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
9 changes: 6 additions & 3 deletions Descent3/WeaponFire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Descent3/aipath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions Descent3/bnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions Descent3/gamesequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Descent3/matcen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
2 changes: 2 additions & 0 deletions Descent3/mmItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Descent3/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]]);
Expand Down
4 changes: 2 additions & 2 deletions Descent3/osiris_predefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
Expand Down
2 changes: 2 additions & 0 deletions ddio_lnx/lnxkey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion ddvid_lnx/video_lnx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ void ddvid_LockFrameBuffer(ubyte **data, int *pitch) {
return;
}

//*data = vga_getgraphmem();
// *data = vga_getgraphmem();
*pitch = DDVideo_info.info->linewidth;
*/
}
Expand Down
2 changes: 1 addition & 1 deletion grtext/textaux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 2 additions & 0 deletions lnxcontroller/lnxcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion music/sequencer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ OutrageMusicSeq::music_stream *OutrageMusicSeq::AddToList(short region, short th
void OutrageMusicSeq::FreeList() {
tListNode<music_stream> *node;

while (node = m_music_list.start()) {
while ((node = m_music_list.start())) {
node = m_music_list.unlink();
delete[] node;
}
Expand Down
4 changes: 4 additions & 0 deletions netgames/dmfc/dmfcstats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 5 additions & 3 deletions physics/Collide.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 11 additions & 7 deletions physics/FindIntersection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down Expand Up @@ -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++;
Expand Down Expand Up @@ -4825,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;
}
}
Expand Down
4 changes: 2 additions & 2 deletions physics/physics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand Down
1 change: 0 additions & 1 deletion scripts/DallasFuncs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
2 changes: 1 addition & 1 deletion scripts/aigame2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down
1 change: 0 additions & 1 deletion scripts/level14.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
1 change: 0 additions & 1 deletion scripts/orbital.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 9e9b713

Please sign in to comment.