Get rid of ship and land unit load counters
Load counters are redundant; they can be computed from the carrier uids. Keeping them up-to-date as the carriers change is a pain, and we never got that quite complete. Computing load counters straight from the carrier uids every time we need them would be rather inefficient, but computing them from cargo lists is not. So do that. Remove the load counters: struct shpstr members shp_nplane, shp_nchoppers, shp_nxlight, shp_nland, and struct lndstr members lnd_nxlight and lnd_nland. Don't compute/update load counters in build_ship(), build_land(), land(), ldump(), load_plane_ship(), load_land_ship(), load_plane_land(), load_land_land(), lstat(), sdump(), shi(), sstat(), tend_land(), check_trade(), put_combat(), pln_oneway_to_carrier_ok), pln_newlanding(), fit_plane_on_ship(), fit_plane_on_land(), unit_list(). Nothing left in fit_plane_off_ship(), fit_plane_off_land(), so remove them. load_land_ship(), load_land_land(), check_trade(), pln_newlanding(), put_plane_on_ship(), take_plane_off_ship(), put_plane_on_land(), take_plane_off_land() no longer change the carrier, so don't put it. Remove functions to recompute the load counters from carrier uids: count_units(), lnd_count_units(), count_planes(), count_land_planes(), pln_fixup() and lnd_fixup(), along with the latter two's private copies of fit_plane_on_ship() and fit_plane_on_land(). New cargo list functions to compute load counts: unit_cargo_count() and unit_nplane(), with convenience wrappers shp_nplane(), shp_nland(), lnd_nxlight(), lnd_nland(). Use them to make ship selectors nplane, nchoppers, nxlight, nland virtual. They now reflect what is loaded, not how the load uses the available slots. This makes a difference when x-light planes or choppers use plane slots. Use them to make land unit selectors nxlight and nland virtual. Use them to get load counts in land(), ldump(), load_plane_ship(), load_land_ship(), load_plane_land(), load_land_land(), sdump(), shi(), tend_land(), fit_plane_on_land(), trade_desc(), unit_list(). Rewrite fit_plane_on_ship() and could_be_on_ship() to use shp_nplane(). could_be_on_ship() now takes load count arguments, as computed by shp_nplane(), so it can be used for checking against an existing load as well.
This commit is contained in:
parent
8b1470e3a8
commit
3e370da58c
22 changed files with 215 additions and 449 deletions
|
@ -70,7 +70,6 @@ struct lndstr {
|
|||
short lnd_ship; /* pointer to transporting ship */
|
||||
signed char lnd_harden; /* fortification */
|
||||
short lnd_retreat; /* retreat percentage */
|
||||
unsigned char lnd_nxlight; /* How many xlight planes on board? */
|
||||
int lnd_rflags; /* When do I retreat? */
|
||||
char lnd_rpath[RET_LEN]; /* retreat path */
|
||||
unsigned char lnd_rad_max; /* max radius for this unit */
|
||||
|
@ -79,7 +78,6 @@ struct lndstr {
|
|||
short lnd_pstage; /* plague stage */
|
||||
short lnd_ptime; /* how many etus remain in this stage */
|
||||
short lnd_land; /* pointer to transporting unit */
|
||||
unsigned char lnd_nland;
|
||||
short lnd_access; /* Last tick mob was updated (MOB_ACCESS) */
|
||||
};
|
||||
|
||||
|
@ -164,6 +162,8 @@ extern void lnd_carrier_change(struct lndstr *, int, int, int);
|
|||
extern int lnd_first_on_ship(struct shpstr *);
|
||||
extern int lnd_first_on_land(struct lndstr *);
|
||||
extern int lnd_next_on_unit(int);
|
||||
extern int lnd_nxlight(struct lndstr *);
|
||||
extern int lnd_nland(struct lndstr *);
|
||||
|
||||
extern int lnd_fire(struct lndstr *);
|
||||
extern double lnd_fire_range(struct lndstr *);
|
||||
|
@ -186,8 +186,6 @@ extern void lnd_submil(struct lndstr *, int);
|
|||
extern void lnd_takemob(struct emp_qelem *, double);
|
||||
extern int lnd_spyval(struct lndstr *);
|
||||
extern void intelligence_report(int, struct lndstr *, int, char *);
|
||||
extern void count_units(struct shpstr *);
|
||||
extern void lnd_count_units(struct lndstr *);
|
||||
extern void lnd_mar(struct emp_qelem *, double *, double *, int *, natid);
|
||||
extern int lnd_hardtarget(struct lndstr *);
|
||||
extern int lnd_mar_one_sector(struct emp_qelem *, int, natid, int);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue