Mark various per-file structures as static

This commit is contained in:
Kp 2015-08-12 03:11:46 +00:00
parent bc7c469ab2
commit 17b1943c5e
35 changed files with 161 additions and 4 deletions

View file

@ -341,6 +341,8 @@ int gr_bitmap_rle_compress(grs_bitmap &bmp)
#define MAX_CACHE_BITMAPS 32
namespace {
struct rle_cache_element
{
const grs_bitmap *rle_bitmap;
@ -348,6 +350,8 @@ struct rle_cache_element
int last_used;
};
}
static int rle_cache_initialized;
static int rle_counter;
static int rle_next;

View file

@ -18,11 +18,15 @@
#define MAX_INSTANCE_DEPTH 5
namespace {
struct instance_context {
vms_matrix m;
vms_vector p;
};
}
static array<instance_context, MAX_INSTANCE_DEPTH> instance_stack;
int instance_depth = 0;

View file

@ -20,12 +20,16 @@
#include "compiler-range_for.h"
namespace {
struct rod_4point
{
array<cg3s_point *, 4> point_list;
array<g3s_point, 4> points;
};
}
//compute the corners of a rod. fills in vertbuf.
static int calc_rod_corners(rod_4point &rod_point_group, const g3s_point &bot_point,fix bot_width,const g3s_point &top_point,fix top_width)
{

View file

@ -19,6 +19,8 @@
#include "playsave.h"
#include "kconfig.h"
namespace {
int num_joysticks = 0;
/* This struct is a "virtual" joystick, which includes all the axes
@ -56,6 +58,8 @@ struct d_physical_joystick {
int button_map[MAX_BUTTONS_PER_JOYSTICK];
};
}
static array<d_physical_joystick, MAX_JOYSTICKS> SDL_Joysticks;
void joy_button_handler(SDL_JoyButtonEvent *jbe)

View file

@ -295,11 +295,15 @@ const array<key_props, 256> key_properties = {{
{ "W95", 255, SDLK_WORLD_95 }, // 255
}};
namespace {
struct d_event_keycommand : d_event
{
int keycode;
};
}
static int key_ismodlck(int keycode)
{
switch (keycode)

View file

@ -44,11 +44,15 @@ constexpr tt::integral_constant<uint8_t, 6> UI_GADGET_INPUTBOX::s_kind;
constexpr tt::integral_constant<uint8_t, 7> UI_GADGET_USERBOX::s_kind;
constexpr tt::integral_constant<uint8_t, 9> UI_GADGET_ICON::s_kind;
namespace {
struct event_gadget : d_event
{
UI_GADGET *gadget;
};
}
void ui_gadget_add(UI_DIALOG * dlg, short x1, short y1, short x2, short y2, UI_GADGET *gadget)
{
if (dlg->gadget == NULL )

View file

@ -34,6 +34,8 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#define MENU_BORDER 2
#define MENU_VERT_SPACING 2
namespace {
struct menu
{
std::unique_ptr<std::unique_ptr<UI_GADGET_BUTTON>[]> button_g;
@ -42,6 +44,8 @@ struct menu
int num_buttons;
};
}
static int menu_handler(UI_DIALOG *,const d_event &event, menu *m)
{
for (int i=0; i<m->num_buttons; i++ )

View file

@ -41,6 +41,8 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#define MAXMENUS 30
#define MAXITEMS 32
namespace {
struct ITEM {
short x, y, w, h;
RAIIdmem<char[]> Text;
@ -59,6 +61,8 @@ struct MENU : embed_window_pointer_t {
array<ITEM, MAXITEMS> Item;
};
}
static array<MENU, MAXMENUS> Menu;
static unsigned num_menus;

View file

@ -43,6 +43,8 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#define BUTTON_HORZ_SPACING 20
#define TEXT_EXTRA_HEIGHT 5
namespace {
struct messagebox
{
const ui_messagebox_tie *button;
@ -54,6 +56,8 @@ struct messagebox
int line_y;
};
}
static int messagebox_handler(UI_DIALOG *dlg,const d_event &event, messagebox *m)
{
if (event.type == EVENT_UI_DIALOG_DRAW)

View file

@ -61,6 +61,8 @@ static UI_DIALOG *MainWindow = NULL;
static int CurrentHostageIndex = -1;
static int LastHostageIndex = -1;
namespace {
struct hostage_dialog
{
std::unique_ptr<UI_GADGET_USERBOX> hostageViewBox;
@ -72,6 +74,8 @@ struct hostage_dialog
fix vclip_playback_speed; // Calculated internally. Frames/second of vclip.
};
}
static int SelectPrevHostage() {
int start=0;

View file

@ -29,12 +29,16 @@
//#define D2TMAP_CONV // used for testing
namespace {
struct snd_info
{
unsigned int length;
ubyte *data;
};
}
struct DiskBitmapHeader2
{
char name[8];
@ -66,6 +70,8 @@ struct DiskSoundHeader
int offset;
} __pack__;
namespace {
struct custom_info
{
int offset;
@ -74,6 +80,8 @@ struct custom_info
int width, height;
};
}
static array<grs_bitmap, MAX_BITMAP_FILES> BitmapOriginal;
static array<snd_info, MAX_SOUND_FILES> SoundOriginal;

View file

@ -1581,11 +1581,15 @@ void drop_stolen_items(const vcobjptr_t objp)
}
// --------------------------------------------------------------------------------------------------------------
namespace {
struct escort_menu : ignore_window_pointer_t
{
array<char, 300> msg;
};
}
static window_event_result escort_menu_keycommand(window *, const d_event &event, escort_menu *)
{
int key;

View file

@ -63,12 +63,16 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#include "compiler-range_for.h"
namespace {
// Subtitle data
struct subtitle {
short first_frame,last_frame;
char *msg;
};
}
static int init_subtitles(const char *filename);
#define MAX_SUBTITLES 500
@ -99,10 +103,14 @@ public:
// Movielib data
static const array<array<char, 8>, 3> movielib_files{{{"intro"}, {"other"}, {"robots"}}};
namespace {
struct loaded_movie_t
{
array<char, FILENAME_LEN + 2> filename;
};
}
static loaded_movie_t extra_robot_movie_mission;
static RWops_ptr RoboFile;
@ -253,6 +261,7 @@ static void MovieSetPalette(const unsigned char *p, unsigned start, unsigned cou
memcpy(&gr_palette[start],p+start*3,count*3);
}
namespace {
struct movie : ignore_window_pointer_t
{
@ -262,6 +271,8 @@ struct movie : ignore_window_pointer_t
MVESTREAM_ptr_t pMovie;
};
}
static window_event_result show_pause_message(window *, const d_event &event, const unused_window_userdata_t *)
{
switch (event.type)

View file

@ -59,6 +59,8 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#define MAX_OPEN_FONTS 50
namespace {
struct openfont
{
array<char, FILENAME_LEN> filename;
@ -67,6 +69,8 @@ struct openfont
std::unique_ptr<uint8_t[]> dataptr;
};
}
//list of open fonts, for use (for now) for palette remapping
static array<openfont, MAX_OPEN_FONTS> open_font;

View file

@ -41,6 +41,8 @@
/* Sound system function pointers */
namespace {
struct sound_function_table_t
{
int (*init)();
@ -92,8 +94,6 @@ static const sound_function_table_t digi_audio_table{
&digi_audio_set_digi_volume,
};
namespace {
class sound_function_pointers_t
{
#ifdef USE_SDLMIXER

View file

@ -50,6 +50,8 @@
#endif
#define MIN_VOLUME 10
namespace {
struct RAIIMix_Chunk : public Mix_Chunk
{
~RAIIMix_Chunk()
@ -58,6 +60,8 @@ struct RAIIMix_Chunk : public Mix_Chunk
}
};
}
static int digi_initialised = 0;
static int digi_mixer_max_channels = MAX_SOUND_SLOTS;
static inline int fix2byte(fix f) { return (f / 256) % 256; }

View file

@ -63,6 +63,8 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
//-------------------------------------------------------------------------
static UI_DIALOG *MainWindow = NULL;
namespace {
struct centers_dialog
{
std::unique_ptr<UI_GADGET_BUTTON> quitButton;
@ -71,6 +73,8 @@ struct centers_dialog
int old_seg_num;
};
}
static int centers_dialog_handler(UI_DIALOG *dlg,const d_event &event, centers_dialog *c);
//-------------------------------------------------------------------------

View file

@ -60,6 +60,8 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
static UI_DIALOG *MainWindow = NULL;
namespace {
struct trigger_dialog
{
std::unique_ptr<UI_GADGET_USERBOX> wallViewBox;
@ -68,6 +70,8 @@ struct trigger_dialog
int old_trigger_num;
};
}
//-----------------------------------------------------------------
// Adds a trigger to wall, and returns the trigger number.

View file

@ -210,6 +210,8 @@ const
#endif
array<color_t, 3> edge_colors{{54, 59, 64}};
namespace {
struct seg_edge
{
union {
@ -220,6 +222,8 @@ struct seg_edge
ubyte face_count, backface_count;
};
}
static array<seg_edge, MAX_EDGES> edge_list;
static array<int, MAX_EDGES> used_list; //which entries in edge_list have been used
int n_used;

View file

@ -68,6 +68,8 @@ static int GoodyPrevID();
//-------------------------------------------------------------------------
static UI_DIALOG *MainWindow = NULL;
namespace {
struct robot_dialog
{
std::unique_ptr<UI_GADGET_USERBOX> robotViewBox, containsViewBox;
@ -78,6 +80,8 @@ struct robot_dialog
int old_object;
};
}
static int robot_dialog_handler(UI_DIALOG *dlg,const d_event &event, robot_dialog *r);
static void call_init_ai_object(const vobjptr_t objp, ai_behavior behavior)
@ -715,6 +719,8 @@ int robot_dialog_handler(UI_DIALOG *dlg,const d_event &event, robot_dialog *r)
static UI_DIALOG *MattWindow = NULL;
namespace {
struct object_dialog
{
struct creation_context
@ -730,6 +736,8 @@ struct object_dialog
std::unique_ptr<UI_GADGET_BUTTON> quitButton;
};
}
static int object_dialog_handler(UI_DIALOG *dlg,const d_event &event, object_dialog *o);
void object_close_window()

View file

@ -65,6 +65,8 @@ static int wall_remove_door_flag(sbyte flag);
//-------------------------------------------------------------------------
static UI_DIALOG *MainWindow = NULL;
namespace {
struct wall_dialog
{
std::unique_ptr<UI_GADGET_USERBOX> wallViewBox;
@ -76,8 +78,6 @@ struct wall_dialog
int framenum;
};
static int wall_dialog_handler(UI_DIALOG *dlg,const d_event &event, wall_dialog *wd);
static int Current_door_type=1;
struct count_wall
@ -87,6 +87,10 @@ struct count_wall
short sidenum;
};
}
static int wall_dialog_handler(UI_DIALOG *dlg,const d_event &event, wall_dialog *wd);
//---------------------------------------------------------------------
// Add a wall (removable 2 sided)
static int add_wall(const vsegptridx_t seg, short side)

View file

@ -4169,10 +4169,14 @@ void create_awareness_event(const vobjptr_t objp, player_awareness_type_t type)
}
}
namespace {
struct awareness_t : array<player_awareness_type_t, MAX_SEGMENTS>
{
};
}
// ----------------------------------------------------------------------------------
static void pae_aux(segnum_t segnum, player_awareness_type_t type, int level, awareness_t &New_awareness)
{

View file

@ -96,6 +96,8 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#define EF_NO_FADE 32 // An edge that doesn't fade with distance
#define EF_TOO_FAR 64 // An edge that is too far away
namespace {
struct Edge_info
{
array<int, 2> verts; // 8 bytes
@ -154,6 +156,8 @@ struct automap : ignore_window_pointer_t
segment_depth_array_t depth_array;
};
}
#define MAX_EDGES_FROM_VERTS(v) ((v)*4)
#define K_WALL_NORMAL_COLOR BM_XRGB(29, 29, 29 )

View file

@ -2514,6 +2514,8 @@ void collide_two_objects(vobjptridx_t A, vobjptridx_t B, vms_vector &collision_p
#define ENABLE_SAME_COLLISION(type,f) COLLISION_RESULT(type,type,RESULT_CHECK);
#define DISABLE_SAME_COLLISION(type) COLLISION_RESULT(type,type,RESULT_NOTHING);
namespace {
template <object_type_t A, object_type_t B>
struct collision_result_t : public tt::conditional<(B < A), collision_result_t<B, A>, tt::integral_constant<ubyte, RESULT_NOTHING>>::type {};
@ -2523,6 +2525,8 @@ struct collision_result_t : public tt::conditional<(B < A), collision_result_t<B
COLLISION_TABLE(DISABLE, ENABLE);
}
template <std::size_t R, std::size_t... C>
static inline constexpr collision_inner_array_t collide_init(index_sequence<C...>)
{

View file

@ -68,6 +68,8 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#define ALLOWED_CHAR (!Current_mission ? 'R' : (is_SHAREWARE ? 'S' : 'R'))
#endif
namespace {
struct credits : ignore_window_pointer_t
{
RAIIPHYSFS_File file;
@ -81,6 +83,8 @@ struct credits : ignore_window_pointer_t
grs_bitmap backdrop;
};
}
static window_event_result credits_handler(window *, const d_event &event, credits *cr)
{
int l, y;

View file

@ -81,6 +81,8 @@ static int find_plane_line_intersection(vms_vector &new_pnt,const vms_vector &pl
}
namespace {
struct vec2d {
fix i,j;
};
@ -98,6 +100,8 @@ struct ij_pair
fix vms_vector::*j;
};
}
__attribute_warn_unused_result
static ij_pair find_largest_normal(vms_vector t)
{
@ -592,6 +596,8 @@ static vm_distance_squared check_vector_to_object(vms_vector &intp,const vms_vec
}
namespace {
#define MAX_SEGS_VISITED 100
struct fvi_segment_visit_count_t
{
@ -600,10 +606,13 @@ struct fvi_segment_visit_count_t
{
}
};
struct fvi_segments_visited_t : public fvi_segment_visit_count_t, public visited_segment_bitarray_t
{
};
}
int fvi_nest_count;
//these vars are used to pass vars from fvi_sub() to find_vector_intersection()

View file

@ -745,12 +745,16 @@ static inline void add_to_fcd_cache(int seg0, int seg1, int depth, vm_distance d
#define MIN_CACHE_FCD_DIST (F1_0*80) // Must be this far apart for cache lookup to succeed. Recognizes small changes in distance matter at small distances.
#define MAX_FCD_CACHE 8
namespace {
struct fcd_data {
segnum_t seg0, seg1;
int csd;
vm_distance dist;
};
}
int Fcd_index = 0;
static array<fcd_data, MAX_FCD_CACHE> Fcd_cache;
fix64 Last_fcd_flush_time;

View file

@ -38,6 +38,8 @@
#include "playsave.h"
#include "countarray.h"
namespace {
struct hudmsg
{
fix time;
@ -50,6 +52,8 @@ struct hudmsg
}
};
}
struct hudmsg_array_t : public count_array_t<hudmsg, HUD_MAX_NUM_STOR> {};
static hudmsg_array_t HUD_messages;

View file

@ -120,6 +120,8 @@ fix Cruise_speed=0;
#define INFO_Y (188)
namespace {
struct kc_item
{
const short x, y; // x, y pos of label
@ -153,6 +155,8 @@ struct kc_menu : embed_window_pointer_t
ubyte mouse_state;
};
}
const array<array<ubyte, MAX_CONTROLS>, 3> DefaultKeySettings{{
#if defined(DXX_BUILD_DESCENT_I)
{{0xc8,0x48,0xd0,0x50,0xcb,0x4b,0xcd,0x4d,0x38,0xff,0xff,0x4f,0xff,0x51,0xff,0x4a,0xff,0x4e,0xff,0xff,0x10,0x47,0x12,0x49,0x1d,0x9d,0x39,0xff,0x21,0xff,0x1e,0xff,0x2c,0xff,0x30,0xff,0x13,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf,0xff,0x33,0x0,0x34,0x0}},

View file

@ -181,6 +181,8 @@ static void kmatrix_status_msg (fix time, int reactor)
gr_printf(0x8000, SHEIGHT-LINE_SPACING, "Level finished. Wait (%d) to proceed or ESC to Quit.", time);
}
namespace {
struct kmatrix_screen : ignore_window_pointer_t
{
grs_bitmap background;
@ -190,6 +192,8 @@ struct kmatrix_screen : ignore_window_pointer_t
int aborted;
};
}
static void kmatrix_redraw(kmatrix_screen *km)
{
playernum_array_t sorted;

View file

@ -68,6 +68,8 @@ enum mle_loc
ML_MISSIONDIR = 1
};
namespace {
//mission list entry
struct mle : Mission_path
{
@ -80,6 +82,8 @@ struct mle : Mission_path
enum mle_loc location; // where the mission is
};
}
typedef std::vector<mle> mission_list;
Mission_ptr Current_mission; // currently loaded mission

View file

@ -873,7 +873,12 @@ static ubyte code_window_point(fix x,fix y,const rect &w)
char visited2[MAX_SEGMENTS];
#endif
namespace {
struct visited_twobit_array_t : visited_segment_multibit_array_t<2> {};
}
int lcnt_save,scnt_save;
//Given two sides of segment, tell the two verts which form the

View file

@ -574,6 +574,8 @@ static void state_read_player(PHYSFS_file *fp, player &pl, int swap)
state_player_rw_to_player(&pl_rw, &pl);
}
namespace {
//-------------------------------------------------------------------
struct state_userdata
{
@ -581,6 +583,8 @@ struct state_userdata
array<grs_bitmap_ptr, NUM_SAVES> sc_bmp;
};
}
static int state_callback(newmenu *menu,const d_event &event, state_userdata *const userdata)
{
array<grs_bitmap_ptr, NUM_SAVES> &sc_bmp = userdata->sc_bmp;

View file

@ -46,6 +46,8 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
//static grs_bitmap * cache_bitmaps[MAX_NUM_CACHE_BITMAPS];
namespace {
struct TEXTURE_CACHE {
grs_bitmap_ptr bitmap;
grs_bitmap * bottom_bmp;
@ -54,6 +56,8 @@ struct TEXTURE_CACHE {
fix64 last_time_used;
};
}
static array<TEXTURE_CACHE, MAX_NUM_CACHE_BITMAPS> Cache;
static unsigned num_cache_entries;

View file

@ -97,6 +97,8 @@ static int rescale_y(int y)
return y * GHEIGHT / 200;
}
namespace {
struct title_screen : ignore_window_pointer_t
{
grs_bitmap title_bm;
@ -104,6 +106,8 @@ struct title_screen : ignore_window_pointer_t
int allow_keys;
};
}
static window_event_result title_handler(window *, const d_event &event, title_screen *ts)
{
switch (event.type)