Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More aggressive static declarations #347

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions 2dlib/memsurf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,10 @@
// internal functions
// ---------------------------------------------------------------------------

static mem_bitmap grMemSurf_object;

Check warning on line 142 in 2dlib/memsurf.cpp

View workflow job for this annotation

GitHub Actions / Linux-x64-clang, Debug

unused variable 'grMemSurf_object' [-Wunused-variable]

bool gr_bm_mem_Blt16(ddgr_surface *dsf, int dx, int dy, ddgr_surface *ssf, int sx, int sy, int sw, int sh);
bool gr_bm_mem_Blt16ck(ddgr_surface *dsf, int dx, int dy, ddgr_surface *ssf, int sx, int sy, int sw, int sh);
static bool gr_bm_mem_Blt16(ddgr_surface *dsf, int dx, int dy, ddgr_surface *ssf, int sx, int sy, int sw, int sh);
static bool gr_bm_mem_Blt16ck(ddgr_surface *dsf, int dx, int dy, ddgr_surface *ssf, int sx, int sy, int sw, int sh);

// ---------------------------------------------------------------------------
// initializes a memory surface by allocating memory based on bit depth
Expand Down
2 changes: 1 addition & 1 deletion AudioEncode/encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "audio_encode.h"
#include "mono.h"

