2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2021, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure, Markus Armbruster
6 * Empire is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 * See files README, COPYING and CREDITS in the root of the source
22 * tree for related information and legal notices. It is expected
23 * that future projects/authors will amend these files as needed.
27 * plane.c: Plane characteristics
29 * Known contributors to this file:
32 * Thomas Ruschak, 1992
44 * Table of plane types
45 * Initialized on startup from plane.config and deity custom config (if any).
46 * Terminated by a sentinel with null pl_name.
48 struct plchrstr plchr[PLCHR_SZ];
50 #define logx(a, b) (log((a)) / log((b)))
51 #define PLN_ATTDEF(b, t) (b + ((b?1:0) * ((t/20)>10?10:(t/20))))
52 #define PLN_ACC(b, t) (b * (1.0 - (sqrt(t) / 50.)))
53 #define PLN_RAN(b, t) (t ? (b + (logx(t, 2.0))) : b)
54 #define PLN_LOAD(b, t) (t ? (b * (logx(t, 50.0) < 1.0 ? 1.0 : \
58 pl_att(struct plchrstr *pcp, int tech)
60 return PLN_ATTDEF(pcp->pl_att, MAX(0, tech - pcp->pl_tech));
64 pl_def(struct plchrstr *pcp, int tech)
66 return PLN_ATTDEF(pcp->pl_def, MAX(0, tech - pcp->pl_tech));
70 pl_acc(struct plchrstr *pcp, int tech)
72 return PLN_ACC(pcp->pl_acc, MAX(0, tech - pcp->pl_tech));
76 pl_range(struct plchrstr *pcp, int tech)
78 return PLN_RAN(pcp->pl_range, MAX(0, tech - pcp->pl_tech));
82 pl_load(struct plchrstr *pcp, int tech)
84 return PLN_LOAD(pcp->pl_load, MAX(0, tech - pcp->pl_tech));
88 pln_att(struct plnstr *pp)
90 return pl_att(plchr + pp->pln_type, pp->pln_tech);
94 pln_def(struct plnstr *pp)
96 return pl_def(plchr + pp->pln_type, pp->pln_tech);
100 pln_acc(struct plnstr *pp)
102 return pl_acc(plchr + pp->pln_type, pp->pln_tech);
106 pln_range_max(struct plnstr *pp)
108 return pl_range(plchr + pp->pln_type, pp->pln_tech);
112 pln_load(struct plnstr *pp)
114 return pl_load(plchr + pp->pln_type, pp->pln_tech);