Annotation of 43BSD/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.  The Berkeley software License Agreement
        !             4:  * specifies the terms and conditions for redistribution.
        !             5:  */
        !             6: 
        !             7: #ifndef lint
        !             8: static char sccsid[] = "@(#)shield.c   5.1 (Berkeley) 1/29/86";
        !             9: #endif not lint
        !            10: 
        !            11: # include      "trek.h"
        !            12: # include      "getpar.h"
        !            13: 
        !            14: /*
        !            15: **  SHIELD AND CLOAKING DEVICE CONTROL
        !            16: **
        !            17: **     'f' is one for auto shield up (in case of Condition RED),
        !            18: **     zero for shield control, and negative one for cloaking
        !            19: **     device control.
        !            20: **
        !            21: **     Called with an 'up' or 'down' on the same line, it puts
        !            22: **     the shields/cloak into the specified mode.  Otherwise it
        !            23: **     reports to the user the current mode, and asks if she wishes
        !            24: **     to change.
        !            25: **
        !            26: **     This is not a free move.  Hits that occur as a result of
        !            27: **     this move appear as though the shields are half up/down,
        !            28: **     so you get partial hits.
        !            29: */
        !            30: 
        !            31: struct cvntab Udtab[] =
        !            32: {
        !            33:        "u",            "p",                    (int (*)())1,           0,
        !            34:        "d",            "own",                  0,              0,
        !            35:        0
        !            36: };
        !            37: 
        !            38: shield(f)
        !            39: int    f;
        !            40: {
        !            41:        register int            i;
        !            42:        char                    c;
        !            43:        struct cvntab           *r;
        !            44:        char                    s[100];
        !            45:        char                    *device, *dev2, *dev3;
        !            46:        int                     ind;
        !            47:        char                    *stat;
        !            48: 
        !            49:        if (f > 0 && (Ship.shldup || damaged(SRSCAN)))
        !            50:                return;
        !            51:        if (f < 0)
        !            52:        {
        !            53:                /* cloaking device */
        !            54:                if (Ship.ship == QUEENE)
        !            55:                        return (printf("Ye Faire Queene does not have the cloaking device.\n"));
        !            56:                device = "Cloaking device";
        !            57:                dev2 = "is";
        !            58:                ind = CLOAK;
        !            59:                dev3 = "it";
        !            60:                stat = &Ship.cloaked;
        !            61:        }
        !            62:        else
        !            63:        {
        !            64:                /* shields */
        !            65:                device = "Shields";
        !            66:                dev2 = "are";
        !            67:                dev3 = "them";
        !            68:                ind = SHIELD;
        !            69:                stat = &Ship.shldup;
        !            70:        }
        !            71:        if (damaged(ind))
        !            72:        {
        !            73:                if (f <= 0)
        !            74:                        out(ind);
        !            75:                return;
        !            76:        }
        !            77:        if (Ship.cond == DOCKED)
        !            78:        {
        !            79:                printf("%s %s down while docked\n", device, dev2);
        !            80:                return;
        !            81:        }
        !            82:        if (f <= 0 && !testnl())
        !            83:        {
        !            84:                r = getcodpar("Up or down", Udtab);
        !            85:                i = (int) r->value;
        !            86:        }
        !            87:        else
        !            88:        {
        !            89:                if (*stat)
        !            90:                        sprintf(s, "%s %s up.  Do you want %s down", device, dev2, dev3);
        !            91:                else
        !            92:                        sprintf(s, "%s %s down.  Do you want %s up", device, dev2, dev3);
        !            93:                if (!getynpar(s))
        !            94:                        return;
        !            95:                i = !*stat;
        !            96:        }
        !            97:        if (*stat == i)
        !            98:        {
        !            99:                printf("%s already ", device);
        !           100:                if (i)
        !           101:                        printf("up\n");
        !           102:                else
        !           103:                        printf("down\n");
        !           104:                return;
        !           105:        }
        !           106:        if (i)
        !           107:                if (f >= 0)
        !           108:                        Ship.energy -= Param.shupengy;
        !           109:                else
        !           110:                        Ship.cloakgood = 0;
        !           111:        Move.free = 0;
        !           112:        if (f >= 0)
        !           113:                Move.shldchg = 1;
        !           114:        *stat = i;
        !           115:        return;
        !           116: }

unix.superglobalmegacorp.com

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