Annotation of 43BSDReno/games/trek/shield.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1980 Regents of the University of California.
                      3:  * All rights reserved.
                      4:  *
                      5:  * Redistribution and use in source and binary forms are permitted provided
                      6:  * that: (1) source distributions retain this entire copyright notice and
                      7:  * comment, and (2) distributions including binaries display the following
                      8:  * acknowledgement:  ``This product includes software developed by the
                      9:  * University of California, Berkeley and its contributors'' in the
                     10:  * documentation or other materials provided with the distribution and in
                     11:  * all advertising materials mentioning features or use of this software.
                     12:  * Neither the name of the University nor the names of its contributors may
                     13:  * be used to endorse or promote products derived from this software without
                     14:  * specific prior written permission.
                     15:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
                     16:  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
                     17:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                     18:  */
                     19: 
                     20: #ifndef lint
                     21: static char sccsid[] = "@(#)shield.c   5.5 (Berkeley) 6/1/90";
                     22: #endif /* not lint */
                     23: 
                     24: # include      "trek.h"
                     25: # include      "getpar.h"
                     26: 
                     27: /*
                     28: **  SHIELD AND CLOAKING DEVICE CONTROL
                     29: **
                     30: **     'f' is one for auto shield up (in case of Condition RED),
                     31: **     zero for shield control, and negative one for cloaking
                     32: **     device control.
                     33: **
                     34: **     Called with an 'up' or 'down' on the same line, it puts
                     35: **     the shields/cloak into the specified mode.  Otherwise it
                     36: **     reports to the user the current mode, and asks if she wishes
                     37: **     to change.
                     38: **
                     39: **     This is not a free move.  Hits that occur as a result of
                     40: **     this move appear as though the shields are half up/down,
                     41: **     so you get partial hits.
                     42: */
                     43: 
                     44: struct cvntab Udtab[] =
                     45: {
                     46:        "u",            "p",                    (int (*)())1,           0,
                     47:        "d",            "own",                  0,              0,
                     48:        0
                     49: };
                     50: 
                     51: shield(f)
                     52: int    f;
                     53: {
                     54:        register int            i;
                     55:        char                    c;
                     56:        struct cvntab           *r;
                     57:        char                    s[100];
                     58:        char                    *device, *dev2, *dev3;
                     59:        int                     ind;
                     60:        char                    *stat;
                     61: 
                     62:        if (f > 0 && (Ship.shldup || damaged(SRSCAN)))
                     63:                return;
                     64:        if (f < 0)
                     65:        {
                     66:                /* cloaking device */
                     67:                if (Ship.ship == QUEENE)
                     68:                        return (printf("Ye Faire Queene does not have the cloaking device.\n"));
                     69:                device = "Cloaking device";
                     70:                dev2 = "is";
                     71:                ind = CLOAK;
                     72:                dev3 = "it";
                     73:                stat = &Ship.cloaked;
                     74:        }
                     75:        else
                     76:        {
                     77:                /* shields */
                     78:                device = "Shields";
                     79:                dev2 = "are";
                     80:                dev3 = "them";
                     81:                ind = SHIELD;
                     82:                stat = &Ship.shldup;
                     83:        }
                     84:        if (damaged(ind))
                     85:        {
                     86:                if (f <= 0)
                     87:                        out(ind);
                     88:                return;
                     89:        }
                     90:        if (Ship.cond == DOCKED)
                     91:        {
                     92:                printf("%s %s down while docked\n", device, dev2);
                     93:                return;
                     94:        }
                     95:        if (f <= 0 && !testnl())
                     96:        {
                     97:                r = getcodpar("Up or down", Udtab);
                     98:                i = (int) r->value;
                     99:        }
                    100:        else
                    101:        {
                    102:                if (*stat)
                    103:                        (void)sprintf(s, "%s %s up.  Do you want %s down", device, dev2, dev3);
                    104:                else
                    105:                        (void)sprintf(s, "%s %s down.  Do you want %s up", device, dev2, dev3);
                    106:                if (!getynpar(s))
                    107:                        return;
                    108:                i = !*stat;
                    109:        }
                    110:        if (*stat == i)
                    111:        {
                    112:                printf("%s already ", device);
                    113:                if (i)
                    114:                        printf("up\n");
                    115:                else
                    116:                        printf("down\n");
                    117:                return;
                    118:        }
                    119:        if (i)
                    120:                if (f >= 0)
                    121:                        Ship.energy -= Param.shupengy;
                    122:                else
                    123:                        Ship.cloakgood = 0;
                    124:        Move.free = 0;
                    125:        if (f >= 0)
                    126:                Move.shldchg = 1;
                    127:        *stat = i;
                    128:        return;
                    129: }

unix.superglobalmegacorp.com

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