Next step towards structure merge.
[super-star-trek.git] / sst.c
diff --git a/sst.c b/sst.c
index fa24d75dbaafb779fb486f9d02e57cef79a8b3e7..55066eb7fdeaa9b487647493486b2c434834a739 100644 (file)
--- a/sst.c
+++ b/sst.c
@@ -13,8 +13,6 @@ static int linecount; /* for paging */
 \r
 static void clearscreen(void);\r
 \r
-#define NUMCOMMANDS 34\r
-\r
 /* Compared to original version, I've changed the "help" command to\r
    "call" and the "terminate" command to "quit" to better match\r
    user expectations. The DECUS version apparently made those changes\r
@@ -52,7 +50,7 @@ static void clearscreen(void);
    */\r
 \r
 \r
-static char *commands[NUMCOMMANDS] = {\r
+static char *commands[] = {\r
        "srscan",\r
        "lrscan",\r
        "phasers",\r
@@ -88,6 +86,7 @@ static char *commands[NUMCOMMANDS] = {
        "quit",\r
        "help"\r
 };\r
+#define NUMCOMMANDS    sizeof(commands)/sizeof(commands[0])\r
 \r
 static void listCommands(int x) {\r
        prout("   SRSCAN    MOVE      PHASERS   CALL\n"\r
@@ -324,7 +323,7 @@ static void makemoves(void) {
                                events();\r
                                if (alldone) break;             // Events did us in\r
                        }\r
-                       if (d.galaxy[quadx][quady] == 1000) { // Galaxy went Nova!\r
+                       if (state.galaxy[quadx][quady] == 1000) { // Galaxy went Nova!\r
                                atover(0);\r
                                continue;\r
                        }\r
@@ -332,7 +331,7 @@ static void makemoves(void) {
                        if (hitme && justin==0) {\r
                                attack(2);\r
                                if (alldone) break;\r
-                               if (d.galaxy[quadx][quady] == 1000) {   // went NOVA! \r
+                               if (state.galaxy[quadx][quady] == 1000) {       // went NOVA! \r
                                        atover(0);\r
                                        hitme = TRUE;\r
                                        continue;\r
@@ -345,7 +344,7 @@ static void makemoves(void) {
 }\r
 \r
 \r
-void main(int argc, char **argv) {\r
+int main(int argc, char **argv) {\r
        int i;\r
        int hitme;\r
        char ch;\r
@@ -486,7 +485,8 @@ int scan(void) {
                        chew();\r
                        return IHEOL;\r
                }\r
-               gets(line);\r
+               fgets(line, sizeof(line), stdin);\r
+               line[strlen(line)-1] = '\0';\r
                linep = line;\r
        }\r
        // Skip leading white space\r
@@ -657,7 +657,7 @@ void debugme(void) {
                        key = scan();\r
                        if (key == IHALPHA &&  isit("y")) {\r
                                damage[i] = 10.0;\r
-                               if (i == DRADIO) stdamtim = d.date;\r
+                               if (i == DRADIO) stdamtim = state.date;\r
                        }\r
                }\r
        }\r
@@ -676,12 +676,12 @@ void debugme(void) {
                                case FSCMOVE: proutn("SC Move         "); break;\r
                                case FSCDBAS: proutn("SC Base Destroy "); break;\r
                        }\r
-                       cramf(future[i]-d.date, 8, 2);\r
+                       cramf(future[i]-state.date, 8, 2);\r
                        chew();\r
                        proutn("  ?");\r
                        key = scan();\r
                        if (key == IHREAL) {\r
-                               future[i] = d.date + aaitem;\r
+                               future[i] = state.date + aaitem;\r
                        }\r
                }\r
                chew();\r