14 #include "gb/GB_server.h" 15 #include "gb/buffers.h" 17 #include "gb/files_shl.h" 18 #include "gb/globals.h" 23 #include "gb/shipdata.h" 25 #include "gb/sql/sql.h" 26 #include "gb/tweakables.h" 27 #include "gb/utils/rand.h" 36 #define RACIAL_TYPES 10
39 static char desshow(
const int x,
const int y, SectorMap &);
45 .125, .125, .125, .125, .125};
47 0.6, 0.65, 0.7, 0.75, 0.8};
50 170, 160, 150, 140, 130};
53 .7, .7, .75, .75, .8};
58 1.30, 1.45, 1.6, 1.75, 1.9};
60 #define RMass(x) (db_Mass[(x)] + .001
* (double)int_rand(-25
, 25
)) 61 #define Birthrate(x) (db_Birthrate[(x)] + .01
* (double)int_rand(-10
, 10
)) 62 #define Fighters(x) (db_Fighters[(x)] + int_rand(-1
, 1
)) 63 #define Intelligence(x) (db_Intelligence[(x)] + int_rand(-10
, 10
)) 64 #define Adventurism(x) (db_Adventurism[(x)] + 0.01
* (double)int_rand(-10
, 10
)) 66 (int_rand(Min_Sexes[(x)], int_rand(Min_Sexes[(x)], Max_Sexes[(x)]))) 67 #define Metabolism(x) (db_Metabolism[(x)] + .01
* (double)int_rand(-15
, 15
)) 89 struct stype secttypes[SectorType::SEC_WASTED + 1] = {};
91 unsigned char not_found[PlanetType::DESERT + 1];
99 printf(
"There are already %d players; No more allowed.\n",
MAXPLAYERS - 1);
103 printf(
"Enter racial type to be created (1-%d):",
RACIAL_TYPES);
108 printf(
"Bad racial index.\n");
115 star_arena = (startype *)malloc(Sdata.numstars *
sizeof(startype));
116 for (
int s = 0; s < Sdata.numstars; s++) {
117 Stars[s] = &star_arena[s];
120 printf(
"There is still space for player %d.\n", Playernum);
122 bzero((
char *)not_found,
sizeof(not_found));
125 "\nLive on what type planet:\n (e)arth, (g)asgiant, (m)ars, " 126 "(i)ce, (w)ater, (d)esert, (f)orest? ");
132 ppref = PlanetType::WATER;
135 ppref = PlanetType::EARTH;
138 ppref = PlanetType::MARS;
141 ppref = PlanetType::GASGIANT;
144 ppref = PlanetType::ICEBALL;
147 ppref = PlanetType::DESERT;
150 ppref = PlanetType::FOREST;
153 printf(
"Oh well.\n");
157 printf(
"Looking for type %d planet...\n", ppref);
163 for (star = 0; star < Sdata.numstars && !found && count < 100;) {
166 if (Stars[star]->inhabited[0] + Stars[star]->inhabited[1] ||
167 Stars[star]->numplanets < 2)
173 while (!found && pnum < Stars[star]->numplanets) {
176 if (planet.type == ppref && Stars[star]->numplanets != 1) {
178 for (i = 1; i <= Playernum; i++)
179 if (planet.info[i - 1].numsectsowned) vacant = 0;
180 if (vacant && planet.conditions[
RTEMP] >= -50 &&
181 planet.conditions[
RTEMP] <= 50) {
193 star = int_rand(0, Sdata.numstars - 1);
198 printf(
"planet type not found in any free systems.\n");
199 not_found[ppref] = 1;
200 for (found = 1, i = PlanetType::EARTH; i <= PlanetType::DESERT; i++)
201 found &= not_found[i];
203 printf(
"Looks like there aren't any free planets left. bye..\n");
206 printf(
" Try a different one...\n");
212 auto race =
new Race;
213 bzero(race,
sizeof(Race));
215 printf(
"\n\tDeity/Guest/Normal (d/g/n) ?");
219 race->God = (c ==
'd');
220 race->Guest = (c ==
'g');
221 strcpy(race->name,
"Unknown");
224 race->governor[0].money = 0;
225 race->governor[0].homelevel = race->governor[0].deflevel =
226 ScopeLevel::LEVEL_PLAN;
227 race->governor[0].homesystem = race->governor[0].defsystem = star;
228 race->governor[0].homeplanetnum = race->governor[0].defplanetnum = pnum;
230 race->governor[0].toggle.highlight = Playernum;
231 race->governor[0].toggle.inverse = 1;
232 race->governor[0].toggle.color = 0;
233 race->governor[0].active = 1;
234 printf(
"Enter the password for this race:");
235 scanf(
"%s", race->password);
237 printf(
"Enter the password for this leader:");
238 scanf(
"%s", race->governor[0].password);
244 for (j = 0; j <=
OTHER; j++) race->conditions[j] = planet.conditions[j];
250 if ((i == (Playernum - 1) || Playernum == 1) || race->God)
251 race->translate[i] = 100;
253 race->translate[i] = 1;
261 race->allied[0] = race->allied[1] = 0;
262 race->atwar[0] = race->atwar[1] = 0;
264 race->mass =
RMass(idx);
269 race->Metamorph = race->absorb = race->collective_iq = race->pods = 1;
272 race->Metamorph = race->absorb = race->collective_iq = race->pods = 0;
275 race->number_sexes =
Sexes(idx);
278 printf(
"%s\n", race->Metamorph ?
"METAMORPHIC" :
"");
279 printf(
" Birthrate: %.3f\n", race->birthrate);
280 printf(
"Fighting ability: %d\n", race->fighters);
281 printf(
" IQ: %d\n", race->IQ);
282 printf(
" Metabolism: %.2f\n", race->metabolism);
283 printf(
" Adventurism: %.2f\n", race->adventurism);
284 printf(
" Mass: %.2f\n", race->mass);
285 printf(
" Number of sexes: %d (min req'd for colonization)\n",
288 printf(
"\n\nLook OK(y/n)\?");
289 if (fgets(str,
STRSIZE, stdin) ==
nullptr) exit(1);
290 }
while (str[0] !=
'y');
295 "\nChoose a primary sector preference. This race will prefer to " 296 "live\non this type of sector.\n");
301 secttypes[smap.get(x, y).condition]
.count++;
302 if (!secttypes[smap.get(x, y).condition]
.here) {
303 secttypes[smap.get(x, y).condition]
.here = 1;
304 secttypes[smap.get(x, y).condition]
.x = x;
305 secttypes[smap.get(x, y).condition]
.y = y;
309 for (i = SectorType::SEC_SEA; i <= SectorType::SEC_WASTED; i++)
310 if (secttypes[i]
.here) {
311 printf(
"(%2d): %c (%d, %d) (%s, %d sectors)\n", i,
313 secttypes[i]
.y, Desnames[i], secttypes[i]
.count);
319 printf(
"\nchoice (enter the number): ");
322 if (i < SectorType::SEC_SEA || i > SectorType::SEC_WASTED ||
323 !secttypes[i]
.here) {
324 printf(
"There are none of that type here..\n");
329 auto § = smap.get(secttypes[i]
.x, secttypes[i]
.y);
331 race->likes[i] = 1.0;
332 race->likes[SectorType::SEC_PLATED] = 1.0;
333 race->likes[SectorType::SEC_WASTED] = 0.0;
334 printf(
"\nEnter compatibilities of other sectors -\n");
335 for (j = SectorType::SEC_SEA; j < SectorType::SEC_PLATED; j++)
337 printf(
"%6s (%3d sectors) :", Desnames[j], secttypes[j]
.count);
339 race->likes[j] = (
double)k / 100.0;
345 sigaddset(&block, SIGHUP);
346 sigaddset(&block, SIGTERM);
347 sigaddset(&block, SIGINT);
348 sigaddset(&block, SIGQUIT);
349 sigaddset(&block, SIGSTOP);
350 sigaddset(&block, SIGTSTP);
351 sigprocmask(SIG_BLOCK, &block, &mask);
357 bzero(&s,
sizeof(s));
359 printf(
"Creating government ship %d...\n", shipno);
360 race->Gov_ship = shipno;
361 planet.ships = shipno;
364 s.type = ShipType::OTYPE_GOV;
365 s.xpos = Stars[star]->xpos + planet.xpos;
366 s.ypos = Stars[star]->ypos + planet.ypos;
367 s.land_x = (
char)secttypes[i]
.x;
368 s.land_y = (
char)secttypes[i]
.y;
377 s.build_type = ShipType::OTYPE_GOV;
378 s.armor = Shipdata[ShipType::OTYPE_GOV][ABIL_ARMOR];
380 s.primary = Shipdata[ShipType::OTYPE_GOV][ABIL_GUNS];
381 s.primtype = Shipdata[ShipType::OTYPE_GOV][ABIL_PRIMARY];
382 s.secondary = Shipdata[ShipType::OTYPE_GOV][ABIL_GUNS];
383 s.sectype = Shipdata[ShipType::OTYPE_GOV][ABIL_SECONDARY];
384 s.max_crew = Shipdata[ShipType::OTYPE_GOV][ABIL_MAXCREW];
385 s.max_destruct = Shipdata[ShipType::OTYPE_GOV][ABIL_DESTCAP];
386 s.max_resource = Shipdata[ShipType::OTYPE_GOV][ABIL_CARGO];
387 s.max_fuel = Shipdata[ShipType::OTYPE_GOV][ABIL_FUELCAP];
388 s.max_speed = Shipdata[ShipType::OTYPE_GOV][ABIL_SPEED];
389 s.build_cost = Shipdata[ShipType::OTYPE_GOV][ABIL_COST];
392 sprintf(s.shipclass,
"Standard");
395 s.popn = Shipdata[s.type][ABIL_MAXCREW];
397 s.mass = s.base_mass + Shipdata[s.type][ABIL_MAXCREW] * race->mass;
398 s.destruct = s.resource = 0;
406 s.whatorbits = ScopeLevel::LEVEL_PLAN;
407 s.whatdest = ScopeLevel::LEVEL_PLAN;
423 printf(
"Created on sector %d,%d on /%s/%s\n", s.land_x, s.land_y,
424 Stars[s.storbits]->name, Stars[s.storbits]->pnames[s.pnumorbits]);
428 for (j = 0; j <
MAXPLAYERS; j++) race->points[j] = 0;
432 planet.info[Playernum - 1].numsectsowned = 1;
434 planet.info[Playernum - 1].explored = 1;
437 sect.owner = Playernum;
438 sect.race = Playernum;
439 sect.popn = planet.popn = race->number_sexes;
442 sect.troops = planet.troops = 0;
452 setbit(Stars[star]->explored, Playernum);
453 setbit(Stars[star]->inhabited, Playernum);
454 Stars[star]->AP[Playernum - 1] = 5;
457 sigprocmask(SIG_SETMASK, &mask,
nullptr);
459 printf(
"\nYou are player %d.\n\n", Playernum);
460 printf(
"Your race has been created on sector %d,%d on\n", secttypes[i]
.x,
462 printf(
"%s/%s.\n\n", Stars[star]->name, Stars[star]->pnames[pnum]);
469 const auto &s = smap.get(x, y);
471 switch (s.condition) {
472 case SectorType::SEC_WASTED:
474 case SectorType::SEC_SEA:
476 case SectorType::SEC_LAND:
478 case SectorType::SEC_MOUNT:
480 case SectorType::SEC_GAS:
482 case SectorType::SEC_PLATED:
484 case SectorType::SEC_DESERT:
486 case SectorType::SEC_FOREST:
488 case SectorType::SEC_ICE:
static int db_Intelligence[RACIAL_TYPES]
Planet getplanet(const starnum_t star, const planetnum_t pnum)
static double db_Metabolism[RACIAL_TYPES]
void PermuteSects(const Planet &planet)
static double db_Mass[RACIAL_TYPES]
void warn(const player_t, const governor_t, const std::string &)
static double db_Adventurism[RACIAL_TYPES]
void putsector(const Sector &s, const Planet &p, const int x, const int y)
bool notify(const player_t, const governor_t, const std::string &)
static char desshow(const int x, const int y, SectorMap &)
static int db_Fighters[RACIAL_TYPES]
void putstar(startype *s, starnum_t snum)
void getsdata(struct stardata *S)
void putplanet(const Planet &p, startype *star, const int pnum)
void getstar(startype **s, int star)
static int Max_Sexes[RACIAL_TYPES]
SectorMap getsmap(const Planet &p)
int Getxysect(const Planet &p, int *x, int *y, int r)
static int Min_Sexes[RACIAL_TYPES]
int maxsupport(const Race *r, const Sector &s, const double c, const int toxic)
static int Thing[RACIAL_TYPES]
static double db_Birthrate[RACIAL_TYPES]