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

unix.superglobalmegacorp.com

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