#include <time.h>
-#ifdef SERGEEV
#include <sys/stat.h>
-#include <conio.h>
-#endif /* SERGEEV */
+#include "conio.h"
#include "sst.h"
-#ifdef SERGEEV
#ifdef __linux__
static long filelength(int fd) {
struct stat buf;
return buf.st_size;
}
#endif
-#endif /* SERGEEV */
void prelim(void) {
skip(2);
prout("-SUPER- STAR TREK");
skip(1);
-#ifndef SERGEEV
+#ifndef __HISTORICAL__
prout("Latest update-21 Sept 78");
skip(1);
-#endif /* SERGEEV */
+#endif /* __HISTORICAL__ */
}
void freeze(int boss) {
return 1;
}
fread(&game, sizeof(game), 1, fp);
- if (strcmp(game.magic, SSTMAGIC)) {
+ if (feof(fp) || ftell(fp) != filelength(fileno(fp)) || strcmp(game.magic, SSTMAGIC)) {
prout("Game file format is bad, should begin with " SSTMAGIC);
skip(1);
fclose(fp);
skip(2);
prout("Good Luck!");
if (game.state.nscrem) prout(" YOU'LL NEED IT.");
-#ifdef SERGEEV
- getche();
-#endif /* SERGEEV */
+ waitfor();
newqad(0);
if (nenhere-iqhere-ithere) shldup=1.0;
if (neutz) attack(0); // bad luck to start in a Romulan Neutral Zone
}
int choose(int needprompt) {
+ while (TRUE) {
tourn = 0;
thawed = 0;
skill = 0;
length = 0;
- while (TRUE) {
if (needprompt) /* Can start with command line options */
- proutn("Would you like a regular, tournament, or frozen game?");
+ proutn("Would you like a regular, tournament, or saved game? ");
scan();
if (strlen(citem)==0) continue; // Try again
if (isit("tournament")) {
srand((unsigned int)(int)aaitem);
break;
}
- if (isit("frozen")) {
- thaw();
+ if (isit("saved") || isit("frozen")) {
+ if (thaw()) continue;
chew();
if (*game.passwd==0) continue;
- randomize();
- Rand(); Rand(); Rand(); Rand();
if (!alldone) thawed = 1; // No plaque if not finished
- report(1);
+ report();
+ waitfor();
return TRUE;
}
- if (isit("regular")) {
- skip(2);
- randomize();
- Rand(); Rand(); Rand(); Rand();
- break;
- }
+ if (isit("regular")) break;
proutn("What is \"");
proutn(citem);
prout("\"?");
else if (skill == 0) proutn("Are you a Novice, Fair, Good, Expert, or Emeritus player? ");
}
}
-#ifndef SERGEEV
- while (TRUE) {
- scan();
- strcpy(game.passwd, citem);
- chew();
- if (*game.passwd != 0) break;
- proutn("Please type in a secret password-");
- }
-#else
- for(i=0;i<3;i++) game.passwd[i]=(char)(97+(int)(Rand()*25));
- game.passwd[3]=0;
-#endif /* SERGEEV */
+ setpassword();
#ifdef DEBUG
if (strcmp(game.passwd, "debug")==0) idebug = 1;
#endif
game.kdist[i] = game.kavgd[i] = sqrt(square(sectx-ix) + square(secty-iy));
game.kpower[i] = Rand()*400.0 + 450.0 + 50.0*skill;
}
- sortkl();
// If quadrant needs a starbase, put it in
if (quadnum >= 10) {
quadnum -= 10;