#include "sst.h"\r
\r
-static char classes[4][2]={"","M","N","O"};\r
static int height;\r
\r
+static char *classes[] = {"M","N","O"};\r
+\r
static int consumeTime(void) {\r
/* I think most of this avoidance was caused by overlay scheme.\r
Let's see what happens if all events can occur here */\r
ididit = 1;\r
#if 0\r
/* Don't wory about this */\r
- if (future[FTBEAM] <= state.date+Time && state.remcom != 0 && condit != IHDOCKED) {\r
+ if (future[FTBEAM] <= game.state.date+Time && game.state.remcom != 0 && condit != IHDOCKED) {\r
/* We are about to be tractor beamed -- operation fails */\r
return 1;\r
}\r
events(); /* Used to avoid if future[FSCMOVE] within time */\r
// future[FSNOVA] = asave;\r
/*fails if game over, quadrant super-novas or we've moved to new quadrant*/\r
- if (alldone || state.galaxy[quadx][quady] == 1000 || justin != 0) return 1;\r
+ if (alldone || game.state.galaxy[quadx][quady] == 1000 || justin != 0) return 1;\r
return 0;\r
}\r
\r
chew();\r
prout("Spock- \"Planet report follows, Captain.\"");\r
skip(1);\r
- for (i = 1; i <= inplan; i++) {\r
- if (state.plnets[i].known\r
+ for (i = 0; i < inplan; i++) {\r
+ if (game.state.plnets[i].known != unknown\r
#ifdef DEBUG\r
- || ( idebug && state.plnets[i].x !=0)\r
+ || ( idebug && game.state.plnets[i].x !=0)\r
#endif\r
) {\r
iknow = 1;\r
#ifdef DEBUG\r
- if (idebug && state.plnets[i].known==0) proutn("(Unknown) ");\r
+ if (idebug && game.state.plnets[i].known==unknown) proutn("(Unknown) ");\r
#endif\r
- cramlc(1, state.plnets[i].x, state.plnets[i].y);\r
+ proutn(cramlc(quadrant, game.state.plnets[i].x, game.state.plnets[i].y));\r
proutn(" class ");\r
- proutn(classes[state.plnets[i].pclass]);\r
+ proutn(classes[game.state.plnets[i].pclass]);\r
proutn(" ");\r
- if (state.plnets[i].crystals == 0) proutn("no ");\r
+ if (game.state.plnets[i].crystals == 0) proutn("no ");\r
prout("dilithium crystals present.");\r
- if (state.plnets[i].known==2) \r
+ if (game.state.plnets[i].known==shuttle_down) \r
prout(" Shuttle Craft Galileo on surface.");\r
}\r
}\r
}\r
\r
void orbit(void) {\r
- double asave;\r
-\r
skip(1);\r
chew();\r
ididit=0;\r
prout("Already in standard orbit.");\r
return;\r
}\r
- if (frozen.damage[DWARPEN] != 0 && frozen.damage[DIMPULS] != 0) {\r
+ if (game.damage[DWARPEN] != 0 && game.damage[DIMPULS] != 0) {\r
prout("Both warp and impulse engines damaged.");\r
return;\r
}\r
prout("Helmsman Sulu- \"Entering standard orbit, Sir.\"");\r
newcnd();\r
if (consumeTime()) return;\r
- proutn("Sulu- \"Entered orbit at altitude ");\r
- cramf(height = (1400.+7200.*Rand()), 0, 2);\r
- prout(" kilometers.\"");\r
+ height = (1400.+7200.*Rand());\r
+ prout("Sulu- \"Entered orbit at altitude %.2f kilometers.\"", height);\r
inorbit = 1;\r
return;\r
}\r
void sensor(void) {\r
skip(1);\r
chew();\r
- if (frozen.damage[DSRSENS] != 0.0) {\r
+ if (game.damage[DSRSENS] != 0.0) {\r
prout("Short range sensors damaged.");\r
return;\r
}\r
prout("No planet in this quadrant.");\r
return;\r
}\r
- proutn("Spock- \"Sensor scan for");\r
- cramlc(1, quadx, quady);\r
- prout("-");\r
+ prout("Spock- \"Sensor scan for %s-", cramlc(quadrant, quadx, quady));\r
skip(1);\r
- proutn(" Planet at");\r
- cramlc(2, plnetx, plnety);\r
- proutn(" is of class ");\r
- proutn(classes[state.plnets[iplnet].pclass]);\r
- prout(".");\r
- if (state.plnets[iplnet].known==2) \r
+ prout(" Planet at %s is of class %s.", \r
+ cramlc(sector, plnetx, plnety),\r
+ classes[game.state.plnets[iplnet].pclass]);\r
+ if (game.state.plnets[iplnet].known==shuttle_down) \r
prout(" Sensors show Galileo still on surface.");\r
proutn(" Readings indicate");\r
- if (state.plnets[iplnet].crystals == 0) proutn(" no");\r
+ if (game.state.plnets[iplnet].crystals == 0) proutn(" no");\r
prout(" dilithium crystals present.\"");\r
- if (state.plnets[iplnet].known == 0) state.plnets[iplnet].known = 1;\r
+ if (game.state.plnets[iplnet].known == unknown) game.state.plnets[iplnet].known = known;\r
return;\r
}\r
\r
void beam(void) {\r
chew();\r
skip(1);\r
- if (frozen.damage[DTRANSP] != 0) {\r
+ if (game.damage[DTRANSP] != 0) {\r
prout("Transporter damaged.");\r
- if (frozen.damage[DSHUTTL]==0 && (state.plnets[iplnet].known==2 || iscraft == 1)) {\r
+ if (game.damage[DSHUTTL]==0 && (game.state.plnets[iplnet].known==shuttle_down || iscraft == 1)) {\r
skip(1);\r
prout("Spock- \"May I suggest the shuttle craft, Sir?\" ");\r
if (ja() != 0) shuttle();\r
prout("Impossible to transport through shields.");\r
return;\r
}\r
- if (state.plnets[iplnet].known==0) {\r
+ if (game.state.plnets[iplnet].known==unknown) {\r
prout("Spock- \"Captain, we have no information on this planet");\r
prout(" and Starfleet Regulations clearly state that in this situation");\r
prout(" you may not go down.\"");\r
}\r
if (landed==1) {\r
/* Coming from planet */\r
- if (state.plnets[iplnet].known==2) {\r
+ if (game.state.plnets[iplnet].known==shuttle_down) {\r
proutn("Spock- \"Wouldn't you rather take the Galileo?\" ");\r
if (ja() != 0) {\r
chew();\r
}\r
else {\r
/* Going to planet */\r
- if (state.plnets[iplnet].crystals==0) {\r
+ if (game.state.plnets[iplnet].crystals==0) {\r
prout("Spock- \"Captain, I fail to see the logic in");\r
prout(" exploring a planet with no dilithium crystals.");\r
proutn(" Are you sure this is wise?\" ");\r
skip(2);\r
prout("Transport complete.");\r
landed = -landed;\r
- if (landed==1 && state.plnets[iplnet].known==2) {\r
+ if (landed==1 && game.state.plnets[iplnet].known==shuttle_down) {\r
prout("The shuttle craft Galileo is here!");\r
}\r
if (landed!=1 && imine==1) {\r
prout("Mining party not on planet.");\r
return;\r
}\r
- if (state.plnets[iplnet].crystals == 0) {\r
+ if (game.state.plnets[iplnet].crystals == 0) {\r
prout("No dilithium crystals on this planet.");\r
return;\r
}\r
prout("there's no reason to mine more at this time.");\r
return;\r
}\r
- Time = (0.1+0.2*Rand())*state.plnets[iplnet].pclass;\r
+ Time = (0.1+0.2*Rand())*game.state.plnets[iplnet].pclass;\r
if (consumeTime()) return;\r
prout("Mining operation complete.");\r
imine = 1;\r
chew();\r
skip(1);\r
ididit = 0;\r
- if(frozen.damage[DSHUTTL] != 0.0) {\r
- if (frozen.damage[DSHUTTL] == -1.0) {\r
- if (inorbit && state.plnets[iplnet].known == 2)\r
+ if(game.damage[DSHUTTL] != 0.0) {\r
+ if (game.damage[DSHUTTL] == -1.0) {\r
+ if (inorbit && game.state.plnets[iplnet].known == shuttle_down)\r
prout("Ye Faerie Queene has no shuttle craft bay to dock it at.");\r
else\r
prout("Ye Faerie Queene had no shuttle craft.");\r
}\r
- else if (frozen.damage[DSHUTTL] > 0)\r
+ else if (game.damage[DSHUTTL] > 0)\r
prout("The Galileo is damaged.");\r
else prout("Shuttle craft is now serving Big Macs.");\r
return;\r
prout(" not in standard orbit.");\r
return;\r
}\r
- if ((state.plnets[iplnet].known != 2) && iscraft != 1) {\r
+ if ((game.state.plnets[iplnet].known != shuttle_down) && iscraft != 1) {\r
prout("Shuttle craft not currently available.");\r
return;\r
}\r
- if (landed==-1 && state.plnets[iplnet].known==2) {\r
+ if (landed==-1 && game.state.plnets[iplnet].known==shuttle_down) {\r
prout("You will have to beam down to retrieve the shuttle craft.");\r
return;\r
}\r
prout("Shuttle craft cannot pass through shields.");\r
return;\r
}\r
- if (state.plnets[iplnet].known==0) {\r
+ if (game.state.plnets[iplnet].known==unknown) {\r
prout("Spock- \"Captain, we have no information on this planet");\r
prout(" and Starfleet Regulations clearly state that in this situation");\r
prout(" you may not fly down.\"");\r
return;\r
}\r
Time = 3.0e-5*height;\r
- if (Time >= 0.8*state.remtime) {\r
+ if (Time >= 0.8*game.state.remtime) {\r
prout("First Officer Spock- \"Captain, I compute that such");\r
- prout(" a maneuver would require approximately ");\r
- cramf(100*Time/state.remtime,0,4);\r
- prout("% of our");\r
+ proutn(" a maneuver would require approximately 2d%% of our",\r
+ (int)(100*Time/game.state.remtime));\r
prout("remaining time.");\r
prout("Are you sure this is wise?\" ");\r
if (ja()==0) {\r
/* Kirk on planet */\r
if (iscraft==1) {\r
/* Galileo on ship! */\r
- if (frozen.damage[DTRANSP]==0) {\r
+ if (game.damage[DTRANSP]==0) {\r
proutn("Spock- \"Would you rather use the transporter?\" ");\r
if (ja() != 0) {\r
beam();\r
iscraft = 0;\r
skip(1);\r
if (consumeTime()) return;\r
- state.plnets[iplnet].known=2;\r
+ game.state.plnets[iplnet].known=shuttle_down;\r
prout("Trip complete.");\r
return;\r
}\r
prout("shuttle craft for the trip back to the Enterprise.");\r
skip(1);\r
prout("The short hop begins . . .");\r
- state.plnets[iplnet].known=1;\r
+ game.state.plnets[iplnet].known=known;\r
icraft = 1;\r
skip(1);\r
landed = -1;\r
icraft = 1;\r
iscraft = 0;\r
if (consumeTime()) return;\r
- state.plnets[iplnet].known = 2;\r
+ game.state.plnets[iplnet].known = shuttle_down;\r
landed = 1;\r
icraft = 0;\r
prout("Trip complete");\r
prout("Sulu- \"But Sir, there are no enemies in this quadrant.\"");\r
return;\r
}\r
- if (frozen.damage[DDRAY] > 0.0) {\r
+ if (game.damage[DDRAY] > 0.0) {\r
prout("Death Ray is damaged.");\r
return;\r
}\r
prout("Spock- \"Captain, the 'Experimental Death Ray'");\r
prout(" is highly unpredictible. Considering the alternatives,");\r
- prout(" are you sure this is wise?\" ");\r
+ proutn(" are you sure this is wise?\" ");\r
if (ja()==0) return;\r
prout("Spock- \"Acknowledged.\"");\r
skip(1);\r
prouts("Sulu- \"Captain! It's working!\"");\r
skip(2);\r
while (nenhere > 0)\r
- deadkl(frozen.kx[1],frozen.ky[1],frozen.quad[frozen.kx[1]][frozen.ky[1]],frozen.kx[1],frozen.ky[1]);\r
+ deadkl(game.kx[1],game.ky[1],game.quad[game.kx[1]][game.ky[1]],game.kx[1],game.ky[1]);\r
prout("Ensign Chekov- \"Congratulations, Captain!\"");\r
- if (state.remkl == 0) finish(FWON);\r
+ if (game.state.remkl == 0) finish(FWON);\r
prout("Spock- \"Captain, I believe the `Experimental Death Ray'");\r
if (Rand() <= 0.05) {\r
prout(" is still operational.\"");\r
}\r
else {\r
- prout(" has been rendered disfunctional.\"");\r
- frozen.damage[DDRAY] = 39.95;\r
+ prout(" has been rendered nonfunctional.\"");\r
+ game.damage[DDRAY] = 39.95;\r
}\r
return;\r
}\r
prout(" Mr. Sulu.");\r
for (i=1; i<=10; i++)\r
for (j=1; j<=10; j++)\r
- if (frozen.quad[i][j] == IHDOT) frozen.quad[i][j] = IHQUEST;\r
+ if (game.quad[i][j] == IHDOT) game.quad[i][j] = IHQUEST;\r
prout(" Captain, our quadrant is now infested with");\r
prouts(" - - - - - - *THINGS*.");\r
skip(1);\r