|
|
1.1 ! root 1: # include "trek.h" ! 2: ! 3: /** ! 4: ** Handle a Klingon's death ! 5: **/ ! 6: ! 7: killk(ix, iy) ! 8: int ix, iy; ! 9: { ! 10: register int i; ! 11: ! 12: printf(" *** Klingon at %d,%d destroyed ***\n", ix, iy); ! 13: Status.kling =- 1; ! 14: Sect[ix][iy] = EMPTY; ! 15: Quad[Quadx][Quady].qkling =- 1; ! 16: Quad[Quadx][Quady].scanned =- 100; ! 17: Game.gkillk =+ 1; ! 18: for (i = 0; i < Nkling; i++) ! 19: if (ix == Kling[i].x && iy == Kling[i].y) ! 20: { ! 21: Nkling =- 1; ! 22: for (; i < Nkling; i++) ! 23: bmove(&Kling[i+1], &Kling[i], sizeof Kling[i]); ! 24: break; ! 25: } ! 26: if (Status.kling <= 0) ! 27: win(); ! 28: Status.time = Status.resource / Status.kling; ! 29: } ! 30: ! 31: ! 32: /** ! 33: ** handle a starbase's death ! 34: **/ ! 35: ! 36: killb(qx, qy) ! 37: int qx, qy; ! 38: { ! 39: register QUAD *q; ! 40: register XY *b; ! 41: ! 42: q = &Quad[qx][qy]; ! 43: ! 44: if (q->bases <= 0) ! 45: return; ! 46: q->bases = 0; ! 47: Status.bases =- 1; ! 48: for (b = Base; ; b++) ! 49: if (qx == b->x && qy == b->y) ! 50: break; ! 51: bmove(&Base[Status.bases], b, sizeof *b); ! 52: if (qx == Quadx && qy == Quady) ! 53: { ! 54: Sect[Starbase.x][Starbase.y] = EMPTY; ! 55: if (Status.cond == DOCKED) ! 56: undock(); ! 57: printf("Starbase at %d,%d destroyed\n", Starbase.x, Starbase.y); ! 58: } else if(!Damage[SSRADIO]) { ! 59: printf("Uhura:\tStarfleet command reports that the starbase in\n"); ! 60: printf("\tquadrant %d,%d has been destroyed\n", qx, qy); ! 61: } ! 62: if(!Damage[SSRADIO]) { ! 63: /* then update starchart */ ! 64: if (q->scanned < 1000) ! 65: q->scanned =- 10; ! 66: else ! 67: if (q->scanned > 1000) ! 68: q->scanned = -1; ! 69: } ! 70: } ! 71: ! 72: ! 73: /** ! 74: ** kill an inhabited starsystem ! 75: **/ ! 76: ! 77: kills(x, y, f) ! 78: int x, y; /* quad coords if f == 0, else sector coords */ ! 79: int f; /* f != 0 -- this quad; f < 0 -- Enterprise's fault */ ! 80: { ! 81: register QUAD *q; ! 82: register EVENT *e; ! 83: register int i; ! 84: ! 85: if (f) ! 86: { ! 87: /* current quadrant */ ! 88: q = &Quad[Quadx][Quady]; ! 89: Sect[x][y] = EMPTY; ! 90: i = getqname(q); ! 91: if(i==0) return; ! 92: printf("Inhabited starsystem %s at %d,%d destroyed\n", ! 93: Systemname[i], x, y); ! 94: if (f < 0) ! 95: Game.killinhab =+ 1; ! 96: } ! 97: else ! 98: { ! 99: /* different quadrant */ ! 100: q = &Quad[x][y]; ! 101: } ! 102: if (q->systemname&Q_DISTRESS) ! 103: { ! 104: /* distressed starsystem */ ! 105: e = &Event[q->systemname&Q_STARNAME]; ! 106: printf("Distress call for %s invalidated\n", ! 107: Systemname[e->evdata]); ! 108: unschedule(e); ! 109: } ! 110: q->systemname = 0; ! 111: q->stars =- 1; ! 112: } ! 113: ! 114: ! 115: /** ! 116: ** "kill" a distress call ! 117: **/ ! 118: ! 119: killd(x, y) ! 120: int x, y; /* quadrant coordinates */ ! 121: { ! 122: register EVENT *e; ! 123: register int i; ! 124: register QUAD *q; ! 125: ! 126: q = &Quad[x][y]; ! 127: for (i = 0; i < MAXEVENTS; i++) ! 128: { ! 129: e = &Event[i]; ! 130: if (e->x != x || e->y != y) ! 131: continue; ! 132: switch (e->evcode) ! 133: { ! 134: case E_KDESB: ! 135: printf("Distress call for starbase in %d,%d nullified\n", ! 136: x, y); ! 137: unschedule(e); ! 138: break; ! 139: ! 140: case E_ENSLV: ! 141: case E_REPRO: ! 142: printf("Distress call for %s in quadrant %d,%d nullified\n", ! 143: Systemname[e->evdata], x, y); ! 144: q->systemname = e->evdata; ! 145: unschedule(e); ! 146: } ! 147: } ! 148: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.