2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2009, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure
6 * This program 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 2 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, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * See files README, COPYING and CREDITS in the root of the source
23 * tree for related information and legal notices. It is expected
24 * that future projects/authors will amend these files as needed.
28 * plane.c: Plane characteristics
30 * Known contributors to this file:
33 * Thomas Ruschak, 1992
45 * Table of plane types
46 * Initialized on startup from plane.config and deity custom config (if any).
47 * Terminated by a sentinel with null pl_name.
49 struct plchrstr plchr[PLN_TYPE_MAX + 2];
51 #define logx(a, b) (log((a)) / log((b)))
52 #define PLN_ATTDEF(b, t) (b + ((b?1:0) * ((t/20)>10?10:(t/20))))
53 #define PLN_ACC(b, t) (b * (1.0 - (sqrt(t) / 50.)))
54 #define PLN_RAN(b, t) (t ? (b + (logx(t, 2.0))) : b)
55 #define PLN_LOAD(b, t) (t ? (b * (logx(t, 50.0) < 1.0 ? 1.0 : \
59 pl_att(struct plchrstr *pcp, int tech)
61 return PLN_ATTDEF(pcp->pl_att, MAX(0, tech - pcp->pl_tech));
65 pl_def(struct plchrstr *pcp, int tech)
67 return PLN_ATTDEF(pcp->pl_def, MAX(0, tech - pcp->pl_tech));
71 pl_acc(struct plchrstr *pcp, int tech)
73 return PLN_ACC(pcp->pl_acc, MAX(0, tech - pcp->pl_tech));
77 pl_range(struct plchrstr *pcp, int tech)
79 return PLN_RAN(pcp->pl_range, MAX(0, tech - pcp->pl_tech));
83 pl_load(struct plchrstr *pcp, int tech)
85 return PLN_LOAD(pcp->pl_load, MAX(0, tech - pcp->pl_tech));
89 pln_att(struct plnstr *pp)
91 return pl_att(plchr + pp->pln_type, pp->pln_tech);
95 pln_def(struct plnstr *pp)
97 return pl_def(plchr + pp->pln_type, pp->pln_tech);
101 pln_acc(struct plnstr *pp)
103 return pl_acc(plchr + pp->pln_type, pp->pln_tech);
107 pln_range_max(struct plnstr *pp)
109 return pl_range(plchr + pp->pln_type, pp->pln_tech);
113 pln_load(struct plnstr *pp)
115 return pl_load(plchr + pp->pln_type, pp->pln_tech);