config: Make work to build units independently configurable

The work required for build and repairs is traditionally a function of
build materials: 20 + lcm + 2*hcm for ships, planes and land units,
and (lcm + 2*hcm + oil + rad)/5 for nukes.  Make it independently
configurable instead, via new ship-chr, plane-chr, land-chr, nuke-chr
selector bwork, backed by new struct mchrstr member m_bwork, struct
plchrstr member pl_bwork, struct lchrstr member l_bwork, struct
nchrstr member n_bwork.  Keep the required work exactly the same for
now.

Clients that compute work from materials need to be updated.  Easy,
since build work is now exposed in xdump.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2016-05-27 13:39:11 +02:00
parent 14af586b57
commit 68c7c08a58
19 changed files with 319 additions and 351 deletions

View file

@ -30,7 +30,7 @@
* Thomas Ruschak, 1992
* Ken Stevens, 1995
* Steve McClure, 1998
* Markus Armbruster, 2004-2015
* Markus Armbruster, 2004-2016
*/
#ifndef LAND_H
@ -86,6 +86,7 @@ struct lchrstr {
int l_mil; /* how many mil it takes to build (unused) */
int l_gun; /* how many guns it takes to build (unused) */
int l_shell; /* #shells it takes to build (unused) */
int l_bwork; /* work to build 100% */
int l_tech; /* tech required to build */
int l_cost; /* how much it costs to build */
float l_att; /* attack multiplier */
@ -120,9 +121,6 @@ struct lchrstr {
#define L_TRAIN bit(11) /* train unit - neato */
#define L_HEAVY bit(12) /* heavy unit - can't go on trains */
/* Work required for building 100% */
#define LND_BLD_WORK(lcm, hcm) (20 + (lcm) + 2 * (hcm))
/* Chance to detect L_SPY unit (percent) */
#define LND_SPY_DETECT_CHANCE(eff) ((110-(eff))/100.0)

View file

@ -28,6 +28,7 @@
*
* Known contributors to this file:
* Dave Pare, 1986
* Markus Armbruster, 2004-2016
*/
#ifndef NUKE_H
@ -69,8 +70,9 @@ struct nchrstr {
int n_rad;
int n_blast; /* blast radius */
int n_dam; /* damage at center */
int n_cost;
int n_bwork; /* work to build 100% */
int n_tech; /* tech needed to build */
int n_cost; /* how much it costs to build */
int n_weight;
int n_flags; /* description of capability */
signed char n_type; /* index in nchr[] */
@ -82,10 +84,6 @@ struct nchrstr {
#define putnuke(n, p) ef_write(EF_NUKE, (n), (p))
#define getnukep(n) ((struct nukstr *)ef_ptr(EF_NUKE, (n)))
/* Work required for building */
#define NUK_BLD_WORK(lcm, hcm, oil, rad) \
(((lcm) + 2 * (hcm) + (oil) + (rad) + 4) / 5)
extern struct nchrstr nchr[N_MAXNUKE + 1];
/* src/lib/common/cargo.c */

View file

@ -30,7 +30,7 @@
* Dave Pare, 1986
* Ken Stevens, 1995
* Steve McClure, 1998
* Markus Armbruster, 2004-2013
* Markus Armbruster, 2004-2016
*/
#ifndef PLANE_H
@ -81,8 +81,9 @@ struct plchrstr {
char *pl_name; /* full name of type of plane */
int pl_lcm; /* costs to build */
int pl_hcm;
int pl_cost;
int pl_bwork; /* work to build 100% */
int pl_tech; /* tech needed to build */
int pl_cost; /* how much it costs to build */
int pl_acc; /* bombing accuracy (higher the better) */
int pl_load; /* bomb load, also for carrying cargo */
int pl_att; /* air-air attack/defense strengths */
@ -141,9 +142,6 @@ struct shiplist {
struct shiplist *next;
};
/* Work required for building 100% */
#define PLN_BLD_WORK(lcm, hcm) (20 + (lcm) + 2 * (hcm))
extern int pl_att(struct plchrstr *, int);
extern int pl_def(struct plchrstr *, int);
extern int pl_acc(struct plchrstr *, int);

View file

@ -31,7 +31,7 @@
* Thomas Ruschak, 1992
* Ken Stevens, 1995
* Steve McClure, 1998
* Markus Armbruster, 2004-2015
* Markus Armbruster, 2004-2016
*/
#ifndef SHIP_H
@ -93,6 +93,7 @@ struct mchrstr {
unsigned char m_nxlight; /* maximum number of xlight planes */
unsigned char m_nchoppers; /* maximum number of choppers */
char *m_name; /* full name of type of ship */
int m_bwork; /* work to build 100% */
int m_tech; /* tech required to build */
int m_cost; /* how much it costs to build */
int m_flags; /* what special things can this ship do */
@ -131,9 +132,6 @@ struct mchrstr {
extern struct mchrstr mchr[SHP_TYPE_MAX + 2];
/* Work required for building 100% */
#define SHP_BLD_WORK(lcm, hcm) (20 + (lcm) + 2 * (hcm))
enum {
SHP_AIROPS_EFF = 50, /* min. efficiency for air ops */
SHP_TORP_SHELLS = 3 /* number of shells used by a torpedo */