7 #include "gb/commands/fix.h" 18 #include "gb/GB_server.h" 19 #include "gb/buffers.h" 21 #include "gb/files_shl.h" 25 #include "gb/shlmisc.h" 26 #include "gb/tweakables.h" 30 void fix(
const command_t &argv, GameObj &g) {
31 player_t Playernum = g.player;
32 governor_t Governor = g.governor;
34 notify(Playernum, Governor,
35 "This command is only available to the deity.\n");
39 if (argv[1] ==
"planet") {
40 if (g.level != ScopeLevel::LEVEL_PLAN) {
41 g.out <<
"Change scope to the planet first.\n";
45 if (argv[2] ==
"Maxx") {
46 if (argv.size() > 3) p.Maxx = std::stoi(argv[3]);
47 sprintf(buf,
"Maxx = %d\n", p.Maxx);
48 }
else if (argv[2] ==
"Maxy") {
49 if (argv.size() > 3) p.Maxy = std::stoi(argv[3]);
50 sprintf(buf,
"Maxy = %d\n", p.Maxy);
51 }
else if (argv[2] ==
"xpos") {
52 if (argv.size() > 3) p.xpos = (
double)std::stoi(argv[3]);
53 sprintf(buf,
"xpos = %f\n", p.xpos);
54 }
else if (argv[2] ==
"ypos") {
55 if (argv.size() > 3) p.ypos = (
double)std::stoi(argv[3]);
56 sprintf(buf,
"ypos = %f\n", p.ypos);
57 }
else if (argv[2] ==
"ships") {
58 if (argv.size() > 3) p.ships = std::stoi(argv[3]);
59 sprintf(buf,
"ships = %ld\n", p.ships);
60 }
else if (argv[2] ==
"rtemp") {
61 if (argv.size() > 3) p.conditions[
RTEMP] = std::stoi(argv[3]);
62 sprintf(buf,
"RTEMP = %d\n", p.conditions[
RTEMP]);
63 }
else if (argv[2] ==
"temperature") {
64 if (argv.size() > 3) p.conditions[
TEMP] = std::stoi(argv[3]);
65 sprintf(buf,
"TEMP = %d\n", p.conditions[
TEMP]);
66 }
else if (argv[2] ==
"methane") {
67 if (argv.size() > 3) p.conditions[
METHANE] = std::stoi(argv[3]);
68 sprintf(buf,
"METHANE = %d\n", p.conditions[
METHANE]);
69 }
else if (argv[2] ==
"oxygen") {
70 if (argv.size() > 3) p.conditions[
OXYGEN] = std::stoi(argv[3]);
71 sprintf(buf,
"OXYGEN = %d\n", p.conditions[
OXYGEN]);
72 }
else if (argv[2] ==
"co2") {
73 if (argv.size() > 3) p.conditions[
CO2] = std::stoi(argv[3]);
74 sprintf(buf,
"CO2 = %d\n", p.conditions[
CO2]);
75 }
else if (argv[2] ==
"hydrogen") {
76 if (argv.size() > 3) p.conditions[
HYDROGEN] = std::stoi(argv[3]);
77 sprintf(buf,
"HYDROGEN = %d\n", p.conditions[
HYDROGEN]);
78 }
else if (argv[2] ==
"nitrogen") {
79 if (argv.size() > 3) p.conditions[
NITROGEN] = std::stoi(argv[3]);
80 sprintf(buf,
"NITROGEN = %d\n", p.conditions[
NITROGEN]);
81 }
else if (argv[2] ==
"sulfur") {
82 if (argv.size() > 3) p.conditions[
SULFUR] = std::stoi(argv[3]);
83 sprintf(buf,
"SULFUR = %d\n", p.conditions[
SULFUR]);
84 }
else if (argv[2] ==
"helium") {
85 if (argv.size() > 3) p.conditions[
HELIUM] = std::stoi(argv[3]);
86 sprintf(buf,
"HELIUM = %d\n", p.conditions[
HELIUM]);
87 }
else if (argv[2] ==
"other") {
88 if (argv.size() > 3) p.conditions[
OTHER] = std::stoi(argv[3]);
89 sprintf(buf,
"OTHER = %d\n", p.conditions[
OTHER]);
90 }
else if (argv[2] ==
"toxic") {
91 if (argv.size() > 3) p.conditions[
TOXIC] = std::stoi(argv[3]);
92 sprintf(buf,
"TOXIC = %d\n", p.conditions[
TOXIC]);
94 g.out <<
"No such option for 'fix planet'.\n";
97 notify(Playernum, Governor, buf);
101 if (argv[1] ==
"ship") {
102 if (g.level != ScopeLevel::LEVEL_SHIP) {
103 notify(Playernum, Governor,
104 "Change scope to the ship you wish to fix.\n");
107 auto s = getship(g.shipno);
108 if (argv[2] ==
"fuel") {
109 if (argv.size() > 3) s->fuel = (
double)std::stoi(argv[3]);
110 sprintf(buf,
"fuel = %f\n", s->fuel);
111 }
else if (argv[2] ==
"max_fuel") {
112 if (argv.size() > 3) s->max_fuel = std::stoi(argv[3]);
113 sprintf(buf,
"fuel = %d\n", s->max_fuel);
114 }
else if (argv[2] ==
"destruct") {
115 if (argv.size() > 3) s->destruct = std::stoi(argv[3]);
116 sprintf(buf,
"destruct = %d\n", s->destruct);
117 }
else if (argv[2] ==
"resource") {
118 if (argv.size() > 3) s->resource = std::stoi(argv[3]);
119 sprintf(buf,
"resource = %lu\n", s->resource);
120 }
else if (argv[2] ==
"damage") {
121 if (argv.size() > 3) s->damage = std::stoi(argv[3]);
122 sprintf(buf,
"damage = %d\n", s->damage);
123 }
else if (argv[2] ==
"alive") {
126 sprintf(buf,
"%s resurrected\n", ship_to_string(*s).c_str());
127 }
else if (argv[2] ==
"dead") {
130 sprintf(buf,
"%s destroyed\n", ship_to_string(*s).c_str());
132 g.out <<
"No such option for 'fix ship'.\n";
135 notify(Playernum, Governor, buf);
139 g.out <<
"Fix what?\n";
Planet getplanet(const starnum_t star, const planetnum_t pnum)
void putplanet(const Planet &p, startype *star, const int pnum)
void fix(const command_t &argv, GameObj &g)