7 #include "gb/dissolve.h" 12 #include "gb/GB_server.h" 13 #include "gb/buffers.h" 15 #include "gb/files_shl.h" 18 #include "gb/shlmisc.h" 20 #include "gb/tweakables.h" 21 #include "gb/utils/rand.h" 24 void dissolve(
const command_t &argv, GameObj &g) {
25 player_t Playernum = g.player;
26 governor_t Governor = g.governor;
28 notify(Playernum, Governor,
29 "Dissolve has been disabled. Please notify diety.\n");
40 notify(Playernum, Governor,
41 "Only the leader may dissolve the race. The " 42 "leader has been notified of your " 44 sprintf(buf,
"Governor #%d has attempted to dissolve this race.\n",
46 notify(Playernum, 0, buf);
50 if (argv.size() < 3) {
51 g.out <<
"Self-Destruct sequence requires passwords.\n";
52 g.out <<
"Please use 'dissolve <race password> <leader " 53 "password>'<option> to initiate\n";
54 g.out <<
"self-destruct sequence.\n";
57 g.out <<
"WARNING!! WARNING!! WARNING!!\n";
58 g.out <<
"-------------------------------\n";
59 g.out <<
"Entering self destruct sequence!\n";
61 sscanf(argv[1].c_str(),
"%s", racepass);
62 sscanf(argv[2].c_str(),
"%s", govpass);
65 if (argv.size() > 3) {
66 if (argv[3][0] ==
'w') waste =
true;
69 auto [player, governor] = getracenum(racepass, govpass);
71 if (!player || !governor) {
72 g.out <<
"Password mismatch, self-destruct not initiated!\n";
77 for (i = 1; i <= n_ships; i++) {
79 if (sp->owner != Playernum)
continue;
80 kill_ship(Playernum, &*sp);
81 sprintf(buf,
"Ship #%d, self-destruct enabled\n", i);
82 notify(Playernum, Governor, buf);
87 for (z = 0; z < Sdata.numstars; z++) {
89 if (
isset(Stars[z]->explored, Playernum)) {
90 for (i = 0; i < Stars[z]->numplanets; i++) {
93 if (pl.info[Playernum - 1].explored &&
94 pl.info[Playernum - 1].numsectsowned) {
95 pl.info[Playernum - 1].fuel = 0;
96 pl.info[Playernum - 1].destruct = 0;
97 pl.info[Playernum - 1].resource = 0;
98 pl.info[Playernum - 1].popn = 0;
99 pl.info[Playernum - 1].troops = 0;
100 pl.info[Playernum - 1].tax = 0;
101 pl.info[Playernum - 1].newtax = 0;
102 pl.info[Playernum - 1].crystals = 0;
103 pl.info[Playernum - 1].numsectsowned = 0;
104 pl.info[Playernum - 1].explored = 0;
105 pl.info[Playernum - 1].autorep = 0;
109 for (
auto &s : smap) {
110 if (s.owner == Playernum) {
114 if (waste) s.condition = SectorType::SEC_WASTED;
124 Race = races[Playernum - 1];
128 sprintf(buf,
"%s [%d] has dissolved.\n", Race->name, Playernum);
134 int revolt(Planet *pl,
int victim,
int agent) {
142 int changed_hands = 0;
144 Race = races[victim - 1];
152 for (y = lowy; y <= hiy; y++) {
153 for (x = lowx; x <= hix; x++) {
154 auto &s = smap.get(x, y);
155 if (s.owner == victim && s.popn) {
156 if (success(pl->info[victim - 1].tax)) {
157 if (
static_cast<
unsigned long>(long_rand(1, s.popn)) >
158 10 * Race->fighters * s.troops) {
160 s.popn = int_rand(1, (
int)s.popn);
162 pl->info[victim - 1].numsectsowned -= 1;
163 pl->info[agent - 1].numsectsowned += 1;
164 pl->info[victim - 1].mob_points -= s.mobilization;
165 pl->info[agent - 1].mob_points += s.mobilization;
174 return changed_hands;
void post(const char *origmsg, int type)
Planet getplanet(const starnum_t star, const planetnum_t pnum)
void putsmap(SectorMap &map, Planet &p)
void putstar(startype *s, starnum_t snum)
void dissolve(const command_t &argv, GameObj &g)
void getsdata(struct stardata *S)
void putplanet(const Planet &p, startype *star, const int pnum)
void getstar(startype **s, int star)
SectorMap getsmap(const Planet &p)
int revolt(Planet *pl, int victim, int agent)