and upgrade code.
(build_ship, build_plane, build_land, supgr, pupgr, lupgr): Use them.
Upgrading planes no longer sets plane range to maximum.
(pupgr): Just clear the mission, don't bother to clear op area.
(doship, doplane, dounit): Editing tech now updates stats, like an
upgrade command. Proper range checking.
(warn_deprecated): New.
(pr_ship, doship): Deprecate key 'D'.
(pr_land, dounit): Deprecate key 'A' and 'D'.
extern int lnd_support(natid, natid, coord, coord);
extern int lnd_can_attack(struct lndstr *);
extern int lnd_fortify (struct lndstr *lp, int hard_amt);
+extern void lnd_set_tech(struct lndstr *, int);
#endif /* _LAND_H_ */
extern int pln_hitchance(struct plnstr *, int, int);
extern int pln_damage(struct plnstr *, coord, coord, s_char, int *, int);
extern int pln_identchance(struct plnstr *, int, int);
+extern void pln_set_tech(struct plnstr *, int);
/* pr.c */
extern void pr(s_char *, ...) ATTRIBUTE((format (printf, 1, 2)));
extern void prnf(s_char *buf);
extern int shp_nav_one_sector(struct emp_qelem *, int, natid, int);
extern int shp_missile_defense(coord, coord, natid, int);
extern void shp_missdef(struct shpstr *, natid);
+extern void shp_set_tech(struct shpstr *, int);
/* snxtitem.c */
extern int snxtitem(register struct nstr_item *, int, s_char *);
/* snxtsct.c */
* Steve McClure, 1998-2000
*/
-#include <math.h>
#include <string.h>
#include "misc.h"
#include "player.h"
float eff = SHIP_MINEFF / 100.0;
int lcm, hcm;
int freeship = 0;
- int techdiff;
hcm = roundavg((double)mp->m_hcm * eff);
lcm = roundavg((double)mp->m_lcm * eff);
memset(ship.shp_item, 0, sizeof(ship.shp_item));
ship.shp_pstage = PLG_HEALTHY;
ship.shp_ptime = 0;
- ship.shp_tech = tlev;
-
- techdiff = (int)(tlev - mp->m_tech);
- ship.shp_armor = (short)SHP_DEF(mp->m_armor, techdiff);
- ship.shp_speed = (short)SHP_SPD(mp->m_speed, techdiff);
- ship.shp_visib = (short)SHP_VIS(mp->m_visib, techdiff);
- ship.shp_frnge = (short)SHP_RNG(mp->m_frnge, techdiff);
- ship.shp_glim = (short)SHP_FIR(mp->m_glim, techdiff);
-
ship.shp_mobquota = 0;
*ship.shp_path = 0;
ship.shp_follow = nstr.cur;
ship.shp_fuel = mchr[(int)ship.shp_type].m_fuelc;
ship.shp_rflags = 0;
memset(ship.shp_rpath, 0, sizeof(ship.shp_rpath));
+ shp_set_tech(&ship, tlev);
vec[I_LCM] -= lcm;
vec[I_HCM] -= hcm;
} else {
land.lnd_mobil = 0;
}
- land.lnd_tech = tlev;
land.lnd_uid = nstr.cur;
land.lnd_army = ' ';
land.lnd_flags = 0;
memset(land.lnd_item, 0, sizeof(land.lnd_item));
land.lnd_pstage = PLG_HEALTHY;
land.lnd_ptime = 0;
- land.lnd_att = (float)LND_ATTDEF(lp->l_att, tlev - lp->l_tech);
- land.lnd_def = (float)LND_ATTDEF(lp->l_def, tlev - lp->l_tech);
- land.lnd_vul = (int)LND_VUL(lp->l_vul, tlev - lp->l_tech);
- land.lnd_spd = (int)LND_SPD(lp->l_spd, tlev - lp->l_tech);
- land.lnd_vis = (int)LND_VIS(lp->l_vis, tlev - lp->l_tech);
- land.lnd_spy = (int)LND_SPY(lp->l_spy, tlev - lp->l_tech);
- land.lnd_rad = (int)LND_RAD(lp->l_rad, tlev - lp->l_tech);
- land.lnd_frg = (int)LND_FRG(lp->l_frg, tlev - lp->l_tech);
- land.lnd_acc = (int)LND_ACC(lp->l_acc, tlev - lp->l_tech);
- land.lnd_dam = (int)LND_DAM(lp->l_dam, tlev - lp->l_tech);
- land.lnd_ammo = (int)LND_AMM(lp->l_ammo, lp->l_dam, tlev - lp->l_tech);
- land.lnd_aaf = (int)LND_AAF(lp->l_aaf, tlev - lp->l_tech);
- land.lnd_fuelc = (int)LND_FC(lp->l_fuelc, tlev - lp->l_tech);
- land.lnd_fuelu = (int)LND_FU(lp->l_fuelu, tlev - lp->l_tech);
- land.lnd_maxlight = (int)LND_XPL(lp->l_nxlight, tlev - lp->l_tech);
- land.lnd_maxland = (int)LND_MXL(lp->l_mxland, tlev - lp->l_tech);
+ lnd_set_tech(&land, tlev);
vec[I_LCM] -= lcm;
vec[I_HCM] -= hcm;
plane.pln_opx = 0;
plane.pln_opy = 0;
plane.pln_radius = 0;
-
- /* Note that this next block of variables can be changed so that individual
- * planes may have their own stats (like based on tech maybe? :) ) Thus,
- * the code now checks the pln_acc, pln_load and pln_fuel instead of using
- * the static definitions of them. */
- plane.pln_att = PLN_ATTDEF(pp->pl_att, (int)(tlev - pp->pl_tech));
- plane.pln_def = PLN_ATTDEF(pp->pl_def, (int)(tlev - pp->pl_tech));
- plane.pln_acc = PLN_ACC(pp->pl_acc, (int)(tlev - pp->pl_tech));
- plane.pln_range = PLN_RAN(pp->pl_range, (int)(tlev - pp->pl_tech));
+ plane.pln_range = UCHAR_MAX; /* will be adjusted by pln_set_tech() */
plane.pln_range_max = plane.pln_range;
- plane.pln_load = PLN_LOAD(pp->pl_load, (int)(tlev - pp->pl_tech));
plane.pln_fuel = pp->pl_fuel;
-
plane.pln_wing = ' ';
- plane.pln_tech = tlev;
plane.pln_ship = -1;
plane.pln_land = -1;
plane.pln_uid = nstr.cur;
plane.pln_nuketype = -1;
plane.pln_harden = 0;
plane.pln_flags = 0;
+ pln_set_tech(&plane, tlev);
+
+ vec[I_LCM] -= lcm;
+ vec[I_HCM] -= hcm;
+ vec[I_MILIT] -= mil;
+
makenotlost(EF_PLANE, plane.pln_own, plane.pln_uid, plane.pln_x,
plane.pln_y);
putplane(plane.pln_uid, &plane);
pr("%s built in sector %s\n", prplane(&plane),
xyas(sp->sct_x, sp->sct_y, player->cnum));
- vec[I_LCM] -= lcm;
- vec[I_HCM] -= hcm;
- vec[I_MILIT] -= mil;
return 1;
}
pr("Mobility <M>: %d\n", (int)land->lnd_mobil);
pr("Tech <t>: %d\t\t", land->lnd_tech);
pr("Army <a>: %c\n", land->lnd_army);
- pr("Attack <A>: %1.2f\t", land->lnd_att);
- pr("Defense <D>: %1.2f\n", land->lnd_def);
pr("Fortification <F>: %d\t", land->lnd_harden);
pr("Fuel <B>: %d\n", land->lnd_fuel);
count_land_planes(land);
/* could depend on opt_FUEL - but a deity might want to set this
up before enabling the option */
pr("Fuel <B>: %d\t\t\t", (int)ship->shp_fuel);
- pr("Defense <D>: %d\n", (int)ship->shp_armor);
pr("Retreat path <R>: '%s'\t\tRetreat Flags <W>: %d\n",
ship->shp_rpath, (int)ship->shp_rflags);
pr("Plague Stage <a>: %d\t\t",ship->shp_pstage);
return RET_OK;
}
+static void
+warn_deprecated(char key)
+{
+ pr("Key <%c> is deprecated and will go away in a future release\n", key);
+}
static int
doland(s_char op, int arg, s_char *p, struct sctstr *sect)
ship->shp_y = newy;
break;
case 'T':
- ship->shp_tech = arg;
+ shp_set_tech(ship,
+ errcheck(arg, mchr[ship->shp_type].m_tech, SHRT_MAX));
break;
case 'E':
ship->shp_effic = errcheck(arg, SHIP_MINEFF, 100);
ship->shp_item[I_RAD] = arg;
break;
case 'D':
- ship->shp_armor = errcheck(arg, 0, 127);
+ warn_deprecated(op);
+ ship->shp_armor = errcheck(arg, 0, SHRT_MAX);
break;
default:
pr("huh? (%c)\n", op);
land->lnd_mobil = arg;
break;
case 't':
- land->lnd_tech = arg;
+ lnd_set_tech(land,
+ errcheck(arg, lchr[land->lnd_type].l_tech, SHRT_MAX));
break;
case 'a':
if (p[0] == '~')
land->lnd_item[I_RAD] = arg;
break;
case 'A':
+ warn_deprecated(op);
pr("Attack changed from %1.2f to %1.2f.\n",
land->lnd_att, farg);
land->lnd_att = farg;
break;
case 'D':
+ warn_deprecated(op);
pr("Defense changed from %1.2f to %1.2f.\n",
land->lnd_def, farg);
land->lnd_def = farg;
plane->pln_mobil = errcheck(arg, -127, 255);
break;
case 't':
- plane->pln_tech = arg;
+ pln_set_tech(plane,
+ errcheck(arg, plchr[plane->pln_type].pl_tech, SHRT_MAX));
break;
case 'w':
if (p[0] == '~')
* Steve McClure, 1996-2000
*/
-#include <math.h>
-
#include "misc.h"
#include "player.h"
#include "xy.h"
int tlev;
int avail, cost;
int rel;
- int techdiff;
long cash;
if (!snxtitem(&ni, EF_LAND, player->argp[2]))
sect.sct_avail -= avail;
land.lnd_effic -= UPGR_EFF;
-
- land.lnd_tech = tlev;
- techdiff = (int)(tlev - lp->l_tech);
-
+ lnd_set_tech(&land, tlev);
land.lnd_harden = 0;
land.lnd_mission = 0;
-
- land.lnd_att = (float)LND_ATTDEF(lp->l_att, techdiff);
- land.lnd_def = (float)LND_ATTDEF(lp->l_def, techdiff);
- land.lnd_vul = (int)LND_VUL(lp->l_vul, techdiff);
- land.lnd_spd = (int)LND_SPD(lp->l_spd, techdiff);
- land.lnd_vis = (int)LND_VIS(lp->l_vis, techdiff);
- land.lnd_spy = (int)LND_SPY(lp->l_spy, techdiff);
- land.lnd_rad = (int)LND_RAD(lp->l_rad, techdiff);
- land.lnd_frg = (int)LND_FRG(lp->l_frg, techdiff);
- land.lnd_acc = (int)LND_ACC(lp->l_acc, techdiff);
- land.lnd_dam = (int)LND_DAM(lp->l_dam, techdiff);
- land.lnd_ammo = (int)LND_AMM(lp->l_ammo, lp->l_dam, techdiff);
- land.lnd_aaf = (int)LND_AAF(lp->l_aaf, techdiff);
- land.lnd_fuelc = (int)LND_FC(lp->l_fuelc, techdiff);
- land.lnd_fuelu = (int)LND_FU(lp->l_fuelu, techdiff);
- land.lnd_maxlight = (int)LND_XPL(lp->l_nxlight, techdiff);
- land.lnd_maxland = (int)LND_MXL(lp->l_mxland, techdiff);
-
time(&land.lnd_access);
putland(land.lnd_uid, &land);
int tlev;
int avail, cost;
int rel;
- int techdiff;
long cash;
if (!snxtitem(&ni, EF_SHIP, player->argp[2]))
sect.sct_avail -= avail;
ship.shp_effic -= UPGR_EFF;
- ship.shp_tech = tlev;
-
- techdiff = (int)(tlev - mp->m_tech);
- ship.shp_armor = (short)SHP_DEF(mp->m_armor, techdiff);
- ship.shp_speed = (short)SHP_SPD(mp->m_speed, techdiff);
- ship.shp_visib = (short)SHP_VIS(mp->m_visib, techdiff);
- ship.shp_frnge = (short)SHP_RNG(mp->m_frnge, techdiff);
- ship.shp_glim = (short)SHP_FIR(mp->m_glim, techdiff);
-
+ shp_set_tech(&ship, tlev);
ship.shp_mission = 0;
time(&ship.shp_access);
int tlev;
int avail, cost;
int rel;
- int techdiff;
long cash;
if (!snxtitem(&ni, EF_PLANE, player->argp[2]))
sect.sct_avail -= avail;
plane.pln_effic -= UPGR_EFF;
-
- plane.pln_tech = tlev;
- techdiff = (int)(tlev - pp->pl_tech);
-
- plane.pln_mission = 0;
- plane.pln_opx = 0;
- plane.pln_opy = 0;
- plane.pln_radius = 0;
+ pln_set_tech(&plane, tlev);
plane.pln_harden = 0;
plane.pln_mission = 0;
-
- plane.pln_att = PLN_ATTDEF(pp->pl_att, techdiff);
- plane.pln_def = PLN_ATTDEF(pp->pl_def, techdiff);
- plane.pln_acc = PLN_ACC(pp->pl_acc, techdiff);
- plane.pln_range = PLN_RAN(pp->pl_range, techdiff);
- plane.pln_range_max = plane.pln_range;
- plane.pln_load = PLN_LOAD(pp->pl_load, techdiff);
-
time(&plane.pln_access);
putplane(plane.pln_uid, &plane);
return hard_amt;
}
+
+/*
+ * Set LP's tech to TLEV along with everything else that depends on it.
+ */
+void
+lnd_set_tech(struct lndstr *lp, int tlev)
+{
+ struct lchrstr *lcp = lchr + lp->lnd_type;
+ int tech_diff = tlev - lcp->l_tech;
+
+ if (CANT_HAPPEN(tech_diff < 0)) {
+ tlev -= tech_diff;
+ tech_diff = 0;
+ }
+
+ lp->lnd_tech = tlev;
+ lp->lnd_att = (float)LND_ATTDEF(lcp->l_att, tech_diff);
+ lp->lnd_def = (float)LND_ATTDEF(lcp->l_def, tech_diff);
+ lp->lnd_vul = (int)LND_VUL(lcp->l_vul, tech_diff);
+ lp->lnd_spd = (int)LND_SPD(lcp->l_spd, tech_diff);
+ lp->lnd_vis = (int)LND_VIS(lcp->l_vis, tech_diff);
+ lp->lnd_spy = (int)LND_SPY(lcp->l_spy, tech_diff);
+ lp->lnd_rad = (int)LND_RAD(lcp->l_rad, tech_diff);
+ lp->lnd_frg = (int)LND_FRG(lcp->l_frg, tech_diff);
+ lp->lnd_acc = (int)LND_ACC(lcp->l_acc, tech_diff);
+ lp->lnd_dam = (int)LND_DAM(lcp->l_dam, tech_diff);
+ lp->lnd_ammo = (int)LND_AMM(lcp->l_ammo, lcp->l_dam, tech_diff);
+ lp->lnd_aaf = (int)LND_AAF(lcp->l_aaf, tech_diff);
+ lp->lnd_fuelc = (int)LND_FC(lcp->l_fuelc, tech_diff);
+ lp->lnd_fuelu = (int)LND_FU(lcp->l_fuelu, tech_diff);
+ lp->lnd_maxlight = (int)LND_XPL(lcp->l_nxlight, tech_diff);
+ lp->lnd_maxland = (int)LND_MXL(lcp->l_mxland, tech_diff);
+}
* Steve McClure, 1998-2000
*/
+#include <math.h>
#include "misc.h"
#include "player.h"
#include "var.h"
return min(32 + pp->pln_mobil, cost + 5);
}
+
+/*
+ * Set PP's tech to TLEV along with everything else that depends on it.
+ */
+void
+pln_set_tech(struct plnstr *pp, int tlev)
+{
+ struct plchrstr *pcp = plchr + pp->pln_type;
+ int tech_diff = tlev - pcp->pl_tech;
+ int limited_range = pp->pln_range < pp->pln_range_max;
+
+ if (CANT_HAPPEN(tech_diff < 0)) {
+ tlev -= tech_diff;
+ tech_diff = 0;
+ }
+
+ pp->pln_tech = tlev;
+ pp->pln_att = PLN_ATTDEF(pcp->pl_att, tech_diff);
+ pp->pln_def = PLN_ATTDEF(pcp->pl_def, tech_diff);
+ pp->pln_acc = PLN_ACC(pcp->pl_acc, tech_diff);
+ pp->pln_range_max = PLN_RAN(pcp->pl_range, tech_diff);
+ pp->pln_load = PLN_LOAD(pcp->pl_load, tech_diff);
+
+ if (!limited_range || pp->pln_range > pp->pln_range_max)
+ pp->pln_range = pp->pln_range_max;
+}
* Steve McClure, 1996-2000
*/
+#include <math.h>
#include "misc.h"
#include "queue.h"
#include "player.h"
if (!QEMPTY(&list))
free(mlp);
}
+
+/*
+ * Set SP's tech to TLEV along with everything else that depends on it.
+ */
+void
+shp_set_tech(struct shpstr *sp, int tlev)
+{
+ struct mchrstr *mcp = mchr + sp->shp_type;
+ int tech_diff = tlev - mcp->m_tech;
+
+ if (CANT_HAPPEN(tech_diff < 0)) {
+ tlev -= tech_diff;
+ tech_diff = 0;
+ }
+
+ sp->shp_tech = tlev;
+ sp->shp_armor = (short)SHP_DEF(mcp->m_armor, tech_diff);
+ sp->shp_speed = (short)SHP_SPD(mcp->m_speed, tech_diff);
+ sp->shp_visib = (short)SHP_VIS(mcp->m_visib, tech_diff);
+ sp->shp_frnge = (short)SHP_RNG(mcp->m_frnge, tech_diff);
+ sp->shp_glim = (short)SHP_FIR(mcp->m_glim, tech_diff);
+}