11 #include "gb/GB_server.h" 12 #include "gb/buffers.h" 13 #include "gb/commands/orbit.h" 14 #include "gb/files_shl.h" 16 #include "gb/getplace.h" 20 #include "gb/shlmisc.h" 21 #include "gb/tweakables.h" 22 #include "gb/utils/rand.h" 25 static void show_map(
const player_t,
const governor_t,
const starnum_t,
26 const planetnum_t,
const Planet &);
28 void map(
const command_t &argv, GameObj &g) {
29 const player_t Playernum = g.player;
30 const governor_t Governor = g.governor;
33 if (argv.size() > 1) {
34 where = getplace(g, argv[1], 0);
36 where = getplace(g,
"", 0);
39 if (where.err)
return;
41 switch (where.level) {
42 case ScopeLevel::LEVEL_SHIP:
43 g.out <<
"Bad scope.\n";
45 case ScopeLevel::LEVEL_PLAN: {
48 if (Stars[where.snum]->stability > 50)
49 g.out <<
"WARNING! This planet's primary is unstable.\n";
56 static void show_map(
const player_t Playernum,
const governor_t Governor,
57 const starnum_t snum,
const planetnum_t pnum,
70 auto Race = races[Playernum - 1];
72 if (!Race->governor[Governor].toggle.geography) {
75 iq = !!p.info[Playernum - 1].numsectsowned;
77 Shiplist shiplist{p.ships};
78 for (
const auto &s : shiplist) {
79 if (s.owner == Playernum && authorized(Governor, s) &&
80 (s.popn || (s.type == ShipType::OTYPE_PROBE)))
82 if (s.alive && landed(s)) shiplocs[s.land_x][s.land_y] = Shipltrs[s.type];
88 sprintf(buf,
"%s;", Stars[snum]->pnames[pnum]);
91 sprintf(buf,
"%d;%d;%d;", p.Maxx, p.Maxy, show);
95 for (
const auto §or : smap) {
96 bool owned1 = (sector.owner == Race->governor[Governor].toggle.highlight);
97 if (shiplocs[sector.x][sector.y] && iq) {
98 if (Race->governor[Governor].toggle.color)
99 sprintf(buf,
"%c%c", (
char)(sector.owner +
'?'),
100 shiplocs[sector.x][sector.y]);
102 if (owned1 && Race->governor[Governor].toggle.inverse)
103 sprintf(buf,
"1%c", shiplocs[sector.x][sector.y]);
105 sprintf(buf,
"0%c", shiplocs[sector.x][sector.y]);
108 if (Race->governor[Governor].toggle.color)
109 sprintf(buf,
"%c%c", (
char)(sector.owner +
'?'),
110 desshow(Playernum, Governor, Race, sector));
112 if (owned1 && Race->governor[Governor].toggle.inverse)
113 sprintf(buf,
"1%c", desshow(Playernum, Governor, Race, sector));
115 sprintf(buf,
"0%c", desshow(Playernum, Governor, Race, sector));
120 strcat(output,
"\n");
121 notify(Playernum, Governor, output);
124 sprintf(temp,
"Type: %8s Sects %7s: %3u Aliens:", Planet_types[p.type],
125 Race->Metamorph ?
"covered" :
"owned",
126 p.info[Playernum - 1].numsectsowned);
130 if (p.info[i - 1].numsectsowned && i != Playernum) {
132 sprintf(buf,
"%c%d",
isset(Race->atwar, i) ?
'*' :
' ', i);
135 if (!f) strcat(temp,
"(none)");
137 strcat(temp, R"(???)");
139 notify(Playernum, Governor, temp);
140 sprintf(temp,
" Guns : %3d Mob Points : %ld\n",
141 p.info[Playernum - 1].guns, p.info[Playernum - 1].mob_points);
142 notify(Playernum, Governor, temp);
143 sprintf(temp,
" Mobilization : %3d (%3d) Compatibility: %.2f%%",
144 p.info[Playernum - 1].comread, p.info[Playernum - 1].mob_set,
145 compatibility(p, Race));
146 if (p.conditions[
TOXIC] > 50) {
147 sprintf(buf,
" (%d%% TOXIC)", p.conditions[
TOXIC]);
151 notify(Playernum, Governor, temp);
152 sprintf(temp,
"Resource stockpile : %-9lu Fuel stockpile: %u\n",
153 p.info[Playernum - 1].resource, p.info[Playernum - 1].fuel);
154 notify(Playernum, Governor, temp);
155 sprintf(temp,
" Destruct cap : %-9u%18s: %-5lu (%lu/%u)\n",
156 p.info[Playernum - 1].destruct,
157 Race->Metamorph ?
"Tons of biomass" :
"Total Population",
158 p.info[Playernum - 1].popn, p.popn,
159 round_rand(.01 * (100. - p.conditions[
TOXIC]) * p.maxpopn));
160 notify(Playernum, Governor, temp);
161 sprintf(temp,
" Crystals : %-9u%18s: %-5lu (%lu)\n",
162 p.info[Playernum - 1].crystals,
"Ground forces",
163 p.info[Playernum - 1].troops, p.troops);
164 notify(Playernum, Governor, temp);
165 sprintf(temp,
"%ld Total Resource Deposits Tax rate %u%% New %u%%\n",
166 p.total_resources, p.info[Playernum - 1].tax,
167 p.info[Playernum - 1].newtax);
168 notify(Playernum, Governor, temp);
169 sprintf(temp,
"Estimated Production Next Update : %.2f\n",
170 p.info[Playernum - 1].est_production);
171 notify(Playernum, Governor, temp);
173 sprintf(temp,
" ENSLAVED to player %d\n", p.slaved_to);
174 notify(Playernum, Governor, temp);
179 char desshow(
const player_t Playernum,
const governor_t Governor,
const Race *r,
181 if (s.troops && !r->governor[Governor].toggle.geography) {
182 if (s.owner == Playernum)
return CHAR_MY_TROOPS;
183 if (
isset(r->allied, s.owner))
return CHAR_ALLIED_TROOPS;
184 if (
isset(r->atwar, s.owner))
return CHAR_ATWAR_TROOPS;
186 return CHAR_NEUTRAL_TROOPS;
189 if (s.owner && !r->governor[Governor].toggle.geography &&
190 !r->governor[Governor].toggle.color) {
191 if (!r->governor[Governor].toggle.inverse ||
192 s.owner != r->governor[Governor].toggle.highlight) {
193 if (!r->governor[Governor].toggle.double_digits)
194 return s.owner % 10 +
'0';
196 if (s.owner < 10 || s.x % 2)
return s.owner % 10 +
'0';
198 return s.owner / 10 +
'0';
202 if (s.crystals && (r->discoveries[
D_CRYSTAL] || r->God))
return CHAR_CRYSTAL;
204 switch (s.condition) {
205 case SectorType::SEC_WASTED:
207 case SectorType::SEC_SEA:
209 case SectorType::SEC_LAND:
211 case SectorType::SEC_MOUNT:
213 case SectorType::SEC_GAS:
215 case SectorType::SEC_PLATED:
217 case SectorType::SEC_ICE:
219 case SectorType::SEC_DESERT:
221 case SectorType::SEC_FOREST:
void map(const command_t &argv, GameObj &g)
Planet getplanet(const starnum_t star, const planetnum_t pnum)
static void show_map(const player_t, const governor_t, const starnum_t, const planetnum_t, const Planet &)
SectorMap getsmap(const Planet &p)
char desshow(const player_t Playernum, const governor_t Governor, const Race *r, const Sector &s)