void kills(int x, int y, int f) { struct quad *q; struct event *e; const char *name; if (f) { /* current quadrant */ q = &Quad[Ship.quadx][Ship.quady]; Sect[x][y] = EMPTY; name = systemname(q); if (name == NULL) return; printf("Inhabited starsystem %s at %d,%d destroyed\n", name, x, y); if (f < 0) Game.killinhab += 1; } else { /* different quadrant */ q = &Quad[x][y]; } if (q->qsystemname & Q_DISTRESSED) { /* distressed starsystem */ e = &Event[q->qsystemname & Q_SYSTEM]; printf("Distress call for %s invalidated\n", Systemname[e->systemname]); unschedule(e); } q->qsystemname = 0; q->stars -= 1; }
dumpssradio() { register struct event *e; register int j; register int chkrest; chkrest = 0; for (j = 0; j < MAXEVENTS; j++) { e = &Event[j]; /* if it is not hidden, then just ignore it */ if ((e->evcode & E_HIDDEN) == 0) continue; if (e->evcode & E_GHOST) { unschedule(e); printf("Starsystem %s in quadrant %d,%d is no longer distressed\n", systemname(e), e->x, e->y); continue; } switch (e->evcode) { case E_KDESB: printf("Starbase in quadrant %d,%d is under attack\n", e->x, e->y); chkrest++; break; case E_ENSLV: case E_REPRO: printf("Starsystem %s in quadrant %d,%d is distressed\n", systemname(e), e->x, e->y); chkrest++; break; } } return (chkrest); }
void httpreply (int nstatus, std::string const& content, rpc::output output) { if (shouldlog (lstrace, rpc)) { writelog (lstrace, rpc) << "http reply " << nstatus << " " << content; } if (nstatus == 401) { output ("http/1.0 401 authorization required\r\n"); output (gethttpheadertimestamp ()); // checkme this returns a different version than the replies below. is // this by design or an accident or should it be using // buildinfo::getfullversionstring () as well? output ("server: " + systemname () + "-json-rpc/v1"); output ("\r\n"); // be careful in modifying this! if you change the contents you must // update the content-length header as well to indicate the correct // size of the data. output ("www-authenticate: basic realm=\"jsonrpc\"\r\n" "content-type: text/html\r\n" "content-length: 296\r\n" "\r\n" "<!doctype html public \"-//w3c//dtd html 4.01 " "transitional//en\"\r\n" "\"http://www.w3.org/tr/1999/rec-html401-19991224/loose.dtd" "\">\r\n" "<html>\r\n" "<head>\r\n" "<title>error</title>\r\n" "<meta http-equiv='content-type' " "content='text/html; charset=iso-8859-1'>\r\n" "</head>\r\n" "<body><h1>401 unauthorized.</h1></body>\r\n"); return; } switch (nstatus) { case 200: output ("http/1.1 200 ok\r\n"); break; case 400: output ("http/1.1 400 bad request\r\n"); break; case 403: output ("http/1.1 403 forbidden\r\n"); break; case 404: output ("http/1.1 404 not found\r\n"); break; case 500: output ("http/1.1 500 internal server error\r\n"); break; } output (gethttpheadertimestamp ()); output ("connection: keep-alive\r\n" "content-length: "); // vfalco todo determine if/when this header should be added //if (getconfig ().rpc_allow_remote) // output ("access-control-allow-origin: *\r\n"); output (std::to_string(content.size () + 2)); output ("\r\n" "content-type: application/json; charset=utf-8\r\n"); output ("server: " + systemname () + "-json-rpc/"); output (buildinfo::getfullversionstring ()); output ("\r\n" "\r\n"); output (content); output ("\r\n"); }
void abandon(int v __unused) { struct quad *q; int i; int j; struct event *e; if (Ship.ship == QUEENE) { printf("You may not abandon ye Faire Queene\n"); return; } if (Ship.cond != DOCKED) { if (damaged(SHUTTLE)) { out(SHUTTLE); return; } printf("Officers escape in shuttlecraft\n"); /* decide on fate of crew */ q = &Quad[Ship.quadx][Ship.quady]; if (q->qsystemname == 0 || damaged(XPORTER)) { printf("Entire crew of %d left to die in outer space\n", Ship.crew); Game.deaths += Ship.crew; } else { printf("Crew beams down to planet %s\n", systemname(q)); } } /* see if you can be exchanged */ if (Now.bases == 0 || Game.captives < 20 * Game.skill) lose(L_CAPTURED); /* re-outfit new ship */ printf("You are hereby put in charge of an antiquated but still\n"); printf(" functional ship, the Fairie Queene.\n"); Ship.ship = QUEENE; Ship.shipname = "Fairie Queene"; Param.energy = Ship.energy = 3000; Param.torped = Ship.torped = 6; Param.shield = Ship.shield = 1250; Ship.shldup = 0; Ship.cloaked = 0; Ship.warp = 5.0; Ship.warp2 = 25.0; Ship.warp3 = 125.0; Ship.cond = GREEN; /* clear out damages on old ship */ for (i = 0; i < MAXEVENTS; i++) { e = &Event[i]; if (e->evcode != E_FIXDV) continue; unschedule(e); } /* get rid of some devices and redistribute probabilities */ i = Param.damprob[SHUTTLE] + Param.damprob[CLOAK]; Param.damprob[SHUTTLE] = Param.damprob[CLOAK] = 0; while (i > 0) for (j = 0; j < NDEV; j++) { if (Param.damprob[j] != 0) { Param.damprob[j] += 1; i--; if (i <= 0) break; } } /* pick a starbase to restart at */ i = ranf(Now.bases); Ship.quadx = Now.base[i].x; Ship.quady = Now.base[i].y; /* setup that quadrant */ while (1) { initquad(1); Sect[Ship.sectx][Ship.secty] = EMPTY; for (i = 0; i < 5; i++) { Ship.sectx = Etc.starbase.x + ranf(3) - 1; if (Ship.sectx < 0 || Ship.sectx >= NSECTS) continue; Ship.secty = Etc.starbase.y + ranf(3) - 1; if (Ship.secty < 0 || Ship.secty >= NSECTS) continue; if (Sect[Ship.sectx][Ship.secty] == EMPTY) { Sect[Ship.sectx][Ship.secty] = QUEENE; dock(0); compkldist(0); return; } } } }