7 #include "gb/doplanet.h" 13 #include "gb/GB_server.h" 15 #include "gb/bombard.h" 16 #include "gb/buffers.h" 18 #include "gb/dosector.h" 19 #include "gb/doship.h" 20 #include "gb/doturn.h" 21 #include "gb/files_shl.h" 26 #include "gb/moveship.h" 31 #include "gb/shlmisc.h" 32 #include "gb/shootblast.h" 35 #include "gb/tweakables.h" 36 #include "gb/utils/rand.h" 39 static void do_dome(Ship *, SectorMap &);
40 static void do_quarry(Ship *, Planet *, SectorMap &);
45 static void plow(Ship *, Planet *, SectorMap &);
46 static void terraform(Ship *, Planet *, SectorMap &);
48 int doplanet(
const int starnum, Planet *planet,
const int planetnum) {
59 unsigned char allmod = 0;
60 unsigned char allexp = 0;
64 bzero((
char *)Sectinfo,
sizeof(Sectinfo));
66 bzero((
char *)avg_mob,
sizeof(avg_mob));
67 bzero((
char *)sects_gained,
sizeof(sects_gained));
68 bzero((
char *)sects_lost,
sizeof(sects_lost));
69 bzero((
char *)prod_res,
sizeof(prod_res));
70 bzero((
char *)prod_fuel,
sizeof(prod_fuel));
71 bzero((
char *)prod_destruct,
sizeof(prod_destruct));
72 bzero((
char *)prod_crystals,
sizeof(prod_crystals));
74 tot_resdep = prod_eff = prod_mob = tot_captured = 0;
81 planet->total_resources = 0;
84 for (i = 1; i <= Num_races; i++) {
85 Compat[i - 1] = compatibility(*planet, races[i - 1]);
86 planet->info[i - 1].numsectsowned = 0;
87 planet->info[i - 1].troops = 0;
88 planet->info[i - 1].popn = 0;
89 planet->info[i - 1].est_production = 0.0;
90 prod_crystals[i - 1] = 0;
92 prod_destruct[i - 1] = 0;
97 shipno = planet->ships;
100 if (ship->alive && !ship->rad) {
103 switch (ship->type) {
104 case ShipType::OTYPE_VN:
105 planet_doVN(ship, planet, smap);
107 case ShipType::OTYPE_BERS:
108 if (!ship->destruct || !ship->bombard)
109 planet_doVN(ship, planet, smap);
113 case ShipType::OTYPE_TERRA:
114 if ((ship->on && landed(*ship) && ship->popn)) {
117 else if (!ship->notified) {
123 case ShipType::OTYPE_PLOW:
124 if (ship->on && landed(*ship)) {
127 else if (!ship->notified) {
131 }
else if (ship->on) {
132 sprintf(buf,
"K%lu is not landed.", ship->number);
133 push_telegram(ship->owner, ship->governor, buf);
135 sprintf(buf,
"K%lu is not switched on.", ship->number);
136 push_telegram(ship->owner, ship->governor, buf);
139 case ShipType::OTYPE_DOME:
140 if (ship->on && landed(*ship)) {
144 sprintf(buf,
"Y%lu does not have enough resources.",
146 push_telegram(ship->owner, ship->governor, buf);
148 }
else if (ship->on) {
149 sprintf(buf,
"Y%lu is not landed.", ship->number);
150 push_telegram(ship->owner, ship->governor, buf);
152 sprintf(buf,
"Y%lu is not switched on.", ship->number);
153 push_telegram(ship->owner, ship->governor, buf);
156 case ShipType::OTYPE_WPLANT:
163 sprintf(buf,
"W%lu does not have enough resources.",
165 push_telegram(ship->owner, ship->governor, buf);
167 sprintf(buf,
"W%lu does not have enough fuel.", ship->number);
168 push_telegram(ship->owner, ship->governor, buf);
172 sprintf(buf,
"W%lu is not landed.", ship->number);
173 push_telegram(ship->owner, ship->governor, buf);
176 case ShipType::OTYPE_QUARRY:
177 if ((ship->on && landed(*ship) && ship->popn)) {
180 else if (!ship->notified) {
186 sprintf(buf,
"q%lu is not switched on.", ship->number);
188 if (!landed(*ship)) {
189 sprintf(buf,
"q%lu is not landed.", ship->number);
192 sprintf(buf,
"q%lu does not have workers aboard.", ship->number);
194 push_telegram(ship->owner, ship->governor, buf);
201 if (!landed(*ship) && planet->type == PlanetType::GASGIANT) {
202 switch (ship->type) {
203 case ShipType::STYPE_TANKER:
206 case ShipType::STYPE_HABITAT:
213 fadd = std::min((
double)max_fuel(*ship) - ship->fuel, fadd);
217 shipno = ship->nextship;
222 planet->conditions[
TEMP] = planet->conditions[
RTEMP] +
223 Stinfo[starnum][planetnum].temp_add +
229 auto &p = smap.get(x, y);
231 if (p.owner && (p.popn || p.troops)) {
233 if (!Stars[starnum]->nova_stage) {
242 if (Stars[starnum]->nova_stage == 14)
243 p.popn = p.owner = p.troops = 0;
245 p.popn = round_rand((
double)p.popn * .50);
247 Sectinfo[x][y].done = 1;
250 if ((!p.popn && !p.troops) || !p.owner) {
252 p.popn = p.troops = 0;
294 auto &p = smap.get(x, y);
295 if (p.owner) planet->info[p.owner - 1].numsectsowned++;
298 if (planet->expltimer >= 1) planet->expltimer--;
299 if (!Stars[starnum]->nova_stage && !planet->expltimer) {
300 if (!planet->expltimer) planet->expltimer = 5;
301 for (i = 1; !Claims && !allexp && i <= Num_races; i++) {
303 if (planet->info[i - 1].numsectsowned)
304 while (!Claims && !allexp && timer > 0) {
310 o &= Sectinfo[x][y].explored;
311 auto &p = smap.get(x, y);
312 if (((Sectinfo[x][y].explored == i) && !(random() & 02)) &&
313 (!p.owner && p.condition != SectorType::SEC_WASTED &&
314 p.condition == races[i - 1]->likesbest)) {
317 p.popn = races[i - 1]->number_sexes;
328 if (allexp) planet->expltimer = 5;
333 nukex = int_rand(0, (
int)planet->Maxx - 1);
334 nukey = int_rand(0, (
int)planet->Maxy - 1);
335 auto &p = smap.get(nukex, nukey);
336 p.condition = SectorType::SEC_WASTED;
337 p.popn = p.owner = p.troops = 0;
340 for (i = 1; i <= Num_races; i++)
341 if (sects_gained[i - 1] || sects_lost[i - 1]) {
342 sprintf(telegram_buf,
"****** Report: Planet /%s/%s ******\n",
343 Stars[starnum]->name, Stars[starnum]->pnames[planetnum]);
344 sprintf(buf,
" WAR STATUS: %d sectors gained, %d sectors lost.\n",
345 sects_gained[i - 1], sects_lost[i - 1]);
346 strcat(telegram_buf, buf);
347 push_telegram(i, (
int)Stars[starnum]->governor[i - 1], telegram_buf);
349 for (i = 1; i <= Num_races; i++) {
350 planet->info[i - 1].prod_crystals = prod_crystals[i - 1];
351 planet->info[i - 1].prod_res = prod_res[i - 1];
352 planet->info[i - 1].prod_fuel = prod_fuel[i - 1];
353 planet->info[i - 1].prod_dest = prod_destruct[i - 1];
354 if (planet->info[i - 1].autorep) {
355 planet->info[i - 1].autorep--;
356 sprintf(telegram_buf,
"\nFrom /%s/%s\n", Stars[starnum]->name,
357 Stars[starnum]->pnames[planetnum]);
359 if (Stinfo[starnum][planetnum].temp_add) {
360 sprintf(buf,
"Temp: %d to %d\n", planet->conditions[
RTEMP],
361 planet->conditions[
TEMP]);
362 strcat(telegram_buf, buf);
364 sprintf(buf,
"Total Prod: %ldr %ldf %ldd\n", prod_res[i - 1],
365 prod_fuel[i - 1], prod_destruct[i - 1]);
366 strcat(telegram_buf, buf);
367 if (prod_crystals[i - 1]) {
368 sprintf(buf,
" %ld crystals found\n", prod_crystals[i - 1]);
369 strcat(telegram_buf, buf);
372 sprintf(buf,
"%ld sectors captured\n", tot_captured);
373 strcat(telegram_buf, buf);
375 if (Stars[starnum]->nova_stage) {
376 sprintf(buf,
"This planet's primary is in a Stage %d nova.\n",
377 Stars[starnum]->nova_stage);
378 strcat(telegram_buf, buf);
382 sprintf(buf,
"Environmental damage on sector %d,%d\n", nukex, nukey);
383 strcat(telegram_buf, buf);
385 if (planet->slaved_to) {
386 sprintf(buf,
"ENSLAVED to player %d\n", planet->slaved_to);
387 strcat(telegram_buf, buf);
389 push_telegram(i, Stars[starnum]->governor[i - 1], telegram_buf);
394 if (Stars[starnum]->nova_stage == 1) {
395 sprintf(telegram_buf,
"BULLETIN from /%s/%s\n", Stars[starnum]->name,
396 Stars[starnum]->pnames[planetnum]);
397 sprintf(buf,
"\nStar %s is undergoing nova.\n", Stars[starnum]->name);
398 strcat(telegram_buf, buf);
399 if (planet->type == PlanetType::EARTH ||
400 planet->type == PlanetType::WATER ||
401 planet->type == PlanetType::FOREST) {
402 sprintf(buf,
"Seas and rivers are boiling!\n");
403 strcat(telegram_buf, buf);
405 sprintf(buf,
"This planet must be evacuated immediately!\n%c",
TELEG_DELIM);
406 strcat(telegram_buf, buf);
407 for (i = 1; i <= Num_races; i++)
408 if (planet->info[i - 1].numsectsowned)
409 push_telegram(i, Stars[starnum]->governor[i - 1], telegram_buf);
417 planet->total_resources = 0;
419 for (i = 1; i <= Num_races; i++) {
420 planet->info[i - 1].numsectsowned = 0;
421 planet->info[i - 1].popn = 0;
422 planet->info[i - 1].troops = 0;
427 auto &p = smap.get(x, y);
429 planet->info[p.owner - 1].numsectsowned++;
430 planet->info[p.owner - 1].troops += p.troops;
431 planet->info[p.owner - 1].popn += p.popn;
432 planet->popn += p.popn;
433 planet->troops += p.troops;
434 planet->maxpopn += maxsupport(races[p.owner - 1], p, Compat[p.owner - 1],
435 planet->conditions[
TOXIC]);
436 Power[p.owner - 1].troops += p.troops;
437 Power[p.owner - 1].popn += p.popn;
438 Power[p.owner - 1].sum_eff += p.eff;
439 Power[p.owner - 1].sum_mob += p.mobilization;
440 starpopns[starnum][p.owner - 1] += p.popn;
445 planet->total_resources += p.resource;
449 if (planet->slaved_to) {
450 if (planet->info[planet->slaved_to - 1].popn > planet->popn / 1000) {
451 for (i = 1; i <= Num_races; i++)
453 if (planet->info[i - 1].numsectsowned) {
454 planet->info[planet->slaved_to - 1].resource += prod_res[i - 1];
456 planet->info[planet->slaved_to - 1].fuel += prod_fuel[i - 1];
457 prod_fuel[i - 1] = 0;
458 planet->info[planet->slaved_to - 1].destruct += prod_destruct[i - 1];
459 prod_destruct[i - 1] = 0;
464 i = planet->popn / 1000 + 1;
466 auto &p = smap.get(int_rand(0, (
int)planet->Maxx - 1),
467 int_rand(0, (
int)planet->Maxy - 1));
468 if (p.popn + p.troops) {
469 p.owner = p.popn = p.troops = 0;
470 p.condition = SectorType::SEC_WASTED;
476 if (Stinfo[starnum][planetnum].intimidated && random() & 01) {
477 auto &p = smap.get(x, y);
478 if (p.owner == planet->slaved_to) {
482 p.condition = SectorType::SEC_WASTED;
487 sprintf(telegram_buf,
"\nThere has been a SLAVE REVOLT on /%s/%s!\n",
488 Stars[starnum]->name, Stars[starnum]->pnames[planetnum]);
489 strcat(telegram_buf, buf);
491 "All population belonging to player #%d on the planet have " 494 strcat(telegram_buf, buf);
495 sprintf(buf,
"Productions now go to their rightful owners.\n");
496 strcat(telegram_buf, buf);
497 for (i = 1; i <= Num_races; i++)
498 if (planet->info[i - 1].numsectsowned)
499 push_telegram(i, (
int)Stars[starnum]->governor[i - 1], telegram_buf);
500 planet->slaved_to = 0;
505 for (i = 1; i <= Num_races; i++)
506 if (planet->info[i - 1].numsectsowned) {
507 planet->info[i - 1].fuel += prod_fuel[i - 1];
508 planet->info[i - 1].resource += prod_res[i - 1];
509 planet->info[i - 1].destruct += prod_destruct[i - 1];
510 planet->info[i - 1].crystals += prod_crystals[i - 1];
513 if (races[i - 1]->Gov_ship) {
514 planet->info[i - 1].prod_money =
516 (
double)planet->info[i - 1].popn);
517 races[i - 1]->governor[Stars[starnum]->governor[i - 1]].money +=
518 planet->info[i - 1].prod_money;
519 planet->info[i - 1].tax += std::min(
520 (
int)planet->info[i - 1].newtax - (
int)planet->info[i - 1].tax, 5);
522 planet->info[i - 1].prod_money = 0;
523 races[i - 1]->governor[Stars[starnum]->governor[i - 1]].income +=
524 planet->info[i - 1].prod_money;
527 if (races[i - 1]->Gov_ship) {
528 if (races[i - 1]->governor[Stars[starnum]->governor[i - 1]].money >=
529 planet->info[i - 1].tech_invest) {
530 planet->info[i - 1].prod_tech =
532 (
int)(planet->info[i - 1].popn)
);
533 races[i - 1]->governor[Stars[starnum]->governor[i - 1]].money -=
534 planet->info[i - 1].tech_invest;
535 races[i - 1]->tech += planet->info[i - 1].prod_tech;
536 races[i - 1]->governor[Stars[starnum]->governor[i - 1]].cost_tech +=
537 planet->info[i - 1].tech_invest;
539 planet->info[i - 1].prod_tech = 0;
541 planet->info[i - 1].prod_tech = 0;
544 if (planet->info[i - 1].tox_thresh > 0 &&
545 planet->conditions[
TOXIC] >= planet->info[i - 1].tox_thresh &&
546 planet->info[i - 1].resource >=
547 Shipcost(ShipType::OTYPE_TOXWC, races[i - 1])) {
551 ships = (Ship **)realloc(ships,
552 (
unsigned)((Num_ships + 1) *
sizeof(Ship *)));
553 s2 = ships[Num_ships] = (Ship *)malloc(
sizeof(Ship));
554 bzero((
char *)s2,
sizeof(Ship));
555 s2->number = Num_ships;
556 s2->type = ShipType::OTYPE_TOXWC;
558 s2->armor = Shipdata[ShipType::OTYPE_TOXWC][ABIL_ARMOR];
559 s2->guns = GTYPE_NONE;
560 s2->primary = Shipdata[ShipType::OTYPE_TOXWC][ABIL_GUNS];
561 s2->primtype = Shipdata[ShipType::OTYPE_TOXWC][ABIL_PRIMARY];
562 s2->secondary = Shipdata[ShipType::OTYPE_TOXWC][ABIL_GUNS];
563 s2->sectype = Shipdata[ShipType::OTYPE_TOXWC][ABIL_SECONDARY];
564 s2->max_crew = Shipdata[ShipType::OTYPE_TOXWC][ABIL_MAXCREW];
565 s2->max_resource = Shipdata[ShipType::OTYPE_TOXWC][ABIL_CARGO];
566 s2->max_fuel = Shipdata[ShipType::OTYPE_TOXWC][ABIL_FUELCAP];
567 s2->max_destruct = Shipdata[ShipType::OTYPE_TOXWC][ABIL_DESTCAP];
568 s2->max_speed = Shipdata[ShipType::OTYPE_TOXWC][ABIL_SPEED];
569 s2->build_cost = Shipcost(ShipType::OTYPE_TOXWC, races[i - 1]);
570 s2->size = ship_size(*s2);
572 s2->mass = s2->base_mass;
575 sprintf(s2->name,
"Scum%04ld", Num_ships);
577 insert_sh_plan(planet, s2);
579 s2->whatorbits = ScopeLevel::LEVEL_PLAN;
580 s2->storbits = starnum;
581 s2->pnumorbits = planetnum;
583 s2->xpos = Stars[starnum]->xpos + planet->xpos;
584 s2->ypos = Stars[starnum]->ypos + planet->ypos;
585 s2->land_x = int_rand(0, (
int)planet->Maxx - 1);
586 s2->land_y = int_rand(0, (
int)planet->Maxy - 1);
587 s2->whatdest = ScopeLevel::LEVEL_PLAN;
588 s2->deststar = starnum;
589 s2->destpnum = planetnum;
591 s2->governor = Stars[starnum]->governor[i - 1];
593 planet->conditions[
TOXIC] -= t;
594 s2->special.waste.toxic = t;
598 if (planet->maxpopn > 0 && planet->conditions[
TOXIC] < 100)
599 planet->conditions[
TOXIC] += planet->popn / planet->maxpopn;
601 if (planet->conditions[
TOXIC] > 100)
602 planet->conditions[
TOXIC] = 100;
603 else if (planet->conditions[
TOXIC] < 0)
604 planet->conditions[
TOXIC] = 0;
606 for (i = 1; i <= Num_races; i++) {
607 Power[i - 1].resource += planet->info[i - 1].resource;
608 Power[i - 1].destruct += planet->info[i - 1].destruct;
609 Power[i - 1].fuel += planet->info[i - 1].fuel;
610 Power[i - 1].sectors_owned += planet->info[i - 1].numsectsowned;
611 Power[i - 1].planets_owned += !!planet->info[i - 1].numsectsowned;
612 if (planet->info[i - 1].numsectsowned) {
614 planet->info[i - 1].mob_points = avg_mob[i - 1];
615 avg_mob[i - 1] /= (
int)planet->info[i - 1].numsectsowned;
616 planet->info[i - 1].comread = avg_mob[i - 1];
618 planet->info[i - 1].comread = 0;
619 planet->info[i - 1].guns =
planet_guns(planet->info[i - 1].mob_points
);
630 if (ship->shipclass[ship->special.terraform.index] ==
's') {
634 if (ship->shipclass[ship->special.terraform.index] ==
'c')
635 ship->special.terraform.index = 0;
637 (
void)
get_move(ship->shipclass[ship->special.terraform.index]
, ship->land_x
, 638 ship->land_y
, &x
, &y
, *planet
);
639 if (y >= planet->Maxy) {
644 if (planet->Maxy == 1) y = 0;
645 if (ship->shipclass[ship->special.terraform.index + 1] !=
'\0') {
646 ++ship->special.terraform.index;
647 if ((ship->shipclass[ship->special.terraform.index + 1] ==
'\0') &&
649 char teleg_buf[1000];
651 sprintf(teleg_buf,
"%s is out of orders at %s.",
652 ship_to_string(*ship).c_str(), prin_ship_orbits(ship));
653 push_telegram((
int)(ship->owner), (
int)ship->governor, teleg_buf);
656 ship->shipclass[ship->special.terraform.index] +=
657 ((ship->shipclass[ship->special.terraform.index] >
'5') ? -6 : 6);
663 static void terraform(Ship *ship, Planet *planet, SectorMap &smap) {
666 auto &s = smap.get(ship->land_x, ship->land_y);
667 if ((s.condition != races[ship->owner - 1]->likesbest) &&
668 (s.condition != SectorType::SEC_GAS) &&
669 success((100 - (
int)ship->damage) * ship->popn / ship->max_crew)) {
672 s.condition = races[ship->owner - 1]->likesbest;
675 s.popn = s.troops = 0;
678 if ((random() & 01) && (planet->conditions[
TOXIC] < 100))
679 planet->conditions[
TOXIC] += 1;
684 }
else if (s.condition == races[ship->owner - 1]->likesbest) {
685 sprintf(buf,
" T%lu is full of zealots!!!", ship->number);
686 push_telegram(ship->owner, ship->governor, buf);
688 if (s.condition == SectorType::SEC_GAS) {
689 sprintf(buf,
" T%lu is trying to terraform gas.", ship->number);
690 push_telegram(ship->owner, ship->governor, buf);
694 static void plow(Ship *ship, Planet *planet, SectorMap &smap) {
696 auto &s = smap.get(ship->land_x, ship->land_y);
697 if ((races[ship->owner - 1]->likes[s.condition]) && (s.fert < 100)) {
698 int adjust = round_rand(
699 10 * (0.01 * (100.0 - (
double)ship->damage) * (
double)ship->popn) /
706 s.fert = std::min(100u, s.fert + adjust);
708 sprintf(buf,
" K%lu is full of zealots!!!", ship->number);
709 push_telegram(ship->owner, ship->governor, buf);
712 if ((random() & 01) && (planet->conditions[
TOXIC] < 100))
713 planet->conditions[
TOXIC] += 1;
717 static void do_dome(Ship *ship, SectorMap &smap) {
720 auto &s = smap.get(ship->land_x, ship->land_y);
722 sprintf(buf,
" Y%lu is full of zealots!!!", ship->number);
723 push_telegram(ship->owner, ship->governor, buf);
726 adjust = round_rand(.05 * (100. - (
double)ship->damage) * (
double)ship->popn /
729 if (s.eff > 100) s.eff = 100;
733 static void do_quarry(Ship *ship, Planet *planet, SectorMap &smap) {
737 auto &s = smap.get(ship->land_x, ship->land_y);
745 s.condition = SectorType::SEC_WASTED;
746 prod = round_rand(races[ship->owner - 1]->metabolism * (
double)ship->popn /
747 (
double)ship->max_crew);
749 prod_res[ship->owner - 1] += prod;
750 tox = int_rand(0, int_rand(0, prod));
751 planet->conditions[
TOXIC] = std::min(100, planet->conditions[
TOXIC] + tox);
759 if (ship->whatdest == ScopeLevel::LEVEL_PLAN &&
760 ship->whatorbits == ScopeLevel::LEVEL_PLAN && !landed(*ship) &&
761 ship->storbits == ship->deststar && ship->pnumorbits == ship->destpnum) {
762 if (!bombard(ship, planet, races[ship->owner - 1]))
763 ship->destpnum = int_rand(0, Stars[ship->storbits]->numplanets - 1);
764 else if (Sdata.VN_hitlist[ship->special.mind.who_killed - 1] > 0)
765 --Sdata.VN_hitlist[ship->special.mind.who_killed - 1];
769 static void do_recover(Planet *planet,
int starnum,
int planetnum) {
777 int stolencrystals = 0;
778 int all_buddies_here = 1;
780 ownerbits[0] = ownerbits[1] = 0;
782 for (i = 1; i <= Num_races && all_buddies_here; i++) {
783 if (planet->info[i - 1].numsectsowned > 0) {
786 for (j = 1; j < i && all_buddies_here; j++)
787 if (
isset(ownerbits, j) && (!
isset(races[i - 1]->allied, j) ||
788 !
isset(races[j - 1]->allied, i)))
789 all_buddies_here = 0;
792 stolenres += planet->info[i - 1].resource;
793 stolendes += planet->info[i - 1].destruct;
794 stolenfuel += planet->info[i - 1].fuel;
795 stolencrystals += planet->info[i - 1].crystals;
799 if (all_buddies_here && owners != 0 &&
800 (stolenres > 0 || stolendes > 0 || stolenfuel > 0 ||
801 stolencrystals > 0)) {
811 int givencrystals = 0;
813 for (i = 1; i <= Num_races; i++)
814 if (
isset(ownerbits, i)) {
815 sprintf(telegram_buf,
"Recovery Report: Planet /%s/%s\n",
816 Stars[starnum]->name, Stars[starnum]->pnames[planetnum]);
817 push_telegram(i, (
int)Stars[starnum]->governor[i - 1], telegram_buf);
818 sprintf(telegram_buf,
"%-14.14s %5s %5s %5s %5s\n",
"",
"res",
"destr",
820 push_telegram(i, (
int)Stars[starnum]->governor[i - 1], telegram_buf);
823 for (i = 1; i <= Num_races && owners > 1; i++)
824 if (
isset(ownerbits, i)) {
825 if ((res = round_rand((
double)stolenres / shares)) + givenres >
827 res = stolenres - givenres;
828 if ((des = round_rand((
double)stolendes / shares)) + givendes >
830 des = stolendes - givendes;
831 if ((fuel = round_rand((
double)stolenfuel / shares)) + givenfuel >
833 fuel = stolenfuel - givenfuel;
834 if ((crystals = round_rand((
double)stolencrystals / shares)) +
837 crystals = stolencrystals - givencrystals;
838 planet->info[i - 1].resource += res;
840 planet->info[i - 1].destruct += des;
842 planet->info[i - 1].fuel += fuel;
844 planet->info[i - 1].crystals += crystals;
845 givencrystals += crystals;
848 sprintf(telegram_buf,
"%-14.14s %5d %5d %5d %5d", races[i - 1]->name,
849 res, des, fuel, crystals);
850 for (j = 1; j <= Num_races; j++)
851 if (
isset(ownerbits, j))
852 push_telegram(j, (
int)Stars[starnum]->governor[j - 1],
856 for (; i <= Num_races; i++)
857 if (
isset(ownerbits, i))
break;
858 if (i <= Num_races) {
859 res = stolenres - givenres;
860 des = stolendes - givendes;
861 fuel = stolenfuel - givenfuel;
862 crystals = stolencrystals - givencrystals;
864 planet->info[i - 1].resource += res;
865 planet->info[i - 1].destruct += des;
866 planet->info[i - 1].fuel += fuel;
867 planet->info[i - 1].crystals += crystals;
868 sprintf(telegram_buf,
"%-14.14s %5d %5d %5d %5d", races[i - 1]->name, res,
869 des, fuel, crystals);
870 sprintf(buf,
"%-14.14s %5d %5d %5d %5d\n",
"Total:", stolenres, stolendes,
871 stolenfuel, stolencrystals);
872 for (j = 1; j <= Num_races; j++)
873 if (
isset(ownerbits, j)) {
874 push_telegram(j, (
int)Stars[starnum]->governor[j - 1], telegram_buf);
875 push_telegram(j, (
int)Stars[starnum]->governor[j - 1], buf);
878 push_telegram(1, 0,
"Bug in stealing resources\n");
880 for (i = 2; i <= Num_races; i++)
881 if (!
isset(ownerbits, i)) {
882 planet->info[i - 1].resource = 0;
883 planet->info[i - 1].destruct = 0;
884 planet->info[i - 1].fuel = 0;
885 planet->info[i - 1].crystals = 0;
891 return (races[s.owner - 1]->metabolism * (
double)s.eff * (
double)s.eff /
void use_fuel(Ship *s, double amt)
static int moveship_onplanet(Ship *, Planet *)
static void do_recover(Planet *, int, int)
void rcv_fuel(Ship *s, double amt)
void explore(const Planet &, Sector &, int, int, int)
void PermuteSects(const Planet &planet)
static void do_quarry(Ship *, Planet *, SectorMap &)
void spread(const Planet &, Sector &, int, int, SectorMap &)
int do_weapon_plant(Ship *)
static void plow(Ship *, Planet *, SectorMap &)
#define FUEL_GAS_ADD_TANKER
#define FUEL_GAS_ADD_HABITAT
static double est_production(const Sector &)
void putsmap(SectorMap &map, Planet &p)
static void terraform(Ship *, Planet *, SectorMap &)
static void do_berserker(Ship *, Planet *)
double tech_prod(int investment, int popn)
int doplanet(const int, Planet *, const int)
int get_move(char direction, int x, int y, int *x2, int *y2, const Planet &planet)
void use_resource(Ship *s, int amt)
SectorMap getsmap(const Planet &p)
int Getxysect(const Planet &p, int *x, int *y, int r)
static void do_dome(Ship *, SectorMap &)
void produce(startype *, const Planet &, Sector &)