5 #include "gb/explore.h" 11 #include "gb/GB_server.h" 12 #include "gb/buffers.h" 13 #include "gb/files_shl.h" 14 #include "gb/getplace.h" 21 #include "gb/tweakables.h" 24 void distance(
const command_t &argv, GameObj &g) {
25 const player_t Playernum = g.player;
26 const governor_t Governor = g.governor;
35 if (argv.size() < 3) {
36 g.out <<
"Syntax: 'distance <from> <to>'.\n";
40 from = getplace(g, argv[1], 1);
42 sprintf(buf,
"Bad scope '%s'.\n", argv[1].c_str());
43 notify(Playernum, Governor, buf);
46 to = getplace(g, argv[2], 1);
48 sprintf(buf,
"Bad scope '%s'.\n", argv[2].c_str());
49 notify(Playernum, Governor, buf);
57 if (from.level == ScopeLevel::LEVEL_SHIP) {
58 auto ship = getship(from.shipno);
59 if (ship->owner != Playernum) {
60 g.out <<
"Nice try.\n";
65 }
else if (from.level == ScopeLevel::LEVEL_PLAN) {
67 x0 = p.xpos + Stars[from.snum]->xpos;
68 y0 = p.ypos + Stars[from.snum]->ypos;
69 }
else if (from.level == ScopeLevel::LEVEL_STAR) {
70 x0 = Stars[from.snum]->xpos;
71 y0 = Stars[from.snum]->ypos;
74 if (to.level == ScopeLevel::LEVEL_SHIP) {
75 auto ship = getship(to.shipno);
76 if (ship->owner != Playernum) {
77 g.out <<
"Nice try.\n";
82 }
else if (to.level == ScopeLevel::LEVEL_PLAN) {
84 x1 = p.xpos + Stars[to.snum]->xpos;
85 y1 = p.ypos + Stars[to.snum]->ypos;
86 }
else if (to.level == ScopeLevel::LEVEL_STAR) {
87 x1 = Stars[to.snum]->xpos;
88 y1 = Stars[to.snum]->ypos;
91 dist = sqrt(
Distsq(x0, y0, x1, y1));
92 sprintf(buf,
"Distance = %f\n", dist);
93 notify(Playernum, Governor, buf);
97 const player_t Playernum = g.player;
98 const governor_t Governor = g.governor;
109 max = std::stoi(argv[1]);
113 for (i = 0; i < Sdata.numstars; i++) {
114 dist = sqrt(
Distsq(Stars[i]->xpos, Stars[i]->ypos, x, y));
115 if ((
int)dist <= max) {
116 sprintf(buf,
"(%2d) %20.20s (%8.0f,%8.0f) %7.0f\n", i, Stars[i]->name,
117 Stars[i]->xpos, Stars[i]->ypos, dist);
118 notify(Playernum, Governor, buf);
124 const player_t Playernum = g.player;
125 const governor_t Governor = g.governor;
133 if (argv.size() == 2) {
134 where = getplace(g, argv[1], 0);
136 sprintf(buf,
"explore: bad scope.\n");
137 notify(Playernum, Governor, buf);
140 if (where.level == ScopeLevel::LEVEL_SHIP ||
141 where.level == ScopeLevel::LEVEL_UNIV) {
142 sprintf(buf,
"Bad scope '%s'.\n", argv[1].c_str());
143 notify(Playernum, Governor, buf);
149 Race = races[Playernum - 1];
152 sprintf(buf,
" ========== Exploration Report ==========\n");
153 notify(Playernum, Governor, buf);
154 sprintf(buf,
" Global action points : [%2d]\n", Sdata.AP[Playernum - 1]);
155 notify(Playernum, Governor, buf);
158 " Star (stability)[AP] # Planet [Attributes] Type (Compatibility)\n");
159 notify(Playernum, Governor, buf);
160 for (starnum_t star = 0; star < Sdata.numstars; star++)
161 if ((starq == -1) || (starq == star)) {
163 if (
isset(Stars[star]->explored, Playernum))
164 for (planetnum_t i = 0; i < Stars[star]->numplanets; i++) {
168 sprintf(buf,
"\n%13s (%2d)[%2d]\n", Stars[star]->name,
169 Stars[star]->stability, Stars[star]->AP[Playernum - 1]);
170 notify(Playernum, Governor, buf);
172 sprintf(buf,
"\n%13s (/?/?)[%2d]\n", Stars[star]->name,
173 Stars[star]->AP[Playernum - 1]);
174 notify(Playernum, Governor, buf);
178 sprintf(buf,
"\t\t ");
179 notify(Playernum, Governor, buf);
181 sprintf(buf,
" #%d. %-15s [ ", i + 1, Stars[star]->pnames[i]);
182 notify(Playernum, Governor, buf);
183 if (pl.info[Playernum - 1].explored) {
185 notify(Playernum, Governor, buf);
186 if (pl.info[Playernum - 1].autorep) {
187 sprintf(buf,
"Rep ");
188 notify(Playernum, Governor, buf);
190 if (pl.info[Playernum - 1].numsectsowned) {
191 sprintf(buf,
"Inhab ");
192 notify(Playernum, Governor, buf);
195 sprintf(buf,
"SLAVED ");
196 notify(Playernum, Governor, buf);
198 for (j = 1; j <= Num_races; j++)
199 if (j != Playernum && pl.info[j - 1].numsectsowned) {
200 sprintf(buf,
"%d ", j);
201 notify(Playernum, Governor, buf);
203 if (pl.conditions[
TOXIC] > 70) {
204 sprintf(buf,
"TOXIC ");
205 notify(Playernum, Governor, buf);
207 sprintf(buf,
"] %s %2.0f%%\n", Planet_types[pl.type],
209 notify(Playernum, Governor, buf);
211 sprintf(buf,
"No Data ]\n");
212 notify(Playernum, Governor, buf);
#define Distsq(x1, y1, x2, y2)
void exploration(const command_t &argv, GameObj &g)
Planet getplanet(const starnum_t star, const planetnum_t pnum)
void star_locations(const command_t &argv, GameObj &g)
#define TECH_SEE_STABILITY
double compatibility(const Planet &planet, const Race *race)
void distance(const command_t &argv, GameObj &g)
void getsdata(struct stardata *S)
void getstar(startype **s, int star)