|
|
1.1 ! root 1: #ifndef lint ! 2: static char sccsid[] = "@(#)initquad.c 4.3 (Berkeley) 5/27/83"; ! 3: #endif not lint ! 4: ! 5: # include "trek.h" ! 6: ! 7: /* ! 8: ** Paramize Quadrant Upon Entering ! 9: ** ! 10: ** A quadrant is initialized from the information held in the ! 11: ** Quad matrix. Basically, everything is just initialized ! 12: ** randomly, except for the starship, which goes into a fixed ! 13: ** sector. ! 14: ** ! 15: ** If there are Klingons in the quadrant, the captain is informed ! 16: ** that the condition is RED, and he is given a chance to put ! 17: ** his shields up if the computer is working. ! 18: ** ! 19: ** The flag `f' is set to disable the check for condition red. ! 20: ** This mode is used in situations where you know you are going ! 21: ** to be docked, i.e., abandon() and help(). ! 22: */ ! 23: ! 24: initquad(f) ! 25: int f; ! 26: { ! 27: register int i, j; ! 28: int rx, ry; ! 29: int nbases, nstars; ! 30: register struct quad *q; ! 31: int nholes; ! 32: ! 33: q = &Quad[Ship.quadx][Ship.quady]; ! 34: ! 35: /* ignored supernova'ed quadrants (this is checked again later anyway */ ! 36: if (q->stars < 0) ! 37: return; ! 38: Etc.nkling = q->klings; ! 39: nbases = q->bases; ! 40: nstars = q->stars; ! 41: nholes = q->holes; ! 42: ! 43: /* have we blundered into a battle zone w/ shields down? */ ! 44: if (Etc.nkling > 0 && !f) ! 45: { ! 46: printf("Condition RED\n"); ! 47: Ship.cond = RED; ! 48: if (!damaged(COMPUTER)) ! 49: shield(1); ! 50: } ! 51: ! 52: /* clear out the quadrant */ ! 53: for (i = 0; i < NSECTS; i++) ! 54: for (j = 0; j < NSECTS; j++) ! 55: Sect[i][j] = EMPTY; ! 56: ! 57: /* initialize Enterprise */ ! 58: Sect[Ship.sectx][Ship.secty] = Ship.ship; ! 59: ! 60: /* initialize Klingons */ ! 61: for (i = 0; i < Etc.nkling; i++) ! 62: { ! 63: sector(&rx, &ry); ! 64: Sect[rx][ry] = KLINGON; ! 65: Etc.klingon[i].x = rx; ! 66: Etc.klingon[i].y = ry; ! 67: Etc.klingon[i].power = Param.klingpwr; ! 68: Etc.klingon[i].srndreq = 0; ! 69: } ! 70: compkldist(1); ! 71: ! 72: /* initialize star base */ ! 73: if (nbases > 0) ! 74: { ! 75: sector(&rx, &ry); ! 76: Sect[rx][ry] = BASE; ! 77: Etc.starbase.x = rx; ! 78: Etc.starbase.y = ry; ! 79: } ! 80: ! 81: /* initialize inhabited starsystem */ ! 82: if (q->qsystemname != 0) ! 83: { ! 84: sector(&rx, &ry); ! 85: Sect[rx][ry] = INHABIT; ! 86: nstars -= 1; ! 87: } ! 88: ! 89: /* initialize black holes */ ! 90: for (i = 0; i < nholes; i++) ! 91: { ! 92: sector(&rx, &ry); ! 93: Sect[rx][ry] = HOLE; ! 94: } ! 95: ! 96: /* initialize stars */ ! 97: for (i = 0; i < nstars; i++) ! 98: { ! 99: sector(&rx, &ry); ! 100: Sect[rx][ry] = STAR; ! 101: } ! 102: Move.newquad = 1; ! 103: } ! 104: ! 105: ! 106: sector(x, y) ! 107: int *x, *y; ! 108: { ! 109: register int i, j; ! 110: ! 111: do ! 112: { ! 113: i = ranf(NSECTS); ! 114: j = ranf(NSECTS); ! 115: } while (Sect[i][j] != EMPTY); ! 116: *x = i; ! 117: *y = j; ! 118: return; ! 119: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.