Annotation of 43BSDReno/games/sail/pl_4.c, revision 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_4.c     5.4 (Berkeley) 6/1/90";
        !            22: #endif /* not lint */
        !            23: 
        !            24: #include "player.h"
        !            25: 
        !            26: changesail()
        !            27: {
        !            28:        int rig, full;
        !            29: 
        !            30:        rig = mc->rig1;
        !            31:        full = mf->FS;
        !            32:        if (windspeed == 6 || windspeed == 5 && mc->class > 4)
        !            33:                rig = 0;
        !            34:        if (mc->crew3 && rig) {
        !            35:                if (!full) {
        !            36:                        if (sgetch("Increase to Full sails? ",
        !            37:                                (struct ship *)0, 1) == 'y') {
        !            38:                                changed = 1;
        !            39:                                Write(W_FS, ms, 0, 1, 0, 0, 0);
        !            40:                        }
        !            41:                } else {
        !            42:                        if (sgetch("Reduce to Battle sails? ",
        !            43:                                (struct ship *)0, 1) == 'y') {
        !            44:                                Write(W_FS, ms, 0, 0, 0, 0, 0);
        !            45:                                changed = 1;
        !            46:                        }
        !            47:                }
        !            48:        } else if (!rig)
        !            49:                Signal("Sails rent to pieces", (struct ship *)0);
        !            50: }
        !            51: 
        !            52: acceptsignal()
        !            53: {
        !            54:        char buf[60];
        !            55:        register char *p = buf;
        !            56: 
        !            57:        *p++ = '"';
        !            58:        sgetstr("Message? ", p, sizeof buf - 2);
        !            59:        while (*p++)
        !            60:                ;
        !            61:        p[-1] = '"';
        !            62:        *p = 0;
        !            63:        Write(W_SIGNAL, ms, 1, (int)buf, 0, 0, 0);
        !            64: }
        !            65: 
        !            66: lookout()
        !            67: {
        !            68:        register struct ship *sp;
        !            69:        char buf[3];
        !            70:        register char c;
        !            71: 
        !            72:        sgetstr("What ship? ", buf, sizeof buf);
        !            73:        foreachship(sp) {
        !            74:                c = *countryname[sp->nationality];
        !            75:                if ((c == *buf || tolower(c) == *buf || colours(sp) == *buf)
        !            76:                    && (sp->file->stern == buf[1] || sterncolour(sp) == buf[1]
        !            77:                        || buf[1] == '?')) {
        !            78:                        eyeball(sp);
        !            79:                }
        !            80:        }
        !            81: }
        !            82: 
        !            83: char *
        !            84: saywhat(sp, flag)
        !            85: register struct ship *sp;
        !            86: char flag;
        !            87: {
        !            88:        if (sp->file->captain[0])
        !            89:                return sp->file->captain;
        !            90:        else if (sp->file->struck)
        !            91:                return "(struck)";
        !            92:        else if (sp->file->captured != 0)
        !            93:                return "(captured)";
        !            94:        else if (flag)
        !            95:                return "(available)";
        !            96:        else
        !            97:                return "(computer)";
        !            98: }
        !            99: 
        !           100: eyeball(ship)
        !           101: register struct ship *ship;
        !           102: {
        !           103:        int i;
        !           104: 
        !           105:        if (ship->file->dir != 0) {
        !           106:                Signal("Sail ho! (range %d, %s)",
        !           107:                        (struct ship *)0, range(ms, ship), saywhat(ship, 0));
        !           108:                i = portside(ms, ship, 1) - mf->dir;
        !           109:                if (i <= 0)
        !           110:                        i += 8;
        !           111:                Signal("%s (%c%c) %s %s %s.",
        !           112:                        ship, countryname[ship->nationality],
        !           113:                        classname[ship->specs->class], directionname[i]);
        !           114:        }
        !           115: }

unix.superglobalmegacorp.com

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