int32_t aenc_ReadSamp(void *data) {
static int32_t aenc_ReadSamp(void *data) {
FILE *f = (FILE *)data;
int a, b;
a = getc(f);
Expand Down
13 changes: 7 additions & 6 deletions Descent3/AImain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1555,6 +1555,7 @@
#define MIN_TARGET_UPDATE_INTERVAL 2.0f
#define MAX_TARGET_UPDATE_INTERVAL 4.5f

// TODO: MTS: unused?
float AI_last_time_room_noise_alert_time[MAX_ROOMS + 8];
int AI_unique_goal_id = 0;

Expand Down Expand Up @@ -2254,7 +2255,7 @@ bool AITurnTowardsMatrix(object *obj, float turn_rate, matrix *g_orient) {
return false;
}

// MTS: Unused?
// TODO: MTS: unused?
void AITurnTowardsPosition(object *obj, /*velocity *new_vel,*/ vector *pos /*, bool remain_level*/) {
vector goal_dir = *pos - obj->pos;
ai_frame *ai_info = obj->ai_info;
Expand Down Expand Up @@ -3497,7 +3498,7 @@ void ai_do_animation(object *obj, float anim_time) {

#define FRR_MAX_TRIES 15

// MTS: Unused?
// TODO: MTS: unused?
int AIGoalGotoRandomRoom() { return -1; }

int AIFindRandomRoom(object *obj, ai_frame *ai_info, goal *goal_ptr, int avoid_room, int min_depth, int max_depth,
Expand Down Expand Up @@ -4104,10 +4105,10 @@ bool AIStatusCircleFrame(object *obj, object *g_obj, float dist, float c_dist, i
}
}

// MTS: Unused?
// TODO: MTS: unused?
bool ai_target_need_path(object *obj) { return true; }

// MTS: Unused?
// TODO: MTS: unused?
bool ai_move_need_path(object *obj, vector *pos, int roomnum) {
if (obj->roomnum == roomnum) {
return false;
Expand Down Expand Up @@ -4211,7 +4212,7 @@ static inline bool IsTargetLocal(object *obj, object *target) {
#define COHESION_OPTI2_DIST 90.0f
#define COHESION_FALL_OFF 110.0f

// MTS: commented out/returns a bool instead of a float
// FIXME: MTS: commented out/returns a bool instead of a float
float AIGoalIsEnabledForDist(goal *goal, float dist) {
return true; // chrishack -- test code -- temp
}
Expand Down Expand Up @@ -4363,7 +4364,7 @@ void AIDoTrackFrame(object *obj) {
}
}

// MTS: unused?
// TODO: MTS: unused?
float AIDetermineGoalInfluence(object *obj, goal *goal) {
float influence = goal->influence;
int g_index = goal - obj->ai_info->goals;
Expand Down
2 changes: 1 addition & 1 deletion Descent3/Briefing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ static tBriefingTag HotTags[] = {
{"#PLEVELNUM#", TAG_PLEVELNUM, -1},
{"#NLEVELNUM#", TAG_NLEVELNUM, -1},
};
static const int NumHotTags = sizeof(HotTags) / sizeof(tBriefingTag);
static constexpr int NumHotTags = sizeof(HotTags) / sizeof(tBriefingTag);

static int osb_xoff = 0, osb_yoff = 0;
static int current_screen = -1;
Expand Down
2 changes: 1 addition & 1 deletion Descent3/Controls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ static void DoControllerWeapons(game_controls *controls);
static void DoMisc(game_controls *contols);
static void DoKeyboardMisc(game_controls *controls);
static void DoControllerMisc(game_controls *controls);
// MTS: no implementation!
// FIXME: MTS: no implementation!
void DoCommands();

static void ToggleHeadlightControlState();
Expand Down
2 changes: 1 addition & 1 deletion Descent3/CtlCfgElem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ UIBitmapItem *cfg_element::m_xbtn_bmp_lit = NULL;
UIBitmapItem *cfg_element::m_xbtn_bmp = NULL;
int16_t cfg_element::m_count = 0;

// MTS: unused?
// TODO: MTS: unused?
bool key_cfg_element(uint8_t *element, uint8_t *flags);

//////////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion Descent3/DllWrappers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void dSetAudioTaunts(bool enable) {

// Changes the ship_index for a given player
void ChangePlayerShipIndex(int pnum, int ship_index) {
int ObjInitTypeSpecific(object * objp, bool reinitializing);
extern int ObjInitTypeSpecific(object * objp, bool reinitializing);

if (pnum < 0 || pnum >= MAX_PLAYERS)
return;
Expand Down
2 changes: 1 addition & 1 deletion Descent3/GameLoop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2231,7 +2231,7 @@ void ProcessTestKeys(int key) {
} break;

case KEY_F10:
int ObjInitTypeSpecific(object * objp, bool reinitializing);
extern int ObjInitTypeSpecific(object * objp, bool reinitializing);
FreeCockpit();
CloseShipHUD();
Players[0].ship_index = GetNextShip(Players[0].ship_index);
Expand Down
21 changes: 12 additions & 9 deletions Descent3/Mission.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,7 @@
#include "terrain.h"
#include "multi.h"
#include "hud.h"
#include "menu.h"
// ---------------------------------------------------------------------------
// Data
// ---------------------------------------------------------------------------
Expand All @@ -692,16 +693,17 @@ extern msn_urls Net_msn_URLs;
bool InitMissionScript();
void DoEndMission();
void DoMissionMovie(const char *movie);
void FreeMission();
static void FreeMission();
// FIXME: MTS: unused?
// used in load level callback
void LoadLevelCB(const char *chunk, int curlen, int filelen);
// MN3 based mission functions.
// loads the msn file from the mn3 file specified, specifies the hog and table file.
bool mn3_Open(const char *mn3file);
// returns mission information given the mn3 file.
bool mn3_GetInfo(const char *mn3file, tMissionInfo *msn);
//bool mn3_Open(const char *mn3file);
/// Returns mission information given the mn3 file.
static bool mn3_GetInfo(const char *mn3file, tMissionInfo *msn);
// closes the current mn3 file
void mn3_Close();
//void mn3_Close();

static inline bool IS_MN3_FILE(const char *fname) {
char name[PSFILENAME_LEN + 1];
Expand Down Expand Up @@ -1314,7 +1316,7 @@ bool started_page = 0;
/*
$$TABLE_GAMEFILE "tunnelload.ogf"
*/
bool Progress_screen_loaded = false;
static bool Progress_screen_loaded = false;
void LoadLevelProgress(int step, float percent, const char *chunk) {
static tLargeBitmap level_bmp;
static bool level_bmp_loaded = false;
Expand Down Expand Up @@ -1634,8 +1636,8 @@ bool DoMissionBriefing(int level) {
ret = !TelComShow(TS_MISSION, false, true);
return ret;
}
extern bool FirstGame;

bool Skip_next_movie = false;
// ---------------------------------------------------------------------------
// play movie
void DoMissionMovie(const char *movie) {
Expand Down Expand Up @@ -1682,7 +1684,7 @@ bool InitMissionScript() {
//@@ }
return true;
}
extern bool IsRestoredGame;

void InitLevelScript() {
if (Current_level->filename) {
char filename[_MAX_PATH], ext[_MAX_EXT];
Expand Down Expand Up @@ -1800,14 +1802,15 @@ bool IsMissionMultiPlayable(const char *mission) {
}
return false;
}
// TODO: MTS: unused function?
bool IsMissionSinglePlayable(const char *mission) {
tMissionInfo msninfo;
if (GetMissionInfo(mission, &msninfo)) {
return msninfo.single;
}
return false;
}
int Mission_voice_hog_handle = 0;
static int Mission_voice_hog_handle = 0;
// MN3 based mission functions.
// loads the msn file from the mn3 file specified, specifies the hog and table file.
bool mn3_Open(const char *mn3file) {
Expand Down
24 changes: 16 additions & 8 deletions Descent3/Mission.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,20 +181,22 @@
void LoadLevelProgress(int step, float percent, const char *chunk = NULL);

// array constants
const int MSN_FILENAMELEN = _MAX_PATH, MSN_URLLEN = 256;
static constexpr int MSN_FILENAMELEN = PSPATHNAME_LEN, MSN_URLLEN = 256;

#define MAX_KEYWORDLEN 300

// increase this value if you are going to add more levels to a mission than the max.
const int MAX_LEVELS_PER_MISSION = 30;
static constexpr int MAX_LEVELS_PER_MISSION = 30;

// mission flags.
const unsigned LVLFLAG_STARTMOVIE = 1, LVLFLAG_ENDMOVIE = 2, LVLFLAG_BRIEFING = 4, LVLFLAG_SHIPSELECT = 8,
LVLFLAG_SPAWNSECRET = 16, LVLFLAG_SPECIALHOG = 32, LVLFLAG_BRANCH = 64, LVLFLAG_UNUSED = 128,
LVLFLAG_SCORE = 256, LVLFLAG_FINAL = 512;
// mission flags. TODO: move into an enum?
static constexpr unsigned LVLFLAG_STARTMOVIE = 1, LVLFLAG_ENDMOVIE = 2, LVLFLAG_BRIEFING = 4, LVLFLAG_SHIPSELECT = 8,
LVLFLAG_SPAWNSECRET = 16, LVLFLAG_SPECIALHOG = 32, LVLFLAG_BRANCH = 64, LVLFLAG_UNUSED = 128,
LVLFLAG_SCORE = 256, LVLFLAG_FINAL = 512;

const int LVLOBJ_NUM = 4;
const uint16_t LVLOBJF_SECONDARY1 = 1, LVLOBJF_SECONDARY2 = 2, LVLOBJF_SECONDARY3 = 4, LVLOBJF_SECONDARY4 = 8;
static constexpr int LVLOBJ_NUM = 4;
static constexpr uint16_t LVLOBJF_SECONDARY1 = 1, LVLOBJF_SECONDARY2 = 2, LVLOBJF_SECONDARY3 = 4, LVLOBJF_SECONDARY4 = 8;

extern bool Skip_next_movie;

// Struct for info about the current level
struct level_info {
Expand Down Expand Up @@ -326,6 +328,12 @@ bool GetMissionInfo(const char *msnfile, tMissionInfo *msn);
// MAX_NET_PLAYERS -- This is playable with any number of teams the mod wants
int MissionGetKeywords(const char *mission, char *keywords);

// MN3 based mission functions.
/// Loads the msn file from the mn3 file specified, specifies the hog and table file.
extern bool mn3_Open(const char *mn3file);
/// Closes the current mn3 file.
extern void mn3_Close();

#ifdef EDITOR
// Used by editor to load all necessary elements for level playing for systems
// not initialized in editor, but only in game.
Expand Down
2 changes: 1 addition & 1 deletion Descent3/NewPyroGauges.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ static struct {

//////////////////////////////////////////////////////////////////////////////

void GetCenterPoint(int *x, int *y, vector *wpos);
static void GetCenterPoint(int *x, int *y, vector *wpos);

void NewPyroInitGauges() {
int texhandle;
Expand Down
8 changes: 6 additions & 2 deletions Descent3/aiterrain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ static int ai_num_checks_since_init = 0;
static float ai_rad;
static ground_information *ai_ground_info_ptr;

static void ait_terrain_clean();
static void ai_check_terrain_node(int cur_node, int f_check_local_nodes);

void ait_Init() {
ai_num_segs_checked = 0;
memset(ai_terrain_check_list, 0, ((TERRAIN_WIDTH * TERRAIN_DEPTH) >> 3) + 1);
Expand All @@ -76,7 +79,7 @@ void ait_Init() {
#endif
}

static void ait_terrain_clean() {
void ait_terrain_clean() {
int i;

assert(ai_num_segs_checked >= 0 && ai_num_segs_checked <= AI_MAX_SEGS_CHECKED);
Expand All @@ -96,7 +99,7 @@ static void ait_terrain_clean() {
ai_num_segs_checked = 0;
}

static void ai_check_terrain_node(int cur_node, int f_check_local_nodes) {
void ai_check_terrain_node(int cur_node, int f_check_local_nodes) {
int check_x, check_y;
int new_node;
int xcounter, ycounter;
Expand Down Expand Up @@ -160,6 +163,7 @@ static void ai_check_terrain_node(int cur_node, int f_check_local_nodes) {
return;
}

// TODO: MTS: unused?
// Returns true if the new point is on the terrain and false if the path results in leaving the terrain
bool ait_GetGroundInfo(ground_information *ground_info, vector *p0, vector *p1, float rad, angle fov) {
int start_node, end_node;
Expand Down
7 changes: 5 additions & 2 deletions Descent3/ambient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,15 @@
asp Ambient_sound_patterns[MAX_AMBIENT_SOUND_PATTERNS];
int Num_ambient_sound_patterns = 0;

static void ProcessASP(asp *asp);
static void FreeAmbientSoundData();

// Computes a floating-point pseudo-random number.
// Returns value in the range 0..1, with the precision 1/D3_RAND_MAX
static float randf() { return ((float)ps_rand()) / ((float)D3_RAND_MAX); }

// Process an Ambient Sound Pattern
static void ProcessASP(asp *asp) {
void ProcessASP(asp *asp) {
// Check for empty ASP
if (!asp->num_sounds)
return;
Expand Down Expand Up @@ -161,7 +164,7 @@ void InitAmbientSounds() {
#include "mem.h"

// Close down ambient sound system and free data
static void FreeAmbientSoundData() {
void FreeAmbientSoundData() {
for (int p = 0; p < Num_ambient_sound_patterns; p++)
if (Ambient_sound_patterns[p].num_sounds)
mem_free(Ambient_sound_patterns[p].sounds);
Expand Down
22 changes: 17 additions & 5 deletions Descent3/attach.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,22 @@ PI); rot_angle = acos(dot);
}
*/

/// Finds the position of a attach point on an object.
/// The uvec is optional as most attaching objects don't need at complete orientation set (only an fvec).
static bool AttachPointPos(object *obj, char ap, bool f_compute_pos, vector *attach_pos, bool f_compute_fvec,
vector *attach_fvec, bool *f_computed_uvec = NULL, vector *attach_uvec = NULL);

static void ConvertAxisAmountMatrix(vector *n, float w, matrix *rotmat);

// Adds and subtracts from mass from connections and disconnections
static void AttachPropagateMass(object *child, bool f_attach = true);

static void ProprogateUltimateAttachParent(object *parent, int ultimate_handle);

// Finds the position of a attach point on an object
// The uvec is optional as most attaching objects don't need at complete orientation set (only an fvec)
static bool AttachPointPos(object *obj, char ap, bool f_compute_pos, vector *attach_pos, bool f_compute_fvec,
vector *attach_fvec, bool *f_computed_uvec = NULL, vector *attach_uvec = NULL) {
bool AttachPointPos(object *obj, char ap, bool f_compute_pos, vector *attach_pos, bool f_compute_fvec,
vector *attach_fvec, bool *f_computed_uvec, vector *attach_uvec) {
poly_model *pm;
vector pnt;
vector normal;
Expand Down Expand Up @@ -227,7 +239,7 @@ static bool AttachPointPos(object *obj, char ap, bool f_compute_pos, vector *att
return true;
}

static void ConvertAxisAmountMatrix(vector *n, float w, matrix *rotmat) {
void ConvertAxisAmountMatrix(vector *n, float w, matrix *rotmat) {
float s;
float c;
float t;
Expand Down Expand Up @@ -399,7 +411,7 @@ bool AttachDoPosOrient(object *parent, char parent_ap, object *child, char child
}

// Adds and subtracts from mass from connections and disconnections
static void AttachPropagateMass(object *child, bool f_attach = true) {
void AttachPropagateMass(object *child, bool f_attach) {
object *new_parent;

if (!child)
Expand Down Expand Up @@ -447,7 +459,7 @@ static inline void ComputeUltimateAttachParent(object *child) {
} while (cur_obj->flags & OF_ATTACHED);
}

static void ProprogateUltimateAttachParent(object *parent, int ultimate_handle) {
void ProprogateUltimateAttachParent(object *parent, int ultimate_handle) {
int i;

ASSERT(parent);
Expand Down
2 changes: 1 addition & 1 deletion Descent3/audiotaunts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ struct tWaveFile {
static char taunt_LoadWaveFile(const char *filename, tWaveFile *wave);

static int TauntLastError = TAUNTIMPERR_NOERROR;
bool Audio_taunts_enabled = true;
static bool Audio_taunts_enabled = true;
static float Audio_taunt_delay_time = 5.0f;

// taunt_Enable
Expand Down
2 changes: 0 additions & 2 deletions Descent3/audiotaunts.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@
#ifndef __AUDIO_TAUNT_H_
#define __AUDIO_TAUNT_H_

extern bool Audio_taunts_enabled;

// Error codes:
#define TAUNTIMPERR_NOERROR 0
#define TAUNTIMPERR_NOTFOUND 1
Expand Down
Loading
Loading