|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1983 Regents of the University of California. ! 3: * All rights reserved. The Berkeley software License Agreement ! 4: * specifies the terms and conditions for redistribution. ! 5: */ ! 6: ! 7: #ifndef lint ! 8: static char sccsid[] = "@(#)pl_6.c 5.1 (Berkeley) 5/29/85"; ! 9: #endif not lint ! 10: ! 11: #include "player.h" ! 12: ! 13: repair() ! 14: { ! 15: char c; ! 16: register char *repairs; ! 17: register struct shipspecs *ptr = mc; ! 18: register int count; ! 19: ! 20: #define FIX(x, m) (m - ptr->x > count \ ! 21: ? (ptr->x += count, count = 0) : (count -= m - ptr->x, ptr->x = m)) ! 22: ! 23: if (repaired || loaded || fired || changed || turned()) { ! 24: Signal("No hands free to repair", (struct ship *)0); ! 25: return; ! 26: } ! 27: c = sgetch("Repair (hull, guns, rigging)? ", (struct ship *)0, 1); ! 28: switch (c) { ! 29: case 'h': ! 30: repairs = &mf->RH; ! 31: break; ! 32: case 'g': ! 33: repairs = &mf->RG; ! 34: break; ! 35: case 'r': ! 36: repairs = &mf->RR; ! 37: break; ! 38: default: ! 39: Signal("Avast heaving!", (struct ship *)0); ! 40: return; ! 41: } ! 42: if (++*repairs >= 3) { ! 43: count = 2; ! 44: switch (c) { ! 45: case 'h': { ! 46: int max = ptr->guns/4; ! 47: if (ptr->hull < max) { ! 48: FIX(hull, max); ! 49: Write(W_HULL, ms, 0, ptr->hull, 0, 0, 0); ! 50: } ! 51: break; ! 52: } ! 53: case 'g': ! 54: if (ptr->gunL < ptr->gunR) { ! 55: int max = ptr->guns/5 - ptr->carL; ! 56: if (ptr->gunL < max) { ! 57: FIX(gunL, max); ! 58: Write(W_GUNL, ms, 0, ptr->gunL, ! 59: ptr->carL, 0, 0); ! 60: } ! 61: } else { ! 62: int max = ptr->guns/5 - ptr->carR; ! 63: if (ptr->gunR < max) { ! 64: FIX(gunR, max); ! 65: Write(W_GUNR, ms, 0, ptr->gunR, ! 66: ptr->carR, 0, 0); ! 67: } ! 68: } ! 69: break; ! 70: case 'r': ! 71: #define X 2 ! 72: if (ptr->rig4 >= 0 && ptr->rig4 < X) { ! 73: FIX(rig4, X); ! 74: Write(W_RIG4, ms, 0, ptr->rig4, 0, 0, 0); ! 75: } ! 76: if (count && ptr->rig3 < X) { ! 77: FIX(rig3, X); ! 78: Write(W_RIG3, ms, 0, ptr->rig3, 0, 0, 0); ! 79: } ! 80: if (count && ptr->rig2 < X) { ! 81: FIX(rig2, X); ! 82: Write(W_RIG2, ms, 0, ptr->rig2, 0, 0, 0); ! 83: } ! 84: if (count && ptr->rig1 < X) { ! 85: FIX(rig1, X); ! 86: Write(W_RIG1, ms, 0, ptr->rig1, 0, 0, 0); ! 87: } ! 88: break; ! 89: } ! 90: if (count == 2) { ! 91: Signal("Repairs completed.", (struct ship *)0); ! 92: *repairs = 2; ! 93: } else { ! 94: *repairs = 0; ! 95: blockalarm(); ! 96: draw_stat(); ! 97: unblockalarm(); ! 98: } ! 99: } ! 100: blockalarm(); ! 101: draw_slot(); ! 102: unblockalarm(); ! 103: repaired = 1; ! 104: } ! 105: ! 106: turned() ! 107: { ! 108: register char *p; ! 109: ! 110: for (p = movebuf; *p; p++) ! 111: if (*p == 'r' || *p == 'l') ! 112: return 1; ! 113: return 0; ! 114: } ! 115: ! 116: loadplayer() ! 117: { ! 118: char c; ! 119: register loadL, loadR, ready, load; ! 120: ! 121: if (!mc->crew3) { ! 122: Signal("Out of crew", (struct ship *)0); ! 123: return; ! 124: } ! 125: loadL = mf->loadL; ! 126: loadR = mf->loadR; ! 127: if (!loadL && !loadR) { ! 128: c = sgetch("Load which broadside (left or right)? ", ! 129: (struct ship *)0, 1); ! 130: if (c == 'r') ! 131: loadL = 1; ! 132: else ! 133: loadR = 1; ! 134: } ! 135: if (!loadL && loadR || loadL && !loadR) { ! 136: c = sgetch("Reload with (round, double, chain, grape)? ", ! 137: (struct ship *)0, 1); ! 138: switch (c) { ! 139: case 'r': ! 140: load = L_ROUND; ! 141: ready = 0; ! 142: break; ! 143: case 'd': ! 144: load = L_DOUBLE; ! 145: ready = R_DOUBLE; ! 146: break; ! 147: case 'c': ! 148: load = L_CHAIN; ! 149: ready = 0; ! 150: break; ! 151: case 'g': ! 152: load = L_GRAPE; ! 153: ready = 0; ! 154: break; ! 155: default: ! 156: Signal("Broadside not loaded.", ! 157: (struct ship *)0); ! 158: return; ! 159: } ! 160: if (!loadR) { ! 161: mf->loadR = load; ! 162: mf->readyR = ready|R_LOADING; ! 163: } else { ! 164: mf->loadL = load; ! 165: mf->readyL = ready|R_LOADING; ! 166: } ! 167: loaded = 1; ! 168: } ! 169: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.