X-Git-Url: https://jxself.org/git/?p=super-star-trek.git;a=blobdiff_plain;f=setup.c;h=747618c4bde4f7fae9a656798c1b9e28e3901837;hp=9b5ac4241b9abda67b875a4ef39c89fb6af1446c;hb=942f187b68be75931f4bd35015d74d284ef802c4;hpb=48763357ef69f0b711fc332b13e2170ab914d881 diff --git a/setup.c b/setup.c index 9b5ac42..747618c 100644 --- a/setup.c +++ b/setup.c @@ -36,6 +36,7 @@ void freeze(int boss) { skip(1); return; } + strcpy(game.magic, SSTMAGIC); fwrite(&game, sizeof(game), 1, fp); fclose(fp); @@ -69,6 +70,11 @@ void thaw(void) { return; } fread(&game, sizeof(game), 1, fp); + if (strcmp(game.magic, SSTMAGIC)) { + prout("Game file format is bad, should begin with " SSTMAGIC); + skip(1); + return; + } fclose(fp); @@ -161,7 +167,7 @@ void abandn(void) { iscraft=0; /* Gallileo disappears */ /* Resupply ship */ condit=IHDOCKED; - for (l = 1; l <= ndevice; l++) game.damage[l] = 0.0; + for (l = 1; l <= NDEVICES; l++) game.damage[l] = 0.0; game.damage[DSHUTTL] = -1; energy = inenrg = 3000.0; shield = inshld = 1250.0; @@ -195,7 +201,7 @@ void setup(void) { nprobes = (int)(3.0*Rand() + 2.0); /* Give them 2-4 of these wonders */ warpfac = 5.0; wfacsq = warpfac * warpfac; - for (i=0; i <= ndevice; i++) game.damage[i] = 0.0; + for (i=0; i <= NDEVICES; i++) game.damage[i] = 0.0; // Set up assorted game parameters batx = baty = 0; game.state.date = indate = 100.0*(int)(31.0*Rand()+20.0); @@ -239,13 +245,13 @@ void setup(void) { if (distq < 6.0*(6-inbase) && Rand() < 0.75) { contflag = TRUE; #ifdef DEBUG - printf("DEBUG: Abandoning base #%d at %d-%d\n", i, ix, iy); + proutn("DEBUG: Abandoning base #%d at %d-%d\n", i, ix, iy); #endif break; } #ifdef DEBUG else if (distq < 6.0 * (6-inbase)) { - printf("DEBUG: saving base #%d, close to #%d\n", i, j); + proutn("DEBUG: saving base #%d, close to #%d\n", i, j); } #endif } @@ -298,15 +304,15 @@ void setup(void) { game.state.cy[i] = iy; } // Locate planets in galaxy - for (i = 1; i <= inplan; i++) { + for (i = 0; i < inplan; i++) { do iran8(&ix, &iy); while (game.state.newstuf[ix][iy] > 0); game.state.newstuf[ix][iy] = 1; game.state.plnets[i].x = ix; game.state.plnets[i].y = iy; - game.state.plnets[i].pclass = Rand()*3.0 + 1.0; // Planet class M N or O + game.state.plnets[i].pclass = Rand()*3.0; // Planet class M N or O game.state.plnets[i].crystals = 1.5*Rand(); // 1 in 3 chance of crystals - game.state.plnets[i].known = 0; + game.state.plnets[i].known = unknown; } // Locate Romulans for (i = 1; i <= game.state.nromrem; i++) { @@ -334,24 +340,26 @@ void setup(void) { game.state.snap = 0; if (skill == 1) { - printf("It is stardate %d. The Federation is being attacked by\n", + prout("It is stardate %d. The Federation is being attacked by", (int)game.state.date); - printf("a deadly Klingon invasion force. As captain of the United\n" - "Starship U.S.S. Enterprise, it is your mission to seek out\n" - "and destroy this invasion force of %d battle cruisers.\n", + prout("a deadly Klingon invasion force. As captain of the United"); + prout("Starship U.S.S. Enterprise, it is your mission to seek out"); + prout("and destroy this invasion force of %d battle cruisers.", inkling); - printf("You have an initial allotment of %d stardates to complete\n" - "your mission. As you proceed you may be given more time.\n\n" - "You will have %d supporting starbases.\n" - "Starbase locations- ", - (int)intime, inbase); + prout("You have an initial allotment of %d stardates to complete", (int)intime); + prout("your mission. As you proceed you may be given more time."); + prout(""); + prout("You will have %d supporting starbases.", inbase); + proutn("Starbase locations- "); } else { - printf("Stardate %d.\n\n" - "%d Klingons.\nAn unknown number of Romulans\n", - (int)game.state.date, inkling); - if (game.state.nscrem) printf("and one (GULP) Super-Commander.\n"); - printf("%d stardates\n%d starbases in ",(int)intime, inbase); + prout("Stardate %d.", (int)game.state.date); + prout(""); + prout("%d Klingons.", inkling); + prout("An unknown number of Romulans."); + if (game.state.nscrem) prout("and one (GULP) Super-Commander."); + prout("%d stardates.",(int)intime); + proutn("%d starbases in ", inbase); } for (i = 1; i <= inbase; i++) { cramlc(0, game.state.baseqx[i], game.state.baseqy[i]); @@ -593,9 +601,9 @@ void newqad(int shutup) { if (nplan) { // If quadrant needs a planet, put it in - for (i=1; i <= inplan; i++) + for (i=0; i < inplan; i++) if (game.state.plnets[i].x == quadx && game.state.plnets[i].y == quady) break; - if (i <= inplan) { + if (i < inplan) { iplnet = i; dropin(IHP, &plnetx, &plnety); }