Use array<> for Powerup_info
This commit is contained in:
parent
488e46b562
commit
7c62bf98ef
|
@ -125,8 +125,8 @@ struct powerup_type_info
|
||||||
fix light; // amount of light cast by this powerup, set in bitmaps.tbl
|
fix light; // amount of light cast by this powerup, set in bitmaps.tbl
|
||||||
} __pack__;
|
} __pack__;
|
||||||
|
|
||||||
extern int N_powerup_types;
|
extern unsigned N_powerup_types;
|
||||||
extern powerup_type_info Powerup_info[MAX_POWERUP_TYPES];
|
extern array<powerup_type_info, MAX_POWERUP_TYPES> Powerup_info;
|
||||||
#else
|
#else
|
||||||
struct powerup_type_info;
|
struct powerup_type_info;
|
||||||
#endif
|
#endif
|
||||||
|
@ -148,10 +148,7 @@ void powerup_basic_str(int redadd, int greenadd, int blueadd, int score, const c
|
||||||
extern void powerup_basic(int redadd, int greenadd, int blueadd, int score, const char *format, ...) __attribute_format_printf(5, 6);
|
extern void powerup_basic(int redadd, int greenadd, int blueadd, int score, const char *format, ...) __attribute_format_printf(5, 6);
|
||||||
#define powerup_basic(A1,A2,A3,A4,F,...) dxx_call_printf_checked(powerup_basic,powerup_basic_str,(A1,A2,A3,A4),(F),##__VA_ARGS__)
|
#define powerup_basic(A1,A2,A3,A4,F,...) dxx_call_printf_checked(powerup_basic,powerup_basic_str,(A1,A2,A3,A4),(F),##__VA_ARGS__)
|
||||||
|
|
||||||
/*
|
void powerup_type_info_read(PHYSFS_file *fp, powerup_type_info &pti);
|
||||||
* reads n powerup_type_info structs from a PHYSFS_file
|
|
||||||
*/
|
|
||||||
extern int powerup_type_info_read_n(powerup_type_info *pti, int n, PHYSFS_file *fp);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1754,7 +1754,8 @@ void bm_write_all(PHYSFS_file *fp)
|
||||||
PHYSFS_write( fp, Weapon_info, sizeof(weapon_info), MAX_WEAPON_TYPES);
|
PHYSFS_write( fp, Weapon_info, sizeof(weapon_info), MAX_WEAPON_TYPES);
|
||||||
|
|
||||||
PHYSFS_write( fp, &N_powerup_types, sizeof(int), 1);
|
PHYSFS_write( fp, &N_powerup_types, sizeof(int), 1);
|
||||||
PHYSFS_write( fp, Powerup_info, sizeof(powerup_type_info), MAX_POWERUP_TYPES);
|
range_for (const auto &p, Powerup_info)
|
||||||
|
PHYSFS_write( fp, &p, sizeof(p), 1);
|
||||||
|
|
||||||
PHYSFS_write( fp, &N_polygon_models, sizeof(int), 1);
|
PHYSFS_write( fp, &N_polygon_models, sizeof(int), 1);
|
||||||
PHYSFS_write( fp, Polygon_models, sizeof(polymodel), N_polygon_models);
|
PHYSFS_write( fp, Polygon_models, sizeof(polymodel), N_polygon_models);
|
||||||
|
|
|
@ -2139,7 +2139,8 @@ void bm_write_all(PHYSFS_file *fp)
|
||||||
PHYSFSX_printf(tfile, "N_weapon_types = %d, Weapon_info array = %d\n", N_weapon_types, (int) sizeof(weapon_info)*N_weapon_types);
|
PHYSFSX_printf(tfile, "N_weapon_types = %d, Weapon_info array = %d\n", N_weapon_types, (int) sizeof(weapon_info)*N_weapon_types);
|
||||||
|
|
||||||
PHYSFS_write( fp, &N_powerup_types, sizeof(int), 1 );
|
PHYSFS_write( fp, &N_powerup_types, sizeof(int), 1 );
|
||||||
PHYSFS_write( fp, Powerup_info, sizeof(powerup_type_info), N_powerup_types );
|
range_for (const auto &p, partial_range(Powerup_info, N_powerup_types))
|
||||||
|
PHYSFS_write( fp, &p, sizeof(p), 1 );
|
||||||
PHYSFSX_printf(tfile, "N_powerup_types = %d, Powerup_info array = %d\n", N_powerup_types, (int) sizeof(powerup_info)*N_powerup_types);
|
PHYSFSX_printf(tfile, "N_powerup_types = %d, Powerup_info array = %d\n", N_powerup_types, (int) sizeof(powerup_info)*N_powerup_types);
|
||||||
|
|
||||||
t = N_D2_POLYGON_MODELS;
|
t = N_D2_POLYGON_MODELS;
|
||||||
|
|
|
@ -188,7 +188,8 @@ void properties_read_cmp(PHYSFS_file * fp)
|
||||||
weapon_info_read_n(Weapon_info, MAX_WEAPON_TYPES, fp, 0);
|
weapon_info_read_n(Weapon_info, MAX_WEAPON_TYPES, fp, 0);
|
||||||
|
|
||||||
N_powerup_types = PHYSFSX_readInt(fp);
|
N_powerup_types = PHYSFSX_readInt(fp);
|
||||||
powerup_type_info_read_n(Powerup_info, MAX_POWERUP_TYPES, fp);
|
range_for (auto &p, Powerup_info)
|
||||||
|
powerup_type_info_read(fp, p);
|
||||||
|
|
||||||
N_polygon_models = PHYSFSX_readInt(fp);
|
N_polygon_models = PHYSFSX_readInt(fp);
|
||||||
polymodel_read_n(Polygon_models, N_polygon_models, fp);
|
polymodel_read_n(Polygon_models, N_polygon_models, fp);
|
||||||
|
@ -328,7 +329,8 @@ void bm_read_all(PHYSFS_file * fp)
|
||||||
weapon_info_read_n(Weapon_info, N_weapon_types, fp, Piggy_hamfile_version);
|
weapon_info_read_n(Weapon_info, N_weapon_types, fp, Piggy_hamfile_version);
|
||||||
|
|
||||||
N_powerup_types = PHYSFSX_readInt(fp);
|
N_powerup_types = PHYSFSX_readInt(fp);
|
||||||
powerup_type_info_read_n(Powerup_info, N_powerup_types, fp);
|
range_for (auto &p, partial_range(Powerup_info, N_powerup_types))
|
||||||
|
powerup_type_info_read(fp, p);
|
||||||
|
|
||||||
N_polygon_models = PHYSFSX_readInt(fp);
|
N_polygon_models = PHYSFSX_readInt(fp);
|
||||||
polymodel_read_n(Polygon_models, N_polygon_models, fp);
|
polymodel_read_n(Polygon_models, N_polygon_models, fp);
|
||||||
|
|
|
@ -59,8 +59,8 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
||||||
#endif
|
#endif
|
||||||
#include "playsave.h"
|
#include "playsave.h"
|
||||||
|
|
||||||
int N_powerup_types = 0;
|
unsigned N_powerup_types;
|
||||||
powerup_type_info Powerup_info[MAX_POWERUP_TYPES];
|
array<powerup_type_info, MAX_POWERUP_TYPES> Powerup_info;
|
||||||
|
|
||||||
//process this powerup for this frame
|
//process this powerup for this frame
|
||||||
void do_powerup_frame(objptridx_t obj)
|
void do_powerup_frame(objptridx_t obj)
|
||||||
|
@ -726,18 +726,10 @@ int do_powerup(objptridx_t obj)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
void powerup_type_info_read(PHYSFS_file *fp, powerup_type_info &pti)
|
||||||
* reads n powerup_type_info structs from a PHYSFS_file
|
|
||||||
*/
|
|
||||||
int powerup_type_info_read_n(powerup_type_info *pti, int n, PHYSFS_file *fp)
|
|
||||||
{
|
{
|
||||||
int i;
|
pti.vclip_num = PHYSFSX_readInt(fp);
|
||||||
|
pti.hit_sound = PHYSFSX_readInt(fp);
|
||||||
for (i = 0; i < n; i++) {
|
pti.size = PHYSFSX_readFix(fp);
|
||||||
pti[i].vclip_num = PHYSFSX_readInt(fp);
|
pti.light = PHYSFSX_readFix(fp);
|
||||||
pti[i].hit_sound = PHYSFSX_readInt(fp);
|
|
||||||
pti[i].size = PHYSFSX_readFix(fp);
|
|
||||||
pti[i].light = PHYSFSX_readFix(fp);
|
|
||||||
}
|
|
||||||
return i;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue