]> git.pond.sub.org Git - empserver/blob - include/sect.h
Sectors need space for items, deliveries and distribution thresholds.
[empserver] / include / sect.h
1 /*
2  *  Empire - A multi-player, client/server Internet based war game.
3  *  Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
4  *                           Ken Stevens, Steve McClure
5  *
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.
10  *
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.
15  *
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
19  *
20  *  ---
21  *
22  *  See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23  *  related information and legal notices. It is expected that any future
24  *  projects/authors will amend these files as needed.
25  *
26  *  ---
27  *
28  *  sect.h: Definitions for things having to do with sectors.
29  * 
30  *  Known contributors to this file:
31  *     Dave Pare
32  *     Ken Stevens, 1995
33  *     Steve McClure, 1998
34  */
35
36
37 #ifndef _SECT_H_
38 #define _SECT_H_
39
40 #include "var.h"
41
42 /* The order of the following elements is there to match up with genitem */
43
44 struct sctstr {
45     short ef_type;
46     natid sct_own;              /* owner's country num */
47     short sct_elev;             /* elevation/depth */
48     coord sct_x;                /* x coord of sector */
49     coord sct_y;                /* y coord of sector */
50     u_char sct_type;            /* sector type */
51     u_char sct_effic;           /* 0% to 100% */
52     short sct_mobil;            /* mobility units */
53     u_char sct_loyal;           /* updates until civilans "converted" */
54     u_char sct_terr;            /* territory 0 id # of sector */
55     u_char sct_terr1;           /* territory 1 id # of sector */
56     u_char sct_terr2;           /* territory 2 id # of sector */
57     u_char sct_terr3;           /* territory 3 id # of sector */
58     coord sct_dist_x;           /* Dist sector */
59     coord sct_dist_y;
60     short sct_avail;            /* available workforce for "other things" */
61     short sct_flags;            /* temporary flags */
62     short sct_fill;             /* gunk */
63     u_char sct_work;            /* pct of civ actually working */
64     u_char sct_coastal;         /* is this a coastal sector? */
65     u_char sct_newtype;         /* for changing designations */
66     u_char sct_min;             /* ease of mining ore */
67     u_char sct_gmin;            /* amount of gold ore */
68     u_char sct_fertil;          /* fertility of soil */
69     u_char sct_oil;             /* oil content */
70     u_char sct_uran;            /* uranium ore content */
71     natid sct_oldown;           /* old owner of sector (for liberation) */
72     u_char sct_updated;         /* Has this sect been updated? */
73     u_char sct_off;             /* Should this sector produce? */
74     u_short sct_item[I_MAX+1];  /* amount of items stored here */
75     u_short sct_del[I_MAX+1];   /* delivieries */
76     u_short sct_dist[I_MAX+1];  /* distribution thresholds */
77     u_short sct_mines;          /* number of mines */
78     u_short sct_pstage;         /* plague stage */
79     u_short sct_ptime;          /* how many etus remain in this stage */
80     u_short sct_che;            /* che combo */
81     u_short sct_fallout;
82     time_t sct_access;          /* Last time mob was updated (MOB_ACCESS) */
83     u_char sct_road;            /* Road value of a sector */
84     u_char sct_rail;            /* Rail value of a sector */
85     u_char sct_defense;         /* Defensive value of a sector */
86     time_t sct_timestamp;       /* Last time this sector was written to */
87 };
88
89 struct dchrstr {
90     int d_mnem;                 /* map symbol */
91     int d_prd;                  /* product vtype */
92     int d_mcst;                 /* movement cost */
93     int d_flg;                  /* movement cost */
94     int d_pkg;                  /* type of packaging in these sects */
95     float d_ostr;               /* offensive strength */
96     float d_dstr;               /* defensive strength */
97     int d_value;                /* resale ("collect") value */
98     int d_cost;                 /* cost to designate the sect */
99     int d_build;                /* cost multiplier for eff */
100     int d_lcms;                 /* lcm's needed per point of eff */
101     int d_hcms;                 /* hcm's needed per point of eff */
102     s_char *d_name;             /* full name of sector type */
103 };
104
105 #define NPKG    0               /* no special packaging */
106 #define WPKG    1               /* "warehouse" packaging */
107 #define UPKG    2               /* "urban" packaging */
108 #define BPKG    3               /* "bank" packaging */
109
110 /* for d_flg */
111 #define NAVOK   1               /* ships can always navigate */
112 #define NAV_02  2               /* requires 2% effic to navigate */
113 #define NAV_60  3               /* requires 60% effic to navigate */
114
115         /* sector types (must agree with order in dchr, empglb.c) */
116
117 #define SCT_WATER       0       /* basics */
118 #define SCT_MOUNT       1
119 #define SCT_SANCT       2
120 #define SCT_WASTE       3
121 #define SCT_RURAL       4
122 #define SCT_CAPIT       5
123 #define SCT_URAN        6
124 #define SCT_PARK        7
125 #define SCT_ARMSF       8       /* industries */
126 #define SCT_AMMOF       9
127 #define SCT_MINE        10
128 #define SCT_GMINE       11
129 #define SCT_HARBR       12
130 #define SCT_WAREH       13
131 #define SCT_AIRPT       14
132 #define SCT_AGRI        15
133 #define SCT_OIL         16
134 #define SCT_LIGHT       17
135 #define SCT_HEAVY       18
136 #define SCT_FORTR       19      /* military/scientific */
137 #define SCT_TECH        20
138 #define SCT_RSRCH       21
139 #define SCT_NUKE        22
140 #define SCT_LIBR        23
141 #define SCT_HIWAY       24      /* communications */
142 #define SCT_RADAR       25
143 #define SCT_HEADQ       26      /* headquarters */
144 #define SCT_BHEAD       27      /* Bridge head */
145 #define SCT_BSPAN       28      /* Bridge span */
146 #define SCT_BANK        29      /* financial */
147 #define SCT_REFINE      30      /* refinery */
148 #define SCT_ENLIST      31      /* enlistment center */
149 #define SCT_PLAINS      32      /* plains sector */
150 #define SCT_BTOWER      33      /* Bridge tower */
151
152 #define SCT_EFFIC       34      /* used in update & budget */
153 #define SCT_MAXDEF      34      /* highest sector type in header files */
154
155 #define getsect(x, y, p) \
156         ef_read(EF_SECTOR, sctoff((int) x, (int) y), (caddr_t)p)
157 #define putsect(p) \
158         ef_write(EF_SECTOR, sctoff((int) (p)->sct_x, \
159                 (int) (p)->sct_y), (caddr_t)p)
160 #define getsectp(x, y) \
161         (struct sctstr *) ef_ptr(EF_SECTOR, sctoff((int)x, (int)y))
162 #define getsectid(id) \
163         (struct sctstr *) ef_ptr(EF_SECTOR, id)
164
165 /* things relating to sectors */
166 extern int sctoff(coord x, coord y);
167
168 extern int sct_maxno;
169 extern struct dchrstr dchr[];
170 extern struct dchrstr bigcity_dchr;
171
172 #define MIN_MOBCOST  0.001      /* lowest cost a sector can have to move into */
173 #define FORTEFF 5               /* forts must be 5% efficient to fire. */
174
175 #define MOB_NONE    0
176 #define MOB_ROAD    1
177 #define MOB_RAIL    2
178
179 #define INT_ROAD    0
180 #define INT_RAIL    1
181 #define INT_DEF     2
182
183 /* Sector flags */
184 #define MOVE_IN_PROGRESS        bit(0)  /* move in progress */
185
186 /* Each cost is per point of efficency */
187 struct sctintrins {
188     char *in_name;
189     u_char in_lcms;
190     u_char in_hcms;
191     u_char in_dcost;
192     u_char in_mcost;
193 };
194
195 extern struct sctintrins intrchr[];
196
197 #endif /* _SECT_H_ */