From 66a70fd373f40c8c51997521eeb733a9a2852b90 Mon Sep 17 00:00:00 2001 From: Kp Date: Thu, 2 Apr 2015 02:36:52 +0000 Subject: [PATCH] Prepare for global arrays to be array<> --- common/include/editor/editor.h | 4 ---- common/include/gr.h | 1 - common/main/ai.h | 15 ++++++++------- common/main/fwdwall.h | 2 -- common/main/hostage.h | 3 +-- common/main/morph.h | 2 +- common/main/physics.h | 3 ++- common/misc/hmp.cpp | 14 +++++++++----- d1x-rebirth/main/custom.cpp | 4 ++-- similar/main/gamefont.cpp | 3 +-- similar/main/gauges.cpp | 2 +- similar/main/hostage.cpp | 2 +- similar/main/physics.cpp | 3 ++- similar/main/piggy.cpp | 27 ++++++++++++--------------- similar/main/polyobj.cpp | 4 ++-- similar/main/wall.cpp | 3 +-- 16 files changed, 43 insertions(+), 49 deletions(-) diff --git a/common/include/editor/editor.h b/common/include/editor/editor.h index ea0fc5162..c1b47c15e 100644 --- a/common/include/editor/editor.h +++ b/common/include/editor/editor.h @@ -404,10 +404,6 @@ extern segnum_t get_free_segment_number(void); #define diagnostic_message editor_status #define diagnostic_message_fmt editor_status_fmt -// Status Icon. -extern void print_status_icon( char icon[1], int position ); -extern void clear_status_icon( char icon[1], int position ); - // Editor status message. extern void editor_status_fmt(const char *format, ... ) __attribute_format_printf(1, 2); #define editor_status_fmt(F,...) dxx_call_printf_checked(editor_status_fmt,editor_status,(),(F),##__VA_ARGS__) diff --git a/common/include/gr.h b/common/include/gr.h index 05b43d0f0..0ba81a919 100644 --- a/common/include/gr.h +++ b/common/include/gr.h @@ -452,7 +452,6 @@ extern palette_array_t gr_palette; typedef array gft_array0; typedef array gft_array1; extern gft_array1 gr_fade_table; -extern ubyte gr_inverse_table[32*32*32]; extern ushort gr_palette_selector; extern ushort gr_inverse_table_selector; diff --git a/common/main/ai.h b/common/main/ai.h index 7d501d419..da17428bc 100644 --- a/common/main/ai.h +++ b/common/main/ai.h @@ -74,14 +74,15 @@ extern sbyte Boss_hit_this_frame; #define NUM_D2_BOSSES 8 -extern const ubyte Boss_teleports[NUM_D2_BOSSES]; // Set byte if this boss can teleport -extern const ubyte Boss_spew_more[NUM_D2_BOSSES]; // Set byte if this boss can teleport +typedef ubyte boss_flags_t[NUM_D2_BOSSES]; +extern const boss_flags_t Boss_teleports; // Set byte if this boss can teleport +extern const boss_flags_t Boss_spew_more; // Set byte if this boss can teleport //extern ubyte Boss_cloaks[NUM_D2_BOSSES]; // Set byte if this boss can cloak -extern const ubyte Boss_spews_bots_energy[NUM_D2_BOSSES]; // Set byte if boss spews bots when hit by energy weapon. -extern const ubyte Boss_spews_bots_matter[NUM_D2_BOSSES]; // Set byte if boss spews bots when hit by matter weapon. -extern const ubyte Boss_invulnerable_energy[NUM_D2_BOSSES]; // Set byte if boss is invulnerable to energy weapons. -extern const ubyte Boss_invulnerable_matter[NUM_D2_BOSSES]; // Set byte if boss is invulnerable to matter weapons. -extern const ubyte Boss_invulnerable_spot[NUM_D2_BOSSES]; // Set byte if boss is invulnerable in all but a certain spot. (Dot product fvec|vec_to_collision < BOSS_INVULNERABLE_DOT) +extern const boss_flags_t Boss_spews_bots_energy; // Set byte if boss spews bots when hit by energy weapon. +extern const boss_flags_t Boss_spews_bots_matter; // Set byte if boss spews bots when hit by matter weapon. +extern const boss_flags_t Boss_invulnerable_energy; // Set byte if boss is invulnerable to energy weapons. +extern const boss_flags_t Boss_invulnerable_matter; // Set byte if boss is invulnerable to matter weapons. +extern const boss_flags_t Boss_invulnerable_spot; // Set byte if boss is invulnerable in all but a certain spot. (Dot product fvec|vec_to_collision < BOSS_INVULNERABLE_DOT) extern segnum_t Believed_player_seg; extern objnum_t Ai_last_missile_camera; #endif diff --git a/common/main/fwdwall.h b/common/main/fwdwall.h index 8e0a0341e..6afb4b368 100644 --- a/common/main/fwdwall.h +++ b/common/main/fwdwall.h @@ -170,8 +170,6 @@ extern unsigned Num_open_doors; // Number of open doors extern unsigned Num_wall_anims; extern array WallAnims; - -extern int walls_bm_num[MAX_WALL_ANIMS]; #endif #ifdef EDITOR diff --git a/common/main/hostage.h b/common/main/hostage.h index d0ca369eb..e975dec9d 100644 --- a/common/main/hostage.h +++ b/common/main/hostage.h @@ -60,8 +60,7 @@ static inline void hostage_init_info(const objnum_t &) {} #endif #endif -extern int N_hostage_types; - +extern unsigned N_hostage_types; extern int Hostage_vclip_num[MAX_HOSTAGE_TYPES]; // for each type of hostage void draw_hostage(vobjptridx_t obj); diff --git a/common/main/morph.h b/common/main/morph.h index 963b5b18e..a18a3b05a 100644 --- a/common/main/morph.h +++ b/common/main/morph.h @@ -33,7 +33,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #define MAX_VECS 5000 -struct morph_data +struct morph_data : prohibit_void_ptr { object *obj; // object which is morphing vms_vector morph_vecs[MAX_VECS]; diff --git a/common/main/physics.h b/common/main/physics.h index 4a40a0428..59654089d 100644 --- a/common/main/physics.h +++ b/common/main/physics.h @@ -39,7 +39,8 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. // these global vars are set after a call to do_physics_sim(). Ugly, I know. // list of segments went through -extern int phys_seglist[MAX_FVI_SEGS], n_phys_segs; +extern unsigned n_phys_segs; +extern int phys_seglist[MAX_FVI_SEGS]; // Simulate a physics object for this frame void do_physics_sim(vobjptridx_t obj); diff --git a/common/misc/hmp.cpp b/common/misc/hmp.cpp index 284b12529..32e326dc9 100644 --- a/common/misc/hmp.cpp +++ b/common/misc/hmp.cpp @@ -24,6 +24,8 @@ #include "dxxsconf.h" #include "compiler-make_unique.h" +#include "compiler-range_for.h" +#include "partial_range.h" #ifdef WORDS_BIGENDIAN #define MIDIINT(x) (x) @@ -34,9 +36,9 @@ #endif #ifdef _WIN32 -int midi_volume; -int channel_volume[16]; -void hmp_stop(hmp_file *hmp); +static int midi_volume; +static int channel_volume[16]; +static void hmp_stop(hmp_file *hmp); #endif // READ/OPEN/CLOSE HMP @@ -181,12 +183,14 @@ static int get_event(hmp_file *hmp, event *ev) { static const int cmdlen[7]={3,3,3,3,2,2,3}; unsigned long got; unsigned long mindelta, delta; - int i, ev_num; + int ev_num; hmp_track *trk, *fndtrk; mindelta = INT_MAX; fndtrk = NULL; - for (trk = hmp->trks, i = hmp->num_trks; (i--) > 0; trk++) { + range_for (auto &rtrk, partial_range(hmp->trks, static_cast(hmp->num_trks))) + { + const auto trk = &rtrk; if (!trk->left || (hmp->loop_start && hmp->looping && !trk->loop_set)) continue; if (!(got = get_var_num_hmi(trk->cur, trk->left, &delta))) diff --git a/d1x-rebirth/main/custom.cpp b/d1x-rebirth/main/custom.cpp index 76482421a..b4c8256c2 100644 --- a/d1x-rebirth/main/custom.cpp +++ b/d1x-rebirth/main/custom.cpp @@ -547,8 +547,8 @@ static void load_hxm(const d_fname &hxmname) static void custom_remove() { int i; - grs_bitmap *bmo = BitmapOriginal; - grs_bitmap *bmp = GameBitmaps; + auto bmo = begin(BitmapOriginal); + auto bmp = begin(GameBitmaps); for (i = 0; i < MAX_BITMAP_FILES; bmo++, bmp++, i++) if (bmo->bm_flags & 0x80) diff --git a/similar/main/gamefont.cpp b/similar/main/gamefont.cpp index cde7d2eab..c4283e6a9 100644 --- a/similar/main/gamefont.cpp +++ b/similar/main/gamefont.cpp @@ -54,7 +54,7 @@ static const char Gamefont_filenames_h[][16] = { array Gamefonts; -int Gamefont_installed=0; +static int Gamefont_installed; float FNTScaleX = 1, FNTScaleY = 1; //code to allow variable GAME_FONT, added 10/7/99 Matt Mueller - updated 11/18/99 to handle all fonts, not just GFONT_SMALL @@ -65,7 +65,6 @@ struct a_gamefont_conf int y; union{ char name[64];//hrm. - grs_font *ptr; } f; }; diff --git a/similar/main/gauges.cpp b/similar/main/gauges.cpp index 6b0c269e1..2efeb3917 100644 --- a/similar/main/gauges.cpp +++ b/similar/main/gauges.cpp @@ -2380,7 +2380,7 @@ static void sb_draw_energy_bar(int energy) static void sb_draw_afterburner() { int erase_height, w, h, aw, i; - char ab_str[3] = "AB"; + auto &ab_str = "AB"; PAGE_IN_GAUGE( SB_GAUGE_AFTERBURNER ); hud_bitblt(HUD_SCALE_X(SB_AFTERBURNER_GAUGE_X), HUD_SCALE_Y(SB_AFTERBURNER_GAUGE_Y), &GameBitmaps[GET_GAUGE_INDEX(SB_GAUGE_AFTERBURNER)]); diff --git a/similar/main/hostage.cpp b/similar/main/hostage.cpp index 524f9ecd0..d5483d9e4 100644 --- a/similar/main/hostage.cpp +++ b/similar/main/hostage.cpp @@ -40,7 +40,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. //------------- Globaly used hostage variables -------------------------------- -int N_hostage_types = 0; // Number of hostage types +unsigned N_hostage_types; // Number of hostage types int Hostage_vclip_num[MAX_HOSTAGE_TYPES]; // vclip num for each tpye of hostage diff --git a/similar/main/physics.cpp b/similar/main/physics.cpp index 4aa688321..c3fffe7bf 100644 --- a/similar/main/physics.cpp +++ b/similar/main/physics.cpp @@ -157,7 +157,8 @@ static void set_object_turnroll(const vobjptr_t obj) } //list of segments went through -int phys_seglist[MAX_FVI_SEGS],n_phys_segs; +unsigned n_phys_segs; +int phys_seglist[MAX_FVI_SEGS]; #define MAX_IGNORE_OBJS 100 diff --git a/similar/main/piggy.cpp b/similar/main/piggy.cpp index b8e7bb884..bc19d6159 100644 --- a/similar/main/piggy.cpp +++ b/similar/main/piggy.cpp @@ -68,6 +68,9 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #define DEFAULT_PIGFILE_REGISTERED "descent.pig" #elif defined(DXX_BUILD_DESCENT_II) +#include "compiler-range_for.h" +#include "partial_range.h" + #define DEFAULT_PIGFILE_REGISTERED "groupa.pig" #define DEFAULT_PIGFILE_SHAREWARE "d2demo.pig" #define DEFAULT_HAMFILE_REGISTERED "descent2.ham" @@ -87,7 +90,6 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. unsigned Num_aliases; array alias_list; -int Must_write_hamfile = 0; int Piggy_hamfile_version = 0; #endif @@ -99,8 +101,15 @@ struct SoundFile char name[15]; }; +#if defined(DXX_BUILD_DESCENT_II) +namespace { +#endif hashtable AllBitmapsNames; hashtable AllDigiSndNames; +int GameBitmapOffset[MAX_BITMAP_FILES]; +#if defined(DXX_BUILD_DESCENT_II) +} +#endif int Num_bitmap_files = 0; int Num_sound_files = 0; @@ -109,8 +118,6 @@ digi_sound GameSounds[MAX_SOUND_FILES]; int SoundOffset[MAX_SOUND_FILES]; grs_bitmap GameBitmaps[MAX_BITMAP_FILES]; -int Num_bitmap_files_new = 0; -int Num_sound_files_new = 0; #if defined(DXX_BUILD_DESCENT_I) #define DBM_FLAG_LARGE 128 // Flags added onto the flags struct in b static @@ -120,16 +127,12 @@ static SoundFile AllSounds[ MAX_SOUND_FILES ]; #define DBM_FLAG_ABM 64 // animated bitmap -int Piggy_bitmap_cache_size = 0; -int Piggy_bitmap_cache_next = 0; +static int Piggy_bitmap_cache_size; +static int Piggy_bitmap_cache_next; ubyte * Piggy_bitmap_cache_data = NULL; #if defined(DXX_BUILD_DESCENT_II) static #endif -int GameBitmapOffset[MAX_BITMAP_FILES]; -#if defined(DXX_BUILD_DESCENT_II) -static -#endif ubyte GameBitmapFlags[MAX_BITMAP_FILES]; ushort GameBitmapXlat[MAX_BITMAP_FILES]; @@ -280,7 +283,6 @@ bitmap_index piggy_register_bitmap( grs_bitmap * bmp, const char * name, int in_ #endif if (GameArg.DbgNoCompressPigBitmap) gr_bitmap_rle_compress(*bmp); - Num_bitmap_files_new++; } #if defined(DXX_BUILD_DESCENT_II) else if (SoundOffset[Num_sound_files] == 0) @@ -333,10 +335,6 @@ int piggy_register_sound( digi_sound * snd, const char * name, int in_file ) #endif i = Num_sound_files; - - if (!in_file) - Num_sound_files_new++; - Num_sound_files++; return i; } @@ -974,7 +972,6 @@ int read_hamfile() } if (!ham_fp) { - Must_write_hamfile = 1; return 0; } diff --git a/similar/main/polyobj.cpp b/similar/main/polyobj.cpp index 19f6b57be..7811af4e5 100644 --- a/similar/main/polyobj.cpp +++ b/similar/main/polyobj.cpp @@ -370,8 +370,8 @@ static polymodel *read_model_file(polymodel *pm,const char *filename,robot_info Assert(n_frames == N_ANIM_STATES); for (int m=0;mn_models;m++) - for (int f=0;f