Annotation of 43BSDReno/games/sail/pl_6.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1983 Regents of the University of California.
                      3:  * All rights reserved.
                      4:  *
                      5:  * Redistribution and use in source and binary forms are permitted
                      6:  * provided that: (1) source distributions retain this entire copyright
                      7:  * notice and comment, and (2) distributions including binaries display
                      8:  * the following acknowledgement:  ``This product includes software
                      9:  * developed by the University of California, Berkeley and its contributors''
                     10:  * in the documentation or other materials provided with the distribution
                     11:  * and in all advertising materials mentioning features or use of this
                     12:  * software. Neither the name of the University nor the names of its
                     13:  * contributors may be used to endorse or promote products derived
                     14:  * from this software without specific prior written permission.
                     15:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
                     16:  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
                     17:  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                     18:  */
                     19: 
                     20: #ifndef lint
                     21: static char sccsid[] = "@(#)pl_6.c     5.4 (Berkeley) 6/1/90";
                     22: #endif /* not lint */
                     23: 
                     24: #include "player.h"
                     25: 
                     26: repair()
                     27: {
                     28:        char c;
                     29:        register char *repairs;
                     30:        register struct shipspecs *ptr = mc;
                     31:        register int count;
                     32: 
                     33: #define FIX(x, m) (m - ptr->x > count \
                     34:        ? (ptr->x += count, count = 0) : (count -= m - ptr->x, ptr->x = m))
                     35: 
                     36:        if (repaired || loaded || fired || changed || turned()) {
                     37:                Signal("No hands free to repair", (struct ship *)0);
                     38:                return;
                     39:        }
                     40:        c = sgetch("Repair (hull, guns, rigging)? ", (struct ship *)0, 1);
                     41:        switch (c) {
                     42:                case 'h':
                     43:                        repairs = &mf->RH;
                     44:                        break;
                     45:                case 'g':
                     46:                        repairs = &mf->RG;
                     47:                        break;
                     48:                case 'r':
                     49:                        repairs = &mf->RR;
                     50:                        break;
                     51:                default:
                     52:                        Signal("Avast heaving!", (struct ship *)0);
                     53:                        return;
                     54:        }
                     55:        if (++*repairs >= 3) {
                     56:                count = 2;
                     57:                switch (c) {
                     58:                case 'h': {
                     59:                        int max = ptr->guns/4;
                     60:                        if (ptr->hull < max) {
                     61:                                FIX(hull, max);
                     62:                                Write(W_HULL, ms, 0, ptr->hull, 0, 0, 0);
                     63:                        }
                     64:                        break;
                     65:                        }
                     66:                case 'g':
                     67:                        if (ptr->gunL < ptr->gunR) {
                     68:                                int max = ptr->guns/5 - ptr->carL;
                     69:                                if (ptr->gunL < max) {
                     70:                                        FIX(gunL, max);
                     71:                                        Write(W_GUNL, ms, 0, ptr->gunL,
                     72:                                                ptr->carL, 0, 0);
                     73:                                }
                     74:                        } else {
                     75:                                int max = ptr->guns/5 - ptr->carR;
                     76:                                if (ptr->gunR < max) {
                     77:                                        FIX(gunR, max);
                     78:                                        Write(W_GUNR, ms, 0, ptr->gunR,
                     79:                                                ptr->carR, 0, 0);
                     80:                                }
                     81:                        }
                     82:                        break;
                     83:                case 'r':
                     84: #define X 2
                     85:                        if (ptr->rig4 >= 0 && ptr->rig4 < X) {
                     86:                                FIX(rig4, X);
                     87:                                Write(W_RIG4, ms, 0, ptr->rig4, 0, 0, 0);
                     88:                        }
                     89:                        if (count && ptr->rig3 < X) {
                     90:                                FIX(rig3, X);
                     91:                                Write(W_RIG3, ms, 0, ptr->rig3, 0, 0, 0);
                     92:                        }
                     93:                        if (count && ptr->rig2 < X) {
                     94:                                FIX(rig2, X);
                     95:                                Write(W_RIG2, ms, 0, ptr->rig2, 0, 0, 0);
                     96:                        }
                     97:                        if (count && ptr->rig1 < X) {
                     98:                                FIX(rig1, X);
                     99:                                Write(W_RIG1, ms, 0, ptr->rig1, 0, 0, 0);
                    100:                        }
                    101:                        break;
                    102:                }
                    103:                if (count == 2) {
                    104:                        Signal("Repairs completed.", (struct ship *)0);
                    105:                        *repairs = 2;
                    106:                } else {
                    107:                        *repairs = 0;
                    108:                        blockalarm();
                    109:                        draw_stat();
                    110:                        unblockalarm();
                    111:                }
                    112:        }
                    113:        blockalarm();
                    114:        draw_slot();
                    115:        unblockalarm();
                    116:        repaired = 1;
                    117: }
                    118: 
                    119: turned()
                    120: {
                    121:        register char *p;
                    122: 
                    123:        for (p = movebuf; *p; p++)
                    124:                if (*p == 'r' || *p == 'l')
                    125:                        return 1;
                    126:        return 0;
                    127: }
                    128: 
                    129: loadplayer()
                    130: {
                    131:        char c;
                    132:        register loadL, loadR, ready, load;
                    133: 
                    134:        if (!mc->crew3) {
                    135:                Signal("Out of crew", (struct ship *)0);
                    136:                return;
                    137:        }
                    138:        loadL = mf->loadL;
                    139:        loadR = mf->loadR;
                    140:        if (!loadL && !loadR) {
                    141:                c = sgetch("Load which broadside (left or right)? ",
                    142:                        (struct ship *)0, 1);
                    143:                if (c == 'r')
                    144:                        loadL = 1;
                    145:                else
                    146:                        loadR = 1;
                    147:        }
                    148:        if (!loadL && loadR || loadL && !loadR) {
                    149:                c = sgetch("Reload with (round, double, chain, grape)? ",
                    150:                        (struct ship *)0, 1);
                    151:                switch (c) {
                    152:                case 'r':
                    153:                        load = L_ROUND;
                    154:                        ready = 0;
                    155:                        break;
                    156:                case 'd':
                    157:                        load = L_DOUBLE;
                    158:                        ready = R_DOUBLE;
                    159:                        break;
                    160:                case 'c':
                    161:                        load = L_CHAIN;
                    162:                        ready = 0;
                    163:                        break;
                    164:                case 'g':
                    165:                        load = L_GRAPE;
                    166:                        ready = 0;
                    167:                        break;
                    168:                default:
                    169:                        Signal("Broadside not loaded.",
                    170:                                (struct ship *)0);
                    171:                        return;
                    172:                }
                    173:                if (!loadR) {
                    174:                        mf->loadR = load;
                    175:                        mf->readyR = ready|R_LOADING;
                    176:                } else {
                    177:                        mf->loadL = load;
                    178:                        mf->readyL = ready|R_LOADING;
                    179:                }
                    180:                loaded = 1;
                    181:        }
                    182: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.