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

unix.superglobalmegacorp.com

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