annotate src/pl_gen6.c @ 18:1424868939a8

Indenting
author darius
date Wed, 24 Dec 1997 12:38:35 +0000
parents 8c6d5731234d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1 /*--------------------------------------------------------------------------
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
2 NETREK II -- Paradise
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
3
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
4 Permission to use, copy, modify, and distribute this software and its
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
5 documentation, or any derivative works thereof, for any NON-COMMERCIAL
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
6 purpose and without fee is hereby granted, provided that this copyright
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
7 notice appear in all copies. No representations are made about the
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
8 suitability of this software for any purpose. This software is provided
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
9 "as is" without express or implied warranty.
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
10
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
11 Xtrek Copyright 1986 Chris Guthrie
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
12 Netrek (Xtrek II) Copyright 1989 Kevin P. Smith
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
13 Scott Silvey
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
14 Paradise II (Netrek II) Copyright 1993 Larry Denys
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
15 Kurt Olsen
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
16 Brandon Gillespie
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
17 --------------------------------------------------------------------------*/
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
18
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
19 #include "config.h"
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
20 #include <math.h>
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
21
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
22 #include "defs.h"
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
23 #include "struct.h"
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
24 #include "data.h"
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
25 #include "shmem.h"
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
26 #include "planets.h"
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
27
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
28 #define SYSWIDTH (GWIDTH/4.5) /* 5.9 width of a system */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
29
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
30 #define SYSTEMS 6 /* 9 number of planetary systems */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
31
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
32 /* atmosphere chances form a cascade win rand()%100 */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
33 #define PATMOS1 40 /* chance for normal atmosphere */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
34 #define PATMOS2 70 /* chance for thin atmosphere */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
35 #define PATMOS3 90 /* chance for slightly toxic stmos */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
36 #define PPOISON 100 /* chance for poison atmos */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
37
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
38 /* defines that deal with planets resources and types */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
39 #define NMETAL 13 /* number of metal deposits */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
40 #define NDILYTH 10 /* number of dilythium deposits */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
41 #define NARABLE 15 /* number of arable land planets */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
42 /* defines that deal with star placement */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
43
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
44 #define GW ((float)GWIDTH) /* size of galaxy in floating point */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
45 #define STARBORD (GW*0.27)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
46 #define TEAMBORD (GW*0.32)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
47 #define STARMIN (GW/5.6)/* min dist between stars */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
48 #define STARMAX GW
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
49 #define TEAMMIN (GW/2.8)/* min dist between team stars */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
50 #define TEAMMAX (GW/1.8)/* max dist between team stars */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
51
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
52 /* defines that deal with systems and their planets */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
53 #define SYSADD 2 /* number possible above min number */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
54 #define SYSBORD (7000.0 + (float)GWIDTH/200) /* min distance from
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
55 * border wall */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
56 #define INDBORD (GW*0.23)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
57 #define SYSMIN (5500.0 + (float)GWIDTH/200) /* min distance between
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
58 * objects */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
59 #define SYSMIN2 (SYSMIN*SYSMIN) /* square of sysmin distance */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
60 #define SYSPLMIN 9 /* 5 min number of planets for system */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
61 #define SYSPLADD 0 /* number of possible extra planets */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
62 #define MINARMY 5 /* 8 /* min numer of armies on a
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
63 * planet */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
64 #define MAXARMY 6 /* 15 /* max number of armies on a
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
65 * planet */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
66
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
67 /* other defines */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
68 #define HOMEARMIES 30 /* number of armies on home planets */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
69 #define COLONYARMIES 10 /* number of armies for colony planet */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
70
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
71
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
72 /* defines dealing with growth timers */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
73 #define PLGFUEL configvals->plgrow.fuel /* time for growth of fuel
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
74 * depot */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
75 #define PLGAGRI configvals->plgrow.agri /* time for growth of agri */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
76 #define PLGREPAIR configvals->plgrow.repair /* time for growth of
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
77 * repair */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
78 #define PLGSHIP configvals->plgrow.shipyard /* time for growth of
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
79 * shipyard */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
80
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
81
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
82 /*-----------------------------PLACESYSTEMS------------------------------*/
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
83 /*
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
84 * This function places the planets in each star's system. The function will
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
85 * return the index of the first planet that was not placed in a system. The
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
86 * coordinates of the planets are placed in the space grid.
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
87 */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
88
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
89 static int
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
90 placesystems()
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
91 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
92 int i, j, k; /* looping vars */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
93 double x, y; /* to hold star coordinates */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
94 int done; /* flag to indicate done */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
95 double dx, dy; /* delta x and y's */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
96 int n; /* number of planet to place */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
97 int np; /* number of planets in system */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
98 int attempts;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
99
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
100 n = SYSTEMS; /* first planet to place */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
101 for (i = 0; i < SYSTEMS; i++)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
102 { /* planets for each system */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
103 np = SYSPLMIN + lrand48() % (SYSPLADD + 1); /* how many planets */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
104 for (k = 0; k < np; k++)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
105 { /* go place the planets */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
106 attempts = 0;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
107 do
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
108 { /* do until location found */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
109 attempts++;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
110 done = 0; /* not done yet */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
111 dx = (drand48() * SYSWIDTH - SYSWIDTH / 2.0);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
112 dy = (drand48() * SYSWIDTH - SYSWIDTH / 2.0);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
113 if (dx * dx + dy * dy > (SYSWIDTH / 2.0) * (SYSWIDTH / 2.0))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
114 continue; /* might orbit its way out of the galaxy */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
115 x = planets[i].pl_x + dx;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
116 y = planets[i].pl_y + dy;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
117 if ((x > GW - SYSBORD) || (x < SYSBORD)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
118 || (y < SYSBORD) || (y > GW - SYSBORD))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
119 continue; /* too close to border? */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
120
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
121 done = 1; /* assume valid coord found */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
122 for (j = 0; j < n; j++)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
123 { /* go through previous planets */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
124 dx = fabs(x - (double) planets[j].pl_x);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
125 dy = fabs(y - (double) planets[j].pl_y);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
126 if (dx * dx + dy * dy < SYSMIN2)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
127 { /* if too close to another star */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
128 done = 0; /* we must get another coord */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
129 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
130 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
131 } while (!done && attempts < 200); /* do until location found */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
132
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
133 if (!done)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
134 return 0; /* universe too crowded, try again */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
135
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
136 move_planet(n, (int) x, (int) y, 0);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
137 planets[n].pl_system = i + 1; /* mark the sytem number */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
138 planets[n].pl_armies = MINARMY + lrand48() % (MAXARMY - MINARMY);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
139 n++; /* go to next planet */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
140 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
141 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
142 return (n); /* return index of next planet */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
143 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
144
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
145
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
146
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
147
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
148 /*-----------------------------PLACEINDEP------------------------------*/
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
149 /*
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
150 * This function places idependent planets that are not in a system. They can
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
151 * appear anywhere in the galaxy as long as they are not too close to another
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
152 * planet. The coords are put in the space grid.
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
153 */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
154
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
155 static int
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
156 placeindep(n)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
157 int n;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
158 /* number of planet to start with */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
159 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
160 int i, j; /* looping vars */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
161 double x, y; /* to hold star coordinates */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
162 int done; /* flag to indicate done */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
163 double dx, dy; /* delta x and y's */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
164 int attempts;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
165
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
166 for (i = n; i < (NUMPLANETS - (WORMPAIRS * 2)); i++)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
167 { /* go through rest of planets */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
168 x = drand48() * (GW - 2 * INDBORD) + INDBORD; /* pick initial coords */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
169 y = drand48() * (GW - 2 * INDBORD) + INDBORD;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
170 attempts = 0;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
171 do
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
172 { /* do until location found */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
173 attempts++;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
174 done = 0; /* not done yet */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
175 x = INDBORD + fmod(x + (3574.0 - INDBORD), GW - 2 * INDBORD); /* offset coords a
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
176 * little */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
177 y = INDBORD + fmod(y + (1034.0 - INDBORD), GW - 2 * INDBORD); /* every loop */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
178 #if 0
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
179 if ((x > GW - INDBORD) || (x < INDBORD)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
180 || (y < INDBORD) || (y > GW - INDBORD))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
181 continue; /* too close to border? */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
182 #endif
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
183 done = 1; /* assume valid coord */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
184 for (j = 0; j < n; j++)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
185 { /* go through previous planets */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
186 dx = fabs(x - (double) planets[j].pl_x);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
187 dy = fabs(y - (double) planets[j].pl_y);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
188 if (dx * dx + dy * dy < SYSMIN2)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
189 { /* if planet to close */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
190 done = 0; /* we must get another coord */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
191 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
192 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
193 } while (!done && attempts < 200); /* do until location found */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
194
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
195 if (!done)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
196 return 0;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
197
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
198 move_planet(n, (int) x, (int) y, 0);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
199 planets[n].pl_system = 0; /* mark the no sytem */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
200 planets[n].pl_armies = MINARMY + lrand48() % (MAXARMY - MINARMY);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
201 n++; /* go to next planet */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
202 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
203 for (i = n; i < NUMPLANETS; i++) /* now place wormholes */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
204 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
205 x = drand48() * GW; /* pick intial coords */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
206 y = drand48() * GW;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
207 attempts = 0;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
208 do
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
209 { /* do until location found */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
210 attempts++;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
211 done = 0; /* not done yet */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
212 x = fmod(x + 3574.0, GW); /* offset coords a little */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
213 y = fmod(y + 1034.0, GW); /* every loop */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
214 #if 0
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
215 if ((x > GW) || (y > GW))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
216 continue; /* too close to border? */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
217 #endif
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
218 done = 1; /* assume valid coord */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
219 for (j = 0; j < n; j++)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
220 { /* go through previous planets */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
221 dx = fabs(x - (double) planets[j].pl_x);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
222 dy = fabs(y - (double) planets[j].pl_y);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
223 if (dx * dx + dy * dy < SYSMIN2)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
224 { /* if planet to close */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
225 done = 0; /* we must get another coord */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
226 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
227 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
228 } while (!done && attempts < 200); /* do until location found */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
229
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
230 if (!done)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
231 return 0;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
232
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
233 move_planet(n, (int) x, (int) y, 0);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
234 planets[n].pl_system = 0; /* mark the no system */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
235 planets[n].pl_flags |= PLWHOLE; /* mark the planet as a wormhole */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
236 /* the armies in a wormhole is the other wormhole's x coord */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
237 /* the radius is the other wormhole's y coord */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
238 if (NUMPLANETS % 2)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
239 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
240 if (!(n % 2))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
241 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
242 planets[n].pl_armies = planets[n - 1].pl_x;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
243 planets[n].pl_radius = planets[n - 1].pl_y;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
244 planets[n - 1].pl_armies = planets[n].pl_x;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
245 planets[n - 1].pl_radius = planets[n].pl_y;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
246 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
247 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
248 else
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
249 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
250 if (n % 2)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
251 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
252 planets[n].pl_armies = planets[n - 1].pl_x;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
253 planets[n].pl_radius = planets[n - 1].pl_y;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
254 planets[n - 1].pl_armies = planets[n].pl_x;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
255 planets[n - 1].pl_radius = planets[n].pl_y;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
256 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
257 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
258 planets[i].pl_owner = NOBODY; /* no team owns a star */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
259 planets[i].pl_hinfo = ALLTEAM; /* all teams know its a star */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
260 for (j = 0; j < MAXTEAM + 1; j++)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
261 { /* go put in info for teams */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
262 planets[i].pl_tinfo[j].owner = NOBODY; /* nobody owns it */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
263 planets[i].pl_tinfo[j].armies = 0;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
264 planets[i].pl_tinfo[j].flags = planets[i].pl_flags;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
265 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
266 n++; /* go to next planet */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
267 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
268 return 1;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
269 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
270
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
271
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
272
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
273
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
274 /*---------------------------------PLACERACES------------------------------*/
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
275 /*
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
276 * This function places the races in the galaxy. Each race is placed in a
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
277 * different system. The race is given a home world with an Agri and Ship-
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
278 * yard on it and HOMEARMIES. They are also given a conoly planet with
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
279 * dilythium deposits and COLONYARMIES on it.
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
280 */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
281
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
282 static void
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
283 placeraces()
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
284 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
285 int i, j, k, x; /* looping vars */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
286 int p; /* to hold planet for race */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
287 int r[4], t;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
288
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
289 r[0] = r[1] = lrand48() % 4; /* pick two races at random. They will be */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
290 while (r[0] == r[1]) /* the races whose systems are 'optimally' */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
291 r[1] = lrand48() % 4; /* placed. */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
292 i = 0;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
293 while (i == r[0] || i == r[1])
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
294 i++;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
295 r[2] = i++;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
296 while (i == r[0] || i == r[1])
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
297 i++;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
298 r[3] = i;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
299
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
300 /* only allow these teams */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
301 status2->nontteamlock = (1 << r[0]) | (1 << r[1]);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
302
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
303 for (i = 0; i < 4; i++)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
304 { /* go through races */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
305 t = r[i]; /* which team */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
306 p = lrand48() % NUMPLANETS; /* pick random planet */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
307 /* for (x=0; x <= 1; x++) { /* loop twice for 2 systems */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
308 while ((planets[p].pl_system != i + 1)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
309 || (PL_TYPE(planets[p]) == PLSTAR)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
310 || (planets[p].pl_owner != NOBODY))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
311 p = (p + 1) % NUMPLANETS; /* go on to next planet */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
312
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
313 planets[p].pl_flags &= ~PLSURMASK; /* make sure no dilithium */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
314 planets[p].pl_flags |= (PLMETAL | PLARABLE); /* metal and arable */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
315 planets[p].pl_flags |= PLATYPE1; /* good atmosphere */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
316 planets[p].pl_flags |= (PLAGRI | PLSHIPYARD | PLREPAIR);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
317 planets[p].pl_tagri = PLGAGRI; /* set timers for resources */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
318 planets[p].pl_tshiprepair = PLGSHIP;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
319 planets[p].pl_owner = 1 << t; /* make race the owner */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
320 planets[p].pl_armies = HOMEARMIES; /* set the armies */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
321 planets[p].pl_hinfo = 1 << t; /* race has info on planet */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
322 planets[p].pl_tinfo[1 << t].owner = 1 << t; /* know about owner */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
323 planets[p].pl_tinfo[1 << t].armies = planets[p].pl_armies;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
324 planets[p].pl_tinfo[1 << t].flags = planets[p].pl_flags;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
325
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
326 /* find colony planet */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
327 p = lrand48() % NUMPLANETS; /* pick random planet */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
328 while ((planets[p].pl_system != i + 1)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
329 || (PL_TYPE(planets[p]) == PLSTAR)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
330 || (planets[p].pl_owner != NOBODY))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
331 p = (p + 1) % NUMPLANETS; /* go on to next planet */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
332 planets[p].pl_flags |= PLFUEL; /* make fuel depot */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
333 planets[p].pl_tfuel = PLGFUEL; /* set timer for fuel depot */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
334 planets[p].pl_flags &= ~PLATMASK; /* take off previous atmos */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
335 planets[p].pl_flags |= PLPOISON; /* poison atmosphere */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
336 planets[p].pl_flags |= PLDILYTH; /* dilythium deposits */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
337 planets[p].pl_owner = 1 << t; /* make race the owner */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
338 planets[p].pl_armies = COLONYARMIES; /* set the armies */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
339 planets[p].pl_hinfo = 1 << t; /* race knows about */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
340 planets[p].pl_tinfo[1 << t].owner = 1 << t; /* know about owner */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
341 planets[p].pl_tinfo[1 << t].armies = planets[p].pl_armies;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
342 planets[p].pl_tinfo[1 << t].flags = planets[p].pl_flags;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
343 for (j = 0; j < NUMPLANETS; j++)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
344 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
345 if ((planets[j].pl_system == i + 1)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
346 && (PL_TYPE(planets[j]) != PLSTAR))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
347 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
348 #ifdef LEAGUE_SUPPORT
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
349 for (k = (status2->league ? 0 : t);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
350 k < (status2->league ? 4 : t + 1);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
351 k++)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
352 #else
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
353 k = t;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
354 #endif
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
355 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
356 planets[j].pl_owner = 1 << t;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
357 planets[j].pl_hinfo =
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
358 #ifdef LEAGUE_SUPPORT
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
359 status2->league ? (1 << 4) - 1 :
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
360 #endif
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
361 (1 << t);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
362 planets[j].pl_tinfo[1 << k].owner = 1 << t;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
363 planets[j].pl_tinfo[1 << k].armies = planets[j].pl_armies;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
364 planets[j].pl_tinfo[1 << k].flags = planets[j].pl_flags;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
365 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
366 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
367 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
368 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
369 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
370
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
371 /*
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
372 * Generate a complete galaxy. This variation is similar to gen_galaxy_1;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
373 * except that it tries to place the races at consistent distances from one
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
374 * another.
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
375 */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
376
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
377 void
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
378 gen_galaxy_6()
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
379 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
380 int t;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
381
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
382 NUMPLANETS = 60; /* planets + wormholes */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
383 GWIDTH = 200000;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
384
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
385 while (1)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
386 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
387 initplanets(); /* initialize planet structures */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
388
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
389 /* place the resources */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
390 zero_plflags(planets, NUMPLANETS);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
391 randomize_atmospheres(planets + SYSTEMS, NUMPLANETS - SYSTEMS,
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
392 PATMOS1, PATMOS2, PATMOS3, PPOISON);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
393 randomize_resources(planets + SYSTEMS, NUMPLANETS - SYSTEMS,
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
394 NMETAL, NDILYTH, NARABLE);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
395
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
396 /* place system centers */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
397 t = place_stars(planets, 2,
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
398 (int) TEAMBORD, (int) TEAMMIN, (int) TEAMMAX,
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
399 (struct planet *) 0, 0)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
400 && place_stars(planets + 2, 2,
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
401 (int) (STARBORD * 0.8), (int) TEAMMIN, (int) STARMAX,
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
402 planets, 2)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
403 && place_stars(planets + 4, SYSTEMS - 4,
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
404 (int) STARBORD, (int) STARMIN, (int) STARMAX,
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
405 planets, 4);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
406
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
407 if (!t)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
408 continue;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
409 t = placesystems(); /* place planets in systems */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
410 if (!t)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
411 continue;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
412 t = placeindep(t); /* place independent planets */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
413 if (t)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
414 break; /* success */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
415 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
416 if (configvals->justify_galaxy)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
417 justify_galaxy(SYSTEMS);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
418 placeraces(); /* place home planets for races */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
419 }