X-Git-Url: https://jxself.org/git/?p=super-star-trek.git;a=blobdiff_plain;f=setup.c;h=51089b6aed927723ee5ec657f40ea989889fb086;hp=3a5a794b105b228ccc2f06ea0d3f5bec2ff2d517;hb=89e52d61fcf689e15a8f831dea084a33ceaa8217;hpb=ba71f219a8543b5510a53c59ce793339b84903a7 diff --git a/setup.c b/setup.c index 3a5a794..51089b6 100644 --- a/setup.c +++ b/setup.c @@ -1,11 +1,7 @@ #include -#ifdef SERGEEV #include -#include -#endif /* SERGEEV */ #include "sst.h" -#ifdef SERGEEV #ifdef __linux__ static long filelength(int fd) { struct stat buf; @@ -13,16 +9,15 @@ 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) { @@ -84,7 +79,7 @@ int thaw(void) { 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); @@ -389,9 +384,7 @@ void setup(int needprompt) { 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 @@ -402,13 +395,13 @@ void randomize(void) { } 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")) { @@ -424,22 +417,16 @@ int choose(int needprompt) { 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("\"?"); @@ -467,18 +454,7 @@ int choose(int needprompt) { 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 @@ -599,7 +575,6 @@ void newqad(int shutup) { 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;