diff --git a/2dlib/font.cpp b/2dlib/font.cpp index 5411b999..a018be5b 100644 --- a/2dlib/font.cpp +++ b/2dlib/font.cpp @@ -141,6 +141,13 @@ typedef CFILE *FONTFILE; +static inline int READ_FONT_INT(FONTFILE ffile); +static inline short READ_FONT_SHORT(FONTFILE ffile); +static inline ubyte READ_FONT_BYTE(FONTFILE ffile); +static inline int READ_FONT_DATA(FONTFILE ffile, void *buf, int size, int nelem); +static inline FONTFILE OPEN_FONT(char *filename, bool &success); +static inline void CLOSE_FONT(FONTFILE ffile); + #define BITS_TO_BYTES(_c) (((_c) + 7) >> 3) #define BITS_TO_SHORTS(_c) (((_c) + 15) >> 4) diff --git a/2dlib/surface.cpp b/2dlib/surface.cpp index 04856683..2ad6c17b 100644 --- a/2dlib/surface.cpp +++ b/2dlib/surface.cpp @@ -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); diff --git a/Descent3/AIGoal.cpp b/Descent3/AIGoal.cpp index 60c41c80..a4bbcd95 100644 --- a/Descent3/AIGoal.cpp +++ b/Descent3/AIGoal.cpp @@ -479,6 +479,9 @@ extern int AI_unique_goal_id; +static void GoalInitWanderAround(object *obj, goal *goal_ptr); +static int GoalAllocSlot(object *obj, int level, float influence); + #define BASH_TO_ANIM_SCALER 10.0f #define MAX_BASH_TO_FLINCH_TIME 2.5f diff --git a/Descent3/AImain.cpp b/Descent3/AImain.cpp index 09b16ecd..686725d1 100644 --- a/Descent3/AImain.cpp +++ b/Descent3/AImain.cpp @@ -1563,7 +1563,40 @@ bool AI_debug_robot_do = false; int AI_debug_robot_index = -2; #endif -bool compute_dodge_dir(/* vector *dodge_dir, */ object *obj, object *dodge_obj); +static bool compute_dodge_dir(/* vector *dodge_dir, */ object *obj, object *dodge_obj); +static float AIDetermineObjVisLevel(object *obj, object *target); +static bool move_relative_object_vec(object *obj, vector *vec, object *target, float circle_dist, float scalar, + bool f_toward, vector *mdir, bool *f_moved); +static void move_away_from_position(object *obj, vector *pos /*, bool random_evade*/, float scale, vector *mdir, + bool *f_moved); +static bool goal_do_dodge(object *obj, int goal_index); +static bool goal_do_avoid_walls(object *obj, vector *mdir); +static bool MeleeHitOk(object *obj); +static bool AiMelee(object *obj); +static void do_ranged_attack(object *obj); +static bool AIDetermineAimPoint(object *robot, object *target, vector *aim_pt, float weapon_speed = 0.0f); +static vector *AIDetermineFovVec(object *obj, vector *fov); +static void AISeeTarget(object *obj, bool f_see); +static void ai_do_animation(object *obj, float anim_time); +static void ObjSetAIInfo(object *objp); +static void AICheckTargetVis(object *obj); +static void ai_update_registers(object *obj); +static bool AiGoalAvoid(vector *adir, object *obj, object *a_obj, float dist); +static void AIGoalDoRepulse(object *obj, float dist, vector *dir, goal *goal, vector *mdir); +static void AIGoalDoCohesion(object *obj, object *g_obj, float dist, goal *goal, vector *mdir); +static void AIGoalDoAlignment(object *obj, float dist, vector *fvec, goal *goal, vector *mdir); +static void AIDoTrackFrame(object *obj); +static void AIDoOrientVelocity(object *obj); +static void AIDoOrientDefault(object *obj); +static void AIDoOrient(object *obj, int g_index); +static void AIDetermineSpeed(object *obj, int flags, float *speed); +static void ai_move(object *obj); +static void ai_fire(object *obj); +static int AIGetTeam(object *obj); +static void AITargetCheck(object *obj, object *target, object **best_obj, float *best_dot, float *best_dist); +static void AIDetermineTarget(object *obj); +static void AIDoFreud(object *obj); +static void AIDoMemFrame(object *obj); // chrishack -- AI problems @@ -1598,14 +1631,14 @@ int AI_NumHostileAlert = 0; int Buddy_handle[MAX_PLAYERS]; -int AI_FriendNumNear = 0; // Number of friends found -object *AI_FriendObj[2]; // Friend objects -float AI_FriendDist[2]; // Distances to the friends -vector AI_FriendDir[2]; // Direction to the friends -int AI_EnemyNumNear = 0; // Number of enemies found -object *AI_EnemyObj[2]; // Enemy objects -float AI_EnemyDist[2]; // Distances to the enemies -vector AI_EnemyDir[2]; // Direction to the enemies +static int AI_FriendNumNear = 0; // Number of friends found +static object *AI_FriendObj[2]; // Friend objects +static float AI_FriendDist[2]; // Distances to the friends +static vector AI_FriendDir[2]; // Direction to the friends +static int AI_EnemyNumNear = 0; // Number of enemies found +static object *AI_EnemyObj[2]; // Enemy objects +static float AI_EnemyDist[2]; // Distances to the enemies +static vector AI_EnemyDir[2]; // Direction to the enemies #define AIVIS_NONE 0.0f #define AIVIS_BARELY 1.0f @@ -1648,7 +1681,7 @@ float AIDetermineObjVisLevel(object *obj, object *target) { return vis_level; } -inline bool ai_target_valid(object *obj) { +static inline bool ai_target_valid(object *obj) { ai_frame *ai_info = obj->ai_info; bool f_valid = false; @@ -1917,8 +1950,6 @@ bool goal_do_dodge(object *obj, int goal_index) { return false; } -extern uint check_point_to_face(vector *colp, vector *face_normal, int nv, vector **vertex_ptr_list); - #define MAX_WALL_AVOID_INFLUENCE 0.9f #define MAX_TERRAIN_AVOID_INFLUENCE 0.9f #define GB_WALL_PULSE_INTERVAL 7 @@ -2224,6 +2255,7 @@ bool AITurnTowardsMatrix(object *obj, float turn_rate, matrix *g_orient) { return false; } +// 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; @@ -2734,7 +2766,7 @@ new_anim_label: } } -inline void ApplyConstantForce(object *objp, vector *new_pos, vector *force, float delta_time) { +static inline void ApplyConstantForce(object *objp, vector *new_pos, vector *force, float delta_time) { const vector velocity = objp->mtype.phys_info.velocity; const float drag = objp->mtype.phys_info.drag; const float mass = objp->mtype.phys_info.mass; @@ -2744,7 +2776,7 @@ inline void ApplyConstantForce(object *objp, vector *new_pos, vector *force, flo (mass / drag) * (velocity - (*force / drag)) * (1 - exp(-(drag / mass) * delta_time)); } -bool AIDetermineAimPoint(object *robot, object *target, vector *aim_pt, float weapon_speed = 0.0f) { +bool AIDetermineAimPoint(object *robot, object *target, vector *aim_pt, float weapon_speed) { if (DIFF_LEVEL == DIFFICULTY_TRAINEE && ((robot->ai_info->flags & AIF_TEAM_MASK) != AIF_TEAM_REBEL)) { *aim_pt = target->pos; return true; @@ -3470,6 +3502,7 @@ done: #define FRR_MAX_TRIES 15 +// 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, @@ -4076,8 +4109,10 @@ bool AIStatusCircleFrame(object *obj, object *g_obj, float dist, float c_dist, i } } +// MTS: Unused? bool ai_target_need_path(object *obj) { return true; } +// MTS: Unused? bool ai_move_need_path(object *obj, vector *pos, int roomnum) { if (obj->roomnum == roomnum) { return false; @@ -4146,7 +4181,7 @@ bool AiGoalAvoid(vector *adir, object *obj, object *a_obj, float dist) { return true; } -inline bool IsTargetLocal(object *obj, object *target) { +static inline bool IsTargetLocal(object *obj, object *target) { int target_room = target->roomnum; int cur_room = obj->roomnum; int i; @@ -4181,6 +4216,7 @@ 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 float AIGoalIsEnabledForDist(goal *goal, float dist) { return true; // chrishack -- test code -- temp } @@ -4332,6 +4368,7 @@ void AIDoTrackFrame(object *obj) { } } +// MTS: unused? float AIDetermineGoalInfluence(object *obj, goal *goal) { float influence = goal->influence; int g_index = goal - obj->ai_info->goals; @@ -4405,12 +4442,6 @@ void AIDoOrientDefault(object *obj) { } } -extern bool AIPathAtEnd(ai_path_info *aip); -extern bool AIPathAtStart(ai_path_info *aip); -extern bool AIPathGetNextNodePos(ai_path_info *aip, vector *pos, int *room = NULL); -extern bool AIPathGetPrevNodePos(ai_path_info *aip, vector *pos, int *room = NULL); -extern bool AIPathGetCurrentNodePos(ai_path_info *aip, vector *pos, int *room = NULL); - void AIDoOrient(object *obj, int g_index) { ai_frame *ai_info = obj->ai_info; goal *goal_ptr = &ai_info->goals[g_index]; @@ -5512,7 +5543,7 @@ void ai_fire(object *obj) { #define PERCENT_QUIRK_PER_SEC .1 #define PERCENT_TAUNT_PER_SEC .1 -inline void do_awareness_based_anim_stuff(object *obj) { +static inline void do_awareness_based_anim_stuff(object *obj) { int next_anim; ai_frame *ai_info = obj->ai_info; @@ -5557,7 +5588,7 @@ inline void do_awareness_based_anim_stuff(object *obj) { } } -inline void ai_decrease_awareness(object *obj) { +static inline void ai_decrease_awareness(object *obj) { ai_frame *ai_info = obj->ai_info; if (ai_info->awareness == AWARE_NONE && !(ai_info->flags & AIF_PERSISTANT)) { @@ -5583,7 +5614,7 @@ inline void ai_decrease_awareness(object *obj) { // mprintf((0, "Awareness %f", ai_info->awareness)); } -inline bool ai_do_script_stuff(object *obj) { +static inline bool ai_do_script_stuff(object *obj) { tOSIRISEventInfo ei; Osiris_CallEvent(obj, EVT_AI_FRAME, &ei); //@$-D3XExecScript(obj, EVT_AI_FRAME, NULL, REF_OBJTYPE, NULL); @@ -5591,7 +5622,7 @@ inline bool ai_do_script_stuff(object *obj) { return true; } -inline void ai_walker_stuff(object *obj) { +static inline void ai_walker_stuff(object *obj) { ai_frame *ai_info = obj->ai_info; // Do standing->walking and walking->standing stuff diff --git a/Descent3/BOA.cpp b/Descent3/BOA.cpp index e3671d72..45cb74da 100644 --- a/Descent3/BOA.cpp +++ b/Descent3/BOA.cpp @@ -141,33 +141,33 @@ #define BOA_VERSION 25 -const ubyte bbf_lookup[27] = {(0), - (0x01), - (0x02), - (0x04), - (0x08), - (0x10), - (0x20), - (0x01 | 0x02), - (0x01 | 0x04), - (0x01 | 0x10), - (0x01 | 0x20), - (0x02 | 0x04), - (0x02 | 0x08), - (0x02 | 0x20), - (0x04 | 0x08), - (0x04 | 0x10), - (0x08 | 0x10), - (0x08 | 0x20), - (0x10 | 0x20), - (0x01 | 0x02 | 0x04), - (0x01 | 0x02 | 0x20), - (0x01 | 0x04 | 0x10), - (0x01 | 0x10 | 0x20), - (0x08 | 0x02 | 0x04), - (0x08 | 0x02 | 0x20), - (0x08 | 0x04 | 0x10), - (0x08 | 0x10 | 0x20)}; +static const ubyte bbf_lookup[27] = {(0), + (0x01), + (0x02), + (0x04), + (0x08), + (0x10), + (0x20), + (0x01 | 0x02), + (0x01 | 0x04), + (0x01 | 0x10), + (0x01 | 0x20), + (0x02 | 0x04), + (0x02 | 0x08), + (0x02 | 0x20), + (0x04 | 0x08), + (0x04 | 0x10), + (0x08 | 0x10), + (0x08 | 0x20), + (0x10 | 0x20), + (0x01 | 0x02 | 0x04), + (0x01 | 0x02 | 0x20), + (0x01 | 0x04 | 0x10), + (0x01 | 0x10 | 0x20), + (0x08 | 0x02 | 0x04), + (0x08 | 0x02 | 0x20), + (0x08 | 0x04 | 0x10), + (0x08 | 0x10 | 0x20)}; unsigned short BOA_Array[MAX_ROOMS + MAX_BOA_TERRAIN_REGIONS][MAX_ROOMS + MAX_BOA_TERRAIN_REGIONS]; float BOA_cost_array[MAX_ROOMS + MAX_BOA_TERRAIN_REGIONS][MAX_PATH_PORTALS]; @@ -177,7 +177,7 @@ bool BOA_vis_valid = 0; // Is the vis table up to date and valid to use? int BOA_AABB_checksum = 0; int BOA_AABB_ROOM_checksum[MAX_ROOMS + MAX_BOA_TERRAIN_REGIONS]; -bool BOA_f_making_boa = false; +static bool BOA_f_making_boa = false; int BOA_num_mines = 0; int BOA_num_terrain_regions = 0; @@ -185,7 +185,25 @@ int BOA_num_terrain_regions = 0; int BOA_num_connect[MAX_BOA_TERRAIN_REGIONS]; connect_data BOA_connect[MAX_BOA_TERRAIN_REGIONS][MAX_PATH_PORTALS]; -void ComputeBOAVisFaceUpperLeft(room *rp, face *fp, vector *upper_left, float *xdiff, float *ydiff, vector *center); +static void add_mine_room(int room, int mine, char *checked); +static void compute_mine_info(); +static void add_terrain_cell(int cell, int t_region, char *checked); +static void compute_terrain_region_info(); +static void compute_sound_dist_info(); +static void clear_BOA(); +static void compute_costs(); +static void update_path_info(q_item *node_list[MAX_ROOMS], int start, int end); +static void FindPath(int i, int j); +static void compute_next_segs(); +static void compute_blockage_info(); +static void ComputeBOAVisFaceUpperLeft(room *rp, face *fp, vector *upper_left, float *xdiff, float *ydiff, + vector *center); +static int BOAGetRoomChecksum(int i); +static bool IsPathPointValid(int room, vector *pos); +static void ValidateRoomPathPoint(int room, char *message, int len); +static void verify_connections(); +static void find_small_portals(); +static void compute_robot_path_info(); bool BOA_PassablePortal(int room, int portal_index, bool f_for_sound, bool f_making_robot_path_invalid_list) { if (room == -1) { @@ -1483,8 +1501,6 @@ void ComputeBOAVisFaceUpperLeft(room *rp, face *fp, vector *upper_left, float *x *center = avg_vert; } -extern uint check_point_to_face(vector *colp, vector *face_normal, int nv, vector **vertex_ptr_list); - #if (defined(EDITOR) || defined(NEWEDITOR)) #ifdef NEWEDITOR @@ -2082,7 +2098,7 @@ void MakeBOA(void) { mprintf((0, "BOA is done\n")); } -int Current_sort_room; +static int Current_sort_room; static int face_sort_func1(const short *a, const short *b) { if (Rooms[Current_sort_room].faces[*a].min_xyz.y > Rooms[Current_sort_room].faces[*b].min_xyz.y) diff --git a/Descent3/Briefing.cpp b/Descent3/Briefing.cpp index d16f413e..5ee855b5 100644 --- a/Descent3/Briefing.cpp +++ b/Descent3/Briefing.cpp @@ -229,21 +229,39 @@ typedef struct { #define TAG_PLEVELNUM 1 #define TAG_NLEVELNUM 2 -tBriefingTag HotTags[] = { +static tBriefingTag HotTags[] = { {"#LEVELNUM#", TAG_LEVELNUM, -1}, {"#PLEVELNUM#", TAG_PLEVELNUM, -1}, {"#NLEVELNUM#", TAG_NLEVELNUM, -1}, }; -int NumHotTags = sizeof(HotTags) / sizeof(tBriefingTag); +static const int NumHotTags = sizeof(HotTags) / sizeof(tBriefingTag); -int osb_xoff = 0, osb_yoff = 0; -int current_screen = -1; -tTelComInfo *pb_tcs = NULL; -bool gottitle = false; -bool pbfirst_call; -char pbtitle[100]; -bool ok_to_parse_screen = false; -int skipped_screens; +static int osb_xoff = 0, osb_yoff = 0; +static int current_screen = -1; +static tTelComInfo *pb_tcs = NULL; +static bool gottitle = false; +static bool pbfirst_call; +static char pbtitle[100]; +static bool ok_to_parse_screen = false; +static int skipped_screens; + +static bool IsMissionMaskOK(uint set, uint unset); +static void ReplaceHotTag(char *string, int tag); +static bool ParseForHotTags(char *src, char **dest); +static bool PlayBriefing(tTelComInfo *tcs); +static void PBAddTextEffect(LPTCTEXTDESC desc, char *text, char *description, int id); +static void PBAddBmpEffect(LPTCBMPDESC desc, char *description); +static void PBAddMovieEffect(LPTCMOVIEDESC desc, char *description); +static void PBAddBkgEffect(LPTCBKGDESC desc, char *description); +static void PBAddPolyEffect(LPTCPOLYDESC desc, char *description); +static void PBAddButtonEffect(LPTCBUTTONDESC desc, char *description, int id); +static void PBStartScreen(int screen_num, char *description, char *layout, uint mask_set, uint mask_unset); +static void PBEndScreen(); +static bool PBLoopCallback(); +static void PBSetTitle(char *title); +static void PBSetStatic(float amount); +static void PBSetGlitch(float amount); +static void PBAddVoice(char *filename, int flags, char *description); bool IsMissionMaskOK(uint set, uint unset) { uint Gamemissionmask = Current_mission.game_state_flags; diff --git a/Descent3/BriefingParse.cpp b/Descent3/BriefingParse.cpp index 2752102e..27a00461 100644 --- a/Descent3/BriefingParse.cpp +++ b/Descent3/BriefingParse.cpp @@ -142,8 +142,8 @@ void CBriefParse::SetCallbacks(tBriefParseCallbacks *cb) { #define B_QUIT 4 // exit TelCom // Keywords. These must match the keyword IDs above -const char *keywords[] = {"screen", "button", "text", "endtext", "bitmap", "endscreen", "movie", - "poly", "title", "sound", "static", "glitch", "voice"}; +static const char *const keywords[] = {"screen", "button", "text", "endtext", "bitmap", "endscreen", "movie", + "poly", "title", "sound", "static", "glitch", "voice"}; #define tfxNONE 0 #define tfxFLASH 1 @@ -157,10 +157,10 @@ const char *keywords[] = {"screen", "button", "text", "endtext", "bitmap", "end #define fntSMBRIEF 0 #define fntLGBRIEF 1 -const char *FontNames[] = {"sm_brief", "lg_brief", NULL}; +static const char *const FontNames[] = {"sm_brief", "lg_brief", NULL}; -const char *TextEffectstr[] = {"None", "flash", "scroll_l2r", "scroll_r2l", "scroll_t2b", - "scroll_b2t", "fade_in_and_out", "fade_in", "fade_out", NULL}; +static const char *const TextEffectstr[] = {"None", "flash", "scroll_l2r", "scroll_r2l", "scroll_t2b", + "scroll_b2t", "fade_in_and_out", "fade_in", "fade_out", NULL}; #define bfxNONE 0 #define bfxFADE_IN 1 #define bfxFADE_OUT 2 @@ -173,8 +173,9 @@ const char *TextEffectstr[] = {"None", "flash", "scroll_l2r", "s #define bfxSTRETCH_IN 9 #define bfxSTRETCH_OUT 10 -const char *BitmapEffectstr[] = {"None", "Fade_in", "Fade_out", "Blur_in", "Blur_out", "Scan_in", - "Scan_out", "Invert_in", "Invert_out", "Stretch_in", "Stretch_out", NULL}; +static const char *const BitmapEffectstr[] = {"None", "Fade_in", "Fade_out", "Blur_in", + "Blur_out", "Scan_in", "Scan_out", "Invert_in", + "Invert_out", "Stretch_in", "Stretch_out", NULL}; //////////////////////////////////////////// // These are the types of on screen buttons @@ -185,7 +186,7 @@ const char *BitmapEffectstr[] = {"None", "Fade_in", "Fade_out", "Blur_in #define osbQUIT 4 #define osbJUMP_PAGE 5 -const char *OnScreenButtonTypes[] = {"Down", "Up", "Next", "Prev", "Quit", "Jump", NULL}; +static const char *const OnScreenButtonTypes[] = {"Down", "Up", "Next", "Prev", "Quit", "Jump", NULL}; ///////////////////////////////////////////// // These are the different ways an onscreen button will respond to mouse clicks @@ -193,7 +194,7 @@ const char *OnScreenButtonTypes[] = {"Down", "Up", "Next", "Prev", "Quit", "Jump #define oscCLICK_DOWN 1 #define oscCLICK_UP 2 -const char *OnScreenButtonClickTypes[] = {"HoldDown", "ClickDown", "ClickUp", NULL}; +static const char *const OnScreenButtonClickTypes[] = {"HoldDown", "ClickDown", "ClickUp", NULL}; #define PARSE_INT(i) \ do { \ @@ -226,7 +227,7 @@ const char *OnScreenButtonClickTypes[] = {"HoldDown", "ClickDown", "ClickUp", NU goto done_parsing; \ } while (0) -int ReadFullLine(char **data, CFILE *ifile) { +static int ReadFullLine(char **data, CFILE *ifile) { int counter, readin; char buffer[512]; bool done; @@ -336,7 +337,7 @@ int CBriefParse::ParseBriefing(const char *filename) { // Read & parse lines int bytes_read; - const char *p; + const char *p; linebuf = NULL; diff --git a/Descent3/Controls.cpp b/Descent3/Controls.cpp index 362ad871..6b381fca 100644 --- a/Descent3/Controls.cpp +++ b/Descent3/Controls.cpp @@ -433,7 +433,6 @@ #include #include - float Key_ramp_speed = 0.5f; #define CONTROL_POLL_RATE (1.0f / 25.0f) @@ -468,18 +467,18 @@ static tSpace Key_ramp; // PROTOTYPES -void DoMovement(game_controls *controls); -void DoKeyboardMovement(game_controls *controls); -void DoControllerMovement(game_controls *controls); -void DoWeapons(game_controls *controls); -void DoKeyboardWeapons(game_controls *controls); -void DoControllerWeapons(game_controls *controls); -void DoMisc(game_controls *contols); -void DoKeyboardMisc(game_controls *controls); -void DoControllerMisc(game_controls *controls); +static void DoKeyboardMovement(game_controls *controls); +static void DoControllerMovement(game_controls *controls); +static void DoWeapons(game_controls *controls); +static void DoKeyboardWeapons(game_controls *controls); +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! void DoCommands(); -void ToggleHeadlightControlState(); +static void ToggleHeadlightControlState(); // LIST OF NEEDS ct_function Controller_needs[NUM_CONTROLLER_FUNCTIONS] = { @@ -558,7 +557,7 @@ ct_function Controller_needs[NUM_CONTROLLER_FUNCTIONS] = { {ctfAUDIOTAUNT4_BTN, ctDownCount, ctButton, ctButton, 0, 0, 0, 0}}; // ramping macros -inline float ramp_control_value(float val, float limit, float &ramp_state, float &old_ramp_delta) { +static inline float ramp_control_value(float val, float limit, float &ramp_state, float &old_ramp_delta) { float sign = val / fabs(val), old_sign = old_ramp_delta / fabs(old_ramp_delta); if (sign != old_sign) ramp_state = -ramp_state; @@ -620,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")); } @@ -1131,9 +1130,9 @@ void DoMisc(game_controls *controls) { } // use the currently selected inventory item -bool UseInventoryItem(); +extern bool UseInventoryItem(); // use the currently selected countermeasure -bool UseCountermeasure(); +extern bool UseCountermeasure(); // Inventory/CounterMeasure states void DoKeyboardMisc(game_controls *controls) { diff --git a/Descent3/CtlCfgElem.cpp b/Descent3/CtlCfgElem.cpp index ec7a63e2..ac536e95 100644 --- a/Descent3/CtlCfgElem.cpp +++ b/Descent3/CtlCfgElem.cpp @@ -128,269 +128,269 @@ #include "joystick.h" // all controller binding texts -char Ctltext_KeyBindings[][16] = {"", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "bspc\0\0\0\0\0\0", - "tab\0\0\0\0\0\0", - "q", - "w", - "e", - "r", - "t", - "y", - "u", - "i", - "o", - "p", - "[", - "]", - "enter\0\0\0\0\0", - "lctrl\0\0\0\0\0", - "a", - "s", - "d", - "f", - "g", - "h", - "j", - "k", - "l", - ";", - "'", - "`", - "lshft\0\0\0\0\0", - "\\", - "z", - "x", - "c", - "v", - "b", - "n", - "m", - ",", - ".", - "/", - "rshft\0\0\0\0\0", - "pad*\0\0\0\0\0", - "lalt\0\0\0\0\0", - "spc\0\0\0\0\0", - "caps\0\0\0\0\0", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "num\0\0\0\0\0", - "sclk\0\0\0\0\0", - "pad7\0\0\0\0\0", - "pad8\0\0\0\0\0", - "pad9\0\0\0\0\0", - "pad-\0\0\0\0\0", - "pad4\0\0\0\0\0", - "pad5\0\0\0\0\0", - "pad6\0\0\0\0\0", - "pad+\0\0\0\0\0", - "pad1\0\0\0\0\0", - "pad2\0\0\0\0\0", - "pad3\0\0\0\0\0", - "pad0\0\0\0\0\0", - "pad.\0\0\0\0\0", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "pad�\0\0\0\0\0\0", - "rctrl\0\0\0\0\0", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "pad/\0\0\0\0\0\0", - "", - "", - "ralt\0\0\0\0\0\0", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "home\0\0\0\0\0\0", - "up\0\0\0\0\0\0\0", - "pgup\0\0\0\0\0\0", - "", - "left\0\0\0\0\0\0", - "", - "right\0\0\0\0\0\0", - "", - "end\0\0\0\0\0\0\0", - "down\0\0\0\0\0\0", - "pgdn\0\0\0\0\0\0", - "ins\0\0\0\0\0\0", - "del\0\0\0\0\0\0", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - ""}; +static char Ctltext_KeyBindings[][16] = {"", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "bspc\0\0\0\0\0\0", + "tab\0\0\0\0\0\0", + "q", + "w", + "e", + "r", + "t", + "y", + "u", + "i", + "o", + "p", + "[", + "]", + "enter\0\0\0\0\0", + "lctrl\0\0\0\0\0", + "a", + "s", + "d", + "f", + "g", + "h", + "j", + "k", + "l", + ";", + "'", + "`", + "lshft\0\0\0\0\0", + "\\", + "z", + "x", + "c", + "v", + "b", + "n", + "m", + ",", + ".", + "/", + "rshft\0\0\0\0\0", + "pad*\0\0\0\0\0", + "lalt\0\0\0\0\0", + "spc\0\0\0\0\0", + "caps\0\0\0\0\0", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "num\0\0\0\0\0", + "sclk\0\0\0\0\0", + "pad7\0\0\0\0\0", + "pad8\0\0\0\0\0", + "pad9\0\0\0\0\0", + "pad-\0\0\0\0\0", + "pad4\0\0\0\0\0", + "pad5\0\0\0\0\0", + "pad6\0\0\0\0\0", + "pad+\0\0\0\0\0", + "pad1\0\0\0\0\0", + "pad2\0\0\0\0\0", + "pad3\0\0\0\0\0", + "pad0\0\0\0\0\0", + "pad.\0\0\0\0\0", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "pad�\0\0\0\0\0\0", + "rctrl\0\0\0\0\0", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "pad/\0\0\0\0\0\0", + "", + "", + "ralt\0\0\0\0\0\0", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "home\0\0\0\0\0\0", + "up\0\0\0\0\0\0\0", + "pgup\0\0\0\0\0\0", + "", + "left\0\0\0\0\0\0", + "", + "right\0\0\0\0\0\0", + "", + "end\0\0\0\0\0\0\0", + "down\0\0\0\0\0\0", + "pgdn\0\0\0\0\0\0", + "ins\0\0\0\0\0\0", + "del\0\0\0\0\0\0", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + ""}; + static short key_binding_indices[] = { - KEY_BACKSP, KEY_TAB, KEY_ENTER, KEY_LCTRL, KEY_LSHIFT, KEY_RSHIFT, KEY_PADMULTIPLY, KEY_LALT, - KEY_SPACEBAR, KEY_CAPSLOCK, 0x45, KEY_SCROLLOCK, KEY_PAD7, KEY_PAD8, KEY_PAD9, KEY_PADMINUS, - KEY_PAD4, KEY_PAD5, KEY_PAD6, KEY_PADPLUS, KEY_PAD1, KEY_PAD2, KEY_PAD3, KEY_PAD0, - KEY_PADPERIOD, KEY_PADENTER, KEY_RCTRL, KEY_PADDIVIDE, KEY_RALT, KEY_HOME, KEY_UP, KEY_PAGEUP, - KEY_LEFT, KEY_RIGHT, KEY_END, KEY_DOWN, KEY_PAGEDOWN, KEY_INSERT, KEY_DELETE, - 0xff}; + KEY_BACKSP, KEY_TAB, KEY_ENTER, KEY_LCTRL, KEY_LSHIFT, KEY_RSHIFT, KEY_PADMULTIPLY, KEY_LALT, + KEY_SPACEBAR, KEY_CAPSLOCK, 0x45, KEY_SCROLLOCK, KEY_PAD7, KEY_PAD8, KEY_PAD9, KEY_PADMINUS, + KEY_PAD4, KEY_PAD5, KEY_PAD6, KEY_PADPLUS, KEY_PAD1, KEY_PAD2, KEY_PAD3, KEY_PAD0, + KEY_PADPERIOD, KEY_PADENTER, KEY_RCTRL, KEY_PADDIVIDE, KEY_RALT, KEY_HOME, KEY_UP, KEY_PAGEUP, + KEY_LEFT, KEY_RIGHT, KEY_END, KEY_DOWN, KEY_PAGEDOWN, KEY_INSERT, KEY_DELETE, 0xff}; #define NUM_KEYBINDSTRINGS (sizeof(Ctltext_KeyBindings) / sizeof(char *)) @@ -536,7 +536,7 @@ UIBitmapItem *cfg_element::m_xbtn_bmp_lit = NULL; UIBitmapItem *cfg_element::m_xbtn_bmp = NULL; short cfg_element::m_count = 0; -const char *cfg_binding_text(ct_type ctype, ubyte binding); +// MTS: unused? bool key_cfg_element(ubyte *element, ubyte *flags); ////////////////////////////////////////////////////////////////////////////// diff --git a/Descent3/CtlCfgElem.h b/Descent3/CtlCfgElem.h index d21569ef..57a9bc12 100644 --- a/Descent3/CtlCfgElem.h +++ b/Descent3/CtlCfgElem.h @@ -119,7 +119,7 @@ typedef struct tCfgDataParts { ubyte bind_0, bind_1, ctrl_0, ctrl_1; } tCfgDataParts; -inline void parse_config_data(tCfgDataParts *parts, ct_type type0, ct_type type1, ct_config_data cfgdata) { +static inline void parse_config_data(tCfgDataParts *parts, ct_type type0, ct_type type1, ct_config_data cfgdata) { switch (type0) { case ctKey: parts->bind_0 = CONTROLLER_KEY1_VALUE(CONTROLLER_VALUE(cfgdata)); @@ -160,9 +160,11 @@ inline void parse_config_data(tCfgDataParts *parts, ct_type type0, ct_type type1 parts->ctrl_1 = CONTROLLER_CTL2_INFO(CONTROLLER_INFO(cfgdata)); } -inline ct_config_data unify_config_data(tCfgDataParts *parts) { +static inline ct_config_data unify_config_data(tCfgDataParts *parts) { return MAKE_CONFIG_DATA(CONTROLLER_CTL_INFO(parts->ctrl_0, parts->ctrl_1), CONTROLLER_CTL_VALUE(parts->bind_0, parts->bind_1)); } +extern const char *cfg_binding_text(ct_type ctype, ubyte ctrl, ubyte binding); + #endif diff --git a/Descent3/Game2DLL.cpp b/Descent3/Game2DLL.cpp index d1aa0b82..060490a5 100644 --- a/Descent3/Game2DLL.cpp +++ b/Descent3/Game2DLL.cpp @@ -72,7 +72,7 @@ extern int Camera_view_mode[NUM_CAMERA_VIEWS]; // Purpose: // This function initializes a Module Init Struct with all the needed data to get sent // to the module during initialization. -void Osiris_CreateModuleInitStruct(tOSIRISModuleInit *mi); +extern void Osiris_CreateModuleInitStruct(tOSIRISModuleInit *mi); module GameDLLHandle = {NULL}; extern ddgr_color Player_colors[]; typedef struct { diff --git a/Descent3/GameLoop.cpp b/Descent3/GameLoop.cpp index b3aa8614..5e800c29 100644 --- a/Descent3/GameLoop.cpp +++ b/Descent3/GameLoop.cpp @@ -877,6 +877,7 @@ #include "gamefont.h" #include "renderobject.h" #include "vibeinterface.h" +#include "buddymenu.h" #ifdef EDITOR #include "editor\d3edit.h" @@ -1178,8 +1179,6 @@ void ProcessButtons() { #define GBC_RTYPE 39 // Use Gaurdian Powerup #define GBC_ANTI_VIRUS 40 // Use Anti-virus Powerup #define GBC_RETURN_TO_SHIP 43 // Return to ship -extern int Buddy_handle[MAX_PLAYERS]; -extern void MultiSendGuidebotMenuSelection(gb_com *); // Handles guidebot shortcut keys void ProcessGuidebotKeys(int key) { if (!(key & KEY_SHIFTED)) diff --git a/Descent3/Mission.cpp b/Descent3/Mission.cpp index 39e50b6f..3b6cdb92 100644 --- a/Descent3/Mission.cpp +++ b/Descent3/Mission.cpp @@ -671,6 +671,7 @@ #include "BOA.h" #include "terrain.h" #include "multi.h" +#include "hud.h" // --------------------------------------------------------------------------- // Data // --------------------------------------------------------------------------- @@ -699,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); @@ -1276,7 +1277,7 @@ void LoadLevelText(const char *level_filename) { DestroyStringTable(goal_strings, n_strings); } } -extern bool Hud_show_controls; + /* loads a level and sets it as current level in mission */ bool LoadMissionLevel(int level) { @@ -1315,8 +1316,6 @@ bool LoadMissionLevel(int level) { #define LOADBAR_W (260 * (float)Max_window_w / (float)FIXED_SCREEN_WIDTH) #define LOADBAR_H (22 * (float)Max_window_h / (float)FIXED_SCREEN_HEIGHT) #define N_LOAD_MSGS 12 -extern int need_to_page_in; -extern int paged_in_count; bool started_page = 0; /* $$TABLE_GAMEFILE "tunnelload.ogf" diff --git a/Descent3/ObjScript.h b/Descent3/ObjScript.h index d8c4e842..ccc4fa5c 100644 --- a/Descent3/ObjScript.h +++ b/Descent3/ObjScript.h @@ -105,22 +105,22 @@ struct object; struct trigger; // assigns scripts for a level. -void AssignScriptsForLevel(); +extern void AssignScriptsForLevel(); // free scripts for a level -void FreeScriptsForLevel(); +extern void FreeScriptsForLevel(); // allocates and initializes the scripts for an object. -void InitObjectScripts(object *objp, bool do_evt_created = true); +extern void InitObjectScripts(object *objp, bool do_evt_created = true); // frees all scripts for an object. -void FreeObjectScripts(object *objp, bool level_end = false); +extern void FreeObjectScripts(object *objp, bool level_end = false); // allocates and initializes the scripts for a trigger. -void InitTriggerScript(trigger *tp); +extern void InitTriggerScript(trigger *tp); // frees all scripts for an trigger. -void FreeTriggerScript(trigger *tp, bool level_end = false); +extern void FreeTriggerScript(trigger *tp, bool level_end = false); //@@// called to reinitialize an object's 'state' given the current script element of object. //@@// refuses to call EVT_CREATED too. this just restores the state of a script given the current script_info diff --git a/Descent3/OsirisLoadandBind.cpp b/Descent3/OsirisLoadandBind.cpp index 5761fb07..b7a66ecd 100644 --- a/Descent3/OsirisLoadandBind.cpp +++ b/Descent3/OsirisLoadandBind.cpp @@ -490,7 +490,7 @@ typedef struct { #endif } tOSIRISModule; -tOSIRISModule OSIRIS_loaded_modules[MAX_LOADED_MODULES]; +static tOSIRISModule OSIRIS_loaded_modules[MAX_LOADED_MODULES]; tOSIRISModuleInit Osiris_module_init; struct { bool level_loaded; @@ -512,17 +512,17 @@ typedef struct { char *temp_filename; char *real_filename; } tExtractedScriptInfo; -tExtractedScriptInfo OSIRIS_Extracted_scripts[MAX_LOADED_MODULES]; -char *OSIRIS_Extracted_script_dir = NULL; +static tExtractedScriptInfo OSIRIS_Extracted_scripts[MAX_LOADED_MODULES]; +static char *OSIRIS_Extracted_script_dir = NULL; // Osiris_CreateModuleInitStruct // Purpose: // This function initializes a Module Init Struct with all the needed data to get sent // to the module during initialization. -void Osiris_CreateModuleInitStruct(tOSIRISModuleInit *mi); +extern void Osiris_CreateModuleInitStruct(tOSIRISModuleInit *mi); -void Osiris_RestoreOMMS(CFILE *file); -void Osiris_SaveOMMS(CFILE *file); +static void Osiris_RestoreOMMS(CFILE *file); +static void Osiris_SaveOMMS(CFILE *file); // Osiris_CreateGameChecksum // Purpose: @@ -533,21 +533,21 @@ uint Osiris_CreateGameChecksum(void); // Osiris_IsEventEnabled // Purpose: // Returns true if the event is allowed to be called -bool Osiris_IsEventEnabled(int event); +static bool Osiris_IsEventEnabled(int event); -void Cinematic_StartCannedScript(tCannedCinematicInfo *info); +extern void Cinematic_StartCannedScript(tCannedCinematicInfo *info); // Osiris_DumpLoadedObjects // // Debug. Dumps all loaded objects to given file -void Osiris_DumpLoadedObjects(char *file); -void Osiris_ForceUnloadModules(void); +static void Osiris_DumpLoadedObjects(char *file); +static void Osiris_ForceUnloadModules(void); uint Osiris_game_checksum; -ubyte Osiris_event_mask = OEM_OBJECTS | OEM_TRIGGERS | OEM_LEVELS; -bool Osiris_create_events_disabled = false; -bool Osiris_level_script_loaded = false; +static ubyte Osiris_event_mask = OEM_OBJECTS | OEM_TRIGGERS | OEM_LEVELS; +static bool Osiris_create_events_disabled = false; +static bool Osiris_level_script_loaded = false; #define HAVECUSTOMONLY(type) (type == OBJ_CAMERA) #define CANBEASSIGNEDSCRIPT(obj) \ @@ -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; @@ -3380,15 +3380,15 @@ tOMMSNode *Osiris_OMMS_FindHandle(OMMSHANDLE handle, tOMMSHashNode **hash = NULL // the script) Returns -1 if there isn't enough available memory Returns -2 if the unique identifier passed in is // already used, but the requested amount_of_memory is different Returns -3 if the unique identifier passed in is // already used, same size requested -OMMSHANDLE Osiris_OMMS_Malloc(size_t amount_of_memory, uint unique_identifier, char *script_identifier); +static OMMSHANDLE Osiris_OMMS_Malloc(size_t amount_of_memory, uint unique_identifier, char *script_identifier); // Attaches to a block of global OMMS memory. As long as at least one module (or script) is // attached to a module, the memory will not be deleted. (Increments the reference count) // Returns NULL if the memory couldn't be attached (it has been either free'd or never malloced) -void *Osiris_OMMS_Attach(OMMSHANDLE handle); +static void *Osiris_OMMS_Attach(OMMSHANDLE handle); // Detaches a block of global OMMS memory. (Reduces the reference count). -void Osiris_OMMS_Detach(OMMSHANDLE handle); +static void Osiris_OMMS_Detach(OMMSHANDLE handle); // Frees a block of global memory // Only has affect if you are attached to the memory. Memory will _ONLY_ be deleted when the @@ -3400,19 +3400,19 @@ void Osiris_OMMS_Detach(OMMSHANDLE handle); // invalid. // // handle : the value returned by OMMS_Malloc() -void Osiris_OMMS_Free(OMMSHANDLE handle); +static void Osiris_OMMS_Free(OMMSHANDLE handle); // Returns an OMMSHANDLE to a block of global memory allocated by a module/script. Pass // in the unique_identifier and the script_identifier that was passed in the OMMS_Malloc(). // Note: script_identifier is really the filename of the module that called the OMMS_Malloc(). // Returns -1 if the module was never OMMS_Malloc()'d. -OMMSHANDLE Osiris_OMMS_Find(uint unique_identifier, char *script_identifier); +static OMMSHANDLE Osiris_OMMS_Find(uint unique_identifier, char *script_identifier); // Returns information about the OMMS memory given it's handle returned from the OMMS_Find() or // OMMS_Malloc(). Returns 0 if the handle was invalid, 1 if the information has been filled in; // Pass NULL in for those parameters you don't need information about. -char Osiris_OMMS_GetInfo(OMMSHANDLE handle, uint *mem_size, uint *uid, ushort *reference_count, - ubyte *has_free_been_called); +static char Osiris_OMMS_GetInfo(OMMSHANDLE handle, uint *mem_size, uint *uid, ushort *reference_count, + ubyte *has_free_been_called); void Osiris_InitOMMS(void) { OMMS_Current_base_id = 0; diff --git a/Descent3/PilotPicsAPI.cpp b/Descent3/PilotPicsAPI.cpp index 29d3258f..732f90c6 100644 --- a/Descent3/PilotPicsAPI.cpp +++ b/Descent3/PilotPicsAPI.cpp @@ -75,11 +75,11 @@ #define PILOTPIC_DATABASE_HOG "PPics.Hog" #define PILOTPIC_DATABASE_INDEX "PPics.idx" -CFILE *PilotPic_database_index_handle = NULL; -int PilotPic_database_hog_handle = 0; -int PilotPic_find_offset; -char PilotPic_find_name[PILOT_STRING_SIZE]; -bool PilotPic_init = false; +static CFILE *PilotPic_database_index_handle = NULL; +static int PilotPic_database_hog_handle = 0; +static int PilotPic_find_offset; +static char PilotPic_find_name[PILOT_STRING_SIZE]; +static bool PilotPic_init = false; // ----------------------------------------------- // PPic_BuildDatabase @@ -87,13 +87,13 @@ bool PilotPic_init = false; // Builds up some databases for fast access // based off the index file. // ----------------------------------------------- -bool PPic_BuildDatabases(void); +static bool PPic_BuildDatabases(void); // ----------------------------------------------- // PPic_FreeDatabase // Purpose: // Frees up memory associated with the databases // ----------------------------------------------- -void PPic_FreeDatabase(void); +static void PPic_FreeDatabase(void); // ------------------------------------------------- // PPic_JumpToPilot // Purpose: @@ -101,20 +101,20 @@ void PPic_FreeDatabase(void); // the first pilot that matches pilot_name is. -1 // is returned if no match // -------------------------------------------------- -int PPic_JumpToPilot(char *pilot_name); +static int PPic_JumpToPilot(char *pilot_name); // ------------------------------------- // PPic_GetIndexFromID // Purpose: // Returns the file index into the Pilot_id_to_offset // list for the given id, -1 if not found. // ------------------------------------- -int PPic_GetIndexFromID(int id); +static int PPic_GetIndexFromID(int id); // ------------------------------------- // PPic_GetOffsetByID // Purpose: // Returns the file offset of the given pilot id. -1 if not found // ------------------------------------- -int PPic_GetOffsetByID(ushort pilot_id); +static int PPic_GetOffsetByID(ushort pilot_id); //=========================================================================== @@ -745,4 +745,4 @@ int PPic_GetIndexFromID(int id) { max = index_to_check - 1; } return -1; -} \ No newline at end of file +} diff --git a/Descent3/Player.cpp b/Descent3/Player.cpp index 8676927e..238e8462 100644 --- a/Descent3/Player.cpp +++ b/Descent3/Player.cpp @@ -1137,7 +1137,6 @@ player Players[MAX_PLAYERS]; int Player_num; -extern bool IsCheater; int Num_teams = 0; int Team_game = 0; @@ -1146,7 +1145,7 @@ float HudNameTan = -1; team Teams[MAX_TEAMS]; -int Highest_player_start = 0; +static int Highest_player_start = 0; // Only one of these waypoint variable can be active at one time; the other will be -1 int Current_waypoint = 0; // the most recent manually-set waypoint, or -1 @@ -1167,18 +1166,18 @@ float Player_energy_saved_from_last_level = -1.0f; uint Players_typing; // information about which players are typing messages (to display an icon) -float Player_camera_last_sample_time = 0; -float Player_camera_last_follow_time = 0; +static float Player_camera_last_sample_time = 0; +static float Player_camera_last_follow_time = 0; -int Camera_sample_index = 0; -int Camera_follow_index = 0; -vector Camera_sample_vectors[MAX_CAMERA_SAMPLES]; -matrix Camera_sample_matrix[MAX_CAMERA_SAMPLES]; -int Camera_sample_rooms[MAX_CAMERA_SAMPLES]; +static int Camera_sample_index = 0; +static int Camera_follow_index = 0; +static vector Camera_sample_vectors[MAX_CAMERA_SAMPLES]; +static matrix Camera_sample_matrix[MAX_CAMERA_SAMPLES]; +static int Camera_sample_rooms[MAX_CAMERA_SAMPLES]; float Total_time_dead = 0; -void StartPlayerDeath(int slot, float damage, bool melee, int fate); +static void StartPlayerDeath(int slot, float damage, bool melee, int fate); // Sets up the players array void InitPlayers() { diff --git a/Descent3/SmallViews.cpp b/Descent3/SmallViews.cpp index 004bfd66..aa432163 100644 --- a/Descent3/SmallViews.cpp +++ b/Descent3/SmallViews.cpp @@ -178,10 +178,10 @@ typedef struct { } small_view; // The array of small views -small_view Small_views[NUM_SMALL_VIEWS]; +static small_view Small_views[NUM_SMALL_VIEWS]; // Saved copies of small views for while a pop-up is active -small_view Small_views_save[NUM_SMALL_VIEWS]; +static small_view Small_views_save[NUM_SMALL_VIEWS]; // guided missile in small view? if so, then true. bool Guided_missile_smallview = false; diff --git a/Descent3/TelCom.cpp b/Descent3/TelCom.cpp index 605114d0..3039ec75 100644 --- a/Descent3/TelCom.cpp +++ b/Descent3/TelCom.cpp @@ -528,32 +528,33 @@ //------------------------------New TelCom Stuff--------------------------------------- -void TelCom_BltToMem(int dest_bmp, int dx, int dy, int src_bmp, int sx, int sy, int sw, int sh, bool trans = true); -void TelCom_BltToScreen(int dx, int dy, chunked_bitmap *src_bmp); -void TelCom_BltToScreen(int dx, int dy, chunked_bitmap *src_bmp, int sx, int sy, int sw, int sh); -void DrawHotSpotOn(int hotspot); +static void TelCom_BltToMem(int dest_bmp, int dx, int dy, int src_bmp, int sx, int sy, int sw, int sh, + bool trans = true); +static void TelCom_BltToScreen(int dx, int dy, chunked_bitmap *src_bmp); +static void TelCom_BltToScreen(int dx, int dy, chunked_bitmap *src_bmp, int sx, int sy, int sw, int sh); +static void DrawHotSpotOn(int hotspot); //************************************************************************************* // Globals--------------------------------------------------------------------------- -bool TelCom_init = false; // Whether the TelComInit() function was called -bool Telcom_first_render = true; -bool Telcom_exit_to_mainmenu = false; +static bool TelCom_init = false; // Whether the TelComInit() function was called +static bool Telcom_first_render = true; +static bool Telcom_exit_to_mainmenu = false; bool Telcom_called_from_game = false; -int Telcom_mouse_last_effect = -1; // the last efxnum the mouse was over +static int Telcom_mouse_last_effect = -1; // the last efxnum the mouse was over hotspotmap_t hotspotmap; // Holds hotspot data (position) windowmap_t windowmap; // Holds window data (position) tTelComInfo Telcom_system; chunked_bitmap Telcom_bitmap; // background bitmap for telcom system -chunked_bitmap *hotspot_bitmaps; -int LoadTelcomBitmap(const char *filename, chunked_bitmap *bmp); -bool TelComMainMenu(tTelComInfo *tcs); +static chunked_bitmap *hotspot_bitmaps; +static int LoadTelcomBitmap(const char *filename, chunked_bitmap *bmp); +static bool TelComMainMenu(tTelComInfo *tcs); -void TelCom_PrepareCustomKeyEvents(void); -void TelCom_PostProcessCustomKeyEvents(void); +static void TelCom_PrepareCustomKeyEvents(void); +static void TelCom_PostProcessCustomKeyEvents(void); static int Telcom_mouse_x, Telcom_mouse_y; @@ -1361,88 +1362,88 @@ bool TelComMainMenu(tTelComInfo *tcs) { */ /// internal prototypes ************************************* // Creates the screen overlays for the main monitor -void TelcomCreateScreenOverlays(void); +static void TelcomCreateScreenOverlays(void); // Destroys the screen overlays that were used for the main monitor -void TelcomDestroyScreenOverlays(void); +static void TelcomDestroyScreenOverlays(void); // Renders the screen overlays -void TelcomRenderOverlays(void); +static void TelcomRenderOverlays(void); // Renders the screen hilights -void TelcomRenderDrawHiLites(void); +static void TelcomRenderDrawHiLites(void); // Loads the Hilites for a monitor -void TelcomLoadHiLites(const char *filelist[], int monitor, int xoff, int yoff); +static void TelcomLoadHiLites(const char *filelist[], int monitor, int xoff, int yoff); // Frees all the memory allocated for the hilites -void TelcomFreeHiLites(void); +static void TelcomFreeHiLites(void); // Renders the scanline to be drawn -void TelcomRenderScanline(void); +static void TelcomRenderScanline(void); // Creates the scanline -void TelcomCreateScanLine(void); +static void TelcomCreateScanLine(void); // Destroys the scanline -void TelcomDestroyScanLine(void); +static void TelcomDestroyScanLine(void); // Loads the mouse cursor -void TelcomLoadMouseCursor(void); +static void TelcomLoadMouseCursor(void); // Frees the mouse cursor -void TelcomFreeMouseCursor(void); +static void TelcomFreeMouseCursor(void); // Renders the mouse cursor -void TelcomRenderMouse(void); +static void TelcomRenderMouse(void); // draws the telcom background, handles flickering lights, power button etc -void TelcomDrawScreen(bool poweron, bool powerup); +static void TelcomDrawScreen(bool poweron, bool powerup); // used to display the rounded corners of the monitor screens -void TelcomDisplayCorners(void); +static void TelcomDisplayCorners(void); // Frees the bitmaps used for the corners of each monitor -void TelcomFreeCorners(void); +static void TelcomFreeCorners(void); // Allocates the bitmaps for corners of each monitor -void TelcomCreateCorners(void); +static void TelcomCreateCorners(void); // Displays static on the screen -void TelcomDisplayStatic(float amount); +static void TelcomDisplayStatic(float amount); // Frees the static bitmap overlays -void TelcomFreeStaticOverlays(void); +static void TelcomFreeStaticOverlays(void); // Creates the static bitmap overlays -void TelcomCreateStaticOverlays(void); +static void TelcomCreateStaticOverlays(void); // Initializes the bitmaps, etc needed for power up/down effect -void TelcomInitPowerEffect(void); +static void TelcomInitPowerEffect(void); // Frees the bitmaps, etc for power up/down effect -void TelcomFreePowerEffect(void); +static void TelcomFreePowerEffect(void); // Draws a frame of the power up/down effect -void TelcomDoPowerEffect(bool power_down, float frametime); +static void TelcomDoPowerEffect(bool power_down, float frametime); /// global variables **************************************** // Telcom rendering globals static void (*TC_callback)() = NULL; -int TC_current_screen = DUMMY_SCREEN; +static int TC_current_screen = DUMMY_SCREEN; int TC_cursor = -1; // Monitor hilight variables -int TelcomHiLiteCount[MAX_MONITOR]; -int *TelcomHiLites[MAX_MONITOR]; +static int TelcomHiLiteCount[MAX_MONITOR]; +static int *TelcomHiLites[MAX_MONITOR]; struct { int x, y; } TelcomHiLiteOffset[MAX_MONITOR]; // Main monitor scanline info -float scanline_nexttime, scanline_speed; -int scanliney, scanline_handle; -float last_rendertime = 0, last_frametime = 0; +static float scanline_nexttime, scanline_speed; +static int scanliney, scanline_handle; +static float last_rendertime = 0; +float last_frametime = 0; // Monitor corner variables -chunked_bitmap lt_corners[MAX_MONITOR]; -chunked_bitmap rt_corners[MAX_MONITOR]; -chunked_bitmap lb_corners[MAX_MONITOR]; -chunked_bitmap rb_corners[MAX_MONITOR]; -bool has_corners[MAX_MONITOR]; +static chunked_bitmap lt_corners[MAX_MONITOR]; +static chunked_bitmap rt_corners[MAX_MONITOR]; +static chunked_bitmap lb_corners[MAX_MONITOR]; +static chunked_bitmap rb_corners[MAX_MONITOR]; +static bool has_corners[MAX_MONITOR]; // Screen variables -int TCWorking_screen; +static int TCWorking_screen; // Static variables #define STATIC_BMPS 12 -int StaticBmps[STATIC_BMPS]; -bool Telcom_show_static = false; -bool Telcom_static_last_frame = false; -float Telcom_static_setting = 0; +static int StaticBmps[STATIC_BMPS]; +static bool Telcom_show_static = false; +static bool Telcom_static_last_frame = false; +static float Telcom_static_setting = 0; // Glitch variables -bool Telcom_show_glitch = false; -bool Telcom_glitch_screen = false; -float Telcom_glitch_setting = 0; -extern int glitch_dx, glitch_dy; -float myrand(float max); +static bool Telcom_show_glitch = false; +static bool Telcom_glitch_screen = false; +static float Telcom_glitch_setting = 0; +static float myrand(float max); // Powereffect variables -int PowerBmps[2]; +static int PowerBmps[2]; // Initializes the Telcom rendering engine void TelcomRenderInit(void) { @@ -2388,10 +2389,8 @@ tcpe_adjust: *************************************************** */ -extern tceffect TCEffects[MAX_TCEFFECTS]; -extern int Screen_roots[MAX_TELCOM_SCREENS]; // returns the true if there is a next screen (from the current) -bool TelComIsThereANextScreen(void); +static bool TelComIsThereANextScreen(void); /* * Initializes the TelCom Event manager system diff --git a/Descent3/TelCom.h b/Descent3/TelCom.h index 1cf066ce..b53b266d 100644 --- a/Descent3/TelCom.h +++ b/Descent3/TelCom.h @@ -64,6 +64,8 @@ $$TABLE_GAMEFILE "TelComOn.OGF" */ extern chunked_bitmap Telcom_bitmap; +extern int TC_cursor; +extern float last_frametime; /* // Note for above: In TelCom.h there is a section of defines which give names to the above files diff --git a/Descent3/TelComAutoMap.cpp b/Descent3/TelComAutoMap.cpp index b886bf85..092e2f3d 100644 --- a/Descent3/TelComAutoMap.cpp +++ b/Descent3/TelComAutoMap.cpp @@ -179,24 +179,24 @@ #include "hlsoundlib.h" // Variables needed for automap -vector AM_view_pos = {0, 0, 0}; -matrix AM_view_orient; -tTelComInfo *AM_tcs; -int AM_ship_model_handle = -1; +static vector AM_view_pos = {0, 0, 0}; +static matrix AM_view_orient; +static tTelComInfo *AM_tcs; +static int AM_ship_model_handle = -1; ubyte AutomapVisMap[MAX_ROOMS]; -float AM_heading; -float AM_pitch; +static float AM_heading; +static float AM_pitch; int AM_terrain = 0, AM_realign = 0, AM_center_on_player = 0, AM_current_marker; -int Num_AM_rooms; -ushort AM_room_list[MAX_ROOMS]; -ubyte AM_rooms_seen[MAX_ROOMS]; -g3Point *AM_rotated_points = NULL; //[MAX_VERTS_PER_ROOM]; +static int Num_AM_rooms; +static ushort AM_room_list[MAX_ROOMS]; +static ubyte AM_rooms_seen[MAX_ROOMS]; +static g3Point *AM_rotated_points = NULL; //[MAX_VERTS_PER_ROOM]; -void TCAMCallback(void); +static void TCAMCallback(void); static ubyte *Small_faces[MAX_ROOMS]; @@ -568,7 +568,6 @@ void TCAMRenderRoom(int roomnum) { #define AM_ROTATIONAL_SCALAR 90 // Reads the controls for the automap, and adjusts viewpoint accordingly -extern float last_frametime; void TCAMReadControls() { Frametime = last_frametime; int save_mode = Game_interface_mode; diff --git a/Descent3/TelComCargo.cpp b/Descent3/TelComCargo.cpp index b3d4160d..2d0ce7f4 100644 --- a/Descent3/TelComCargo.cpp +++ b/Descent3/TelComCargo.cpp @@ -134,7 +134,7 @@ tLineInfo StatusLines[] = { #define NUM_LINES (sizeof(StatusLines) / sizeof(tLineInfo)) #define TITLE_X 30 + TCminx #define VALUE_X 400 + TCminx -int TCminx, TCmaxx, TCminy, TCmaxy; +static int TCminx, TCmaxx, TCminy, TCmaxy; #define SM_FONT BRIEFING_FONT #define BG_FONT BIG_BRIEFING_FONT diff --git a/Descent3/TelComEffects.cpp b/Descent3/TelComEffects.cpp index 41beda8f..e475afef 100644 --- a/Descent3/TelComEffects.cpp +++ b/Descent3/TelComEffects.cpp @@ -146,7 +146,7 @@ tceffect TCEffects[MAX_TCEFFECTS]; int Screen_roots[MAX_TELCOM_SCREENS]; -bool Screen_has_effect_with_focus[MAX_TELCOM_SCREENS]; +static bool Screen_has_effect_with_focus[MAX_TELCOM_SCREENS]; // Initializes the effects void EfxInit(void) { diff --git a/Descent3/TelComEffects.h b/Descent3/TelComEffects.h index 32c94398..ee163d9f 100644 --- a/Descent3/TelComEffects.h +++ b/Descent3/TelComEffects.h @@ -283,6 +283,9 @@ typedef struct { extern int glitch_dx, glitch_dy; +extern tceffect TCEffects[MAX_TCEFFECTS]; +extern int Screen_roots[MAX_TELCOM_SCREENS]; + ///////////////////////////////////////////////// // Prototypes diff --git a/Descent3/TelComGoals.cpp b/Descent3/TelComGoals.cpp index 0247d441..096620b6 100644 --- a/Descent3/TelComGoals.cpp +++ b/Descent3/TelComGoals.cpp @@ -122,19 +122,18 @@ typedef struct { int goal_index; int lx, rx, ty, by; // bounding box } tGoalLineInfo; -tGoalLineInfo *TG_Lines; -int TG_NumLines; -int *TG_SortedList; -int TG_CurrObjectiveArrow; +static tGoalLineInfo *TG_Lines; +static int TG_NumLines; +static int *TG_SortedList; +static int TG_CurrObjectiveArrow; typedef struct { int w, h; } tToolTipData; -tToolTipData TG_TT_dest; -tToolTipData TG_TT_curr; -chunked_bitmap TG_Tooltipbitmap; -int TG_MouseOffset_x = -1, TG_MouseOffset_y = -1; -extern int TC_cursor; +static tToolTipData TG_TT_dest; +static tToolTipData TG_TT_curr; +static chunked_bitmap TG_Tooltipbitmap; +static int TG_MouseOffset_x = -1, TG_MouseOffset_y = -1; // returns true if left < right bool TG_compare_slots(int left, int right) { int left_index, right_index; @@ -297,7 +296,6 @@ int FindHighlightedItem(int x, int y) { #define COLOR_INCOMPLETE GR_RGB(255, 40, 40) #define COLOR_FAILED GR_RGB(255, 255, 40) -extern float last_frametime; void TCGoalsRenderCallback(void) { static bool active_alpha_in = false; static float active_alpha = ACTIVE_ALPHA_MAX; diff --git a/Descent3/TelcomEffectsRender.cpp b/Descent3/TelcomEffectsRender.cpp index ff28861c..b4e308f0 100644 --- a/Descent3/TelcomEffectsRender.cpp +++ b/Descent3/TelcomEffectsRender.cpp @@ -57,8 +57,6 @@ #include int glitch_dx = 0, glitch_dy = 0; -extern tceffect TCEffects[MAX_TCEFFECTS]; -extern int Screen_roots[MAX_TELCOM_SCREENS]; #define DISABLED_TEXT_COLOR GR_RGB(180, 180, 180); int GetTextEffectWithTabStopsOnScreen(int screen) { int count = 0; diff --git a/Descent3/TerrainSearch.cpp b/Descent3/TerrainSearch.cpp index c79540f3..10e4f5f5 100644 --- a/Descent3/TerrainSearch.cpp +++ b/Descent3/TerrainSearch.cpp @@ -231,44 +231,43 @@ #include "dedicated_server.h" -int EvaluateBlock(int x, int z, int lod); +static int EvaluateBlock(int x, int z, int lod); ushort TS_FrameCount = 0xFFFF; -int SearchQuadTree(int x1, int y1, int x2, int y2, int dir, int *ccount); +static int SearchQuadTree(int x1, int y1, int x2, int y2, int dir, int *ccount); int GlobalTransCount = 0; int TotalDepth; // LOD shutoff stuff #define MAX_LODOFFS 100 -lodoff LODOffs[MAX_LODOFFS]; -int Num_lodoffs = 0; +static lodoff LODOffs[MAX_LODOFFS]; +static int Num_lodoffs = 0; // Render the terrain as flat? ubyte Flat_terrain = 0; // Variables for LOD engine -float ViewDistance1 = .68f, ViewDistance2 = 1.0f; -float TS_Lambda, TS_SimplifyCondition; +static float ViewDistance1 = .68f, ViewDistance2 = 1.0f; +static float TS_Lambda, TS_SimplifyCondition; -matrix *TS_View_matrix; -vector *TS_View_position; +static matrix *TS_View_matrix; +static vector *TS_View_position; -vector TS_PreRows[TERRAIN_DEPTH]; -vector TS_FVectorAdd, TS_RVectorAdd; +static vector TS_PreRows[TERRAIN_DEPTH]; +static vector TS_FVectorAdd, TS_RVectorAdd; -ubyte Terrain_y_flags[256]; -vector Terrain_y_cache[256]; +static ubyte Terrain_y_flags[256]; +static vector Terrain_y_cache[256]; -ushort LOD_sort_bucket[MAX_TERRAIN_LOD][MAX_CELLS_TO_RENDER]; -ushort LOD_sort_num[MAX_TERRAIN_LOD]; +static ushort LOD_sort_bucket[MAX_TERRAIN_LOD][MAX_CELLS_TO_RENDER]; +static ushort LOD_sort_num[MAX_TERRAIN_LOD]; // Variable to determine if we're in editor or game extern function_mode View_mode; -extern ubyte Terrain_from_mine; -vector TJoint_VectorAddZ; -vector TJoint_VectorAddX; +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 @@ -294,7 +293,7 @@ void PreRotateTerrain() { } } -inline vector *GetDYVector(int h) { +static inline vector *GetDYVector(int h) { vector *dyp; dyp = &Terrain_y_cache[h]; @@ -310,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 diff --git a/Descent3/WeaponFire.cpp b/Descent3/WeaponFire.cpp index d7c78d16..b2b1efa7 100644 --- a/Descent3/WeaponFire.cpp +++ b/Descent3/WeaponFire.cpp @@ -945,7 +945,7 @@ #include -bool AreObjectsAttached(const object *obj1, const object *obj2) { +static bool AreObjectsAttached(const object *obj1, const object *obj2) { const bool f_o1_a = (obj1->flags & OF_ATTACHED) != 0; const bool f_o2_a = (obj2->flags & OF_ATTACHED) != 0; @@ -1054,8 +1054,7 @@ bool ObjectsAreRelated(int o1, int o2) { 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; } } @@ -3067,9 +3066,6 @@ void FireFlareFromPlayer(object *objp) { } } -// Creates a gravity field that sucks objects into it -int CreateGravityField(vector *pos, int roomnum, float size, float time, int parent_handle); - // Plays the animation that accompanies a weapon death void DoWeaponExploded(object *obj, vector *norm, vector *collision_point, object *hit_object) { weapon *w = &Weapons[obj->id]; diff --git a/Descent3/aipath.cpp b/Descent3/aipath.cpp index 15229e4e..3ea87c42 100644 --- a/Descent3/aipath.cpp +++ b/Descent3/aipath.cpp @@ -37,7 +37,7 @@ ai_dynamic_path AIDynamicPath[MAX_DYNAMIC_PATHS]; int AIAltPath[MAX_ROOMS]; int AIAltPathNumNodes; -void AIUpdatePathInfo(q_item **node_list, int start, int end) { +static void AIUpdatePathInfo(q_item **node_list, int start, int end) { int cur_room = end; int i; @@ -205,7 +205,7 @@ done: return f_found; } -bool AIPathGetCurrentNodePos(ai_path_info *aip, vector *pos, int *room = NULL) { +bool AIPathGetCurrentNodePos(ai_path_info *aip, vector *pos, int *room) { int c_path = aip->cur_path; int c_node = aip->cur_node; @@ -236,7 +236,7 @@ bool AIPathGetCurrentNodePos(ai_path_info *aip, vector *pos, int *room = NULL) { } // Chrishack -- need to add static path flag stuff -bool AIPathMoveToNextNode(ai_path_info *aip) { +static bool AIPathMoveToNextNode(ai_path_info *aip) { int c_path = aip->cur_path; int c_node = aip->cur_node; @@ -277,7 +277,7 @@ bool AIPathAtEnd(ai_path_info *aip) { return false; } -void AIPathSetAtEnd(ai_path_info *aip) { +static void AIPathSetAtEnd(ai_path_info *aip) { aip->cur_path = aip->num_paths - 1; aip->cur_node = aip->path_end_node[aip->num_paths - 1]; } @@ -287,7 +287,7 @@ void AIPathSetAtStart(ai_path_info *aip) { aip->cur_node = aip->path_start_node[0]; } -bool AIPathMoveToPrevNode(ai_path_info *aip) { +static bool AIPathMoveToPrevNode(ai_path_info *aip) { int c_path = aip->cur_path; int c_node = aip->cur_node; @@ -315,7 +315,7 @@ bool AIPathMoveToPrevNode(ai_path_info *aip) { return false; } -bool AIPathGetNextNodePos(ai_path_info *aip, vector *pos, int *room = NULL) { +bool AIPathGetNextNodePos(ai_path_info *aip, vector *pos, int *room) { if (AIPathMoveToNextNode(aip)) { AIPathGetCurrentNodePos(aip, pos, room); AIPathMoveToPrevNode(aip); @@ -326,7 +326,7 @@ bool AIPathGetNextNodePos(ai_path_info *aip, vector *pos, int *room = NULL) { return false; } -bool AIPathGetPrevNodePos(ai_path_info *aip, vector *pos, int *room = NULL) { +bool AIPathGetPrevNodePos(ai_path_info *aip, vector *pos, int *room) { if (AIPathMoveToPrevNode(aip)) { AIPathGetCurrentNodePos(aip, pos, room); AIPathMoveToNextNode(aip); @@ -337,7 +337,7 @@ bool AIPathGetPrevNodePos(ai_path_info *aip, vector *pos, int *room = NULL) { return false; } -void AIPathComplete(object *obj) { GoalPathComplete(obj); } +static void AIPathComplete(object *obj) { GoalPathComplete(obj); } void AIPathMoveTurnTowardsNode(object *obj, vector *mdir, bool *f_moved) { ai_path_info *aip = &obj->ai_info->path; @@ -535,7 +535,7 @@ pass_node: } } -bool AIPathFreeDPathSlot(int slot) { +static bool AIPathFreeDPathSlot(int slot) { ASSERT(AIDynamicPath[slot].use_count >= 0); ASSERT(slot >= 0 && slot < MAX_DYNAMIC_PATHS && AIDynamicPath[slot].use_count != 0); @@ -549,7 +549,7 @@ bool AIPathFreeDPathSlot(int slot) { return true; } -bool AIPathGetDPathSlot(int *slot, int handle) { +static bool AIPathGetDPathSlot(int *slot, int handle) { int i; for (i = 0; i < MAX_DYNAMIC_PATHS; i++) { @@ -600,7 +600,7 @@ bool AIPathFreePath(ai_path_info *aip) { return true; } -bool AIPathAddDPath(ai_path_info *aip, int handle) { +static bool AIPathAddDPath(ai_path_info *aip, int handle) { int slot; bool status; @@ -626,7 +626,7 @@ bool AIPathAddDPath(ai_path_info *aip, int handle) { return status; } -bool AIPathAddStaticPath(ai_path_info *aip, int path_id, int start_index, int end_index) { +static bool AIPathAddStaticPath(ai_path_info *aip, int path_id, int start_index, int end_index) { // chrishack -- validation code is needed if (aip->num_paths >= MAX_JOINED_PATHS) { @@ -644,7 +644,7 @@ bool AIPathAddStaticPath(ai_path_info *aip, int path_id, int start_index, int en return true; } -inline bool AIPathAddDPathNode(ai_path_info *aip, int *slot, int *cur_node, vector *pos, int room, int handle) { +static inline bool AIPathAddDPathNode(ai_path_info *aip, int *slot, int *cur_node, vector *pos, int room, int handle) { int status; if (*cur_node == MAX_NODES) { @@ -665,8 +665,8 @@ inline bool AIPathAddDPathNode(ai_path_info *aip, int *slot, int *cur_node, vect return true; } -bool AIGenerateAltBNodePath(object *obj, vector *start_pos, int *start_room, vector *end_pos, int *end_room, - ai_path_info *aip, int *slot, int *cur_node, int handle) { +static bool AIGenerateAltBNodePath(object *obj, vector *start_pos, int *start_room, vector *end_pos, int *end_room, + ai_path_info *aip, int *slot, int *cur_node, int handle) { int x; vector *pos; bool f_path_exists = true; @@ -773,7 +773,8 @@ done: return f_path_exists; } -void AIGenerateAltBOAPath(vector *start_pos, vector *end_pos, ai_path_info *aip, int *slot, int *cur_node, int handle) { +static void AIGenerateAltBOAPath(vector *start_pos, vector *end_pos, ai_path_info *aip, int *slot, int *cur_node, + int handle) { int x; vector *pos = NULL; @@ -823,8 +824,8 @@ void AIGenerateAltBOAPath(vector *start_pos, vector *end_pos, ai_path_info *aip, // next_room = *end_room; // } -bool AIGenerateBNodePath(object *obj, vector *start_pos, int *start_room, vector *end_pos, int *end_room, - ai_path_info *aip, int *slot, int *cur_node, int handle) { +static bool AIGenerateBNodePath(object *obj, vector *start_pos, int *start_room, vector *end_pos, int *end_room, + ai_path_info *aip, int *slot, int *cur_node, int handle) { int next_room = BOA_INDEX(*start_room); bool f_path_exists = true; vector *pos; @@ -938,8 +939,8 @@ done: return f_path_exists; } -bool AIGenerateBOAPath(vector *start_pos, int *start_room, vector *end_pos, int *end_room, ai_path_info *aip, int *slot, - int *cur_node, int handle) { +static bool AIGenerateBOAPath(vector *start_pos, int *start_room, vector *end_pos, int *end_room, ai_path_info *aip, + int *slot, int *cur_node, int handle) { int next_room = *start_room; bool f_path_exists = true; vector *pos; diff --git a/Descent3/aipath.h b/Descent3/aipath.h index f8f318fd..e8744acb 100644 --- a/Descent3/aipath.h +++ b/Descent3/aipath.h @@ -24,17 +24,23 @@ #include "aistruct.h" // Exported functions -void AIPathMoveTurnTowardsNode(object *obj, vector *mdir, bool *f_moved); +extern void AIPathMoveTurnTowardsNode(object *obj, vector *mdir, bool *f_moved); // void AIPathMoveTowardsRoom(object *obj, int room_index); -bool AIPathSetAsStaticPath(object *obj, void *goal_ptr, int path_id, int start_node, int end_node, int cur_node); -bool AIPathAllocPath(object *obj, ai_frame *ai_info, void *goal_ptr, int *start_room, vector *start_pos, int *end_room, - vector *end_pos, float rad, int flags, int handle, int ignore_obj = -1); -bool AIPathInitPath(ai_path_info *aip); -bool AIPathFreePath(ai_path_info *aip); -bool AIFindAltPath(object *obj, int i, int j, float *dist = NULL); +extern bool AIPathSetAsStaticPath(object *obj, void *goal_ptr, int path_id, int start_node, int end_node, int cur_node); +extern bool AIPathAllocPath(object *obj, ai_frame *ai_info, void *goal_ptr, int *start_room, vector *start_pos, + int *end_room, vector *end_pos, float rad, int flags, int handle, int ignore_obj = -1); +extern bool AIPathInitPath(ai_path_info *aip); +extern bool AIPathFreePath(ai_path_info *aip); +extern bool AIFindAltPath(object *obj, int i, int j, float *dist = NULL); + +extern bool AIPathAtEnd(ai_path_info *aip); +extern bool AIPathAtStart(ai_path_info *aip); +extern bool AIPathGetNextNodePos(ai_path_info *aip, vector *pos, int *room = NULL); +extern bool AIPathGetPrevNodePos(ai_path_info *aip, vector *pos, int *room = NULL); +extern bool AIPathGetCurrentNodePos(ai_path_info *aip, vector *pos, int *room = NULL); #ifdef _DEBUG -bool MakeTestPath(int *start_room, vector *pos); +extern bool MakeTestPath(int *start_room, vector *pos); extern int AIPath_test_end_room; extern vector AIPath_test_end_pos; diff --git a/Descent3/aiterrain.cpp b/Descent3/aiterrain.cpp index 45e8fd1e..67495b18 100644 --- a/Descent3/aiterrain.cpp +++ b/Descent3/aiterrain.cpp @@ -57,15 +57,15 @@ #define AI_MAX_SEGS_CHECKED 200 -int ai_num_segs_checked = 0; -ubyte ai_terrain_check_list[((TERRAIN_WIDTH * TERRAIN_DEPTH) >> 3) + 1]; -int ai_segs_checked[AI_MAX_SEGS_CHECKED]; +static int ai_num_segs_checked = 0; +static ubyte ai_terrain_check_list[((TERRAIN_WIDTH * TERRAIN_DEPTH) >> 3) + 1]; +static int ai_segs_checked[AI_MAX_SEGS_CHECKED]; #ifdef _DEBUG -int ai_num_checks_since_init = 0; +static int ai_num_checks_since_init = 0; #endif -float ai_rad; -ground_information *ai_ground_info_ptr; +static float ai_rad; +static ground_information *ai_ground_info_ptr; void ait_Init() { ai_num_segs_checked = 0; @@ -76,7 +76,7 @@ void ait_Init() { #endif } -void ait_terrain_clean() { +static void ait_terrain_clean() { int i; assert(ai_num_segs_checked >= 0 && ai_num_segs_checked <= AI_MAX_SEGS_CHECKED); @@ -96,7 +96,7 @@ void ait_terrain_clean() { ai_num_segs_checked = 0; } -void ai_check_terrain_node(int cur_node, int f_check_local_nodes) { +static void ai_check_terrain_node(int cur_node, int f_check_local_nodes) { int check_x, check_y; int new_node; int xcounter, ycounter; diff --git a/Descent3/ambient.cpp b/Descent3/ambient.cpp index 1dad6abc..52525ab1 100644 --- a/Descent3/ambient.cpp +++ b/Descent3/ambient.cpp @@ -90,10 +90,10 @@ int Num_ambient_sound_patterns = 0; // Computes a floating-point pseudo-random number. // Returns value in the range 0..1, with the precision 1/RAND_MAX -float randf() { return ((float)ps_rand()) / ((float)RAND_MAX); } +static float randf() { return ((float)ps_rand()) / ((float)RAND_MAX); } // Process an Ambient Sound Pattern -void ProcessASP(asp *asp) { +static void ProcessASP(asp *asp) { // Check for empty ASP if (!asp->num_sounds) return; @@ -161,7 +161,7 @@ void InitAmbientSounds() { #include "mem.h" // Close down ambient sound system and free data -void FreeAmbientSoundData() { +static 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); diff --git a/Descent3/args.cpp b/Descent3/args.cpp index bd31734a..608725a4 100644 --- a/Descent3/args.cpp +++ b/Descent3/args.cpp @@ -25,7 +25,7 @@ #endif // rcg07062000 used to be static. -int TotalArgs = 0; +static int TotalArgs = 0; char GameArgs[MAX_ARGS][MAX_CHARS_PER_ARG]; const char *GetArg(int index) { diff --git a/Descent3/attach.cpp b/Descent3/attach.cpp index 23afea87..50653cdc 100644 --- a/Descent3/attach.cpp +++ b/Descent3/attach.cpp @@ -142,8 +142,8 @@ 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) -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 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) { poly_model *pm; vector pnt; vector normal; @@ -227,7 +227,7 @@ bool AttachPointPos(object *obj, char ap, bool f_compute_pos, vector *attach_pos return true; } -void ConvertAxisAmountMatrix(vector *n, float w, matrix *rotmat) { +static void ConvertAxisAmountMatrix(vector *n, float w, matrix *rotmat) { float s; float c; float t; @@ -399,7 +399,7 @@ bool AttachDoPosOrient(object *parent, char parent_ap, object *child, char child } // Adds and subtracts from mass from connections and disconnections -void AttachPropagateMass(object *child, bool f_attach = true) { +static void AttachPropagateMass(object *child, bool f_attach = true) { object *new_parent; if (!child) @@ -436,7 +436,7 @@ void AttachPropagateMass(object *child, bool f_attach = true) { } while (child->flags & OF_ATTACHED); } -inline void ComputeUltimateAttachParent(object *child) { +static inline void ComputeUltimateAttachParent(object *child) { object *cur_obj = child; do { @@ -447,7 +447,7 @@ inline void ComputeUltimateAttachParent(object *child) { } while (cur_obj->flags & OF_ATTACHED); } -void ProprogateUltimateAttachParent(object *parent, int ultimate_handle) { +static void ProprogateUltimateAttachParent(object *parent, int ultimate_handle) { int i; ASSERT(parent); @@ -700,4 +700,4 @@ bool UnattachChildren(object *parent) { } return true; -} \ No newline at end of file +} diff --git a/Descent3/audiotaunts.cpp b/Descent3/audiotaunts.cpp index 9f786595..99db4d0d 100644 --- a/Descent3/audiotaunts.cpp +++ b/Descent3/audiotaunts.cpp @@ -59,11 +59,11 @@ typedef struct { // 8: invalid samples // 9: invalid bit (8 or 16) // 10: no data -char taunt_LoadWaveFile(char *filename, tWaveFile *wave); +static char taunt_LoadWaveFile(char *filename, tWaveFile *wave); -int TauntLastError = TAUNTIMPERR_NOERROR; +static int TauntLastError = TAUNTIMPERR_NOERROR; bool Audio_taunts_enabled = true; -float Audio_taunt_delay_time = 5.0f; +static float Audio_taunt_delay_time = 5.0f; // taunt_Enable // diff --git a/Descent3/bnode.cpp b/Descent3/bnode.cpp index c7c8f026..0b137d21 100644 --- a/Descent3/bnode.cpp +++ b/Descent3/bnode.cpp @@ -172,14 +172,14 @@ public: } }; -float BNode_QuickDist(vector *pos1, vector *pos2) { +static float BNode_QuickDist(vector *pos1, vector *pos2) { return fabs(pos1->x - pos2->x) + fabs(pos1->y - pos2->y) + fabs(pos1->z - pos2->z); } int BNode_Path[MAX_BNODES_PER_ROOM]; int BNode_PathNumNodes; -void BNode_UpdatePathInfo(pq_item **node_list, int start, int end) { +static void BNode_UpdatePathInfo(pq_item **node_list, int start, int end) { int cur_node = end; int i; @@ -287,12 +287,13 @@ done: return f_found; } +// TODO: MTS: Unused? int BNode_GenerateBestPathThroughRoom(int sroom, int spnt, int croom, int eroom, int eportal, int max_nodes, vector *pos_list) { return -1; } -char BNode_vis[MAX_BNODES_PER_ROOM]; +static char BNode_vis[MAX_BNODES_PER_ROOM]; #define VIS_NO_CHECK 2 #define VIS_OK 1 #define VIS_NO 2 @@ -502,6 +503,7 @@ void BNode_ClearBNodeInfo(void) { BNode_verified = false; } +// Unused? bool BNode_MakeSubPath(short sroom, short spnt, short eroom, short epnt, int flags, float size, short *roomlist, short *pnts, int max_elements) { return false; @@ -560,4 +562,4 @@ void BNode_RemapTerrainRooms(int old_hri, int new_hri) { } } } -} \ No newline at end of file +} diff --git a/Descent3/bsp.cpp b/Descent3/bsp.cpp index a30f5c1c..de7882bf 100644 --- a/Descent3/bsp.cpp +++ b/Descent3/bsp.cpp @@ -57,10 +57,11 @@ bsptree MineBSP; ubyte BSP_initted = 0; -int ConvexSubspaces = 0, ConvexPolys = 0; -int Solids = 0, Empty = 0; +static int ConvexSubspaces = 0, ConvexPolys = 0; +static int Solids = 0, Empty = 0; int BSPChecksum = -1; +// TODO: MTS: Only used here? ubyte UseBSP = 0; // Goes through all the valid points in the indoor engine and returns a unique @@ -1061,7 +1062,7 @@ void BuildSingleBSPTree(int roomnum) { } // Returns true if the point is inside the min,max -inline int BSPInMinMax(vector *pos, vector *min_xyz, vector *max_xyz) { +static inline int BSPInMinMax(vector *pos, vector *min_xyz, vector *max_xyz) { if (pos->x < min_xyz->x || pos->y < min_xyz->y || pos->z < min_xyz->z || pos->x > max_xyz->x || pos->y > max_xyz->y || pos->z > max_xyz->z) return 0; @@ -1072,7 +1073,7 @@ 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]; diff --git a/Descent3/buddymenu.cpp b/Descent3/buddymenu.cpp index 1a79bfb8..ed58d228 100644 --- a/Descent3/buddymenu.cpp +++ b/Descent3/buddymenu.cpp @@ -89,15 +89,15 @@ #define BUDDYMENU_ITEM_W 226 #define UID_BUDDYCMD 0x100 -gb_menu Guidebot_menu_data; -int Guidebot_data_download_status; +static gb_menu Guidebot_menu_data; +static int Guidebot_data_download_status; // downloads data for the buddybot // on return: if 1, process data // if 0, abort // if -1, no guidebot -int BuddyBotDownloadData(void); -void BuddyProcessCommand(int res); +static int BuddyBotDownloadData(void); +static void BuddyProcessCommand(int res); void BuddyDisplay(void) { newuiTiledWindow gbcommand_wnd; @@ -181,7 +181,7 @@ void BuddyDisplay(void) { gbcommand_wnd.Destroy(); } -void MultiAskforGuidebotMenu() { +static void MultiAskforGuidebotMenu() { int size_offset; int count = 0; ubyte data[MAX_GAME_DATA_SIZE]; @@ -196,7 +196,7 @@ void MultiAskforGuidebotMenu() { nw_SendReliable(NetPlayers[Player_num].reliable_socket, data, count); } -void MultiStuffGuidebotMenuData(ubyte *data, int *count, gb_menu *menu) { +static void MultiStuffGuidebotMenuData(ubyte *data, int *count, gb_menu *menu) { int i; // Get the menu data and stick it here // length of the title @@ -254,7 +254,7 @@ void MultiSendGuidebotMenuSelection(gb_com *command) { nw_SendReliable(NetPlayers[Player_num].reliable_socket, data, count); } -void MultiSendGuidebotMenuText(gb_menu *menu, int slot) { +static void MultiSendGuidebotMenuText(gb_menu *menu, int slot) { int size_offset; int count = 0; @@ -272,7 +272,7 @@ void MultiSendGuidebotMenuText(gb_menu *menu, int slot) { nw_SendReliable(NetPlayers[slot].reliable_socket, data, count, false); } -void MultiReadGuidebotMenuData(ubyte *data, int *count, gb_menu *menu) { +static void MultiReadGuidebotMenuData(ubyte *data, int *count, gb_menu *menu) { int i; // Get the menu data and stick it here diff --git a/Descent3/buddymenu.h b/Descent3/buddymenu.h index 59d4bef4..bffc1ef8 100644 --- a/Descent3/buddymenu.h +++ b/Descent3/buddymenu.h @@ -20,5 +20,7 @@ #define __BUDDYMENU_H_ void BuddyDisplay(void); +struct gb_com; +extern void MultiSendGuidebotMenuSelection(gb_com *); #endif diff --git a/Descent3/cinematics.cpp b/Descent3/cinematics.cpp index 47c71fc4..63be080c 100644 --- a/Descent3/cinematics.cpp +++ b/Descent3/cinematics.cpp @@ -42,7 +42,7 @@ static struct { static bool Cinematic_lib_init = false; static int Cinematic_x = 0, Cinematic_y = 0, Cinematic_w = 0, Cinematic_h = 0; -void CinematicCallback(int mve_x, int mve_y, int frame_num); +static void CinematicCallback(int mve_x, int mve_y, int frame_num); /////////////////////////////////////////////////////////////////////////////// // functions diff --git a/Descent3/cockpit.cpp b/Descent3/cockpit.cpp index d4b1065d..6fe41828 100644 --- a/Descent3/cockpit.cpp +++ b/Descent3/cockpit.cpp @@ -241,14 +241,13 @@ typedef struct tCockpitInfo { matrix orient; // orientation of cockpit } tCockpitInfo; static tCockpitInfo Cockpit_info; -float KeyframeAnimateCockpit(); +static float KeyframeAnimateCockpit(); // loads cockpit. model_name = NULL, then will not load in model name. -void LoadCockpitInfo(const char *ckt_file, tCockpitCfgInfo *info); +static void LoadCockpitInfo(const char *ckt_file, tCockpitCfgInfo *info); ////////////////////////////////////////////////////////////////////////////// // Initializes the cockpit by loading it in and initializing all it's gauges. // initialization of cockpit. void InitCockpit(int ship_index) { - extern void FreeReticle(); tCockpitCfgInfo cfginfo; int i; mprintf((0, "Initializing cockpit.\n")); diff --git a/Descent3/config.cpp b/Descent3/config.cpp index 029d079d..2face28a 100644 --- a/Descent3/config.cpp +++ b/Descent3/config.cpp @@ -425,26 +425,26 @@ tGameToggles Game_toggles = { // toggles specified in general settings. #define MINIMUM_RENDER_DIST 80 #define MAXIMUM_RENDER_DIST 200 -tDetailSettings DetailPresetLow = {DL_LOW_TERRAIN_DISTANCE, DL_LOW_PIXEL_ERROR, DL_LOW_SPECULAR_LIGHT, - DL_LOW_DYNAMIC_LIGHTING, DL_LOW_FAST_HEADLIGHT, DL_LOW_MIRRORED_SURFACES, - DL_LOW_FOG_ENABLED, DL_LOW_CORONAS_ENABLES, DL_LOW_PROCEDURALS, - DL_LOW_POWERUP_HALOS, DL_LOW_SCORCH_MARKS, DL_LOW_WEAPON_CORONAS, - DL_LOW_SPEC_MAPPING_TYPE, DL_LOW_OBJECT_COMPLEXITY}; -tDetailSettings DetailPresetMed = {DL_MED_TERRAIN_DISTANCE, DL_MED_PIXEL_ERROR, DL_MED_SPECULAR_LIGHT, - DL_MED_DYNAMIC_LIGHTING, DL_MED_FAST_HEADLIGHT, DL_MED_MIRRORED_SURFACES, - DL_MED_FOG_ENABLED, DL_MED_CORONAS_ENABLES, DL_MED_PROCEDURALS, - DL_MED_POWERUP_HALOS, DL_MED_SCORCH_MARKS, DL_MED_WEAPON_CORONAS, - DL_MED_SPEC_MAPPING_TYPE, DL_MED_OBJECT_COMPLEXITY}; -tDetailSettings DetailPresetHigh = {DL_HIGH_TERRAIN_DISTANCE, DL_HIGH_PIXEL_ERROR, DL_HIGH_SPECULAR_LIGHT, - DL_HIGH_DYNAMIC_LIGHTING, DL_HIGH_FAST_HEADLIGHT, DL_HIGH_MIRRORED_SURFACES, - DL_HIGH_FOG_ENABLED, DL_HIGH_CORONAS_ENABLES, DL_HIGH_PROCEDURALS, - DL_HIGH_POWERUP_HALOS, DL_HIGH_SCORCH_MARKS, DL_HIGH_WEAPON_CORONAS, - DL_HIGH_SPEC_MAPPING_TYPE, DL_HIGH_OBJECT_COMPLEXITY}; -tDetailSettings DetailPresetVHi = {DL_VHI_TERRAIN_DISTANCE, DL_VHI_PIXEL_ERROR, DL_VHI_SPECULAR_LIGHT, - DL_VHI_DYNAMIC_LIGHTING, DL_VHI_FAST_HEADLIGHT, DL_VHI_MIRRORED_SURFACES, - DL_VHI_FOG_ENABLED, DL_VHI_CORONAS_ENABLES, DL_VHI_PROCEDURALS, - DL_VHI_POWERUP_HALOS, DL_VHI_SCORCH_MARKS, DL_VHI_WEAPON_CORONAS, - DL_VHI_SPEC_MAPPING_TYPE, DL_VHI_OBJECT_COMPLEXITY}; +static const tDetailSettings DetailPresetLow = { + DL_LOW_TERRAIN_DISTANCE, DL_LOW_PIXEL_ERROR, DL_LOW_SPECULAR_LIGHT, DL_LOW_DYNAMIC_LIGHTING, + DL_LOW_FAST_HEADLIGHT, DL_LOW_MIRRORED_SURFACES, DL_LOW_FOG_ENABLED, DL_LOW_CORONAS_ENABLES, + DL_LOW_PROCEDURALS, DL_LOW_POWERUP_HALOS, DL_LOW_SCORCH_MARKS, DL_LOW_WEAPON_CORONAS, + DL_LOW_SPEC_MAPPING_TYPE, DL_LOW_OBJECT_COMPLEXITY}; +static const tDetailSettings DetailPresetMed = { + DL_MED_TERRAIN_DISTANCE, DL_MED_PIXEL_ERROR, DL_MED_SPECULAR_LIGHT, DL_MED_DYNAMIC_LIGHTING, + DL_MED_FAST_HEADLIGHT, DL_MED_MIRRORED_SURFACES, DL_MED_FOG_ENABLED, DL_MED_CORONAS_ENABLES, + DL_MED_PROCEDURALS, DL_MED_POWERUP_HALOS, DL_MED_SCORCH_MARKS, DL_MED_WEAPON_CORONAS, + DL_MED_SPEC_MAPPING_TYPE, DL_MED_OBJECT_COMPLEXITY}; +static const tDetailSettings DetailPresetHigh = { + DL_HIGH_TERRAIN_DISTANCE, DL_HIGH_PIXEL_ERROR, DL_HIGH_SPECULAR_LIGHT, DL_HIGH_DYNAMIC_LIGHTING, + DL_HIGH_FAST_HEADLIGHT, DL_HIGH_MIRRORED_SURFACES, DL_HIGH_FOG_ENABLED, DL_HIGH_CORONAS_ENABLES, + DL_HIGH_PROCEDURALS, DL_HIGH_POWERUP_HALOS, DL_HIGH_SCORCH_MARKS, DL_HIGH_WEAPON_CORONAS, + DL_HIGH_SPEC_MAPPING_TYPE, DL_HIGH_OBJECT_COMPLEXITY}; +static const tDetailSettings DetailPresetVHi = { + DL_VHI_TERRAIN_DISTANCE, DL_VHI_PIXEL_ERROR, DL_VHI_SPECULAR_LIGHT, DL_VHI_DYNAMIC_LIGHTING, + DL_VHI_FAST_HEADLIGHT, DL_VHI_MIRRORED_SURFACES, DL_VHI_FOG_ENABLED, DL_VHI_CORONAS_ENABLES, + DL_VHI_PROCEDURALS, DL_VHI_POWERUP_HALOS, DL_VHI_SCORCH_MARKS, DL_VHI_WEAPON_CORONAS, + DL_VHI_SPEC_MAPPING_TYPE, DL_VHI_OBJECT_COMPLEXITY}; void ConfigSetDetailLevel(int level) { switch (level) { @@ -483,7 +483,7 @@ void ConfigSetDetailLevel(int level) { #define IDV_AUTOGAMMA 6 -void gamma_callback(newuiTiledWindow *wnd, void *data) { +static void gamma_callback(newuiTiledWindow *wnd, void *data) { int bm_handle = *((int *)data); g3Point pnts[4], *pntlist[4]; @@ -552,7 +552,7 @@ void gamma_callback(newuiTiledWindow *wnd, void *data) { rend_SetZBufferState(1); } -void config_gamma() { +static void config_gamma() { newuiTiledWindow gamma_wnd; newuiSheet *sheet; tSliderSettings slider_set; @@ -1357,8 +1357,7 @@ void details_menu::set_preset_details(int setting) { // new Options menu // -// externed from init.cpp -extern void SaveGameSettings(); +#include "init.h" void OptionsMenu() { newuiMenu menu; diff --git a/Descent3/credits.cpp b/Descent3/credits.cpp index 19dd7dba..343cb1f3 100644 --- a/Descent3/credits.cpp +++ b/Descent3/credits.cpp @@ -123,17 +123,17 @@ typedef struct creditline { float displaytime; } creditline; -void Credits_Render(creditline *, float); -creditline Creditlines; +static void Credits_Render(creditline *, float); +static creditline Creditlines; -ddgr_color CreditTextColor, CreditHeadingColor; -int CreditStartX, CreditStartY, CreditEndX, CreditEndY; -float CreditDisplayTime; -chunked_bitmap Credits_bm; +static ddgr_color CreditTextColor, CreditHeadingColor; +static int CreditStartX, CreditStartY, CreditEndX, CreditEndY; +static float CreditDisplayTime; +static chunked_bitmap Credits_bm; #define MAX_CREDIT_LEN 200 -bool Credits_IsKeyPressed(void) { +static bool Credits_IsKeyPressed(void) { if (ddio_KeyInKey()) return true; @@ -142,7 +142,7 @@ bool Credits_IsKeyPressed(void) { // Parses a credit line // Returns 1 if new text was read, else 0 -int Credits_ParseLine(char *line, creditline *credit) { +static int Credits_ParseLine(char *line, creditline *credit) { int line_len = strlen(line); int new_text = 0; @@ -239,7 +239,7 @@ int Credits_ParseLine(char *line, creditline *credit) { } // Given a filename, attempts to load that filename as credit text -bool Credits_LoadCredits(const char *filename) { +static bool Credits_LoadCredits(const char *filename) { CFILE *infile; char curline[MAX_CREDIT_LEN]; @@ -306,7 +306,7 @@ bool Credits_LoadCredits(const char *filename) { return true; } -void ShowStaticScreen(char *bitmap_filename, bool timed = false, float delay_time = 0.0f); +extern void ShowStaticScreen(char *bitmap_filename, bool timed = false, float delay_time = 0.0f); #define CREDIT_PIXELS_PER_SECOND 22 diff --git a/Descent3/ctlconfig.cpp b/Descent3/ctlconfig.cpp index e8e6e3b6..ac0ca16f 100644 --- a/Descent3/ctlconfig.cpp +++ b/Descent3/ctlconfig.cpp @@ -403,10 +403,10 @@ t_cfg_element Cfg_joy_elements[] = {{-1, CtlText_WeaponGroup, CCITEM_WPN_X2, CCI {ctfBANK_RIGHTBUTTON, CtlText_BankRight, 0, 0}}; #define N_JOY_CFG_FN (sizeof(Cfg_joy_elements) / sizeof(t_cfg_element)) #define N_KEY_CFG_FN (sizeof(Cfg_key_elements) / sizeof(t_cfg_element)) -void ctl_cfg_set_and_verify_changes(short fnid, ct_type elem_type, ubyte controller, ubyte elem, sbyte slot); -void ctl_cfg_element_options_dialog(short fnid); +static void ctl_cfg_set_and_verify_changes(short fnid, ct_type elem_type, ubyte controller, ubyte elem, sbyte slot); +static void ctl_cfg_element_options_dialog(short fnid); // used for adjusting settings. -int weapon_select_dialog(int wpn, bool is_secondary); +static int weapon_select_dialog(int wpn, bool is_secondary); #define UID_KEYCFG_ID 0x1000 #define UID_JOYCFG_ID 0x1100 #define UID_PRIMARY_WPN 0x1200 @@ -966,7 +966,6 @@ void ctl_cfg_set_and_verify_changes(short fnid, ct_type elem_type, ubyte ctrl, u Controller->set_controller_function(fnid, ctype_fn, ccfgdata_fn, cfgflags_fn); } // used as a help/options dialog for each controller config element -extern const char *cfg_binding_text(ct_type ctype, ubyte ctrl, ubyte binding); void ctl_cfg_element_options_dialog(short fnid) { newuiTiledWindow wnd; newuiSheet *sheet; diff --git a/Descent3/d3serial.cpp b/Descent3/d3serial.cpp index 2b7559f5..11c5bc40 100644 --- a/Descent3/d3serial.cpp +++ b/Descent3/d3serial.cpp @@ -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 @@ -95,7 +95,7 @@ static char name_copy[DESC_ID_LEN]; -unsigned int d3_serialnum = 100000; +static unsigned int d3_serialnum = 100000; // checks the exectuable (serialization) int SerialCheck(void) { diff --git a/Descent3/damage.cpp b/Descent3/damage.cpp index 8c084144..8ed87a98 100644 --- a/Descent3/damage.cpp +++ b/Descent3/damage.cpp @@ -590,6 +590,17 @@ #include +static void SetDeformDamageEffect(object *obj); +static void ApplyFreezeDamageEffect(object *obj); +static void DecreasePlayerShields(int slot, float damage); +static void DoEDrainEffect(int eventnum, void *data); +static void PlayPlayerDamageSound(object *playerobj, int damage_type); +static void GenerateDefaultDeath(object *obj, int *death_flags, float *delay_time); +static void PlayPlayerInvulnerabilitySound(object *playerobj); +static void SetFlyingPhysics(object *objp, bool tumbles); +static float GetDeathAnimTime(object *objp); +static void SetFallingPhysics(object *objp); + // Shake variables static matrix Old_player_orient; float Shake_magnitude = 0.0; @@ -1467,9 +1478,7 @@ void ShakePlayer() { void UnshakePlayer() { ObjSetOrient(Player_object, &Old_player_orient); } #include "terrain.h" - -void ComputeCenterPointOnFace(vector *vp, room *rp, int facenum); -void FindHitpointUV(float *u, float *v, vector *point, room *rp, int facenum); +#include "collide.h" #define SHARD_MAX_EDGE_LEN 3.0f diff --git a/Descent3/damage.h b/Descent3/damage.h index f24b7699..3569d9e0 100644 --- a/Descent3/damage.h +++ b/Descent3/damage.h @@ -151,6 +151,8 @@ void ShakePlayer(); // Restores the player orientation matrix after shaking void UnshakePlayer(); +extern void SetShakeMagnitude(float delta); + // Break the specified (glass) face into shards // Parameters: rp, facenum - the face to break // hitpnt - the point on the face where the face shatters. If NULL, uses center diff --git a/Descent3/dedicated_server.cpp b/Descent3/dedicated_server.cpp index 844cf430..044578d5 100644 --- a/Descent3/dedicated_server.cpp +++ b/Descent3/dedicated_server.cpp @@ -144,24 +144,28 @@ typedef int socklen_t; bool Dedicated_server = false; -int Dedicated_start_level = 1; -int Dummy_dedicated_var; -char Dummy_dedicated_string[_MAX_PATH]; +static int Dedicated_start_level = 1; +static int Dummy_dedicated_var; +static char Dummy_dedicated_string[_MAX_PATH]; // If true, allow remote connections -int Dedicated_allow_remote = 0; -ushort Dedicated_listen_port = 2092; -char dedicated_telnet_password[65]; -int Dedicated_num_teams = 1; +static int Dedicated_allow_remote = 0; +static ushort Dedicated_listen_port = 2092; +static char dedicated_telnet_password[65]; +static int Dedicated_num_teams = 1; -int CheckMissionForScript(char *mission, char *script, int dedicated_server_num_teams); +static int RunServerConfigs(); +static int DedicatedServerLex(const char *command); +static void SetCVarNone(int index); + +extern int CheckMissionForScript(char *mission, char *script, int dedicated_server_num_teams); extern char Multi_message_of_the_day[]; extern char PXO_hosted_lobby_name[]; // These define the types of variables that can be set in the code through // the dedicated server -cvar_entry CVars[] = { +static cvar_entry CVars[] = { {"PPS", CVAR_TYPE_INT, &Netgame.packets_per_second, 2, 20, CVAR_GAMEINIT}, // 0 {"TimeLimit", CVAR_TYPE_INT, &Netgame.timelimit, 0, 10000, CVAR_GAMEINIT}, {"KillGoal", CVAR_TYPE_INT, &Netgame.killgoal, 0, 10000, CVAR_GAMEINIT}, diff --git a/Descent3/demofile.cpp b/Descent3/demofile.cpp index 7c95cbf0..8da448ed 100644 --- a/Descent3/demofile.cpp +++ b/Descent3/demofile.cpp @@ -300,23 +300,23 @@ #include "demofile.h" extern bool is_multi_demo; -CFILE *Demo_cfp = NULL; +static CFILE *Demo_cfp = NULL; char Demo_fname[_MAX_PATH * 2]; -char Old_demo_fname[_MAX_PATH * 2]; -float Demo_next_frame = 0; -float Demo_frame_time = 0; -float Demo_last_pinfo; +static char Old_demo_fname[_MAX_PATH * 2]; +static float Demo_next_frame = 0; +static float Demo_frame_time = 0; +static float Demo_last_pinfo; float Demo_frame_ofs; -int Demo_auto_idx = 0; +static int Demo_auto_idx = 0; unsigned int Demo_flags = 0; unsigned short Demo_obj_map[MAX_OBJECTS]; -bool Demo_turretchanged[MAX_OBJECTS]; +static bool Demo_turretchanged[MAX_OBJECTS]; bool Demo_looping = false; bool Demo_paused = false; bool Demo_do_one_frame = false; bool Demo_restart = false; bool Demo_auto_play = false; -bool Demo_first_frame = true; +static bool Demo_first_frame = true; bool Demo_make_movie = false; #define DEMO_PINFO_UPDATE .1 @@ -333,9 +333,9 @@ extern bool Game_paused; extern bool Game_gauge_do_time_test; -bool Demo_play_fast = false; +static bool Demo_play_fast = false; -void PageInAllData(void); +extern void PageInAllData(void); // Prompts user for filename and starts recording if successfull void DemoToggleRecording() { diff --git a/Descent3/descent.cpp b/Descent3/descent.cpp index 96941c2e..50a5c479 100644 --- a/Descent3/descent.cpp +++ b/Descent3/descent.cpp @@ -756,7 +756,7 @@ function_mode GetFunctionMode() { return Function_mode; } // The game's defer handler (For Win32, it happens during idle processing) // --------------------------------------------------------------------------- extern bool Skip_render_game_frame; -void GameFrame(void); +extern void GameFrame(void); void D3DeferHandler(bool is_active) { if (is_active) { // perform any needed io system processing in the background diff --git a/Descent3/difficulty.cpp b/Descent3/difficulty.cpp index 055fb301..19ef1c1e 100644 --- a/Descent3/difficulty.cpp +++ b/Descent3/difficulty.cpp @@ -23,18 +23,18 @@ // 1. Don't mess with target leading (other than algorithm type) as it will make robots // turn strangely (or at least never scale it up beyond 1.0) -float Diff_ai_dodge_percent[5] = {0.04f, 0.10f, 1.00f, 1.00f, 1.50f}; -float Diff_ai_dodge_speed[5] = {0.20f, 0.30f, 1.00f, 1.25f, 1.50f}; -float Diff_ai_speed[5] = {0.70f, 0.80f, 1.00f, 1.10f, 1.20f}; -float Diff_ai_rotspeed[5] = {0.70f, 0.80f, 1.00f, 1.10f, 1.20f}; -float Diff_ai_circle_dist[5] = {1.10f, 1.00f, 1.00f, 1.00f, 1.00f}; -float Diff_ai_vis_dist[5] = {0.80f, 0.90f, 1.00f, 1.10f, 1.20f}; -float Diff_player_damage[5] = {0.30f, 0.60f, 1.00f, 1.50f, 2.00f}; -float Diff_ai_weapon_speed[5] = {0.50f, 0.75f, 1.00f, 1.20f, 1.40f}; -float Diff_homing_strength[5] = {0.20f, 0.70f, 1.00f, 1.20f, 1.40f}; -float Diff_robot_damage[5] = {2.75f, 1.50f, 1.00f, 0.80f, 0.60f}; -float Diff_general_scalar[5] = {2.50f, 1.75f, 1.00f, 0.75f, 0.50f}; -float Diff_general_inv_scalar[5] = {0.50f, 0.75f, 1.00f, 1.75f, 2.50f}; -float Diff_shield_energy_scalar[5] = {2.25f, 1.5f, 1.0f, 0.75f, 0.5f}; -float Diff_ai_turret_speed[5] = {0.6f, 0.7f, 1.0f, 1.0f, 1.0f}; -float Diff_ai_min_fire_spread[5] = {.30f, .15f, 0.0f, 0.0f, 0.0f}; \ No newline at end of file +const float Diff_ai_dodge_percent[5] = {0.04f, 0.10f, 1.00f, 1.00f, 1.50f}; +const float Diff_ai_dodge_speed[5] = {0.20f, 0.30f, 1.00f, 1.25f, 1.50f}; +const float Diff_ai_speed[5] = {0.70f, 0.80f, 1.00f, 1.10f, 1.20f}; +const float Diff_ai_rotspeed[5] = {0.70f, 0.80f, 1.00f, 1.10f, 1.20f}; +const float Diff_ai_circle_dist[5] = {1.10f, 1.00f, 1.00f, 1.00f, 1.00f}; +const float Diff_ai_vis_dist[5] = {0.80f, 0.90f, 1.00f, 1.10f, 1.20f}; +const float Diff_player_damage[5] = {0.30f, 0.60f, 1.00f, 1.50f, 2.00f}; +const float Diff_ai_weapon_speed[5] = {0.50f, 0.75f, 1.00f, 1.20f, 1.40f}; +const float Diff_homing_strength[5] = {0.20f, 0.70f, 1.00f, 1.20f, 1.40f}; +const float Diff_robot_damage[5] = {2.75f, 1.50f, 1.00f, 0.80f, 0.60f}; +const float Diff_general_scalar[5] = {2.50f, 1.75f, 1.00f, 0.75f, 0.50f}; +const float Diff_general_inv_scalar[5] = {0.50f, 0.75f, 1.00f, 1.75f, 2.50f}; +const float Diff_shield_energy_scalar[5] = {2.25f, 1.5f, 1.0f, 0.75f, 0.5f}; +const float Diff_ai_turret_speed[5] = {0.6f, 0.7f, 1.0f, 1.0f, 1.0f}; +const float Diff_ai_min_fire_spread[5] = {.30f, .15f, 0.0f, 0.0f, 0.0f}; diff --git a/Descent3/difficulty.h b/Descent3/difficulty.h index 5f816e68..6c704ed8 100644 --- a/Descent3/difficulty.h +++ b/Descent3/difficulty.h @@ -29,19 +29,19 @@ extern ubyte ingame_difficulty; #define DIFF_LEVEL (((Game_mode & GM_MULTI)) ? Netgame.difficulty : ingame_difficulty) // #define DIFF_LEVEL (((Game_mode & GM_MULTI))?Netgame.difficulty:dCurrentPilotDifficulty()) -extern float Diff_ai_dodge_percent[5]; // -extern float Diff_ai_dodge_speed[5]; // -extern float Diff_ai_speed[5]; // -extern float Diff_ai_rotspeed[5]; // -extern float Diff_ai_circle_dist[5]; // -extern float Diff_ai_vis_dist[5]; // -extern float Diff_player_damage[5]; // -extern float Diff_ai_weapon_speed[5]; // -extern float Diff_homing_strength[5]; // -extern float Diff_robot_damage[5]; // -extern float Diff_general_scalar[5]; // Trainee = 2.50f HotShot = 1.0f -extern float Diff_general_inv_scalar[5]; // Trainee = 0.50f HotShot = 1.0f -extern float Diff_shield_energy_scalar[5]; -extern float Diff_ai_turret_speed[5]; -extern float Diff_ai_min_fire_spread[5]; +const extern float Diff_ai_dodge_percent[5]; // +const extern float Diff_ai_dodge_speed[5]; // +const extern float Diff_ai_speed[5]; // +const extern float Diff_ai_rotspeed[5]; // +const extern float Diff_ai_circle_dist[5]; // +const extern float Diff_ai_vis_dist[5]; // +const extern float Diff_player_damage[5]; // +const extern float Diff_ai_weapon_speed[5]; // +const extern float Diff_homing_strength[5]; // +const extern float Diff_robot_damage[5]; // +const extern float Diff_general_scalar[5]; // Trainee = 2.50f HotShot = 1.0f +const extern float Diff_general_inv_scalar[5]; // Trainee = 0.50f HotShot = 1.0f +const extern float Diff_shield_energy_scalar[5]; +const extern float Diff_ai_turret_speed[5]; +const extern float Diff_ai_min_fire_spread[5]; #endif diff --git a/Descent3/doorway.cpp b/Descent3/doorway.cpp index 29c69ce2..dd67e564 100644 --- a/Descent3/doorway.cpp +++ b/Descent3/doorway.cpp @@ -150,9 +150,10 @@ int Global_keys; // --------------------------------------------------------------------------- // Prototypes -void DoorwayOpen(room *rp); -void DoorwayClose(room *rp); -void DoorwayWait(room *rp); +// TODO: MTS: none of the following were found +// void DoorwayOpen(room *rp); +// void DoorwayClose(room *rp); +// void DoorwayWait(room *rp); object *GetDoorObject(room *rp); // --------------------------------------------------------------------------- diff --git a/Descent3/fireball.cpp b/Descent3/fireball.cpp index c9c93eff..b33f2d31 100644 --- a/Descent3/fireball.cpp +++ b/Descent3/fireball.cpp @@ -615,6 +615,12 @@ #include +static object *CreateSubobjectDebris(object *parent, int subobj_num, float explosion_mag, int death_flags); +static void DrawSmolderingObject(object *obj); +static int GetRandomExplosion(float size); +static void CreateBlueBlastRing(vector *pos, int index, float lifetime, float max_size, int roomnum, int objnum, + int force_up); + // If an objects size is bigger than this, we create size/threshold extra explosions #define EXTRA_EXPLOSION_THRESHOLD 15 fireball Fireballs[NUM_FIREBALLS] = { @@ -709,7 +715,7 @@ void InitFireballs() { } GameBitmaps[Fireballs[GRAY_SPARK_INDEX].bm_handle].flags |= BF_CHANGED; } -void DrawSmolderingObject(object *obj); + // Given an object, renders the representation of this fireball void DrawFireballObject(object *obj) { ASSERT(obj->type == OBJ_FIREBALL); @@ -855,6 +861,7 @@ int CreateFireball(vector *pos, int fireball_num, int roomnum, int realtype) { return objnum; } +// TODO: MTS: used only in this file. // Creates a fireball object with a custom texture/vclip int CreateCustomFireballObject(vector *pos, int fireball_num, int tex_handle, int roomnum) { int objnum; @@ -1199,7 +1206,7 @@ void DoDeathSpew(object *parent) { } } } -int GetRandomExplosion(float size); + // Creates a fireball vis effect for the specified object // The explosion size is based on the object size times the size_scale // The fireball type will be randomly selected based on the explosion size @@ -1504,7 +1511,6 @@ void DoDyingFrame(object *objp) { } } } -extern void SetShakeMagnitude(float delta); // Pulls every object near the gravity field into its center void DoGravityFieldEffect(object *obj) { float max_size = obj->ctype.blast_info.max_size; @@ -2020,11 +2026,13 @@ int CreateBlastRing(vector *pos, int index, float lifetime, float max_size, int return objnum; } +// TODO: MTS: only used in this file. // Creates a standard blast ring for an object int CreateObjectBlastRing(object *objp) { float ring_size = OBJECT_OUTSIDE(objp) ? (objp->size * 3) : objp->size; return CreateBlastRing(&objp->pos, BLAST_RING_INDEX, DAMAGE_RING_TIME, ring_size, objp->roomnum); } +// TODO: MTS: Not used? // Creates a smolding smoke to be drawn int CreateSmolderingObject(vector *pos, int index, float lifetime, float max_size, int roomnum) { int objnum; @@ -2050,6 +2058,7 @@ void DrawColoredDisk(vector *pos, float r, float g, float b, float inner_alpha, DrawColoredRing(pos, r, g, b, inner_alpha, outer_alpha, size, 0, saturate, lod); rend_SetZBufferWriteMask(1); } +// TODO: MTS: Not used? // Draws a glowing cone of light using a bitmap void DrawColoredGlow(vector *pos, float r, float g, float b, float size) { rend_SetTextureType(TT_LINEAR); @@ -2140,6 +2149,7 @@ void DrawColoredRing(vector *pos, float r, float g, float b, float inner_alpha, } } +// TODO: MTS: not used? // Draws a sphere with the appropriate texture. If texture=-1, then uses rgb as colors void DrawSphere(vector *pos, float r, float g, float b, float alpha, float size, int texture, ubyte saturate) { static vector sphere_vecs[16][16]; @@ -2222,7 +2232,8 @@ void DrawSphere(vector *pos, float r, float g, float b, float alpha, float size, rend_SetZBufferWriteMask(1); } #define BLAST_RING_ALPHA 1.0f -// Draws a blast ring +// TODO: MTS: only used in this file. +// Draws a blast ring void DrawBlastRingObject(object *obj) { vector inner_vecs[30], outer_vecs[30]; g3Point inner_points[30], outer_points[30]; @@ -2342,7 +2353,8 @@ void DoBlastRingEvent(int eventnum, void *data) { object *obj = (object *)data; CreateObjectBlastRing(obj); } -// Creates an explosion +// TODO: MTS: only used in this file. +// Creates an explosion void DoExplosionEvent(int eventnum, void *data) { float *vals = (float *)data; vector pos; @@ -2395,6 +2407,7 @@ int GetRandomExplosion(float size) { else return GetRandomMediumExplosion(); } +// TODO: MTS: only found in this file. // Returns a random medium sized explosion int GetRandomMediumExplosion() { int choices[] = {MED_EXPLOSION_INDEX, MED_EXPLOSION_INDEX2, MED_EXPLOSION_INDEX3}; @@ -2406,6 +2419,7 @@ int GetRandomSmallExplosion() { int pick = ps_rand() % 2; return (choices[pick]); } +// TODO: MTS: only found in this file. int GetRandomBillowingExplosion() { int choices[] = {BILLOWING_INDEX, MED_EXPLOSION_INDEX2}; int pick = ps_rand() % 2; diff --git a/Descent3/fireball.h b/Descent3/fireball.h index 65365a04..c54141c3 100644 --- a/Descent3/fireball.h +++ b/Descent3/fireball.h @@ -220,6 +220,9 @@ void MakeShockwave(object *explode_obj_ptr, int parent_handle); void DoConcussiveForce(object *explode_obj_ptr, int parent_handle, float player_scalar = 1); +// Creates a gravity field that sucks objects into it +extern int CreateGravityField(vector *pos, int roomnum, float size, float time, int parent_handle); + // Control code for explosions void DoExplosionFrame(object *obj); diff --git a/Descent3/game.h b/Descent3/game.h index 225b768f..30bad7e0 100644 --- a/Descent3/game.h +++ b/Descent3/game.h @@ -255,6 +255,8 @@ extern float force_field_bounce_multiplier[MAX_FORCE_FIELD_BOUNCE_TEXTURES]; extern bool Level_powerups_ignore_wind; +extern bool IsCheater; + #ifdef _DEBUG extern int Game_show_sphere; extern int Game_show_portal_vis_pnts; diff --git a/Descent3/gamecinematics.cpp b/Descent3/gamecinematics.cpp index 67bc29d6..d9a46203 100644 --- a/Descent3/gamecinematics.cpp +++ b/Descent3/gamecinematics.cpp @@ -285,25 +285,43 @@ typedef struct { } tCinematicDemoInfo; -void Cinematic_WriteDemoFileData(tCinematicDemoInfo *info); -bool Cinematic_StartCine(tGameCinematic *info, const char *text_string, int camera_objhandle); +static void Cinematic_WriteDemoFileData(tCinematicDemoInfo *info); +static bool Cinematic_StartCine(tGameCinematic *info, const char *text_string, int camera_objhandle); -void Cinematic_DrawText(void); -void Cinematic_DoEndTransition(void); -void Cinematic_DoStartTransition(void); +static void Cinematic_DrawText(void); +static void Cinematic_DoEndTransition(void); +static void Cinematic_DoStartTransition(void); bool Cinematic_inuse; -tGameCinematic Cinematic_fake_info; +static tGameCinematic Cinematic_fake_info; bool Cinematic_fake_queued = false; -int gc_fade_bmp_handle = BAD_BITMAP_HANDLE; -int gc_fadewhite_bmp_handle = BAD_BITMAP_HANDLE; -int gc_wacky_bmp_handle = BAD_BITMAP_HANDLE; -int gc_temp_bmp_handle = BAD_BITMAP_HANDLE; +static int gc_fade_bmp_handle = BAD_BITMAP_HANDLE; +static int gc_fadewhite_bmp_handle = BAD_BITMAP_HANDLE; +static int gc_wacky_bmp_handle = BAD_BITMAP_HANDLE; +static int gc_temp_bmp_handle = BAD_BITMAP_HANDLE; #define END_TRANSITION_TIME 1.0f -float Cine_GetPathTravelSpeed(int pathnum, float time); +static float Cine_GetPathTravelSpeed(int pathnum, float time); +static void Cinematic_PerformFake(void); +static void Cinematic_SetForFakeCinematic(tGameCinematic *info); +static inline void verify_percentranage(PercentageRange *range); +static inline int Cinematics_CreateCamera(void); +static inline void Cinematic_DeleteCamera(int objhandle); +static inline bool Cinematic_IsPlayerDead(void); +static bool Cinematic_IsKeyPressed(void); +static void CannedCinematicIntroCallback(int type); +static void CannedCinematic_Intro(int PathID, char *Text, int PlayerPath, float Seconds, int camera_handle); +static void CannedCinematicEndLevelCallback(int type); +static void CannedCinematic_EndLevelPath(int PathID, char *Text, int PlayerPath, float Seconds, int camera_handle); +static void CannedCinematic_EndLevelPoint(vector *pos, int room, char *Text, int PlayerPath, float Seconds, + int camera_handle); +static void CannedCinematicMovePlayerFadeCallback(int type); +static void CannedCinematic_MovePlayerFade(object *player, int room, vector *pos, matrix *orient, int camera_handle); +static void CannedCinematicLevelEndFadeWhiteCallback(int type); +static void CannedCinematic_LevelEndFadeWhite(int camera_handle, float time, char *text_to_display); +static void Cinematic_DoFakeCannedCinematics(tCannedCinematicInfo *info); // Returns the hud mode before cinematics tHUDMode Cinematic_GetOldHudMode(void) { return GameCinema.old_hudmode; } @@ -385,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) @@ -436,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; @@ -490,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); @@ -872,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))) { @@ -1798,7 +1816,7 @@ struct { float cinematic_time; bool should_thrust; } CannedCinematicEndLevel; -bool EndLevel(); +extern bool EndLevel(); void CannedCinematicEndLevelCallback(int type) { switch (type) { @@ -2190,18 +2208,18 @@ void Cinematic_StartCanned(tCannedCinematicInfo *info, int camera_handle) { //================================================== // Demo file support //================================================== -void mf_WriteInt(ubyte *buffer, int *pointer, int data); -void mf_WriteShort(ubyte *buffer, int *pointer, short data); -void mf_WriteByte(ubyte *buffer, int *pointer, ubyte data); -void mf_WriteFloat(ubyte *buffer, int *pointer, float data); -void mf_WriteBytes(ubyte *buffer, int *pointer, ubyte *data, int len); -void mf_WriteString(ubyte *buffer, int *pointer, const char *string); -int mf_ReadInt(ubyte *buffer, int *pointer); -short mf_ReadShort(ubyte *buffer, int *pointer); -ubyte mf_ReadByte(ubyte *buffer, int *pointer); -float mf_ReadFloat(ubyte *buffer, int *pointer); -void mf_ReadBytes(ubyte *buffer, int *pointer, ubyte *data, int len); -void mf_ReadString(ubyte *buffer, int *pointer, char *string); +static void mf_WriteInt(ubyte *buffer, int *pointer, int data); +static void mf_WriteShort(ubyte *buffer, int *pointer, short data); +static void mf_WriteByte(ubyte *buffer, int *pointer, ubyte data); +static void mf_WriteFloat(ubyte *buffer, int *pointer, float data); +static void mf_WriteBytes(ubyte *buffer, int *pointer, ubyte *data, int len); +static void mf_WriteString(ubyte *buffer, int *pointer, const char *string); +static int mf_ReadInt(ubyte *buffer, int *pointer); +static short mf_ReadShort(ubyte *buffer, int *pointer); +static ubyte mf_ReadByte(ubyte *buffer, int *pointer); +static float mf_ReadFloat(ubyte *buffer, int *pointer); +static void mf_ReadBytes(ubyte *buffer, int *pointer, ubyte *data, int len); +static void mf_ReadString(ubyte *buffer, int *pointer, char *string); void Cinematic_DoDemoFileData(ubyte *buffer) { int count = 0; diff --git a/Descent3/gamesequence.cpp b/Descent3/gamesequence.cpp index 44c587b9..842ffafc 100644 --- a/Descent3/gamesequence.cpp +++ b/Descent3/gamesequence.cpp @@ -1906,8 +1906,6 @@ void FlushDataCache() { /////////////////////////////////////////////////////////////////////////////// // Parameter: state - 1 = success, 0 = failure, -1 = abort -extern float Player_shields_saved_from_last_level; -extern float Player_energy_saved_from_last_level; void EndLevel(int state) { // tell IntelliVIBE VIBE_DoLevelEnd(); diff --git a/Descent3/gamesequence.h b/Descent3/gamesequence.h index 5bdcf8f4..8eb55634 100644 --- a/Descent3/gamesequence.h +++ b/Descent3/gamesequence.h @@ -148,6 +148,8 @@ typedef enum tGameState { // variables extern tGameState Game_state; extern int Game_interface_mode; // current interface mode of game (menu, game?) +extern int paged_in_count; +extern int paged_in_num; // functions // main sequencing code for game. run this to execute a game. diff --git a/Descent3/gametexture.cpp b/Descent3/gametexture.cpp index aafc6b9c..627d454b 100644 --- a/Descent3/gametexture.cpp +++ b/Descent3/gametexture.cpp @@ -283,12 +283,13 @@ #include "args.h" #include "mem.h" +// TODO: MTS: this is only used in this file. int Num_textures = 0; texture GameTextures[MAX_TEXTURES]; extern bool Mem_superlow_memory_mode; -int Total_memory_saved = 0; +static int Total_memory_saved = 0; void FreeAllTextures() { for (int i = 0; i < MAX_TEXTURES; i++) { diff --git a/Descent3/gauges.cpp b/Descent3/gauges.cpp index 27aba12c..6b17abeb 100644 --- a/Descent3/gauges.cpp +++ b/Descent3/gauges.cpp @@ -255,56 +255,59 @@ static float *Render_normalized_times; static bool Render_gauge_moving; // gauge is moving, but temporarily off. static bool Render_gauge_reset; // set this if gauges will be moving, but are still active +// TODO: MTS: function not found // loads all shield bitmaps into memory -void FreeShieldFrames(); +static void FreeShieldFrames(); +// TODO: MTS: function not found // loads all ship bitmaps into memory -void FreeShipFrames(); +static void FreeShipFrames(); // projects monitor coordinates to screen coordinates -void RotateMonitorPosition(tGauge *gauge); +static void RotateMonitorPosition(tGauge *gauge); +// TODO: MTS: function not found // renders the current inventory item name at the x,y position -void InventoryRenderGauge(int x, int y); +static void InventoryRenderGauge(int x, int y); // renders the primary monitor gauge -void RenderPrimaryMonitor(tGauge *gauge, bool modified); +static void RenderPrimaryMonitor(tGauge *gauge, bool modified); // renders the secondary monitor gauge -void RenderSecondaryMonitor(tGauge *gauge, bool modified); +static void RenderSecondaryMonitor(tGauge *gauge, bool modified); // renders the shield gauge monitor -void RenderShieldMonitor(tGauge *gauge, bool modified); +static void RenderShieldMonitor(tGauge *gauge, bool modified); // renders the ship gauge monitor -void RenderShipMonitor(tGauge *gauge, bool modified); +static void RenderShipMonitor(tGauge *gauge, bool modified); // renders the ship gauge monitor -void RenderEnergyMonitor(tGauge *gauge, int orient, bool modified); +static void RenderEnergyMonitor(tGauge *gauge, int orient, bool modified); // renders the ship gauge monitor -void RenderAfterburnMonitor(tGauge *gauge, bool modified); +static void RenderAfterburnMonitor(tGauge *gauge, bool modified); // renders a monitor style quad -void DrawGaugeMonitor(g3Point *pts, int bm, float brightness, float *alphas); +static void DrawGaugeMonitor(g3Point *pts, int bm, float brightness, float *alphas); // renders a square texture onto the screen. -void DrawGaugeQuad(g3Point *pts, int bm, float u0, float v0, float u1, float v1, ubyte alpha, bool saturate); +static void DrawGaugeQuad(g3Point *pts, int bm, float u0, float v0, float u1, float v1, ubyte alpha, bool saturate); // renders a square texture onto the screen. -void DrawGaugeQuad(g3Point *pts, int bm, ubyte alpha = 255, bool saturate = false); +static void DrawGaugeQuad(g3Point *pts, int bm, ubyte alpha = 255, bool saturate = false); // renders a flat poly onto the screen with given color -void DrawGaugeQuadFlat(g3Point *pts, float r, float g, float b, ubyte alpha); +static void DrawGaugeQuadFlat(g3Point *pts, float r, float g, float b, ubyte alpha); // renders a flat poly onto the screen with 4 colors (for each vertex) -void DrawGaugeQuadFlat(g3Point *pts, float *r, float *g, float *b, ubyte alpha); +static void DrawGaugeQuadFlat(g3Point *pts, float *r, float *g, float *b, ubyte alpha); // correctly orders monitor vertices based off of UVs -int GetFirstVert(bsp_info *sm); +static int GetFirstVert(bsp_info *sm); // tells what gauge index is the gauge stat item. -inline int GAUGE_INDEX(tStatMask mask) { +static inline int GAUGE_INDEX(tStatMask mask) { int i; for (i = 0; i < NUM_GAUGES; i++) @@ -498,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); diff --git a/Descent3/help.cpp b/Descent3/help.cpp index 05032c87..d736edc4 100644 --- a/Descent3/help.cpp +++ b/Descent3/help.cpp @@ -143,51 +143,51 @@ #include "stringtable.h" #define TITLETEXT TXT_HELP -int HelpText[] = {TXI_ESC, - TXI_HLPQUIT, +static const int HelpText[] = {TXI_ESC, + TXI_HLPQUIT, #ifndef DEMO // Do Not include in the PC Gamer Demo - TXI_HLPALTF2, - TXI_HLPSAVEGAME, - TXI_HLPALTF3, - TXI_HLPLOADGAME, + TXI_HLPALTF2, + TXI_HLPSAVEGAME, + TXI_HLPALTF3, + TXI_HLPLOADGAME, #endif - TXI_F2, - TXI_HLPCONFIG, - TXI_F3, - TXI_HLPCOCKPIT, - TXI_HLPF4, - TXI_HLPGUIDEBOT, - TXI_F5, - TXI_TOGGLEDEMO, - TXI_F6, - TXI_MLTMENU, - TXI_F8, - TXI_HLP_MULTIMSG, - TXI_F9, - TXI_HLP_QUIKSAVE, - TXI_F12, - TXI_DROPSMARKER, - TXI_SHFTTAB, - TXI_TCMM, - TXI_HLPPAUSE, - TXI_HLPPAUSEDESC, - TXI_PLUSMINUS, - TXI_HLPSCRNSIZE, - TXI_HLPPRNTSCRN, - TXI_HLPTAKESCRNSHT, - TXI_HLP1_5, - TXI_HLPSELPRIM, - TXI_HLP6_0, - TXI_HLPSELSECN, - TXI_SF1, - TXI_HLPREARLEFT, - TXI_SF2, - TXI_HLPREARRIGHT, - TXI_SHFTF8, - TXI_DISPLAYGAMEMSGCONSOLE, - TXI_SHFTF9, - TXI_DISPLAYHUDMSGCONSOLE, - 0}; + TXI_F2, + TXI_HLPCONFIG, + TXI_F3, + TXI_HLPCOCKPIT, + TXI_HLPF4, + TXI_HLPGUIDEBOT, + TXI_F5, + TXI_TOGGLEDEMO, + TXI_F6, + TXI_MLTMENU, + TXI_F8, + TXI_HLP_MULTIMSG, + TXI_F9, + TXI_HLP_QUIKSAVE, + TXI_F12, + TXI_DROPSMARKER, + TXI_SHFTTAB, + TXI_TCMM, + TXI_HLPPAUSE, + TXI_HLPPAUSEDESC, + TXI_PLUSMINUS, + TXI_HLPSCRNSIZE, + TXI_HLPPRNTSCRN, + TXI_HLPTAKESCRNSHT, + TXI_HLP1_5, + TXI_HLPSELPRIM, + TXI_HLP6_0, + TXI_HLPSELSECN, + TXI_SF1, + TXI_HLPREARLEFT, + TXI_SF2, + TXI_HLPREARRIGHT, + TXI_SHFTF8, + TXI_DISPLAYGAMEMSGCONSOLE, + TXI_SHFTF9, + TXI_DISPLAYHUDMSGCONSOLE, + 0}; #define HELP_X_KEY_POS 60 #define HELP_X_DESC_POS 160 diff --git a/Descent3/hotspotmap.cpp b/Descent3/hotspotmap.cpp index fafd496a..74c66425 100644 --- a/Descent3/hotspotmap.cpp +++ b/Descent3/hotspotmap.cpp @@ -114,7 +114,9 @@ #include "bitmap.h" #include "manage.h" -void makecorner(int corner_bmp, int back_bmp, const char *tmap, int l, int t, int r, int b); +static void makecorner(int corner_bmp, int back_bmp, const char *tmap, int l, int t, int r, int b); +static int CreateHotSpotMap(const char *map, int width, int height, hotspotmap_t *hsmap); +static void CreateWindowMap(const char *map, int width, int height, windowmap_t *wndmap); // just like the old bm_tga_translate_pixel function, but it stores the alpha in the alpha_value parameter ushort menutga_translate_pixel(int pixel, char *alpha_value) { @@ -504,6 +506,7 @@ void CreateWindowMap(const char *map, int width, int height, windowmap_t *wndmap } } +// TODO: MTS: only used in this file // Loads a tga or ogf file into a bitmap...returns handle to bm or -1 on error, and fills in the alphamap int menutga_alloc_file(const char *name, char *hsmap[1], int *w, int *h) { ubyte image_id_len, color_map_type, image_type, pixsize, descriptor; @@ -589,6 +592,7 @@ int menutga_alloc_file(const char *name, char *hsmap[1], int *w, int *h) { return (n); } +// TODO: MTS: only used in this file // Given a filename and a hotspotmap structure, it saves it to disk (.HSM) void menutga_SaveHotSpotMap(const char *filename, hotspotmap_t *hsmap, windowmap_t *wndmap) { CFILE *file; @@ -911,6 +915,7 @@ bool menutga_ConvertTGAtoHSM(const char *fpath) { return true; } +// TODO: MTS: Unused? // Given a hotspotmap structure, it draws the pretty hotspot map to the screen (blue areas are the hotspots) void DisplayHotSpots(hotspotmap_t *hsmap, windowmap_t *wndmap) { //@@ grSurface *cursurf; @@ -965,6 +970,7 @@ void DisplayHotSpots(hotspotmap_t *hsmap, windowmap_t *wndmap) { //@@ Game_screen->flip(); } +// TODO: MTS: only used in this file // Writes a hotspotmap_t struct to a text file void ExportHotSpot(const char *filename, hotspotmap_t *hsmap) { CFILE *file; diff --git a/Descent3/hud.cpp b/Descent3/hud.cpp index 72f15890..62274866 100644 --- a/Descent3/hud.cpp +++ b/Descent3/hud.cpp @@ -480,25 +480,22 @@ static tHUDItem HUD_array[MAX_HUD_ITEMS]; struct sHUDResources HUD_resources; // initializes non configurable hud items. -void InitDefaultHUDItems(); +static void InitDefaultHUDItems(); // initializes items based off their type (information, etc.) -void InitHUDItem(int new_item, tHUDItem *item); +static void InitHUDItem(int new_item, tHUDItem *item); // iterate through entire hud item list to draw. -void RenderHUDItems(tStatMask stat_mask); - -// frees up reticle bitmaps -void FreeReticle(); +static void RenderHUDItems(tStatMask stat_mask); // renders the reticle -void RenderReticle(); +static void RenderReticle(); // renders missile reticle -void RenderMissileReticle(); +static void RenderMissileReticle(); // renders zoom reticle -void RenderZoomReticle(); +static void RenderZoomReticle(); // hack! @@ -1340,8 +1337,6 @@ void RenderAuxHUDFrame() { HUD_msg_con.Draw(); } -extern const char *cfg_binding_text(ct_type ctype, ubyte ctrl, ubyte binding); - char *GetControllerBindingText(int fidcont) { static char *cont_bind_txt; ct_type ctype[CTLBINDS_PER_FUNC]; @@ -1921,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; @@ -1957,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; diff --git a/Descent3/hud.h b/Descent3/hud.h index 26e1198b..307411fc 100644 --- a/Descent3/hud.h +++ b/Descent3/hud.h @@ -332,6 +332,8 @@ extern tStatMask Hud_stat_mask; extern float Hud_aspect_x; extern float Hud_aspect_y; +extern bool Hud_show_controls; + // normalize hud coordinates #define HUD_X(_x) ((float)(_x) * Hud_aspect_x) #define HUD_Y(_y) ((float)(_y) * Hud_aspect_y) @@ -392,6 +394,9 @@ void InitReticle(int primary_slots, int secondary_slots); // resets reticle to current weapon. void ResetReticle(); +// frees up reticle bitmaps +void FreeReticle(); + // Flags for persistent HUD messages #define HPF_FADEOUT 1 // message fades out when done #define HPF_FREESPACE_DRAW 2 // message draws with the FreeSpace briefing effect diff --git a/Descent3/huddisplay.cpp b/Descent3/huddisplay.cpp index d91a3b90..e038415c 100644 --- a/Descent3/huddisplay.cpp +++ b/Descent3/huddisplay.cpp @@ -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 @@ -244,34 +244,34 @@ // Data // renders the description for the current inventory item -void RenderHUDInventory(tHUDItem *item); +static void RenderHUDInventory(tHUDItem *item); // renders the shield rating for the ship -void RenderHUDShieldValue(tHUDItem *item); +static void RenderHUDShieldValue(tHUDItem *item); // renders the energy rating for the ship -void RenderHUDEnergyValue(tHUDItem *item); +static void RenderHUDEnergyValue(tHUDItem *item); // draws the afterburner hud gauge. -void RenderHUDAfterburner(tHUDItem *item); +static void RenderHUDAfterburner(tHUDItem *item); // draws the primary weapon current in. -void RenderHUDPrimary(tHUDItem *item); +static void RenderHUDPrimary(tHUDItem *item); // draw secondary weapon current in. -void RenderHUDSecondary(tHUDItem *item); +static void RenderHUDSecondary(tHUDItem *item); // renders ship status. -void RenderHUDShipStatus(tHUDItem *item); +static void RenderHUDShipStatus(tHUDItem *item); // renders warnings like system failures or missile locks. -void RenderHUDWarnings(tHUDItem *item); +static void RenderHUDWarnings(tHUDItem *item); // render hud countermeasures -void RenderHUDCountermeasures(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; @@ -285,7 +285,7 @@ inline int get_weapon_icon(int player, int type) { return HUD_resources.wpn_bmp; } -void RenderHUDTextFlagsNoFormat(int flags, ddgr_color col, ubyte alpha, int sat_count, int x, int y, const char *str); +static void RenderHUDTextFlagsNoFormat(int flags, ddgr_color col, ubyte alpha, int sat_count, int x, int y, const char *str); ////////////////////////////////////////////////////////////////////////////// // Hud item display routines. diff --git a/Descent3/hudmessage.cpp b/Descent3/hudmessage.cpp index c079b506..03de840e 100644 --- a/Descent3/hudmessage.cpp +++ b/Descent3/hudmessage.cpp @@ -368,14 +368,14 @@ int Doing_input_message = HUD_MESSAGE_NONE; int HudInputMessageLen = 0; static tDirtyRect HUD_inmsg_dirty_rect; -char HUD_messages[MAX_HUD_MESSAGES][HUD_MESSAGE_LENGTH]; -int HUD_message_type[MAX_HUD_MESSAGES]; -ddgr_color HUD_message_color[MAX_HUD_MESSAGES]; +static char HUD_messages[MAX_HUD_MESSAGES][HUD_MESSAGE_LENGTH]; +static int HUD_message_type[MAX_HUD_MESSAGES]; +static ddgr_color HUD_message_color[MAX_HUD_MESSAGES]; int Num_hud_messages = 0; -int Hud_scroll_offset = 0; +static int Hud_scroll_offset = 0; static tDirtyRect HUD_msg_dirty_rect; -float Hud_timer = 0.0f; +static float Hud_timer = 0.0f; static ubyte Hud_persistent_msg_id = HUD_INVALID_ID; static float Hud_persistent_msg_timer = 0.0f; @@ -405,17 +405,17 @@ static bool Hud_messages_paused = false; #define GAME_MSGCON_Y ((Max_window_h - GAME_MSGCON_H) / 2) // This function takes a HUD messages, ensures it isn't too long, and if it is, it correctly fixes it -void CorrectHudMessage(char *str); +static void CorrectHudMessage(char *str); /////////////////////////////////////////////////////////////////////////////// // Functions // prints a string onto the debug consle -void AddMessageToRollback(char *msg) { HUD_msg_list.add(msg); } +static void AddMessageToRollback(char *msg) { HUD_msg_list.add(msg); } // Adds a single line to the hud message list // Returns true if message added, or false if message not (because the previous message was the same) -bool AddLineToHUDMessages(char *temp_message, ddgr_color color = -1); +static bool AddLineToHUDMessages(char *temp_message, ddgr_color color = -1); bool AddLineToHUDMessages(char *temp_message, ddgr_color color) { if (Num_hud_messages > 0 && !strcmp(temp_message, HUD_messages[Num_hud_messages - 1])) return 0; // this is the same message as before, don't print it twice! @@ -464,7 +464,7 @@ bool AddLineToHUDMessages(char *temp_message, ddgr_color color) { // Adds line, splitting if too long // Returns true if line added -bool AddMultipleLinesToHUDMessages(char *temp_message, ddgr_color color = -1); +static bool AddMultipleLinesToHUDMessages(char *temp_message, ddgr_color color = -1); bool AddMultipleLinesToHUDMessages(char *temp_message, ddgr_color color) { char ourstr[HUD_MESSAGE_LENGTH * 2]; char *p; diff --git a/Descent3/init.cpp b/Descent3/init.cpp index cbd1968b..49597f19 100644 --- a/Descent3/init.cpp +++ b/Descent3/init.cpp @@ -1017,10 +1017,16 @@ bool Running_editor = false; // didn't we have a variable like this somewhere static bool Init_in_editor = false; // used to update load bar. -void SetInitMessageLength(const char *c, float amount); // portion of total bar to fill (0 to 1) -void UpdateInitMessage(float amount); // amount is 0 to 1 -void SetupTempDirectory(void); -void DeleteTempFiles(void); +static void SetInitMessageLength(const char *c, float amount); // portion of total bar to fill (0 to 1) +extern void UpdateInitMessage(float amount); // amount is 0 to 1 +static void SetupTempDirectory(void); +static void DeleteTempFiles(void); +static void PreGameCdCheck(); +static void InitIOSystems(bool editor); +static void InitStringTable(); +static void InitGraphics(bool editor); +static void InitGameSystems(bool editor); +static void InitDedicatedServer(); #define TEMPBUFFERSIZE 256 @@ -1045,8 +1051,8 @@ extern int Use_file_xfer; extern bool Mem_superlow_memory_mode; -const float kDefaultMouselookSensitivity = 9.102f; -const float kAnglesPerDegree = 65536.0f / 360.0f; +static const float kDefaultMouselookSensitivity = 9.102f; +static const float kAnglesPerDegree = 65536.0f / 360.0f; int CD_inserted = 0; float Mouselook_sensitivity = kAnglesPerDegree * kDefaultMouselookSensitivity; float Mouse_sensitivity = 1.0f; @@ -1352,7 +1358,6 @@ void LoadGameSettings() { Render_preferred_state.gamma = 1.5; PreferredRenderer = RENDERER_NONE; - Sound_system.SetLLSoundQuantity(MIN_SOUNDS_MIXED + (MAX_SOUNDS_MIXED - MIN_SOUNDS_MIXED) / 2); D3MusicSetVolume(0.5f); Detail_settings.Pixel_error = 8.0; @@ -1546,9 +1551,9 @@ void LoadGameSettings() { typedef struct { const char *wildcard; } tTempFileInfo; -tTempFileInfo temp_file_wildcards[] = {{"d3s*.tmp"}, {"d3m*.tmp"}, {"d3o*.tmp"}, - {"d3c*.tmp"}, {"d3t*.tmp"}, {"d3i*.tmp"}}; -int num_temp_file_wildcards = sizeof(temp_file_wildcards) / sizeof(tTempFileInfo); +static const tTempFileInfo temp_file_wildcards[] = {{"d3s*.tmp"}, {"d3m*.tmp"}, {"d3o*.tmp"}, + {"d3c*.tmp"}, {"d3t*.tmp"}, {"d3i*.tmp"}}; +static const int num_temp_file_wildcards = sizeof(temp_file_wildcards) / sizeof(tTempFileInfo); /* I/O systems initialization @@ -1647,14 +1652,14 @@ void InitIOSystems(bool editor) { sys_hid = cf_OpenLibrary(fullname); #endif #endif - + // JC: Steam release uses extra1.hog instead of extra.hog, so try loading it first // Open this file if it's present for stuff we might add later ddio_MakePath(fullname, LocalD3Dir, "extra1.hog", NULL); extra_hid = cf_OpenLibrary(fullname); if (extra_hid == 0) { - ddio_MakePath(fullname, LocalD3Dir, "extra.hog", NULL); - extra_hid = cf_OpenLibrary(fullname); + ddio_MakePath(fullname, LocalD3Dir, "extra.hog", NULL); + extra_hid = cf_OpenLibrary(fullname); } // JC: Steam release uses extra.hog instead of merc.hog, so try loading it last (so we don't conflict with the above) @@ -1662,8 +1667,8 @@ void InitIOSystems(bool editor) { ddio_MakePath(fullname, LocalD3Dir, "merc.hog", NULL); merc_hid = cf_OpenLibrary(fullname); if (merc_hid == 0) { - ddio_MakePath(fullname, LocalD3Dir, "extra.hog", NULL); - merc_hid = cf_OpenLibrary(fullname); + ddio_MakePath(fullname, LocalD3Dir, "extra.hog", NULL); + merc_hid = cf_OpenLibrary(fullname); } // Open this for extra 1.3 code (Black Pyro, etc) @@ -1710,9 +1715,7 @@ void InitIOSystems(bool editor) { } // Returns true if Mercenary is installed (inits the Black Pyro and Red GB) -bool MercInstalled() { - return merc_hid > 0; -} +bool MercInstalled() { return merc_hid > 0; } extern int Num_languages; void InitStringTable() { @@ -2066,7 +2069,6 @@ void InitD3Systems1(bool editor) { // Initialize a random seed. ps_srand(time(nullptr)); - // This function has to be done before any sound stuff is called InitSounds(); @@ -2325,8 +2327,7 @@ void DeleteTempFiles(void) { if (ddio_FindFileStart(temp_file_wildcards[i].wildcard, filename)) { do { ddio_DeleteFile(filename); - } - while (ddio_FindNextFile(filename)); + } while (ddio_FindNextFile(filename)); } ddio_FindFileClose(); } @@ -2349,6 +2350,7 @@ static bool Init_ui_cursor_visible; static bool Init_was_game_paused = false; static pilot Init_old_pilot; +// TODO: MTS: Unused in project void ShutdownD3() { if (!Init_systems_init) return; @@ -2392,6 +2394,7 @@ void ShutdownD3() { ddio_Close(); } +// TODO: MTS: unused in project // This function restarts all game systems void RestartD3() { ddio_init_info io_info; diff --git a/Descent3/lighting.cpp b/Descent3/lighting.cpp index d67d4926..61931202 100644 --- a/Descent3/lighting.cpp +++ b/Descent3/lighting.cpp @@ -64,33 +64,47 @@ typedef struct { float Specular_tables[3][MAX_SPECULAR_INCREMENTS]; -ushort *Dynamic_lightmap_memory = NULL; -float Light_component_scalar[32]; +static ushort *Dynamic_lightmap_memory = NULL; +static float Light_component_scalar[32]; float Ubyte_to_float[256]; static ubyte Lmi_spoken_for[MAX_LIGHTMAP_INFOS / 8]; -dynamic_lightmap *Dynamic_lightmaps; -dynamic_face Dynamic_face_list[MAX_DYNAMIC_FACES]; -ushort Specular_face_list[MAX_DYNAMIC_FACES]; -volume_object Dynamic_volume_object_list[MAX_VOLUME_OBJECTS]; -dynamic_cell Dynamic_cell_list[MAX_DYNAMIC_CELLS]; -int Specular_maps[NUM_DYNAMIC_CLASSES]; +static dynamic_lightmap *Dynamic_lightmaps; +static dynamic_face Dynamic_face_list[MAX_DYNAMIC_FACES]; +static ushort Specular_face_list[MAX_DYNAMIC_FACES]; +static volume_object Dynamic_volume_object_list[MAX_VOLUME_OBJECTS]; +static dynamic_cell Dynamic_cell_list[MAX_DYNAMIC_CELLS]; +static int Specular_maps[NUM_DYNAMIC_CLASSES]; -ushort Edges_to_blend[MAX_DYNAMIC_LIGHTMAPS]; -int Num_edges_to_blend = 0; +static ushort Edges_to_blend[MAX_DYNAMIC_LIGHTMAPS]; +static int Num_edges_to_blend = 0; -int Num_specular_faces = 0; -int Num_dynamic_faces = 0; -int Num_dynamic_lightmaps = 0; -int Cur_dynamic_mem_ptr = 0; -int Num_volume_objects = 0; -int Num_dynamic_cells = 0; -int Num_destroyed_lights_this_frame = 0; +static int Num_specular_faces = 0; +static int Num_dynamic_faces = 0; +static int Num_dynamic_lightmaps = 0; +static int Cur_dynamic_mem_ptr = 0; +static int Num_volume_objects = 0; +static int Num_dynamic_cells = 0; +static int Num_destroyed_lights_this_frame = 0; #define MAX_DESTROYED_LIGHTS_PER_FRAME 20 -int Destroyed_light_rooms_this_frame[MAX_DESTROYED_LIGHTS_PER_FRAME]; -int Destroyed_light_faces_this_frame[MAX_DESTROYED_LIGHTS_PER_FRAME]; +static int Destroyed_light_rooms_this_frame[MAX_DESTROYED_LIGHTS_PER_FRAME]; +static int Destroyed_light_faces_this_frame[MAX_DESTROYED_LIGHTS_PER_FRAME]; + +static void FreeLighting(); +static int GetFreeDynamicLightmap(int w, int h); +static void BlendLightingEdges(lightmap_info *lmi_ptr); +static void ApplyLightingToExternalRoom(vector *pos, int roomnum, float light_dist, float red_scale, float green_scale, + float blue_scale, vector *light_direction, float dot_range); +static void StartLightingInstance(vector *pos, matrix *orient); +static void DoneLightingInstance(); +static void ApplyLightingToSubmodel(object *obj, poly_model *pm, bsp_info *sm, float light_dist, float red_scale, + float green_scale, float blue_scale, float dot_range); +static void ApplyVolumeLightToObject(vector *pos, object *obj, float light_dist, float red_scale, float green_scale, + float blue_scale, vector *light_direction, float dot_range); +static void ApplyLightingToObjects(vector *pos, int roomnum, float light_dist, float red_scale, float green_scale, + float blue_scale, vector *light_direction, float dot_range); // Frees memory used by dynamic light structures void FreeLighting() { @@ -1589,6 +1603,7 @@ void ApplyLightingToTerrain(vector *pos, int cellnum, float light_dist, float re } } +// TODO: MTS: Unused? // Sets pulse parameters for an entire room void SetRoomPulse(room *rp, ubyte pulse_time, ubyte pulse_offset) { ASSERT(rp->used); @@ -1597,6 +1612,7 @@ void SetRoomPulse(room *rp, ubyte pulse_time, ubyte pulse_offset) { rp->pulse_offset = pulse_offset; } +// TODO: MTS: Unused? // Returns the total number of bytes needed for volume lighting in this room int GetVolumeSizeOfRoom(room *rp, int *w, int *h, int *d) { int width = ((rp->max_xyz.x - rp->min_xyz.x) / VOLUME_SPACING) + 1; @@ -2206,6 +2222,7 @@ void DestroyLight(int roomnum, int facenum) { } } +// TODO: MTS: unused? // Adds to our list of destroyable lights that got destroyed this frame void AddToDestroyableLightList(int roomnum, int facenum) { if (Num_destroyed_lights_this_frame >= MAX_DESTROYED_LIGHTS_PER_FRAME) { diff --git a/Descent3/lightmap_info.cpp b/Descent3/lightmap_info.cpp index 9019fa8c..457b64b3 100644 --- a/Descent3/lightmap_info.cpp +++ b/Descent3/lightmap_info.cpp @@ -35,6 +35,8 @@ lightmap_info *LightmapInfo = NULL; static ushort *Free_lmi_list = NULL; +static void CloseLightmapInfos(); + void CloseLightmapInfos() { bool final_lightmap = true; @@ -191,6 +193,7 @@ int lmi_h(int handle) { return (LightmapInfo[handle].height); } +// TODO: MTS: unused? // Softens the edges of lightmaps so there are fewer artifaces void ShadeLightmapInfoEdges(int type) { int i; @@ -322,6 +325,7 @@ void ShadeLightmapInfoEdges(int type) { } } +// TODO: MTS: unused? // Blurs the lightmaps so a dithering pattern is less noticeable void BlurLightmapInfos(int type) { int i; diff --git a/Descent3/lnxmain.cpp b/Descent3/lnxmain.cpp index 346fe300..fa017d1b 100644 --- a/Descent3/lnxmain.cpp +++ b/Descent3/lnxmain.cpp @@ -528,8 +528,8 @@ int main(int argc, char *argv[]) { if (FindArg("-game_checksum")) { extern tOSIRISModuleInit Osiris_module_init; - void Osiris_CreateModuleInitStruct(tOSIRISModuleInit * st); - unsigned int Osiris_CreateGameChecksum(void); + extern void Osiris_CreateModuleInitStruct(tOSIRISModuleInit * st); + extern unsigned int Osiris_CreateGameChecksum(void); Osiris_CreateModuleInitStruct(&Osiris_module_init); unsigned int checksum = Osiris_CreateGameChecksum(); diff --git a/Descent3/loadstate.cpp b/Descent3/loadstate.cpp index be1a4b62..2d946d36 100644 --- a/Descent3/loadstate.cpp +++ b/Descent3/loadstate.cpp @@ -219,11 +219,12 @@ #include -void PageInAllData(); +extern void PageInAllData(); // dynamically allocated to be efficient (only needed during save/load) -int LGSSnapshot(CFILE *fp); +static int LGSSnapshot(CFILE *fp); +static void IncreaseRestoreCount(const char *file); int Times_game_restored = 0; // static gs_tables *gs_Xlates = NULL; @@ -614,6 +615,7 @@ int LGSRooms(CFILE *fp) { return retval; } +// TODO: MTS: unused? // loads in and sets these events int LGSEvents(CFILE *fp) { int retval = LGS_OK; diff --git a/Descent3/menu.cpp b/Descent3/menu.cpp index 9cca4e89..a8a4e619 100644 --- a/Descent3/menu.cpp +++ b/Descent3/menu.cpp @@ -710,7 +710,6 @@ bool MenuNewGame(); extern bool Mem_quick_exit; bool IsRestoredGame = false; ////////////////////////////////////////////////////////////////////////////// -extern bool IsCheater; extern bool Demo_looping; extern bool Game_gauge_do_time_test; extern char Game_gauge_usefile[_MAX_PATH]; @@ -1075,7 +1074,7 @@ bool ProcessCommandLine() { #define UID_MSNLB 100 #define UID_MSNINFO 0x1000 #define TRAINING_MISSION_NAME "Pilot Training" -inline int count_missions(const char *pathname, const char *wildcard) { +static inline int count_missions(const char *pathname, const char *wildcard) { int c = 0; char fullpath[_MAX_PATH]; char filename[PSPATHNAME_LEN]; @@ -1107,8 +1106,8 @@ inline int count_missions(const char *pathname, const char *wildcard) { } return c; } -inline int generate_mission_listbox(newuiListBox *lb, int n_maxfiles, char **filelist, const char *pathname, - const char *wildcard) { +static inline int generate_mission_listbox(newuiListBox *lb, int n_maxfiles, char **filelist, const char *pathname, + const char *wildcard) { int c = 0; char fullpath[_MAX_PATH]; char filename[PSPATHNAME_LEN]; diff --git a/Descent3/multi.h b/Descent3/multi.h index 3f169c39..f6a4c2c5 100644 --- a/Descent3/multi.h +++ b/Descent3/multi.h @@ -701,7 +701,7 @@ typedef struct { short multi_matrix[9]; } multi_orientation; -inline void MultiMatrixMakeEndianFriendly(multi_orientation *mmat) { +static inline void MultiMatrixMakeEndianFriendly(multi_orientation *mmat) { for (int i = 0; i < 9; i++) { mmat->multi_matrix[i] = INTEL_SHORT(mmat->multi_matrix[i]); } diff --git a/Descent3/multisafe.cpp b/Descent3/multisafe.cpp index 8070f76c..562b2a19 100644 --- a/Descent3/multisafe.cpp +++ b/Descent3/multisafe.cpp @@ -719,7 +719,7 @@ object *VALIDATE_OBJECT(int handle) { } return objp; } -extern bool Hud_show_controls; + // Gets a value for the calling party void msafe_GetValue(int type, msafe_struct *mstruct) { object *objp; diff --git a/Descent3/newui_core.cpp b/Descent3/newui_core.cpp index 899f39a0..6d5321ca 100644 --- a/Descent3/newui_core.cpp +++ b/Descent3/newui_core.cpp @@ -496,19 +496,19 @@ private: 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); } diff --git a/Descent3/object.h b/Descent3/object.h index 39251513..9c3cb0cc 100644 --- a/Descent3/object.h +++ b/Descent3/object.h @@ -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); diff --git a/Descent3/osiris_dll.h b/Descent3/osiris_dll.h index dd9505a4..c9b84d5f 100644 --- a/Descent3/osiris_dll.h +++ b/Descent3/osiris_dll.h @@ -119,26 +119,27 @@ #include "cfile.h" extern uint Osiris_game_checksum; +extern tOSIRISModuleInit Osiris_module_init; // Osiris_InitModuleLoader // Purpose: // Initializes the OSIRIS module loader and handling system -void Osiris_InitModuleLoader(void); +extern void Osiris_InitModuleLoader(void); // Osiris_FreeModule // Purpose: // Removes a currently loaded module from the OSIRIS system -void Osiris_FreeModule(int id); +extern void Osiris_FreeModule(int id); // Osiris_ShutdownModuleLoader // Purpose: // Closes down the OSIRIS module loader and handling system -void Osiris_ShutdownModuleLoader(void); +extern void Osiris_ShutdownModuleLoader(void); // Osiris_FindLoadedModule // Purpose: // Given the name of a module, it returns the id of a loaded OSIRIS module. -1 if it isn't loaded. -int Osiris_FindLoadedModule(char *filename); +extern int Osiris_FindLoadedModule(char *filename); // Osiris_LoadLevelModule // Purpose: @@ -147,14 +148,14 @@ int Osiris_FindLoadedModule(char *filename); // before calling this function, it will return the id to where the module is, and will not reload // the module. Returns -1 if the module does not exist. Returns -2 if the module couldn't initialize. // Returns -3 if the module is not a level module. Returns -4 if no module slots are available. -int Osiris_LoadLevelModule(char *module_name); +extern int Osiris_LoadLevelModule(char *module_name); // Osiris_UnloadLevelModule // Purpose: // Instead of saving the handle returned from Osiris_LoadLevelModule() and calling // Osiris_UnloadModule() with that handle, you can just call this, instead of the call // to Osiris_UnloadModule(). -void Osiris_UnloadLevelModule(void); +extern void Osiris_UnloadLevelModule(void); // Osiris_LoadGameModule // Purpose: @@ -163,13 +164,13 @@ void Osiris_UnloadLevelModule(void); // before calling this function, it will return the id to where the module is, and will not reload // the module. Returns -1 if the module does not exist. Returns -2 if the module couldn't initialize. // Returns -3 if the module is not a game module. Returns -4 if no module slots are available. -int Osiris_LoadGameModule(char *module_name); +extern int Osiris_LoadGameModule(char *module_name); // Osiris_UnloadModule // Purpose: // Given a module id, it will decrement the reference count to that module by one. If the reference // count becomes zero, the module will be unloaded from memory. -void Osiris_UnloadModule(int module_id); +extern void Osiris_UnloadModule(int module_id); // Osiris_LoadMissionModule // Purpose: @@ -180,14 +181,14 @@ void Osiris_UnloadModule(int module_id); // Returns -3 if the module is not a game module. Returns -4 if no module slots are available. // This technically doesn't load a mission module, as it should already be loaded by // Descent 3 prior. -int Osiris_LoadMissionModule(module *module_handle, const char *filename); +extern int Osiris_LoadMissionModule(module *module_handle, const char *filename); // Osiris_UnloadMissionModule // Purpose: // Instead of saving the handle returned from Osiris_LoadMissionModule() and calling // Osiris_UnloadModule() with that handle, you can just call this, instead of the call // to Osiris_UnloadModule(). -void Osiris_UnloadMissionModule(void); +extern void Osiris_UnloadMissionModule(void); // Osiris_BindScriptsToObject // Purpose: @@ -196,13 +197,13 @@ void Osiris_UnloadMissionModule(void); // to make sure that all fields have been filled in. This function does not call any events. // This function will also load any dll's needed for it's game script. // returns false if nothing was bound. -bool Osiris_BindScriptsToObject(object *obj); +extern bool Osiris_BindScriptsToObject(object *obj); // Osiris_DetachScriptsFromObject // Purpose: // Call this function when an object is about to be destroyed. This will unbind and remove // all scripts associated with that object. This function does not call any events. -void Osiris_DetachScriptsFromObject(object *obj); +extern void Osiris_DetachScriptsFromObject(object *obj); // Osiris_CallEvent // Purpose: @@ -211,107 +212,107 @@ void Osiris_DetachScriptsFromObject(object *obj); // object (as long as they are available) in the order: custom script, level script, // mission script, and finally it's default script. The chain breaks if one of the scripts // returns false on the call to their CallInstanceEvent(). -bool Osiris_CallEvent(object *obj, int event, tOSIRISEventInfo *data); +extern bool Osiris_CallEvent(object *obj, int event, tOSIRISEventInfo *data); // Osiris_CallLevelEvent // Purpose: // Triggers an event for a level script. Returns true if the default action should continue // to process. -bool Osiris_CallLevelEvent(int event, tOSIRISEventInfo *data); +extern bool Osiris_CallLevelEvent(int event, tOSIRISEventInfo *data); // Osiris_CallTriggerEvent // Purpose: // Triggers an event for a trigger script. Returns true if the default action should continue // to process. -bool Osiris_CallTriggerEvent(int trignum, int event, tOSIRISEventInfo *ei); +extern bool Osiris_CallTriggerEvent(int trignum, int event, tOSIRISEventInfo *ei); // Osiris_ProcessTimers // Purpose: // This function checks all timers currently running, if any need to be signaled it signals them. -void Osiris_ProcessTimers(void); +extern void Osiris_ProcessTimers(void); // Osiris_CreateTimer // Pupose: // Adds a timer to the list to be processed. You'll receive a EVT_TIMER when the timer is signaled. // Returns an id to the timer, which can be used to cancel a timer. -1 on error. -int Osiris_CreateTimer(tOSIRISTIMER *ot); +extern int Osiris_CreateTimer(tOSIRISTIMER *ot); // Osiris_ResetAllTimers // Purpose: // Flushes all the timers -void Osiris_ResetAllTimers(void); +extern void Osiris_ResetAllTimers(void); // Osiris_CancelTimer // Purpose: // Cancels a timer thats in use, given it's ID -void Osiris_CancelTimer(int handle); +extern void Osiris_CancelTimer(int handle); // Osiris_TimerExists // Purpose: // Returns true if the timer is valid -ubyte Osiris_TimerExists(int handle); +extern ubyte Osiris_TimerExists(int handle); // Osiris_SaveSystemState // Purpose: // Saves the current state of the system (not the scripts!) to file -void Osiris_SaveSystemState(CFILE *file); +extern void Osiris_SaveSystemState(CFILE *file); // Osiris_RestoreSystemState // Purpose: // Restore the state of the system from file (does not restore scripts!) -bool Osiris_RestoreSystemState(CFILE *file); +extern bool Osiris_RestoreSystemState(CFILE *file); // Osiris_InitMemoryManager // Purpose: // Initializes the memory manager for the scripts, for buffers that the scripts want // automatically restored/save. -void Osiris_InitMemoryManager(void); +extern void Osiris_InitMemoryManager(void); // Osiris_CloseMemoryManager // Purpose: // Shuts down the Osiris memory manager, freeing any unfreed memory -void Osiris_CloseMemoryManager(void); +extern void Osiris_CloseMemoryManager(void); // Osiris_AllocateMemory // Purpose: // Allocates a chunk of memory to be associated with a script. It will automatically // save this memory to disk on game save, and will pass the pointer to this memory on EVT_RESTORE -void *Osiris_AllocateMemory(tOSIRISMEMCHUNK *mc); +extern void *Osiris_AllocateMemory(tOSIRISMEMCHUNK *mc); // Osiris_FreeMemory // Purpose: // Frees a chunk of memory that was allocated by Osiris_AllocateMemory(). -void Osiris_FreeMemory(void *mem_ptr); +extern void Osiris_FreeMemory(void *mem_ptr); // Osiris_FreeMemoryForScript // Purpose: // Frees all memory allocated for a given script -void Osiris_FreeMemoryForScript(tOSIRISSCRIPTID *sid); +extern void Osiris_FreeMemoryForScript(tOSIRISSCRIPTID *sid); // Osiris_RestoreMemoryChunks // Purpose: // Restores the 'auto manage' from file, calls the EVT_MEMRESTORE -void Osiris_RestoreMemoryChunks(CFILE *file); +extern void Osiris_RestoreMemoryChunks(CFILE *file); // Osiris_SaveMemoryChunks // Purpose: // Saves out the 'auto manage' script memory to file -void Osiris_SaveMemoryChunks(CFILE *file); +extern void Osiris_SaveMemoryChunks(CFILE *file); // Osiris_ExtractScriptsFromHog // Given the handle of a loaded hog file, this extracts all the scripts out to a temp directory // Pass false for the second parameter if it's a game hog (d3.hog for example) -int Osiris_ExtractScriptsFromHog(int library_handle, bool is_mission_hog = true); +extern int Osiris_ExtractScriptsFromHog(int library_handle, bool is_mission_hog = true); // Osiris_ClearExtractedScripts // Deletes the temp files created when the scripts where extracted from the hog // Pass false if you want it to remove _all_ extracted hogs...else only mission related ones -void Osiris_ClearExtractedScripts(bool misson_only = true); +extern void Osiris_ClearExtractedScripts(bool misson_only = true); // Initializes the Osiris Mission Memory System -void Osiris_InitOMMS(void); +extern void Osiris_InitOMMS(void); // Shutsdown the Osiris Mission Memory System (frees all memory associated, call at end of mission) -void Osiris_CloseOMMS(void); +extern void Osiris_CloseOMMS(void); extern bool Show_osiris_debug; @@ -321,22 +322,22 @@ extern bool Show_osiris_debug; // Osiris_EnableEvents // Purpose: // Enables the passed in mask of event types to be called -void Osiris_EnableEvents(ubyte mask); +extern void Osiris_EnableEvents(ubyte mask); // Osiris_DisableEvents // Purpose: // Disables the passed in mask of event types -void Osiris_DisableEvents(ubyte mask); +extern void Osiris_DisableEvents(ubyte mask); // Osiris_DisableCreateEvents // Purpose: // Disables any events involved when an object is created. This is to be used for // Loading games/viewing demos, as so not to re-initialize good data. -void Osiris_DisableCreateEvents(void); +extern void Osiris_DisableCreateEvents(void); // Osiris_EnablesCreateEvents // Purpose: // Enables any events involved when an object is created. This is to be used for // Loading games/viewing demos, as so not to re-initialize good data. (call when done with // Osiris_DisableCreateEvents()) -void Osiris_EnableCreateEvents(void); +extern void Osiris_EnableCreateEvents(void); #endif diff --git a/Descent3/pilot.cpp b/Descent3/pilot.cpp index e44dff30..56f02012 100644 --- a/Descent3/pilot.cpp +++ b/Descent3/pilot.cpp @@ -1529,8 +1529,6 @@ void NewPltUpdate(newuiListBox *list, char **flist, int filecount, int selected, // updates the current pilot's information (level played, mission played, etc) // call after every successful mission completion -extern bool IsCheater; -extern int Default_ship_permission; void CurrentPilotUpdateMissionStatus(bool just_add_data) { // Don't update if it's a multiplayer game if (Game_mode & GM_MULTI) diff --git a/Descent3/pilot_class.cpp b/Descent3/pilot_class.cpp index 611d2c25..34520d54 100644 --- a/Descent3/pilot_class.cpp +++ b/Descent3/pilot_class.cpp @@ -149,11 +149,11 @@ #define __PILOT_H_ // don't want to include pilot.h right now #include "difficulty.h" +#include "audiotaunts.h" #include -void grtext_SetProfanityFilter(bool enabled); -void taunt_Enable(bool enable); +extern void grtext_SetProfanityFilter(bool enabled); extern float Key_ramp_speed; diff --git a/Descent3/player.h b/Descent3/player.h index 48d43c7f..637e6abf 100644 --- a/Descent3/player.h +++ b/Descent3/player.h @@ -432,6 +432,9 @@ extern bool Player_has_camera; extern int Player_camera_objnum; extern uint Players_typing; // information about which players are typing messages (to display an icon) +extern float Player_shields_saved_from_last_level; +extern float Player_energy_saved_from_last_level; + // How long a player must be dead before he can respawn #define DEATH_RESPAWN_TIME 3.0f extern float Total_time_dead; @@ -574,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 diff --git a/Descent3/procedurals.cpp b/Descent3/procedurals.cpp index 1a3dbb43..f5554d2b 100644 --- a/Descent3/procedurals.cpp +++ b/Descent3/procedurals.cpp @@ -82,7 +82,7 @@ const char *ProcNames[] = {"None", "Line Lightning", "Sphere lightning", "St const char *WaterProcNames[] = {"None", "Height blob", "Sine Blob", "Random Raindrops", "Random Blobdrops", "END"}; static ubyte *ProcDestData; int pholdrand = 1; -inline int prand() { return (((pholdrand = pholdrand * 214013L + 2531011L) >> 16) & 0x7fff); } +static inline int prand() { return (((pholdrand = pholdrand * 214013L + 2531011L) >> 16) & 0x7fff); } // Given an array of r,g,b values, generates a 16bit palette table for those colors void GeneratePaletteForProcedural(ubyte *r, ubyte *g, ubyte *b, ushort *pal) { int i; @@ -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; diff --git a/Descent3/render.cpp b/Descent3/render.cpp index 9ba948e4..ac7c5cf7 100644 --- a/Descent3/render.cpp +++ b/Descent3/render.cpp @@ -216,7 +216,7 @@ int Num_mirror_rooms = 0; // Determines if a face renders // Parameters: rp - pointer to room that contains the face // fp - pointer to the face in question -inline bool FaceIsRenderable(room *rp, face *fp) { +static inline bool FaceIsRenderable(room *rp, face *fp) { // Check for a floating trigger, which doesn't get rendered if ((fp->flags & FF_FLOATING_TRIG) && (!In_editor_mode || !Render_floating_triggers)) return 0; @@ -241,7 +241,7 @@ inline bool FaceIsRenderable(room *rp, face *fp) { // bm_handle - the handle for the bitmap for this frame, or -1 if don't care about // transparence Returns: bitmask describing the alpha blending for the face // the return bits are the ATF_ flags in renderer.h -inline int GetFaceAlpha(face *fp, int bm_handle) { +static inline int GetFaceAlpha(face *fp, int bm_handle) { int ret = AT_ALWAYS; if (GameTextures[fp->tmap].flags & TF_SATURATE) { ret = AT_SATURATE_TEXTURE; @@ -260,7 +260,7 @@ inline int GetFaceAlpha(face *fp, int bm_handle) { // Parameters: rp - the room the portal is in // pp - the portal we're checking // Returns: true if you should render the room to which the portal connects -inline bool RenderPastPortal(room *rp, portal *pp) { +static inline bool RenderPastPortal(room *rp, portal *pp) { // If we don't render the portal's faces, then we see through it if (!(pp->flags & PF_RENDER_FACES)) return 1; @@ -357,7 +357,7 @@ struct clip_wnd { float left, top, right, bot; }; -inline int clip2d(g3Point *pnt, clip_wnd *wnd) { +static inline int clip2d(g3Point *pnt, clip_wnd *wnd) { int ret = 0; if (pnt->p3_codes & CC_BEHIND) return CC_BEHIND; @@ -374,7 +374,7 @@ inline int clip2d(g3Point *pnt, clip_wnd *wnd) { } // Returns true if a line intersects another line -inline bool LineIntersectsLine(g3Point *ls, g3Point *le, float x1, float y1, float x2, float y2) { +static inline bool LineIntersectsLine(g3Point *ls, g3Point *le, float x1, float y1, float x2, float y2) { float num, denom; num = ((ls->p3_sy - y1) * (x2 - x1)) - ((ls->p3_sx - x1) * (y2 - y1)); denom = ((le->p3_sx - ls->p3_sx) * (y2 - y1)) - ((le->p3_sy - ls->p3_sy) * (x2 - x1)); @@ -389,7 +389,7 @@ inline bool LineIntersectsLine(g3Point *ls, g3Point *le, float x1, float y1, flo return false; } // Returns true if a face intersects the passed in portal in any way -inline bool FaceIntersectsPortal(room *rp, face *fp, clip_wnd *wnd) { +static inline bool FaceIntersectsPortal(room *rp, face *fp, clip_wnd *wnd) { g3Codes cc; int i; @@ -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; diff --git a/Descent3/renderobject.cpp b/Descent3/renderobject.cpp index 9b956765..8cec80cf 100644 --- a/Descent3/renderobject.cpp +++ b/Descent3/renderobject.cpp @@ -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) @@ -856,7 +856,7 @@ void ComputeDebugVisFaceUpperLeft(room *rp, face *fp, vector *upper_left, float *upper_left = rot_vert + avg_vert; *center = avg_vert; } -extern uint check_point_to_face(vector *colp, vector *face_normal, int nv, vector **vertex_ptr_list); + #define VIS_TABLE_RESOLUTION 6 void DrawRoomVisPnts(object *obj) { int roomnum = obj->roomnum; diff --git a/Descent3/room.h b/Descent3/room.h index fda5abbe..a9f8dd9b 100644 --- a/Descent3/room.h +++ b/Descent3/room.h @@ -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 diff --git a/Descent3/spew.cpp b/Descent3/spew.cpp index 1dba1d09..3615bf5d 100644 --- a/Descent3/spew.cpp +++ b/Descent3/spew.cpp @@ -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; @@ -494,4 +494,4 @@ bool SpewObjectNeedsEveryFrameUpdate(object *obj, int gun_num) { } return false; -} \ No newline at end of file +} diff --git a/Descent3/terrain.h b/Descent3/terrain.h index 1037732e..8df81b2a 100644 --- a/Descent3/terrain.h +++ b/Descent3/terrain.h @@ -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; diff --git a/Descent3/weapon.cpp b/Descent3/weapon.cpp index 7e4ae7dd..9a6598f9 100644 --- a/Descent3/weapon.cpp +++ b/Descent3/weapon.cpp @@ -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; } diff --git a/Descent3/weapon.h b/Descent3/weapon.h index 60da7c47..71040d55 100644 --- a/Descent3/weapon.h +++ b/Descent3/weapon.h @@ -417,7 +417,7 @@ void WeaponDoFrame(object *obj); bool WeaponCalcGun(vector *gun_point, vector *gun_normal, object *obj, int gun_num); // Checks for relation between weapons and other objects -bool ObjectsAreRelated(int o1, int o2); +extern bool ObjectsAreRelated(int o1, int o2); // A quick way to see where a weapon hits. Weapons make debris. void CreateWeaponDebris(object *obj); diff --git a/bitmap/bitmain.cpp b/bitmap/bitmain.cpp index 95624292..a761dde9 100644 --- a/bitmap/bitmain.cpp +++ b/bitmap/bitmain.cpp @@ -332,12 +332,16 @@ typedef struct bm_Node_ { struct bm_Node_ *next; /* next bm_Node */ bm_T data; /* data stored in bm_Node */ } bm_Node; -bm_Node *bm_findNode(bm_T data); -void bm_deleteNode(bm_T data); -bm_Node *bm_insertNode(bm_T data); -bm_hashTableIndex bm_hash(bm_T data); -bm_Node **bm_hashTable = NULL; -int bm_hashTableSize = (MAX_BITMAPS / 2); +static bm_Node *bm_findNode(bm_T data); +static void bm_deleteNode(bm_T data); +static bm_Node *bm_insertNode(bm_T data); +static bm_hashTableIndex bm_hash(bm_T data); +static bm_Node **bm_hashTable = NULL; +static const int bm_hashTableSize = (MAX_BITMAPS / 2); +static void bm_InitHashTable(); +static void bm_DeleteHashTable(); +static int bm_TestName(const char *src); + void bm_InitHashTable() { bm_hashTable = (bm_Node **)mem_malloc(bm_hashTableSize * sizeof(bm_Node *)); for (int a = 0; a < bm_hashTableSize; a++) { diff --git a/bitmap/bumpmap.cpp b/bitmap/bumpmap.cpp index 116a6100..b973f0e4 100644 --- a/bitmap/bumpmap.cpp +++ b/bitmap/bumpmap.cpp @@ -24,11 +24,11 @@ #include "mono.h" #include "mem.h" -int Num_of_bumpmaps = 0; +static int Num_of_bumpmaps = 0; static ushort Free_bumpmap_list[MAX_BUMPMAPS]; bms_bumpmap GameBumpmaps[MAX_BUMPMAPS]; -int Bumpmap_mem_used = 0; +static int Bumpmap_mem_used = 0; // Sets all the bumpmaps to unused void bump_InitBumpmaps() { @@ -126,4 +126,4 @@ ubyte bump_w(int handle) { ubyte bump_h(int handle) { ASSERT(GameBumpmaps[handle].flags & BUMPF_USED); return GameBumpmaps[handle].height; -} \ No newline at end of file +} diff --git a/bitmap/iff.cpp b/bitmap/iff.cpp index 87b7baa1..69ddfa91 100644 --- a/bitmap/iff.cpp +++ b/bitmap/iff.cpp @@ -130,6 +130,21 @@ short iff_has_transparency; // 0=no transparency, 1=iff_transparent_color is val #define IFF_SIG_DELTA 9 #define IFF_SIG_ANHD 10 +static int bm_iff_get_sig(CFILE *f); +static int bm_iff_parse_bmhd(CFILE *ifile, uint len, iff_bitmap_header *bmheader); + +/// the buffer pointed to by raw_data is stuffed with a pointer to decompressed pixel data +static int bm_iff_parse_body(CFILE *ifile, int len, iff_bitmap_header *bmheader); + +/// the buffer pointed to by raw_data is stuffed with a pointer to bitplane pixel data +static void bm_iff_skip_chunk(CFILE *ifile, uint len); + +/// modify passed bitmap +static int bm_iff_parse_delta(CFILE *ifile, int len, iff_bitmap_header *bmheader); + +static int bm_iff_parse_file(CFILE *ifile, iff_bitmap_header *bmheader, iff_bitmap_header *prev_bm); +static void bm_iff_convert_8_to_16(int dest_bm, iff_bitmap_header *iffbm); + int bm_iff_get_sig(CFILE *f) { char s[4]; int i; diff --git a/bitmap/lightmap.cpp b/bitmap/lightmap.cpp index aae0c405..b248ae33 100644 --- a/bitmap/lightmap.cpp +++ b/bitmap/lightmap.cpp @@ -30,10 +30,10 @@ #include -int Num_of_lightmaps = 0; +static int Num_of_lightmaps = 0; static ushort Free_lightmap_list[MAX_LIGHTMAPS]; bms_lightmap GameLightmaps[MAX_LIGHTMAPS]; -int Lightmap_mem_used = 0; +static int Lightmap_mem_used = 0; // Sets all the lightmaps to unused void lm_InitLightmaps() { int i; @@ -144,4 +144,4 @@ ushort *lm_data(int handle) { d = GameLightmaps[handle].data; return (d); -} \ No newline at end of file +} diff --git a/bitmap/pcx.cpp b/bitmap/pcx.cpp index e9453999..25993d7b 100644 --- a/bitmap/pcx.cpp +++ b/bitmap/pcx.cpp @@ -62,9 +62,9 @@ #include // load an 8bit pcx image -int bm_pcx_8bit_alloc_file(CFILE *infile); +static int bm_pcx_8bit_alloc_file(CFILE *infile); // load a 24bit pcx image -int bm_pcx_24bit_alloc_file(CFILE *infile); +static int bm_pcx_24bit_alloc_file(CFILE *infile); // Loads a pcx file and converts it to 16 bit. Returns bitmap handle or -1 on error int bm_pcx_alloc_file(CFILE *infile) { @@ -313,4 +313,4 @@ int bm_pcx_24bit_alloc_file(CFILE *infile) { mem_free(rawdata); return src_bm; // success! -} \ No newline at end of file +} diff --git a/bitmap/tga.cpp b/bitmap/tga.cpp index 3accd71c..8cda0862 100644 --- a/bitmap/tga.cpp +++ b/bitmap/tga.cpp @@ -142,13 +142,20 @@ #include "byteswap.h" #include #include "mem.h" +#include "gamesequence.h" #include -char *Tga_file_data = NULL; -int Fake_pos = 0; -int Bad_tga = 0; -int Fake_file_size = 0; +static char *Tga_file_data = NULL; +static int Fake_pos = 0; +static int Bad_tga = 0; +static int Fake_file_size = 0; + +static inline char tga_read_byte(); +static inline int tga_read_int(); +static inline short tga_read_short(); +static ushort bm_tga_translate_pixel(int pixel, int format); +static int bm_tga_read_outrage_compressed16(CFILE *infile, int n, int num_mips, int type); inline char tga_read_byte() { // Check for bad file @@ -591,8 +598,6 @@ int bm_tga_alloc_file(CFILE *infile, char *name, int format) { return (n); } -extern int paged_in_count; -extern int paged_in_num; // Pages in bitmap index n. Returns 1 if successful, 0 if not int bm_page_in_file(int n) { ubyte image_id_len, color_map_type, image_type, pixsize, descriptor; diff --git a/cfile/cfile.cpp b/cfile/cfile.cpp index 7896fc80..5e262eaf 100644 --- a/cfile/cfile.cpp +++ b/cfile/cfile.cpp @@ -92,7 +92,10 @@ void ThrowCFileError(int type, CFILE *file, const char *msg) { throw &cfe; } -void cf_Close(); +static void cf_Close(); + +// searches through the open HOG files, and opens a file if it finds it in any of the libs +static CFILE *open_file_in_lib(const char *filename); // Opens a HOG file. Future calls to cfopen(), etc. will look in this HOG. // Parameters: libname - the path & filename of the HOG file @@ -344,7 +347,7 @@ CFILE *cf_OpenFileInLibrary(const char *filename, int libhandle) { } cfile = (CFILE *)mem_malloc(sizeof(*cfile)); if (!cfile) - Error("Out of memory in open_file_in_lib()"); + Error("Out of memory in cf_OpenFileInLibrary()"); cfile->name = lib->entries[i].name; cfile->file = fp; cfile->lib_handle = lib->handle; @@ -483,6 +486,9 @@ void CFindFiles::Close() { globfree(&ffres); } +static FILE *open_file_in_directory_case_sensitive(const char *directory, const char *filename, const char *mode, + char *new_filename); + bool cf_FindRealFileNameCaseInsenstive(const char *directory, const char *fname, char *new_filename) { bool use_dir = false; char dir_to_use[_MAX_PATH]; @@ -637,6 +643,9 @@ FILE *open_file_in_directory_case_sensitive(const char *directory, const char *f } #endif +// look for the file in the specified directory +static CFILE *open_file_in_directory(const char *filename, const char *mode, const char *directory); + // look for the file in the specified directory CFILE *open_file_in_directory(const char *filename, const char *mode, const char *directory) { FILE *fp; @@ -880,10 +889,11 @@ int cfexist(const char *filename) { int ret; cfp = cfopen(filename, "rb"); - if (!cfp) { // Didn't get file. Why? - if (errno == EACCES) // File exists, but couldn't open it + if (!cfp) { // Didn't get file. Why? + if (errno == EACCES) // File exists, but couldn't open it return CFES_ON_DISK; // so say it exists on the disk - // DAJ if (errno != ENOENT) //Check if error is "file not found" + // DAJ if (errno != ENOENT) //Check if error is "file not + // found" // DAJ Int3(); //..warn if not return CFES_NOT_FOUND; // Say we didn't find the file } diff --git a/d3music/musicapi.cpp b/d3music/musicapi.cpp index 6ab17a39..f7b71790 100644 --- a/d3music/musicapi.cpp +++ b/d3music/musicapi.cpp @@ -40,8 +40,8 @@ #define MUSICAIF_NEWREGION 0x40 // names of themes. (match to music.h THEME_TYPES) -const char *Music_type_names[] = {"No song", "Intro song", "Idle song", "Combat song", - "Death song", "Idle-Combat song", "Combat-Idle song"}; +const char *const Music_type_names[] = {"No song", "Intro song", "Idle song", "Combat song", + "Death song", "Idle-Combat song", "Combat-Idle song"}; // global data #ifdef _DEBUG @@ -68,10 +68,10 @@ static struct { } MusicAI; // handles operations on current events. -void D3MusicSongSelector(); +static void D3MusicSongSelector(); // creates music ai struction from music info passed in. -void D3MusicAI(tMusicSeqInfo *music_info); +static void D3MusicAI(tMusicSeqInfo *music_info); /////////////////////////////////////////////////////////////////////////////// diff --git a/dd_lnxsound/mixer.cpp b/dd_lnxsound/mixer.cpp index d7ce6701..d4cab7fb 100644 --- a/dd_lnxsound/mixer.cpp +++ b/dd_lnxsound/mixer.cpp @@ -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; diff --git a/dd_sndlib/ddsoundload.cpp b/dd_sndlib/ddsoundload.cpp index 1657d07c..5b0ae480 100644 --- a/dd_sndlib/ddsoundload.cpp +++ b/dd_sndlib/ddsoundload.cpp @@ -102,6 +102,7 @@ #include "pserror.h" #include #include "byteswap.h" +#include "gamesequence.h" sound_info Sounds[MAX_SOUNDS]; sound_file_info SoundFiles[MAX_SOUND_FILES]; @@ -113,8 +114,6 @@ sound_file_info SoundFiles[MAX_SOUND_FILES]; #define SND_LOAD_ERROR_NO_FILE 0 #define SND_LOAD_ERROR_INVALID 1 -extern int paged_in_count; -extern int paged_in_num; char SoundLoadWaveFile(const char *filename, float percent_volume, int sound_file_index, bool f_high_quality, bool f_load_sample_data, int *e_type) { diff --git a/ddebug/lnxdebug.cpp b/ddebug/lnxdebug.cpp index 1f99211e..4708d765 100644 --- a/ddebug/lnxdebug.cpp +++ b/ddebug/lnxdebug.cpp @@ -50,7 +50,7 @@ bool Debug_break = false; bool Debug_mono = false; -char *Debug_DumpInfo(); +static char *Debug_DumpInfo(); // if we are running under a debugger, then pass true bool Debug_Init(bool debugger, bool mono_debug) { diff --git a/ddio_lnx/lnxfile.cpp b/ddio_lnx/lnxfile.cpp index d36a97dd..764b7757 100644 --- a/ddio_lnx/lnxfile.cpp +++ b/ddio_lnx/lnxfile.cpp @@ -290,7 +290,7 @@ void ddio_MakePath(char *newPath, const char *absolutePathHeader, const char *su // Use FindFileClose to end your search. glob_t ffres = {0, NULL, 0}; int globindex = -1; -int globerrfn(const char *path, int err) { +static int globerrfn(const char *path, int err) { mprintf((0, "Error accessing %s: %s .... \n", path, strerror(err))); return 0; } diff --git a/ddio_lnx/lnxkey_sdl.cpp b/ddio_lnx/lnxkey_sdl.cpp index 70a07d60..d9be4ef2 100644 --- a/ddio_lnx/lnxkey_sdl.cpp +++ b/ddio_lnx/lnxkey_sdl.cpp @@ -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; diff --git a/grtext/grfont.cpp b/grtext/grfont.cpp index 80279f96..900b6d12 100644 --- a/grtext/grfont.cpp +++ b/grtext/grfont.cpp @@ -156,6 +156,13 @@ static bool Font_init = false; typedef CFILE *FONTFILE; +static inline int READ_FONT_INT(FONTFILE ffile); +static inline short READ_FONT_SHORT(FONTFILE ffile); +static inline ubyte READ_FONT_BYTE(FONTFILE ffile); +static inline int READ_FONT_DATA(FONTFILE ffile, void *buf, int size, int nelem); +static inline FONTFILE OPEN_FONT(char *filename); +static inline void CLOSE_FONT(FONTFILE ffile); + inline int READ_FONT_INT(FONTFILE ffile) { return cf_ReadInt(ffile); } inline short READ_FONT_SHORT(FONTFILE ffile) { return cf_ReadShort(ffile); } @@ -191,6 +198,13 @@ inline void CLOSE_FONT(FONTFILE ffile) { cfclose(ffile); } typedef FILE *FONTFILE2; +static inline int WRITE_FONT_INT(FONTFILE2 ffile, int i); +static inline int WRITE_FONT_SHORT(FONTFILE2 ffile, short s); +static inline int WRITE_FONT_BYTE(FONTFILE2 ffile, ubyte c); +static inline int WRITE_FONT_DATA(FONTFILE2 ffile, void *buf, int size, int nelem); +static inline FONTFILE2 OPEN_FONT2(char *filename); +static inline void CLOSE_FONT2(FONTFILE2 ffile); + inline int WRITE_FONT_INT(FONTFILE2 ffile, int i) { return fwrite(&i, sizeof(i), 1, (FILE *)ffile); } inline int WRITE_FONT_SHORT(FONTFILE2 ffile, short s) { return fwrite(&s, sizeof(s), 1, (FILE *)ffile); } @@ -221,12 +235,12 @@ inline void CLOSE_FONT2(FONTFILE2 ffile) { fclose((FILE *)ffile); } ////////////////////////////////////////////////////////////////////////////// // Functions -void grfont_Close(); -void grfont_TranslateToBitmaps(int handle); -void grfont_XlateMonoChar(int bmp_handle, int x, int y, int index, tFontFileInfo *ft, int width); -void grfont_XlateColorChar(int bmp_handle, int x, int y, int index, tFontFileInfo *ft, int width); -void grfont_XlateColorGrayChar(int bmp_handle, int x, int y, int index, tFontFileInfo *ft, int width); -void grfont_ClearBitmap(int bmp_handle); +static void grfont_Close(); +static void grfont_TranslateToBitmaps(int handle); +static void grfont_XlateMonoChar(int bmp_handle, int x, int y, int index, tFontFileInfo *ft, int width); +static void grfont_XlateColorChar(int bmp_handle, int x, int y, int index, tFontFileInfo *ft, int width); +static void grfont_XlateColorGrayChar(int bmp_handle, int x, int y, int index, tFontFileInfo *ft, int width); +static void grfont_ClearBitmap(int bmp_handle); // clears out font buffer. void grfont_Reset() { @@ -523,6 +537,7 @@ void grfont_FreeTemplate(tFontTemplate *ft) { } } +// MTS: unused? // sets a template to a font, be careful. bool grfont_SetTemplate(const char *pathname, const tFontTemplate *ft) { // okay, load the font manually, set the template members, then save it out. @@ -674,6 +689,7 @@ bool grfont_SetTemplate(const char *pathname, const tFontTemplate *ft) { return true; } +// MTS: Unused? // sets a font's template without saving... bool grfont_SetKerning(int font, ubyte *kern_data) { tFontInfo *oldft = &Fonts[font]; @@ -706,6 +722,7 @@ bool grfont_SetKerning(int font, ubyte *kern_data) { return true; } +// MTS: Unused? // sets a font's tracking bool grfont_SetTracking(int font, int tracking) { ASSERT(font >= 0 && font < MAX_FONTS); @@ -1052,6 +1069,7 @@ int grfont_KeyToAscii(int font, int key) { return key; } +// MTS: Unused? // returns the raw bitmap data for a character in a font, its width and height // returned data should be in 565 hicolor format if (*mono) is false. if (*mono) is true, // then a bitmask will be returned, and you should treat a bit as a pixel. diff --git a/grtext/grtext.cpp b/grtext/grtext.cpp index 4663adf9..1442b314 100644 --- a/grtext/grtext.cpp +++ b/grtext/grtext.cpp @@ -190,15 +190,15 @@ static float Grtext_scale = 1.0f; static ddgr_color Grtext_color = GR_BLACK; // draws a string -void grtext_RenderString(int x, int y, char *str); -void grtext_DrawTextLine(int x, int y, char *str); -void grtext_DrawTextLineClip(int x, int y, char *str); +static void grtext_RenderString(int x, int y, char *str); +static void grtext_DrawTextLine(int x, int y, char *str); +static void grtext_DrawTextLineClip(int x, int y, char *str); #define XORVAL 205 #define MAX_BAD_WORD_LEN 10 typedef unsigned char badword[MAX_BAD_WORD_LEN]; // These all need to be lower case! -badword bad_words[] = { +static badword bad_words[] = { // These are just XOR'd with XORVAL {0xab, 0xb8, 0xae, 0xa6, 0x00}, // = fuck {0xbe, 0xa5, 0xa4, 0xb9, 0x00}, // = shit @@ -214,11 +214,11 @@ badword bad_words[] = { #define NUM_BAD_WORDS (sizeof(bad_words) / sizeof(badword)) -char subst_chars[] = "#!&@&#%*"; +static const char subst_chars[] = "#!&@&#%*"; #define NUM_SUBST_CHARS (sizeof(subst_chars) - 1) -bool grtext_FilterProfanity = false; +static bool grtext_FilterProfanity = false; void grtext_SetProfanityFilter(bool enabled) { grtext_FilterProfanity = enabled; } // Right now this just decrypts the bad words @@ -234,14 +234,14 @@ void grtext_Init(void) { } // macro to get character width -inline int CHAR_WIDTH(int font, int ch) { return (int)(grfont_GetCharWidth(font, ch) * Grtext_scale); } +static inline int CHAR_WIDTH(int font, int ch) { return (int)(grfont_GetCharWidth(font, ch) * Grtext_scale); } -inline int CHAR_HEIGHT(int font) { return (int)(grfont_GetHeight(font) * Grtext_scale); } +static inline int CHAR_HEIGHT(int font) { return (int)(grfont_GetHeight(font) * Grtext_scale); } -inline int CHAR_SPACING(int font, int ch1, int ch2) { return (int)(grfont_GetKernedSpacing(font, ch1, ch2)); } +static inline int CHAR_SPACING(int font, int ch1, int ch2) { return (int)(grfont_GetKernedSpacing(font, ch1, ch2)); } // macro to get character width -inline int CHAR_WIDTH_TEMP(const tFontTemplate *ft, int ch) { +static inline int CHAR_WIDTH_TEMP(const tFontTemplate *ft, int ch) { if (ch > ft->max_ascii && ft->uppercase) { ch = toupper(ch); } else if (ch < ft->min_ascii || ch > ft->max_ascii) { @@ -251,9 +251,9 @@ inline int CHAR_WIDTH_TEMP(const tFontTemplate *ft, int ch) { return (int)((ft->proportional) ? ft->ch_widths[ch - ft->min_ascii] : ft->ch_maxwidth); } -inline int CHAR_HEIGHT_TEMP(const tFontTemplate *ft) { return (int)ft->ch_height; } +static inline int CHAR_HEIGHT_TEMP(const tFontTemplate *ft) { return (int)ft->ch_height; } -inline int CHAR_SPACING_TEMP(const tFontTemplate *ft, int ch1, int ch2) { +static inline int CHAR_SPACING_TEMP(const tFontTemplate *ft, int ch1, int ch2) { if (ch1 > ft->max_ascii && ft->uppercase) { ch1 = toupper(ch1); } diff --git a/lib/3d.h b/lib/3d.h index d608625f..a2abb769 100644 --- a/lib/3d.h +++ b/lib/3d.h @@ -398,7 +398,7 @@ void g3_SetCustomClipPlane(ubyte state, vector *pnt, vector *normal); void g3_SetFarClipZ(float z); // Disables the far clip plane -inline void g3_ResetFarClipZ() { g3_SetFarClipZ(FLT_MAX); } +static inline void g3_ResetFarClipZ() { g3_SetFarClipZ(FLT_MAX); } // Clips a polygon // Parameters: pointlist - pointer to a list of pointers to points diff --git a/lib/collide.h b/lib/collide.h index 8f03cae5..cf35fa5b 100644 --- a/lib/collide.h +++ b/lib/collide.h @@ -119,6 +119,8 @@ extern void collide_player_and_powerup(object *player, object *powerup, vector * extern void apply_damage_to_controlcen(object *controlcen, float damage, short who); extern void bump_one_object(object *obj0, vector *hit_dir, float damage); +extern void FindHitpointUV(float *u, float *v, vector *point, room *rp, int facenum); + void ConvertEulerToAxisAmount(vector *e, vector *n, float *w); void ConvertAxisAmountToEuler(vector *n, float *w, vector *e); diff --git a/lib/d3music.h b/lib/d3music.h index d7b38fa5..d8a8b5a3 100644 --- a/lib/d3music.h +++ b/lib/d3music.h @@ -87,7 +87,7 @@ #define MUSICTRIGGER_NONE 0 #define MUSICTRIGGER_NEWREGION 1 // player entered new region -extern const char *Music_type_names[]; // contains type names. +extern const char *const Music_type_names[]; // contains type names. // structure passed to music frame typedef struct tMusicSeqInfo { diff --git a/lib/demofile.h b/lib/demofile.h index 83bc4984..b8635632 100644 --- a/lib/demofile.h +++ b/lib/demofile.h @@ -113,7 +113,9 @@ extern bool Demo_paused; extern bool Demo_do_one_frame; extern bool Demo_restart; extern bool Demo_auto_play; +extern bool Demo_make_movie; extern float Demo_frame_ofs; +extern unsigned short Demo_obj_map[MAX_OBJECTS]; #define DF_NONE 0 #define DF_RECORDING 1 #define DF_PLAYBACK 2 diff --git a/lib/findintersection.h b/lib/findintersection.h index 5c09e1f7..969e8cd5 100644 --- a/lib/findintersection.h +++ b/lib/findintersection.h @@ -249,7 +249,7 @@ extern bool FVI_always_check_ceiling; #define Q_LEFT 1 #define Q_MIDDLE 2 -inline bool FastVectorBBox(const float *min, const float *max, const float *origin, const float *dir) { +static inline bool FastVectorBBox(const float *min, const float *max, const float *origin, const float *dir) { bool f_inside = true; char quad[3]; int i; @@ -418,6 +418,8 @@ bool PolyCollideObject(object *obj); bool BBoxPlaneIntersection(bool fast_exit, vector *collision_point, vector *collision_normal, object *obj, vector *new_pos, int nv, vector **vertex_ptr_list, vector *face_normal, matrix *orient); +extern uint check_point_to_face(vector *colp, vector *face_normal, int nv, vector **vertex_ptr_list); + extern int check_vector_to_sphere_1(vector *intp, float *col_dist, const vector *p0, const vector *p1, vector *sphere_pos, float sphere_rad, bool f_correcting, bool f_init_collisions); diff --git a/lib/gr.h b/lib/gr.h index 3155853d..5d08f4c6 100644 --- a/lib/gr.h +++ b/lib/gr.h @@ -565,7 +565,7 @@ inline void grViewport::get_char_properties(tCharProperties *props) const { // useful macros -inline void VP_BITBLT(grViewport *vp, int dx, int dy, int bm) { +static inline void VP_BITBLT(grViewport *vp, int dx, int dy, int bm) { grMemorySurface surf(bm); vp->blt(dx, dy, &surf); } diff --git a/lib/grdefs.h b/lib/grdefs.h index e8515318..bde07539 100644 --- a/lib/grdefs.h +++ b/lib/grdefs.h @@ -75,18 +75,18 @@ typedef uint ddgr_color; // Color constants -const ddgr_color GR_NULL = 0xffffffff, // don't do a thing with this. +static const ddgr_color GR_NULL = 0xffffffff, // don't do a thing with this. GR_BLACK = 0x00000000, GR_GREEN = 0x0000ff00, GR_RED = 0x00ff0000, GR_BLUE = 0x000000ff, GR_DARKGRAY = 0x00404040, - GR_LIGHTGRAY = 0x00c0c0c0, GR_WHITE = 0x00ffffff; + GR_LIGHTGRAY = 0x00c0c0c0, GR_WHITE = 0x00ffffff; #define GR_COLOR_CHAR 1 // ASCII 1 and (r,g,b) changes current text color in string. // MACROS -inline ddgr_color GR_RGB(int r, int g, int b) { return ((r << 16) + (g << 8) + b); } +static inline ddgr_color GR_RGB(int r, int g, int b) { return ((r << 16) + (g << 8) + b); } -inline ushort GR_RGB16(int r, int g, int b) { return (((r >> 3) << 10) + ((g >> 3) << 5) + (b >> 3)); } +static inline ushort GR_RGB16(int r, int g, int b) { return (((r >> 3) << 10) + ((g >> 3) << 5) + (b >> 3)); } -inline ushort GR_COLOR_TO_16(ddgr_color c) { +static inline ushort GR_COLOR_TO_16(ddgr_color c) { int r, g, b; r = ((c & 0x00ff0000) >> 16); g = ((c & 0x0000ff00) >> 8); @@ -95,22 +95,22 @@ inline ushort GR_COLOR_TO_16(ddgr_color c) { return (ushort)(((r >> 3) << 10) + ((g >> 3) << 5) + (b >> 3)); } -inline int GR_COLOR_RED(ddgr_color c) { +static inline int GR_COLOR_RED(ddgr_color c) { int r = ((c & 0x00ff0000) >> 16); return (int)r; } -inline int GR_COLOR_GREEN(ddgr_color c) { +static inline int GR_COLOR_GREEN(ddgr_color c) { int g = ((c & 0x0000ff00) >> 8); return (int)g; } -inline int GR_COLOR_BLUE(ddgr_color c) { +static inline int GR_COLOR_BLUE(ddgr_color c) { int b = (c & 0x000000ff); return (int)b; } -inline ddgr_color GR_16_TO_COLOR(ushort col) { +static inline ddgr_color GR_16_TO_COLOR(ushort col) { int r, g, b; r = (col & 0x7c00) >> 7; diff --git a/lib/linux/linux_fix.h b/lib/linux/linux_fix.h index fdd61748..3d500065 100644 --- a/lib/linux/linux_fix.h +++ b/lib/linux/linux_fix.h @@ -45,7 +45,7 @@ char *strupr(char *string); // _stdcall replacement #define _stdcall __attribute__((stdcall)) -inline int _filelength(int fd) { +static inline int _filelength(int fd) { struct stat statbuf; if (fstat(fd, &statbuf) != 0) { diff --git a/lib/networking.h b/lib/networking.h index ea210080..0c9dd1cb 100644 --- a/lib/networking.h +++ b/lib/networking.h @@ -163,24 +163,24 @@ #include // helper macros for working with SOCKADDR_IN to make it look nicer between windows and Linux -inline void INADDR_SET_SUN_SADDR(struct in_addr *st, unsigned int value) { st->S_un.S_addr = value; } -inline void INADDR_GET_SUN_SADDR(struct in_addr *st, unsigned int *value) { *value = st->S_un.S_addr; } -inline void INADDR_SET_SUN_SUNW(struct in_addr *st, unsigned short s_w1, unsigned short s_w2) { +static inline void INADDR_SET_SUN_SADDR(struct in_addr *st, unsigned int value) { st->S_un.S_addr = value; } +static inline void INADDR_GET_SUN_SADDR(struct in_addr *st, unsigned int *value) { *value = st->S_un.S_addr; } +static inline void INADDR_SET_SUN_SUNW(struct in_addr *st, unsigned short s_w1, unsigned short s_w2) { st->S_un.S_un_w.s_w1 = s_w1; st->S_un.S_un_w.s_w2 = s_w2; } -inline void INADDR_GET_SUN_SUNW(struct in_addr *st, unsigned short *s_w1, unsigned short *s_w2) { +static inline void INADDR_GET_SUN_SUNW(struct in_addr *st, unsigned short *s_w1, unsigned short *s_w2) { *s_w1 = st->S_un.S_un_w.s_w1; *s_w2 = st->S_un.S_un_w.s_w2; } -inline void INADDR_SET_SUN_SUNB(struct in_addr *st, unsigned char s_b1, unsigned char s_b2, unsigned char s_b3, +static inline void INADDR_SET_SUN_SUNB(struct in_addr *st, unsigned char s_b1, unsigned char s_b2, unsigned char s_b3, unsigned char s_b4) { st->S_un.S_un_b.s_b1 = s_b1; st->S_un.S_un_b.s_b2 = s_b2; st->S_un.S_un_b.s_b3 = s_b3; st->S_un.S_un_b.s_b4 = s_b4; } -inline void INADDR_GET_SUN_SUNB(struct in_addr *st, unsigned char *s_b1, unsigned char *s_b2, unsigned char *s_b3, +static inline void INADDR_GET_SUN_SUNB(struct in_addr *st, unsigned char *s_b1, unsigned char *s_b2, unsigned char *s_b3, unsigned char *s_b4) { *s_b1 = st->S_un.S_un_b.s_b1; *s_b2 = st->S_un.S_un_b.s_b2; @@ -236,13 +236,13 @@ inline void INADDR_GET_SUN_SUNB(struct in_addr *st, unsigned char *s_b1, unsigne #define WSAEINVAL EINVAL #define WSAENOPROTOOPT ENOPROTOOPT -inline int WSAGetLastError() { return errno; } +static inline int WSAGetLastError() { return errno; } extern bool Use_DirectPlay; // helper macros for working with SOCKADDR_IN to make it look nicer between windows and Linux -inline void INADDR_SET_SUN_SADDR(struct in_addr *st, unsigned int value) { st->s_addr = value; } -inline void INADDR_GET_SUN_SADDR(struct in_addr *st, unsigned int *value) { *value = st->s_addr; } -inline void INADDR_SET_SUN_SUNW(struct in_addr *st, unsigned short s_w1, unsigned short s_w2) { +static inline void INADDR_SET_SUN_SADDR(struct in_addr *st, unsigned int value) { st->s_addr = value; } +static inline void INADDR_GET_SUN_SADDR(struct in_addr *st, unsigned int *value) { *value = st->s_addr; } +static inline void INADDR_SET_SUN_SUNW(struct in_addr *st, unsigned short s_w1, unsigned short s_w2) { union { struct { unsigned char s_b1, s_b2, s_b3, s_b4; @@ -257,7 +257,7 @@ inline void INADDR_SET_SUN_SUNW(struct in_addr *st, unsigned short s_w1, unsigne S_un.S_un_w.s_w2 = s_w2; st->s_addr = S_un.S_addr; } -inline void INADDR_GET_SUN_SUNW(struct in_addr *st, unsigned short *s_w1, unsigned short *s_w2) { +static inline void INADDR_GET_SUN_SUNW(struct in_addr *st, unsigned short *s_w1, unsigned short *s_w2) { union { struct { unsigned char s_b1, s_b2, s_b3, s_b4; @@ -272,7 +272,7 @@ inline void INADDR_GET_SUN_SUNW(struct in_addr *st, unsigned short *s_w1, unsign *s_w1 = S_un.S_un_w.s_w1; *s_w2 = S_un.S_un_w.s_w2; } -inline void INADDR_SET_SUN_SUNB(struct in_addr *st, unsigned char s_b1, unsigned char s_b2, unsigned char s_b3, +static inline void INADDR_SET_SUN_SUNB(struct in_addr *st, unsigned char s_b1, unsigned char s_b2, unsigned char s_b3, unsigned char s_b4) { union { struct { @@ -290,7 +290,7 @@ inline void INADDR_SET_SUN_SUNB(struct in_addr *st, unsigned char s_b1, unsigned S_un.S_un_b.s_b4 = s_b4; st->s_addr = S_un.S_addr; } -inline void INADDR_GET_SUN_SUNB(struct in_addr *st, unsigned char *s_b1, unsigned char *s_b2, unsigned char *s_b3, +static inline void INADDR_GET_SUN_SUNB(struct in_addr *st, unsigned char *s_b1, unsigned char *s_b2, unsigned char *s_b3, unsigned char *s_b4) { union { struct { diff --git a/lib/polymodel.h b/lib/polymodel.h index e238788f..f0f8ee0a 100644 --- a/lib/polymodel.h +++ b/lib/polymodel.h @@ -331,11 +331,11 @@ extern g3Point Robot_points[]; // Flag to draw an outline around the faces extern bool Polymodel_outline_mode; -inline float POLY_WIDTH(int model_num) { return Poly_models[model_num].maxs.x - Poly_models[model_num].mins.x; } +static inline float POLY_WIDTH(int model_num) { return Poly_models[model_num].maxs.x - Poly_models[model_num].mins.x; } -inline float POLY_HEIGHT(int model_num) { return Poly_models[model_num].maxs.y - Poly_models[model_num].mins.y; } +static inline float POLY_HEIGHT(int model_num) { return Poly_models[model_num].maxs.y - Poly_models[model_num].mins.y; } -inline float POLY_DEPTH(int model_num) { return Poly_models[model_num].maxs.z - Poly_models[model_num].mins.z; } +static inline float POLY_DEPTH(int model_num) { return Poly_models[model_num].maxs.z - Poly_models[model_num].mins.z; } // given a filename, reads in a POF and returns an index into the Poly_models array // returns -1 if something is wrong @@ -437,4 +437,7 @@ void FreePolymodelData(int i); // Sets the position and rotation of a polymodel. Used for rendering and collision detection void SetModelAnglesAndPos(poly_model *po, float *normalized_time, uint subobj_flags = 0xFFFFFFFF); +extern void DoneLightInstance(); +extern void StartLightInstance(vector *, matrix *); + #endif diff --git a/lib/pserror.h b/lib/pserror.h index 4d58d6a3..2fa1cbec 100644 --- a/lib/pserror.h +++ b/lib/pserror.h @@ -186,7 +186,7 @@ void DumpTextToClipboard(char *text); extern void (*DebugBreak_callback_stop)(); extern void (*DebugBreak_callback_resume)(); // set DEBUG_BREAK callback -inline void SetDebugBreakHandlers(void (*stop)(), void (*resume)()) { +static inline void SetDebugBreakHandlers(void (*stop)(), void (*resume)()) { DebugBreak_callback_stop = stop; DebugBreak_callback_resume = resume; } diff --git a/lib/uisys.h b/lib/uisys.h index b43b31c0..0aad0401 100644 --- a/lib/uisys.h +++ b/lib/uisys.h @@ -75,7 +75,7 @@ class oeApplication; #define ISKEYRELEASED(_k) ((UI_input.key == (_k) && UI_input.key_status == UIKEY_RELEASED) ? true : false) // inlined supporter functions -inline bool PT_IN_GADGET(UIWindow *wnd, UIGadget *gadget, int x, int y) { +static inline bool PT_IN_GADGET(UIWindow *wnd, UIGadget *gadget, int x, int y) { int gl, gt, gr, gb; gl = wnd->X() + gadget->X(); gt = wnd->Y() + gadget->Y(); @@ -89,26 +89,26 @@ inline bool PT_IN_GADGET(UIWindow *wnd, UIGadget *gadget, int x, int y) { return false; } -inline bool PT_IN_RECT(int x, int y, int l, int t, int w, int h) { +static inline bool PT_IN_RECT(int x, int y, int l, int t, int w, int h) { if (x >= l && x < (l + w) && y >= t && y < (t + h)) return true; else return false; } -inline int SCREEN_TO_WND_X(UIWindow *wnd, int x) { return (x - wnd->X()); } +static inline int SCREEN_TO_WND_X(UIWindow *wnd, int x) { return (x - wnd->X()); } -inline int SCREEN_TO_WND_Y(UIWindow *wnd, int y) { return (y - wnd->Y()); } +static inline int SCREEN_TO_WND_Y(UIWindow *wnd, int y) { return (y - wnd->Y()); } -inline int SCREEN_TO_GAD_X(UIGadget *gad, int x) { return (SCREEN_TO_WND_X(gad->GetWindow(), x) - gad->X()); } +static inline int SCREEN_TO_GAD_X(UIGadget *gad, int x) { return (SCREEN_TO_WND_X(gad->GetWindow(), x) - gad->X()); } -inline int SCREEN_TO_GAD_Y(UIGadget *gad, int y) { return (SCREEN_TO_WND_Y(gad->GetWindow(), y) - gad->Y()); } +static inline int SCREEN_TO_GAD_Y(UIGadget *gad, int y) { return (SCREEN_TO_WND_Y(gad->GetWindow(), y) - gad->Y()); } #define LOCK_FOCUS(_gadget) (_gadget)->LockFocus(); #define UNLOCK_FOCUS(_gadget) (_gadget)->UnlockFocus(); -inline float UI_TIME() { return UI_input.cur_time; } +static inline float UI_TIME() { return UI_input.cur_time; } ////////////////////////////////////////////////////////////////////////////// // FUNCTIONS diff --git a/lib/vecmat_external.h b/lib/vecmat_external.h index 2fc6e6f3..2dc3fef8 100644 --- a/lib/vecmat_external.h +++ b/lib/vecmat_external.h @@ -76,13 +76,13 @@ typedef struct { } matrix4; // Zero's out a vector -inline void vm_MakeZero(vector *v) { v->x = v->y = v->z = 0; } +static inline void vm_MakeZero(vector *v) { v->x = v->y = v->z = 0; } // Set an angvec to {0,0,0} -inline void vm_MakeZero(angvec *a) { a->p = a->h = a->b = 0; } +static inline void vm_MakeZero(angvec *a) { a->p = a->h = a->b = 0; } // Checks for equality -inline bool operator==(vector a, vector b) { +static inline bool operator==(vector a, vector b) { bool equality = false; // Adds two vectors. @@ -93,7 +93,7 @@ inline bool operator==(vector a, vector b) { } // Checks for inequality -inline bool operator!=(vector a, vector b) { +static inline bool operator!=(vector a, vector b) { bool equality = true; // Adds two vectors. @@ -104,7 +104,7 @@ inline bool operator!=(vector a, vector b) { } // Adds 2 vectors -inline vector operator+(vector a, vector b) { +static inline vector operator+(vector a, vector b) { // Adds two vectors. a.x += b.x; @@ -115,10 +115,10 @@ inline vector operator+(vector a, vector b) { } // Adds 2 vectors -inline vector operator+=(vector &a, vector b) { return (a = a + b); } +static inline vector operator+=(vector &a, vector b) { return (a = a + b); } // Adds 2 matrices -inline matrix operator+(matrix a, matrix b) { +static inline matrix operator+(matrix a, matrix b) { // Adds two 3x3 matrixs. a.rvec += b.rvec; @@ -129,10 +129,10 @@ inline matrix operator+(matrix a, matrix b) { } // Adds 2 matrices -inline matrix operator+=(matrix &a, matrix b) { return (a = a + b); } +static inline matrix operator+=(matrix &a, matrix b) { return (a = a + b); } // Subtracts 2 vectors -inline vector operator-(vector a, vector b) { +static inline vector operator-(vector a, vector b) { // subtracts two vectors a.x -= b.x; @@ -143,10 +143,10 @@ inline vector operator-(vector a, vector b) { } // Subtracts 2 vectors -inline vector operator-=(vector &a, vector b) { return (a = a - b); } +static inline vector operator-=(vector &a, vector b) { return (a = a - b); } // Subtracts 2 matrices -inline matrix operator-(matrix a, matrix b) { +static inline matrix operator-(matrix a, matrix b) { // subtracts two 3x3 matrices a.rvec = a.rvec - b.rvec; @@ -157,13 +157,13 @@ inline matrix operator-(matrix a, matrix b) { } // Subtracts 2 matrices -inline matrix operator-=(matrix &a, matrix b) { return (a = a - b); } +static inline matrix operator-=(matrix &a, matrix b) { return (a = a - b); } // Does a simple dot product calculation -inline float operator*(vector u, vector v) { return (u.x * v.x) + (u.y * v.y) + (u.z * v.z); } +static inline float operator*(vector u, vector v) { return (u.x * v.x) + (u.y * v.y) + (u.z * v.z); } // Scalar multiplication -inline vector operator*(vector v, float s) { +static inline vector operator*(vector v, float s) { v.x *= s; v.y *= s; v.z *= s; @@ -172,13 +172,13 @@ inline vector operator*(vector v, float s) { } // Scalar multiplication -inline vector operator*=(vector &v, float s) { return (v = v * s); } +static inline vector operator*=(vector &v, float s) { return (v = v * s); } // Scalar multiplication -inline vector operator*(float s, vector v) { return v * s; } +static inline vector operator*(float s, vector v) { return v * s; } // Scalar multiplication -inline matrix operator*(float s, matrix m) { +static inline matrix operator*(float s, matrix m) { m.fvec = m.fvec * s; m.uvec = m.uvec * s; m.rvec = m.rvec * s; @@ -187,13 +187,13 @@ inline matrix operator*(float s, matrix m) { } // Scalar multiplication -inline matrix operator*(matrix m, float s) { return s * m; } +static inline matrix operator*(matrix m, float s) { return s * m; } // Scalar multiplication -inline matrix operator*=(matrix &m, float s) { return (m = m * s); } +static inline matrix operator*=(matrix &m, float s) { return (m = m * s); } // Scalar division -inline vector operator/(vector src, float n) { +static inline vector operator/(vector src, float n) { src.x /= n; src.y /= n; src.z /= n; @@ -202,10 +202,10 @@ inline vector operator/(vector src, float n) { } // Scalar division -inline vector operator/=(vector &src, float n) { return (src = src / n); } +static inline vector operator/=(vector &src, float n) { return (src = src / n); } // Scalar division -inline matrix operator/(matrix src, float n) { +static inline matrix operator/(matrix src, float n) { src.fvec = src.fvec / n; src.rvec = src.rvec / n; src.uvec = src.uvec / n; @@ -214,11 +214,11 @@ inline matrix operator/(matrix src, float n) { } // Scalar division -inline matrix operator/=(matrix &src, float n) { return (src = src / n); } +static inline matrix operator/=(matrix &src, float n) { return (src = src / n); } // Computes a cross product between u and v, returns the result // in Normal. -inline vector operator^(vector u, vector v) { +static inline vector operator^(vector u, vector v) { vector dest; dest.x = (u.y * v.z) - (u.z * v.y); @@ -229,7 +229,7 @@ inline vector operator^(vector u, vector v) { } // Matrix transpose -inline matrix operator~(matrix m) { +static inline matrix operator~(matrix m) { float t; t = m.uvec.x; @@ -246,7 +246,7 @@ inline matrix operator~(matrix m) { } // Negate vector -inline vector operator-(vector a) { +static inline vector operator-(vector a) { a.x *= -1; a.y *= -1; a.z *= -1; @@ -255,7 +255,7 @@ inline vector operator-(vector a) { } // Apply a matrix to a vector -inline vector operator*(vector v, matrix m) { +static inline vector operator*(vector v, matrix m) { vector result; result.x = v * m.rvec; @@ -265,7 +265,7 @@ inline vector operator*(vector v, matrix m) { return result; } -inline float vm_Dot3Vector(float x, float y, float z, vector *v) { return (x * v->x) + (y * v->y) + (z * v->z); } +static inline float vm_Dot3Vector(float x, float y, float z, vector *v) { return (x * v->x) + (y * v->y) + (z * v->z); } #define vm_GetSurfaceNormal vm_GetNormal diff --git a/lnxcontroller/lnxcontroller.cpp b/lnxcontroller/lnxcontroller.cpp index 5d9e46cd..052ca08e 100644 --- a/lnxcontroller/lnxcontroller.cpp +++ b/lnxcontroller/lnxcontroller.cpp @@ -149,10 +149,10 @@ void lnxgameController::set_controller_deadzone(int ctl, float deadzone) { char Ctltext_AxisBindings[][16] = {"", "X-axis", "Y-axis", "Z-axis", "R-axis", "U-axis", "V-axis"}; -char Ctltext_BtnBindings[][16] = {"", "btn1", "btn2", "btn3", "btn4", "btn5", "btn6", "btn7", "btn8", - "btn9", "btn10", "btn11", "btn12", "btn13", "btn14", "btn15", "btn16", "btn17", - "btn18", "btn19", "btn20", "btn21", "btn22", "btn23", "btn24", "btn25", "btn26", - "btn27", "btn28", "btn29", "btn30", "btn31", "btn32"}; +static char Ctltext_BtnBindings[][16] = { + "", "btn1", "btn2", "btn3", "btn4", "btn5", "btn6", "btn7", "btn8", "btn9", "btn10", + "btn11", "btn12", "btn13", "btn14", "btn15", "btn16", "btn17", "btn18", "btn19", "btn20", "btn21", + "btn22", "btn23", "btn24", "btn25", "btn26", "btn27", "btn28", "btn29", "btn30", "btn31", "btn32"}; char Ctltext_PovBindings[][16] = {"", "pov-U", "pov-R", "pov-D", "pov-L"}; diff --git a/model/newstyle.cpp b/model/newstyle.cpp index a4c58e8c..5e5f0c7b 100644 --- a/model/newstyle.cpp +++ b/model/newstyle.cpp @@ -112,7 +112,27 @@ static float Fog_distance, Fog_eye_distance; static vector Fog_view_pos, Specular_view_pos, Bump_view_pos; static matrix Unscaled_bumpmap_matrix; -static int ModelFaceSortFunc(const short *a, const short *b) { +static int ModelFaceSortFunc(const short *a, const short *b); +static inline void RenderSubmodelFace(poly_model *pm, bsp_info *sm, int facenum); +static inline void RenderSubmodelLightmapFace(poly_model *pm, bsp_info *sm, int facenum); +static inline void RenderSubmodelFaceFogged(poly_model *pm, bsp_info *sm, int facenum); +static inline void RenderSubmodelFaceSpecular(poly_model *pm, bsp_info *sm, int facenum); + +/// Draws a glowing cone of light. +static void DrawGlowEffect(vector *pos, float r, float g, float b, vector *norm, float size); + +/// Draws a glowing cone of light that represents thrusters +static void DrawThrusterEffect(vector *pos, float r, float g, float b, vector *norm, float size, float length); + +static void RenderSubmodelFacesSorted(poly_model *pm, bsp_info *sm); +static void RenderSubmodelFacesUnsorted(poly_model *pm, bsp_info *sm); + +/// Rotates all of the points of a submodel, plus supplies color info. +static void RotateModelPoints(poly_model *pm, bsp_info *sm); + +static float ComputeDefaultSizeFunc(int handle, float *size_ptr, vector *offset_ptr, bool f_use_all_frames); + +int ModelFaceSortFunc(const short *a, const short *b) { float az, bz; az = face_depth[*a]; @@ -127,7 +147,7 @@ static int ModelFaceSortFunc(const short *a, const short *b) { } #ifdef _DEBUG -void model_draw_outline(int nverts, g3Point **pointlist) { +static void model_draw_outline(int nverts, g3Point **pointlist) { int i; for (i = 0; i < nverts - 1; i++) @@ -136,7 +156,7 @@ void model_draw_outline(int nverts, g3Point **pointlist) { g3_DrawLine(GR_RGB(255, 255, 255), pointlist[i], pointlist[0]); } -void DrawSubmodelFaceOutline(int nv, g3Point **pointlist) { +static void DrawSubmodelFaceOutline(int nv, g3Point **pointlist) { int i; g3Point tpnt[64]; g3Point *tpnt_list[64]; @@ -882,10 +902,6 @@ void RenderSubmodelFacesUnsorted(poly_model *pm, bsp_info *sm) { } } -void BuildModelAngleMatrix(matrix *mat, angle ang, vector *axis); -void StartLightInstance(vector *, matrix *); -void DoneLightInstance(); - // Rotates all of the points of a submodel, plus supplies color info void RotateModelPoints(poly_model *pm, bsp_info *sm) { diff --git a/model/polymodel.cpp b/model/polymodel.cpp index df11f3d1..c984051d 100644 --- a/model/polymodel.cpp +++ b/model/polymodel.cpp @@ -614,6 +614,7 @@ #include #include "robotfire.h" #include "mem.h" +#include "gamesequence.h" #include @@ -658,6 +659,28 @@ lightmap_object *Polylighting_lightmap_object; vector *Polymodel_light_direction, Polymodel_fog_plane, Polymodel_specular_pos, Polymodel_fog_portal_vert, Polymodel_bump_pos; +static inline void RecursiveAssignWB(poly_model *pm, int sm_index, int wb_index); +static void FindWBSubobjects(poly_model *pm); +/// Sets aside a polymodel for use. +/// Errors and returns -1 if none free. +static int AllocPolyModel(); +static void ReadModelVector(vector *vec, CFILE *infile); +static void ReadModelStringLen(char *ptr, int len, CFILE *infile); +/// Given a modelnumber, opens the original pof file and attempts to rematch that +/// models textures with the bitmaps with have in memory. +static int ReloadModelTextures(int modelnum); +static void SetPolymodelProperties(bsp_info *subobj, char *props); +static void MinMaxSubmodel(poly_model *pm, bsp_info *sm, vector offset); +static void FindMinMaxForModel(poly_model *pm); +static int ReadNewModelFile(int polynum, CFILE *infile); +static void SetNormalizedTimeObjTimed(object *obj, float *normalized_time); +static void SetNormalizedTimeAnimTimed(float frame, float *normalized_time, poly_model *pm); +static void FreeAllModels(); +/// Given a model pointer and an array of floats that go from 0..1, calculate the interpolated +/// position/angle of each corresponding subobject. +static void SetModelAnglesAndPosTimed(poly_model *po, float *normalized_time, uint subobj_flags); +static void BuildModelAngleMatrix(matrix *mat, angle ang, vector *axis); + int findtextbmpname = 0; int findtextname = 0; @@ -2039,9 +2062,6 @@ int ReadNewModelFile(int polynum, CFILE *infile) { return 1; } -extern int paged_in_count; -extern int paged_in_num; - // given a filename, reads in a POF and returns an index into the Poly_models array // returns -1 if something is wrong int LoadPolyModel(const char *filename, int pageable) { @@ -2212,6 +2232,7 @@ poly_model *GetPolymodelPointer(int polynum) { return (&Poly_models[polynum]); } +// MTS: only used in this file. // gets the filename from a path void ChangePolyModelName(const char *src, char *dest) { int limit; @@ -2736,13 +2757,13 @@ void SetModelAnglesAndPos(poly_model *po, float *normalized_time, uint subobj_fl } } -vector Instance_fog_plane_stack[MAX_SUBOBJECTS]; -vector Instance_fog_portal_vert_stack[MAX_SUBOBJECTS]; -vector Instance_light_stack[MAX_SUBOBJECTS]; -vector Instance_specular_pos[MAX_SUBOBJECTS]; -vector Instance_bump_pos[MAX_SUBOBJECTS]; +static vector Instance_fog_plane_stack[MAX_SUBOBJECTS]; +static vector Instance_fog_portal_vert_stack[MAX_SUBOBJECTS]; +static vector Instance_light_stack[MAX_SUBOBJECTS]; +static vector Instance_specular_pos[MAX_SUBOBJECTS]; +static vector Instance_bump_pos[MAX_SUBOBJECTS]; -int Instance_light_cnt = 0; +static int Instance_light_cnt = 0; void StartLightInstance(vector *pos, matrix *orient) { int gouraud = 0, specular = 0, fogged = 0, bumped = 0; @@ -3073,6 +3094,7 @@ int InitModels() { return 1; } +// MTS: used only in this file. // Given an actual keyframe number, returns the normalized (0 to 1) position of that // keyframe // Handle is an index into the Poly_models array @@ -3109,6 +3131,7 @@ void RemapPolyModels() { } } +// MTS: not used? // Returns the total number of faces in a model int CountFacesInPolymodel(poly_model *pm) { int i; diff --git a/module/module.cpp b/module/module.cpp index a733a44d..f0452eaa 100644 --- a/module/module.cpp +++ b/module/module.cpp @@ -99,7 +99,7 @@ #ifdef __LINUX__ #include -bool mod_FindRealFileNameCaseInsenstive(const char *directory, const char *filename, char *new_filename); +static bool mod_FindRealFileNameCaseInsenstive(const char *directory, const char *filename, char *new_filename); #endif #include "module.h" @@ -113,7 +113,7 @@ bool mod_FindRealFileNameCaseInsenstive(const char *directory, const char *filen #endif #if defined(WIN32) // INSTEAD OF MAKING MODULE HAVE DEPENDENCIES, PUT THE 2 DDIO FUNCTIONS I NEED HERE // Split a pathname into its component parts -void dd_SplitPath(const char *srcPath, char *path, char *filename, char *ext) { +static void dd_SplitPath(const char *srcPath, char *path, char *filename, char *ext) { char drivename[_MAX_DRIVE], dirname[_MAX_DIR]; _splitpath(srcPath, drivename, dirname, filename, ext); if (path) @@ -125,7 +125,7 @@ void dd_SplitPath(const char *srcPath, char *path, char *filename, char *ext) { // (specified in local file system syntax) // takes a variable number of subdirectories which will be concatenated on to the path // the last argument in the list of sub dirs *MUST* be NULL to terminate the list -void dd_MakePath(char *newPath, const char *absolutePathHeader, const char *subDir, ...) { +static void dd_MakePath(char *newPath, const char *absolutePathHeader, const char *subDir, ...) { const char delimiter = '\\'; va_list args; char *currentDir = NULL; @@ -160,7 +160,7 @@ void dd_MakePath(char *newPath, const char *absolutePathHeader, const char *subD } #elif defined(__LINUX__) // Split a pathname into its component parts -void dd_SplitPath(const char *srcPath, char *path, char *filename, char *ext) { +static void dd_SplitPath(const char *srcPath, char *path, char *filename, char *ext) { int pathStart = -1; int pathEnd = -1; int fileStart = -1; @@ -237,7 +237,7 @@ void dd_SplitPath(const char *srcPath, char *path, char *filename, char *ext) { // (specified in local file system syntax) // takes a variable number of subdirectories which will be concatenated on to the path // the last argument in the list of sub dirs *MUST* be NULL to terminate the list -void dd_MakePath(char *newPath, const char *absolutePathHeader, const char *subDir, ...) { +static void dd_MakePath(char *newPath, const char *absolutePathHeader, const char *subDir, ...) { const char delimiter = '/'; va_list args; char *currentDir = NULL; diff --git a/movie/d3movie.cpp b/movie/d3movie.cpp index dad97d36..7fa27b0f 100644 --- a/movie/d3movie.cpp +++ b/movie/d3movie.cpp @@ -432,17 +432,18 @@ public: #endif } // namespace -void *CallbackAlloc(unsigned int size); -void CallbackFree(void *p); -unsigned int CallbackFileRead(int hFile, void *pBuffer, unsigned int bufferCount); -void InitializePalette(); -void CallbackSetPalette(unsigned char *pBuffer, unsigned int start, unsigned int count); -void CallbackShowFrame(unsigned char *buf, unsigned int bufw, unsigned int bufh, unsigned int sx, unsigned int sy, - unsigned int w, unsigned int h, unsigned int dstx, unsigned int dsty, unsigned int hicolor); +static void *CallbackAlloc(unsigned int size); +static void CallbackFree(void *p); +static unsigned int CallbackFileRead(int hFile, void *pBuffer, unsigned int bufferCount); +static void InitializePalette(); +static void CallbackSetPalette(unsigned char *pBuffer, unsigned int start, unsigned int count); +static void CallbackShowFrame(unsigned char *buf, unsigned int bufw, unsigned int bufh, unsigned int sx, + unsigned int sy, unsigned int w, unsigned int h, unsigned int dstx, unsigned int dsty, + unsigned int hicolor); #ifndef NO_MOVIES -bool mve_InitSound(oeApplication *app, MovieSoundDevice &device); -void mve_CloseSound(MovieSoundDevice &device); +static bool mve_InitSound(oeApplication *app, MovieSoundDevice &device); +static void mve_CloseSound(MovieSoundDevice &device); #endif // sets the directory where movies are stored diff --git a/music/omflex.cpp b/music/omflex.cpp index 0dd5b5ed..35e62764 100644 --- a/music/omflex.cpp +++ b/music/omflex.cpp @@ -86,9 +86,10 @@ #define OMFFILEERR_GOTO (INFFILE_CUSTOM + 3) // no goto label exists #define OMFFILEERR_SYNTAX (INFFILE_CUSTOM + 4) // syntax error. -const char *OMFCommands[OMFCMD_NUM] = {"stream", "section", "play", "endsection", "label", "compare", "lcmp", - "llpt", "lplc", "inci", "seti", "ifi", "region", "endregion", - "q2", "blt", "bgt", "beq", "bnif", "goto", "wait"}; +static const char *OMFCommands[OMFCMD_NUM] = { + "stream", "section", "play", "endsection", "label", "compare", "lcmp", "llpt", "lplc", "inci", "seti", + "ifi", "region", "endregion", "q2", "blt", "bgt", "beq", "bnif", "goto", "wait"}; +static int OMFLex(const char *command); int OMFLex(const char *command) { for (int i = 0; i < OMFCMD_NUM; i++) { diff --git a/netcon/includes/con_dll.h b/netcon/includes/con_dll.h index a9392ea6..bf36edc3 100644 --- a/netcon/includes/con_dll.h +++ b/netcon/includes/con_dll.h @@ -393,7 +393,7 @@ DescentDefer_fp DLLDescentDefer; typedef void (*DoMessageBox_fp)(const char *title, const char *msg, int type, ddgr_color title_color, ddgr_color text_color); DoMessageBox_fp DLLDoMessageBoxFP; -inline void DLLDoMessageBox(const char *title, const char *msg, int type, ddgr_color title_color = GR_WHITE, +static inline void DLLDoMessageBox(const char *title, const char *msg, int type, ddgr_color title_color = GR_WHITE, ddgr_color text_color = GR_WHITE) { DLLDoMessageBoxFP(title, msg, type, title_color, text_color); } @@ -458,7 +458,7 @@ ddio_FindNextFile_fp DLLddio_FindNextFile; // typedef void( *MultiStartServer_fp) (int playing,char *scriptname,int dedicated_num_teams=-1); typedef void (*MultiStartServer_fp)(int playing, char *scriptname, int dedicated_num_teams); MultiStartServer_fp DLLMultiStartServerFP; -inline void DLLMultiStartServer(int playing, char *scriptname, int dedicated_num_teams = -1) { +static inline void DLLMultiStartServer(int playing, char *scriptname, int dedicated_num_teams = -1) { DLLMultiStartServerFP(playing, scriptname, dedicated_num_teams); } @@ -489,7 +489,7 @@ RemoveUITextItem_fp DLLRemoveUITextItem; typedef void *(*CreateNewUITextItem_fp)(const char *newtext, unsigned int color, int font); CreateNewUITextItem_fp DLLCreateNewUITextItemFP; -inline void *DLLCreateNewUITextItem(const char *newtext, unsigned int color, int font = -1) { +static inline void *DLLCreateNewUITextItem(const char *newtext, unsigned int color, int font = -1) { return DLLCreateNewUITextItemFP(newtext, color, font); } diff --git a/netcon/includes/inetgetfile.h b/netcon/includes/inetgetfile.h index 0b825955..f02617f5 100644 --- a/netcon/includes/inetgetfile.h +++ b/netcon/includes/inetgetfile.h @@ -127,7 +127,7 @@ #define SOCKET_ERROR -1 #ifndef NETWORKING_H -inline int WSAGetLastError() { return errno; } +static inline int WSAGetLastError() { return errno; } #endif diff --git a/netcon/inetfile/CFtp.cpp b/netcon/inetfile/CFtp.cpp index 12006202..8d964b2b 100644 --- a/netcon/inetfile/CFtp.cpp +++ b/netcon/inetfile/CFtp.cpp @@ -80,9 +80,9 @@ typedef int socklen_t; #include "inetgetfile.h" #endif - #include "CFtp.h" +// MTS: only used in this file? #ifdef __LINUX__ int FTPObjThread(void *obj) #else diff --git a/netcon/inetfile/Chttpget.cpp b/netcon/inetfile/Chttpget.cpp index 84ae00b4..ee687943 100644 --- a/netcon/inetfile/Chttpget.cpp +++ b/netcon/inetfile/Chttpget.cpp @@ -123,7 +123,6 @@ #include #endif - #include #include #include @@ -155,12 +154,14 @@ inline void Sleep(int millis) { #define NW_AGHBN_READ 3 #ifndef __LINUX__ -void __cdecl http_gethostbynameworker(void *parm); +static void HTTPObjThread(void *obj); +static void __cdecl http_gethostbynameworker(void *parm); #else -int http_gethostbynameworker(void *parm); +static int HTTPObjThread(void *obj); +static int http_gethostbynameworker(void *parm); #endif -int http_Asyncgethostbyname(unsigned int *ip, int command, char *hostname); +static int http_Asyncgethostbyname(unsigned int *ip, int command, char *hostname); #ifndef __LINUX__ void HTTPObjThread(void *obj) @@ -679,14 +680,8 @@ typedef struct _async_dns_lookup { #endif } async_dns_lookup; -async_dns_lookup httpaslu; -async_dns_lookup *http_lastaslu = NULL; - -#ifndef __LINUX__ -void __cdecl http_gethostbynameworker(void *parm); -#else -int http_gethostbynameworker(void *parm); -#endif +static async_dns_lookup httpaslu; +static async_dns_lookup *http_lastaslu = NULL; int http_Asyncgethostbyname(unsigned int *ip, int command, char *hostname) { diff --git a/netcon/lanclient/lanclient.cpp b/netcon/lanclient/lanclient.cpp index 207bc358..7aa0b332 100644 --- a/netcon/lanclient/lanclient.cpp +++ b/netcon/lanclient/lanclient.cpp @@ -325,7 +325,6 @@ extern int MTAVersionCheck(unsigned int oldver, char *URL); ///////////////////////////// // Defines - // These next two function prototypes MUST appear in the extern "C" block if called // from a CPP file. extern "C" { @@ -691,6 +690,7 @@ int MainMultiplayerMenu() { return ret; } +// MTS: only used in this file void AutoLoginAndJoinGame(void) { unsigned short port; unsigned int iaddr; diff --git a/netgames/anarchy/anarchy.cpp b/netgames/anarchy/anarchy.cpp index f2203807..4ea57e9b 100644 --- a/netgames/anarchy/anarchy.cpp +++ b/netgames/anarchy/anarchy.cpp @@ -60,32 +60,35 @@ #include IDMFC *DMFCBase = NULL; -IDmfcStats *dstat = NULL; +static IDmfcStats *dstat = NULL; -int SortedPlayers[MAX_PLAYER_RECORDS]; // sorted player nums -bool DisplayScoreScreen; -int Highlight_bmp = -1; +static int SortedPlayers[MAX_PLAYER_RECORDS]; // sorted player nums +static bool DisplayScoreScreen; +static int Highlight_bmp = -1; #define AHD_NONE 0 #define AHD_SCORE 1 #define AHD_EFFICIENCY 2 #define ACM_PLAYERCOLOR 0 #define ACM_NORMAL 1 -ubyte Anarchy_hud_display = AHD_SCORE; -ubyte HUD_color_model = ACM_PLAYERCOLOR; -bool display_my_welcome = false; +static ubyte Anarchy_hud_display = AHD_SCORE; +static ubyte HUD_color_model = ACM_PLAYERCOLOR; +static bool display_my_welcome = false; -void DisplayHUDScores(struct tHUDItem *hitem); -void DisplayScores(void); -void DisplayWelcomeMessage(int player_num); -void SaveStatsToFile(char *filename); -void SwitchHUDColor(int i); +static void DisplayHUDScores(struct tHUDItem *hitem); +static void DisplayScores(void); +static void DisplayWelcomeMessage(int player_num); +static void SaveStatsToFile(char *filename); +static void SwitchHUDColor(int i); +static void SwitchAnarchyScores(int i); +static const char *GetString(int d); +static void DetermineScore(int precord_num, int column_num, char *buffer, int buffer_size); /////////////////////////////////////////////// // localization info -char **StringTable; -int StringTableSize = 0; -const char *_ErrorString = "Missing String"; +static char **StringTable; +static int StringTableSize = 0; +static const char *_ErrorString = "Missing String"; const char *GetString(int d) { if ((d < 0) || (d >= StringTableSize)) return _ErrorString; @@ -115,7 +118,6 @@ void SwitchAnarchyScores(int i) { }; } - // This function gets called by the game when it wants to learn some info about the game void DLLFUNCCALL DLLGetGameInfo(tDLLOptions *options) { options->flags = DOF_MAXTEAMS; @@ -1005,4 +1007,3 @@ void SwitchHUDColor(int i) { break; }; } - diff --git a/netgames/coop/coop.cpp b/netgames/coop/coop.cpp index 31be2dd2..6238346a 100644 --- a/netgames/coop/coop.cpp +++ b/netgames/coop/coop.cpp @@ -109,12 +109,16 @@ #include IDMFC *DMFCBase = NULL; -IDmfcStats *dstat = NULL; -player *dPlayers; +static IDmfcStats *dstat = NULL; +static player *dPlayers; typedef struct { int Score[2]; } tPlayerStat; + +static int pack_pstat(tPlayerStat *user_info, ubyte *data); +static int unpack_pstat(tPlayerStat *user_info, ubyte *data); + int pack_pstat(tPlayerStat *user_info, ubyte *data) { int count = 0; MultiAddInt(user_info->Score[0], data, &count); @@ -131,9 +135,9 @@ int unpack_pstat(tPlayerStat *user_info, ubyte *data) { /////////////////////////////////////////////// // localization info -char **StringTable; -int StringTableSize = 0; -const char *_ErrorString = "Missing String"; +static char **StringTable; +static int StringTableSize = 0; +static const char *_ErrorString = "Missing String"; const char *GetStringFromTable(int d) { if ((d < 0) || (d >= StringTableSize)) return _ErrorString; @@ -141,18 +145,19 @@ const char *GetStringFromTable(int d) { return StringTable[d]; } /////////////////////////////////////////////// -int SortedPlayers[MAX_PLAYER_RECORDS]; -bool DisplayScoreScreen = false; -bool FirstFrame = false; -bool display_my_welcome = false; +static int SortedPlayers[MAX_PLAYER_RECORDS]; +static bool DisplayScoreScreen = false; +static bool FirstFrame = false; +static bool display_my_welcome = false; -void DisplayWelcomeMessage(int player_num); -void DisplayHUDScores(struct tHUDItem *hitem); -int Highlight_bmp = -1; - -void OnPLRInterval(void); -void OnPLRInit(void); +static void DisplayWelcomeMessage(int player_num); +static void DisplayHUDScores(struct tHUDItem *hitem); +static void DetermineScore(int precord_num, int column_num, char *buffer, int buffer_size); +static bool compare_slots(int a, int b); +static int Highlight_bmp = -1; +static void OnPLRInterval(void); +static void OnPLRInit(void); void DetermineScore(int precord_num, int column_num, char *buffer, int buffer_size) { player_record *pr = DMFCBase->GetPlayerRecord(precord_num); @@ -792,8 +797,8 @@ void OnPrintScores(int level) { */ } -float PLRElapsedtime = 0.0f; -float PLRLasttime = 0.0f; +static float PLRElapsedtime = 0.0f; +static float PLRLasttime = 0.0f; void OnPLRInit(void) { PLRElapsedtime = 0.0f; @@ -834,4 +839,3 @@ void OnPLRInterval(void) { DLLgrtext_Flush(); } - diff --git a/netgames/ctf/ctf.cpp b/netgames/ctf/ctf.cpp index 3bc21450..efde17df 100644 --- a/netgames/ctf/ctf.cpp +++ b/netgames/ctf/ctf.cpp @@ -92,12 +92,12 @@ #include "CTFstr.h" IDMFC *DMFCBase; -IDmfcStats *dstat; +static IDmfcStats *dstat; -object *dObjects; -player *dPlayers; -room *dRooms; -netplayer *dNetPlayers; +static object *dObjects; +static player *dPlayers; +static room *dRooms; +static netplayer *dNetPlayers; #define SPID_GAMESTATE 0x01 #define SPID_ADDDELFLAG 0x02 @@ -139,20 +139,22 @@ $$TABLE_SOUND "CTFReturnedFlag1" $$TABLE_SOUND "CTFHatTrick" $$TABLE_SOUND "CTFHatTrick" */ -int snd_return_ownteam = -1; -int snd_return_otherteam = -1; -int snd_pickedup_otherteam = -1; -int snd_pickedup_ownteam = -1; -int snd_score_ownteam = -1; -int snd_score_otherteam = -1; -int snd_lose_ownteam = -1; -int snd_lose_otherteam = -1; -int snd_hattrick_first = -1; -int snd_hattrick_reg = -1; +static int snd_return_ownteam = -1; +static int snd_return_otherteam = -1; +static int snd_pickedup_otherteam = -1; +static int snd_pickedup_ownteam = -1; +static int snd_score_ownteam = -1; +static int snd_score_otherteam = -1; +static int snd_lose_ownteam = -1; +static int snd_lose_otherteam = -1; +static int snd_hattrick_first = -1; +static int snd_hattrick_reg = -1; typedef struct { int Score[2]; } tPlayerStat; // Overall scores (throughout the game) +static int pack_pstat(tPlayerStat *user_info, ubyte *data); +static int unpack_pstat(tPlayerStat *user_info, ubyte *data); int pack_pstat(tPlayerStat *user_info, ubyte *data) { int count = 0; MultiAddInt(user_info->Score[0], data, &count); @@ -167,77 +169,78 @@ int unpack_pstat(tPlayerStat *user_info, ubyte *data) { return count; } -int SortedPlayers[MAX_PLAYER_RECORDS]; // sorted player nums -int SortedPLRPlayers[DLLMAX_TEAMS][MAX_PLAYER_RECORDS]; +static int SortedPlayers[MAX_PLAYER_RECORDS]; // sorted player nums +static int SortedPLRPlayers[DLLMAX_TEAMS][MAX_PLAYER_RECORDS]; -int TeamScores[DLLMAX_TEAMS]; // teams scores -int OverallTeamScores[DLLMAX_TEAMS]; // overall scores per team -int SortedTeams[DLLMAX_TEAMS]; // sorted team scores -int Highlight_bmp = -1; -bool DisplayScoreScreen; -bool Someone_has_hattrick = false; // this is false if no one has had a hattrick this level -bool First_game_frame = false; +static int TeamScores[DLLMAX_TEAMS]; // teams scores +static int OverallTeamScores[DLLMAX_TEAMS]; // overall scores per team +static int SortedTeams[DLLMAX_TEAMS]; // sorted team scores +static int Highlight_bmp = -1; +static bool DisplayScoreScreen; +static bool Someone_has_hattrick = false; // this is false if no one has had a hattrick this level +static bool First_game_frame = false; -int FlagIDs[DLLMAX_TEAMS]; // Flag Object ID's -int AFlagIDs[DLLMAX_TEAMS]; // Attached Flag Object ID's -int GoalRooms[DLLMAX_TEAMS]; // Goal Rooms for Teams -int FlagBmp[DLLMAX_TEAMS]; // Flag Bitmap handles -int FlagAHBmp[DLLMAX_TEAMS]; // Flag At Home Bitmap handles -int DimFlagAHBmp[DLLMAX_TEAMS]; // Dimmed versions of the Flag At Home Bitmaps -bool FlagAtHome[DLLMAX_TEAMS]; // Flag At Home bools -int HasFlag[DLLMAX_TEAMS]; // List of Playernums of who has what flag, -1 if no one does -bool DisplayFlagBlink = true, DisplayScoreBlink = true; -int WhoJustFlagged = -1, WhoJustFlaggedTimer = -1; -int WhoJustScored = -1, WhoJustScoredTimer = -1; -int CTFNumOfTeams = 2; -int ChildFlags[DLLMAX_TEAMS]; // Object handles of attached flags as a player has em +static int FlagIDs[DLLMAX_TEAMS]; // Flag Object ID's +static int AFlagIDs[DLLMAX_TEAMS]; // Attached Flag Object ID's +static int GoalRooms[DLLMAX_TEAMS]; // Goal Rooms for Teams +static int FlagBmp[DLLMAX_TEAMS]; // Flag Bitmap handles +static int FlagAHBmp[DLLMAX_TEAMS]; // Flag At Home Bitmap handles +static int DimFlagAHBmp[DLLMAX_TEAMS]; // Dimmed versions of the Flag At Home Bitmaps +static bool FlagAtHome[DLLMAX_TEAMS]; // Flag At Home bools +static int HasFlag[DLLMAX_TEAMS]; // List of Playernums of who has what flag, -1 if no one does +static bool DisplayFlagBlink = true, DisplayScoreBlink = true; +static int WhoJustFlagged = -1, WhoJustFlaggedTimer = -1; +static int WhoJustScored = -1, WhoJustScoredTimer = -1; +static int CTFNumOfTeams = 2; +static int ChildFlags[DLLMAX_TEAMS]; // Object handles of attached flags as a player has em -float Flag_timeout_timers[DLLMAX_TEAMS]; -bool display_my_welcome = false; +static float Flag_timeout_timers[DLLMAX_TEAMS]; +static bool display_my_welcome = false; -void OnTimerScoreKill(void); // timer callback: when a score flash timer ends -void OnTimerScore(void); // timer callback: on a score flash interval -void OnTimer(void); // timer callback: when a flag taken flash timer ends -void OnTimerKill(void); // timer callback: on a flag taken flash interval -void DisplayWelcomeMessage(int player_num); // displays a welcome message to the player when he joins -void SortTeamScores(int *sortedindex, int *scores); // sorts an array of team scores, filling in the sorted index - // numbers -void DisplayHUDScores(struct tHUDItem *hitem); // callback when the HUD info is to be drawn -void ReceiveGameState(ubyte *data); // callback when a gamestate packet is received from the server -void SendGameState(int playernum); // called when the server is to send gamestate packet to a client -void SetColoredBalls( +static void OnTimerScoreKill(void); // timer callback: when a score flash timer ends +static void OnTimerScore(void); // timer callback: on a score flash interval +static void OnTimer(void); // timer callback: when a flag taken flash timer ends +static void OnTimerKill(void); // timer callback: on a flag taken flash interval +static void DisplayWelcomeMessage(int player_num); // displays a welcome message to the player when he joins +static void SortTeamScores(int *sortedindex, int *scores); // sorts an array of team scores, filling in the sorted index + // numbers +static void DisplayHUDScores(struct tHUDItem *hitem); // callback when the HUD info is to be drawn +static void ReceiveGameState(ubyte *data); // callback when a gamestate packet is received from the server +static void SendGameState(int playernum); // called when the server is to send gamestate packet to a client +static void SetColoredBalls( int playernum, bool reset = false); // sets the colored balls around a player (determined by what is in their inventory) -void ChangeNumberOfTeams(int newsize); // called when the number of teams in the game is changed or to be changed -void DoFlagReturnedHome(int team); // called to handle any events when a flag is returned home for a team -void DoLoseFlag(int team); // called to handle any events when a team loses their flag -void TellClientsToAddorDelFlag(int pnum, int team, int objnum, bool add); -void ServerIsTellingMeToAddorDelAFlag(ubyte *data); -void OnGetTokenString(char *src, char *dest, int dest_size); -// returns the number of flags a player has, 0 if none, or an invalid pnum -int GetFlagCountForPlayer(int pnum); -// returns the mask of which flags this player currently has -ubyte GetFlagMaskForPlayer(int pnum); +static void ChangeNumberOfTeams(int newsize); // called when the number of teams in the game is changed or to be changed +static void DoFlagReturnedHome(int team); // called to handle any events when a flag is returned home for a team +static void DoLoseFlag(int team); // called to handle any events when a team loses their flag +static void TellClientsToAddorDelFlag(int pnum, int team, int objnum, bool add); +static void ServerIsTellingMeToAddorDelAFlag(ubyte *data); +static void OnGetTokenString(char *src, char *dest, int dest_size); +// returns the number of flags a player has, 0 if none, or an invalid pnum +static int GetFlagCountForPlayer(int pnum); +// returns the mask of which flags this player currently has +static ubyte GetFlagMaskForPlayer(int pnum); // adds a flag to a player, as a precaution, it will go through all the players and makes sure that no one // has the flag that is being added. If they are adding the flag, than remove that flag from whoever we thought // had it it will return false if it had to remove a flag from a player -bool GivePlayerFlag(int pnum, ubyte team); +static bool GivePlayerFlag(int pnum, ubyte team); // this function takes a flag away from the player, useful for when he scores, spews, disconnects, or observer modes -void LoseFlagForPlayer(int pnum, ubyte team, bool remove_from_inven = true); +static void LoseFlagForPlayer(int pnum, ubyte team, bool remove_from_inven = true); /////////////////////////////////////////////// // localization info/functions -char **StringTable; -int StringTableSize = 0; -const char *_ErrorString = "Missing String"; +static char **StringTable; +static int StringTableSize = 0; +static const char *_ErrorString = "Missing String"; const char *GetString(int d) { if ((d < 0) || (d >= StringTableSize)) return _ErrorString; else return StringTable[d]; } -void SaveStatsToFile(char *filename); - +static void SaveStatsToFile(char *filename); +static void DetermineScore(int precord_num, int column_num, char *buffer, int buffer_size); +static void ShowStatBitmap(int precord_num, int column_num, int x, int y, int w, int h, ubyte alpha_to_use); // This function gets called by the game when it wants to learn some info about the game void DLLFUNCCALL DLLGetGameInfo(tDLLOptions *options) { @@ -2714,4 +2717,3 @@ void OnGetTokenString(char *src, char *dest, int dest_size) { DMFCBase->OnGetTokenString(src, dest, dest_size); } - diff --git a/netgames/entropy/EntropyAux.h b/netgames/entropy/EntropyAux.h index 559eaa20..c1bd205b 100644 --- a/netgames/entropy/EntropyAux.h +++ b/netgames/entropy/EntropyAux.h @@ -61,6 +61,7 @@ void ReceiveTakeOverPacket(ubyte *data); void DoVirusCreate(ubyte *data); void SendVirusCreate(object *obj); bool IsPlayerInEnemy(int pnum); +void RemoveVirusFromPlayer(int player_num, bool remove_all); // Functions in EntropyRoom.cpp int SpewObjectInRoom(int type, int id, int roomnum); @@ -85,5 +86,7 @@ extern int LabText[NUM_TEAMS]; // texture handles to La extern int virus_id; // Object ID of the Virus object extern int *RoomList; // List of room index's that are special for Entropy (i.e. all the labs, repairs and energy rooms) extern int RoomCount; // Size of RoomList when it's finally allocated +extern room *dRooms; +extern object *dObjects; #endif diff --git a/netgames/entropy/EntropyBase.cpp b/netgames/entropy/EntropyBase.cpp index 01debba3..a68b28aa 100644 --- a/netgames/entropy/EntropyBase.cpp +++ b/netgames/entropy/EntropyBase.cpp @@ -105,11 +105,11 @@ // the DMFC object, used throughout, and required by all mods IDMFC *DMFCBase = NULL; // our DmfcStats object, used for the F7 screen -IDmfcStats *dstat = NULL; +static IDmfcStats *dstat = NULL; // these are some helper pointers, so we don't have to constantly query // DMFC for these arrays, we can query once and just save it for just future use. object *dObjects; -player *dPlayers; +static player *dPlayers; room *dRooms; //////////////////////////////////////////////////// @@ -142,6 +142,8 @@ typedef struct { typedef struct { int Score[2]; } tPlayerStat; // Overall scores (throughout the game) +static int pack_pstat(tPlayerStat *user_info, ubyte *data); +static int unpack_pstat(tPlayerStat *user_info, ubyte *data); int pack_pstat(tPlayerStat *user_info, ubyte *data) { int count = 0; MultiAddInt(user_info->Score[0], data, &count); @@ -157,59 +159,59 @@ int unpack_pstat(tPlayerStat *user_info, ubyte *data) { } int TeamOwnedRooms[NUM_TEAMS]; -int TeamVirii[NUM_TEAMS][MAX_VIRII]; +static int TeamVirii[NUM_TEAMS][MAX_VIRII]; int NumberOfKillsSinceLastDeath[DLLMAX_PLAYERS]; -int SortedPLRPlayers[NUM_TEAMS][MAX_PLAYER_RECORDS]; +static int SortedPLRPlayers[NUM_TEAMS][MAX_PLAYER_RECORDS]; int TeamScore[NUM_TEAMS]; -int SortedTeams[NUM_TEAMS]; -int SortedPlayers[MAX_PLAYER_RECORDS]; +static int SortedTeams[NUM_TEAMS]; +static int SortedPlayers[MAX_PLAYER_RECORDS]; int EnergyText[NUM_TEAMS]; int RepairText[NUM_TEAMS]; int LabText[NUM_TEAMS]; -tPlayerPos TimeInRoom[DLLMAX_PLAYERS]; -bool DisplayScoreScreen; +static tPlayerPos TimeInRoom[DLLMAX_PLAYERS]; +static bool DisplayScoreScreen; int virus_id = -1; int *RoomList = NULL; int RoomCount; -int Highlight_bmp = -1; -bool display_my_welcome = false; -float Server_last_play_damage_sound = 0; -int Player_who_took_over_last_base = -1; +static int Highlight_bmp = -1; +static bool display_my_welcome = false; +static float Server_last_play_damage_sound = 0; +static int Player_who_took_over_last_base = -1; -int snd_repair_center = -1; -int snd_energy_center = -1; -int snd_score = -1; -int snd_virus_destroy = -1; -int snd_damage = -1; -int snd_virus_pickup = -1; +static int snd_repair_center = -1; +static int snd_energy_center = -1; +static int snd_score = -1; +static int snd_virus_destroy = -1; +static int snd_damage = -1; +static int snd_virus_pickup = -1; // void DisplayScores(void); -void DisplayHUDScores(struct tHUDItem *hitem); -void DisplayWelcomeMessage(int player_num); -void SortTeamScores(int *sortedindex, int *scores); -void SaveStatsToFile(char *filename); -void OnLabSpewTimer(void); +static void DisplayHUDScores(struct tHUDItem *hitem); +static void DisplayWelcomeMessage(int player_num); +static void SortTeamScores(int *sortedindex, int *scores); +static void SaveStatsToFile(char *filename); +static void OnLabSpewTimer(void); void RemoveVirusFromPlayer(int player_num, bool remove_all); -bool ScanForLaboratory(int team, int *newlab); -bool CompareDistanceTravel(vector *curr_pos, vector *last_pos); -void OnDisconnectSaveStatsToFile(void); -void OnLevelEndSaveStatsToFile(void); -void OnGetTokenString(char *src, char *dest, int dest_size); +static bool ScanForLaboratory(int team, int *newlab); +static bool CompareDistanceTravel(vector *curr_pos, vector *last_pos); +static void OnDisconnectSaveStatsToFile(void); +static void OnLevelEndSaveStatsToFile(void); +static void OnGetTokenString(char *src, char *dest, int dest_size); // Player in special room functions -void DoIntervalPlayerFrame(void); -void DoPlayerInLab(int pnum, float time); -void DoPlayerInEnergy(int pnum, float time); -void DoPlayerInRepair(int pnum, float time); -void DoPlayerInEnemy(int pnum, float time); +static void DoIntervalPlayerFrame(void); +static void DoPlayerInLab(int pnum, float time); +static void DoPlayerInEnergy(int pnum, float time); +static void DoPlayerInRepair(int pnum, float time); +static void DoPlayerInEnemy(int pnum, float time); -void DoServerConfigureDialog(void); -void OnPrintScores(int level); +extern void DoServerConfigureDialog(void); +static void OnPrintScores(int level); /////////////////////////////////////////////// // localization info -char **StringTable; -int StringTableSize = 0; -const char *_ErrorString = "Missing String"; +static char **StringTable; +static int StringTableSize = 0; +static const char *_ErrorString = "Missing String"; const char *GetStringFromTable(int d) { if ((d < 0) || (d >= StringTableSize)) return _ErrorString; @@ -218,7 +220,6 @@ const char *GetStringFromTable(int d) { } /////////////////////////////////////////////// - // This function gets called by the game when it wants to learn some info about the game void DLLFUNCCALL DLLGetGameInfo(tDLLOptions *options) { options->flags = DOF_MAXTEAMS | DOF_MINTEAMS; @@ -2009,4 +2010,3 @@ void OnPrintScores(int level) { } } } - diff --git a/netgames/entropy/EntropyPackets.cpp b/netgames/entropy/EntropyPackets.cpp index dcc6f4dd..666bc213 100644 --- a/netgames/entropy/EntropyPackets.cpp +++ b/netgames/entropy/EntropyPackets.cpp @@ -79,8 +79,6 @@ void ReceiveTakeOverPacket(ubyte *data) { TakeOverRoom(newteam, oldteam, room, victor); } -void RemoveVirusFromPlayer(int player_num, bool remove_all); - // Handles when we get a new player packet void GetGameStartPacket(ubyte *data) { int i, count = 0; @@ -160,6 +158,7 @@ void ReceivePickupVirus(ubyte *data) { #define RT_BLUREP 4 #define RT_BLUENG 5 +// MTS: only used in this file. void SendRoomInfo(int pnum) { char *room_info = NULL; int flags, r, i; diff --git a/netgames/entropy/EntropyRoom.cpp b/netgames/entropy/EntropyRoom.cpp index 35f88e10..4f22c40c 100644 --- a/netgames/entropy/EntropyRoom.cpp +++ b/netgames/entropy/EntropyRoom.cpp @@ -55,9 +55,6 @@ #include "EntropyAux.h" extern IDMFC *DMFCBase; -extern room *dRooms; -extern object *dObjects; - bool PaintRoomWithTexture(int text, int roomnum) { if (ROOMNUM_OUTSIDE(roomnum)) { diff --git a/netgames/hoard/hoard.cpp b/netgames/hoard/hoard.cpp index 8c6bff8e..8fec98b9 100644 --- a/netgames/hoard/hoard.cpp +++ b/netgames/hoard/hoard.cpp @@ -73,10 +73,10 @@ #include IDMFC *DMFCBase = NULL; -IDmfcStats *dstat = NULL; -IMenuItem *OSMenuSave = NULL; -object *dObjects = NULL; -player *dPlayers = NULL; +static IDmfcStats *dstat = NULL; +static IMenuItem *OSMenuSave = NULL; +static object *dObjects = NULL; +static player *dPlayers = NULL; #define SPID_INVINFO 1 // packet for hoard inventory info #define SPID_GAMECONFIG 2 @@ -89,6 +89,8 @@ typedef struct { int Score[2]; int HighestScore[2]; } tPlayerStat; +static int pack_pstat(tPlayerStat *user_info, ubyte *data); +static int unpack_pstat(tPlayerStat *user_info, ubyte *data); int pack_pstat(tPlayerStat *user_info, ubyte *data) { int count = 0; MultiAddInt(user_info->Score[0], data, &count); @@ -107,41 +109,39 @@ int unpack_pstat(tPlayerStat *user_info, ubyte *data) { return count; } -tGameConfig config; +static tGameConfig config; -int SortedPlayers[MAX_PLAYER_RECORDS]; // sorted player nums -bool DisplayScoreScreen; -int HoardID = 0; -int HoardOrbIcon = BAD_BITMAP_HANDLE; -bool DisplayBlink = true; -int WhoJustScored = -1; -int WhoJustScoredTimer = -1; -ubyte HUD_color_model = HCM_PLAYERCOLOR; -int Highlight_bmp = -1; -bool display_my_welcome = false; +static int SortedPlayers[MAX_PLAYER_RECORDS]; // sorted player nums +static bool DisplayScoreScreen; +static int HoardID = 0; +static int HoardOrbIcon = BAD_BITMAP_HANDLE; +static bool DisplayBlink = true; +static int WhoJustScored = -1; +static int WhoJustScoredTimer = -1; +static ubyte HUD_color_model = HCM_PLAYERCOLOR; +static int Highlight_bmp = -1; +static bool display_my_welcome = false; -void OnTimer(void); -void OnTimerKill(void); -void DisplayWelcomeMessage(int player_num); -void DisplayHUDScores(struct tHUDItem *hitem); -void SortPlayerScores(int *sortedindex, int size); -void DisplayWelcomeMessage(int player_num); -void DoBallsEffect(int i, int count); -void ReceiveHoardInv(ubyte *data); -void SendHoardInv(int playernum); -void SaveStatsToFile(char *filename); -void ReceiveGameConfig(ubyte *data); -void OnClientPlayerEntersGame(int player_num); +static void OnTimer(void); +static void OnTimerKill(void); +static void DisplayWelcomeMessage(int player_num); +static void DisplayHUDScores(struct tHUDItem *hitem); +static void SortPlayerScores(int *sortedindex, int size); +static void DisplayWelcomeMessage(int player_num); +static void DoBallsEffect(int i, int count); +static void ReceiveHoardInv(ubyte *data); +static void SendHoardInv(int playernum); +static void SaveStatsToFile(char *filename); +static void ReceiveGameConfig(ubyte *data); +static void OnClientPlayerEntersGame(int player_num); -// Displays the Hoard game configuration dialog (Server) -void DisplayHoardConfigDialog(tGameConfig *); -bool Config_displayed = false; +static bool Config_displayed = false; /////////////////////////////////////////////// // localization info -char **StringTable; -int StringTableSize = 0; -const char *_ErrorString = "Missing String"; +static char **StringTable; +static int StringTableSize = 0; +static const char *_ErrorString = "Missing String"; const char *GetStringFromTable(int d) { if ((d < 0) || (d >= StringTableSize)) return _ErrorString; @@ -150,7 +150,6 @@ const char *GetStringFromTable(int d) { } /////////////////////////////////////////////// - // This function gets called by the game when it wants to learn some info about the game void DLLFUNCCALL DLLGetGameInfo(tDLLOptions *options) { options->flags = DOF_MAXTEAMS; @@ -1509,4 +1508,3 @@ void ShowGameConfigDialog(int i) { } void SwitchHUDColor(int i) { HUD_color_model = i; } - diff --git a/netgames/hoard/hoardaux.h b/netgames/hoard/hoardaux.h index 7b5d8546..929098f2 100644 --- a/netgames/hoard/hoardaux.h +++ b/netgames/hoard/hoardaux.h @@ -26,4 +26,7 @@ typedef struct { // game config send/receive void SendGameConfig(int towho); +// Displays the Hoard game configuration dialog (Server) +extern void DisplayHoardConfigDialog(tGameConfig *); + #endif diff --git a/netgames/hyperanarchy/hyperanarchy.cpp b/netgames/hyperanarchy/hyperanarchy.cpp index 1cdb073b..792329fa 100644 --- a/netgames/hyperanarchy/hyperanarchy.cpp +++ b/netgames/hyperanarchy/hyperanarchy.cpp @@ -60,9 +60,9 @@ #include "HyperAnarchy.h" #include "hyperstr.h" IDMFC *DMFCBase = NULL; -IDmfcStats *dstat = NULL; -object *dObjects; -player *dPlayers; +static IDmfcStats *dstat = NULL; +static object *dObjects; +static player *dPlayers; #define SPID_HYPERINFO 0 #define SPID_HYPERPOS 1 @@ -73,6 +73,9 @@ typedef struct { int Score[2]; } tPlayerStat; +static int pack_pstat(tPlayerStat *user_info, ubyte *data); +static int unpack_pstat(tPlayerStat *user_info, ubyte *data); + int pack_pstat(tPlayerStat *user_info, ubyte *data) { int count = 0; MultiAddInt(user_info->Score[0], data, &count); @@ -87,26 +90,26 @@ int unpack_pstat(tPlayerStat *user_info, ubyte *data) { return count; } -int SortedPlayers[MAX_PLAYER_RECORDS]; -bool DisplayScoreScreen; -int HyperOrbID = -1; -int WhoHasOrb = -1; -int KillCount = 0; -int HyperOrbIcon = -1; -bool DisplayFlagBlink = true; -int WhoJustScoredTimer = -1; -int HyperMoveTimer = -1; -ubyte HUD_color_model = HCM_PLAYERCOLOR; -int Highlight_bmp = -1; -bool display_my_welcome = false; +static int SortedPlayers[MAX_PLAYER_RECORDS]; +static bool DisplayScoreScreen; +static int HyperOrbID = -1; +static int WhoHasOrb = -1; +static int KillCount = 0; +static int HyperOrbIcon = -1; +static bool DisplayFlagBlink = true; +static int WhoJustScoredTimer = -1; +static int HyperMoveTimer = -1; +static ubyte HUD_color_model = HCM_PLAYERCOLOR; +static int Highlight_bmp = -1; +static bool display_my_welcome = false; -void OnClientPlayerEntersGame(int player_num); +static void OnClientPlayerEntersGame(int player_num); /////////////////////////////////////////////// // localization info -char **StringTable; -int StringTableSize = 0; -const char *_ErrorString = "Missing String"; +static char **StringTable; +static int StringTableSize = 0; +static const char *_ErrorString = "Missing String"; const char *GetStringFromTable(int d) { if ((d < 0) || (d >= StringTableSize)) return _ErrorString; @@ -115,41 +118,41 @@ const char *GetStringFromTable(int d) { } /////////////////////////////////////////////// -void SwitchHUDColor(int i); +static void SwitchHUDColor(int i); // handles a Hyper Anarchy Game State packet -void ReceiveHyperGameState(ubyte *data); +static void ReceiveHyperGameState(ubyte *data); // sends a Hyper Anarchy Game State packet -void SendHyperGameState(int playernum); +static void SendHyperGameState(int playernum); // Displays HUD scores -void DisplayHUDScores(struct tHUDItem *hitem); +static void DisplayHUDScores(struct tHUDItem *hitem); // Displays the Stats screen -void DisplayScores(void); +static void DisplayScores(void); // Sorts based on score -void SortPlayerScores(int *sortedindex, int size); +static void SortPlayerScores(int *sortedindex, int size); // Updates the effect on all the players -void UpdateEffect(void); +static void UpdateEffect(void); // Displays the Welcome Screen -void DisplayWelcomeScreen(int pnum); +static void DisplayWelcomeScreen(int pnum); // Handler for menu item for turning on/off blinking hud -void SwitchBlinkingHud(int i); +static void SwitchBlinkingHud(int i); // Generates a valid random room -int GetRandomValidRoom(void); +static int GetRandomValidRoom(void); // Moves the HyperOrb to the center of a random room // if objnum is -1, than the HyperOrb is created and moved -void MoveHyperOrbToRoom(int objnum); +static void MoveHyperOrbToRoom(int objnum); // Given a room the HyperOrb is created and placed in the center of it -void CreateHyperOrbInRoom(int room); +static void CreateHyperOrbInRoom(int room); // Given the objnum and room it will move the HyperOrb to the center of that room. Objnum better be valid. -void MoveHyperOrbToRoomCenter(int objnum, int room); +static void MoveHyperOrbToRoomCenter(int objnum, int room); // handles a Hyper Anarchy Object Placement packet -void ReceiveHyperPos(ubyte *data); +static void ReceiveHyperPos(ubyte *data); // Searches through all the objects and looks for the HyperOrb, returns it's objnum. -1 if it doesn't exist -int FindHyperObjectNum(void); +static int FindHyperObjectNum(void); // Searches through all the player's inventory, returns the pnum of the player who has the HyperOrb, -1 // if no one does. -int FindHyperOrbInInventory(void); -void ResetTimer(void); -void SaveStatsToFile(char *filename); +static int FindHyperOrbInInventory(void); +static void ResetTimer(void); +static void SaveStatsToFile(char *filename); void DetermineScore(int precord_num, int column_num, char *buffer, int buffer_size) { player_record *pr = DMFCBase->GetPlayerRecord(precord_num); @@ -180,7 +183,6 @@ void OnTimerKill(void); void OnTimerFlagReturn(void); void OnTimerFlagReturnKill(void); - // This function gets called by the game when it wants to learn some info about the game void DLLFUNCCALL DLLGetGameInfo(tDLLOptions *options) { options->flags = DOF_MAXTEAMS; @@ -1505,4 +1507,3 @@ void OnTimerFlagReturn(void) { void OnTimerFlagReturnKill(void) { HyperMoveTimer = -1; } void SwitchHUDColor(int i) { HUD_color_model = i; } - diff --git a/netgames/monsterball/monsterball.cpp b/netgames/monsterball/monsterball.cpp index 9c1a1bbb..a733bcc0 100644 --- a/netgames/monsterball/monsterball.cpp +++ b/netgames/monsterball/monsterball.cpp @@ -168,15 +168,14 @@ #include #include "monsterstr.h" - #include IDMFC *DMFCBase = NULL; -IDmfcStats *dstat = NULL; -room *dRooms; -object *dObjects; -player *dPlayers; -vis_effect *dVisEffects; +static IDmfcStats *dstat = NULL; +static room *dRooms; +static object *dObjects; +static player *dPlayers; +static vis_effect *dVisEffects; ////////////////////////////////// // defines #define SPID_NEWPLAYER 0 @@ -208,6 +207,9 @@ typedef struct { int BadScore[2]; } tPlayerStat; +static int pack_pstat(tPlayerStat *user_info, ubyte *data); +static int unpack_pstat(tPlayerStat *user_info, ubyte *data); + int pack_pstat(tPlayerStat *user_info, ubyte *data) { int count = 0; MultiAddInt(user_info->Score[0], data, &count); @@ -246,29 +248,29 @@ struct { ////////////////////////////////// // Globals -int SortedPLRPlayers[DLLMAX_TEAMS][MAX_PLAYER_RECORDS]; -int TeamScores[DLLMAX_TEAMS]; -int SortedTeams[DLLMAX_TEAMS]; -int SortedPlayers[MAX_PLAYER_RECORDS]; +static int SortedPLRPlayers[DLLMAX_TEAMS][MAX_PLAYER_RECORDS]; +static int TeamScores[DLLMAX_TEAMS]; +static int SortedTeams[DLLMAX_TEAMS]; +static int SortedPlayers[MAX_PLAYER_RECORDS]; -int NumOfTeams = 2; -int WhoJustScored = -1, WhoJustScoredTimer = -1; -int GoalRooms[DLLMAX_TEAMS]; -int Highlight_bmp; -int LastHitPnum = -1; +static int NumOfTeams = 2; +static int WhoJustScored = -1, WhoJustScoredTimer = -1; +static int GoalRooms[DLLMAX_TEAMS]; +static int Highlight_bmp; +static int LastHitPnum = -1; -bool players_sorted = false; // the Sorted*[] have been sorted -bool DisplayPowerBBlink = true; -bool DisplayScoreBlink = true; -bool DisplayScoreScreen = false; -bool display_my_welcome = false; -bool monsterball_info_set = false; +static bool players_sorted = false; // the Sorted*[] have been sorted +static bool DisplayPowerBBlink = true; +static bool DisplayScoreBlink = true; +static bool DisplayScoreScreen = false; +static bool display_my_welcome = false; +static bool monsterball_info_set = false; /////////////////////////////////////////////// // localization info -char **StringTable; -int StringTableSize = 0; -const char *_ErrorString = "Missing String"; +static char **StringTable; +static int StringTableSize = 0; +static const char *_ErrorString = "Missing String"; const char *GetStringFromTable(int d) { if ((d < 0) || (d >= StringTableSize)) return _ErrorString; @@ -279,34 +281,35 @@ const char *GetStringFromTable(int d) { ////////////////////////////////// // Prototypes -void DisplayHUDScores(struct tHUDItem *hitem); -void DisplayStats(void); -void GetGameStartPacket(ubyte *data); -void SendGameStartPacket(int pnum); -bool GetMonsterballInfo(int id); -void SortTeams(void); -void DisplayWelcomeMessage(int player_num); -void OnTimerScore(void); -void OnTimer(void); -void OnTimerScoreKill(void); -void OnTimerKill(void); -void OnTimerRegen(void); -void OnTimerRegenKill(void); -void SaveStatsToFile(char *filename); -void SortPlayerSlots(int *sorted_list, int count); -void SendLastHitInfo(void); -void GetLastHitInfo(ubyte *data); +static void DisplayHUDScores(struct tHUDItem *hitem); +static void DisplayStats(void); +static void GetGameStartPacket(ubyte *data); +static void SendGameStartPacket(int pnum); +static bool GetMonsterballInfo(int id); +static void SortTeams(void); +static void DisplayWelcomeMessage(int player_num); +static void OnTimerScore(void); +static void OnTimer(void); +static void OnTimerScoreKill(void); +static void OnTimerKill(void); +static void OnTimerRegen(void); +static void OnTimerRegenKill(void); +static void SaveStatsToFile(char *filename); +static void SortPlayerSlots(int *sorted_list, int count); +static void SendLastHitInfo(void); +static void GetLastHitInfo(ubyte *data); -void HandlePickupPowerball(object *owner); -void HandleLosePowerball(bool play_sound); -void HandleMonsterballCollideWithObject(object *ball, object *player, vector *point, vector *normal); -void HandleMonsterballCollideWithWeapon(object *ball, weapon_collide_info *winfo, vector *point, vector *normal); -void bump_object(object *object0, vector *rotvel, vector *velocity, vector *pos, matrix *orient, float mass, float size, - vector *collision_point, vector *collision_normal, float rot_scale, float vel_scale); -void DoMonsterballScoreEffect(void); -void OnClientPlayerEntersGame(int player_num); +static void HandlePickupPowerball(object *owner); +static void HandleLosePowerball(bool play_sound); +static void HandleMonsterballCollideWithObject(object *ball, object *player, vector *point, vector *normal); +static void HandleMonsterballCollideWithWeapon(object *ball, weapon_collide_info *winfo, vector *point, vector *normal); +static void bump_object(object *object0, vector *rotvel, vector *velocity, vector *pos, matrix *orient, float mass, + float size, vector *collision_point, vector *collision_normal, float rot_scale, + float vel_scale); +static void DoMonsterballScoreEffect(void); +static void OnClientPlayerEntersGame(int player_num); -bool ValidateOwner(int *pnum, object **obj); +static bool ValidateOwner(int *pnum, object **obj); void DetermineScore(int precord_num, int column_num, char *buffer, int buffer_size) { player_record *pr = DMFCBase->GetPlayerRecord(precord_num); @@ -348,7 +351,6 @@ void ShowStatBitmap(int precord_num, int column_num, int x, int y, int w, int h, } } - #define NUM_TEAMS 2 // This function gets called by the game when it wants to learn some info about the game @@ -2210,4 +2212,3 @@ void DoMonsterballScoreEffect(void) { Monsterball->effect_info->fade_max_time = 4.0f; } } - diff --git a/netgames/roboanarchy/roboanarchy.cpp b/netgames/roboanarchy/roboanarchy.cpp index ed5ef685..a1a0d229 100644 --- a/netgames/roboanarchy/roboanarchy.cpp +++ b/netgames/roboanarchy/roboanarchy.cpp @@ -57,32 +57,33 @@ #include IDMFC *DMFCBase = NULL; -IDmfcStats *dstat = NULL; +static IDmfcStats *dstat = NULL; -int SortedPlayers[MAX_PLAYER_RECORDS]; // sorted player nums -bool DisplayScoreScreen; -int Highlight_bmp = -1; +static int SortedPlayers[MAX_PLAYER_RECORDS]; // sorted player nums +static bool DisplayScoreScreen; +static int Highlight_bmp = -1; #define AHD_NONE 0 #define AHD_SCORE 1 #define AHD_EFFICIENCY 2 #define ACM_PLAYERCOLOR 0 #define ACM_NORMAL 1 -ubyte Anarchy_hud_display = AHD_SCORE; -ubyte HUD_color_model = ACM_PLAYERCOLOR; -bool display_my_welcome = false; +static ubyte Anarchy_hud_display = AHD_SCORE; +static ubyte HUD_color_model = ACM_PLAYERCOLOR; +static bool display_my_welcome = false; -void DisplayHUDScores(struct tHUDItem *hitem); -void DisplayScores(void); -void DisplayWelcomeMessage(int player_num); -void SaveStatsToFile(char *filename); -void SwitchHUDColor(int i); +static void DisplayHUDScores(struct tHUDItem *hitem); +static void DisplayScores(void); +static void DisplayWelcomeMessage(int player_num); +static void SaveStatsToFile(char *filename); +static void SwitchHUDColor(int i); +static void SwitchAnarchyScores(int i); /////////////////////////////////////////////// // localization info -char **StringTable; -int StringTableSize = 0; -const char *_ErrorString = "Missing String"; +static char **StringTable; +static int StringTableSize = 0; +static const char *_ErrorString = "Missing String"; const char *GetString(int d) { if ((d < 0) || (d >= StringTableSize)) return _ErrorString; @@ -112,7 +113,6 @@ void SwitchAnarchyScores(int i) { }; } - // This function gets called by the game when it wants to learn some info about the game void DLLFUNCCALL DLLGetGameInfo(tDLLOptions *options) { options->flags = DOF_MAXTEAMS; @@ -1002,4 +1002,3 @@ void SwitchHUDColor(int i) { break; }; } - diff --git a/netgames/tanarchy/tanarchy.cpp b/netgames/tanarchy/tanarchy.cpp index 3b62fbb0..1f871f86 100644 --- a/netgames/tanarchy/tanarchy.cpp +++ b/netgames/tanarchy/tanarchy.cpp @@ -82,37 +82,40 @@ #include "tanDMFC.h" #include "tanarchystr.h" IDMFC *DMFCBase = NULL; -IDmfcStats *dstat = NULL; -player *dPlayers; +static IDmfcStats *dstat = NULL; +static player *dPlayers; #define SPID_NEWPLAYER 0 #define NUM_TEAMS 2 -int SortedPLRPlayers[MAX_TEAMS][MAX_PLAYER_RECORDS]; -int TeamScore[NUM_TEAMS]; -int SortedTeams[NUM_TEAMS]; -int SortedPlayers[MAX_PLAYER_RECORDS]; -bool DisplayScoreScreen; -bool display_my_welcome = false; +static int SortedPLRPlayers[MAX_TEAMS][MAX_PLAYER_RECORDS]; +static int TeamScore[NUM_TEAMS]; +static int SortedTeams[NUM_TEAMS]; +static int SortedPlayers[MAX_PLAYER_RECORDS]; +static bool DisplayScoreScreen; +static bool display_my_welcome = false; -void GetGameStartPacket(ubyte *data); -void SendGameStartPacket(int pnum); -void DisplayScores(void); -void DisplayHUDScores(struct tHUDItem *hitem); -void DisplayWelcomeMessage(int player_num); -void SortTeamScores(int *sortedindex, int *scores); +static void GetGameStartPacket(ubyte *data); +static void SendGameStartPacket(int pnum); +static void DisplayScores(void); +static void DisplayHUDScores(struct tHUDItem *hitem); +static void DisplayWelcomeMessage(int player_num); +static void SortTeamScores(int *sortedindex, int *scores); void OnSaveStatsToFile(void); -void OnLevelEndSaveStatsToFile(void); -void OnDisconnectSaveStatsToFile(void); -void OnPrintScores(int level); +static void OnLevelEndSaveStatsToFile(void); +static void OnDisconnectSaveStatsToFile(void); +static void OnPrintScores(int level); +static void DetermineScore(int precord_num, int column_num, char *buffer, int buffer_size); +static void TeamScoreCallback(int team, char *buffer, int buffer_size); +static bool compare_slots(int a, int b); -int Highlight_bmp = -1; +static int Highlight_bmp = -1; /////////////////////////////////////////////// // localization info -char **StringTable; -int StringTableSize = 0; -const char *_ErrorString = "Missing String"; +static char **StringTable; +static int StringTableSize = 0; +static const char *_ErrorString = "Missing String"; const char *GetStringFromTable(int d) { if ((d < 0) || (d >= StringTableSize)) return _ErrorString; @@ -138,7 +141,6 @@ void TeamScoreCallback(int team, char *buffer, int buffer_size) { snprintf(buffer, buffer_size, " %d", TeamScore[team]); } - // This function gets called by the game when it wants to learn some info about the game void DLLFUNCCALL DLLGetGameInfo(tDLLOptions *options) { options->flags = DOF_MAXTEAMS | DOF_MINTEAMS; @@ -1067,4 +1069,3 @@ void OnPrintScores(int level) { } } } - diff --git a/networking/networking.cpp b/networking/networking.cpp index 32040984..0deeba0a 100644 --- a/networking/networking.cpp +++ b/networking/networking.cpp @@ -340,7 +340,6 @@ typedef int socklen_t; bool Use_DirectPlay = false; #endif - #include "module.h" //for some nice defines to use below #define MAX_CONNECT_TRIES 50 @@ -418,16 +417,16 @@ static short Packet_free_list[MAX_PACKET_BUFFERS]; // contains id' static int Num_packet_buffers; static int Largest_packet_index = 0; -int Uncompressed_outgoing_data_len = 0; -int Compressed_outgoing_data_len = 0; +static int Uncompressed_outgoing_data_len = 0; +static int Compressed_outgoing_data_len = 0; int Next_packet_id; int Last_packet_id; -CFILE *NetDebugFile = NULL; +static CFILE *NetDebugFile = NULL; // An array of callbacks -NetworkReceiveCallback Netcallbacks[16]; +static NetworkReceiveCallback Netcallbacks[16]; #define R_NET_SEQUENCE_NONE 0 #define R_NET_SEQUENCE_CONNECTING 1 @@ -436,18 +435,18 @@ NetworkReceiveCallback Netcallbacks[16]; #define R_NET_PACKET_QUEUE_TIME .1f -int Net_connect_socket_id = INVALID_SOCKET; -int Net_connect_sequence = R_NET_SEQUENCE_NONE; +static int Net_connect_socket_id = INVALID_SOCKET; +static int Net_connect_sequence = R_NET_SEQUENCE_NONE; // ------------------------------------------------------------------------------------------------------ // PACKET BUFFERING FUNCTIONS // // a sequence number of -1 will indicate that this packet is not valid -network_packet_buffer Psnet_buffers[MAX_PACKET_BUFFERS]; -int Psnet_seq_number = 0; -int Psnet_lowest_id = 0; -int Psnet_highest_id = 0; +static network_packet_buffer Psnet_buffers[MAX_PACKET_BUFFERS]; +static int Psnet_seq_number = 0; +static int Psnet_lowest_id = 0; +static int Psnet_highest_id = 0; // Reliable UDP stuff //******************************* @@ -476,12 +475,12 @@ typedef struct { ubyte buffer[NETBUFFERSIZE]; } reliable_net_rcvbuffer; -SOCKET Reliable_UDP_socket = INVALID_SOCKET; +static SOCKET Reliable_UDP_socket = INVALID_SOCKET; -float first_sent_iamhere = 0; -float last_sent_iamhere = 0; +static float first_sent_iamhere = 0; +static float last_sent_iamhere = 0; -unsigned int serverconn = 0xFFFFFFFF; +static unsigned int serverconn = 0xFFFFFFFF; #ifdef WIN32 #pragma pack(pop, r_udp) @@ -518,9 +517,13 @@ typedef struct { ubyte send_urgent; } reliable_socket; -reliable_socket reliable_sockets[MAXRELIABLESOCKETS]; +static reliable_socket reliable_sockets[MAXRELIABLESOCKETS]; //******************************* +static void CloseNetworking(); +static void nw_SetSocketOptions(SOCKET sock); +static void nw_LoadThreadLibrary(void); + void CloseNetworking() { if (Sockets_initted != 1) return; @@ -552,7 +555,6 @@ void CloseNetworking() { } #endif - Network_initted = 0; Sockets_initted = 0; @@ -919,10 +921,12 @@ int nw_Send(network_address *who_to, void *data, int len, int flags) { return nw_SendWithID(NWT_UNRELIABLE, (ubyte *)data, len, who_to); } +// MTS: only used in this file? void nw_HandleUnreliableData(ubyte *data, int len, network_address *from_addr) { nw_psnet_buffer_packet((ubyte *)data, len, from_addr); } +// MTS: unused? // routine to "free" a packet buffer void nw_FreePacket(int id) { Packet_buffers[id].sequence_number = -1; @@ -1204,10 +1208,12 @@ int nw_SendReliable(unsigned int socketid, ubyte *data, int length, bool urgent) return 0; } +// MTS: only used in this file int nw_InitReliableSocket() { nw_RegisterCallback((NetworkReceiveCallback)nw_WorkReliable, NWT_RELIABLE); return 1; } +// MTS: only used in this file void nw_SendReliableAck(SOCKADDR *raddr, unsigned int sig, network_protocol link_type, float time_sent) { int ret; reliable_header ack_header; @@ -1506,6 +1512,7 @@ void nw_WorkReliable(ubyte *data, int len, network_address *naddr) { } while (0); // while((IPX_has_data>0) || (UDP_has_data>0)); } +// MTS: only used in this file void nw_HandleConnectResponse(ubyte *data, int len, network_address *server_addr) { int i; @@ -1733,6 +1740,7 @@ int nw_CheckReliableSocket(int socknum) { } } +// MTS: only used in this file. int nw_PingCompare(const void *arg1, const void *arg2) { float *ping1 = (float *)arg1; float *ping2 = (float *)arg2; @@ -1747,6 +1755,7 @@ int nw_PingCompare(const void *arg1, const void *arg2) { return 0; } +// MTS: only used in this file // Warning, experimental compression below, if you want to use it, talk to Kevin. Doesn't do much currently, only // reduces 0's #define COMPRESS_KEY 0xfd @@ -1785,6 +1794,7 @@ int nw_Compress(void *srcdata, void *destdata, int count) { return currp - (ubyte *)destdata; } +// MTS: only used in this file int nw_Uncompress(void *compdata, void *uncompdata, int count) { int i; int destlen = 0; @@ -1814,6 +1824,7 @@ int nw_Uncompress(void *compdata, void *uncompdata, int count) { return destlen; } +// MTS: only used in this file // initialize the buffering system void nw_psnet_buffer_init() { int idx; @@ -1832,6 +1843,7 @@ void nw_psnet_buffer_init() { Psnet_highest_id = -1; } +// MTS: only used in this file // buffer a packet (maintain order!) void nw_psnet_buffer_packet(ubyte *data, int length, network_address *from) { int idx; @@ -1865,6 +1877,7 @@ void nw_psnet_buffer_packet(ubyte *data, int length, network_address *from) { } } +// MTS: only used in this file // get the index of the next packet in order! int nw_psnet_buffer_get_next_by_dpid(ubyte *data, int *length, unsigned long dpid) { int idx; @@ -1902,6 +1915,7 @@ int nw_psnet_buffer_get_next_by_dpid(ubyte *data, int *length, unsigned long dpi return 1; } +// MTS: only used in this file // get the index of the next packet in order! int nw_psnet_buffer_get_next(ubyte *data, int *length, network_address *from) { int idx; @@ -1939,6 +1953,7 @@ int nw_psnet_buffer_get_next(ubyte *data, int *length, network_address *from) { } #ifdef WIN32 +// MTS: only used in this file // functions to get the status of a RAS connection unsigned int psnet_ras_status() { int rval; @@ -2037,8 +2052,8 @@ unsigned int psnet_ras_status() { } #endif -async_dns_lookup aslu; -async_dns_lookup *lastaslu = NULL; +static async_dns_lookup aslu; +static async_dns_lookup *lastaslu = NULL; #ifdef WIN32 #define CDECLCALL __cdecl @@ -2059,7 +2074,7 @@ int CDECLCALL gethostbynameworker(void *parm); // pthread_create_fp dpthread_create = NULL; static pthread_detach_fp dpthread_detach = NULL; static pthread_self_fp // dpthread_self = NULL; -static void nw_LoadThreadLibrary(void) { +void nw_LoadThreadLibrary(void) { // rcg06192000 use SDL threads. /* if(dpthread_create) @@ -2498,6 +2513,7 @@ int nw_DoReceiveCallbacks(void) { return 0; } +// MTS: only used in this file? // Resend any unack'd packets and send any buffered packets, heartbeats, etc. void nw_ReliableResend(void) { int i, j; diff --git a/physics/Collide.cpp b/physics/Collide.cpp index 1b8e2c8c..7f400ef6 100644 --- a/physics/Collide.cpp +++ b/physics/Collide.cpp @@ -868,6 +868,34 @@ ubyte CollisionResult[MAX_OBJECT_TYPES][MAX_OBJECT_TYPES]; ubyte CollisionRayResult[MAX_OBJECT_TYPES]; +static bool IsOKToApplyForce(object *objp); +static void bump_this_object(object *objp, object *other_objp, vector *force, vector *collision_pnt, int damage_flag); +//! Creates some effects where a weapon has collided with a wall. +static void DoWallEffects(object *weapon, int surface_tmap); +//! Check for lava, volatile, or water surface. If contact, make special sound & kill the weapon. +static void check_for_special_surface(object *weapon, int surface_tmap, vector *surface_normal, float hit_dot); +/// Process a collision between a weapon and a wall. +/// - Returns: true if the weapon hits the wall, and false if should keep going though the wall (for breakable glass). +static bool collide_weapon_and_wall(object *weapon, fix hitspeed, int hitseg, int hitwall, vector *hitpnt, + vector *wall_normal, float hit_dot); +/// Prints out a marker hud message if needed. +static void collide_player_and_marker(object *playerobj, object *marker_obj, vector *collision_point, + vector *collision_normal, bool f_reverse_normal, fvi_info *hit_info); +static void collide_player_and_wall(object *playerobj, float hitspeed, int hitseg, int hitwall, vector *hitpt, + vector *wall_normal, float hit_dot); +static void collide_generic_and_wall(object *genericobj, float hitspeed, int hitseg, int hitwall, vector *hitpt, + vector *wall_normal, float hit_dot); +static void CollideAnglesToMatrix(matrix *m, float p, float h, float b); +static vector *CollideExtractAnglesFromMatrix(vector *a, matrix *m); +static void bump_two_objects(object *object0, object *object1, vector *collision_point, vector *collision_normal, + int damage_flag); +static void collide_player_and_player(object *p1, object *p2, vector *collision_point, vector *collision_normal, + bool f_reverse_normal, fvi_info *hit_info); +static void collide_generic_and_player(object *robotobj, object *playerobj, vector *collision_point, + vector *collision_normal, bool f_reverse_normal, fvi_info *hit_info); +static void MakeWeaponStick(object *weapon, object *parent, fvi_info *hit_info); +static void check_lg_inform(object *A, object *B); + bool IsOKToApplyForce(object *objp) { if (Game_mode & GM_MULTI) { if (objp->type == OBJ_PLAYER) { @@ -1084,7 +1112,7 @@ void DoWallEffects(object *weapon, int surface_tmap) { #define FORCEFIELD_DAMAGE 5.0f -void DeformTerrain(vector *pos, int depth, float size); +extern void DeformTerrain(vector *pos, int depth, float size); // Check for lava, volatile, or water surface. If contact, make special sound & kill the weapon void check_for_special_surface(object *weapon, int surface_tmap, vector *surface_normal, float hit_dot) { @@ -1509,7 +1537,7 @@ void collide_generic_and_wall(object *genericobj, float hitspeed, int hitseg, in return; } -float Last_volatile_scrape_sound_time = 0; +static float Last_volatile_scrape_sound_time = 0; // this gets called when an object is scraping along the wall void scrape_object_on_wall(object *obj, int hitseg, int hitwall, vector *hitpt, vector *wall_normal) { diff --git a/physics/FindIntersection.cpp b/physics/FindIntersection.cpp index 21bd8828..3b544e77 100644 --- a/physics/FindIntersection.cpp +++ b/physics/FindIntersection.cpp @@ -901,40 +901,41 @@ bool FVI_always_check_ceiling = false; float Ceiling_height = MAX_TERRAIN_HEIGHT; // Bit fields for quick 'already-checked' checking -unsigned char +static unsigned char fvi_visit_list[MAX_ROOMS / 8 + 1]; // This bit-field provides a fast check if a mine segment has been visited -unsigned char fvi_terrain_visit_list[(TERRAIN_DEPTH * TERRAIN_WIDTH) / 8 + - 1]; // This bit-field provides a fast check if a terrain segment has been visited -unsigned char +static unsigned char + fvi_terrain_visit_list[(TERRAIN_DEPTH * TERRAIN_WIDTH) / 8 + + 1]; // This bit-field provides a fast check if a terrain segment has been visited +static unsigned char fvi_terrain_obj_visit_list[(TERRAIN_DEPTH * TERRAIN_WIDTH) / 8 + 1]; // This bit-field provides a fast check if a terrain segment has been visited // The number rooms and terrain cells that this fvi call visited. -int fvi_num_rooms_visited; -int fvi_num_cells_visited; -int fvi_num_cells_obj_visited; +static int fvi_num_rooms_visited; +static int fvi_num_cells_visited; +static int fvi_num_cells_obj_visited; // Should we do a terrain check. This flag exists because if we do a terrain check, it always does a full check. So, // we only have to do it once. -bool f_check_terrain; -bool fvi_zero_rad; +static bool f_check_terrain; +static bool fvi_zero_rad; // Unordered list of rooms and terrain cells that this fvi call visited. // DAJ changed to ushorts to save memory -ushort fvi_rooms_visited[MAX_ROOMS]; // This should be a small number (100 to 1000) -ushort fvi_cells_visited[MAX_CELLS_VISITED]; // Use this so that we do not have to use 256x256 elements -ushort fvi_cells_obj_visited[MAX_CELLS_VISITED]; +static ushort fvi_rooms_visited[MAX_ROOMS]; // This should be a small number (100 to 1000) +static ushort fvi_cells_visited[MAX_CELLS_VISITED]; // Use this so that we do not have to use 256x256 elements +static ushort fvi_cells_obj_visited[MAX_CELLS_VISITED]; // Fvi wall collision stuff -float fvi_wall_sphere_rad; -vector fvi_wall_sphere_offset; -vector fvi_wall_sphere_p0; -vector fvi_wall_sphere_p1; +static float fvi_wall_sphere_rad; +static vector fvi_wall_sphere_offset; +static vector fvi_wall_sphere_p0; +static vector fvi_wall_sphere_p1; -float fvi_anim_sphere_rad; -vector fvi_anim_sphere_offset; -vector fvi_anim_sphere_p0; -vector fvi_anim_sphere_p1; +static float fvi_anim_sphere_rad; +static vector fvi_anim_sphere_offset; +static vector fvi_anim_sphere_p0; +static vector fvi_anim_sphere_p1; // Fvi information pointers. fvi_info *fvi_hit_data_ptr; @@ -944,13 +945,13 @@ fvi_query *fvi_query_ptr; float fvi_collision_dist; // AABB for the movement -vector fvi_max_xyz; -vector fvi_min_xyz; -vector fvi_movement_delta; +static vector fvi_max_xyz; +static vector fvi_min_xyz; +static vector fvi_movement_delta; // AABB for the movement -vector fvi_wall_max_xyz; -vector fvi_wall_min_xyz; +static vector fvi_wall_max_xyz; +static vector fvi_wall_min_xyz; // CHRISHACK -- Do we still need this???? int fvi_curobj; @@ -964,9 +965,34 @@ int Fvi_num_recorded_faces = 0; // Some function def's //------------------------------------------------------------------------------------------ -int do_fvi_terrain(); -int fvi_room(int room_index, int from_portal, int room_obj = -1); -void do_fvi_rooms(int initial_room_index); +static int do_fvi_terrain(); +static int fvi_room(int room_index, int from_portal, int room_obj = -1); +static void do_fvi_rooms(int initial_room_index); +/// Find the point on the specified plane where the line intersects. +/// - returns: true if point found, false if line parallel to plane. +/// - parameter new_pnt: is the found point on the plane. +/// - parameter plane_pnt: describe the plane. +/// - parameter plane_norm: describe the plane. +/// - parameter p0: are the ends of the line. +/// - parameter p1: are the ends of the line. +/// +/// Assumes that the initial point is not intersecting the plane. +static inline int find_plane_line_intersection(vector *intp, vector *colp, vector *plane_pnt, const vector *plane_norm, + const vector *p0, const vector *p1, float rad); +static bool IsPointInCylinder(vector *normal, vector *cylinder_pnt, vector *edir, float elen, const float rad, + const vector *pnt, vector *mdir, bool *f_collide); + +//! check if a sphere intersects a face -- this can be optimized (only need 2d stuff after rotation) +static int check_vector_to_cylinder(vector *colp, vector *intp, float *col_dist, vector *wall_norm, const vector *p0, + const vector *p1, float rad, vector *ep0, vector *ep1); + +//! check if a sphere intersects a face. +static int check_sphere_to_face(vector *colp, vector *intp, float *col_dist, vector *wall_norm, const vector *p0, + const vector *p1, vector *face_normal, int nv, float rad, vector **vertex_ptr_list); +static void fvi_rooms_objs(void); +static int obj_in_list(int objnum, int *obj_list); +static void make_trigger_face_list(int last_sim_faces); +static bool PhysPastPortal(const room *rp, portal *pp); //------------------------------------------------------------------------------------------ // FVI FUNCTIONS @@ -1062,7 +1088,7 @@ typedef struct vec2d { // given largest componant of normal, return i & j // if largest componant is negative, swap i & j -int ij_table[3][2] = { +static const int ij_table[3][2] = { {2, 1}, // pos x biggest {0, 2}, // pos y biggest {1, 0}, // pos z biggest @@ -2571,8 +2597,6 @@ void make_trigger_face_list(int last_sim_faces) { Fvi_num_recorded_faces = num_real_collisions; } -void fvi_rooms_objs(void); - // Find out if a vector intersects with anything. // Fills in hit_data, an fvi_info structure (see header file). // Parms: @@ -2954,10 +2978,11 @@ int sphere_intersects_wall(vector *pnt, int segnum, float rad) { return 0; } -int bbox_edges[12][2] = {{0, 1}, {1, 2}, {2, 3}, {3, 0}, {3, 4}, {2, 5}, - {5, 4}, {4, 7}, {5, 6}, {7, 6}, {7, 0}, {6, 1}}; +static const int bbox_edges[12][2] = {{0, 1}, {1, 2}, {2, 3}, {3, 0}, {3, 4}, {2, 5}, + {5, 4}, {4, 7}, {5, 6}, {7, 6}, {7, 0}, {6, 1}}; -int bbox_faces[6][4] = {{4, 5, 2, 3}, {7, 6, 5, 4}, {0, 1, 6, 7}, {0, 3, 2, 1}, {7, 4, 3, 0}, {1, 2, 5, 3}}; +static const int bbox_faces[6][4] = {{4, 5, 2, 3}, {7, 6, 5, 4}, {0, 1, 6, 7}, + {0, 3, 2, 1}, {7, 4, 3, 0}, {1, 2, 5, 3}}; /* bool BBoxPlaneIntersection(bool fast_exit, vector *collision_point, vector *collision_normal, object *obj, vector *new_pos, int nv, vector **vertex_ptr_list, vector *face_normal) @@ -3190,6 +3215,7 @@ vector PointSpeed(object *obj, vector *pos, matrix *orient, vector *rotvel, vect return *velocity + w1; } +// MTS: only used in this file. // Hacked for some initial testing bool BBoxPlaneIntersection(bool fast_exit, vector *collision_point, vector *collision_normal, object *obj, vector *new_pos, int nv, vector **vertex_ptr_list, vector *face_normal, matrix *orient, diff --git a/physics/newstyle_fi.cpp b/physics/newstyle_fi.cpp index 41a9337f..cb9c8ee0 100644 --- a/physics/newstyle_fi.cpp +++ b/physics/newstyle_fi.cpp @@ -32,14 +32,14 @@ extern matrix View_matrix; extern vector View_position; -vector Original_pos; -matrix Original_orient; +static vector Original_pos; +static matrix Original_orient; -vector fvi_move_fvec; -vector fvi_move_uvec; -bool fvi_do_orient; +static vector fvi_move_fvec; +static vector fvi_move_uvec; +static bool fvi_do_orient; -bool Fvi_f_normal; +static bool Fvi_f_normal; #define MAX_INSTANCE_DEPTH 30 @@ -55,6 +55,22 @@ static struct instance_context instance_stack[MAX_INSTANCE_DEPTH]; static int instance_depth = 0; +static inline void ns_compute_movement_AABB(void); +static inline bool ns_movement_manual_AABB(vector *min_xyz, vector *max_xyz); +static void CollideSubmodelFacesUnsorted(poly_model *pm, bsp_info *sm); + +/// instance at specified point with specified orientation. +/// if matrix==NULL, don't modify matrix. This will be like doing an offset. +static void newstyle_StartInstanceMatrix(vector *pos, matrix *orient); +/// instance at specified point with specified orientation. +/// if angles==NULL, don't modify matrix. This will be like doing an offset. +static void newstyle_StartInstanceAngles(vector *pos, angvec *angles); + +/// pops the old context +static void newstyle_DoneInstance(); +static void CollideSubmodel(poly_model *pm, bsp_info *sm, uint f_render_sub); +static void CollidePolygonModel(vector *pos, matrix *orient, int model_num, float *normalized_time, uint f_render_sub); + static void BuildModelAngleMatrix(matrix *mat, angle ang, vector *axis) { float x, y, z; float s, c, t; diff --git a/scripts/AIGame.cpp b/scripts/AIGame.cpp index 69fcb64a..2aade7fd 100644 --- a/scripts/AIGame.cpp +++ b/scripts/AIGame.cpp @@ -42,8 +42,8 @@ int STDCALL SaveRestoreState(void *file_ptr, ubyte saving_state); } #endif -int String_table_size = 0; -char **String_table = NULL; +static int String_table_size = 0; +static char **String_table = NULL; static const char *_Error_string = "!!ERROR MISSING STRING!!"; static const char *_Empty_string = ""; const char *GetStringFromTable(int index) { @@ -202,8 +202,12 @@ const char *GetStringFromTable(int index) { #define TXT_GB_I_FOUND_A_GB_POWERUP TXT(145) // Returns the new child's handle -int CreateAndAttach(int me, const char *child_name, ubyte child_type, char parent_ap, char child_ap, bool f_aligned = true, - bool f_set_parent = false) { +static int CreateAndAttach(int me, const char *child_name, ubyte child_type, char parent_ap, char child_ap, + bool f_aligned = true, bool f_set_parent = false); + +// Returns the new child's handle +int CreateAndAttach(int me, const char *child_name, ubyte child_type, char parent_ap, char child_ap, bool f_aligned, + bool f_set_parent) { int child_handle = OBJECT_HANDLE_NONE; int child_id = Obj_FindID(child_name); msafe_struct m; @@ -284,57 +288,57 @@ typedef struct { const char *name; } tScriptInfo; -tScriptInfo ScriptInfo[NUM_IDS] = {{ID_PEST, "Pest"}, - {ID_STINGER, "Stinger"}, - {ID_DRAGON, "Dragontorso"}, - {ID_TRACKER, "Tracker"}, - {ID_LANCE, "Lance"}, - {ID_FLAK, "Flak"}, - {ID_SUPERTROOPER, "supertrooper"}, - {ID_REDSUPERTROOPER, "red supertrooper"}, - {ID_JUGG, "jugg"}, - {ID_SIXGUN, "Sixgun"}, - {ID_SICKLE, "Sickle"}, - {ID_GUIDEBOT, "Guidebot"}, - {ID_FIREATDIST, "FireAtDist"}, - {ID_TUBBS, "Tubbs"}, - {ID_THIEF, "Thief"}, - {ID_GBPOWERUP, "GBPowerup"}, - {ID_BARNSWALLOW, "BarnSwallow"}, - {ID_SPARKY, "Sparky"}, - {ID_MANTARAY, "Mantaray"}, - {ID_SPYHUNTER, "Spyhunter"}, - {ID_SNIPER, "Sniper"}, - {ID_HUMONCULOUS, "Humonculous"}, - {ID_SEEKER, "Seeker"}, - {ID_BETTY, "Betty"}, - {ID_CHAFF, "ChaffBomb"}, - {ID_CHAFFCHUNK, "ChaffChunk"}, - {ID_PROXMINE, "ProxMine"}, - {ID_BETTYBOMB, "BettyBomb"}, - {ID_JOSHBELL, "JoshBell"}, - {ID_SKIFF, "Skiff"}, - {ID_EXPLODEONCONTACT, "ExplodeOnContact"}, - {ID_EXPLODETIMEOUT, "ExplodeTimeOut"}, - {ID_GUNBOY, "Gunboy"}, - {ID_DEATH_TOWER, "Ltowerbase"}, - {ID_DEATH_COLLECTOR, "Collectorbase"}, - {ID_CHEMICAL_BALL, "ChemicalBall"}, - {ID_HELLION, "Hellion"}, - {ID_SUPERTHIEF, "superthief"}, - {ID_EVADERMODA, "EvaderModA"}, - {ID_DESTROYONCONTACT, "DestroyOnContact"}, - {ID_HATEPTMC, "HatePTMC"}, - {ID_SNIPERNORUN, "SniperNoRun"}, - {ID_FLAMERAS, "FlameRAS"}, - {ID_OLDSCRATCH, "old scratch"}}; +static tScriptInfo ScriptInfo[NUM_IDS] = {{ID_PEST, "Pest"}, + {ID_STINGER, "Stinger"}, + {ID_DRAGON, "Dragontorso"}, + {ID_TRACKER, "Tracker"}, + {ID_LANCE, "Lance"}, + {ID_FLAK, "Flak"}, + {ID_SUPERTROOPER, "supertrooper"}, + {ID_REDSUPERTROOPER, "red supertrooper"}, + {ID_JUGG, "jugg"}, + {ID_SIXGUN, "Sixgun"}, + {ID_SICKLE, "Sickle"}, + {ID_GUIDEBOT, "Guidebot"}, + {ID_FIREATDIST, "FireAtDist"}, + {ID_TUBBS, "Tubbs"}, + {ID_THIEF, "Thief"}, + {ID_GBPOWERUP, "GBPowerup"}, + {ID_BARNSWALLOW, "BarnSwallow"}, + {ID_SPARKY, "Sparky"}, + {ID_MANTARAY, "Mantaray"}, + {ID_SPYHUNTER, "Spyhunter"}, + {ID_SNIPER, "Sniper"}, + {ID_HUMONCULOUS, "Humonculous"}, + {ID_SEEKER, "Seeker"}, + {ID_BETTY, "Betty"}, + {ID_CHAFF, "ChaffBomb"}, + {ID_CHAFFCHUNK, "ChaffChunk"}, + {ID_PROXMINE, "ProxMine"}, + {ID_BETTYBOMB, "BettyBomb"}, + {ID_JOSHBELL, "JoshBell"}, + {ID_SKIFF, "Skiff"}, + {ID_EXPLODEONCONTACT, "ExplodeOnContact"}, + {ID_EXPLODETIMEOUT, "ExplodeTimeOut"}, + {ID_GUNBOY, "Gunboy"}, + {ID_DEATH_TOWER, "Ltowerbase"}, + {ID_DEATH_COLLECTOR, "Collectorbase"}, + {ID_CHEMICAL_BALL, "ChemicalBall"}, + {ID_HELLION, "Hellion"}, + {ID_SUPERTHIEF, "superthief"}, + {ID_EVADERMODA, "EvaderModA"}, + {ID_DESTROYONCONTACT, "DestroyOnContact"}, + {ID_HATEPTMC, "HatePTMC"}, + {ID_SNIPERNORUN, "SniperNoRun"}, + {ID_FLAMERAS, "FlameRAS"}, + {ID_OLDSCRATCH, "old scratch"}}; -int aigame_mod_id; +static int aigame_mod_id; // use this macro to create unique timer IDs #define CREATE_TIMER_ID(id) ((aigame_mod_id << 16) | (id)) -int GetObjectParent(int object); -int GetObjectType(int object); +static int GetObjectParent(int object); +static int GetObjectType(int object); class BaseObjScript { public: @@ -1460,7 +1464,7 @@ public: #define GBC_RETURN_TO_SHIP 43 #define GBC_RENAME_SILENT 44 -int gb_command_text[NUM_GB_COMMANDS] = { +static int gb_command_text[NUM_GB_COMMANDS] = { TXT_GBM_EXITSHIP, TXT_GBM_REPAIR, TXT_GBM_RENAME, TXT_GBM_P0, TXT_GBM_P1, TXT_GBM_P2, TXT_GBM_P3, TXT_GBM_P4, TXT_GBM_P5, TXT_GBM_P6, TXT_GBM_P7, TXT_GBM_S0, TXT_GBM_S1, TXT_GBM_S2, TXT_GBM_S3, @@ -1479,14 +1483,14 @@ int gb_command_text[NUM_GB_COMMANDS] = { #define MAX_AV_ROBOTS 100 -int gb_pow_text[NUM_GB_POWERUPS] = {TXT_GBP_PUTOUTFIRE, TXT_GBP_COWABUNGA, TXT_GBP_BEGENTAL, - TXT_GBP_LETSDOIT, TXT_GBP_CONVERTEN, TXT_GBP_ACCELERATOR}; +static int gb_pow_text[NUM_GB_POWERUPS] = {TXT_GBP_PUTOUTFIRE, TXT_GBP_COWABUNGA, TXT_GBP_BEGENTAL, + TXT_GBP_LETSDOIT, TXT_GBP_CONVERTEN, TXT_GBP_ACCELERATOR}; -int gb_pow_not_text[NUM_GB_POWERUPS] = {TXT_GBPN_NOFIRE, TXT_GBPN_NOFIGHT, TXT_GBPN_GOPLAY, - TXT_GBPN_TOODISSY, TXT_GBPN_NOENEMY, TXT_GBPN_NOCOFFEE}; +static int gb_pow_not_text[NUM_GB_POWERUPS] = {TXT_GBPN_NOFIRE, TXT_GBPN_NOFIGHT, TXT_GBPN_GOPLAY, + TXT_GBPN_TOODISSY, TXT_GBPN_NOENEMY, TXT_GBPN_NOCOFFEE}; -int gb_pow_pickup_text[NUM_GB_POWERUPS] = {TXT_GBPP_EXTIN, TXT_GBPP_WINGNUT, TXT_GBPP_MANCON, - TXT_GBPP_GUARD, TXT_GBPP_ANTIV, TXT_GBPP_ACCEL}; +static int gb_pow_pickup_text[NUM_GB_POWERUPS] = {TXT_GBPP_EXTIN, TXT_GBPP_WINGNUT, TXT_GBPP_MANCON, + TXT_GBPP_GUARD, TXT_GBPP_ANTIV, TXT_GBPP_ACCEL}; #define GB_POW_FIRE 0 #define GB_POW_WINGNUT 1 @@ -1630,7 +1634,7 @@ typedef struct { int name_idx; } tThiefItems; -tThiefItems ThiefableItems[] = { +static tThiefItems ThiefableItems[] = { {0, THIEFABLEITEM_PRIMARY, 0.70f, 0.50f, 0.70f, TXT_WEAP_LASERS}, // Laser {1, THIEFABLEITEM_PRIMARY, 0.70f, 0.50f, 0.70f, TXT_WEAP_VAUSS}, // Vauss {2, THIEFABLEITEM_PRIMARY, 0.70f, 0.50f, 0.70f, TXT_WEAP_MICROWAVE}, // Microwave @@ -1661,7 +1665,7 @@ tThiefItems ThiefableItems[] = { {6, THIEFABLEITEM_ACCESSORY, 1.00f, 0.60f, 1.00f, TXT_WEAP_RAPIDFIRE}, // RapidFire {7, THIEFABLEITEM_ACCESSORY, 1.00f, 0.60f, 1.00f, TXT_WEAP_QUADLASERS}, // Quads }; -int numThiefableItems = sizeof(ThiefableItems) / sizeof(tThiefItems); +static int numThiefableItems = sizeof(ThiefableItems) / sizeof(tThiefItems); typedef struct { unsigned short id; @@ -1738,7 +1742,7 @@ typedef struct { const char *fire_sound; } tSuperThiefItems; -tSuperThiefItems SuperThiefableItems[] = { +static tSuperThiefItems SuperThiefableItems[] = { {0, -1, THIEFABLEITEM_PRIMARY, .25, TXT_WEAP_LASERS, "", ""}, // Laser {1, 4, THIEFABLEITEM_PRIMARY, .1f, TXT_WEAP_VAUSS, "Vauss", "WpnPyroGLVaussSidefire"}, // Vauss {2, 2, THIEFABLEITEM_PRIMARY, .1f, TXT_WEAP_MICROWAVE, "Raygun", "WpnPyroGLMicrowaveSide"}, // Microwave @@ -1762,7 +1766,7 @@ tSuperThiefItems SuperThiefableItems[] = { {19, -1, THIEFABLEITEM_SECONDARY, .2f, TXT_WEAP_BLACKSHARK, "", ""}, // Black Shark }; -int numSuperThiefableItems = sizeof(SuperThiefableItems) / sizeof(tSuperThiefItems); +static int numSuperThiefableItems = sizeof(SuperThiefableItems) / sizeof(tSuperThiefItems); #define SUPERTHIEF_MELEE_DIST 50.0f @@ -2767,7 +2771,7 @@ short STDCALL CallInstanceEvent(int id, void *ptr, int event, tOSIRISEventInfo * // Functions //============================================ -float Obj_GetObjDist(int me, int it, bool f_sub_rads) { +static float Obj_GetObjDist(int me, int it, bool f_sub_rads) { vector me_pos; vector it_pos; float dist; @@ -2789,7 +2793,7 @@ float Obj_GetObjDist(int me, int it, bool f_sub_rads) { return dist; } -inline void AIClearNonHPGoals(int handle) { +static inline void AIClearNonHPGoals(int handle) { int i; for (i = 0; i < MAX_GOALS; i++) { @@ -2798,7 +2802,7 @@ inline void AIClearNonHPGoals(int handle) { } } -inline bool IsGoalFinishedNotify(int index) { +static inline bool IsGoalFinishedNotify(int index) { return (index == AIN_GOAL_COMPLETE || index == AIN_GOAL_INVALID || index == AIN_GOAL_FAIL || index == AIN_GOAL_ERROR); } diff --git a/scripts/AIGame3.cpp b/scripts/AIGame3.cpp index 3fdfd64c..f80beac5 100644 --- a/scripts/AIGame3.cpp +++ b/scripts/AIGame3.cpp @@ -45,8 +45,8 @@ int STDCALL SaveRestoreState(void *file_ptr, ubyte saving_state); } #endif -int String_table_size = 0; -char **String_table = NULL; +static int String_table_size = 0; +static char **String_table = NULL; static const char *_Error_string = "!!ERROR MISSING STRING!!"; static const char *_Empty_string = ""; const char *GetStringFromTable(int index) { @@ -58,37 +58,60 @@ const char *GetStringFromTable(int index) { } #define TXT(x) GetStringFromTable(x) +//------------------- +// Function prototypes +//------------------- + +static int TurnOnSpew(int objref, int gunpoint, int effect_type, float mass, float drag, int gravity_type, ubyte isreal, + float lifetime, float interval, float longevity, float size, float speed, ubyte random); +// Returns the new child's handle +static int CreateAndAttach(int me, const char *child_name, ubyte child_type, char parent_ap, char child_ap, + bool f_aligned = true, bool f_set_parent = false); + +static int FindClosestPlayer(int objhandle); + +// Returns true if object current has an active Dallas low priority goal +static bool HasLowPriorityGoal(int obj_handle); + +// Returns true if object current has an active Dallas high priority goal +static bool HasHighPriorityGoal(int obj_handle); + +// Wipes out all goals except slots 0 and 3 (used by Dallas) +static void SafeGoalClearAll(int obj_handle); + +static void AI_SafeSetType(int obj_handle, int ai_type); + //---------------- // Name lookups //---------------- // Name lookup globals -unsigned short energy_effect_id; // weapon ID for the energy charge effect -unsigned short frag_burst_effect_id; // weapon ID for the frag burst effect -unsigned short boss_frag_burst_id; // weapon ID for the boss frag burst effect -unsigned short transfer_effect_id; // texture ID for the energy transfer lightning effect -unsigned short heal_effect_id; // texture ID for the heal lightning effect -unsigned short boss_heal_effect_id; // texture ID for the boss heal lightning effect -unsigned short tractor_beam_effect_id; // texture ID for the tractor beam effect -unsigned short alien_organism_id; // object type ID for the alien organism robot -unsigned short shield_blast_id; // weapon ID for the HT shield blast effect -unsigned short ht_grenade_id; // weapon ID for the HT grenade -unsigned short ht_grenade_effect_id; // weapon ID for the HT grenade launch effect -unsigned short lifter_blast_effect_id; // weapon ID for the lifter blast effect -unsigned short lifter_stick_effect_id; // texture ID for lifter's night-stick lightning effect -unsigned short teleport_effect_id; // weapon ID for teleporting effect +static unsigned short energy_effect_id; // weapon ID for the energy charge effect +static unsigned short frag_burst_effect_id; // weapon ID for the frag burst effect +static unsigned short boss_frag_burst_id; // weapon ID for the boss frag burst effect +static unsigned short transfer_effect_id; // texture ID for the energy transfer lightning effect +static unsigned short heal_effect_id; // texture ID for the heal lightning effect +static unsigned short boss_heal_effect_id; // texture ID for the boss heal lightning effect +static unsigned short tractor_beam_effect_id; // texture ID for the tractor beam effect +static unsigned short alien_organism_id; // object type ID for the alien organism robot +static unsigned short shield_blast_id; // weapon ID for the HT shield blast effect +static unsigned short ht_grenade_id; // weapon ID for the HT grenade +static unsigned short ht_grenade_effect_id; // weapon ID for the HT grenade launch effect +static unsigned short lifter_blast_effect_id; // weapon ID for the lifter blast effect +static unsigned short lifter_stick_effect_id; // texture ID for lifter's night-stick lightning effect +static unsigned short teleport_effect_id; // weapon ID for teleporting effect -unsigned short ht_grenade_sound_id; // sound ID for firing the grenade +static unsigned short ht_grenade_sound_id; // sound ID for firing the grenade -unsigned short powerup_id; // invisible powerup id +static unsigned short powerup_id; // invisible powerup id -unsigned short boss_flapping_id; // flapping sound id -unsigned short boss_turf_id; // turf id -unsigned short boss_see_id; -unsigned short boss_hurt_id; +static unsigned short boss_flapping_id; // flapping sound id +static unsigned short boss_turf_id; // turf id +static unsigned short boss_see_id; +static unsigned short boss_hurt_id; -unsigned short lifter_pull_sound_id; -unsigned short lifter_amb_sound_id; +static unsigned short lifter_pull_sound_id; +static unsigned short lifter_amb_sound_id; // ========================== // AI Goal Related Functions @@ -114,7 +137,7 @@ bool HasHighPriorityGoal(int obj_handle) { } // Returns True if given index implies that a goal is finished -inline bool IsGoalFinishedNotify(int index) { +static inline bool IsGoalFinishedNotify(int index) { return (index == AIN_GOAL_COMPLETE || index == AIN_GOAL_INVALID || index == AIN_GOAL_FAIL || index == AIN_GOAL_ERROR); } @@ -260,8 +283,8 @@ int TurnOnSpew(int objref, int gunpoint, int effect_type, float mass, float drag } // Returns the new child's handle -int CreateAndAttach(int me, const char *child_name, ubyte child_type, char parent_ap, char child_ap, bool f_aligned = true, - bool f_set_parent = false) { +int CreateAndAttach(int me, const char *child_name, ubyte child_type, char parent_ap, char child_ap, bool f_aligned, + bool f_set_parent) { int child_handle = OBJECT_HANDLE_NONE; int child_id = Obj_FindID(child_name); msafe_struct m; @@ -363,8 +386,13 @@ typedef struct { } tShotPathPositionData; // Clear shot globals -tShotPathPositionData ShotPathPositions[MAX_SHOT_PATH_POSITIONS]; -int num_shot_path_positions; +static tShotPathPositionData ShotPathPositions[MAX_SHOT_PATH_POSITIONS]; +static int num_shot_path_positions; + +static bool ScanShotPathPosition(int obj_handle, vector *pos, int room, float radius, float dist); +static float TraverseShotPath(tShotData *shot_data); +static int ShotIsClear(float risk_factor); +static int HasClearShot(tShotData *shot_data); // Scans area around given shot position for object data bool ScanShotPathPosition(int obj_handle, vector *pos, int room, float radius, float dist) { @@ -568,7 +596,7 @@ typedef struct { const char *name; } tScriptInfo; -tScriptInfo ScriptInfo[NUM_IDS] = { +static tScriptInfo ScriptInfo[NUM_IDS] = { {ID_ALIENORGANISM, "AlienOrganism"}, {ID_HEAVYTROOPER, "HeavyTrooper"}, {ID_LIFTER, "Lifter"}, {ID_ALIENBOSS, "AlienBoss"}, {ID_SECURITYCAMERA, "SecurityCamera"}, {ID_CROWDCONTROL, "CrowdControl"}}; @@ -1190,9 +1218,9 @@ public: // Alien Boss Lookup Globals #define AB_NUM_WANDER_ROOMS 11 -const char *AB_WanderRoomNames[AB_NUM_WANDER_ROOMS] = {"BossRoomA", "BossTunnelAB", "BossRoomB", "BossTunnelBC", - "BossRoomC", "BossTunnelCE", "BossRoomD", "BossTunnelAE", - "BossRoomE", "BossTunnelCE", "BossRoomD"}; +static const char *const AB_WanderRoomNames[AB_NUM_WANDER_ROOMS] = { + "BossRoomA", "BossTunnelAB", "BossRoomB", "BossTunnelBC", "BossRoomC", "BossTunnelCE", + "BossRoomD", "BossTunnelAE", "BossRoomE", "BossTunnelCE", "BossRoomD"}; // Alien Boss memory data structure typedef struct { diff --git a/scripts/aigame2.cpp b/scripts/aigame2.cpp index 1adbf63c..16e89522 100644 --- a/scripts/aigame2.cpp +++ b/scripts/aigame2.cpp @@ -42,8 +42,8 @@ int STDCALL SaveRestoreState(void *file_ptr, ubyte saving_state); } #endif -int String_table_size = 0; -char **String_table = NULL; +static int String_table_size = 0; +static char **String_table = NULL; static const char *_Error_string = "!!ERROR MISSING STRING!!"; static const char *_Empty_string = ""; const char *GetStringFromTable(int index) { @@ -70,7 +70,8 @@ const char *GetStringFromTable(int index) { /////////////////////////////////////////////////////////////////////////////// // Script names -const char *Script_names[NUM_IDS] = {"Samir's Pest", "StormTrooperBlack", "Creeper", "LukeTurret", "STBlackBarrel"}; +static const char *const Script_names[NUM_IDS] = {"Samir's Pest", "StormTrooperBlack", "Creeper", "LukeTurret", + "STBlackBarrel"}; // Class definitions @@ -375,12 +376,20 @@ short STDCALL CallInstanceEvent(int id, void *ptr, int event, tOSIRISEventInfo * // write data to the file_ptr, 0 when you should read in the data. int STDCALL SaveRestoreState(void *file_ptr, ubyte saving_state) { return 0; } +static int CreateAndAttach(int me, const char *child_name, ubyte child_type, char parent_ap, char child_ap, + bool f_aligned = true, bool f_set_parent = false); +static void FlushGoal(int me_handle, int goal_priority); +static void SafeGoalClearAll(int obj_handle); +static void AI_SafeSetType(int obj_handle, int ai_type); +static int TurnOnSpew(int objref, int gunpoint, int effect_type, float mass, float drag, int gravity_type, ubyte isreal, + float lifetime, float interval, float longevity, float size, float speed, ubyte random); + ////////////////////////////////////////////////////////////////////////////// // HELPER FUNCTIONS // Returns the new child's handle -int CreateAndAttach(int me, const char *child_name, ubyte child_type, char parent_ap, char child_ap, bool f_aligned = true, - bool f_set_parent = false) { +int CreateAndAttach(int me, const char *child_name, ubyte child_type, char parent_ap, char child_ap, bool f_aligned, + bool f_set_parent) { int child_handle = OBJECT_HANDLE_NONE; int child_id = Obj_FindID(child_name); msafe_struct m; diff --git a/scripts/aigame4.cpp b/scripts/aigame4.cpp index e3c93935..46876b98 100644 --- a/scripts/aigame4.cpp +++ b/scripts/aigame4.cpp @@ -55,6 +55,12 @@ const char *GetStringFromTable(int index) { } #define TXT(x) GetStringFromTable(x) +static void PortalBreakGlass(int portalnum, int roomnum); +// Returns the new child's handle +static int CreateAndAttach(int me, const char *child_name, ubyte child_type, char parent_ap, char child_ap, + bool f_aligned = true, bool f_set_parent = false); +static float Obj_GetObjDist(int me, int it, bool f_sub_rads); + void PortalBreakGlass(int portalnum, int roomnum) { msafe_struct mstruct; @@ -65,8 +71,8 @@ void PortalBreakGlass(int portalnum, int roomnum) { } // Returns the new child's handle -int CreateAndAttach(int me, const char *child_name, ubyte child_type, char parent_ap, char child_ap, bool f_aligned = true, - bool f_set_parent = false) { +int CreateAndAttach(int me, const char *child_name, ubyte child_type, char parent_ap, char child_ap, bool f_aligned, + bool f_set_parent) { int child_handle = OBJECT_HANDLE_NONE; int child_id = Obj_FindID(child_name); msafe_struct m; @@ -113,13 +119,10 @@ tScriptInfo ScriptInfo[NUM_IDS] = {{ID_MERCENDBOSS, "MercEndBoss"}, {ID_GUN, "Gu {ID_CASING, "Casing"}, {ID_HANGLIGHT, "HangLight"}, {ID_COMBWALLHIT, "CombWallHit"}, {ID_DROPTARGET, "DropTarget"}}; -int aigame_mod_id; +static int aigame_mod_id; // use this macro to create unique timer IDs #define CREATE_TIMER_ID(id) ((aigame_mod_id << 16) | (id)) -int GetObjectParent(int object); -int GetObjectType(int object); - class BaseObjScript { public: BaseObjScript(); @@ -398,7 +401,7 @@ float Obj_GetObjDist(int me, int it, bool f_sub_rads) { return dist; } -inline void AIClearNonHPGoals(int handle) { +static inline void AIClearNonHPGoals(int handle) { int i; for (i = 0; i < MAX_GOALS; i++) { @@ -407,7 +410,7 @@ inline void AIClearNonHPGoals(int handle) { } } -inline bool IsGoalFinishedNotify(int index) { +static inline bool IsGoalFinishedNotify(int index) { return (index == AIN_GOAL_COMPLETE || index == AIN_GOAL_INVALID || index == AIN_GOAL_FAIL || index == AIN_GOAL_ERROR); } diff --git a/scripts/clutter.cpp b/scripts/clutter.cpp index 62602c05..3f7f9a34 100644 --- a/scripts/clutter.cpp +++ b/scripts/clutter.cpp @@ -41,11 +41,11 @@ int STDCALL SaveRestoreState(void *file_ptr, ubyte saving_state); } #endif -int String_table_size = 0; -char **String_table = NULL; +static int String_table_size = 0; +static char **String_table = NULL; static const char *_Error_string = "!!ERROR MISSING STRING!!"; static const char *_Empty_string = ""; -const char *GetStringFromTable(int index) { +static const char *GetStringFromTable(int index) { if ((index < 0) || (index >= String_table_size)) return _Error_string; if (!String_table[index]) @@ -67,15 +67,15 @@ typedef struct { const char *name; } tScriptInfo; -tScriptInfo ScriptIDs[] = {{ID_FRAGCRATE, "fragcrate"}, - {ID_NAPALMBARREL, "napalmbarrel"}, - {ID_ALIENCUPLINK, "Aliencuplink"}, - {ID_TNTHIGHYIELD, "TNTCrateHighYield"}, - {ID_TNTMEDYIELD, "TNTCrateMediumYield"}, - {ID_FALLINGROCK, "FallingRock"}, - {ID_LAVAROCK, "LavaRock"}}; +static tScriptInfo ScriptIDs[] = {{ID_FRAGCRATE, "fragcrate"}, + {ID_NAPALMBARREL, "napalmbarrel"}, + {ID_ALIENCUPLINK, "Aliencuplink"}, + {ID_TNTHIGHYIELD, "TNTCrateHighYield"}, + {ID_TNTMEDYIELD, "TNTCrateMediumYield"}, + {ID_FALLINGROCK, "FallingRock"}, + {ID_LAVAROCK, "LavaRock"}}; -int NumScriptIDs = sizeof(ScriptIDs) / sizeof(tScriptInfo); +static int NumScriptIDs = sizeof(ScriptIDs) / sizeof(tScriptInfo); class ClutterScript { public: diff --git a/scripts/osiris_common.h b/scripts/osiris_common.h index f951693d..fd59376d 100644 --- a/scripts/osiris_common.h +++ b/scripts/osiris_common.h @@ -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 @@ -956,7 +956,7 @@ inline ddgr_color GR_RGB(int r, int g, int b) { return ((r << 16) + (g << 8) + b #define COM_DO_ACTION 1 #define COM_REINIT 2 -typedef struct { +typedef struct gb_com { int8_t action; int8_t index; void *ptr; @@ -993,8 +993,8 @@ typedef struct { // DO NOT ALTER THE STRING IT POINTS TO. uint32_t game_checksum; // Checksum of game structures, if this doesn't match - // the checksum at compile time, it is very likely that - // bad things can happen, and this module shouldn't initialize. + // the checksum at compile time, it is very likely that + // bad things can happen, and this module shouldn't initialize. } tOSIRISModuleInit; // contains the necessary data to initialize @@ -1022,7 +1022,7 @@ typedef struct { } tOSIRISEVTCREATED; // struct for EVT_CREATED data typedef struct { - uint8_t is_dying; // if this is !=0 than the event is coming because it is + uint8_t is_dying; // if this is !=0 than the event is coming because it is // really being destroyed. Else it is due to the level ending. } tOSIRISEVTDESTROY; // struct for EVT_DESTROY data @@ -1176,14 +1176,14 @@ typedef struct { uint16_t flags; int32_t id; // an optional id you can use to store, will be passed back on EVT_TIMER signal int32_t repeat_count; // if OTF_REPEATER is set, this is how many times to repeat the signal (every - // interval). -1 for infinite. + // interval). -1 for infinite. union { int32_t object_handle; // handle to the object to recieve the EVT_TIMER signal int32_t trigger_number; // trigger number to recieve the EVT_TIMER signal (OTF_TRIGGER) }; int32_t object_handle_detonator; // if OTF_CANCELONDEAD is specified, this is the object handle to - // use for checking, if this object dies, than auto-cancel the timer + // use for checking, if this object dies, than auto-cancel the timer float timer_interval; // the timeframe in between EVT_TIMER signals (for non-repeaters, this is how // long until the single EVT_TIMER gets signaled). @@ -1342,7 +1342,7 @@ typedef struct { #define PV_I_NUMPATHS 0x00040000 // get number of paths (path_id & node_id are ignored in this case) typedef struct { - vector pos; // where this node is in the world + vector pos; // where this node is in the world int32_t roomnum; // what room? int32_t flags; // if this point lives over the terrain, etc vector fvec; diff --git a/scripts/osiris_import.h b/scripts/osiris_import.h index 74c8cf89..1a28e3ea 100644 --- a/scripts/osiris_import.h +++ b/scripts/osiris_import.h @@ -91,7 +91,7 @@ OSIRISEXTERN Obj_GetTimeLived_fp Obj_GetTimeLived; typedef void (*Obj_GetGunPos_fp)(int objhandle, int gun_number, vector *gun_pnt, vector *gun_normal); OSIRISEXTERN Obj_GetGunPos_fp Obj_GetGunPosFP; -inline void Obj_GetGunPos(int objhandle, int gun_number, vector *gun_pnt, vector *gun_normal = NULL) { +static inline void Obj_GetGunPos(int objhandle, int gun_number, vector *gun_pnt, vector *gun_normal = NULL) { Obj_GetGunPosFP(objhandle, gun_number, gun_pnt, gun_normal); } @@ -99,7 +99,8 @@ inline void Obj_GetGunPos(int objhandle, int gun_number, vector *gun_pnt, vector // returns information about a groundpoint of an object typedef void (*Obj_GetGroundPos_fp)(int objhandle, int ground_number, vector *ground_pnt, vector *ground_normal); OSIRISEXTERN Obj_GetGroundPos_fp Obj_GetGroundPosFP; -inline void Obj_GetGroundPos(int objhandle, int ground_number, vector *ground_pnt, vector *ground_normal = NULL) { +static inline void Obj_GetGroundPos(int objhandle, int ground_number, vector *ground_pnt, + vector *ground_normal = NULL) { Obj_GetGroundPosFP(objhandle, ground_number, ground_pnt, ground_normal); } @@ -107,7 +108,7 @@ inline void Obj_GetGroundPos(int objhandle, int ground_number, vector *ground_pn typedef void (*Room_Value_fp)(int roomnum, char op, char vhandle, void *ptr, int index); OSIRISEXTERN Room_Value_fp Room_ValueFP; -inline void Room_Value(int roomnum, char op, char vhandle, void *ptr, int index = 0) { +static inline void Room_Value(int roomnum, char op, char vhandle, void *ptr, int index = 0) { Room_ValueFP(roomnum, op, vhandle, ptr, index); } @@ -171,7 +172,7 @@ OSIRISEXTERN AI_GetPathID_fp AI_GetPathID; // int AI_GoalFollowPathSimple(int objhandle,int path_id,int guid,int flags); typedef int (*AI_GoalFollowPathSimple_fp)(int objhandle, int path_id, int guid, int flags, int slot); OSIRISEXTERN AI_GoalFollowPathSimple_fp AI_GoalFollowPathSimpleFP; -inline int AI_GoalFollowPathSimple(int objhandle, int path_id, int guid, int flags, int slot = 3) { +static inline int AI_GoalFollowPathSimple(int objhandle, int path_id, int guid, int flags, int slot = 3) { return AI_GoalFollowPathSimpleFP(objhandle, path_id, guid, flags, slot); } @@ -187,14 +188,14 @@ OSIRISEXTERN AI_Value_fp AI_Value; typedef void (*Obj_Value_fp)(int objhandle, char op, char vtype, void *ptr, int index); OSIRISEXTERN Obj_Value_fp Obj_ValueFP; -inline void Obj_Value(int objhandle, char op, char vtype, void *ptr, int index = 0) { +static inline void Obj_Value(int objhandle, char op, char vtype, void *ptr, int index = 0) { Obj_ValueFP(objhandle, op, vtype, ptr, index); } // void Matcen_Value(int matcen_handle, char op, char vtype, void *ptr, int prod_index = 0); typedef void (*Matcen_Value_fp)(int matcen_handle, char op, char vtype, void *ptr, int prod_index); OSIRISEXTERN Matcen_Value_fp Matcen_ValueFP; -inline void Matcen_Value(int matcen_handle, char op, char vtype, void *ptr, int prod_index = 0) { +static inline void Matcen_Value(int matcen_handle, char op, char vtype, void *ptr, int prod_index = 0) { Matcen_ValueFP(matcen_handle, op, vtype, ptr, prod_index); } @@ -226,8 +227,8 @@ OSIRISEXTERN AI_ClearGoal_fp AI_ClearGoal; // int AI_FindObjOfType(int objhandle,int type, bool f_ignore_init_room, int parent_handle = OBJECT_HANDLE_NONE); typedef int (*AI_FindObjOfType_fp)(int objhandle, int type, int id, bool f_ignore_init_room, int parent_handle); OSIRISEXTERN AI_FindObjOfType_fp AI_FindObjOfTypeFP; -inline int AI_FindObjOfType(int objhandle, int type, int id, bool f_ignore_init_room, - int parent_handle = OBJECT_HANDLE_NONE) { +static inline int AI_FindObjOfType(int objhandle, int type, int id, bool f_ignore_init_room, + int parent_handle = OBJECT_HANDLE_NONE) { return AI_FindObjOfTypeFP(objhandle, type, id, f_ignore_init_room, parent_handle); } // vector AI_GetRoomPathPoint(int roomnum); @@ -393,8 +394,8 @@ OSIRISEXTERN MSafe_DoPowerup_fp MSafe_DoPowerup; typedef int (*Obj_Create_fp)(ubyte type, ushort id, int roomnum, vector *pos, const matrix *orient, int parent_handle, vector *initial_velocity); OSIRISEXTERN Obj_Create_fp Obj_CreateFP; -inline int Obj_Create(ubyte type, ushort id, int roomnum, vector *pos, const matrix *orient = NULL, - int parent_handle = 0, vector *initial_velocity = NULL) { +static inline int Obj_Create(ubyte type, ushort id, int roomnum, vector *pos, const matrix *orient = NULL, + int parent_handle = 0, vector *initial_velocity = NULL) { return Obj_CreateFP(type, id, roomnum, pos, orient, parent_handle, initial_velocity); } // float Game_GetTime() (void) @@ -408,7 +409,7 @@ OSIRISEXTERN Game_GetFrameTime_fp Game_GetFrameTime; // void Obj_WBValue() (int obj_handle, char wb_index, char op, char vtype, void *ptr, char g_index) typedef void (*Obj_WBValue_fp)(int obj_handle, char wb_index, char op, char vtype, void *ptr, char g_index); OSIRISEXTERN Obj_WBValue_fp Obj_WBValueFP; -inline void Obj_WBValue(int obj_handle, char wb_index, char op, char vtype, void *ptr, char g_index = 0) { +static inline void Obj_WBValue(int obj_handle, char wb_index, char op, char vtype, void *ptr, char g_index = 0) { Obj_WBValueFP(obj_handle, wb_index, op, vtype, ptr, g_index); } @@ -441,15 +442,15 @@ OSIRISEXTERN Msn_FlagGet_fp Msn_FlagGet; typedef void (*Player_Value_fp)(int obj_handle, char op, char vhandle, void *ptr, int index); OSIRISEXTERN Player_Value_fp Player_ValueFP; -inline void Player_Value(int obj_handle, char op, char vhandle, void *ptr, int index = 0) { +static inline void Player_Value(int obj_handle, char op, char vhandle, void *ptr, int index = 0) { Player_ValueFP(obj_handle, op, vhandle, ptr, index); } typedef void (*Obj_SetCustomAnim_fp)(int handle, float start, float end, float time, char flags, int sound_handle, char next_anim_type); OSIRISEXTERN Obj_SetCustomAnim_fp Obj_SetCustomAnimFP; -inline void Obj_SetCustomAnim(int handle, float start, float end, float time, char flags, int sound_handle = -1, - char next_anim_type = -1) { +static inline void Obj_SetCustomAnim(int handle, float start, float end, float time, char flags, int sound_handle = -1, + char next_anim_type = -1) { Obj_SetCustomAnimFP(handle, start, end, time, flags, sound_handle, next_anim_type); } @@ -461,7 +462,7 @@ OSIRISEXTERN Obj_Ghost_fp Obj_Ghost; typedef void (*Obj_Burning_fp)(int handle, float time, float damage_per_second); OSIRISEXTERN Obj_Burning_fp Obj_BurningFP; -inline void Obj_Burning(int handle, float time, float damage_per_second = 1.0f) { +static inline void Obj_Burning(int handle, float time, float damage_per_second = 1.0f) { Obj_BurningFP(handle, time, damage_per_second); } @@ -486,17 +487,17 @@ OSIRISEXTERN File_eof_fp File_eof; typedef void (*Sound_Stop_fp)(int s_handle, bool f_immediately); OSIRISEXTERN Sound_Stop_fp Sound_StopFP; -inline void Sound_Stop(int s_handle, bool f_immediately = true) { Sound_StopFP(s_handle, f_immediately); } +static inline void Sound_Stop(int s_handle, bool f_immediately = true) { Sound_StopFP(s_handle, f_immediately); } typedef int (*Sound_Play2d_fp)(int obj_handle, int s_id, float volume); OSIRISEXTERN Sound_Play2d_fp Sound_Play2dFP; -inline int Sound_Play2d(int obj_handle, int s_id, float volume = 1.0f) { +static inline int Sound_Play2d(int obj_handle, int s_id, float volume = 1.0f) { return Sound_Play2dFP(obj_handle, s_id, volume); } typedef int (*Sound_Play3d_fp)(int obj_handle, int s_id, float volume); OSIRISEXTERN Sound_Play3d_fp Sound_Play3dFP; -inline int Sound_Play3d(int obj_handle, int s_id, float volume = 1.0f) { +static inline int Sound_Play3d(int obj_handle, int s_id, float volume = 1.0f) { return Sound_Play3dFP(obj_handle, s_id, volume); } @@ -511,7 +512,7 @@ OSIRISEXTERN AI_IsObjEnemy_fp AI_IsObjEnemy; typedef bool (*AI_GoalValue_fp)(int obj_handle, char g_index, char op, char vtype, void *ptr, char index); OSIRISEXTERN AI_GoalValue_fp AI_GoalValueFP; -inline bool AI_GoalValue(int obj_handle, char g_index, char op, char vtype, void *ptr, char index = 0) { +static inline bool AI_GoalValue(int obj_handle, char g_index, char op, char vtype, void *ptr, char index = 0) { return AI_GoalValueFP(obj_handle, g_index, op, vtype, ptr, index); } @@ -519,9 +520,9 @@ typedef int (*AI_GetNearbyObjs_fp)(vector *pos, int init_roomnum, float rad, int bool f_lightmap_only, bool f_only_players_and_ais, bool f_include_non_collide_objects, bool f_stop_at_closed_doors); OSIRISEXTERN AI_GetNearbyObjs_fp AI_GetNearbyObjsFP; -inline int AI_GetNearbyObjs(vector *pos, int init_roomnum, float rad, int *object_handle_list, int max_elements, - bool f_lightmap_only, bool f_only_players_and_ais = true, - bool f_include_non_collide_objects = false, bool f_stop_at_closed_doors = true) { +static inline int AI_GetNearbyObjs(vector *pos, int init_roomnum, float rad, int *object_handle_list, int max_elements, + bool f_lightmap_only, bool f_only_players_and_ais = true, + bool f_include_non_collide_objects = false, bool f_stop_at_closed_doors = true) { return AI_GetNearbyObjsFP(pos, init_roomnum, rad, object_handle_list, max_elements, f_lightmap_only, f_only_players_and_ais, f_include_non_collide_objects, f_stop_at_closed_doors); } @@ -612,8 +613,8 @@ OSIRISEXTERN Scrpt_FindTextureName_fp Scrpt_FindTextureName; typedef void (*Game_CreateRandomSparks_fp)(int num_sparks, vector *pos, int roomnum, int which_index, float force_scalar); OSIRISEXTERN Game_CreateRandomSparks_fp Game_CreateRandomSparksFP; -inline void Game_CreateRandomSparks(int num_sparks, vector *pos, int roomnum, int which_index = -1, - float force_scalar = 1.0f) { +static inline void Game_CreateRandomSparks(int num_sparks, vector *pos, int roomnum, int which_index = -1, + float force_scalar = 1.0f) { return Game_CreateRandomSparksFP(num_sparks, pos, roomnum, which_index, force_scalar); } @@ -636,7 +637,8 @@ OSIRISEXTERN Game_IsShipEnabled_fp Game_IsShipEnabled; // returns true if operation was successful typedef bool (*Path_GetInformation_fp)(int pathid, int point, vector *pos, int *room, matrix *orient); OSIRISEXTERN Path_GetInformation_fp Path_GetInformationFP; -inline bool Path_GetInformation(int pathid, int point, vector *pos = NULL, int *room = NULL, matrix *orient = NULL) { +static inline bool Path_GetInformation(int pathid, int point, vector *pos = NULL, int *room = NULL, + matrix *orient = NULL) { return Path_GetInformationFP(pathid, point, pos, room, orient); } // starts a canned cinematic sequence @@ -654,7 +656,7 @@ OSIRISEXTERN Scrpt_FindLevelGoalName_fp Scrpt_FindLevelGoalName; typedef void (*LGoal_Value_fp)(char op, char vtype, void *ptr, int g_index, int i_index); OSIRISEXTERN LGoal_Value_fp LGoal_ValueFP; -inline void LGoal_Value(char op, char vtype, void *ptr, int g_index = -1, int i_index = -1) { +static inline void LGoal_Value(char op, char vtype, void *ptr, int g_index = -1, int i_index = -1) { LGoal_ValueFP(op, vtype, ptr, g_index, i_index); } diff --git a/tools/HogMaker/HogFormat.h b/tools/HogMaker/HogFormat.h index f5a9ef96..97ca484f 100644 --- a/tools/HogMaker/HogFormat.h +++ b/tools/HogMaker/HogFormat.h @@ -39,7 +39,7 @@ FILE 1 [filelen(FILE 1)] FILE NFILES-1 [filelen(NFILES -1)] */ -inline std::array array_with(char val) { +static inline std::array array_with(char val) { std::array arr; arr.fill(val); return arr; diff --git a/tools/HogMaker/IOOps.h b/tools/HogMaker/IOOps.h index 3222fdf4..57739270 100644 --- a/tools/HogMaker/IOOps.h +++ b/tools/HogMaker/IOOps.h @@ -25,7 +25,7 @@ namespace D3 { template -inline std::ostream &bin_write(std::ostream &output, T value, bool is_little_endian = true, size_t n = sizeof(T)) { +static inline std::ostream &bin_write(std::ostream &output, T value, bool is_little_endian = true, size_t n = sizeof(T)) { value = is_little_endian ? convert_le(value) : convert_be(value); output.write(reinterpret_cast(&value), n);