Annotation of 43BSDReno/games/trek/play.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 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[] = "@(#)play.c     5.6 (Berkeley) 6/26/90";
        !            22: #endif /* not lint */
        !            23: 
        !            24: # include      "trek.h"
        !            25: # include      "getpar.h"
        !            26: # include      <setjmp.h>
        !            27: 
        !            28: /*
        !            29: **  INSTRUCTION READ AND MAIN PLAY LOOP
        !            30: **
        !            31: **     Well folks, this is it.  Here we have the guts of the game.
        !            32: **     This routine executes moves.  It sets up per-move variables,
        !            33: **     gets the command, and executes the command.  After the command,
        !            34: **     it calls events() to use up time, attack() to have Klingons
        !            35: **     attack if the move was not free, and checkcond() to check up
        !            36: **     on how we are doing after the move.
        !            37: */
        !            38: extern int     abandon(), capture(), shield(), computer(), dcrept(),
        !            39:                destruct(), dock(), help(), impulse(), lrscan(),
        !            40:                warp(), dumpgame(), rest(), srscan(),
        !            41:                myreset(), torped(), visual(), setwarp(), undock(), phaser();
        !            42: 
        !            43: struct cvntab  Comtab[] =
        !            44: {
        !            45:        "abandon",              "",                     abandon,        0,
        !            46:        "ca",                   "pture",                capture,        0,
        !            47:        "cl",                   "oak",                  shield, -1,
        !            48:        "c",                    "omputer",              computer,       0,
        !            49:        "da",                   "mages",                dcrept, 0,
        !            50:        "destruct",             "",                     destruct,       0,
        !            51:        "do",                   "ck",                   dock,           0,
        !            52:        "help",                 "",                     help,           0,
        !            53:        "i",                    "mpulse",               impulse,        0,
        !            54:        "l",                    "rscan",                lrscan, 0,
        !            55:        "m",                    "ove",                  warp,           0,
        !            56:        "p",                    "hasers",               phaser, 0,
        !            57:        "ram",                  "",                     warp,           1,
        !            58:        "dump",                 "",                     dumpgame,       0,
        !            59:        "r",                    "est",                  rest,           0,
        !            60:        "sh",                   "ield",                 shield, 0,
        !            61:        "s",                    "rscan",                srscan, 0,
        !            62:        "st",                   "atus",                 srscan, -1,
        !            63:        "terminate",            "",                     myreset,        0,
        !            64:        "t",                    "orpedo",               torped, 0,
        !            65:        "u",                    "ndock",                undock, 0,
        !            66:        "v",                    "isual",                visual, 0,
        !            67:        "w",                    "arp",                  setwarp,        0,
        !            68:        0
        !            69: };
        !            70: 
        !            71: myreset()
        !            72: {
        !            73:        extern jmp_buf env;
        !            74: 
        !            75:        longjmp(env, 1);
        !            76: }
        !            77: 
        !            78: play()
        !            79: {
        !            80:        struct cvntab           *r;
        !            81: 
        !            82:        while (1)
        !            83:        {
        !            84:                Move.free = 1;
        !            85:                Move.time = 0.0;
        !            86:                Move.shldchg = 0;
        !            87:                Move.newquad = 0;
        !            88:                Move.resting = 0;
        !            89:                skiptonl(0);
        !            90:                r = getcodpar("\nCommand", Comtab);
        !            91:                (*r->value)(r->value2);
        !            92:                events(0);
        !            93:                attack(0);
        !            94:                checkcond();
        !            95:        }
        !            96: }

unix.superglobalmegacorp.com

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