(shp_set_tech, pln_set_tech, lnd_set_tech): New, factored out of build

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'.
This commit is contained in:
Markus Armbruster 2004-05-16 14:19:38 +00:00
parent 65ff91877f
commit c2debd73fc
8 changed files with 113 additions and 102 deletions

View file

@ -33,6 +33,7 @@
* Steve McClure, 1998-2000
*/
#include <math.h>
#include "misc.h"
#include "player.h"
#include "var.h"
@ -1165,3 +1166,29 @@ pln_mobcost(int dist, struct plnstr *pp, int flags)
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;
}