17 #include "gb/GB_server.h" 18 #include "gb/buffers.h" 19 #include "gb/dissolve.h" 21 #include "gb/files_shl.h" 22 #include "gb/getplace.h" 24 #include "gb/mobiliz.h" 27 #include "gb/shlmisc.h" 29 #include "gb/tweakables.h" 30 #include "gb/utils/rand.h" 33 void personal(
const command_t &argv, GameObj &g) {
34 player_t Playernum = g.player;
36 std::stringstream ss_message;
37 std::copy(++argv.begin(), argv.end(),
38 std::ostream_iterator<std::string>(ss_message,
" "));
39 std::string message = ss_message.str();
41 if (g.governor != 0) {
42 g.out <<
"Only the leader can do this.\n";
45 auto Race = races[Playernum - 1];
50 void bless(
const command_t &argv, GameObj &g) {
51 player_t Playernum = g.player;
58 g.out <<
"You are not privileged to use this command.\n";
61 if (g.level != ScopeLevel::LEVEL_PLAN) {
62 g.out <<
"Please cs to the planet in question.\n";
65 player_t who = std::stoi(argv[1]);
66 if (who < 1 || who > Num_races) {
67 g.out <<
"No such player number.\n";
70 if (argv.size() < 3) {
71 g.out <<
"Syntax: bless <player> <what> <+amount>\n";
74 amount = std::stoi(argv[3]);
76 racetype *Race = races[who - 1];
80 if (argv[2] ==
"money") {
81 Race->governor[0].money += amount;
82 sprintf(buf,
"Deity gave you %d money.\n", amount);
83 }
else if (argv[2] ==
"password") {
84 strcpy(Race->password, argv[3].c_str());
85 sprintf(buf,
"Deity changed your race password to `%s'\n", argv[3].c_str());
86 }
else if (argv[2] ==
"morale") {
87 Race->morale += amount;
88 sprintf(buf,
"Deity gave you %d morale.\n", amount);
89 }
else if (argv[2] ==
"pods") {
91 sprintf(buf,
"Deity gave you pod ability.\n");
92 }
else if (argv[2] ==
"nopods") {
94 sprintf(buf,
"Deity took away pod ability.\n");
95 }
else if (argv[2] ==
"collectiveiq") {
96 Race->collective_iq = 1;
97 sprintf(buf,
"Deity gave you collective intelligence.\n");
98 }
else if (argv[2] ==
"nocollectiveiq") {
99 Race->collective_iq = 0;
100 sprintf(buf,
"Deity took away collective intelligence.\n");
101 }
else if (argv[2] ==
"maxiq") {
102 Race->IQ_limit = std::stoi(argv[3]);
103 sprintf(buf,
"Deity gave you a maximum IQ of %d.\n", Race->IQ_limit);
104 }
else if (argv[2] ==
"mass") {
105 Race->mass = atof(argv[3].c_str());
106 sprintf(buf,
"Deity gave you %.2f mass.\n", Race->mass);
107 }
else if (argv[2] ==
"metabolism") {
108 Race->metabolism = atof(argv[3].c_str());
109 sprintf(buf,
"Deity gave you %.2f metabolism.\n", Race->metabolism);
110 }
else if (argv[2] ==
"adventurism") {
111 Race->adventurism = atof(argv[3].c_str());
112 sprintf(buf,
"Deity gave you %-3.0f%% adventurism.\n",
113 Race->adventurism * 100.0);
114 }
else if (argv[2] ==
"birthrate") {
115 Race->birthrate = atof(argv[3].c_str());
116 sprintf(buf,
"Deity gave you %.2f birthrate.\n", Race->birthrate);
117 }
else if (argv[2] ==
"fertility") {
118 Race->fertilize = amount;
119 sprintf(buf,
"Deity gave you a fetilization ability of %d.\n", amount);
120 }
else if (argv[2] ==
"IQ") {
122 sprintf(buf,
"Deity gave you %d IQ.\n", amount);
123 }
else if (argv[2] ==
"fight") {
124 Race->fighters = amount;
125 sprintf(buf,
"Deity set your fighting ability to %d.\n", amount);
126 }
else if (argv[2] ==
"technology") {
127 Race->tech += (
double)amount;
128 sprintf(buf,
"Deity gave you %d technology.\n", amount);
129 }
else if (argv[2] ==
"guest") {
131 sprintf(buf,
"Deity turned you into a guest race.\n");
132 }
else if (argv[2] ==
"god") {
134 sprintf(buf,
"Deity turned you into a deity race.\n");
135 }
else if (argv[2] ==
"mortal") {
138 sprintf(buf,
"Deity turned you into a mortal race.\n");
140 }
else if (argv[2] ==
"water") {
141 Race->likes[SectorType::SEC_SEA] = 0.01 * (
double)amount;
142 sprintf(buf,
"Deity set your water preference to %d%%\n", amount);
143 }
else if (argv[2] ==
"land") {
144 Race->likes[SectorType::SEC_LAND] = 0.01 * (
double)amount;
145 sprintf(buf,
"Deity set your land preference to %d%%\n", amount);
146 }
else if (argv[2] ==
"mountain") {
147 Race->likes[SectorType::SEC_MOUNT] = 0.01 * (
double)amount;
148 sprintf(buf,
"Deity set your mountain preference to %d%%\n", amount);
149 }
else if (argv[2] ==
"gas") {
150 Race->likes[SectorType::SEC_GAS] = 0.01 * (
double)amount;
151 sprintf(buf,
"Deity set your gas preference to %d%%\n", amount);
152 }
else if (argv[2] ==
"ice") {
153 Race->likes[SectorType::SEC_ICE] = 0.01 * (
double)amount;
154 sprintf(buf,
"Deity set your ice preference to %d%%\n", amount);
155 }
else if (argv[2] ==
"forest") {
156 Race->likes[SectorType::SEC_FOREST] = 0.01 * (
double)amount;
157 sprintf(buf,
"Deity set your forest preference to %d%%\n", amount);
158 }
else if (argv[2] ==
"desert") {
159 Race->likes[SectorType::SEC_DESERT] = 0.01 * (
double)amount;
160 sprintf(buf,
"Deity set your desert preference to %d%%\n", amount);
161 }
else if (argv[2] ==
"plated") {
162 Race->likes[SectorType::SEC_PLATED] = 0.01 * (
double)amount;
163 sprintf(buf,
"Deity set your plated preference to %d%%\n", amount);
174 if (argv[2] ==
"explorebit") {
175 planet.info[who - 1].explored = 1;
177 setbit(Stars[g.snum]->explored, who);
179 sprintf(buf,
"Deity set your explored bit at /%s/%s.\n",
180 Stars[g.snum]->name, Stars[g.snum]->pnames[g.pnum]);
181 }
else if (argv[2] ==
"noexplorebit") {
182 planet.info[who - 1].explored = 0;
183 sprintf(buf,
"Deity reset your explored bit at /%s/%s.\n",
184 Stars[g.snum]->name, Stars[g.snum]->pnames[g.pnum]);
185 }
else if (argv[2] ==
"planetpopulation") {
186 planet.info[who - 1].popn = std::stoi(argv[3]);
188 sprintf(buf,
"Deity set your population variable to %ld at /%s/%s.\n",
189 planet.info[who - 1].popn, Stars[g.snum]->name,
190 Stars[g.snum]->pnames[g.pnum]);
191 }
else if (argv[2] ==
"inhabited") {
193 setbit(Stars[g.snum]->inhabited, Playernum);
195 sprintf(buf,
"Deity has set your inhabited bit for /%s/%s.\n",
196 Stars[g.snum]->name, Stars[g.snum]->pnames[g.pnum]);
197 }
else if (argv[2] ==
"numsectsowned") {
198 planet.info[who - 1].numsectsowned = std::stoi(argv[3]);
199 sprintf(buf,
"Deity set your \"numsectsowned\" variable at /%s/%s to %d.\n",
200 Stars[g.snum]->name, Stars[g.snum]->pnames[g.pnum],
201 planet.info[who - 1].numsectsowned);
205 planet.info[who - 1].resource += amount;
206 sprintf(buf,
"Deity gave you %d resources at %s/%s.\n", amount,
207 Stars[g.snum]->name, Stars[g.snum]->pnames[g.pnum]);
210 planet.info[who - 1].destruct += amount;
211 sprintf(buf,
"Deity gave you %d destruct at %s/%s.\n", amount,
212 Stars[g.snum]->name, Stars[g.snum]->pnames[g.pnum]);
215 planet.info[who - 1].fuel += amount;
216 sprintf(buf,
"Deity gave you %d fuel at %s/%s.\n", amount,
217 Stars[g.snum]->name, Stars[g.snum]->pnames[g.pnum]);
220 planet.info[who - 1].crystals += amount;
221 sprintf(buf,
"Deity gave you %d crystals at %s/%s.\n", amount,
222 Stars[g.snum]->name, Stars[g.snum]->pnames[g.pnum]);
226 Stars[g.snum]->AP[who - 1] += amount;
228 sprintf(buf,
"Deity gave you %d action points at %s.\n", amount,
229 Stars[g.snum]->name);
232 g.out <<
"No such commodity.\n";
241 player_t Playernum = g.player;
242 governor_t Governor = g.governor;
254 if (g.level != ScopeLevel::LEVEL_PLAN) {
255 g.out <<
"You must 'cs' to the planet you wish to try it on.\n";
258 if (!
control(Playernum
, Governor
, Stars[g.snum]
)) {
259 g.out <<
"You are not authorized to do that here.\n";
267 if (!
enufAP(Playernum
, Governor
, Stars[g.snum]->AP[Playernum - 1]
, APcount
))
269 if (!(who = get_player(argv[1]))) {
270 g.out <<
"No such player.\n";
273 Race = races[Playernum - 1];
274 alien = races[who - 1];
276 g.out <<
"Don't be such a dickweed.\n";
279 if (who == Playernum) {
280 g.out <<
"You can't revolt against yourself!\n";
285 for (i = 0; i < Stars[g.snum]->numplanets; i++) {
287 eligible += p.info[Playernum - 1].popn;
288 them += p.info[who - 1].popn;
291 g.out <<
"You must have population in the star system to attempt " 297 if (!p.info[who - 1].popn) {
298 g.out <<
"This player does not occupy this planet.\n";
302 int amount = std::stoi(argv[2]);
304 g.out <<
"You have to use a positive amount of money.\n";
307 if (Race->governor[Governor].money < amount) {
308 g.out <<
"Nice try.\n";
312 x =
INSURG_FACTOR * (
double)amount * (
double)p.info[who - 1].tax /
313 (
double)p.info[who - 1].popn;
317 (
double)(Race->fighters * p.info[Playernum - 1].troops -
318 alien->fighters * p.info[who - 1].troops)
) /
320 sprintf(buf,
"x = %f\n", x);
321 notify(Playernum, Governor, buf);
322 chance = round_rand(200.0 * atan((
double)x) / 3.14159265);
323 sprintf(long_buf,
"%s/%s: %s [%d] tries insurgency vs %s [%d]\n",
324 Stars[g.snum]->name, Stars[g.snum]->pnames[g.pnum], Race->name,
325 Playernum, alien->name, who);
326 sprintf(buf,
"\t%s: %d total civs [%d] opposing %d total civs [%d]\n",
327 Stars[g.snum]->name, eligible, Playernum, them, who);
328 strcat(long_buf, buf);
329 sprintf(buf,
"\t\t %ld morale [%d] vs %ld morale [%d]\n", Race->morale,
330 Playernum, alien->morale, who);
331 strcat(long_buf, buf);
332 sprintf(buf,
"\t\t %d money against %ld population at tax rate %d%%\n",
333 amount, p.info[who - 1].popn, p.info[who - 1].tax);
334 strcat(long_buf, buf);
335 sprintf(buf,
"Success chance is %d%%\n", chance);
336 strcat(long_buf, buf);
337 if (success(chance)) {
339 notify(Playernum, Governor, long_buf);
340 sprintf(buf,
"Success! You liberate %d sector%s.\n", changed_hands,
341 (changed_hands == 1) ?
"" :
"s");
342 notify(Playernum, Governor, buf);
344 "A revolt on /%s/%s instigated by %s [%d] costs you %d sector%s\n",
345 Stars[g.snum]->name, Stars[g.snum]->pnames[g.pnum], Race->name,
346 Playernum, changed_hands, (changed_hands == 1) ?
"" :
"s");
347 strcat(long_buf, buf);
348 warn(who, Stars[g.snum]->governor[who - 1], long_buf);
349 p.info[Playernum - 1].tax = p.info[who - 1].tax;
351 sprintf(buf,
"/%s/%s: Successful insurgency by %s [%d] against %s [%d]\n",
352 Stars[g.snum]->name, Stars[g.snum]->pnames[g.pnum], Race->name,
353 Playernum, alien->name, who);
356 notify(Playernum, Governor, long_buf);
357 g.out <<
"The insurgency failed!\n";
358 sprintf(buf,
"A revolt on /%s/%s instigated by %s [%d] fails\n",
359 Stars[g.snum]->name, Stars[g.snum]->pnames[g.pnum], Race->name,
361 strcat(long_buf, buf);
362 warn(who, Stars[g.snum]->governor[who - 1], long_buf);
363 sprintf(buf,
"/%s/%s: Failed insurgency by %s [%d] against %s [%d]\n",
364 Stars[g.snum]->name, Stars[g.snum]->pnames[g.pnum], Race->name,
365 Playernum, alien->name, who);
369 Race->governor[Governor].money -= amount;
373 void pay(
const command_t &argv, GameObj &g) {
374 player_t Playernum = g.player;
375 governor_t Governor = g.governor;
382 if (!(who = get_player(argv[1]))) {
383 g.out <<
"No such player.\n";
387 g.out <<
"You are not authorized to do that.\n";
390 Race = races[Playernum - 1];
391 alien = races[who - 1];
393 amount = std::stoi(argv[2]);
395 g.out <<
"You have to give a player a positive amount of money.\n";
399 g.out <<
"Nice try. Your attempt has been duly noted.\n";
402 if (Race->governor[Governor].money < amount) {
403 g.out <<
"You don't have that much money to give!\n";
407 Race->governor[Governor].money -= amount;
408 alien->governor[0].money += amount;
409 sprintf(buf,
"%s [%d] payed you %d.\n", Race->name, Playernum, amount);
411 sprintf(buf,
"%d payed to %s [%d].\n", amount, alien->name, who);
412 notify(Playernum, Governor, buf);
414 sprintf(buf,
"%s [%d] pays %s [%d].\n", Race->name, Playernum, alien->name,
422 void give(
const command_t &argv, GameObj &g) {
423 player_t Playernum = g.player;
424 governor_t Governor = g.governor;
430 if (!(who = get_player(argv[1]))) {
431 g.out <<
"No such player.\n";
435 g.out <<
"You are not authorized to do that.\n";
438 alien = races[who - 1];
439 Race = races[Playernum - 1];
440 if (alien->Guest && !Race->God) {
441 g.out <<
"You can't give this player anything.\n";
445 g.out <<
"You can't give anyone anything.\n";
450 !(
isset(Race->allied, who) &&
isset(alien->allied, Playernum))) {
451 g.out <<
"You two are not mutually allied.\n";
454 auto shipno = string_to_shipnum(argv[2]);
456 g.out <<
"Illegal ship number.\n";
460 auto ship = getship(*shipno);
462 g.out <<
"No such ship.\n";
466 if (ship->owner != Playernum || !ship->alive) {
467 DontOwnErr(Playernum, Governor, *shipno);
470 if (ship->type == ShipType::STYPE_POD) {
471 g.out <<
"You cannot change the ownership of spore pods.\n";
475 if ((ship->popn + ship->troops) && !Race->God) {
476 g.out <<
"You can't give this ship away while it has crew/mil on board.\n";
479 if (ship->ships && !Race->God) {
481 <<
"You can't give away this ship, it has other ships loaded on it.\n";
484 switch (ship->whatorbits) {
485 case ScopeLevel::LEVEL_UNIV:
486 if (!enufAP(Playernum, Governor, Sdata.AP[Playernum - 1], APcount)) {
491 if (!enufAP(Playernum, Governor, Stars[g.snum]->AP[Playernum - 1],
500 capture_stuff(*ship, g);
505 switch (ship->whatorbits) {
506 case ScopeLevel::LEVEL_UNIV:
508 case ScopeLevel::LEVEL_STAR:
509 getstar(&(Stars[ship->storbits]), (
int)ship->storbits);
510 setbit(Stars[ship->storbits]->explored, who);
511 putstar(Stars[ship->storbits], (
int)ship->storbits);
513 case ScopeLevel::LEVEL_PLAN: {
514 getstar(&(Stars[ship->storbits]), (
int)ship->storbits);
515 setbit(Stars[ship->storbits]->explored, who);
516 putstar(Stars[ship->storbits], (
int)ship->storbits);
518 auto planet = getplanet((
int)ship->storbits, (
int)ship->pnumorbits);
519 planet.info[who - 1].explored = 1;
520 putplanet(planet, Stars[ship->storbits], (
int)ship->pnumorbits);
524 g.out <<
"Something wrong with this ship's scope.\n";
528 switch (ship->whatorbits) {
529 case ScopeLevel::LEVEL_UNIV:
530 deductAPs(Playernum, Governor, APcount, 0, 1);
533 deductAPs(Playernum, Governor, APcount, g.snum, 0);
536 g.out <<
"Owner changed.\n";
537 sprintf(buf,
"%s [%d] gave you %s at %s.\n", Race->name, Playernum,
538 ship_to_string(*ship).c_str(), prin_ship_orbits(&*ship));
542 sprintf(buf,
"%s [%d] gives %s [%d] a ship.\n", Race->name, Playernum,
548 void page(
const command_t &argv, GameObj &g) {
549 player_t Playernum = g.player;
550 governor_t Governor = g.governor;
551 int APcount = g.god ? 0 : 1;
560 if (!
enufAP(Playernum
, Governor
, Stars[g.snum]->AP[Playernum - 1]
, APcount
))
565 if (argv[1] ==
"block") {
567 g.out <<
"Paging alliance block.\n";
571 if (!(who = get_player(argv[1]))) {
572 g.out <<
"No such player.\n";
575 alien = races[who - 1];
576 APcount *= !alien->God;
577 if (argv.size() > 1) gov = std::stoi(argv[2]);
581 case ScopeLevel::LEVEL_UNIV:
582 g.out <<
"You can't make pages at universal scope.\n";
586 if (!
enufAP(Playernum
, Governor
, Stars[g.snum]->AP[Playernum - 1]
, 591 Race = races[Playernum - 1];
593 sprintf(buf,
"%s \"%s\" page(s) you from the %s star system.\n",
594 Race->name, Race->governor[Governor].name, Stars[g.snum]->name);
598 Blocks[Playernum - 1].invite[0] & Blocks[Playernum - 1].pledge[0];
600 Blocks[Playernum - 1].invite[1] & Blocks[Playernum - 1].pledge[1];
601 for (i = 1; i <= Num_races; i++)
602 if (
isset(dummy, i) && i != Playernum) notify_race(i, buf);
605 notify(who, gov, buf);
607 notify_race(who, buf);
610 g.out <<
"Request sent.\n";
617 player_t Playernum = g.player;
618 governor_t Governor = g.governor;
619 bool postit = argv[0] ==
"post";
624 APcount = g.god ? 0 : 1;
642 to_star = to_block = 0;
644 if (argv.size() < 2) {
645 g.out <<
"Send what?\n";
649 Race = races[Playernum - 1];
650 sprintf(msg,
"%s \"%s\" [%d,%d]: ", Race->name,
651 Race->governor[Governor].name, Playernum, Governor);
653 for (j = 1; j < argv.size(); j++) {
654 sprintf(buf,
"%s ", argv[j].c_str());
661 if (argv[1] ==
"block") {
663 g.out <<
"Sending message to alliance block.\n";
664 if (!(who = get_player(argv[2]))) {
665 g.out <<
"No such alliance block.\n";
668 alien = races[who - 1];
669 APcount *= !alien->God;
670 }
else if (argv[1] ==
"star") {
672 g.out <<
"Sending message to star system.\n";
673 where = getplace(g, argv[2], 1);
674 if (where.err || where.level != ScopeLevel::LEVEL_STAR) {
675 g.out <<
"No such star.\n";
681 if (!(who = get_player(argv[1]))) {
682 g.out <<
"No such player.\n";
685 alien = races[who - 1];
686 APcount *= !alien->God;
690 case ScopeLevel::LEVEL_UNIV:
691 g.out <<
"You can't send messages from universal scope.\n";
694 case ScopeLevel::LEVEL_SHIP:
695 g.out <<
"You can't send messages from ship scope.\n";
700 if (!
enufAP(Playernum
, Governor
, Stars[g.snum]->AP[Playernum - 1]
, 706 Race = races[Playernum - 1];
710 sprintf(msg,
"%s \"%s\" [%d,%d] to %s [%d]: ", Race->name,
711 Race->governor[Governor].name, Playernum, Governor,
712 Blocks[who - 1].name, who);
714 sprintf(msg,
"%s \"%s\" [%d,%d] to inhabitants of %s: ", Race->name,
715 Race->governor[Governor].name, Playernum, Governor,
718 sprintf(msg,
"%s \"%s\" [%d,%d]: ", Race->name,
719 Race->governor[Governor].name, Playernum, Governor);
721 if (to_star || to_block || isdigit(*argv[2].c_str()))
728 for (j = start; j < argv.size(); j++) {
729 sprintf(buf,
"%s ", argv[j].c_str());
734 "%s \"%s\" [%d,%d] has sent you a telegram. Use `read' to read it.\n",
735 Race->name, Race->governor[Governor].name, Playernum, Governor);
737 dummy[0] = (Blocks[who - 1].invite[0] & Blocks[who - 1].pledge[0]);
738 dummy[1] = (Blocks[who - 1].invite[1] & Blocks[who - 1].pledge[1]);
740 "%s \"%s\" [%d,%d] sends a message to %s [%d] alliance block.\n",
741 Race->name, Race->governor[Governor].name, Playernum, Governor,
742 Blocks[who - 1].name, who);
743 for (i = 1; i <= Num_races; i++) {
744 if (
isset(dummy, i)) {
746 push_telegram_race(i, msg);
749 }
else if (to_star) {
750 sprintf(buf,
"%s \"%s\" [%d,%d] sends a stargram to %s.\n", Race->name,
751 Race->governor[Governor].name, Playernum, Governor,
753 notify_star(Playernum, Governor, star, buf);
754 warn_star(Playernum, star, msg);
757 if (who == Playernum) APcount = 0;
758 if (isdigit(*argv[2].c_str()) && (gov = std::stoi(argv[2])) >= 0 &&
760 push_telegram(who, gov, msg);
761 notify(who, gov, buf);
763 push_telegram_race(who, msg);
764 notify_race(who, buf);
767 alien = races[who - 1];
769 alien->translate[Playernum - 1] =
770 MIN(alien->translate[Playernum - 1] + 2, 100);
773 g.out <<
"Message sent.\n";
779 player_t Playernum = g.player;
780 governor_t Governor = g.governor;
781 if (argv.size() == 1 || argv[1] ==
"telegram")
783 else if (argv[1] ==
"news") {
785 notify(Playernum, Governor,
786 "\n---------- Declarations ----------\n");
788 notify(Playernum, Governor,
789 "\n---------- Combat ----------\n");
791 notify(Playernum, Governor,
792 "\n---------- Business ----------\n");
794 notify(Playernum, Governor,
795 "\n---------- Bulletins ----------\n");
798 g.out <<
"Read what?\n";
801 void motto(
const command_t &argv, GameObj &g) {
803 player_t Playernum = g.player;
804 governor_t Governor = g.governor;
806 std::stringstream ss_message;
807 std::copy(++argv.begin(), argv.end(),
808 std::ostream_iterator<std::string>(ss_message,
" "));
809 std::string message = ss_message.str();
812 g.out <<
"You are not authorized to do this.\n";
815 strncpy(Blocks[Playernum - 1].motto, message.c_str(),
MOTTOSIZE - 1);
820 void name(
const command_t &argv, GameObj &g) {
822 player_t Playernum = g.player;
823 governor_t Governor = g.governor;
826 unsigned char check = 0;
831 if (argv.size() < 3 || !isalnum(argv[2][0])) {
832 g.out <<
"Illegal name format.\n";
836 sprintf(buf,
"%s", argv[2].c_str());
837 for (
int i = 3; i < argv.size(); i++) {
838 sprintf(tmp,
" %s", argv[i].c_str());
842 sprintf(string,
"%s", buf);
848 while (*ch !=
'\0') {
850 ((!isalnum(*ch) && !(*ch ==
' ') && !(*ch ==
'.')) || (*ch ==
'/'));
852 if (*ch ==
' ') spaces++;
855 if (spaces == strlen(buf)) {
856 g.out <<
"Illegal name.\n";
860 if (strlen(buf) < 1 || check) {
861 sprintf(buf,
"Illegal name %s.\n", check ?
"form" :
"length");
862 notify(Playernum, Governor, buf);
866 if (argv[1] ==
"ship") {
867 if (g.level == ScopeLevel::LEVEL_SHIP) {
868 auto ship = getship(g.shipno);
871 g.out <<
"Name set.\n";
874 g.out <<
"You have to 'cs' to a ship to name it.\n";
877 if (argv[1] ==
"class") {
878 if (g.level == ScopeLevel::LEVEL_SHIP) {
879 auto ship = getship(g.shipno);
880 if (ship->type != ShipType::OTYPE_FACTORY) {
881 g.out <<
"You are not at a factory!\n";
885 g.out <<
"This factory is already on line.\n";
890 g.out <<
"Class set.\n";
893 g.out <<
"You have to 'cs' to a factory to name the ship class.\n";
896 if (argv[1] ==
"block") {
899 g.out <<
"You are not authorized to do this.\n";
902 strncpy(Blocks[Playernum - 1].name, buf,
RNAMESIZE - 1);
905 }
else if (argv[1] ==
"star") {
906 if (g.level == ScopeLevel::LEVEL_STAR) {
907 Race = races[Playernum - 1];
909 g.out <<
"Only dieties may name a star.\n";
912 strncpy(Stars[g.snum]->name, buf,
NAMESIZE - 1);
915 g.out <<
"You have to 'cs' to a star to name it.\n";
918 }
else if (argv[1] ==
"planet") {
919 if (g.level == ScopeLevel::LEVEL_PLAN) {
921 Race = races[Playernum - 1];
923 g.out <<
"Only deity can rename planets.\n";
926 strncpy(Stars[g.snum]->pnames[g.pnum], buf,
NAMESIZE - 1);
930 g.out <<
"You have to 'cs' to a planet to name it.\n";
933 }
else if (argv[1] ==
"race") {
934 Race = races[Playernum - 1];
936 g.out <<
"You are not authorized to do this.\n";
940 sprintf(buf,
"Name changed to `%s'.\n", Race->name);
941 notify(Playernum, Governor, buf);
943 }
else if (argv[1] ==
"governor") {
944 Race = races[Playernum - 1];
945 strncpy(Race->governor[Governor].name, buf,
RNAMESIZE - 1);
946 sprintf(buf,
"Name changed to `%s'.\n", Race->governor[Governor].name);
947 notify(Playernum, Governor, buf);
950 g.out <<
"I don't know what you mean.\n";
956 player_t Playernum = g.player;
957 governor_t Governor = g.governor;
959 enum class Communicate {
967 if (argv[0] ==
"announce")
968 mode = Communicate::ANN;
969 else if (argv[0] ==
"broadcast")
970 mode = Communicate::BROADCAST;
971 else if (argv[0] ==
"'")
972 mode = Communicate::BROADCAST;
973 else if (argv[0] ==
"shout")
974 mode = Communicate::SHOUT;
975 else if (argv[0] ==
"think")
976 mode = Communicate::THINK;
978 g.out <<
"Not sure how you got here.\n";
985 Race = races[Playernum - 1];
986 if (mode == Communicate::SHOUT && !Race->God) {
987 g.out <<
"You are not privileged to use this command.\n";
991 std::stringstream ss_message;
992 std::copy(++argv.begin(), argv.end(),
993 std::ostream_iterator<std::string>(ss_message,
" "));
994 std::string message = ss_message.str();
997 case ScopeLevel::LEVEL_UNIV:
998 if (mode == Communicate::ANN) mode = Communicate::BROADCAST;
1001 if ((mode == Communicate::ANN) &&
1002 !(!!
isset(Stars[g.snum]->inhabited, Playernum) || Race->God)) {
1003 g.out <<
"You do not inhabit this system or have diety privileges.\n";
1009 case Communicate::ANN:
1012 case Communicate::BROADCAST:
1015 case Communicate::SHOUT:
1018 case Communicate::THINK:
1023 sprintf(msg,
"%s \"%s\" [%d,%d] %c %s\n", Race->name,
1024 Race->governor[Governor].name, Playernum, Governor, symbol,
1028 case Communicate::ANN:
1029 d_announce(Playernum, Governor, g.snum, msg);
1031 case Communicate::BROADCAST:
1032 d_broadcast(Playernum, Governor, msg);
1034 case Communicate::SHOUT:
1035 d_shout(Playernum, Governor, msg);
1037 case Communicate::THINK:
1038 d_think(Playernum, Governor, msg);
void teleg_read(GameObj &g)
void post(const char *origmsg, int type)
double morale_factor(double x)
Planet getplanet(const starnum_t star, const planetnum_t pnum)
void personal(const command_t &argv, GameObj &g)
void page(const command_t &argv, GameObj &g)
void announce(const command_t &argv, GameObj &g)
void pay(const command_t &argv, GameObj &g)
void news_read(int Playernum, int Governor, int type)
void insurgency(const command_t &argv, GameObj &g)
void deductAPs(const player_t Playernum, const governor_t Governor, unsigned int n, starnum_t snum, int sdata)
void read_messages(const command_t &argv, GameObj &g)
int enufAP(int Playernum, int Governor, unsigned short AP, int x)
void motto(const command_t &argv, GameObj &g)
void Putblock(struct block b[MAXPLAYERS])
void putstar(startype *s, starnum_t snum)
void send_message(const command_t &argv, GameObj &g)
void putplanet(const Planet &p, startype *star, const int pnum)
void getstar(startype **s, int star)
void give(const command_t &argv, GameObj &g)
int revolt(Planet *pl, int victim, int agent)
void name(const command_t &argv, GameObj &g)
void bless(const command_t &argv, GameObj &g)
int control(int Playernum, int Governor, startype *star)