X-Git-Url: https://jxself.org/git/?p=super-star-trek.git;a=blobdiff_plain;f=sst.c;h=f6db8870c9ae1856cf8eb55d345ac0981475a7c6;hp=fa24d75dbaafb779fb486f9d02e57cef79a8b3e7;hb=77e371705e1e059173ec9c88f63be7a460e44e50;hpb=62ecc7f7980b836681dc37f6ac0e03f976916050 diff --git a/sst.c b/sst.c index fa24d75..f6db887 100644 --- a/sst.c +++ b/sst.c @@ -13,8 +13,6 @@ static int linecount; /* for paging */ static void clearscreen(void); -#define NUMCOMMANDS 34 - /* Compared to original version, I've changed the "help" command to "call" and the "terminate" command to "quit" to better match user expectations. The DECUS version apparently made those changes @@ -52,7 +50,7 @@ static void clearscreen(void); */ -static char *commands[NUMCOMMANDS] = { +static char *commands[] = { "srscan", "lrscan", "phasers", @@ -88,6 +86,7 @@ static char *commands[NUMCOMMANDS] = { "quit", "help" }; +#define NUMCOMMANDS sizeof(commands)/sizeof(commands[0]) static void listCommands(int x) { prout(" SRSCAN MOVE PHASERS CALL\n" @@ -324,7 +323,7 @@ static void makemoves(void) { events(); if (alldone) break; // Events did us in } - if (d.galaxy[quadx][quady] == 1000) { // Galaxy went Nova! + if (game.state.galaxy[quadx][quady] == 1000) { // Galaxy went Nova! atover(0); continue; } @@ -332,7 +331,7 @@ static void makemoves(void) { if (hitme && justin==0) { attack(2); if (alldone) break; - if (d.galaxy[quadx][quady] == 1000) { // went NOVA! + if (game.state.galaxy[quadx][quady] == 1000) { // went NOVA! atover(0); hitme = TRUE; continue; @@ -345,7 +344,7 @@ static void makemoves(void) { } -void main(int argc, char **argv) { +int main(int argc, char **argv) { int i; int hitme; char ch; @@ -486,7 +485,8 @@ int scan(void) { chew(); return IHEOL; } - gets(line); + fgets(line, sizeof(line), stdin); + line[strlen(line)-1] = '\0'; linep = line; } // Skip leading white space @@ -637,7 +637,7 @@ void debugme(void) { proutn("Reset damage? "); if (ja() != 0) { int i; - for (i=0; i <= ndevice; i++) if (damage[i] > 0.0) damage[i] = 0.0; + for (i=0; i <= NDEVICES; i++) if (damage[i] > 0.0) damage[i] = 0.0; stdamtim = 1e30; } proutn("Toggle idebug? "); @@ -649,7 +649,7 @@ void debugme(void) { proutn("Cause selective damage? "); if (ja() != 0) { int i, key; - for (i=1; i <= ndevice; i++) { + for (i=1; i <= NDEVICES; i++) { proutn("Kill "); proutn(device[i]); proutn("? "); @@ -657,7 +657,7 @@ void debugme(void) { key = scan(); if (key == IHALPHA && isit("y")) { damage[i] = 10.0; - if (i == DRADIO) stdamtim = d.date; + if (i == DRADIO) stdamtim = game.state.date; } } } @@ -676,12 +676,12 @@ void debugme(void) { case FSCMOVE: proutn("SC Move "); break; case FSCDBAS: proutn("SC Base Destroy "); break; } - cramf(future[i]-d.date, 8, 2); + cramf(future[i]-game.state.date, 8, 2); chew(); proutn(" ?"); key = scan(); if (key == IHREAL) { - future[i] = d.date + aaitem; + future[i] = game.state.date + aaitem; } } chew();