Skip to content

Commit

Permalink
d3: resolve 175 instances of -Wunused-variable
Browse files Browse the repository at this point in the history
  • Loading branch information
jengelh committed Nov 4, 2024
1 parent 0e6110e commit 8d4adde
Show file tree
Hide file tree
Showing 59 changed files with 42 additions and 201 deletions.
3 changes: 0 additions & 3 deletions Descent3/AIGoal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,6 @@ void GoalClearAll(object *obj) {
int GoalAllocSlot(object *obj, int level, float influence) {
float lowest_influence_slot = -1.0;
float lowest_influence = MAX_INFLUENCE + 1.0;
int alloc_slot = AI_INVALID_INDEX;
ai_frame *ai_info = obj->ai_info;
int cur_slot;

Expand Down Expand Up @@ -1421,8 +1420,6 @@ bool GoalIsGoalEnabled(object *obj, int goal_index) {
if (cur_goal->flags & GF_OBJ_IS_TARGET) {
gobj = ObjGet(obj->ai_info->target_handle);
} else if (cur_goal->flags & (GF_OBJS_ARE_SPECIES | GF_OBJS_ARE_ENEMIES | GF_OBJS_ARE_FRIENDS)) {
bool done = false;

if (cur_goal->flags & (GF_OBJS_ARE_SPECIES | GF_OBJS_ARE_FRIENDS)) {
// chrishack -- not done
}
Expand Down
9 changes: 1 addition & 8 deletions Descent3/AImain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1804,7 +1804,6 @@ bool move_relative_object_vec(object *obj, vector *vec, object *target, float ci
vector from_target;
vector opposite_fvec;
vector goal_pos;
ai_frame *ai_info = obj->ai_info;
bool f_done = false;

from_target = obj->pos - target->pos;
Expand Down Expand Up @@ -2862,8 +2861,7 @@ void AISeeTarget(object *obj, bool f_see) {

// Note: Player position is also updated in the visibility test function
// for MIN_VIS_RECENT_CHECK_INTERVAL seconds
object *targetptr;
object *other_obj = targetptr = ObjGet(ai_info->target_handle);
object *targetptr = ObjGet(ai_info->target_handle);

if (targetptr) {
if (f_see)
Expand Down Expand Up @@ -4533,7 +4531,6 @@ void ai_move(object *obj) {
bool f_dodge = false; // Are there any dodge goals
bool f_avoid = false; // Are there any avoid goals
int highest_influence_goal = -1;
float highest_influence = 0.0f;
float highest_speed = 0.0f;
bool f_turned = true;
bool f_goal_found = false;
Expand Down Expand Up @@ -4814,8 +4811,6 @@ void ai_move(object *obj) {
bool f_orient = AITurnTowardsMatrix(obj, obj->ai_info->max_turn_rate, &orient);

if (f_at_pos && f_orient) {
int goal_index = cur_goal - ai_info->goals;

if (cur_goal->type == AIG_PLACE_OBJ_ON_OBJ) {
UnattachFromParent(child_obj);
AttachObject(g_obj, c_ap, child_obj, p_ap, true);
Expand Down Expand Up @@ -4850,8 +4845,6 @@ void ai_move(object *obj) {
}

if (f_at_pos) {
int goal_index = cur_goal - ai_info->goals;

AttachObject(obj, p_ap, g_obj, rad);

if (cur_goal->g_info.attach_info.flags & GAF_TEMP_CLEAR_ROBOT_COLLISIONS) {
Expand Down
1 change: 0 additions & 1 deletion Descent3/BOA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1332,7 +1332,6 @@ void ValidateRoomPathPoint(int room, char *message, int len) {
if (IsPathPointValid(room, &pos))
return;

bool f_found = false;
// vector best_pnt;
// float best_distance;

Expand Down
2 changes: 0 additions & 2 deletions Descent3/BriefingParse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ static int ReadFullLine(char **data, CFILE *ifile) {
// Parses the briefing file (calling the callbacks throughout), check return code
int CBriefParse::ParseBriefing(const char *filename) {
CFILE *ifile;
bool retvalue = false;
bool voice_def_screen = false;
char text_buf[8192], *text_ptr = NULL;
bool abort = 0;
Expand All @@ -285,7 +284,6 @@ int CBriefParse::ParseBriefing(const char *filename) {
int beffect = bfxNONE;
int x = 0, y = 0;
char filen[40];
bool emergency_exit = false;

// the following block of 'globals' are for when parsing a text block, the information is stored
// here until a $endtext is hit
Expand Down
4 changes: 1 addition & 3 deletions Descent3/Controls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,9 +452,7 @@ bool Control_poll_flag = false; // determines if system is polling controls now.
static bool Control_system_init = false;
static float Control_interval_time = 0.0f;
static float Control_current_time;
static float Control_frametime;
static float Key_pitch_ramp_time = 0.0f;
static float Key_heading_ramp_time = 0.0f;
// static float Control_frametime;

static tSensitivity Key_ramp;

Expand Down
12 changes: 6 additions & 6 deletions Descent3/Game2DLL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ bool InitGameModule(const char *name, module *mod) {
// Clear out error queue
mod_GetLastError();
if (!mod_LoadModule(mod, tmp_dll_name)) {
int err = mod_GetLastError();
mod_GetLastError();
LOG_WARNING.printf("You are missing the DLL %s!", name);
return false;
}
Expand Down Expand Up @@ -640,7 +640,7 @@ int LoadGameDLL(const char *name, int num_teams_to_use) {
mod_GetLastError();
DLLGameInit = (DLLGameInit_fp)mod_GetSymbol(&GameDLLHandle, "DLLGameInit", 12);
if (!DLLGameInit) {
int err = mod_GetLastError();
mod_GetLastError();
LOG_FATAL << "Couldn't get a handle to the dll function DLLGameInit!";
Int3();
FreeGameDLL();
Expand All @@ -650,7 +650,7 @@ int LoadGameDLL(const char *name, int num_teams_to_use) {
mod_GetLastError();
DLLGameCall = (DLLGameCall_fp)mod_GetSymbol(&GameDLLHandle, "DLLGameCall", 8);
if (!DLLGameCall) {
int err = mod_GetLastError();
mod_GetLastError();
LOG_FATAL << "Couldn't get a handle to the dll function DLLGameCall!";
Int3();
FreeGameDLL();
Expand All @@ -660,7 +660,7 @@ int LoadGameDLL(const char *name, int num_teams_to_use) {
mod_GetLastError();
DLLGameClose = (DLLGameClose_fp)mod_GetSymbol(&GameDLLHandle, "DLLGameClose", 0);
if (!DLLGameClose) {
int err = mod_GetLastError();
mod_GetLastError();
LOG_FATAL << "Couldn't get a handle to the dll function DLLGameClose!";
Int3();
FreeGameDLL();
Expand All @@ -670,7 +670,7 @@ int LoadGameDLL(const char *name, int num_teams_to_use) {
mod_GetLastError();
DLLGetGameInfo = (DLLGetGameInfo_fp)mod_GetSymbol(&GameDLLHandle, "DLLGetGameInfo", 4);
if (!DLLGetGameInfo) {
int err = mod_GetLastError();
mod_GetLastError();
LOG_FATAL << "Couldn't get a handle to the dll function DLLGetGameInfo!";
Int3();
FreeGameDLL();
Expand Down Expand Up @@ -753,7 +753,7 @@ bool GetDLLGameInfo(const char *name, tDLLOptions *options) {
mod_GetLastError();
modGetGameInfo = (DLLGetGameInfo_fp)mod_GetSymbol(&mod, "DLLGetGameInfo", 4);
if (!modGetGameInfo) {
int err = mod_GetLastError();
mod_GetLastError();
LOG_FATAL << "Couldn't get a handle to the dll function DLLGetGameInfo!";
Int3();
CloseGameModule(&mod);
Expand Down
6 changes: 3 additions & 3 deletions Descent3/Inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ bool Inventory::AddObject(int object_handle, int flags, const char *description)

ASSERT(obj->type == OBJ_BUILDING || obj->type == OBJ_ROBOT || obj->type == OBJ_POWERUP || obj->type == OBJ_CLUTTER);

inven_item *current = root, *prev = root, *newnode;
inven_item *prev = root, *newnode;

if (count == 0) {
// there are no items in the list...time to add
Expand Down Expand Up @@ -531,7 +531,7 @@ bool Inventory::AddCounterMeasure(int id, int aux_type, int aux_id, int flags, c
return false;
}

inven_item *current = root, *prev = root, *newnode;
inven_item *prev = root, *newnode;

if (count == 0) {
// there are no items in the list...time to add
Expand Down Expand Up @@ -606,7 +606,7 @@ bool Inventory::AddObjectItem(int otype, int oid, int oauxt, int oauxi, int flag
if (count >= MAX_UNIQUE_INVEN_ITEMS)
return false;

inven_item *current = root, *prev = root, *newnode;
inven_item *prev = root, *newnode;

if (count == 0) {
// there are no items in the list...time to add
Expand Down
2 changes: 0 additions & 2 deletions Descent3/LoadLevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3686,13 +3686,11 @@ extern bool Disable_editor_rendering;
// Returns 1 if file read ok, else 0
int LoadLevel(char *filename, void (*cb_fn)(const char *, int, int)) {
CFILE *ifile;
char tag[4];
int n, i, retval = 1;

int version;
bool f_read_AABB = false;
bool no_128s = true;
int total = 0;
#ifdef EDITOR
Disable_editor_rendering = 1;
Num_failed_xlate_items = 0;
Expand Down
2 changes: 0 additions & 2 deletions Descent3/Mission.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1197,7 +1197,6 @@ bool LoadMission(const char *mssn) {

void FreeMission() {
// Free up mission script
int i; //,j;
// close MN3 file if there is one.
mn3_Close();
// Tell Osiris to shutdown the Osiris Mission Memory System, freeing all memory
Expand Down Expand Up @@ -1265,7 +1264,6 @@ bool LoadMissionLevel(int level) {
}
// Test to see if levels are valid
bool boa = true, terrain = true;
char str[255];

if (BOAGetMineChecksum() != BOA_vis_checksum)
boa = false;
Expand Down
2 changes: 0 additions & 2 deletions Descent3/ObjInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1054,8 +1054,6 @@ int ObjInitFireball(object *objp) {
}
int ObjInitMarker(object *objp) {
int ret = 1;
static int first = 1;
static int polynum = -1;
ASSERT(objp->type == OBJ_MARKER);
// Set size & shields
objp->shields = 100;
Expand Down
2 changes: 1 addition & 1 deletion Descent3/OsirisLoadandBind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2683,7 +2683,7 @@ bool Osiris_RestoreSystemState(CFILE *file) {
return false;
}

uint8_t version = (uint8_t)cf_ReadByte(file);
/* uint8_t version = */ cf_ReadByte(file);

num_bytes_to_be_restored = cf_ReadInt(file);

Expand Down
1 change: 0 additions & 1 deletion Descent3/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2571,7 +2571,6 @@ void ResetPlayerControlType(int slot) {

// Init physics
object *playobj = &Objects[Players[slot].objnum];
ship *ship = &Ships[Players[slot].ship_index];

playobj->mtype.phys_info = Ships[Players[slot].ship_index].phys_info;

Expand Down
4 changes: 1 addition & 3 deletions Descent3/TelCom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,6 @@ void TCMainMenuRenderCallback(void) {

// Main menu
bool TelComMainMenu(tTelComInfo *tcs) {
bool exitparse = false;
int mm;

mainmenu_system = -1;
Expand Down Expand Up @@ -3304,7 +3303,7 @@ void PageInTexture(int n, bool resize);
// Pages in all the necessary bitmaps, textures & sounds for the TelCom so that they are in memory
void TelcomPageAllIn(void) {
extern void UpdateInitMessage(float amount); // amount is 0 to 1
const float TELCOM_SOUND_PORTION = 0.3f, TELCOM_BITMAP_PORTION = 0.3f, TELCOM_TEXTUREHI_PORTION = 0.2f,
const float TELCOM_SOUND_PORTION = 0.3f, TELCOM_BITMAP_PORTION = 0.3f,
TELCOM_TEXTURELO_PORTION = 0.2f;

int i;
Expand Down Expand Up @@ -3719,7 +3718,6 @@ void TCSSSCallback(void) {
vector view_pos;
vector light_vec;
matrix view_orient = IDENTITY_MATRIX;
matrix final_mat = IDENTITY_MATRIX;
matrix rot_mat;

// draw model.
Expand Down
1 change: 0 additions & 1 deletion Descent3/TelComCargo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ bool TCCPlayerHasWeapon(int weapon_index) {
int TCCargoCreateLine(int id, int y, const char *title, int type) {
// char buffer[100];
int small_height = grfont_GetHeight(SM_FONT);
int big_height = grfont_GetHeight(BG_FONT);

switch (id) {
case LID_NONE:
Expand Down
13 changes: 4 additions & 9 deletions Descent3/TelcomEffectsRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,6 @@ void RenderBmpBlur(tceffect *tce, float frametime, int xoff, int yoff, bool ok_t
int sbm_handle = tce->bmpinfo.bm_handle;
int dbm_handle = tce->bmpinfo.temp_bmhandle;
bm_ClearBitmap(dbm_handle);
int x = 0;
int y = 0;
bool done = false;
if ((tce->flags == TC_BMPF_OUT) && (tce->bmpinfo.stage < 0))
done = true;
Expand Down Expand Up @@ -636,7 +634,6 @@ void RenderBmpInvert(tceffect *tce, float frametime, int xoff, int yoff, bool ok
uint8_t r, g, b;
int bh = bm_h(srcbmph, 0);
int bw = bm_w(srcbmph, 0);
int how_many = tce->bmpinfo.chunk_bmp.w * tce->bmpinfo.chunk_bmp.h;
int how_many_across = tce->bmpinfo.chunk_bmp.w;
int dim = bm_h(tce->bmpinfo.chunk_bmp.bm_array[0], 0);
int shift; // speed up (since dim is always a power of 2)
Expand Down Expand Up @@ -882,12 +879,10 @@ void RenderButton(tceffect *tce, float frametime, int xoff, int yoff, bool ok_to
bool glow = false;
while (PopEvent(tce, &evt)) {
switch (evt.id) {
case TEVT_GAINFOCUS: {
int num = tce - TCEffects;
} break;
case TEVT_LOSTFOCUS: {
int num = tce - TCEffects;
} break;
case TEVT_GAINFOCUS:
break;
case TEVT_LOSTFOCUS:
break;
case TEVT_MOUSEOVER: {
if (tce->flags & OBF_GLOW) {
if (tce->flags & OBF_MOUSEOVERFOCUS) {
Expand Down
7 changes: 0 additions & 7 deletions Descent3/TerrainSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,18 +265,12 @@ static uint16_t LOD_sort_num[MAX_TERRAIN_LOD];
// Variable to determine if we're in editor or game
extern function_mode View_mode;

static vector TJoint_VectorAddZ;
static vector TJoint_VectorAddX;

// Since our terrain points increment in finite steps we can rotate 2 points (x,z)
// just add them to a base point to get the final rotated point
void PreRotateTerrain() {
vector rvec = {1 * TERRAIN_SIZE, 0, 0};
vector fvec = {0, 0, 1 * TERRAIN_SIZE};

vector tj_rvec = {4, 0, 0};
vector tj_fvec = {0, 0, 4};

TS_FVectorAdd = fvec * *TS_View_matrix;
TS_RVectorAdd = rvec * *TS_View_matrix;

Expand Down Expand Up @@ -792,7 +786,6 @@ float GetTerrainGroundPoint(vector *pos, vector *normal) {
}

int SimplifyVertexSlow(int x, int z, float delta) {
vector *eye = TS_View_position;
g3Point p1, p2;

p1.p3_codes = 0;
Expand Down
5 changes: 0 additions & 5 deletions Descent3/WeaponFire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1210,8 +1210,6 @@ void AquireElectricalTarget(object *obj) {
int CreateAndFireWeapon(vector *pos, vector *dir, object *parent, int weapon_num) {
int objnum;
object *obj;
int parentnum = parent - Objects;
uint8_t terrain = 0;

ASSERT(Weapons[weapon_num].used);

Expand Down Expand Up @@ -1344,9 +1342,6 @@ int CreateAndFireWeapon(vector *pos, vector *dir, object *parent, int weapon_num
fate = fvi_FindIntersection(&fq, &hit_info);

if (fate != HIT_NONE && fate != HIT_OUT_OF_TERRAIN_BOUNDS) {
float try_dist = vm_VectorDistance(&obj->pos, &end_pos);
float got_dist = vm_VectorDistance(&obj->pos, &hit_info.hit_pnt);

obj->ctype.laser_info.hit_pnt = hit_info.hit_pnt;
obj->ctype.laser_info.hit_wall_pnt = hit_info.hit_face_pnt[0];
obj->ctype.laser_info.hit_room = hit_info.hit_room;
Expand Down
5 changes: 0 additions & 5 deletions Descent3/aipath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,6 @@ static bool AIPathMoveToNextNode(ai_path_info *aip) {
int c_path = aip->cur_path;
int c_node = aip->cur_node;

int p_type = aip->path_type[c_path];
int p_index = aip->path_id[c_path];

c_node++;

if (c_node <= aip->path_end_node[c_path]) {
Expand Down Expand Up @@ -342,8 +339,6 @@ void AIPathMoveTurnTowardsNode(object *obj, vector *mdir, bool *f_moved) {

bool f_reverse = (g_ptr->flags & GF_PATH_MOVE_REVERSE_DIR) != 0;

ai_frame *ai_info = obj->ai_info;

vector cur_pos;

AIPathGetCurrentNodePos(aip, &cur_pos);
Expand Down
1 change: 0 additions & 1 deletion Descent3/aiterrain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ static void ai_check_terrain_node(int cur_node, int f_check_local_nodes) {
int xcounter, ycounter;
int xstart, xend;
int ystart, yend;
int f_ignore_terrain_in_this_node = 0;

// Chrishack -- Note

Expand Down
1 change: 0 additions & 1 deletion Descent3/attach.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,6 @@ bool AttachObject(object *parent, char parent_ap, object *child, float percent_r
ASSERT(child);

poly_model *parent_pm = &Poly_models[parent->rtype.pobj_info.model_num];
poly_model *child_pm = &Poly_models[parent->rtype.pobj_info.model_num];

if (parent_ap < 0 || parent_ap >= parent_pm->n_attach) {
LOG_WARNING << "ATTACH: Parent AP invalid";
Expand Down
2 changes: 1 addition & 1 deletion Descent3/audiotaunts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ bool taunt_PlayTauntFile(const char *filename) {
if (!Audio_taunts_enabled)
return false;

int ret = StreamPlay(filename, (MAX_GAME_VOLUME / 2.0f), 0);
StreamPlay(filename, (MAX_GAME_VOLUME / 2.0f), 0);
return true;
}

Expand Down
Loading

0 comments on commit 8d4adde

Please sign in to comment.