X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;ds=sidebyside;f=src%2Fsst.c;h=b68613d21f8fe26540b763805755d387594ad55a;hb=c81e0f1dc6cd1fe5c56e9d521ee1d262932e3a2b;hp=75dca51ba19433a974bba33d5e1e89a74def516b;hpb=e535e2ef833a03ec84d0f002d684c07ddde893f1;p=super-star-trek.git diff --git a/src/sst.c b/src/sst.c index 75dca51..b68613d 100644 --- a/src/sst.c +++ b/src/sst.c @@ -152,13 +152,20 @@ for a lot of magic numbers and refactored the heck out of it. 4. Added game option selection so you can play a close (but not bug-for- bug identical) approximation of older versions. + + 5. Half the quadrants now have inhabited planets, from which one + cannot mine dilithium (there will still be the same additional number + of dilithium-bearing planets). Right now this is just color, but + eventually we'll fold in BSD-Trek-like logic for Klingons to attack + and enslave inhabited worlds. */ /* the input queue */ static char line[128], *linep = line; struct game game; -int thingx, thingy, iqhere, iqengry; +coord thing; +int iqhere, iqengry; int iscore, iskill; // Common PLAQ double aaitem; double perdate; @@ -202,66 +209,66 @@ commands[] = { #define TORPEDO 5 {"TORPEDO", TORPEDO, 0}, {"PHOTONS", TORPEDO, 0}, -#define MOVE 6 +#define MOVE 7 {"MOVE", MOVE, 0}, -#define SHIELDS 7 +#define SHIELDS 8 {"SHIELDS", SHIELDS, 0}, -#define DOCK 8 +#define DOCK 9 {"DOCK", DOCK, 0}, -#define DAMAGES 9 +#define DAMAGES 10 {"DAMAGES", DAMAGES, 0}, -#define CHART 10 +#define CHART 11 {"CHART", CHART, 0}, -#define IMPULSE 11 +#define IMPULSE 12 {"IMPULSE", IMPULSE, 0}, -#define REST 12 +#define REST 13 {"REST", REST, 0}, -#define WARP 13 +#define WARP 14 {"WARP", WARP, 0}, -#define SCORE 14 +#define SCORE 15 {"SCORE", SCORE, 0}, -#define SENSORS 15 +#define SENSORS 16 {"SENSORS", SENSORS, OPTION_PLANETS}, -#define ORBIT 16 +#define ORBIT 17 {"ORBIT", ORBIT, OPTION_PLANETS}, -#define TRANSPORT 17 +#define TRANSPORT 18 {"TRANSPORT", TRANSPORT, OPTION_PLANETS}, -#define MINE 18 +#define MINE 19 {"MINE", MINE, OPTION_PLANETS}, -#define CRYSTALS 19 +#define CRYSTALS 20 {"CRYSTALS", CRYSTALS, OPTION_PLANETS}, -#define SHUTTLE 20 +#define SHUTTLE 21 {"SHUTTLE", SHUTTLE, OPTION_PLANETS}, -#define PLANETS 21 +#define PLANETS 22 {"PLANETS", PLANETS, OPTION_PLANETS}, -#define REPORT 22 +#define REPORT 23 {"REPORT", REPORT, 0}, -#define COMPUTER 23 +#define COMPUTER 24 {"COMPUTER", COMPUTER, 0}, -#define COMMANDS 24 +#define COMMANDS 25 {"COMMANDS", COMMANDS, 0}, -#define EMEXIT 25 +#define EMEXIT 26 {"EMEXIT", EMEXIT, 0}, -#define PROBE 26 +#define PROBE 27 {"PROBE", PROBE, OPTION_PROBE}, -#define SAVE 27 +#define SAVE 28 {"SAVE", SAVE, 0}, {"FREEZE", SAVE, 0}, -#define ABANDON 28 +#define ABANDON 30 {"ABANDON", ABANDON, 0}, -#define DESTRUCT 29 +#define DESTRUCT 31 {"DESTRUCT", DESTRUCT, 0}, -#define DEATHRAY 30 +#define DEATHRAY 32 {"DEATHRAY", DEATHRAY, 0}, -#define DEBUGCMD 31 +#define DEBUGCMD 33 {"DEBUG", DEBUGCMD, 0}, -#define MAYDAY 32 +#define MAYDAY 34 {"MAYDAY", MAYDAY, 0}, //{"SOS", MAYDAY, 0}, //{"CALL", MAYDAY, 0}, -#define QUIT 33 +#define QUIT 35 {"QUIT", QUIT, 0}, -#define HELP 34 +#define HELP 36 {"HELP", HELP, 0}, }; @@ -375,8 +382,8 @@ static void makemoves(void) drawmaps(1); while (TRUE) { /* get a command */ hitme = FALSE; - justin = 0; - Time = 0.0; + game.justin = 0; + game.optime = 0.0; i = -1; chew(); setwnd(prompt_window); @@ -386,7 +393,7 @@ static void makemoves(void) makechart(); continue; } - ididit=0; + game.ididit=0; clrscr(); setwnd(message_window); clrscr(); @@ -422,25 +429,25 @@ static void makemoves(void) break; case PHASERS: // phasers phasers(); - if (ididit) hitme = TRUE; + if (game.ididit) hitme = TRUE; break; case TORPEDO: // photons photon(); - if (ididit) hitme = TRUE; + if (game.ididit) hitme = TRUE; break; case MOVE: // move warp(1); break; case SHIELDS: // shields doshield(1); - if (ididit) { + if (game.ididit) { hitme=TRUE; - shldchg = 0; + game.shldchg = 0; } break; case DOCK: // dock dock(1); - if (ididit) attack(0); + if (game.ididit) attack(0); break; case DAMAGES: // damages dreprt(); @@ -453,7 +460,7 @@ static void makemoves(void) break; case REST: // rest wait(); - if (ididit) hitme = TRUE; + if (game.ididit) hitme = TRUE; break; case WARP: // warp setwrp(); @@ -466,22 +473,22 @@ static void makemoves(void) break; case ORBIT: // orbit orbit(); - if (ididit) hitme = TRUE; + if (game.ididit) hitme = TRUE; break; case TRANSPORT: // transport "beam" beam(); break; case MINE: // mine mine(); - if (ididit) hitme = TRUE; + if (game.ididit) hitme = TRUE; break; case CRYSTALS: // crystals usecrystals(); - if (ididit) hitme = TRUE; + if (game.ididit) hitme = TRUE; break; case SHUTTLE: // shuttle shuttle(); - if (ididit) hitme = TRUE; + if (game.ididit) hitme = TRUE; break; case PLANETS: // Planet list preport(); @@ -502,7 +509,7 @@ static void makemoves(void) break; case PROBE: probe(); // Launch probe - if (ididit) hitme = TRUE; + if (game.ididit) hitme = TRUE; break; case ABANDON: // Abandon Ship abandn(); @@ -513,12 +520,12 @@ static void makemoves(void) case SAVE: // Save Game freeze(FALSE); clrscr(); - if (skill > SKILL_GOOD) + if (game.skill > SKILL_GOOD) prout("WARNING--Saved games produce no plaques!"); break; case DEATHRAY: // Try a desparation measure deathray(); - if (ididit) hitme = TRUE; + if (game.ididit) hitme = TRUE; break; case DEBUGCMD: // What do we want for debug??? #ifdef DEBUG @@ -526,13 +533,13 @@ static void makemoves(void) #endif break; case MAYDAY: // Call for help - help(); - if (ididit) hitme = TRUE; + mayday(); + if (game.ididit) hitme = TRUE; break; case QUIT: - alldone = 1; // quit the game + game.alldone = 1; // quit the game #ifdef DEBUG - if (idebug) score(); + if (game.idebug) score(); #endif break; case HELP: @@ -541,22 +548,22 @@ static void makemoves(void) } commandhook(commands[i].name, FALSE); for (;;) { - if (alldone) break; // Game has ended + if (game.alldone) break; // Game has ended #ifdef DEBUG - if (idebug) prout("2500"); + if (game.idebug) prout("2500"); #endif - if (Time != 0.0) { + if (game.optime != 0.0) { events(); - if (alldone) break; // Events did us in + if (game.alldone) break; // Events did us in } - if (game.state.galaxy[quadx][quady].supernova) { // Galaxy went Nova! + if (game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova) { // Galaxy went Nova! atover(0); continue; } - if (hitme && justin==0) { + if (hitme && game.justin==0) { attack(2); - if (alldone) break; - if (game.state.galaxy[quadx][quady].supernova) { // went NOVA! + if (game.alldone) break; + if (game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova) { // went NOVA! atover(0); hitme = TRUE; continue; @@ -564,7 +571,7 @@ static void makemoves(void) } break; } - if (alldone) break; + if (game.alldone) break; } } @@ -607,16 +614,16 @@ int main(int argc, char **argv) clrscr(); prelim(); setup(line[0] == '\0'); - if (alldone) { + if (game.alldone) { score(); - alldone = 0; + game.alldone = 0; } else makemoves(); skip(1); stars(); skip(1); - if (tourn && alldone) { + if (game.tourn && game.alldone) { proutn("Do you want your score recorded?"); if (ja()) { chew2(); @@ -654,28 +661,28 @@ void cramen(int i) proutn(s); } -char *cramlc(enum loctype key, int x, int y) +char *cramlc(enum loctype key, coord w) { static char buf[32]; buf[0] = '\0'; if (key == quadrant) strcpy(buf, "Quadrant "); else if (key == sector) strcpy(buf, "Sector "); - sprintf(buf+strlen(buf), "%d - %d", x, y); + sprintf(buf+strlen(buf), "%d - %d", w.x, w.y); return buf; } -void crmena(int i, int enemy, int key, int x, int y) +void crmena(int i, int enemy, int key, coord w) { if (i == 1) proutn("***"); cramen(enemy); proutn(" at "); - proutn(cramlc(key, x, y)); + proutn(cramlc(key, w)); } void crmshp(void) { char *s; - switch (ship) { + switch (game.ship) { case IHE: s = "Enterprise"; break; case IHF: s = "Faerie Queene"; break; default: s = "Ship???"; break; @@ -805,10 +812,10 @@ void debugme(void) { proutn("Reset levels? "); if (ja() != 0) { - if (energy < inenrg) energy = inenrg; - shield = inshld; - torps = intorps; - lsupres = inlsr; + if (energy < game.inenrg) energy = game.inenrg; + shield = game.inshld; + torps = game.intorps; + game.lsupres = game.inlsr; } proutn("Reset damage? "); if (ja() != 0) { @@ -817,10 +824,10 @@ void debugme(void) if (game.damage[i] > 0.0) game.damage[i] = 0.0; } - proutn("Toggle idebug? "); + proutn("Toggle game.idebug? "); if (ja() != 0) { - idebug = !idebug; - if (idebug) prout("Debug output ON"); + game.idebug = !game.idebug; + if (game.idebug) prout("Debug output ON"); else prout("Debug output OFF"); } proutn("Cause selective damage? "); @@ -842,7 +849,7 @@ void debugme(void) int i; for (i = 1; i < NEVENTS; i++) { int key; - if (game.future[i] == FOREVER) continue; + if (!is_scheduled(i)) continue; switch (i) { case FSNOVA: proutn("Supernova "); break; case FTBEAM: proutn("T Beam "); break; @@ -852,19 +859,19 @@ void debugme(void) case FSCMOVE: proutn("SC Move "); break; case FSCDBAS: proutn("SC Base Destroy "); break; } - proutn("%.2f", game.future[i]-game.state.date); + proutn("%.2f", scheduled(i)-game.state.date); chew(); proutn(" ?"); key = scan(); if (key == IHREAL) { - game.future[i] = game.state.date + aaitem; + schedule(i, aaitem); } } chew(); } proutn("Induce supernova here? "); if (ja() != 0) { - game.state.galaxy[quadx][quady].supernova = TRUE; + game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova = TRUE; atover(1); } }