More int-to-boolean cleanup. Make the FDISTR event work.
[super-star-trek.git] / src / planets.c
index c76dace1fbffaafedd5201d345b8ccdf322a626f..0b554381e4395fa8761b524a47ba05f6532708cf 100644 (file)
@@ -11,23 +11,24 @@ static int consumeTime(void)
     game.ididit = 1;
 #if 0
     /* Don't worry about this */
-    if (future[FTBEAM] <= game.state.date+game.optime && game.state.remcom != 0 && game.condit != IHDOCKED) {
+    if (scheduled(FTBEAM) <= game.state.date+game.optime && game.state.remcom != 0 && game.condit != IHDOCKED) {
        /* We are about to be tractor beamed -- operation fails */
        return 1;
     }
 #endif
-//     asave = future[FSNOVA];
-//     future[FSNOVA] = FOREVER; /* defer supernovas */
-    events();  /* Used to avoid if future[FSCMOVE] within time */
-//     future[FSNOVA] = asave;
+//     asave = scheduled(FSNOVA);
+//     unschedule(FSNOVA); /* defer supernovas */
+    events();  /* Used to avoid if FSCMOVE is scheduled within time */
+//     schedule(FSNOVA, asave-game.state.time);
     /*fails if game over, quadrant super-novas or we've moved to new quadrant*/
-    if (game.alldone || game.state.galaxy[game.quadx][game.quady].supernova || game.justin != 0) return 1;
+    if (game.alldone || game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova || game.justin != 0) return 1;
     return 0;
 }
 
 void preport(void) 
 {
-    int iknow = 0, i;
+    bool iknow = false;
+    int i;
     skip(1);
     chew();
     prout("Spock-  \"Planet report follows, Captain.\"");
@@ -35,15 +36,12 @@ void preport(void)
     for (i = 0; i < game.inplan; i++) {
        if ((game.state.plnets[i].known != unknown
            && game.state.plnets[i].crystals != 0)
-#ifdef DEBUG
-           || ( game.idebug && game.state.plnets[i].x !=0)
-#endif
+           || (idebug && game.state.plnets[i].w.x !=0)
            ) {
-           iknow = 1;
-#ifdef DEBUG
-           if (game.idebug && game.state.plnets[i].known==unknown) proutn("(Unknown) ");
-#endif
-           proutn(cramlc(quadrant, game.state.plnets[i].x, game.state.plnets[i].y));
+           iknow = true;
+           if (idebug && game.state.plnets[i].known==unknown)
+               proutn("(Unknown) ");
+           proutn(cramlc(quadrant, game.state.plnets[i].w));
            proutn("   class ");
            proutn(classes[game.state.plnets[i].pclass]);
            proutn("   ");
@@ -60,7 +58,7 @@ void orbit(void)
 {
     skip(1);
     chew();
-    if (game.inorbit!=0) {
+    if (game.inorbit) {
        prout("Already in standard orbit.");
        return;
     }
@@ -68,7 +66,7 @@ void orbit(void)
        prout("Both warp and impulse engines damaged.");
        return;
     }
-    if (game.plnetx == 0 || abs(game.sectx-game.plnetx) > 1 || abs(game.secty-game.plnety) > 1) {
+    if (game.plnet.x == 0 || abs(game.sector.x-game.plnet.x) > 1 || abs(game.sector.y-game.plnet.y) > 1) {
        crmshp();
        prout(" not adjacent to planet.");
        skip(1);
@@ -80,8 +78,8 @@ void orbit(void)
     if (consumeTime()) return;
     game.height = (1400.0+7200.0*Rand());
     prout("Sulu-  \"Entered orbit at altitude %.2f kilometers.\"", game.height);
-    game.inorbit = 1;
-    game.ididit=1;
+    game.inorbit = true;
+    game.ididit = true;
 }
 
 void sensor(void) 
@@ -92,15 +90,15 @@ void sensor(void)
        prout("Short range sensors damaged.");
        return;
     }
-    if (!game.plnetx && (game.options & OPTION_TTY)) {
+    if (!game.plnet.x && (game.options & OPTION_TTY)) {
        prout("Spock- \"No planet in this quadrant, Captain.\"");
        return;
     }
-    if ((game.plnetx != 0)&& (game.state.plnets[game.iplnet].known == unknown)) {
-       prout("Spock-  \"Sensor scan for %s-", cramlc(quadrant, game.quadx, game.quady));
+    if ((game.plnet.x != 0)&& (game.state.plnets[game.iplnet].known == unknown)) {
+       prout("Spock-  \"Sensor scan for %s-", cramlc(quadrant, game.quadrant));
        skip(1);
-       prout("         Planet at %s is of class %s.", 
-             cramlc(sector, game.plnetx, game.plnety),
+       prout("         Planet at %s is of class %s.",
+             cramlc(sector,game.plnet),
              classes[game.state.plnets[game.iplnet].pclass]);
        if (game.state.plnets[game.iplnet].known==shuttle_down) 
            prout("         Sensors show Galileo still on surface.");
@@ -124,12 +122,12 @@ void beam(void)
        }
        return;
     }
-    if (game.inorbit==0) {
+    if (!game.inorbit) {
        crmshp();
        prout(" not in standard orbit.");
        return;
     }
-    if (game.shldup!=0) {
+    if (game.shldup) {
        prout("Impossible to transport through shields.");
        return;
     }
@@ -301,7 +299,7 @@ void shuttle(void)
        else prout("Shuttle craft is now serving Big Macs.");
        return;
     }
-    if (game.inorbit==0) {
+    if (!game.inorbit) {
        crmshp();
        prout(" not in standard orbit.");
        return;
@@ -314,7 +312,7 @@ void shuttle(void)
        prout("You will have to beam down to retrieve the shuttle craft.");
        return;
     }
-    if (game.shldup!=0 || game.condit == IHDOCKED) {
+    if (game.shldup || game.condit == IHDOCKED) {
        prout("Shuttle craft cannot pass through shields.");
        return;
     }
@@ -443,7 +441,7 @@ void deathray(void)
        prouts("Sulu- \"Captain!  It's working!\"");
        skip(2);
        while (game.nenhere > 0)
-           deadkl(game.kx[1],game.ky[1],game.quad[game.kx[1]][game.ky[1]],game.kx[1],game.ky[1]);
+           deadkl(game.ks[1], game.quad[game.ks[1].x][game.ks[1].y],game.ks[1].x,game.ks[1].y);
        prout("Ensign Chekov-  \"Congratulations, Captain!\"");
        if (KLINGREM == 0) finish(FWON);
        if ((game.options & OPTION_PLAIN) == 0) {
@@ -511,7 +509,7 @@ void deathray(void)
     return;
 }
 
-char *systemname(planet *planet)
+char *systemname(int pindx)
 {
     static char        *names[NINHAB] =
     {
@@ -584,5 +582,5 @@ char *systemname(planet *planet)
        "Exo III",              /* TOS: "What Are Little Girls Made Of?" (Class P) */
     };
 
-    return names[planet->inhabited];
+    return names[pindx];
 }