14 #include "gb/GB_server.h" 15 #include "gb/buffers.h" 17 #include "gb/files_shl.h" 19 #include "gb/getplace.h" 21 #include "gb/moveship.h" 23 #include "gb/shlmisc.h" 24 #include "gb/shootblast.h" 25 #include "gb/tweakables.h" 34 void order(
const command_t &argv, GameObj &g) {
35 player_t Playernum = g.player;
36 governor_t Governor = g.governor;
42 if (argv.size() == 1) {
44 nextshipno = start_shiplist(g,
"");
46 if (ship->owner == Playernum && authorized(Governor, *ship)) {
51 }
else if (argv.size() >= 2) {
53 nextshipno = start_shiplist(g, argv[1]);
55 if (in_list(Playernum, argv[1], *ship, &nextshipno) &&
56 authorized(Governor, *ship)) {
57 if (argv.size() > 2) give_orders(g, argv, APcount, ship);
63 g.out <<
"I don't understand what you mean.\n";
67 static void give_orders(GameObj &g,
const command_t &argv,
int ,
69 player_t Playernum = g.player;
70 governor_t Governor = g.governor;
76 sprintf(buf,
"%s is irradiated (%d); it cannot be given orders.\n",
77 ship_to_string(*ship).c_str(), ship->rad);
78 notify(Playernum, Governor, buf);
81 if (ship->type != ShipType::OTYPE_TRANSDEV && !ship->popn &&
83 sprintf(buf,
"%s has no crew and is not a robotic ship.\n",
84 ship_to_string(*ship).c_str());
85 notify(Playernum, Governor, buf);
89 if (argv[2] ==
"defense") {
90 if (can_bombard(*ship)) {
92 ship->protect.planet = 0;
94 ship->protect.planet = 1;
96 notify(Playernum, Governor,
97 "That ship cannot be assigned those orders.\n");
100 }
else if (argv[2] ==
"scatter") {
101 if (ship->type != ShipType::STYPE_MISSILE) {
102 g.out <<
"Only missiles can be given this order.\n";
105 ship->special.impact.scatter = 1;
106 }
else if (argv[2] ==
"impact") {
109 if (ship->type != ShipType::STYPE_MISSILE) {
110 notify(Playernum, Governor,
111 "Only missiles can be designated for this.\n");
114 sscanf(argv[3].c_str(),
"%d,%d", &x, &y);
115 ship->special.impact.x = x;
116 ship->special.impact.y = y;
117 ship->special.impact.scatter = 0;
118 }
else if (argv[2] ==
"jump") {
120 notify(Playernum, Governor,
121 "That ship is docked. Use 'launch' or 'undock' first.\n");
124 if (ship->hyper_drive.has) {
125 if (argv[3] ==
"off")
126 ship->hyper_drive.on = 0;
128 if (ship->whatdest != ScopeLevel::LEVEL_STAR &&
129 ship->whatdest != ScopeLevel::LEVEL_PLAN) {
130 g.out <<
"Destination must be star or planet.\n";
133 ship->hyper_drive.on = 1;
134 ship->navigate.on = 0;
136 ship->hyper_drive.charge = 1;
137 ship->hyper_drive.ready = 1;
141 notify(Playernum, Governor,
142 "This ship does not have hyper drive capability.\n");
145 }
else if (argv[2] ==
"protect") {
147 sscanf(argv[3].c_str() + (argv[3][0] ==
'#'),
"%d", &j);
150 if (j == ship->number) {
151 g.out <<
"You can't do that.\n";
154 if (can_bombard(*ship)) {
156 ship->protect.on = 0;
158 ship->protect.on = 1;
159 ship->protect.ship = j;
162 g.out <<
"That ship cannot protect.\n";
165 }
else if (argv[2] ==
"navigate") {
166 if (argv.size() >= 5) {
167 ship->navigate.on = 1;
168 ship->navigate.bearing = std::stoi(argv[3]);
169 ship->navigate.turns = std::stoi(argv[4]);
171 ship->navigate.on = 0;
172 if (ship->hyper_drive.on) ship->hyper_drive.on = 0;
173 }
else if (argv[2] ==
"switch") {
174 if (ship->type == ShipType::OTYPE_FACTORY) {
175 g.out <<
"Use \"on\" to bring factory online.\n";
178 if (has_switch(*ship)) {
179 if (ship->whatorbits == ScopeLevel::LEVEL_SHIP) {
180 g.out <<
"That ship is being transported.\n";
183 ship->on = !ship->on;
185 sprintf(buf,
"That ship does not have an on/off setting.\n");
186 notify(Playernum, Governor, buf);
190 switch (ship->type) {
191 case ShipType::STYPE_MINE:
192 g.out <<
"Mine armed and ready.\n";
194 case ShipType::OTYPE_TRANSDEV:
195 g.out <<
"Transporter ready to receive.\n";
201 switch (ship->type) {
202 case ShipType::STYPE_MINE:
203 g.out <<
"Mine disarmed.\n";
205 case ShipType::OTYPE_TRANSDEV:
206 g.out <<
"No longer receiving.\n";
212 }
else if (argv[2] ==
"destination") {
213 if (speed_rating(*ship)) {
215 notify(Playernum, Governor,
216 "That ship is docked; use undock or launch first.\n");
219 where = getplace(g, argv[3], 1);
221 if (where.level == ScopeLevel::LEVEL_SHIP) {
222 auto tmpship = getship(where.shipno);
223 if (!followable(ship, &*tmpship)) {
224 g.out <<
"Warning: that ship is out of range.\n";
227 ship->destshipno = where.shipno;
228 ship->whatdest = ScopeLevel::LEVEL_SHIP;
231 if (where.level != ScopeLevel::LEVEL_UNIV &&
232 ((ship->storbits != where.snum) &&
233 where.level != ScopeLevel::LEVEL_STAR) &&
234 isclr(Stars[where.snum]->explored, ship->owner)) {
235 g.out <<
"You haven't explored this system.\n";
238 ship->whatdest = where.level;
239 ship->deststar = where.snum;
240 ship->destpnum = where.pnum;
245 g.out <<
"That ship cannot be launched.\n";
248 }
else if (argv[2] ==
"evade") {
249 if (max_crew(*ship) && max_speed(*ship)) {
251 ship->protect.evade = 1;
252 else if (argv[3] ==
"off")
253 ship->protect.evade = 0;
256 }
else if (argv[2] ==
"bombard") {
257 if (ship->type != ShipType::OTYPE_OMCL) {
258 if (can_bombard(*ship)) {
259 if (argv[3] ==
"off")
261 else if (argv[3] ==
"on")
264 notify(Playernum, Governor,
265 "This type of ship cannot be set to retaliate.\n");
267 }
else if (argv[2] ==
"retaliate") {
268 if (ship->type != ShipType::OTYPE_OMCL) {
269 if (can_bombard(*ship)) {
270 if (argv[3] ==
"off")
271 ship->protect.self = 0;
272 else if (argv[3] ==
"on")
273 ship->protect.self = 1;
275 notify(Playernum, Governor,
276 "This type of ship cannot be set to retaliate.\n");
278 }
else if (argv[2] ==
"focus") {
285 g.out <<
"No laser.\n";
286 }
else if (argv[2] ==
"laser") {
288 if (can_bombard(*ship)) {
291 ship->fire_laser = std::stoi(argv[4]);
293 ship->fire_laser = 0;
295 g.out <<
"You do not have a crystal mounted.\n";
297 notify(Playernum, Governor,
298 "This type of ship cannot be set to retaliate.\n");
300 notify(Playernum, Governor,
301 "This ship is not equipped with combat lasers.\n");
302 }
else if (argv[2] ==
"merchant") {
303 if (argv[3] ==
"off")
306 j = std::stoi(argv[3]);
307 if (j < 0 || j > MAX_ROUTES) {
308 g.out <<
"Bad route number.\n";
313 }
else if (argv[2] ==
"speed") {
314 if (speed_rating(*ship)) {
315 j = std::stoi(argv[3]);
317 g.out <<
"Specify a positive speed.\n";
320 if (j > speed_rating(*ship)) j = speed_rating(*ship);
324 g.out <<
"This ship does not have a speed rating.\n";
327 }
else if (argv[2] ==
"salvo") {
328 if (can_bombard(*ship)) {
329 j = std::stoi(argv[3]);
331 g.out <<
"Specify a positive number of guns.\n";
334 if (ship->guns ==
PRIMARY && j > ship->primary)
336 else if (ship->guns ==
SECONDARY && j > ship->secondary)
338 else if (ship->guns == GTYPE_NONE)
344 g.out <<
"This ship cannot be set to retaliate.\n";
347 }
else if (argv[2] ==
"primary") {
349 if (argv.size() < 4) {
351 if (ship->retaliate > ship->primary) ship->retaliate = ship->primary;
353 j = std::stoi(argv[3]);
355 notify(Playernum, Governor,
356 "Specify a nonnegative number of guns.\n");
359 if (j > ship->primary) j = ship->primary;
364 g.out <<
"This ship does not have primary guns.\n";
367 }
else if (argv[2] ==
"secondary") {
368 if (ship->secondary) {
369 if (argv.size() < 4) {
371 if (ship->retaliate > ship->secondary)
372 ship->retaliate = ship->secondary;
374 j = std::stoi(argv[3]);
376 notify(Playernum, Governor,
377 "Specify a nonnegative number of guns.\n");
380 if (j > ship->secondary) j = ship->secondary;
385 g.out <<
"This ship does not have secondary guns.\n";
388 }
else if (argv[2] ==
"explosive") {
389 switch (ship->type) {
390 case ShipType::STYPE_MINE:
391 case ShipType::OTYPE_GR:
397 }
else if (argv[2] ==
"radiative") {
398 switch (ship->type) {
399 case ShipType::STYPE_MINE:
400 case ShipType::OTYPE_GR:
406 }
else if (argv[2] ==
"move") {
407 if ((ship->type != ShipType::OTYPE_TERRA) &&
408 (ship->type != ShipType::OTYPE_PLOW)) {
409 g.out <<
"That ship is not a terraformer or a space plow.\n";
413 if (argv.size() > 3) {
418 for (
auto i = 0; i < moveseq.size(); ++i) {
421 sprintf(buf,
"Warning: that is more than %d moves.\n",
423 notify(Playernum, Governor, buf);
424 g.out <<
"These move orders have been truncated.\n";
429 if ((moveseq[i] ==
'c') || (moveseq[i] ==
's')) {
430 if ((i == 0) && (moveseq[0] ==
'c')) {
431 g.out <<
"Cycling move orders can not be empty!\n";
434 if (moveseq[i + 1]) {
436 "Warning: '%c' should be the last character in the " 439 notify(Playernum, Governor, buf);
440 g.out <<
"These move orders have been truncated.\n";
441 moveseq.resize(i + 1);
444 }
else if ((moveseq[i] <
'1') || (
'9' < moveseq[i])) {
445 sprintf(buf,
"'%c' is not a valid move direction.\n", moveseq[i]);
446 notify(Playernum, Governor, buf);
450 strcpy(ship->shipclass, moveseq.c_str());
452 ship->special.terraform.index = 0;
453 }
else if (argv[2] ==
"trigger") {
454 if (ship->type == ShipType::STYPE_MINE) {
455 if (std::stoi(argv[3]) < 0)
456 ship->special.trigger.radius = 0;
458 ship->special.trigger.radius = std::stoi(argv[3]);
460 notify(Playernum, Governor,
461 "This ship cannot be assigned a trigger radius.\n");
464 }
else if (argv[2] ==
"transport") {
465 if (ship->type == ShipType::OTYPE_TRANSDEV) {
466 ship->special.transport.target = std::stoi(argv[3]);
467 if (ship->special.transport.target == ship->number) {
468 notify(Playernum, Governor,
469 "A transporter cannot transport to itself.");
470 ship->special.transport.target = 0;
472 sprintf(buf,
"Target ship is %d.\n", ship->special.transport.target);
473 notify(Playernum, Governor, buf);
476 g.out <<
"This ship is not a transporter.\n";
479 }
else if (argv[2] ==
"aim") {
480 if (can_aim(*ship)) {
481 if (ship->type == ShipType::OTYPE_GTELE ||
482 ship->type == ShipType::OTYPE_TRACT || ship->fuel >=
FUEL_MANEUVER) {
483 if (ship->type == ShipType::STYPE_MIRROR && ship->docked) {
484 sprintf(buf,
"docked; use undock or launch first.\n");
485 notify(Playernum, Governor, buf);
488 pl = getplace(g, argv[3], 1);
490 g.out <<
"Error in destination.\n";
493 ship->special.aimed_at.level = pl.level;
494 ship->special.aimed_at.pnum = pl.pnum;
495 ship->special.aimed_at.snum = pl.snum;
496 ship->special.aimed_at.shipno = pl.shipno;
497 if (ship->type != ShipType::OTYPE_TRACT &&
498 ship->type != ShipType::OTYPE_GTELE)
500 if (ship->type == ShipType::OTYPE_GTELE ||
501 ship->type == ShipType::OTYPE_STELE)
503 sprintf(buf,
"Aimed at %s\n", prin_aimed_at(*ship).c_str());
504 notify(Playernum, Governor, buf);
507 sprintf(buf,
"Not enough maneuvering fuel (%.2f).\n",
FUEL_MANEUVER);
508 notify(Playernum, Governor, buf);
512 g.out <<
"You can't aim that kind of ship.\n";
515 }
else if (argv[2] ==
"intensity") {
516 if (ship->type == ShipType::STYPE_MIRROR) {
517 ship->special.aimed_at.intensity =
518 std::max(0, std::min(100, std::stoi(argv[3])));
520 }
else if (argv[2] ==
"on") {
521 if (!has_switch(*ship)) {
522 notify(Playernum, Governor,
523 "This ship does not have an on/off setting.\n");
526 if (ship->damage && ship->type != ShipType::OTYPE_FACTORY) {
527 g.out <<
"Damaged ships cannot be activated.\n";
531 g.out <<
"This ship is already activated.\n";
534 if (ship->type == ShipType::OTYPE_FACTORY) {
536 if (ship->whatorbits == ScopeLevel::LEVEL_SHIP) {
539 auto s2 = getship(ship->destshipno);
540 if (s2->type == ShipType::STYPE_HABITAT) {
542 if (s2->resource < oncost) {
544 "You don't have %d resources on Habitat #%lu to " 545 "activate this factory.\n",
546 oncost, ship->destshipno);
547 notify(Playernum, Governor, buf);
550 hangerneeded = (1 + (
int)(
HAB_FACT_SIZE * (
double)ship_size(*ship))) -
551 ((s2->max_hanger - s2->hanger) + ship->size);
552 if (hangerneeded > 0) {
555 "Not enough hanger space free on Habitat #%lu. Need %d more.\n",
556 ship->destshipno, hangerneeded);
557 notify(Playernum, Governor, buf);
560 s2->resource -= oncost;
561 s2->hanger -= ship->size;
562 ship->size = 1 + (
int)(
HAB_FACT_SIZE * (
double)ship_size(*ship));
563 s2->hanger += ship->size;
566 g.out <<
"The factory is currently being transported.\n";
569 }
else if (!landed(*ship)) {
570 g.out <<
"You cannot activate the factory here.\n";
573 auto planet =
getplanet(ship->deststar
, ship->destpnum
);
574 oncost = 2 * ship->build_cost;
575 if (planet.info[Playernum - 1].resource < oncost) {
577 "You don't have %d resources on the planet to activate " 580 notify(Playernum, Governor, buf);
583 planet.info[Playernum - 1].resource -= oncost;
584 putplanet(planet
, Stars[ship->deststar]
, (
int)ship->destpnum
);
586 sprintf(buf,
"Factory activated at a cost of %d resources.\n", oncost);
587 notify(Playernum, Governor, buf);
590 }
else if (argv[2] ==
"off") {
591 if (ship->type == ShipType::OTYPE_FACTORY && ship->on) {
592 notify(Playernum, Governor,
593 "You can't deactivate a factory once it's " 594 "online. Consider using 'scrap'.\n");
606 targ.level = ship.special.aimed_at.level;
607 targ.snum = ship.special.aimed_at.snum;
608 targ.pnum = ship.special.aimed_at.pnum;
609 targ.shipno = ship.special.aimed_at.shipno;
610 return Dispplace(targ);
616 dest.level = ship.whatdest;
617 dest.snum = ship.deststar;
618 dest.pnum = ship.destpnum;
619 dest.shipno = ship.destshipno;
620 return Dispplace(dest);
632 str = Stars[s->special.aimed_at.snum];
637 switch (s->special.aimed_at.level) {
638 case ScopeLevel::LEVEL_UNIV:
639 sprintf(buf,
"There is nothing out here to aim at.");
640 notify(Playernum, Governor, buf);
642 case ScopeLevel::LEVEL_STAR:
643 sprintf(buf,
"Star %s ", prin_aimed_at(*s).c_str());
644 notify(Playernum, Governor, buf);
645 if ((dist = sqrt(
Distsq(xf, yf, str->xpos, str->ypos))) <=
648 setbit(str->explored, Playernum);
650 sprintf(buf,
"Surveyed, distance %g.\n", dist);
651 notify(Playernum, Governor, buf);
654 sprintf(buf,
"Too far to see (%g, max %g).\n", dist,
656 notify(Playernum, Governor, buf);
659 case ScopeLevel::LEVEL_PLAN: {
660 sprintf(buf,
"Planet %s ", prin_aimed_at(*s).c_str());
661 notify(Playernum, Governor, buf);
662 auto p =
getplanet(s->special.aimed_at.snum
, s->special.aimed_at.pnum
);
664 sqrt(
Distsq(xf, yf, str->xpos + p.xpos, str->ypos + p.ypos))) <=
666 setbit(str->explored, Playernum);
667 p.info[Playernum - 1].explored = 1;
669 (
int)s->special.aimed_at.pnum
);
670 sprintf(buf,
"Surveyed, distance %g.\n", dist);
671 notify(Playernum, Governor, buf);
673 sprintf(buf,
"Too far to see (%g, max %g).\n", dist,
675 notify(Playernum, Governor, buf);
678 case ScopeLevel::LEVEL_SHIP:
679 sprintf(buf,
"You can't see anything of use there.\n");
680 notify(Playernum, Governor, buf);
686 notify(Playernum, Governor,
687 " # name sp orbits destin options\n");
690 static void DispOrders(
int Playernum,
int Governor, Ship *ship) {
693 if (ship->owner != Playernum || !authorized(Governor, *ship) || !ship->alive)
697 if (ship->whatdest == ScopeLevel::LEVEL_SHIP)
698 sprintf(temp,
"D#%lu", ship->destshipno);
700 sprintf(temp,
"L%2d,%-2d", ship->land_x, ship->land_y);
702 strcpy(temp, prin_ship_dest(*ship).c_str());
704 sprintf(buf,
"%5lu %c %14.14s %c%1u %-10s %-10.10s ", ship->number,
705 Shipltrs[ship->type], ship->name,
706 ship->hyper_drive.has ? (ship->mounted ?
'+' :
'*') :
' ',
709 if (ship->hyper_drive.on) {
710 sprintf(temp,
"/jump %s %d",
711 (ship->hyper_drive.ready ?
"ready" :
"charging"),
712 ship->hyper_drive.charge);
715 if (ship->protect.self) {
716 sprintf(temp,
"/retal");
721 switch (ship->primtype) {
723 sprintf(temp,
"/lgt primary");
726 sprintf(temp,
"/med primary");
729 sprintf(temp,
"/hvy primary");
732 sprintf(temp,
"/none");
737 switch (ship->sectype) {
739 sprintf(temp,
"/lgt secondary");
742 sprintf(temp,
"/med secndry");
745 sprintf(temp,
"/hvy secndry");
748 sprintf(temp,
"/none");
754 if (ship->fire_laser) {
755 sprintf(temp,
"/laser %d", ship->fire_laser);
758 if (ship->focus) strcat(buf,
"/focus");
760 if (ship->retaliate) {
761 sprintf(temp,
"/salvo %d", ship->retaliate);
764 if (ship->protect.planet) strcat(buf,
"/defense");
765 if (ship->protect.on) {
766 sprintf(temp,
"/prot %d", ship->protect.ship);
769 if (ship->navigate.on) {
770 sprintf(temp,
"/nav %d (%d)", ship->navigate.bearing, ship->navigate.turns);
773 if (ship->merchant) {
774 sprintf(temp,
"/merchant %d", ship->merchant);
777 if (has_switch(*ship)) {
783 if (ship->protect.evade) strcat(buf,
"/evade");
784 if (ship->bombard) strcat(buf,
"/bomb");
785 if (ship->type == ShipType::STYPE_MINE || ship->type == ShipType::OTYPE_GR) {
787 strcat(buf,
"/radiate");
789 strcat(buf,
"/explode");
791 if (ship->type == ShipType::OTYPE_TERRA ||
792 ship->type == ShipType::OTYPE_PLOW) {
794 sprintf(temp,
"/move %s",
795 &(ship->shipclass[ship->special.terraform.index]));
796 if (temp[i = (strlen(temp) - 1)] ==
'c') {
797 char c = ship->shipclass[ship->special.terraform.index];
798 ship->shipclass[ship->special.terraform.index] =
'\0';
799 sprintf(temp + i,
"%sc", ship->shipclass);
800 ship->shipclass[ship->special.terraform.index] = c;
805 if (ship->type == ShipType::STYPE_MISSILE &&
806 ship->whatdest == ScopeLevel::LEVEL_PLAN) {
807 if (ship->special.impact.scatter)
808 strcat(buf,
"/scatter");
810 sprintf(temp,
"/impact %d,%d", ship->special.impact.x,
811 ship->special.impact.y);
816 if (ship->type == ShipType::STYPE_MINE) {
817 sprintf(temp,
"/trigger %d", ship->special.trigger.radius);
820 if (ship->type == ShipType::OTYPE_TRANSDEV) {
821 sprintf(temp,
"/target %d", ship->special.transport.target);
824 if (ship->type == ShipType::STYPE_MIRROR) {
825 sprintf(temp,
"/aim %s/int %d", prin_aimed_at(*ship).c_str(),
826 ship->special.aimed_at.intensity);
831 notify(Playernum, Governor, buf);
834 if (ship->hyper_drive.on) {
838 dist = sqrt(
Distsq(ship->xpos, ship->ypos, Stars[ship->deststar]->xpos,
839 Stars[ship->deststar]->ypos));
841 if (ship->mounted && dist > distfac) {
848 sprintf(buf,
" *** distance %.0f - jump will cost %.1ff ***\n", dist,
850 notify(Playernum, Governor, buf);
851 if (ship->max_fuel < fuse)
852 notify(Playernum, Governor,
853 "Your ship cannot carry enough fuel to do this jump.\n");
857 void route(
const command_t &argv, GameObj &g) {
859 player_t Playernum = g.player;
860 governor_t Governor = g.governor;
866 unsigned char planet;
868 unsigned char unload;
872 if (g.level != ScopeLevel::LEVEL_PLAN) {
873 notify(Playernum, Governor,
874 "You have to 'cs' to a planet to examine routes.\n");
878 if (argv.size() == 1) {
879 for (i = 1; i <= MAX_ROUTES; i++)
880 if (p.info[Playernum - 1].route[i - 1].set) {
881 star = p.info[Playernum - 1].route[i - 1].dest_star;
882 planet = p.info[Playernum - 1].route[i - 1].dest_planet;
883 load = p.info[Playernum - 1].route[i - 1].load;
884 unload = p.info[Playernum - 1].route[i - 1].unload;
885 sprintf(buf,
"%2d land %2d,%2d ", i,
886 p.info[Playernum - 1].route[i - 1].x,
887 p.info[Playernum - 1].route[i - 1].y);
888 strcat(buf,
"load: ");
901 if (
Crystals(load)) strcat(buf,
"x");
904 strcat(buf,
" unload: ");
921 sprintf(temp,
" -> %s/%s\n", Stars[star]->name,
922 Stars[star]->pnames[planet]);
924 notify(Playernum, Governor, buf);
929 if (argv.size() == 2) {
930 i = std::stoi(argv[1]);
931 if (i > MAX_ROUTES || i < 1) {
932 g.out <<
"Bad route number.\n";
935 if (p.info[Playernum - 1].route[i - 1].set) {
936 star = p.info[Playernum - 1].route[i - 1].dest_star;
937 planet = p.info[Playernum - 1].route[i - 1].dest_planet;
938 load = p.info[Playernum - 1].route[i - 1].load;
939 unload = p.info[Playernum - 1].route[i - 1].unload;
940 sprintf(buf,
"%2d land %2d,%2d ", i,
941 p.info[Playernum - 1].route[i - 1].x,
942 p.info[Playernum - 1].route[i - 1].y);
944 sprintf(temp,
"load: ");
946 if (
Fuel(load)) strcat(buf,
"f");
947 if (
Destruct(load)) strcat(buf,
"d");
949 if (
Crystals(load)) strcat(buf,
"x");
952 sprintf(temp,
" unload: ");
954 if (
Fuel(unload)) strcat(buf,
"f");
955 if (
Destruct(unload)) strcat(buf,
"d");
957 if (
Crystals(unload)) strcat(buf,
"x");
959 sprintf(temp,
" -> %s/%s\n", Stars[star]->name,
960 Stars[star]->pnames[planet]);
962 notify(Playernum, Governor, buf);
967 if (argv.size() == 3) {
968 i = std::stoi(argv[1]);
969 if (i > MAX_ROUTES || i < 1) {
970 g.out <<
"Bad route number.\n";
973 if (argv[2] ==
"activate")
974 p.info[Playernum - 1].route[i - 1].set = 1;
975 else if (argv[2] ==
"deactivate")
976 p.info[Playernum - 1].route[i - 1].set = 0;
978 where = getplace(g, argv[2], 1);
980 if (where.level != ScopeLevel::LEVEL_PLAN) {
981 g.out <<
"You have to designate a planet.\n";
984 p.info[Playernum - 1].route[i - 1].dest_star = where.snum;
985 p.info[Playernum - 1].route[i - 1].dest_planet = where.pnum;
988 g.out <<
"Illegal destination.\n";
993 i = std::stoi(argv[1]);
994 if (i > MAX_ROUTES || i < 1) {
995 g.out <<
"Bad route number.\n";
998 if (argv[2] ==
"land") {
999 sscanf(argv[3].c_str(),
"%d,%d", &x, &y);
1000 if (x < 0 || x > p.Maxx - 1 || y < 0 || y > p.Maxy - 1) {
1001 g.out <<
"Bad sector coordinates.\n";
1004 p.info[Playernum - 1].route[i - 1].x = x;
1005 p.info[Playernum - 1].route[i - 1].y = y;
1006 }
else if (argv[2] ==
"load") {
1007 p.info[Playernum - 1].route[i - 1].load = 0;
1008 c = argv[3].c_str();
1010 if (*c ==
'f') p.info[Playernum - 1].route[i - 1].load |=
M_FUEL;
1011 if (*c ==
'd') p.info[Playernum - 1].route[i - 1].load |=
M_DESTRUCT;
1012 if (*c ==
'r') p.info[Playernum - 1].route[i - 1].load |=
M_RESOURCES;
1013 if (*c ==
'x') p.info[Playernum - 1].route[i - 1].load |=
M_CRYSTALS;
1016 }
else if (argv[2] ==
"unload") {
1017 p.info[Playernum - 1].route[i - 1].unload = 0;
1018 c = argv[3].c_str();
1020 if (*c ==
'f') p.info[Playernum - 1].route[i - 1].unload |=
M_FUEL;
1021 if (*c ==
'd') p.info[Playernum - 1].route[i - 1].unload |=
M_DESTRUCT;
1022 if (*c ==
'r') p.info[Playernum - 1].route[i - 1].unload |=
M_RESOURCES;
1023 if (*c ==
'x') p.info[Playernum - 1].route[i - 1].unload |=
M_CRYSTALS;
1027 g.out <<
"What are you trying to do?\n";
static void give_orders(GameObj &, const command_t &, int, Ship *)
void use_fuel(Ship *s, double amt)
#define Distsq(x1, y1, x2, y2)
static void DispOrdersHeader(int, int)
char * Dispshiploc_brief(Ship *ship)
Planet getplanet(const starnum_t star, const planetnum_t pnum)
void order(const command_t &argv, GameObj &g)
#define HYPER_DIST_FACTOR
#define HYPER_DRIVE_FUEL_USE
static void mk_expl_aimed_at(int, int, Ship *)
void putstar(startype *s, starnum_t snum)
static std::string prin_aimed_at(const Ship &)
shipnum_t do_shiplist(Ship **s, shipnum_t *nextshipno)
void route(const command_t &argv, GameObj &g)
void putplanet(const Planet &p, startype *star, const int pnum)
std::string prin_ship_dest(const Ship &ship)
void getstar(startype **s, int star)
static void DispOrders(int, int, Ship *)
double tele_range(int, double)