Convert local arrays to array<>

This commit is contained in:
Kp 2015-04-19 04:18:49 +00:00
parent 3e520afc89
commit 150e2d2686
21 changed files with 49 additions and 48 deletions

View file

@ -23,7 +23,7 @@
struct rod_4point
{
array<cg3s_point *, 4> point_list;
g3s_point points[4];
array<g3s_point, 4> points;
};
//compute the corners of a rod. fills in vertbuf.
@ -68,7 +68,7 @@ static int calc_rod_corners(rod_4point &rod_point_group, const g3s_point &bot_po
rod_point_group.point_list[1] = &rod_point_group.points[1];
rod_point_group.point_list[2] = &rod_point_group.points[2];
rod_point_group.point_list[3] = &rod_point_group.points[3];
g3s_point (&rod_points)[4] = rod_point_group.points;
auto &rod_points = rod_point_group.points;
vm_vec_add(rod_points[0].p3_vec,top_point.p3_vec,tempv);
vm_vec_sub(rod_points[1].p3_vec,top_point.p3_vec,tempv);

View file

@ -292,7 +292,7 @@ struct vms_equation
{
union {
struct {fix x3, x2, x1, x0, y3, y2, y1, y0, z3, z2, z1, z0;} n;
fix xyz[3][4];
array<array<fix, 4>, 3> xyz;
};
};

View file

@ -58,7 +58,7 @@ extern int event_key_get_raw(const d_event &event); // same as above but without
extern unsigned char key_ascii();
// Set to 1 if the key is currently down, else 0
extern volatile unsigned char keyd_pressed[256];
extern array<uint8_t, 256> keyd_pressed;
extern volatile unsigned char keyd_last_pressed;
extern volatile unsigned char keyd_last_released;

View file

@ -42,7 +42,7 @@ struct Cfg : prohibit_void_ptr<Cfg>
bool OrigTrackOrder;
int MusicType;
int CMLevelMusicPlayOrder;
int CMLevelMusicTrack[2];
array<int, 2> CMLevelMusicTrack;
ntstring<PATH_MAX - 1> CMLevelMusicPath;
array<ntstring<PATH_MAX - 1>, 5> CMMiscMusic;
int GammaLevel;

View file

@ -140,7 +140,6 @@ struct robot_info : prohibit_void_ptr<robot_info>
//boss_flag, companion, thief, & pursuit probably should also be bits in the flags byte.
ubyte flags; // misc properties
ubyte pad[3]; // alignment
ubyte deathroll_sound; // if has deathroll, what sound?
ubyte glow; // apply this light to robot itself. stored as 4:4 fixed-point

View file

@ -180,7 +180,7 @@ static int get_var_num(unsigned char *data, int datalen,
}
static int get_event(hmp_file *hmp, event *ev) {
static const int cmdlen[7]={3,3,3,3,2,2,3};
static const array<int, 7> cmdlen{{3,3,3,3,2,2,3}};
unsigned long got;
unsigned long mindelta, delta;
int ev_num;

View file

@ -62,7 +62,7 @@ static UI_EVENT * EventBuffer = NULL;
static int Record = 0;
static int RecordFlags = 0;
static unsigned char SavedState[256];
static array<uint8_t, 256> SavedState;
static int PlaybackSpeed = 1;

View file

@ -118,7 +118,7 @@ struct browser
std::unique_ptr<UI_GADGET_LISTBOX> listbox1, listbox2;
std::unique_ptr<UI_GADGET_INPUTBOX> user_file;
int num_files, num_dirs;
char spaces[35];
array<char, 35> spaces;
};
static int browser_handler(UI_DIALOG *dlg,const d_event &event, browser *b)
@ -133,7 +133,7 @@ static int browser_handler(UI_DIALOG *dlg,const d_event &event, browser *b)
ui_dprintf_at( dlg, 20, 86,"&Files" );
ui_dprintf_at( dlg, 210, 86,"&Dirs" );
ui_dputs_at( dlg, 20, 60, b->spaces );
ui_dputs_at(dlg, 20, 60, b->spaces.data());
ui_dputs_at( dlg, 20, 60, b->view_dir );
return 1;

View file

@ -42,8 +42,7 @@ static int active_pad;
static int desc_x, desc_y;
static int HotKey[17];
static int HotKey1[17];
static array<int, 17> HotKey, HotKey1;
int ui_pad_get_current()
{

View file

@ -30,7 +30,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#include "key.h"
#include "window.h"
static const char *const KeyDesc[256] = { \
static const array<const char *, 256> KeyDesc{{
"","{Esc}","{1}","{2}","{3}","{4}","{5}","{6}","{7}","{8}","{9}","{0}","{-}", \
"{=}","{Backspace}","{Tab}","{Q}","{W}","{E}","{R}","{T}","{Y}","{U}","{I}","{O}", \
"{P}","{[}","{]}","{Enter}","{LeftCtrl}","{A}","{S}","{D}","{F}", \
@ -50,7 +50,8 @@ static const char *const KeyDesc[256] = { \
"","{Left}","","{Right}","","{End}","{Down}","{PageDown}","{Insert}", \
"{Delete}","","","","","","","","","","","","","","","","","", \
"","","","","","","","","","","","","","","","","","","","", \
"","","","","","","" };
"","","","","","",""
}};

View file

@ -74,7 +74,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#endif
static void say_escort_goal(int goal_num);
static void show_escort_menu(char *msg);
static void show_escort_menu(const array<char, 300> &);
static const char Escort_goal_text[MAX_ESCORT_GOALS][12] = {
@ -1552,7 +1552,7 @@ void drop_stolen_items(const vcobjptr_t objp)
// --------------------------------------------------------------------------------------------------------------
struct escort_menu : ignore_window_pointer_t
{
char msg[300];
array<char, 300> msg;
};
static window_event_result escort_menu_keycommand(window *wind,const d_event &event, escort_menu *)
@ -1714,7 +1714,7 @@ void do_escort_menu(void)
else
tstr = "Enable";
sprintf(menu->msg, "Select Guide-Bot Command:\n\n\n"
snprintf(menu->msg.data(), menu->msg.size(), "Select Guide-Bot Command:\n\n\n"
"0. Next Goal: %s" CC_LSPACING_S "3\n\n"
"\x84. Find Energy Powerup" CC_LSPACING_S "3\n\n"
"2. Find Energy Center" CC_LSPACING_S "3\n\n"
@ -1732,8 +1732,9 @@ void do_escort_menu(void)
// -------------------------------------------------------------------------------
// Show the Buddy menu!
void show_escort_menu(char *msg)
void show_escort_menu(const array<char, 300> &amsg)
{
const auto msg = amsg.data();
int w,h,aw;
int x,y;

View file

@ -10,6 +10,7 @@
*
*/
#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
@ -28,6 +29,8 @@
#include "compiler-make_unique.h"
using std::min;
static int sdl_video_flags = SDL_SWSURFACE | SDL_HWPALETTE | SDL_DOUBLEBUF;
SDL_Surface *screen,*canvas;
static int gr_installed;
@ -219,7 +222,7 @@ void gr_palette_step_up( int r, int g, int b )
palette_array_t &p = gr_palette;
int temp;
SDL_Palette *palette;
SDL_Color colors[256];
array<SDL_Color, 256> colors;
if ( (r==last_r) && (g==last_g) && (b==last_b) )
return;
@ -260,18 +263,14 @@ void gr_palette_step_up( int r, int g, int b )
colors[i].b = temp * 4;
}
SDL_SetColors(canvas, colors, 0, 256);
SDL_SetColors(canvas, colors.data(), 0, colors.size());
}
#undef min
static inline int min(int x, int y) { return x < y ? x : y; }
void gr_palette_load( palette_array_t &pal )
{
SDL_Palette *palette;
SDL_Color colors[256];
ubyte gamma[64];
array<SDL_Color, 256> colors;
array<uint8_t, 64> gamma;
if (pal != gr_current_pal)
SDL_FillRect(canvas, NULL, SDL_MapRGB(canvas->format, 0, 0, 0));
@ -300,7 +299,7 @@ void gr_palette_load( palette_array_t &pal )
i++;
}
SDL_SetColors(canvas, colors, 0, 256);
SDL_SetColors(canvas, colors.data(), 0, colors.size());
init_computed_colors();
gr_remap_color_fonts();
gr_remap_mono_fonts();

View file

@ -34,13 +34,13 @@ static unsigned char Installed = 0;
int keyd_repeat = 0; // 1 = use repeats, 0 no repeats
volatile unsigned char keyd_last_pressed;
volatile unsigned char keyd_last_released;
volatile unsigned char keyd_pressed[256];
array<uint8_t, 256> keyd_pressed;
fix64 keyd_time_when_last_pressed;
array<unsigned char, KEY_BUFFER_SIZE> unicode_frame_buffer;
struct keyboard
{
ubyte state[256];
array<uint8_t, 256> state;
};
static keyboard key_data;

View file

@ -529,8 +529,8 @@ int SetPlayerFromCursegAndRotate()
//far enough away to see all of curside
int SetPlayerFromCursegMinusOne()
{
vms_vector corner_v[4];
g3s_point corner_p[4];
array<vms_vector, 4> corner_v;
array<g3s_point, 4> corner_p;
int i;
fix max,view_dist=f1_0*10;
static int edgenum=0;

View file

@ -1226,8 +1226,7 @@ next_side: ;
int med_form_joint(const vsegptridx_t seg1, int side1, const vsegptridx_t seg2, int side2)
{
int bfi,v,s1;
int lost_vertices[4];
array<int, 4> remap_vertices;
array<int, 4> lost_vertices, remap_vertices;
int validation_list[MAX_VALIDATIONS];
uint_fast32_t nv;
@ -1609,7 +1608,7 @@ void warn_if_concave_segment(const vsegptridx_t s)
int med_find_adjacent_segment_side(const vcsegptridx_t sp, int side, segptridx_t &adj_sp, int *adj_side)
{
int s;
int abs_verts[4];
array<int, 4> abs_verts;
// Stuff abs_verts[4] array with absolute vertex indices
for (unsigned v=0; v < 4; v++)

View file

@ -273,7 +273,7 @@ static void validate_uv_coordinates(const vsegptr_t segp)
// ---------------------------------------------------------------------------------------------
// For all faces in side, copy uv coordinates from uvs array to face.
static void copy_uvs_from_side_to_faces(const vsegptr_t segp, int sidenum, uvl uvls[])
static void copy_uvs_from_side_to_faces(const vsegptr_t segp, int sidenum, array<uvl, 4> &uvls)
{
int v;
side *sidep = &segp->sides[sidenum];
@ -320,7 +320,8 @@ fix Stretch_scale_y = F1_0;
static void assign_uvs_to_side(const vsegptridx_t segp, int sidenum, uvl *uva, uvl *uvb, int va, int vb)
{
int vlo,vhi,v0,v1,v2,v3;
uvl uvls[4],ruvmag,fuvmag,uvlo,uvhi;
array<uvl, 4> uvls;
uvl ruvmag,fuvmag,uvlo,uvhi;
fix fmag,mag01;
Assert( (va<4) && (vb<4) );
Assert((abs(va - vb) == 1) || (abs(va - vb) == 3)); // make sure the verticies specify an edge

View file

@ -256,7 +256,7 @@ static const char mode_text[][16] = {
};
// Index into this array with aip->behavior
static const char behavior_text[6][9] = {
const array<char[9], 6> behavior_text{
"STILL ",
"NORMAL ",
"HIDE ",

View file

@ -153,7 +153,7 @@ static uint_fast32_t insert_center_points(point_seg *psegs, uint_fast32_t count)
static void move_towards_outside(point_seg *psegs, int *num_points, const vobjptridx_t objp, int rand_flag)
{
int i;
point_seg new_psegs[200];
array<point_seg, 200> new_psegs;
Assert(*num_points < 200);
@ -1475,7 +1475,7 @@ int Test_size = 1000;
static void test_create_path_many(void) __attribute_used;
static void test_create_path_many(void)
{
point_seg point_segs[200];
array<point_seg, 200> point_segs;
short num_points;
int i;
@ -1483,7 +1483,7 @@ static void test_create_path_many(void)
for (i=0; i<Test_size; i++) {
Cursegp = &Segments[(d_rand() * (Highest_segment_index + 1)) / D_RAND_MAX];
Markedsegp = &Segments[(d_rand() * (Highest_segment_index + 1)) / D_RAND_MAX];
create_path_points(object_first, Cursegp-Segments, Markedsegp-Segments, point_segs, &num_points, -1, 0, 0, segment_none);
create_path_points(object_first, Cursegp-Segments, Markedsegp-Segments, point_segs.begin(), &num_points, -1, 0, 0, segment_none);
}
}
@ -1491,10 +1491,10 @@ static void test_create_path_many(void)
static void test_create_path(void) __attribute_used;
static void test_create_path(void)
{
point_seg point_segs[200];
array<point_seg, 200> point_segs;
short num_points;
create_path_points(object_first, Cursegp-Segments, Markedsegp-Segments, point_segs, &num_points, -1, 0, 0, segment_none);
create_path_points(object_first, Cursegp-Segments, Markedsegp-Segments, point_segs.begin(), &num_points, -1, 0, 0, segment_none);
}

View file

@ -98,8 +98,8 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
struct Edge_info
{
array<int, 2> verts; // 8 bytes
ubyte sides[4]; // 4 bytes
segnum_t segnum[4]; // 16 bytes // This might not need to be stored... If you can access the normals of a side.
array<uint8_t, 4> sides; // 4 bytes
array<segnum_t, 4> segnum; // 16 bytes // This might not need to be stored... If you can access the normals of a side.
ubyte flags; // 1 bytes // See the EF_??? defines above.
color_t color; // 1 bytes
ubyte num_faces; // 1 bytes // 31 bytes...

View file

@ -596,7 +596,8 @@ void plyr_save_stats()
{
int kills = PlayerCfg.NetlifeKills,deaths = PlayerCfg.NetlifeKilled, neg, i;
char filename[PATH_MAX];
unsigned char buf[16],buf2[16],a;
array<uint8_t, 16> buf, buf2;
uint8_t a;
memset(filename, '\0', PATH_MAX);
snprintf(filename,sizeof(filename),PLAYER_EFFECTIVENESS_FILENAME_FORMAT,static_cast<const char *>(Players[Player_num].callsign));
auto f = PHYSFSX_openWriteBuffered(filename);
@ -634,7 +635,7 @@ void plyr_save_stats()
else
i+='A';
PHYSFSX_printf(f,"%c%s %c%s ",i,buf,i,buf2);
PHYSFSX_printf(f,"%c%s %c%s ",i,buf.data(),i,buf2.data());
if (deaths < 0)
{
@ -662,7 +663,7 @@ void plyr_save_stats()
else
i+='A';
PHYSFSX_printf(f,"%c%s %c%s\n",i,buf,i,buf2);
PHYSFSX_printf(f, "%c%s %c%s\n", i, buf.data(), i, buf2.data());
}
#endif

View file

@ -283,7 +283,8 @@ void robot_info_read(PHYSFS_File *fp, robot_info &ri)
ri.death_roll = PHYSFSX_readByte(fp);
ri.flags = PHYSFSX_readByte(fp);
PHYSFS_read(fp, ri.pad, 3, 1);
array<char, 3> pad;
PHYSFS_read(fp, pad, pad.size(), 1);
ri.deathroll_sound = PHYSFSX_readByte(fp);
ri.glow = PHYSFSX_readByte(fp);