comparison src/pl_gen4.c @ 4:aa38447a4b21

First entry of Paradise Server 2.9 patch 10 Beta
author darius
date Sat, 06 Dec 1997 04:37:03 +0000
parents
children
comparison
equal deleted inserted replaced
3:cafa94d86546 4:aa38447a4b21
1 /*--------------------------------------------------------------------------
2 NETREK II -- Paradise
3
4 Permission to use, copy, modify, and distribute this software and its
5 documentation, or any derivative works thereof, for any NON-COMMERCIAL
6 purpose and without fee is hereby granted, provided that this copyright
7 notice appear in all copies. No representations are made about the
8 suitability of this software for any purpose. This software is provided
9 "as is" without express or implied warranty.
10
11 Xtrek Copyright 1986 Chris Guthrie
12 Netrek (Xtrek II) Copyright 1989 Kevin P. Smith
13 Scott Silvey
14 Paradise II (Netrek II) Copyright 1993 Larry Denys
15 Kurt Olsen
16 Brandon Gillespie
17 --------------------------------------------------------------------------*/
18 #include "config.h"
19 #include <math.h>
20 #include <memory.h>
21
22 #include "defs.h"
23 #include "struct.h"
24 #include "data.h"
25 #include "shmem.h"
26 #include "planets.h"
27
28 #if 0
29 #define SYSWIDTH (GWIDTH/5.75) /* width of a system */
30 #endif
31
32 #define SYSTEMS 0 /* number of planetary systems */
33
34 /* atmosphere chances form a cascade win rand()%100 */
35 #define PATMOS1 100 /* chance for normal atmosphere */
36 #define PATMOS2 100 /* chance for thin atmosphere */
37 #define PATMOS3 100 /* chance for slightly toxic stmos */
38 #define PPOISON 100 /* chance for poison atmos */
39
40 /* defines that deal with planets resources and types */
41 #define NMETAL 8 /* number of metal deposits */
42 #define NDILYTH 12 /* number of dilythium deposits */
43 #define NARABLE 8 /* number of arable land planets */
44
45 #define MINARMY 8 /* min numer of armies on a planet */
46 #define MAXARMY 15 /* max number of armies on a planet */
47
48 /* other defines */
49 #define HOMEARMIES 30 /* number of armies on home planets */
50 #define COLONYARMIES 10 /* number of armies for colony planet */
51
52
53 /* defines dealing with growth timers */
54 #define PLGFUEL configvals->plgrow.fuel /* time for growth of fuel
55 * depot */
56 #define PLGAGRI configvals->plgrow.agri /* time for growth of agri */
57 #define PLGREPAIR configvals->plgrow.repair /* time for growth of
58 * repair */
59 #define PLGSHIP configvals->plgrow.shipyard /* time for growth of
60 * shipyard */
61
62
63 /*-------------------------------INITBRONCO------------------------------*/
64 /*
65 * Initializes the planet array the way normaltrek did it -- not much
66 * variety, but some people dig playing chess from the same setup over and
67 * over again too. :)
68 */
69 static void
70 initbronco()
71 {
72 int i, j;
73
74 static struct planet pdata[MAXPLANETS] = {
75 {0, (FED | PLHOME | PLCORE | PLFUEL | PLREPAIR | PLSHIPYARD | PLMETAL | PLARABLE | PLDILYTH),
76 FED, 20000, 80000, 0, 0, 0, "Earth", 5,
77 (ROM | KLI | ORI), 0, 0, 0, 30, 0, FED},
78 {1, FED | PLCORE, FED, 30000, 90000, 0, 0, 0, "Deneb", 5,
79 (ROM | KLI | ORI), 0, 0, 0, 30, 0, FED},
80 {2, FED | PLCORE, FED, 11000, 75000, 0, 0, 0, "Altair", 6,
81 (ROM | KLI | ORI), 0, 0, 0, 30, 0, FED},
82 {3, FED | PLCORE, FED, 8000, 93000, 0, 0, 0, "Vega", 4,
83 (ROM | KLI | ORI), 0, 0, 0, 30, 0, FED},
84 {4, FED, FED, 10000, 60000, 0, 0, 0, "Rigel", 5,
85 (ROM | KLI | ORI), 0, 0, 0, 30, 0, FED},
86 {5, FED, FED, 25000, 60000, 0, 0, 0, "Canopus", 7,
87 (ROM | KLI | ORI), 0, 0, 0, 30, 0, FED},
88 {6, FED, FED, 44000, 81000, 0, 0, 0, "Beta Crucis", 11,
89 (ROM | KLI | ORI), 0, 0, 0, 30, 0, FED},
90 {7, FED, FED, 39000, 55000, 0, 0, 0, "Organia", 7,
91 (ROM | KLI | ORI), 0, 0, 0, 30, 0, FED},
92 {8, FED, FED, 45000, 66000, 0, 0, 0, "Ceti Alpha V", 12,
93 (ROM | KLI | ORI), 0, 0, 0, 30, 0, FED},
94 {9, FED, FED, 32000, 74000, 0, 0, 0, "Alpha Centauri", 14,
95 (ROM | KLI | ORI), 0, 0, 0, 30, 0, FED},
96 {10, (ROM | PLHOME | PLCORE | PLFUEL | PLREPAIR | PLSHIPYARD | PLMETAL | PLARABLE | PLDILYTH),
97 ROM, 20000, 20000, 0, 0, 0, "Romulus", 7,
98 (FED | KLI | ORI), 0, 0, 0, 30, 0, ROM},
99 {11, ROM | PLCORE, ROM, 28000, 8000, 0, 0, 0, "Tauri", 5,
100 (FED | KLI | ORI), 0, 0, 0, 30, 0, ROM},
101 {12, ROM | PLCORE, ROM, 28000, 23000, 0, 0, 0, "Draconis", 8,
102 (FED | KLI | ORI), 0, 0, 0, 30, 0, ROM},
103 {13, ROM | PLCORE, ROM, 4000, 12000, 0, 0, 0, "Aldeberan", 9,
104 (FED | KLI | ORI), 0, 0, 0, 30, 0, ROM},
105 {14, ROM, ROM, 45000, 7000, 0, 0, 0, "Eridani", 7,
106 (FED | KLI | ORI), 0, 0, 0, 30, 0, ROM},
107 {15, ROM, ROM, 42000, 44000, 0, 0, 0, "Regulus", 7,
108 (FED | KLI | ORI), 0, 0, 0, 30, 0, ROM},
109 {16, ROM, ROM, 13000, 45000, 0, 0, 0, "Capella", 7,
110 (FED | KLI | ORI), 0, 0, 0, 30, 0, ROM},
111 {17, ROM, ROM, 40000, 25000, 0, 0, 0, "Sirius", 6,
112 (FED | KLI | ORI), 0, 0, 0, 30, 0, ROM},
113 {18, ROM, ROM, 25000, 44000, 0, 0, 0, "Indi", 4,
114 (FED | KLI | ORI), 0, 0, 0, 30, 0, ROM},
115 {19, ROM, ROM, 8000, 29000, 0, 0, 0, "Hydrae", 6,
116 (FED | KLI | ORI), 0, 0, 0, 30, 0, ROM},
117 {20, (KLI | PLHOME | PLCORE | PLFUEL | PLREPAIR | PLSHIPYARD | PLMETAL | PLARABLE | PLDILYTH),
118 KLI, 80000, 20000, 0, 0, 0, "Klingus", 7,
119 (FED | ROM | ORI), 0, 0, 0, 30, 0, KLI},
120 {21, KLI | PLCORE, KLI, 88000, 12000, 0, 0, 0, "Pollux", 6,
121 (FED | ROM | ORI), 0, 0, 0, 30, 0, KLI},
122 {22, KLI | PLCORE, KLI, 69000, 31000, 0, 0, 0, "Scorpii", 7,
123 (FED | ROM | ORI), 0, 0, 0, 30, 0, KLI},
124 {23, KLI | PLCORE, KLI, 73000, 5000, 0, 0, 0, "Castor", 6,
125 (FED | ROM | ORI), 0, 0, 0, 30, 0, KLI},
126 {24, KLI, KLI, 70000, 40000, 0, 0, 0, "Pleiades V", 10,
127 (FED | ROM | ORI), 0, 0, 0, 30, 0, KLI},
128 {25, KLI, KLI, 60000, 10000, 0, 0, 0, "Andromeda", 9,
129 (FED | ROM | ORI), 0, 0, 0, 30, 0, KLI},
130 {26, KLI, KLI, 54000, 40000, 0, 0, 0, "Lalande", 7,
131 (FED | ROM | ORI), 0, 0, 0, 30, 0, KLI},
132 {27, KLI, KLI, 90000, 37000, 0, 0, 0, "Lyrae", 5,
133 (FED | ROM | ORI), 0, 0, 0, 30, 0, KLI},
134 {28, KLI, KLI, 83000, 48000, 0, 0, 0, "Mira", 4,
135 (FED | ROM | ORI), 0, 0, 0, 30, 0, KLI},
136 {29, KLI, KLI, 54000, 21000, 0, 0, 0, "Cygni", 5,
137 (FED | ROM | ORI), 0, 0, 0, 30, 0, KLI},
138 {30, (ORI | PLHOME | PLCORE | PLFUEL | PLREPAIR | PLSHIPYARD | PLMETAL | PLARABLE | PLDILYTH),
139 ORI, 80000, 80000, 0, 0, 0, "Orion", 5,
140 (FED | ROM | KLI), 0, 0, 0, 30, 0, ORI},
141 {31, ORI | PLCORE, ORI, 72000, 69000, 0, 0, 0, "Procyon", 7,
142 (FED | ROM | KLI), 0, 0, 0, 30, 0, ORI},
143 {32, ORI | PLCORE, ORI, 91000, 94000, 0, 0, 0, "Ursae Majoris", 13,
144 (FED | ROM | KLI), 0, 0, 0, 30, 0, ORI},
145 {33, ORI | PLCORE, ORI, 85000, 70000, 0, 0, 0, "Antares", 7,
146 (FED | ROM | KLI), 0, 0, 0, 30, 0, ORI},
147 {34, ORI, ORI, 92000, 59000, 0, 0, 0, "Cassiopia", 9,
148 (FED | ROM | KLI), 0, 0, 0, 30, 0, ORI},
149 {35, ORI, ORI, 65000, 55000, 0, 0, 0, "El Nath", 7,
150 (FED | ROM | KLI), 0, 0, 0, 30, 0, ORI},
151 {36, ORI, ORI, 52000, 60000, 0, 0, 0, "Spica", 5,
152 (FED | ROM | KLI), 0, 0, 0, 30, 0, ORI},
153 {37, ORI, ORI, 64000, 80000, 0, 0, 0, "Polaris", 7,
154 (FED | ROM | KLI), 0, 0, 0, 30, 0, ORI},
155 {38, ORI, ORI, 56000, 89000, 0, 0, 0, "Arcturus", 8,
156 (FED | ROM | KLI), 0, 0, 0, 30, 0, ORI},
157 {39, ORI, ORI, 70000, 93000, 0, 0, 0, "Herculis", 8,
158 (FED | ROM | KLI), 0, 0, 0, 30, 0, ORI}
159 };
160 for (i = 0; i < NUMPLANETS; i++)
161 {
162 for (j = 0; j < MAXTEAM + 1; j++)
163 {
164 pdata[i].pl_tinfo[j].owner = pdata[i].pl_owner;
165 pdata[i].pl_tinfo[j].armies = pdata[i].pl_armies;
166 pdata[i].pl_tinfo[j].flags = pdata[i].pl_flags;
167 pdata[i].pl_tinfo[j].timestamp = 0;
168 }
169 pdata[i].pl_trevolt = 0;
170 pdata[i].pl_next = 0;
171 pdata[i].pl_prev = 0;
172 pdata[i].pl_gridnum = 0;
173 }
174 memcpy((char *) planets, (char *) pdata, MAXPLANETS * sizeof(struct planet));
175 }
176 /*-------------------------------GENRESOURCES----------------------------*/
177 /*
178 * This function goes through the planets structure and determines what kind
179 * of atmosphere and what kind of surface the planets have. It generates the
180 * stars that will be used as system centers ans then places atmospheres on
181 * the other planets. It then distributes the resources on the planet
182 * surfaces. This version's been bronco-ified. :)
183 */
184
185 static void
186 genresources_bronco()
187 {
188 int i, j; /* looping vars */
189 int t; /* temp var */
190
191 for (i = SYSTEMS; i < NUMPLANETS; i++)
192 { /* generate atmospheres */
193 t = lrand48() % 100; /* random # 0-99 */
194 if (t < PATMOS1) /* is it atmosphere type 1 */
195 planets[i].pl_flags |= PLATYPE1;
196 else if (t < PATMOS2) /* is it atmosphere type 2 */
197 planets[i].pl_flags |= PLATYPE2;
198 else if (t < PATMOS3) /* is it atmosphere type 3 */
199 planets[i].pl_flags |= PLATYPE3;
200 else if (t < PPOISON) /* is it poison atmosphere */
201 planets[i].pl_flags |= PLPOISON;
202 }
203 for (i = 0; i < NMETAL; i++)
204 { /* place the metal deposits */
205 t = lrand48() % ((NUMPLANETS - SYSTEMS) / 4) + SYSTEMS +
206 ((i / (NMETAL / 4)) * ((NUMPLANETS - SYSTEMS) / 4));
207 if (!(planets[t].pl_flags & PLMETAL & PLSURMASK))
208 {
209 planets[t].pl_flags |= PLMETAL; /* OR in the metal flag */
210 planets[t].pl_flags |= PLREPAIR;
211 }
212 else
213 i--;
214 }
215 for (i = 0; i < NDILYTH; i++)
216 { /* place the crystals */
217 t = lrand48() % ((NUMPLANETS - SYSTEMS) / 4) + SYSTEMS +
218 ((i / (NDILYTH / 4)) * ((NUMPLANETS - SYSTEMS) / 4));
219 if (!(planets[t].pl_flags & PLDILYTH & PLSURMASK))
220 {
221 planets[t].pl_flags |= PLDILYTH; /* OR in the dilyth flag */
222 planets[t].pl_flags |= PLFUEL;
223 }
224 else
225 i--;
226 }
227 for (i = 0; i < NARABLE; i++)
228 { /* place the farms */
229 t = lrand48() % ((NUMPLANETS - SYSTEMS) / 4) + SYSTEMS +
230 ((i / (NARABLE / 4)) * ((NUMPLANETS - SYSTEMS) / 4));
231 if (!(planets[t].pl_flags & PLARABLE & PLSURMASK) &&
232 !(planets[t].pl_flags & PLHOME))
233 {
234 planets[t].pl_flags |= PLARABLE | PLATYPE1; /* OR in the arable flag */
235 planets[t].pl_flags |= PLAGRI;
236 }
237 else
238 i--;
239 }
240 for (i = 0; i < NUMPLANETS; i++)
241 for (j = 0; j < MAXTEAM + 1; j++)
242 if (j == planets[i].pl_owner)
243 planets[i].pl_tinfo[j].flags = planets[i].pl_flags;
244 }
245
246
247
248 /*
249 * Generate a complete galaxy. Uses ye old bronco planet setup.
250 */
251
252 void
253 gen_galaxy_4()
254 {
255 GWIDTH = 100000;
256 NUMPLANETS = 40;
257 initbronco(); /* initialize planet structures */
258 genresources_bronco(); /* place the resources */
259 return;
260 }