Skip to content

Commit

Permalink
More migration from bare statics to static inlines.
Browse files Browse the repository at this point in the history
  • Loading branch information
MaddTheSane committed May 7, 2024
1 parent 444472a commit 1db9a4b
Show file tree
Hide file tree
Showing 40 changed files with 146 additions and 147 deletions.
2 changes: 1 addition & 1 deletion 2dlib/surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
#include "texture.h"
#include "renderer.h"

inline unsigned XLAT_RGB_TO_16(ddgr_color c) {
static inline unsigned XLAT_RGB_TO_16(ddgr_color c) {
unsigned char r, g, b;
r = (unsigned char)((c & 0x00ff0000) >> 16);
g = (unsigned char)((c & 0x0000ff00) >> 8);
Expand Down
4 changes: 1 addition & 3 deletions Descent3/Controls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,6 @@
#include <stdlib.h>
#include <memory.h>


float Key_ramp_speed = 0.5f;

#define CONTROL_POLL_RATE (1.0f / 25.0f)
Expand Down Expand Up @@ -468,7 +467,6 @@ static tSpace Key_ramp;

// PROTOTYPES

void DoMovement(game_controls *controls);
static void DoKeyboardMovement(game_controls *controls);
static void DoControllerMovement(game_controls *controls);
static void DoWeapons(game_controls *controls);
Expand Down Expand Up @@ -621,7 +619,7 @@ void InitControls() {
Key_ramp.oy = Key_ramp.y = 0.0f;
Key_ramp.oz = Key_ramp.z = 0.0f;

// Initialize preemptive controller system for non-positonal data.
// Initialize preemptive controller system for non-positonal data.
mprintf((0, "Initialized control system.\n"));
}

Expand Down
4 changes: 2 additions & 2 deletions Descent3/Mission.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -700,14 +700,14 @@ bool mn3_GetInfo(const char *mn3file, tMissionInfo *msn);
// closes the current mn3 file
void mn3_Close();

inline bool IS_MN3_FILE(const char *fname) {
static inline bool IS_MN3_FILE(const char *fname) {
char name[PSFILENAME_LEN + 1];
char ext[PSFILENAME_LEN + 1];
ddio_SplitPath(fname, NULL, name, ext);
return (strcmpi(ext, ".mn3") == 0) ? true : false;
}

inline char *MN3_TO_MSN_NAME(const char *mn3name, char *msnname) {
static inline char *MN3_TO_MSN_NAME(const char *mn3name, char *msnname) {
char fname[PSFILENAME_LEN + 1];
ddio_SplitPath(mn3name, NULL, fname, NULL);

Expand Down
4 changes: 2 additions & 2 deletions Descent3/OsirisLoadandBind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2283,9 +2283,9 @@ typedef struct {
} tOSIRISINTERNALTIMER;
tOSIRISINTERNALTIMER OsirisTimers[MAX_OSIRIS_TIMERS];

inline int FORM_HANDLE(int counter, int slot) { return (((counter & 0xFFFFFF) << 8) | (slot & 0xFF)); }
static inline int FORM_HANDLE(int counter, int slot) { return (((counter & 0xFFFFFF) << 8) | (slot & 0xFF)); }

inline int GET_SLOT(int handle) { return (handle & 0xFF); }
static inline int GET_SLOT(int handle) { return (handle & 0xFF); }

int Osiris_timer_counter = 0;

Expand Down
4 changes: 2 additions & 2 deletions Descent3/TerrainSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ void PreRotateTerrain() {
}
}

inline vector *GetDYVector(int h) {
static inline vector *GetDYVector(int h) {
vector *dyp;

dyp = &Terrain_y_cache[h];
Expand All @@ -309,7 +309,7 @@ inline vector *GetDYVector(int h) {
return dyp;
}

inline void GetPreRotatedPointFast(vector *dest, int x, int z, int yvalue) {
static inline void GetPreRotatedPointFast(vector *dest, int x, int z, int yvalue) {
ASSERT(yvalue >= 0 && yvalue <= 255);

// If the terrain is supposed to be flat, bash this to zero
Expand Down
2 changes: 1 addition & 1 deletion Descent3/bsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,7 @@ static inline int BSPInMinMax(vector *pos, vector *min_xyz, vector *max_xyz) {
extern uint check_point_to_face(vector *colp, vector *face_normal, int nv, vector **vertex_ptr_list);

// Returns true if passed in point collides with a nodes polygon
inline int BSPPointInPolygon(vector *pos, bspnode *node) {
static inline int BSPPointInPolygon(vector *pos, bspnode *node) {
if (node->node_subnum < 0) // Room face
{
room *rp = &Rooms[node->node_roomnum];
Expand Down
8 changes: 4 additions & 4 deletions Descent3/gamecinematics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ void Cinematic_LevelInit(void) {
GameCinema.doing_end_transition = false;
}

inline void verify_percentranage(PercentageRange *range) {
static inline void verify_percentranage(PercentageRange *range) {
if (range->min < 0.0f)
range->min = 0.0f;
if (range->min > 1.0f)
Expand Down Expand Up @@ -454,7 +454,7 @@ void Cinematic_SetForFakeCinematic(tGameCinematic *info) {
Cinematic_fake_queued = true;
}

inline int Cinematics_CreateCamera(void) {
static inline int Cinematics_CreateCamera(void) {
int objnum = ObjCreate(OBJ_CAMERA, 0, Player_object->roomnum, &Player_object->pos, NULL);
if (objnum == -1)
return OBJECT_HANDLE_NONE;
Expand Down Expand Up @@ -508,7 +508,7 @@ bool Cinematic_Start(tGameCinematic *info, char *text_string) {
return Cinematic_StartCine(info, text_string, camera_handle);
}

inline void Cinematic_DeleteCamera(int objhandle) {
static inline void Cinematic_DeleteCamera(int objhandle) {
object *obj = ObjGet(objhandle);
if (obj) {
SetObjectDeadFlag(obj);
Expand Down Expand Up @@ -890,7 +890,7 @@ bool Cinematic_StartCine(tGameCinematic *info, const char *text_string, int came
return true;
}

inline bool Cinematic_IsPlayerDead(void) {
static inline bool Cinematic_IsPlayerDead(void) {
if (!Player_object || (Player_object->type == OBJ_GHOST) ||
(Player_object->type == OBJ_PLAYER &&
Players[Player_object->id].flags & (PLAYER_FLAGS_DYING | PLAYER_FLAGS_DEAD))) {
Expand Down
2 changes: 1 addition & 1 deletion Descent3/gauges.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ void FlagGaugesNonfunctional(tStatMask mask) {
// can render another view though.
// renders the primary monitor gauge

inline int get_weapon_hud_image(int player, int type) {
static inline int get_weapon_hud_image(int player, int type) {
player_weapon *pw = &Players[player].weapon[type];
weapon *wpn = GetWeaponFromIndex(player, pw->index);

Expand Down
4 changes: 2 additions & 2 deletions Descent3/hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1916,7 +1916,7 @@ void ResetReticle() {
}

// creates the reticle display bitmap mask to be used by the reticle renderer.
inline ushort reticle_mask(object *pobj, otype_wb_info *static_wb, int wb_index) {
static inline ushort reticle_mask(object *pobj, otype_wb_info *static_wb, int wb_index) {
poly_model *pm = &Poly_models[pobj->rtype.pobj_info.model_num];
dynamic_wb_info *dyn_wb = &pobj->dynamic_wb[wb_index];
unsigned mask = 0;
Expand Down Expand Up @@ -1952,7 +1952,7 @@ inline ushort reticle_mask(object *pobj, otype_wb_info *static_wb, int wb_index)
return mask;
}

inline void draw_reticle_sub(int cx, int cy, int rw, int rh, ushort on_mask, ushort gp_mask, const int *wb_elem_array) {
static inline void draw_reticle_sub(int cx, int cy, int rw, int rh, ushort on_mask, ushort gp_mask, const int *wb_elem_array) {
int i, x, y;
int bmp_handle;
char align;
Expand Down
2 changes: 1 addition & 1 deletion Descent3/huddisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ static void RenderHUDWarnings(tHUDItem *item);
static void RenderHUDCountermeasures(tHUDItem *item);

// returns the weapon's icon.
inline int get_weapon_icon(int player, int type) {
static inline int get_weapon_icon(int player, int type) {
player_weapon *pw = &Players[player].weapon[type];
weapon *wpn = GetWeaponFromIndex(player, pw->index);
int bmp;
Expand Down
8 changes: 4 additions & 4 deletions Descent3/newui_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,19 +496,19 @@ class newuiEditBox : public UIEdit {
bool m_quick_escape_enable;
};

inline UISnazzyTextItem *MonitorSmallText(const char *text) {
static inline UISnazzyTextItem *MonitorSmallText(const char *text) {
return new UISnazzyTextItem(0, MONITOR9_NEWUI_FONT, text, NEWUI_MONITORFONT_COLOR);
}

inline UISnazzyTextItem *MonitorLargeText(const char *text) {
static inline UISnazzyTextItem *MonitorLargeText(const char *text) {
return new UISnazzyTextItem(0, MONITOR15_NEWUI_FONT, text, NEWUI_MONITORFONT_COLOR);
}

inline UISnazzyTextItem *GadgetSmallText(const char *text) {
static inline UISnazzyTextItem *GadgetSmallText(const char *text) {
return new UISnazzyTextItem(0, GADGET9_NEWUI_FONT, text, NEWUI_GADGETFONT_COLOR);
}

inline UISnazzyTextItem *GadgetLargeText(const char *text) {
static inline UISnazzyTextItem *GadgetLargeText(const char *text) {
return new UISnazzyTextItem(0, GADGET15_NEWUI_FONT, text, NEWUI_GADGETFONT_COLOR);
}

Expand Down
4 changes: 2 additions & 2 deletions Descent3/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -705,8 +705,8 @@ extern short BigObjectList[MAX_BIG_OBJECTS]; // DAJ_MR utb int
*/

// Set the dead flag for an object
void SetObjectDeadFlag(object *obj, bool tell_clients_to_remove = false, bool play_sound_on_clients = false);
inline void SetObjectDeadFlag(object *obj, bool tell_clients_to_remove, bool play_sound_on_clients) {
static inline void SetObjectDeadFlag(object *obj, bool tell_clients_to_remove = false, bool play_sound_on_clients = false);
static inline void SetObjectDeadFlag(object *obj, bool tell_clients_to_remove, bool play_sound_on_clients) {
int objnum = OBJNUM(obj);
ASSERT(objnum != -1);
ASSERT(objnum != 0);
Expand Down
2 changes: 1 addition & 1 deletion Descent3/osiris_dll.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Descent 3
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
Expand Down
4 changes: 2 additions & 2 deletions Descent3/pilot_class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,11 @@

#define __PILOT_H_ // don't want to include pilot.h right now
#include "difficulty.h"
#include "audiotaunts.h"

#include <algorithm>

void grtext_SetProfanityFilter(bool enabled);
void taunt_Enable(bool enable);
extern void grtext_SetProfanityFilter(bool enabled);

extern float Key_ramp_speed;

Expand Down
2 changes: 1 addition & 1 deletion Descent3/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ void MakeAtuoWaypointList();
void SetAutoWaypoint(object *objp);

// Returns the team (0 to 3) of the given player
inline int PlayerGetTeam(int pnum) {
static inline int PlayerGetTeam(int pnum) {
if (Players[pnum].team == -1) {
// special "no-team" for Dedicated server
return 0; // fake a red team
Expand Down
2 changes: 1 addition & 1 deletion Descent3/procedurals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ void AddProcPoint(int x, int y, ubyte color) {
ProcDestData[index] = color;
}
// Adds one point to a bitmap
inline void PlaceProcPoint(int x, int y, ubyte color) {
static inline void PlaceProcPoint(int x, int y, ubyte color) {
x &= (PROC_SIZE - 1);
y &= (PROC_SIZE - 1);
ProcDestData[y * PROC_SIZE + x] = color;
Expand Down
2 changes: 1 addition & 1 deletion Descent3/render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3025,7 +3025,7 @@ static int obj_sort_func(const obj_sort_item *a, const obj_sort_item *b) {
else
return 0;
}
inline void IsRoomDynamicValid(room *rp, int x, int y, int z, float *r, float *g, float *b) {
static inline void IsRoomDynamicValid(room *rp, int x, int y, int z, float *r, float *g, float *b) {
int w = rp->volume_width;
int h = rp->volume_height;
int d = rp->volume_depth;
Expand Down
2 changes: 1 addition & 1 deletion Descent3/renderobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ static void DrawNumber(int num, vector pos, float size, ddgr_color c1) {
}
}
}
inline bool object_object_AABB(object *obj1, object *obj2) {
static inline bool object_object_AABB(object *obj1, object *obj2) {
bool overlap = true;
if (obj1->max_xyz.x < obj2->min_xyz.x || obj2->max_xyz.x < obj1->min_xyz.x || obj1->max_xyz.z < obj2->min_xyz.z ||
obj2->max_xyz.z < obj1->min_xyz.z || obj1->max_xyz.y < obj2->min_xyz.y || obj2->max_xyz.y < obj1->min_xyz.y)
Expand Down
2 changes: 1 addition & 1 deletion Descent3/room.h
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ int CheckTransparentPoint(const vector *pnt, const room *rp, const int facenum);
// Parameters: rp - pointer to the room the face is in
// fp - the face we're interested in
// Returns: bitmask of flags (see above).
inline int GetFacePhysicsFlags(const room *rp, const face *fp) {
static inline int GetFacePhysicsFlags(const room *rp, const face *fp) {
int ret = 0;

// If face is a trigger, must record
Expand Down
6 changes: 3 additions & 3 deletions Descent3/spew.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@

#define MAX_SPEWS_PER_FRAME 5 // maximum number of spews 1 can emit per frame

inline int FORM_HANDLE(int counter, int slot) { return (((counter & 0xFF) << 16) + (slot & 0xFF)); }
static inline int FORM_HANDLE(int counter, int slot) { return (((counter & 0xFF) << 16) + (slot & 0xFF)); }

inline int GET_SLOT(int handle) { return (handle & 0xFF); }
static inline int GET_SLOT(int handle) { return (handle & 0xFF); }

spewinfo SpewEffects[MAX_SPEW_EFFECTS];
int spew_count;
Expand Down Expand Up @@ -494,4 +494,4 @@ bool SpewObjectNeedsEveryFrameUpdate(object *obj, int gun_num) {
}

return false;
}
}
2 changes: 1 addition & 1 deletion Descent3/terrain.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ extern short Terrain_seg_render_objs[];
#ifdef RELEASE
#define TERRAIN_REGION(x) ((Terrain_seg[0x7FFFFFFF & x].flags & TFM_REGION_MASK) >> 5)
#else // debug(-ish) builds - check if x is valid
inline int TERRAIN_REGION(int x) {
static inline int TERRAIN_REGION(int x) {
ASSERT(x != -1 && "invalid/unset room number (-1)!");
// Note: due to the 0x7FFFFFFF mask, terrSegIdx will be >= 0
int terrSegIdx = 0x7FFFFFFF & x;
Expand Down
2 changes: 1 addition & 1 deletion Descent3/weapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ void SelectSecondaryWeapon(int slot);
void SetPrimaryWeapon(int index, int slot);
void SetSecondaryWeapon(int index, int slot);

inline bool is_weapon_available(unsigned player_weapon_flags, int new_weapon, ushort ammo = 0xffff) {
static inline bool is_weapon_available(unsigned player_weapon_flags, int new_weapon, ushort ammo = 0xffff) {
return ((player_weapon_flags & HAS_FLAG(new_weapon)) && ammo > 0) ? true : false;
}

Expand Down
1 change: 0 additions & 1 deletion cfile/cfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,6 @@ void CFindFiles::Close() {
globfree(&ffres);
}

static bool cf_FindRealFileNameCaseInsenstive(const char *directory, const char *fname, char *new_filename);
static FILE *open_file_in_directory_case_sensitive(const char *directory, const char *filename, const char *mode,
char *new_filename);

Expand Down
16 changes: 8 additions & 8 deletions dd_lnxsound/mixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
#define MAX_WRITE_AHEAD 0.04f // Seconds to write ahead of the play position (in seconds)
#define VOLUME_FIX_BITS 1024

inline void opti_8m_mix(unsigned char *cur_sample_8bit, const int num_write, int &samples_played, short *mixer_buffer16,
const float l_volume, const float r_volume);
inline void opti_8s_mix(unsigned char *cur_sample_8bit, const int num_write, int &samples_played, short *mixer_buffer16,
const float l_volume, const float r_volume);
inline void opti_16m_mix(short *cur_sample_16bit, const int num_write, int &samples_played, short *mixer_buffer16,
const float l_volume, const float r_volume);
inline void opti_16s_mix(short *cur_sample_16bit, const int num_write, int &samples_played, short *mixer_buffer16,
const float l_volume, const float r_volume);
static inline void opti_8m_mix(unsigned char *cur_sample_8bit, const int num_write, int &samples_played,
short *mixer_buffer16, const float l_volume, const float r_volume);
static inline void opti_8s_mix(unsigned char *cur_sample_8bit, const int num_write, int &samples_played,
short *mixer_buffer16, const float l_volume, const float r_volume);
static inline void opti_16m_mix(short *cur_sample_16bit, const int num_write, int &samples_played,
short *mixer_buffer16, const float l_volume, const float r_volume);
static inline void opti_16s_mix(short *cur_sample_16bit, const int num_write, int &samples_played,
short *mixer_buffer16, const float l_volume, const float r_volume);

software_mixer::software_mixer() {
m_init = false;
Expand Down
2 changes: 1 addition & 1 deletion ddio_lnx/lnxkey_sdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ int sdlkey_to_ddiocode[27] = {0, KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, K
KEY_I, KEY_J, KEY_K, KEY_L, KEY_M, KEY_N, KEY_O, KEY_P, KEY_Q,
KEY_R, KEY_S, KEY_T, KEY_U, KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z};

inline ubyte sdlkeycode_to_keycode(unsigned int sdlkeycode) {
static inline ubyte sdlkeycode_to_keycode(unsigned int sdlkeycode) {
// unceremoniously taken from Heretic source code with a few modifications.
// (by Outrage. Not Loki. We know better. :) --ryan.)
int rc = sdlkeycode;
Expand Down

0 comments on commit 1db9a4b

Please sign in to comment.