mirror of
https://github.com/vattam/BSDGames.git
synced 2025-12-21 03:14:50 +00:00
copy in from cvs; cvs2svn fucked up big time
git-svn-id: file:///srv/svn/joey/trunk/src/packages/bsdgames@9775 a4a2c43b-8ac3-0310-8836-e0e880c912e2
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# $NetBSD: Makefile,v 1.10 1998/02/18 22:37:32 jtc Exp $
|
||||
# $NetBSD: Makefile,v 1.13 2000/06/11 15:37:51 mycroft Exp $
|
||||
# @(#)Makefile 8.1 (Berkeley) 5/31/93
|
||||
|
||||
PROG= sail
|
||||
|
||||
@@ -1,4 +1,30 @@
|
||||
# Makefrag - makefile fragment for sail
|
||||
#
|
||||
# Copyright (c) 1997, 1998 Joseph Samuel Myers.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. The name of the author may not be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
# SUCH DAMAGE.
|
||||
|
||||
sail_DIRS := $(GAMESDIR) $(MAN6DIR)
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: assorted.c,v 1.6 1997/10/13 21:02:57 christos Exp $ */
|
||||
/* $NetBSD: assorted.c,v 1.14 2001/02/05 01:10:08 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
@@ -38,21 +38,18 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)assorted.c 8.2 (Berkeley) 4/28/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: assorted.c,v 1.6 1997/10/13 21:02:57 christos Exp $");
|
||||
__RCSID("$NetBSD: assorted.c,v 1.14 2001/02/05 01:10:08 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include "extern.h"
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <err.h>
|
||||
#include "extern.h"
|
||||
|
||||
static void strike __P((struct ship *, struct ship *));
|
||||
static void strike (struct ship *, struct ship *);
|
||||
|
||||
void
|
||||
table(rig, shot, hittable, on, from, roll)
|
||||
struct ship *on, *from;
|
||||
int rig, shot, hittable, roll;
|
||||
table(struct ship *from, struct ship *on, int rig, int shot, int hittable, int roll)
|
||||
{
|
||||
int hhits = 0, chits = 0, ghits = 0, rhits = 0;
|
||||
int Ghit = 0, Hhit = 0, Rhit = 0, Chit = 0;
|
||||
@@ -60,8 +57,8 @@ int rig, shot, hittable, roll;
|
||||
int crew[3];
|
||||
int n;
|
||||
int rigg[4];
|
||||
char *message;
|
||||
struct Tables *tp;
|
||||
const char *message;
|
||||
const struct Tables *tp;
|
||||
|
||||
pc = on->file->pcrew;
|
||||
hull = on->specs->hull;
|
||||
@@ -139,17 +136,17 @@ int rig, shot, hittable, roll;
|
||||
hull -= ghits;
|
||||
if (Ghit)
|
||||
Write(portside(from, on, 0) ? W_GUNR : W_GUNL,
|
||||
on, 0, guns, car, 0, 0);
|
||||
on, guns, car, 0, 0);
|
||||
hull -= hhits;
|
||||
hull = hull < 0 ? 0 : hull;
|
||||
if (on->file->captured != 0 && Chit)
|
||||
Write(W_PCREW, on, 0, pc, 0, 0, 0);
|
||||
Write(W_PCREW, on, pc, 0, 0, 0);
|
||||
if (Hhit)
|
||||
Write(W_HULL, on, 0, hull, 0, 0, 0);
|
||||
Write(W_HULL, on, hull, 0, 0, 0);
|
||||
if (Chit)
|
||||
Write(W_CREW, on, 0, crew[0], crew[1], crew[2], 0);
|
||||
Write(W_CREW, on, crew[0], crew[1], crew[2], 0);
|
||||
if (Rhit)
|
||||
Write(W_RIGG, on, 0, rigg[0], rigg[1], rigg[2], rigg[3]);
|
||||
Write(W_RIGG, on, rigg[0], rigg[1], rigg[2], rigg[3]);
|
||||
switch (shot) {
|
||||
case L_ROUND:
|
||||
message = "firing round shot on $$";
|
||||
@@ -217,7 +214,7 @@ int rig, shot, hittable, roll;
|
||||
break;
|
||||
case 5:
|
||||
message = "rudder cables shot through";
|
||||
Write(W_TA, on, 0, 0, 0, 0, 0);
|
||||
Write(W_TA, on, 0, 0, 0, 0);
|
||||
break;
|
||||
case 6:
|
||||
message = "shot holes below the water line";
|
||||
@@ -233,10 +230,10 @@ int rig, shot, hittable, roll;
|
||||
if (on->specs->qual <= 0) {
|
||||
makemsg(on, "crew mutinying!");
|
||||
on->specs->qual = 5;
|
||||
Write(W_CAPTURED, on, 0, on->file->index, 0, 0, 0);
|
||||
Write(W_CAPTURED, on, on->file->index, 0, 0, 0);
|
||||
} else
|
||||
makemsg(on, "crew demoralized");
|
||||
Write(W_QUAL, on, 0, on->specs->qual, 0, 0, 0);
|
||||
Write(W_QUAL, on, on->specs->qual, 0, 0, 0);
|
||||
}
|
||||
*/
|
||||
if (!hull)
|
||||
@@ -244,17 +241,15 @@ int rig, shot, hittable, roll;
|
||||
}
|
||||
|
||||
void
|
||||
Cleansnag(from, to, all, flag)
|
||||
struct ship *from, *to;
|
||||
char all, flag;
|
||||
Cleansnag(struct ship *from, struct ship *to, int all, int flag)
|
||||
{
|
||||
if (flag & 1) {
|
||||
Write(W_UNGRAP, from, 0, to->file->index, all, 0, 0);
|
||||
Write(W_UNGRAP, to, 0, from->file->index, all, 0, 0);
|
||||
Write(W_UNGRAP, from, to->file->index, all, 0, 0);
|
||||
Write(W_UNGRAP, to, from->file->index, all, 0, 0);
|
||||
}
|
||||
if (flag & 2) {
|
||||
Write(W_UNFOUL, from, 0, to->file->index, all, 0, 0);
|
||||
Write(W_UNFOUL, to, 0, from->file->index, all, 0, 0);
|
||||
Write(W_UNFOUL, from, to->file->index, all, 0, 0);
|
||||
Write(W_UNFOUL, to, from->file->index, all, 0, 0);
|
||||
}
|
||||
if (!snagged2(from, to)) {
|
||||
if (!snagged(from)) {
|
||||
@@ -271,27 +266,26 @@ char all, flag;
|
||||
}
|
||||
|
||||
static void
|
||||
strike(ship, from)
|
||||
struct ship *ship, *from;
|
||||
strike(struct ship *ship, struct ship *from)
|
||||
{
|
||||
int points;
|
||||
|
||||
if (ship->file->struck)
|
||||
return;
|
||||
Write(W_STRUCK, ship, 0, 1, 0, 0, 0);
|
||||
Write(W_STRUCK, ship, 1, 0, 0, 0);
|
||||
points = ship->specs->pts + from->file->points;
|
||||
Write(W_POINTS, from, 0, points, 0, 0, 0);
|
||||
Write(W_POINTS, from, points, 0, 0, 0);
|
||||
unboard(ship, ship, 0); /* all offense */
|
||||
unboard(ship, ship, 1); /* all defense */
|
||||
switch (die()) {
|
||||
switch (dieroll()) {
|
||||
case 3:
|
||||
case 4: /* ship may sink */
|
||||
Write(W_SINK, ship, 0, 1, 0, 0, 0);
|
||||
Write(W_SINK, ship, 1, 0, 0, 0);
|
||||
break;
|
||||
case 5:
|
||||
case 6: /* ship may explode */
|
||||
Write(W_EXPLODE, ship, 0, 1, 0, 0, 0);
|
||||
Write(W_EXPLODE, ship, 1, 0, 0, 0);
|
||||
break;
|
||||
}
|
||||
Write(W_SIGNAL, ship, 1, (int) "striking her colours!", 0, 0, 0);
|
||||
Writestr(W_SIGNAL, ship, "striking her colours!");
|
||||
}
|
||||
|
||||
93
sail/dr_1.c
93
sail/dr_1.c
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: dr_1.c,v 1.7 1998/08/30 09:19:40 veego Exp $ */
|
||||
/* $NetBSD: dr_1.c,v 1.18 2001/02/05 01:10:08 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
@@ -38,15 +38,21 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)dr_1.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: dr_1.c,v 1.7 1998/08/30 09:19:40 veego Exp $");
|
||||
__RCSID("$NetBSD: dr_1.c,v 1.18 2001/02/05 01:10:08 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include "driver.h"
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "extern.h"
|
||||
#include "driver.h"
|
||||
|
||||
static int fightitout(struct ship *, struct ship *, int);
|
||||
|
||||
void
|
||||
unfoul()
|
||||
unfoul(void)
|
||||
{
|
||||
struct ship *sp;
|
||||
struct ship *to;
|
||||
@@ -62,14 +68,14 @@ unfoul()
|
||||
!is_toughmelee(sp, to, 0, 0))
|
||||
continue;
|
||||
for (i = fouled2(sp, to); --i >= 0;)
|
||||
if (die() <= 2)
|
||||
if (dieroll() <= 2)
|
||||
cleanfoul(sp, to, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
boardcomp()
|
||||
boardcomp(void)
|
||||
{
|
||||
int crew[3];
|
||||
struct ship *sp, *sq;
|
||||
@@ -133,10 +139,8 @@ boardcomp()
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
fightitout(from, to, key)
|
||||
struct ship *from, *to;
|
||||
int key;
|
||||
static int
|
||||
fightitout(struct ship *from, struct ship *to, int key)
|
||||
{
|
||||
struct ship *fromcap, *tocap;
|
||||
int crewfrom[3], crewto[3], menfrom, mento;
|
||||
@@ -173,12 +177,12 @@ int key;
|
||||
index = fromstrength/10;
|
||||
if (index > 8)
|
||||
index = 8;
|
||||
toinjured = MT[index][2 - die() / 3];
|
||||
toinjured = MT[index][2 - dieroll() / 3];
|
||||
totalto += toinjured;
|
||||
index = strengthto/10;
|
||||
if (index > 8)
|
||||
index = 8;
|
||||
frominjured = MT[index][2 - die() / 3];
|
||||
frominjured = MT[index][2 - dieroll() / 3];
|
||||
totalfrom += frominjured;
|
||||
menfrom -= frominjured;
|
||||
mento -= toinjured;
|
||||
@@ -187,21 +191,21 @@ int key;
|
||||
}
|
||||
if (fromstrength >= strengthto * 3 || count == 4) {
|
||||
unboard(to, from, 0);
|
||||
subtract(from, totalfrom, crewfrom, fromcap, pcfrom);
|
||||
subtract(to, totalto, crewto, tocap, pcto);
|
||||
subtract(from, fromcap, totalfrom, crewfrom, pcfrom);
|
||||
subtract(to, tocap, totalto, crewto, pcto);
|
||||
makemsg(from, "boarders from %s repelled", to->shipname);
|
||||
(void) sprintf(message, "killed in melee: %d. %s: %d",
|
||||
sprintf(message, "killed in melee: %d. %s: %d",
|
||||
totalto, from->shipname, totalfrom);
|
||||
Write(W_SIGNAL, to, 1, (long) message, 0, 0, 0);
|
||||
Writestr(W_SIGNAL, to, message);
|
||||
if (key)
|
||||
return 1;
|
||||
} else if (strengthto >= fromstrength * 3) {
|
||||
unboard(from, to, 0);
|
||||
subtract(from, totalfrom, crewfrom, fromcap, pcfrom);
|
||||
subtract(to, totalto, crewto, tocap, pcto);
|
||||
subtract(from, fromcap, totalfrom, crewfrom, pcfrom);
|
||||
subtract(to, tocap, totalto, crewto, pcto);
|
||||
if (key) {
|
||||
if (fromcap != from)
|
||||
Write(W_POINTS, fromcap, 0,
|
||||
Write(W_POINTS, fromcap,
|
||||
fromcap->file->points -
|
||||
from->file->struck
|
||||
? from->specs->pts
|
||||
@@ -212,22 +216,21 @@ int key;
|
||||
I guess that what is going on here is that the pointer is multiplied
|
||||
or something. */
|
||||
|
||||
Write(W_CAPTURED, from, 0, to->file->index, 0, 0, 0);
|
||||
Write(W_CAPTURED, from, to->file->index, 0, 0, 0);
|
||||
topoints = 2 * from->specs->pts + to->file->points;
|
||||
if (from->file->struck)
|
||||
topoints -= from->specs->pts;
|
||||
Write(W_POINTS, to, 0, topoints, 0, 0, 0);
|
||||
Write(W_POINTS, to, topoints, 0, 0, 0);
|
||||
mento = crewto[0] ? crewto[0] : crewto[1];
|
||||
if (mento) {
|
||||
subtract(to, mento, crewto, tocap, pcto);
|
||||
subtract(from, - mento, crewfrom, to, 0);
|
||||
subtract(to, tocap, mento, crewto, pcto);
|
||||
subtract(from, to, - mento, crewfrom, 0);
|
||||
}
|
||||
(void) sprintf(message, "captured by the %s!",
|
||||
to->shipname);
|
||||
Write(W_SIGNAL, from, 1, (long) message, 0, 0, 0);
|
||||
(void) sprintf(message, "killed in melee: %d. %s: %d",
|
||||
sprintf(message, "captured by the %s!", to->shipname);
|
||||
Writestr(W_SIGNAL, from, message);
|
||||
sprintf(message, "killed in melee: %d. %s: %d",
|
||||
totalto, from->shipname, totalfrom);
|
||||
Write(W_SIGNAL, to, 1, (long) message, 0, 0, 0);
|
||||
Writestr(W_SIGNAL, to, message);
|
||||
mento = 0;
|
||||
return 0;
|
||||
}
|
||||
@@ -236,7 +239,7 @@ int key;
|
||||
}
|
||||
|
||||
void
|
||||
resolve()
|
||||
resolve(void)
|
||||
{
|
||||
int thwart;
|
||||
struct ship *sp, *sq;
|
||||
@@ -246,7 +249,7 @@ resolve()
|
||||
continue;
|
||||
for (sq = sp + 1; sq < ls; sq++)
|
||||
if (sq->file->dir && meleeing(sp, sq) && meleeing(sq, sp))
|
||||
(void) fightitout(sp, sq, 0);
|
||||
fightitout(sp, sq, 0);
|
||||
thwart = 2;
|
||||
foreachship(sq) {
|
||||
if (sq->file->dir && meleeing(sq, sp))
|
||||
@@ -267,7 +270,7 @@ resolve()
|
||||
}
|
||||
|
||||
void
|
||||
compcombat()
|
||||
compcombat(void)
|
||||
{
|
||||
int n;
|
||||
struct ship *sp;
|
||||
@@ -392,14 +395,14 @@ compcombat()
|
||||
if (hit >= 0) {
|
||||
if (load != L_GRAPE)
|
||||
hit = hit > 10 ? 10 : hit;
|
||||
table(shootat, load, hit, closest, sp, die());
|
||||
table(sp, closest, shootat, load, hit, dieroll());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
next()
|
||||
next(void)
|
||||
{
|
||||
if (++turn % 55 == 0) {
|
||||
if (alive)
|
||||
@@ -421,12 +424,16 @@ next()
|
||||
}
|
||||
}
|
||||
if (best > 0.0) {
|
||||
char *p = getenv("WOTD");
|
||||
if (p == 0)
|
||||
char *tp = getenv("WOTD");
|
||||
const char *p;
|
||||
if (tp == 0)
|
||||
p = "Driver";
|
||||
if (islower(*p))
|
||||
*p = toupper(*p);
|
||||
(void) strncpy(bestship->file->captain, p,
|
||||
else {
|
||||
if (islower(*tp))
|
||||
*tp = toupper(*tp);
|
||||
p = tp;
|
||||
}
|
||||
strncpy(bestship->file->captain, p,
|
||||
sizeof bestship->file->captain);
|
||||
bestship->file->captain
|
||||
[sizeof bestship->file->captain - 1] = 0;
|
||||
@@ -434,9 +441,9 @@ next()
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
Write(W_TURN, SHIP(0), 0, turn, 0, 0, 0);
|
||||
if (turn % 7 == 0 && (die() >= cc->windchange || !windspeed)) {
|
||||
switch (die()) {
|
||||
Write(W_TURN, SHIP(0), turn, 0, 0, 0);
|
||||
if (turn % 7 == 0 && (dieroll() >= cc->windchange || !windspeed)) {
|
||||
switch (dieroll()) {
|
||||
case 1:
|
||||
winddir = 1;
|
||||
break;
|
||||
@@ -460,7 +467,7 @@ next()
|
||||
if (winddir < 1)
|
||||
winddir += 8;
|
||||
if (windspeed)
|
||||
switch (die()) {
|
||||
switch (dieroll()) {
|
||||
case 1:
|
||||
case 2:
|
||||
windspeed--;
|
||||
@@ -472,7 +479,7 @@ next()
|
||||
}
|
||||
else
|
||||
windspeed++;
|
||||
Write(W_WIND, SHIP(0), 0, winddir, windspeed, 0, 0);
|
||||
Write(W_WIND, SHIP(0), winddir, windspeed, 0, 0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
114
sail/dr_2.c
114
sail/dr_2.c
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: dr_2.c,v 1.8 1998/09/11 14:13:46 hubertf Exp $ */
|
||||
/* $NetBSD: dr_2.c,v 1.18 2001/02/05 01:10:08 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
@@ -38,17 +38,28 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)dr_2.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: dr_2.c,v 1.8 1998/09/11 14:13:46 hubertf Exp $");
|
||||
__RCSID("$NetBSD: dr_2.c,v 1.18 2001/02/05 01:10:08 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include "driver.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "extern.h"
|
||||
#include "driver.h"
|
||||
|
||||
#define couldwin(f,t) (f->specs->crew2 > t->specs->crew2 * 1.5)
|
||||
|
||||
static int str_end(const char *);
|
||||
static int score(struct ship *, struct ship *, char *, int);
|
||||
static void move_ship(struct ship *, const char *, unsigned char *, short *, short *, char *);
|
||||
static void try(struct ship *, struct ship *, char *, char *, int, int, int, int, int, int *, int);
|
||||
static void rmend(char *);
|
||||
|
||||
const int dtab[] = {0,1,1,2,3,4,4,5}; /* diagonal distances in x==y */
|
||||
|
||||
void
|
||||
thinkofgrapples()
|
||||
thinkofgrapples(void)
|
||||
{
|
||||
struct ship *sp, *sq;
|
||||
char friendly;
|
||||
@@ -79,7 +90,7 @@ thinkofgrapples()
|
||||
}
|
||||
|
||||
void
|
||||
checkup()
|
||||
checkup(void)
|
||||
{
|
||||
struct ship *sp, *sq;
|
||||
char explode, sink;
|
||||
@@ -91,10 +102,10 @@ checkup()
|
||||
sink = sp->file->sink;
|
||||
if (explode != 1 && sink != 1)
|
||||
continue;
|
||||
if (die() < 5)
|
||||
if (dieroll() < 5)
|
||||
continue;
|
||||
Write(sink == 1 ? W_SINK : W_EXPLODE, sp, 0, 2, 0, 0, 0);
|
||||
Write(W_DIR, sp, 0, 0, 0, 0, 0);
|
||||
Write(sink == 1 ? W_SINK : W_EXPLODE, sp, 2, 0, 0, 0);
|
||||
Write(W_DIR, sp, 0, 0, 0, 0);
|
||||
if (snagged(sp))
|
||||
foreachship(sq)
|
||||
cleansnag(sp, sq, 1);
|
||||
@@ -102,7 +113,7 @@ checkup()
|
||||
makemsg(sp, "exploding!");
|
||||
foreachship(sq) {
|
||||
if (sp != sq && sq->file->dir && range(sp, sq) < 4)
|
||||
table(RIGGING, L_EXPLODE, sp->specs->guns/13, sq, sp, 6);
|
||||
table(sp, sq, RIGGING, L_EXPLODE, sp->specs->guns/13, 6);
|
||||
}
|
||||
} else
|
||||
makemsg(sp, "sinking!");
|
||||
@@ -110,7 +121,7 @@ checkup()
|
||||
}
|
||||
|
||||
void
|
||||
prizecheck()
|
||||
prizecheck(void)
|
||||
{
|
||||
struct ship *sp;
|
||||
|
||||
@@ -120,19 +131,17 @@ prizecheck()
|
||||
if (sp->file->struck || sp->file->dir == 0)
|
||||
continue;
|
||||
if (sp->specs->crew1 + sp->specs->crew2 + sp->specs->crew3 > sp->file->pcrew * 6) {
|
||||
Write(W_SIGNAL, sp, 1,
|
||||
(long)"prize crew overthrown", 0, 0, 0);
|
||||
Write(W_POINTS, sp->file->captured, 0, sp->file->captured->file->points - 2 * sp->specs->pts, 0, 0, 0);
|
||||
Write(W_CAPTURED, sp, 0, -1, 0, 0, 0);
|
||||
Writestr(W_SIGNAL, sp, "prize crew overthrown");
|
||||
Write(W_POINTS, sp->file->captured, sp->file->captured->file->points - 2 * sp->specs->pts, 0, 0, 0);
|
||||
Write(W_CAPTURED, sp, -1, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
str_end(str)
|
||||
char *str;
|
||||
static int
|
||||
str_end(const char *str)
|
||||
{
|
||||
char *p;
|
||||
const char *p;
|
||||
|
||||
for (p = str; *p; p++)
|
||||
;
|
||||
@@ -140,26 +149,18 @@ char *str;
|
||||
}
|
||||
|
||||
void
|
||||
closeon(from, to, command, ta, ma, af)
|
||||
struct ship *from, *to;
|
||||
char command[];
|
||||
int ma, ta, af;
|
||||
closeon(struct ship *from, struct ship *to, char *command, int ta, int ma, int af)
|
||||
{
|
||||
int high;
|
||||
char temp[10];
|
||||
|
||||
temp[0] = command[0] = '\0';
|
||||
high = -30000;
|
||||
try(command, temp, ma, ta, af, ma, from->file->dir, from, to, &high, 0);
|
||||
try(from, to, command, temp, ma, ta, af, ma, from->file->dir, &high, 0);
|
||||
}
|
||||
|
||||
int dtab[] = {0,1,1,2,3,4,4,5}; /* diagonal distances in x==y */
|
||||
|
||||
int
|
||||
score(movement, ship, to, onlytemp)
|
||||
char movement[];
|
||||
struct ship *ship, *to;
|
||||
char onlytemp;
|
||||
static int
|
||||
score(struct ship *ship, struct ship *to, char *movement, int onlytemp)
|
||||
{
|
||||
char drift;
|
||||
int row, col, dir, total, ran;
|
||||
@@ -170,9 +171,9 @@ char onlytemp;
|
||||
row = fp->row;
|
||||
col = fp->col;
|
||||
drift = fp->drift;
|
||||
move_ship(movement, ship, &fp->dir, &fp->row, &fp->col, &drift);
|
||||
move_ship(ship, movement, &fp->dir, &fp->row, &fp->col, &drift);
|
||||
if (!*movement)
|
||||
(void) strcpy(movement, "d");
|
||||
strcpy(movement, "d");
|
||||
|
||||
ran = range(ship, to);
|
||||
total = -50 * ran;
|
||||
@@ -189,13 +190,8 @@ char onlytemp;
|
||||
return total;
|
||||
}
|
||||
|
||||
void
|
||||
move_ship(p, ship, dir, row, col, drift)
|
||||
char *p;
|
||||
struct ship *ship;
|
||||
unsigned char *dir;
|
||||
short *row, *col;
|
||||
char *drift;
|
||||
static void
|
||||
move_ship(struct ship *ship, const char *p, unsigned char *dir, short *row, short *col, char *drift)
|
||||
{
|
||||
int dist;
|
||||
char moved = 0;
|
||||
@@ -234,11 +230,8 @@ char *drift;
|
||||
*drift = 0;
|
||||
}
|
||||
|
||||
void
|
||||
try(command, temp, ma, ta, af, vma, dir, f, t, high, rakeme)
|
||||
struct ship *f, *t;
|
||||
int ma, ta, af, vma, dir, *high, rakeme;
|
||||
char command[], temp[];
|
||||
static void
|
||||
try(struct ship *f, struct ship *t, char *command, char *temp, int ma, int ta, int af, int vma, int dir, int *high, int rakeme)
|
||||
{
|
||||
int new, n;
|
||||
char st[4];
|
||||
@@ -246,42 +239,41 @@ char command[], temp[];
|
||||
|
||||
if ((n = str_end(temp)) < '1' || n > '9')
|
||||
for (n = 1; vma - n >= 0; n++) {
|
||||
(void) sprintf(st, "%d", n);
|
||||
(void) strcat(temp, st);
|
||||
new = score(temp, f, t, rakeme);
|
||||
sprintf(st, "%d", n);
|
||||
strcat(temp, st);
|
||||
new = score(f, t, temp, rakeme);
|
||||
if (new > *high && (!rakeme || rakeyou)) {
|
||||
*high = new;
|
||||
(void) strcpy(command, temp);
|
||||
strcpy(command, temp);
|
||||
}
|
||||
try(command, temp, ma-n, ta, af, vma-n,
|
||||
dir, f, t, high, rakeme);
|
||||
try(f, t, command, temp, ma-n, ta, af, vma-n,
|
||||
dir, high, rakeme);
|
||||
rmend(temp);
|
||||
}
|
||||
if ((ma > 0 && ta > 0 && (n = str_end(temp)) != 'l' && n != 'r') || !strlen(temp)) {
|
||||
(void) strcat(temp, "r");
|
||||
new = score(temp, f, t, rakeme);
|
||||
strcat(temp, "r");
|
||||
new = score(f, t, temp, rakeme);
|
||||
if (new > *high && (!rakeme || (gunsbear(f, t) && !gunsbear(t, f)))) {
|
||||
*high = new;
|
||||
(void) strcpy(command, temp);
|
||||
strcpy(command, temp);
|
||||
}
|
||||
try(command, temp, ma-1, ta-1, af, min(ma-1, maxmove(f, (dir == 8 ? 1 : dir+1), 0)), (dir == 8 ? 1 : dir+1),f,t,high,rakeme);
|
||||
try(f, t, command, temp, ma-1, ta-1, af, min(ma-1, maxmove(f, (dir == 8 ? 1 : dir+1), 0)), (dir == 8 ? 1 : dir+1), high, rakeme);
|
||||
rmend(temp);
|
||||
}
|
||||
if ((ma > 0 && ta > 0 && (n = str_end(temp)) != 'l' && n != 'r') || !strlen(temp)){
|
||||
(void) strcat(temp, "l");
|
||||
new = score(temp, f, t, rakeme);
|
||||
strcat(temp, "l");
|
||||
new = score(f, t, temp, rakeme);
|
||||
if (new > *high && (!rakeme || (gunsbear(f, t) && !gunsbear(t, f)))){
|
||||
*high = new;
|
||||
(void) strcpy(command, temp);
|
||||
strcpy(command, temp);
|
||||
}
|
||||
try(command, temp, ma-1, ta-1, af, (min(ma-1,maxmove(f, (dir-1 ? dir-1 : 8), 0))), (dir-1 ? dir -1 : 8), f, t, high, rakeme);
|
||||
try(f, t, command, temp, ma-1, ta-1, af, (min(ma-1,maxmove(f, (dir-1 ? dir-1 : 8), 0))), (dir-1 ? dir -1 : 8), high, rakeme);
|
||||
rmend(temp);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
rmend(str)
|
||||
char *str;
|
||||
static void
|
||||
rmend(char *str)
|
||||
{
|
||||
char *p;
|
||||
|
||||
|
||||
75
sail/dr_3.c
75
sail/dr_3.c
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: dr_3.c,v 1.5 1997/10/13 21:03:27 christos Exp $ */
|
||||
/* $NetBSD: dr_3.c,v 1.14 2001/02/05 01:10:09 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
@@ -38,15 +38,23 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)dr_3.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: dr_3.c,v 1.5 1997/10/13 21:03:27 christos Exp $");
|
||||
__RCSID("$NetBSD: dr_3.c,v 1.14 2001/02/05 01:10:09 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include "driver.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "extern.h"
|
||||
#include "driver.h"
|
||||
|
||||
static int stillmoving(int);
|
||||
static int is_isolated(struct ship *);
|
||||
static int push(struct ship *, struct ship *);
|
||||
static void step(struct ship *, int, char *);
|
||||
|
||||
/* move all comp ships */
|
||||
void
|
||||
moveall() /* move all comp ships */
|
||||
moveall(void)
|
||||
{
|
||||
struct ship *sp, *sq;
|
||||
int n;
|
||||
@@ -86,10 +94,10 @@ moveall() /* move all comp ships */
|
||||
n = 0;
|
||||
foreachship(sp) {
|
||||
if (snagged(sp))
|
||||
(void) strcpy(sp->file->movebuf, "d");
|
||||
strcpy(sp->file->movebuf, "d");
|
||||
else
|
||||
if (*sp->file->movebuf != 'd')
|
||||
(void) strcat(sp->file->movebuf, "d");
|
||||
strcat(sp->file->movebuf, "d");
|
||||
row[n] = sp->file->row;
|
||||
col[n] = sp->file->col;
|
||||
dir[n] = sp->file->dir;
|
||||
@@ -111,7 +119,7 @@ moveall() /* move all comp ships */
|
||||
if (!sp->file->movebuf[k])
|
||||
sp->file->movebuf[k+1] = '\0';
|
||||
else if (sp->file->dir)
|
||||
step(sp->file->movebuf[k], sp, &moved[n]);
|
||||
step(sp, sp->file->movebuf[k], &moved[n]);
|
||||
n++;
|
||||
}
|
||||
/*
|
||||
@@ -135,11 +143,11 @@ moveall() /* move all comp ships */
|
||||
snap++;
|
||||
if (!range(sp, sq) && !fouled2(sp, sq)) {
|
||||
makesignal(sp, "collision with $$", sq);
|
||||
if (die() < 4) {
|
||||
if (dieroll() < 4) {
|
||||
makesignal(sp, "fouled with $$",
|
||||
sq);
|
||||
Write(W_FOUL, sp, 0, l, 0, 0, 0);
|
||||
Write(W_FOUL, sq, 0, n, 0, 0, 0);
|
||||
Write(W_FOUL, sp, l, 0, 0, 0);
|
||||
Write(W_FOUL, sq, n, 0, 0, 0);
|
||||
}
|
||||
snap++;
|
||||
}
|
||||
@@ -170,21 +178,20 @@ moveall() /* move all comp ships */
|
||||
if (sp->file->dir != 0) {
|
||||
*sp->file->movebuf = 0;
|
||||
if (row[n] != sp->file->row)
|
||||
Write(W_ROW, sp, 0, sp->file->row, 0, 0, 0);
|
||||
Write(W_ROW, sp, sp->file->row, 0, 0, 0);
|
||||
if (col[n] != sp->file->col)
|
||||
Write(W_COL, sp, 0, sp->file->col, 0, 0, 0);
|
||||
Write(W_COL, sp, sp->file->col, 0, 0, 0);
|
||||
if (dir[n] != sp->file->dir)
|
||||
Write(W_DIR, sp, 0, sp->file->dir, 0, 0, 0);
|
||||
Write(W_DIR, sp, sp->file->dir, 0, 0, 0);
|
||||
if (drift[n] != sp->file->drift)
|
||||
Write(W_DRIFT, sp, 0, sp->file->drift, 0, 0, 0);
|
||||
Write(W_DRIFT, sp, sp->file->drift, 0, 0, 0);
|
||||
}
|
||||
n++;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
stillmoving(k)
|
||||
int k;
|
||||
static int
|
||||
stillmoving(int k)
|
||||
{
|
||||
struct ship *sp;
|
||||
|
||||
@@ -194,9 +201,8 @@ int k;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
is_isolated(ship)
|
||||
struct ship *ship;
|
||||
static int
|
||||
is_isolated(struct ship *ship)
|
||||
{
|
||||
struct ship *sp;
|
||||
|
||||
@@ -207,9 +213,8 @@ struct ship *ship;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
push(from, to)
|
||||
struct ship *from, *to;
|
||||
static int
|
||||
push(struct ship *from, struct ship *to)
|
||||
{
|
||||
int bs, sb;
|
||||
|
||||
@@ -222,11 +227,8 @@ struct ship *from, *to;
|
||||
return from < to;
|
||||
}
|
||||
|
||||
void
|
||||
step(com, sp, moved)
|
||||
char com;
|
||||
struct ship *sp;
|
||||
char *moved;
|
||||
static void
|
||||
step(struct ship *sp, int com, char *moved)
|
||||
{
|
||||
int dist;
|
||||
|
||||
@@ -266,10 +268,7 @@ char *moved;
|
||||
}
|
||||
|
||||
void
|
||||
sendbp(from, to, sections, isdefense)
|
||||
struct ship *from, *to;
|
||||
int sections;
|
||||
char isdefense;
|
||||
sendbp(struct ship *from, struct ship *to, int sections, int isdefense)
|
||||
{
|
||||
int n;
|
||||
struct BP *bp;
|
||||
@@ -278,7 +277,7 @@ char isdefense;
|
||||
for (n = 0; n < NBP && bp[n].turnsent; n++)
|
||||
;
|
||||
if (n < NBP && sections) {
|
||||
Write(isdefense ? W_DBP : W_OBP, from, 0,
|
||||
Write(isdefense ? W_DBP : W_OBP, from,
|
||||
n, turn, to->file->index, sections);
|
||||
if (isdefense)
|
||||
makemsg(from, "repelling boarders");
|
||||
@@ -288,9 +287,7 @@ char isdefense;
|
||||
}
|
||||
|
||||
int
|
||||
is_toughmelee(ship, to, isdefense, count)
|
||||
struct ship *ship, *to;
|
||||
int isdefense, count;
|
||||
is_toughmelee(struct ship *ship, struct ship *to, int isdefense, int count)
|
||||
{
|
||||
struct BP *bp;
|
||||
int obp = 0;
|
||||
@@ -321,7 +318,7 @@ int isdefense, count;
|
||||
}
|
||||
|
||||
void
|
||||
reload()
|
||||
reload(void)
|
||||
{
|
||||
struct ship *sp;
|
||||
|
||||
@@ -331,7 +328,7 @@ reload()
|
||||
}
|
||||
|
||||
void
|
||||
checksails()
|
||||
checksails(void)
|
||||
{
|
||||
struct ship *sp;
|
||||
int rig, full;
|
||||
@@ -355,6 +352,6 @@ checksails()
|
||||
} else
|
||||
full = 0;
|
||||
if ((sp->file->FS != 0) != full)
|
||||
Write(W_FS, sp, 0, full, 0, 0, 0);
|
||||
Write(W_FS, sp, full, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
20
sail/dr_4.c
20
sail/dr_4.c
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: dr_4.c,v 1.6 1997/10/13 21:03:37 christos Exp $ */
|
||||
/* $NetBSD: dr_4.c,v 1.12 2001/02/05 01:10:09 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
@@ -38,16 +38,15 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)dr_4.c 8.2 (Berkeley) 4/28/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: dr_4.c,v 1.6 1997/10/13 21:03:37 christos Exp $");
|
||||
__RCSID("$NetBSD: dr_4.c,v 1.12 2001/02/05 01:10:09 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include "extern.h"
|
||||
#include <stdlib.h>
|
||||
#include "extern.h"
|
||||
|
||||
void
|
||||
ungrap(from, to)
|
||||
struct ship *from, *to;
|
||||
ungrap(struct ship *from, struct ship *to)
|
||||
{
|
||||
int k;
|
||||
char friend;
|
||||
@@ -56,7 +55,7 @@ struct ship *from, *to;
|
||||
return;
|
||||
friend = capship(from)->nationality == capship(to)->nationality;
|
||||
while (--k >= 0) {
|
||||
if (friend || die() < 3) {
|
||||
if (friend || dieroll() < 3) {
|
||||
cleangrapple(from, to, 0);
|
||||
makesignal(from, "ungrappling $$", to);
|
||||
}
|
||||
@@ -64,12 +63,11 @@ struct ship *from, *to;
|
||||
}
|
||||
|
||||
void
|
||||
grap(from, to)
|
||||
struct ship *from, *to;
|
||||
grap(struct ship *from, struct ship *to)
|
||||
{
|
||||
if (capship(from)->nationality != capship(to)->nationality && die() > 2)
|
||||
if (capship(from)->nationality != capship(to)->nationality && dieroll() > 2)
|
||||
return;
|
||||
Write(W_GRAP, from, 0, to->file->index, 0, 0, 0);
|
||||
Write(W_GRAP, to, 0, from->file->index, 0, 0, 0);
|
||||
Write(W_GRAP, from, to->file->index, 0, 0, 0);
|
||||
Write(W_GRAP, to, from->file->index, 0, 0, 0);
|
||||
makesignal(from, "grappled with $$", to);
|
||||
}
|
||||
|
||||
19
sail/dr_5.c
19
sail/dr_5.c
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: dr_5.c,v 1.5 1997/10/13 19:43:47 christos Exp $ */
|
||||
/* $NetBSD: dr_5.c,v 1.11 2001/02/05 01:10:09 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
@@ -38,17 +38,15 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)dr_5.c 8.2 (Berkeley) 4/28/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: dr_5.c,v 1.5 1997/10/13 19:43:47 christos Exp $");
|
||||
__RCSID("$NetBSD: dr_5.c,v 1.11 2001/02/05 01:10:09 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include "extern.h"
|
||||
|
||||
void
|
||||
subtract(from, totalfrom, crewfrom, fromcap, pcfrom)
|
||||
struct ship *from, *fromcap;
|
||||
int pcfrom;
|
||||
int totalfrom, crewfrom[3];
|
||||
subtract(struct ship *from, struct ship *fromcap, int totalfrom, int *crewfrom, int pcfrom)
|
||||
{
|
||||
int n;
|
||||
|
||||
@@ -62,19 +60,16 @@ int totalfrom, crewfrom[3];
|
||||
totalfrom = 0;
|
||||
}
|
||||
}
|
||||
Write(W_CREW, from, 0, crewfrom[0], crewfrom[1], crewfrom[2], 0);
|
||||
Write(W_CREW, from, crewfrom[0], crewfrom[1], crewfrom[2], 0);
|
||||
} else if (totalfrom) {
|
||||
pcfrom -= totalfrom;
|
||||
pcfrom = pcfrom < 0 ? 0 : pcfrom;
|
||||
Write(W_PCREW, from, 0, pcfrom, 0, 0, 0);
|
||||
Write(W_PCREW, from, pcfrom, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
mensent(from, to, crew, captured, pc, isdefense)
|
||||
struct ship *from, *to, **captured;
|
||||
int crew[3], *pc;
|
||||
char isdefense;
|
||||
mensent(struct ship *from, struct ship *to, int *crew, struct ship **captured, int *pc, int isdefense)
|
||||
{ /* returns # of crew squares sent */
|
||||
int men = 0;
|
||||
int n;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: dr_main.c,v 1.5 1997/10/13 19:43:54 christos Exp $ */
|
||||
/* $NetBSD: dr_main.c,v 1.11 2001/02/05 01:10:09 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
@@ -38,25 +38,28 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)dr_main.c 8.2 (Berkeley) 4/16/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: dr_main.c,v 1.5 1997/10/13 19:43:54 christos Exp $");
|
||||
__RCSID("$NetBSD: dr_main.c,v 1.11 2001/02/05 01:10:09 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include "driver.h"
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "extern.h"
|
||||
#include "driver.h"
|
||||
|
||||
int
|
||||
dr_main()
|
||||
dr_main(void)
|
||||
{
|
||||
int n;
|
||||
struct ship *sp;
|
||||
int nat[NNATION];
|
||||
int value = 0;
|
||||
|
||||
(void) signal(SIGINT, SIG_IGN);
|
||||
(void) signal(SIGQUIT, SIG_IGN);
|
||||
(void) signal(SIGTSTP, SIG_IGN);
|
||||
signal(SIGINT, SIG_IGN);
|
||||
signal(SIGQUIT, SIG_IGN);
|
||||
signal(SIGTSTP, SIG_IGN);
|
||||
if (game < 0 || game >= NSCENE) {
|
||||
fprintf(stderr, "DRIVER: Bad game number %d\n", game);
|
||||
exit(1);
|
||||
@@ -72,7 +75,7 @@ dr_main()
|
||||
foreachship(sp) {
|
||||
if (sp->file == NULL &&
|
||||
(sp->file = (struct File *)calloc(1, sizeof (struct File))) == NULL) {
|
||||
(void) fprintf(stderr, "DRIVER: Out of memory.\n");
|
||||
fprintf(stderr, "DRIVER: Out of memory.\n");
|
||||
exit(1);
|
||||
}
|
||||
sp->file->index = sp - SHIP(0);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: driver.h,v 1.5 1998/03/29 04:57:19 mrg Exp $ */
|
||||
/* $NetBSD: driver.h,v 1.7 2001/01/04 03:21:17 jwise Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
@@ -35,6 +35,4 @@
|
||||
* @(#)driver.h 8.2 (Berkeley) 5/3/95
|
||||
*/
|
||||
|
||||
#include "extern.h"
|
||||
|
||||
extern int dtab[];
|
||||
extern const int dtab[];
|
||||
|
||||
252
sail/extern.h
252
sail/extern.h
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: extern.h,v 1.8 1998/09/13 15:27:30 hubertf Exp $ */
|
||||
/* $NetBSD: extern.h,v 1.24 2001/01/04 06:16:51 jwise Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
@@ -35,34 +35,26 @@
|
||||
* @(#)externs.h 8.1 (Berkeley) 5/31/93
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <setjmp.h>
|
||||
#include <sys/types.h>
|
||||
#include "machdep.h"
|
||||
|
||||
/* program mode */
|
||||
int mode;
|
||||
jmp_buf restart;
|
||||
extern int mode;
|
||||
#define MODE_PLAYER 1
|
||||
#define MODE_DRIVER 2
|
||||
#define MODE_LOGGER 3
|
||||
|
||||
/* command line flags */
|
||||
char debug; /* -D */
|
||||
char randomize; /* -x, give first available ship */
|
||||
char longfmt; /* -l, print score in long format */
|
||||
char nobells; /* -b, don't ring bell before Signal */
|
||||
extern int randomize; /* -x, give first available ship */
|
||||
extern int longfmt; /* -l, print score in long format */
|
||||
extern int nobells; /* -b, don't ring bell before Signal */
|
||||
|
||||
/* other initial modes */
|
||||
gid_t gid;
|
||||
gid_t egid;
|
||||
extern gid_t gid;
|
||||
extern gid_t egid;
|
||||
|
||||
#define die() ((rand() >> 3) % 6 + 1)
|
||||
#define dieroll() ((random()) % 6 + 1)
|
||||
#define sqr(a) ((a) * (a))
|
||||
#define abs(a) ((a) > 0 ? (a) : -(a))
|
||||
#define min(a,b) ((a) < (b) ? (a) : (b))
|
||||
|
||||
#define grappled(a) ((a)->file->ngrap)
|
||||
@@ -216,7 +208,7 @@ struct File {
|
||||
};
|
||||
|
||||
struct ship {
|
||||
char *shipname; /* 0 */
|
||||
const char *shipname; /* 0 */
|
||||
struct shipspecs *specs; /* 2 */
|
||||
unsigned char nationality; /* 4 */
|
||||
short shiprow; /* 6 */
|
||||
@@ -230,7 +222,7 @@ struct scenario {
|
||||
char windspeed; /* 2 */
|
||||
char windchange; /* 4 */
|
||||
unsigned char vessels; /* 12 */
|
||||
char *name; /* 14 */
|
||||
const char *name; /* 14 */
|
||||
struct ship ship[NSHIP]; /* 16 */
|
||||
};
|
||||
extern struct scenario scene[];
|
||||
@@ -259,8 +251,8 @@ struct shipspecs {
|
||||
};
|
||||
extern struct shipspecs specs[];
|
||||
|
||||
struct scenario *cc; /* the current scenario */
|
||||
struct ship *ls; /* &cc->ship[cc->vessels] */
|
||||
extern struct scenario *cc; /* the current scenario */
|
||||
extern struct ship *ls; /* &cc->ship[cc->vessels] */
|
||||
|
||||
#define SHIP(s) (&cc->ship[s])
|
||||
#define foreachship(sp) for ((sp) = cc->ship; (sp) < ls; (sp)++)
|
||||
@@ -268,175 +260,157 @@ struct ship *ls; /* &cc->ship[cc->vessels] */
|
||||
struct windeffects {
|
||||
char A, B, C, D;
|
||||
};
|
||||
extern struct windeffects WET[7][6];
|
||||
extern const struct windeffects WET[7][6];
|
||||
|
||||
struct Tables {
|
||||
char H, G, C, R;
|
||||
};
|
||||
extern struct Tables RigTable[11][6];
|
||||
extern struct Tables HullTable[11][6];
|
||||
extern const struct Tables RigTable[11][6];
|
||||
extern const struct Tables HullTable[11][6];
|
||||
|
||||
extern char AMMO[9][4];
|
||||
extern char HDT[9][10];
|
||||
extern char HDTrake[9][10];
|
||||
extern char QUAL[9][5];
|
||||
extern char MT[9][3];
|
||||
extern const char AMMO[9][4];
|
||||
extern const char HDT[9][10];
|
||||
extern const char HDTrake[9][10];
|
||||
extern const char QUAL[9][5];
|
||||
extern const char MT[9][3];
|
||||
|
||||
extern char *countryname[];
|
||||
extern char *classname[];
|
||||
extern char *directionname[];
|
||||
extern char *qualname[];
|
||||
extern char loadname[];
|
||||
extern const char *const countryname[];
|
||||
extern const char *const classname[];
|
||||
extern const char *const directionname[];
|
||||
extern const char *const qualname[];
|
||||
extern const char loadname[];
|
||||
|
||||
extern char rangeofshot[];
|
||||
extern const char rangeofshot[];
|
||||
|
||||
extern char dr[], dc[];
|
||||
extern const char dr[], dc[];
|
||||
|
||||
int winddir;
|
||||
int windspeed;
|
||||
int turn;
|
||||
int game;
|
||||
int alive;
|
||||
int people;
|
||||
char hasdriver;
|
||||
extern int winddir;
|
||||
extern int windspeed;
|
||||
extern int turn;
|
||||
extern int game;
|
||||
extern int alive;
|
||||
extern int people;
|
||||
extern int hasdriver;
|
||||
|
||||
/* assorted.c */
|
||||
void table __P((int, int, int, struct ship *, struct ship *, int));
|
||||
void Cleansnag __P((struct ship *, struct ship *, int, int));
|
||||
void table (struct ship *, struct ship *, int, int, int, int);
|
||||
void Cleansnag (struct ship *, struct ship *, int, int);
|
||||
|
||||
/* dr_1.c */
|
||||
void unfoul __P((void));
|
||||
void boardcomp __P((void));
|
||||
int fightitout __P((struct ship *, struct ship *, int));
|
||||
void resolve __P((void));
|
||||
void compcombat __P((void));
|
||||
int next __P((void));
|
||||
void unfoul (void);
|
||||
void boardcomp (void);
|
||||
void resolve (void);
|
||||
void compcombat (void);
|
||||
int next (void);
|
||||
|
||||
/* dr_2.c */
|
||||
void thinkofgrapples __P((void));
|
||||
void checkup __P((void));
|
||||
void prizecheck __P((void));
|
||||
int str_end __P((char *));
|
||||
void closeon __P((struct ship *, struct ship *, char[], int, int, int));
|
||||
int score __P((char[], struct ship *, struct ship *, int));
|
||||
void move_ship __P((char *, struct ship *, unsigned char *, short *, short *, char *));
|
||||
void try __P((char[], char [], int, int, int, int, int, struct ship *,
|
||||
struct ship *, int *, int));
|
||||
void rmend __P((char *));
|
||||
void thinkofgrapples (void);
|
||||
void checkup (void);
|
||||
void prizecheck (void);
|
||||
void closeon (struct ship *, struct ship *, char *, int, int, int);
|
||||
|
||||
/* dr_3.c */
|
||||
void moveall __P((void));
|
||||
int stillmoving __P((int));
|
||||
int is_isolated __P((struct ship *));
|
||||
int push __P((struct ship *, struct ship *));
|
||||
void step __P((int, struct ship *, char *));
|
||||
void sendbp __P((struct ship *, struct ship *, int, int));
|
||||
int is_toughmelee __P((struct ship *, struct ship *, int, int));
|
||||
void reload __P((void));
|
||||
void checksails __P((void));
|
||||
void moveall (void);
|
||||
void sendbp (struct ship *, struct ship *, int, int);
|
||||
int is_toughmelee (struct ship *, struct ship *, int, int);
|
||||
void reload (void);
|
||||
void checksails (void);
|
||||
|
||||
/* dr_4.c */
|
||||
void ungrap __P((struct ship *, struct ship *));
|
||||
void grap __P((struct ship *, struct ship *));
|
||||
void ungrap (struct ship *, struct ship *);
|
||||
void grap (struct ship *, struct ship *);
|
||||
|
||||
/* dr_5.c */
|
||||
void subtract __P((struct ship *, int, int [3], struct ship *, int));
|
||||
int mensent __P((struct ship *, struct ship *, int[3], struct ship **, int *,
|
||||
int));
|
||||
void subtract (struct ship *, struct ship *, int, int [3], int);
|
||||
int mensent (struct ship *, struct ship *, int[3], struct ship **, int *,
|
||||
int);
|
||||
|
||||
/* dr_main.c */
|
||||
int dr_main __P((void));
|
||||
int dr_main (void);
|
||||
|
||||
/* game.c */
|
||||
int maxturns __P((struct ship *, char *));
|
||||
int maxmove __P((struct ship *, int, int));
|
||||
int maxturns (struct ship *, char *);
|
||||
int maxmove (struct ship *, int, int);
|
||||
|
||||
/* lo_main.c */
|
||||
int lo_main __P((void));
|
||||
int lo_main (void);
|
||||
|
||||
/* misc.c */
|
||||
int range __P((struct ship *, struct ship *));
|
||||
struct ship *closestenemy __P((struct ship *, int, int));
|
||||
int angle __P((int, int));
|
||||
int gunsbear __P((struct ship *, struct ship *));
|
||||
int portside __P((struct ship *, struct ship *, int));
|
||||
int colours __P((struct ship *));
|
||||
void logger __P((struct ship *));
|
||||
int range (struct ship *, struct ship *);
|
||||
struct ship *closestenemy (struct ship *, int, int);
|
||||
int gunsbear (struct ship *, struct ship *);
|
||||
int portside (struct ship *, struct ship *, int);
|
||||
int colours (struct ship *);
|
||||
void logger (struct ship *);
|
||||
|
||||
/* parties.c */
|
||||
int meleeing __P((struct ship *, struct ship *));
|
||||
int boarding __P((struct ship *, int));
|
||||
void unboard __P((struct ship *, struct ship *, int));
|
||||
int meleeing (struct ship *, struct ship *);
|
||||
int boarding (struct ship *, int);
|
||||
void unboard (struct ship *, struct ship *, int);
|
||||
|
||||
/* pl_1.c */
|
||||
void leave __P((int)) __attribute__((__noreturn__));
|
||||
void choke __P((int)) __attribute__((__noreturn__));
|
||||
void child __P((int));
|
||||
void leave (int) __attribute__((__noreturn__));
|
||||
void choke (int) __attribute__((__noreturn__));
|
||||
void child (int);
|
||||
|
||||
/* pl_2.c */
|
||||
void play __P((void));
|
||||
void play (void) __attribute__((__noreturn__));
|
||||
|
||||
/* pl_3.c */
|
||||
void acceptcombat __P((void));
|
||||
void grapungrap __P((void));
|
||||
void unfoulplayer __P((void));
|
||||
void acceptcombat (void);
|
||||
void grapungrap (void);
|
||||
void unfoulplayer (void);
|
||||
|
||||
/* pl_4.c */
|
||||
void changesail __P((void));
|
||||
void acceptsignal __P((void));
|
||||
void lookout __P((void));
|
||||
char *saywhat __P((struct ship *, int));
|
||||
void eyeball __P((struct ship *));
|
||||
void changesail (void);
|
||||
void acceptsignal (void);
|
||||
void lookout (void);
|
||||
const char *saywhat (struct ship *, int);
|
||||
void eyeball (struct ship *);
|
||||
|
||||
/* pl_5.c */
|
||||
void acceptmove __P((void));
|
||||
void acceptboard __P((void));
|
||||
void parties __P((int[3], struct ship *, int, int));
|
||||
void acceptmove (void);
|
||||
void acceptboard (void);
|
||||
|
||||
/* pl_6.c */
|
||||
void repair __P((void));
|
||||
int turned __P((void));
|
||||
void loadplayer __P((void));
|
||||
void repair (void);
|
||||
void loadplayer (void);
|
||||
|
||||
/* pl_7.c */
|
||||
void initscreen __P((void));
|
||||
void cleanupscreen __P((void));
|
||||
void newturn __P((int));
|
||||
void Signal __P((const char *, struct ship *, ...))
|
||||
void initscreen (void);
|
||||
void cleanupscreen (void);
|
||||
void newturn (int);
|
||||
void Signal (const char *, struct ship *, ...)
|
||||
__attribute__((__format__(__printf__,1,3)));
|
||||
void Msg __P((const char *, ...))
|
||||
void Msg (const char *, ...)
|
||||
__attribute__((__format__(__printf__,1,2)));
|
||||
void Scroll __P((void));
|
||||
void prompt __P((char *, struct ship *));
|
||||
void endprompt __P((int));
|
||||
int sgetch __P((char *, struct ship *, int));
|
||||
void sgetstr __P((char *, char *, int));
|
||||
void draw_screen __P((void));
|
||||
void draw_view __P((void));
|
||||
void draw_turn __P((void));
|
||||
void draw_stat __P((void));
|
||||
void draw_slot __P((void));
|
||||
void draw_board __P((void));
|
||||
void centerview __P((void));
|
||||
void upview __P((void));
|
||||
void downview __P((void));
|
||||
void leftview __P((void));
|
||||
void rightview __P((void));
|
||||
void adjustview __P((void));
|
||||
void prompt (const char *, struct ship *);
|
||||
int sgetch (const char *, struct ship *, int);
|
||||
void sgetstr (const char *, char *, int);
|
||||
void draw_screen (void);
|
||||
void draw_view (void);
|
||||
void draw_turn (void);
|
||||
void draw_stat (void);
|
||||
void draw_slot (void);
|
||||
void draw_board (void);
|
||||
void centerview (void);
|
||||
void upview (void);
|
||||
void downview (void);
|
||||
void leftview (void);
|
||||
void rightview (void);
|
||||
|
||||
/* pl_main.c */
|
||||
int pl_main __P((void));
|
||||
void initialize __P((void));
|
||||
int pl_main (void);
|
||||
|
||||
/* sync.c */
|
||||
void fmtship __P((char *, size_t, const char *, struct ship *));
|
||||
void makesignal __P((struct ship *, const char *, struct ship *, ...))
|
||||
void fmtship (char *, size_t, const char *, struct ship *);
|
||||
void makesignal (struct ship *, const char *, struct ship *, ...)
|
||||
__attribute__((__format__(__printf__,2,4)));
|
||||
void makemsg __P((struct ship *, const char *, ...))
|
||||
void makemsg (struct ship *, const char *, ...)
|
||||
__attribute__((__format__(__printf__,2,3)));
|
||||
int sync_exists __P((int));
|
||||
int sync_open __P((void));
|
||||
void sync_close __P((int));
|
||||
void Write __P((int, struct ship *, int, long, long, long, long));
|
||||
int Sync __P((void));
|
||||
int sync_update __P((int, struct ship *, long, long, long, long));
|
||||
int sync_exists (int);
|
||||
int sync_open (void);
|
||||
void sync_close (int);
|
||||
void Write (int, struct ship *, long, long, long, long);
|
||||
void Writestr (int, struct ship *, const char *);
|
||||
int Sync (void);
|
||||
|
||||
16
sail/game.c
16
sail/game.c
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: game.c,v 1.5 1997/10/13 19:44:09 christos Exp $ */
|
||||
/* $NetBSD: game.c,v 1.10 2001/02/05 01:10:09 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
@@ -38,21 +38,21 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)game.c 8.2 (Berkeley) 4/28/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: game.c,v 1.5 1997/10/13 19:44:09 christos Exp $");
|
||||
__RCSID("$NetBSD: game.c,v 1.10 2001/02/05 01:10:09 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include "extern.h"
|
||||
|
||||
int
|
||||
maxturns(ship, af)
|
||||
struct ship *ship;
|
||||
char *af;
|
||||
maxturns(struct ship *ship, char *af)
|
||||
{
|
||||
int turns;
|
||||
|
||||
turns = ship->specs->ta;
|
||||
if ((*af = (ship->file->drift > 1 && turns)) != 0) {
|
||||
*af = (ship->file->drift > 1 && turns);
|
||||
if (*af != '\0') {
|
||||
turns--;
|
||||
if (ship->file->FS == 1)
|
||||
turns = 0;
|
||||
@@ -61,9 +61,7 @@ char *af;
|
||||
}
|
||||
|
||||
int
|
||||
maxmove(ship, dir, fs)
|
||||
struct ship *ship;
|
||||
int dir, fs;
|
||||
maxmove(struct ship *ship, int dir, int fs)
|
||||
{
|
||||
int riggone = 0, Move, flank = 0;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: globals.c,v 1.6 1997/10/13 19:44:17 christos Exp $ */
|
||||
/* $NetBSD: globals.c,v 1.12 2001/01/04 05:34:56 jwise Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
@@ -38,10 +38,12 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)globals.c 8.2 (Berkeley) 4/28/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: globals.c,v 1.6 1997/10/13 19:44:17 christos Exp $");
|
||||
__RCSID("$NetBSD: globals.c,v 1.12 2001/01/04 05:34:56 jwise Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <setjmp.h>
|
||||
#include "extern.h"
|
||||
|
||||
struct scenario scene[] = {
|
||||
@@ -406,7 +408,7 @@ struct shipspecs specs[] = {
|
||||
/* class qual crew2 gunL carL rig1 rig3 */
|
||||
};
|
||||
|
||||
struct windeffects WET[7][6] = {
|
||||
const struct windeffects WET[7][6] = {
|
||||
{ {9,9,9,9}, {9,9,9,9}, {9,9,9,9}, {9,9,9,9}, {9,9,9,9}, {9,9,9,9} },
|
||||
{ {3,2,2,0}, {3,2,1,0}, {3,2,1,0}, {3,2,1,0}, {2,1,0,0}, {2,1,0,0} },
|
||||
{ {1,1,1,0}, {1,1,0,0}, {1,0,0,0}, {1,0,0,0}, {1,0,0,0}, {1,0,0,0} },
|
||||
@@ -416,7 +418,7 @@ struct windeffects WET[7][6] = {
|
||||
{ {2,1,1,0}, {3,2,1,0}, {3,2,1,0}, {3,2,1,0}, {3,3,2,0}, {3,3,2,0} }
|
||||
};
|
||||
|
||||
struct Tables RigTable[11][6] = {
|
||||
const struct Tables RigTable[11][6] = {
|
||||
{ {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,1}, {0,0,1,0} },
|
||||
{ {0,0,0,0}, {0,0,0,0}, {0,0,0,1}, {0,0,1,0}, {1,0,0,1}, {0,1,1,1} },
|
||||
{ {0,0,0,0}, {0,0,0,1}, {0,0,1,1}, {0,1,0,1}, {0,1,0,1}, {1,0,1,2} },
|
||||
@@ -429,7 +431,7 @@ struct Tables RigTable[11][6] = {
|
||||
{ {1,1,0,4}, {1,0,1,4}, {2,0,0,5}, {0,2,1,5}, {0,1,2,6}, {0,2,0,7} },
|
||||
{ {1,0,1,5}, {0,2,0,6}, {1,2,0,6}, {1,1,1,6}, {2,0,2,6}, {1,1,2,7} }
|
||||
};
|
||||
struct Tables HullTable[11][6] = {
|
||||
const struct Tables HullTable[11][6] = {
|
||||
{ {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {1,0,0,0}, {0,1,0,0} },
|
||||
{ {0,0,0,0}, {0,0,0,0}, {0,1,0,0}, {1,1,0,0}, {1,0,1,0}, {1,0,1,1} },
|
||||
{ {0,1,0,0}, {1,0,0,0}, {1,1,0,0}, {1,0,1,0}, {1,0,1,1}, {2,1,0,0} },
|
||||
@@ -443,7 +445,7 @@ struct Tables HullTable[11][6] = {
|
||||
{ {2,2,4,0}, {3,3,1,1}, {4,2,1,1}, {5,1,0,2}, {5,1,2,1}, {6,2,2,0} },
|
||||
};
|
||||
|
||||
char AMMO[9][4] = {
|
||||
const char AMMO[9][4] = {
|
||||
{ -1, 1, 0, 1 },
|
||||
{ -1, 1, 0, 1 },
|
||||
{ -1, 1, 0, 1 },
|
||||
@@ -455,7 +457,7 @@ char AMMO[9][4] = {
|
||||
{ -3, 2, 0, 3 }
|
||||
};
|
||||
|
||||
char HDT[9][10] = {
|
||||
const char HDT[9][10] = {
|
||||
{ 1, 0,-1,-2,-3,-3,-4,-4,-4,-4 },
|
||||
{ 1, 1, 0,-1,-2,-2,-3,-3,-3,-3 },
|
||||
{ 2, 1, 0,-1,-2,-2,-3,-3,-3,-3 },
|
||||
@@ -467,7 +469,7 @@ char HDT[9][10] = {
|
||||
{ 5, 4, 3, 2, 1, 1, 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
char HDTrake[9][10] = {
|
||||
const char HDTrake[9][10] = {
|
||||
{ 2, 1, 0,-1,-2,-2,-3,-3,-3,-3 },
|
||||
{ 2, 2, 1, 0,-1,-1,-2,-2,-2,-2 },
|
||||
{ 3, 2, 1, 0,-1,-1,-2,-2,-2,-2 },
|
||||
@@ -479,7 +481,7 @@ char HDTrake[9][10] = {
|
||||
{ 9, 8, 7, 6, 5, 5, 4, 4, 4, 4 }
|
||||
};
|
||||
|
||||
char QUAL[9][5] = {
|
||||
const char QUAL[9][5] = {
|
||||
{ -1, 0, 0, 1, 1 },
|
||||
{ -1, 0, 0, 1, 1 },
|
||||
{ -1, 0, 0, 1, 2 },
|
||||
@@ -491,7 +493,7 @@ char QUAL[9][5] = {
|
||||
{ -2,-1, 0, 2, 3 }
|
||||
};
|
||||
|
||||
char MT[9][3] = {
|
||||
const char MT[9][3] = {
|
||||
{ 1, 0, 0 },
|
||||
{ 1, 1, 0 },
|
||||
{ 2, 1, 0 },
|
||||
@@ -503,7 +505,7 @@ char MT[9][3] = {
|
||||
{ 4, 4, 2 }
|
||||
};
|
||||
|
||||
char rangeofshot[] = {
|
||||
const char rangeofshot[] = {
|
||||
0,
|
||||
1, /* grape */
|
||||
3, /* chain */
|
||||
@@ -511,12 +513,12 @@ char rangeofshot[] = {
|
||||
1 /* double */
|
||||
};
|
||||
|
||||
char *countryname[] = {
|
||||
const char *const countryname[] = {
|
||||
"American", "British", "Spanish", "French", "Japanese",
|
||||
"Federation", "Klingon", "Orion"
|
||||
};
|
||||
|
||||
char *classname[] = {
|
||||
const char *const classname[] = {
|
||||
"Drift wood",
|
||||
"Ship of the Line",
|
||||
"Ship of the Line",
|
||||
@@ -526,7 +528,7 @@ char *classname[] = {
|
||||
"Brig"
|
||||
};
|
||||
|
||||
char *directionname[] = {
|
||||
const char *const directionname[] = {
|
||||
"dead ahead",
|
||||
"off the starboard bow",
|
||||
"off the starboard beam",
|
||||
@@ -538,9 +540,30 @@ char *directionname[] = {
|
||||
"dead ahead"
|
||||
};
|
||||
|
||||
char *qualname[] = { "dead", "mutinous", "green", "mundane", "crack", "elite" };
|
||||
const char *const qualname[] = { "dead", "mutinous", "green", "mundane", "crack", "elite" };
|
||||
|
||||
char loadname[] = { '-', 'G', 'C', 'R', 'D', 'E' };
|
||||
const char loadname[] = { '-', 'G', 'C', 'R', 'D', 'E' };
|
||||
|
||||
char dr[] = { 0, 1, 1, 0, -1, -1, -1, 0, 1 };
|
||||
char dc[] = { 0, 0, -1, -1, -1, 0, 1, 1, 1 };
|
||||
const char dr[] = { 0, 1, 1, 0, -1, -1, -1, 0, 1 };
|
||||
const char dc[] = { 0, 0, -1, -1, -1, 0, 1, 1, 1 };
|
||||
|
||||
int mode;
|
||||
jmp_buf restart;
|
||||
|
||||
int randomize; /* -x, give first available ship */
|
||||
int longfmt; /* -l, print score in long format */
|
||||
int nobells; /* -b, don't ring bell before Signal */
|
||||
|
||||
gid_t gid;
|
||||
gid_t egid;
|
||||
|
||||
struct scenario *cc; /* the current scenario */
|
||||
struct ship *ls; /* &cc->ship[cc->vessels] */
|
||||
|
||||
int winddir;
|
||||
int windspeed;
|
||||
int turn;
|
||||
int game;
|
||||
int alive;
|
||||
int people;
|
||||
int hasdriver;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: lo_main.c,v 1.5 1997/10/13 19:44:24 christos Exp $ */
|
||||
/* $NetBSD: lo_main.c,v 1.11 2001/02/05 01:10:10 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
@@ -38,7 +38,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)lo_main.c 8.2 (Berkeley) 4/28/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: lo_main.c,v 1.5 1997/10/13 19:44:24 christos Exp $");
|
||||
__RCSID("$NetBSD: lo_main.c,v 1.11 2001/02/05 01:10:10 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -47,19 +47,21 @@ __RCSID("$NetBSD: lo_main.c,v 1.5 1997/10/13 19:44:24 christos Exp $");
|
||||
*
|
||||
* -l force a long listing (print out real usernames)
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <pwd.h>
|
||||
#include "extern.h"
|
||||
#include "pathnames.h"
|
||||
|
||||
char *title[] = {
|
||||
const char *const title[] = {
|
||||
"Admiral", "Commodore", "Captain", "Captain",
|
||||
"Captain", "Captain", "Captain", "Commander",
|
||||
"Commander", "Lieutenant"
|
||||
};
|
||||
|
||||
int
|
||||
lo_main()
|
||||
lo_main(void)
|
||||
{
|
||||
FILE *fp;
|
||||
char sbuf[32];
|
||||
@@ -85,10 +87,9 @@ lo_main()
|
||||
while (fread((char *)&log, sizeof log, 1, fp) == 1 &&
|
||||
log.l_name[0] != '\0') {
|
||||
if (longfmt && (pass = getpwuid(log.l_uid)) != NULL)
|
||||
(void) sprintf(sbuf, "%10.10s (%s)",
|
||||
log.l_name, pass->pw_name);
|
||||
sprintf(sbuf, "%10.10s (%s)", log.l_name, pass->pw_name);
|
||||
else
|
||||
(void) sprintf(sbuf, "%20.20s", log.l_name);
|
||||
sprintf(sbuf, "%20.20s", log.l_name);
|
||||
ship = &scene[log.l_gamenum].ship[log.l_shipnum];
|
||||
printf("%-10s %21s of the %15s %3d points, %5.2f equiv\n",
|
||||
title[n++], sbuf, ship->shipname, log.l_netpoints,
|
||||
|
||||
46
sail/main.c
46
sail/main.c
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: main.c,v 1.6 1997/10/13 21:03:55 christos Exp $ */
|
||||
/* $NetBSD: main.c,v 1.20 2001/08/29 18:23:44 jsm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
@@ -43,52 +43,58 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1993\n\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)main.c 8.2 (Berkeley) 4/28/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: main.c,v 1.6 1997/10/13 21:03:55 christos Exp $");
|
||||
__RCSID("$NetBSD: main.c,v 1.20 2001/08/29 18:23:44 jsm Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include "extern.h"
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <setjmp.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include "extern.h"
|
||||
#include "restart.h"
|
||||
|
||||
int main __P((int, char **));
|
||||
|
||||
/*ARGSUSED*/
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc __attribute__((unused));
|
||||
char **argv;
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
char *p;
|
||||
int i;
|
||||
int a,i;
|
||||
int fd;
|
||||
|
||||
gid = getgid();
|
||||
egid = getegid();
|
||||
setegid(gid);
|
||||
|
||||
(void) srand(getpid());
|
||||
fd = open("/dev/null", O_RDONLY);
|
||||
if (fd < 3)
|
||||
exit(1);
|
||||
close(fd);
|
||||
|
||||
srandom((u_long)time(NULL));
|
||||
|
||||
if ((p = strrchr(*argv, '/')) != NULL)
|
||||
p++;
|
||||
else
|
||||
p = *argv;
|
||||
|
||||
if (strcmp(p, "driver") == 0 || strcmp(p, "saildriver") == 0)
|
||||
mode = MODE_DRIVER;
|
||||
else if (strcmp(p, "sail.log") == 0)
|
||||
mode = MODE_LOGGER;
|
||||
else
|
||||
mode = MODE_PLAYER;
|
||||
while ((p = *++argv) && *p == '-')
|
||||
switch (p[1]) {
|
||||
|
||||
while ((a = getopt(argc, argv, "dsxlb")) != -1)
|
||||
switch (a) {
|
||||
case 'd':
|
||||
mode = MODE_DRIVER;
|
||||
break;
|
||||
case 's':
|
||||
mode = MODE_LOGGER;
|
||||
break;
|
||||
case 'D':
|
||||
debug++;
|
||||
break;
|
||||
case 'x':
|
||||
randomize++;
|
||||
break;
|
||||
@@ -102,12 +108,18 @@ main(argc, argv)
|
||||
fprintf(stderr, "SAIL: Unknown flag %s.\n", p);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if (*argv)
|
||||
game = atoi(*argv);
|
||||
else
|
||||
game = -1;
|
||||
|
||||
if ((i = setjmp(restart)) != 0)
|
||||
mode = i;
|
||||
|
||||
switch (mode) {
|
||||
case MODE_PLAYER:
|
||||
return pl_main();
|
||||
|
||||
60
sail/misc.c
60
sail/misc.c
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: misc.c,v 1.5 1997/10/13 19:44:38 christos Exp $ */
|
||||
/* $NetBSD: misc.c,v 1.12 2001/02/05 01:10:10 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
@@ -38,23 +38,26 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)misc.c 8.2 (Berkeley) 4/28/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: misc.c,v 1.5 1997/10/13 19:44:38 christos Exp $");
|
||||
__RCSID("$NetBSD: misc.c,v 1.12 2001/02/05 01:10:10 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/file.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "extern.h"
|
||||
#include "pathnames.h"
|
||||
|
||||
#define distance(x,y) (abs(x) >= abs(y) ? abs(x) + abs(y)/2 : abs(y) + abs(x)/2)
|
||||
|
||||
static int angle(int, int);
|
||||
|
||||
/* XXX */
|
||||
int
|
||||
range(from, to)
|
||||
struct ship *from, *to;
|
||||
range(struct ship *from, struct ship *to)
|
||||
{
|
||||
int bow1r, bow1c, bow2r, bow2c;
|
||||
int stern1r, stern1c, stern2c, stern2r;
|
||||
@@ -81,9 +84,7 @@ struct ship *from, *to;
|
||||
}
|
||||
|
||||
struct ship *
|
||||
closestenemy(from, side, anyship)
|
||||
struct ship *from;
|
||||
char side, anyship;
|
||||
closestenemy(struct ship *from, int side, int anyship)
|
||||
{
|
||||
struct ship *sp;
|
||||
char a;
|
||||
@@ -109,9 +110,8 @@ char side, anyship;
|
||||
return closest;
|
||||
}
|
||||
|
||||
int
|
||||
angle(dr, dc)
|
||||
int dr, dc;
|
||||
static int
|
||||
angle(int dr, int dc)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -137,9 +137,9 @@ int dr, dc;
|
||||
return i % 8 + 1;
|
||||
}
|
||||
|
||||
/* checks for target bow or stern */
|
||||
int
|
||||
gunsbear(from, to) /* checks for target bow or stern */
|
||||
struct ship *from, *to;
|
||||
gunsbear(struct ship *from, struct ship *to)
|
||||
{
|
||||
int Dr, Dc, i;
|
||||
int ang;
|
||||
@@ -159,11 +159,10 @@ struct ship *from, *to;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* returns true if fromship is shooting at onship's starboard side */
|
||||
int
|
||||
portside(from, on, quick)
|
||||
struct ship *from, *on;
|
||||
int quick; /* returns true if fromship is */
|
||||
{ /* shooting at onship's starboard side */
|
||||
portside(struct ship *from, struct ship *on, int quick)
|
||||
{
|
||||
int ang;
|
||||
int Dr, Dc;
|
||||
|
||||
@@ -181,8 +180,7 @@ int quick; /* returns true if fromship is */
|
||||
}
|
||||
|
||||
int
|
||||
colours(sp)
|
||||
struct ship *sp;
|
||||
colours(struct ship *sp)
|
||||
{
|
||||
char flag = '\0';
|
||||
|
||||
@@ -199,8 +197,7 @@ struct ship *sp;
|
||||
}
|
||||
|
||||
void
|
||||
logger(s)
|
||||
struct ship *s;
|
||||
logger(struct ship *s)
|
||||
{
|
||||
FILE *fp;
|
||||
int persons;
|
||||
@@ -227,27 +224,24 @@ struct ship *s;
|
||||
= lp->l_gamenum = lp->l_netpoints = 0;
|
||||
rewind(fp);
|
||||
if (persons < 0)
|
||||
(void) putw(1, fp);
|
||||
putw(1, fp);
|
||||
else
|
||||
(void) putw(persons + 1, fp);
|
||||
putw(persons + 1, fp);
|
||||
for (lp = log; lp < &log[NLOG]; lp++)
|
||||
if (net > (float)lp->l_netpoints
|
||||
/ scene[lp->l_gamenum].ship[lp->l_shipnum].specs->pts) {
|
||||
(void) fwrite((char *)log,
|
||||
sizeof (struct logs), lp - log, fp);
|
||||
(void) strcpy(log[NLOG-1].l_name, s->file->captain);
|
||||
fwrite((char *)log, sizeof (struct logs), lp - log, fp);
|
||||
strcpy(log[NLOG-1].l_name, s->file->captain);
|
||||
log[NLOG-1].l_uid = getuid();
|
||||
log[NLOG-1].l_shipnum = s->file->index;
|
||||
log[NLOG-1].l_gamenum = game;
|
||||
log[NLOG-1].l_netpoints = s->file->points;
|
||||
(void) fwrite((char *)&log[NLOG-1],
|
||||
sizeof (struct logs), 1, fp);
|
||||
(void) fwrite((char *)lp,
|
||||
sizeof (struct logs), &log[NLOG-1] - lp, fp);
|
||||
fwrite((char *)&log[NLOG-1], sizeof (struct logs), 1, fp);
|
||||
fwrite((char *)lp, sizeof (struct logs), &log[NLOG-1] - lp, fp);
|
||||
break;
|
||||
}
|
||||
#ifdef LOCK_EX
|
||||
(void) flock(fileno(fp), LOCK_UN);
|
||||
flock(fileno(fp), LOCK_UN);
|
||||
#endif
|
||||
(void) fclose(fp);
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: parties.c,v 1.5 1997/10/13 19:44:47 christos Exp $ */
|
||||
/* $NetBSD: parties.c,v 1.10 2001/02/05 01:10:10 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
@@ -38,16 +38,15 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)parties.c 8.2 (Berkeley) 4/28/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: parties.c,v 1.5 1997/10/13 19:44:47 christos Exp $");
|
||||
__RCSID("$NetBSD: parties.c,v 1.10 2001/02/05 01:10:10 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include "extern.h"
|
||||
|
||||
int
|
||||
meleeing(from, to)
|
||||
struct ship *from;
|
||||
struct ship *to;
|
||||
meleeing(struct ship *from, struct ship *to)
|
||||
{
|
||||
struct BP *p = from->file->OBP;
|
||||
struct BP *q = p + NBP;
|
||||
@@ -59,9 +58,7 @@ struct ship *to;
|
||||
}
|
||||
|
||||
int
|
||||
boarding(from, isdefense)
|
||||
struct ship *from;
|
||||
char isdefense;
|
||||
boarding(struct ship *from, int isdefense)
|
||||
{
|
||||
struct BP *p = isdefense ? from->file->DBP : from->file->OBP;
|
||||
struct BP *q = p + NBP;
|
||||
@@ -73,14 +70,12 @@ char isdefense;
|
||||
}
|
||||
|
||||
void
|
||||
unboard(ship, to, isdefense)
|
||||
struct ship *ship, *to;
|
||||
char isdefense;
|
||||
unboard(struct ship *ship, struct ship *to, int isdefense)
|
||||
{
|
||||
struct BP *p = isdefense ? ship->file->DBP : ship->file->OBP;
|
||||
int n;
|
||||
|
||||
for (n = 0; n < NBP; p++, n++)
|
||||
if (p->turnsent && (p->toship == to || isdefense || ship == to))
|
||||
Write(isdefense ? W_DBP : W_OBP, ship, 0, n, 0, 0, 0);
|
||||
Write(isdefense ? W_DBP : W_OBP, ship, n, 0, 0, 0);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pathnames.h,v 1.3 1995/04/22 10:37:06 cgd Exp $ */
|
||||
/* $NetBSD: pathnames.h,v 1.4 2000/02/09 22:27:56 jsm Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
@@ -36,5 +36,5 @@
|
||||
*/
|
||||
|
||||
#define _PATH_LOGFILE "@sail_scorefile@"
|
||||
#define _PATH_SYNC "@sail_dir@/#sailsink.%d"
|
||||
#define _PATH_LOCK "@sail_dir@/#saillock.%d"
|
||||
#define _PATH_SYNC "@sail_dir@/#sailsink.%d"
|
||||
#define _PATH_LOCK "@sail_dir@/#saillock.%d"
|
||||
|
||||
37
sail/pl_1.c
37
sail/pl_1.c
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pl_1.c,v 1.5 1997/10/13 21:04:02 christos Exp $ */
|
||||
/* $NetBSD: pl_1.c,v 1.16 2001/02/05 01:10:10 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
@@ -38,14 +38,18 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)pl_1.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: pl_1.c,v 1.5 1997/10/13 21:04:02 christos Exp $");
|
||||
__RCSID("$NetBSD: pl_1.c,v 1.16 2001/02/05 01:10:10 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include "player.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "extern.h"
|
||||
#include "player.h"
|
||||
|
||||
/*
|
||||
* If we get here before a ship is chosen, then ms == 0 and
|
||||
@@ -56,14 +60,13 @@ __RCSID("$NetBSD: pl_1.c,v 1.5 1997/10/13 21:04:02 christos Exp $");
|
||||
* because of a Sync() failure.
|
||||
*/
|
||||
void
|
||||
leave(conditions)
|
||||
int conditions;
|
||||
leave(int conditions)
|
||||
{
|
||||
(void) signal(SIGHUP, SIG_IGN);
|
||||
(void) signal(SIGINT, SIG_IGN);
|
||||
(void) signal(SIGQUIT, SIG_IGN);
|
||||
(void) signal(SIGALRM, SIG_IGN);
|
||||
(void) signal(SIGCHLD, SIG_IGN);
|
||||
signal(SIGHUP, SIG_IGN);
|
||||
signal(SIGINT, SIG_IGN);
|
||||
signal(SIGQUIT, SIG_IGN);
|
||||
signal(SIGALRM, SIG_IGN);
|
||||
signal(SIGCHLD, SIG_IGN);
|
||||
|
||||
if (done_curses) {
|
||||
Msg("It looks like you've had it!");
|
||||
@@ -109,8 +112,8 @@ int conditions;
|
||||
if (conditions != LEAVE_SYNC) {
|
||||
makemsg(ms, "Captain %s relinquishing.",
|
||||
mf->captain);
|
||||
Write(W_END, ms, 0, 0, 0, 0, 0);
|
||||
(void) Sync();
|
||||
Write(W_END, ms, 0, 0, 0, 0);
|
||||
Sync();
|
||||
}
|
||||
}
|
||||
sync_close(!hasdriver);
|
||||
@@ -121,25 +124,23 @@ int conditions;
|
||||
|
||||
/*ARGSUSED*/
|
||||
void
|
||||
choke(n)
|
||||
int n __attribute__((unused));
|
||||
choke(int n __attribute__((__unused__)))
|
||||
{
|
||||
leave(LEAVE_QUIT);
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
void
|
||||
child(n)
|
||||
int n __attribute__((unused));
|
||||
child(int n __attribute__((__unused__)))
|
||||
{
|
||||
union wait status;
|
||||
int pid;
|
||||
|
||||
(void) signal(SIGCHLD, SIG_IGN);
|
||||
signal(SIGCHLD, SIG_IGN);
|
||||
do {
|
||||
pid = wait3((int *)&status, WNOHANG, (struct rusage *)0);
|
||||
if (pid < 0 || (pid > 0 && !WIFSTOPPED(status)))
|
||||
hasdriver = 0;
|
||||
} while (pid > 0);
|
||||
(void) signal(SIGCHLD, child);
|
||||
signal(SIGCHLD, child);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pl_2.c,v 1.4 1997/10/13 19:45:01 christos Exp $ */
|
||||
/* $NetBSD: pl_2.c,v 1.10 2001/02/05 01:10:10 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
@@ -38,14 +38,16 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)pl_2.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: pl_2.c,v 1.4 1997/10/13 19:45:01 christos Exp $");
|
||||
__RCSID("$NetBSD: pl_2.c,v 1.10 2001/02/05 01:10:10 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include <signal.h>
|
||||
#include "extern.h"
|
||||
#include "player.h"
|
||||
|
||||
void
|
||||
play()
|
||||
play(void)
|
||||
{
|
||||
struct ship *sp;
|
||||
|
||||
|
||||
30
sail/pl_3.c
30
sail/pl_3.c
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pl_3.c,v 1.6 1998/08/30 09:19:40 veego Exp $ */
|
||||
/* $NetBSD: pl_3.c,v 1.16 2001/02/05 01:10:10 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
@@ -38,15 +38,17 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)pl_3.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: pl_3.c,v 1.6 1998/08/30 09:19:40 veego Exp $");
|
||||
__RCSID("$NetBSD: pl_3.c,v 1.16 2001/02/05 01:10:10 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include "player.h"
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include "extern.h"
|
||||
#include "player.h"
|
||||
|
||||
void
|
||||
acceptcombat()
|
||||
acceptcombat(void)
|
||||
{
|
||||
int men = 0;
|
||||
int target, temp;
|
||||
@@ -177,11 +179,11 @@ acceptcombat()
|
||||
if (windspeed == 6 && temp <= 3)
|
||||
hit--;
|
||||
if (hit >= 0) {
|
||||
roll = die();
|
||||
roll = dieroll();
|
||||
if (load == L_GRAPE)
|
||||
chits = hit;
|
||||
else {
|
||||
struct Tables *t;
|
||||
const struct Tables *t;
|
||||
if (hit > 10)
|
||||
hit = 10;
|
||||
t = &(shootat == RIGGING ? RigTable : HullTable)
|
||||
@@ -197,7 +199,7 @@ acceptcombat()
|
||||
hhits = 0;
|
||||
}
|
||||
}
|
||||
table(shootat, load, hit, closest, ms, roll);
|
||||
table(ms, closest, shootat, load, hit, roll);
|
||||
}
|
||||
Msg("Damage inflicted on the %s:", closest->shipname);
|
||||
Msg("\t%d HULL, %d GUNS, %d CREW, %d RIGGING",
|
||||
@@ -219,7 +221,7 @@ acceptcombat()
|
||||
}
|
||||
|
||||
void
|
||||
grapungrap()
|
||||
grapungrap(void)
|
||||
{
|
||||
struct ship *sp;
|
||||
int i;
|
||||
@@ -232,10 +234,10 @@ grapungrap()
|
||||
switch (sgetch("Attempt to grapple or ungrapple $$: ",
|
||||
sp, 1)) {
|
||||
case 'g':
|
||||
if (die() < 3
|
||||
if (dieroll() < 3
|
||||
|| ms->nationality == capship(sp)->nationality) {
|
||||
Write(W_GRAP, ms, 0, sp->file->index, 0, 0, 0);
|
||||
Write(W_GRAP, sp, 0, player, 0, 0, 0);
|
||||
Write(W_GRAP, ms, sp->file->index, 0, 0, 0);
|
||||
Write(W_GRAP, sp, player, 0, 0, 0);
|
||||
Msg("Attempt succeeds!");
|
||||
makesignal(ms, "grappled with $$", sp);
|
||||
} else
|
||||
@@ -245,7 +247,7 @@ grapungrap()
|
||||
for (i = grappled2(ms, sp); --i >= 0;) {
|
||||
if (ms->nationality
|
||||
== capship(sp)->nationality
|
||||
|| die() < 3) {
|
||||
|| dieroll() < 3) {
|
||||
cleangrapple(ms, sp, 0);
|
||||
Msg("Attempt succeeds!");
|
||||
makesignal(ms, "ungrappling with $$",
|
||||
@@ -259,7 +261,7 @@ grapungrap()
|
||||
}
|
||||
|
||||
void
|
||||
unfoulplayer()
|
||||
unfoulplayer(void)
|
||||
{
|
||||
struct ship *to;
|
||||
int i;
|
||||
@@ -270,7 +272,7 @@ unfoulplayer()
|
||||
if (sgetch("Attempt to unfoul with the $$? ", to, 1) != 'y')
|
||||
continue;
|
||||
for (i = fouled2(ms, to); --i >= 0;) {
|
||||
if (die() <= 2) {
|
||||
if (dieroll() <= 2) {
|
||||
cleanfoul(ms, to, 0);
|
||||
Msg("Attempt succeeds!");
|
||||
makesignal(ms, "Unfouling $$", to);
|
||||
|
||||
28
sail/pl_4.c
28
sail/pl_4.c
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pl_4.c,v 1.6 1997/10/13 21:04:17 christos Exp $ */
|
||||
/* $NetBSD: pl_4.c,v 1.13 2001/02/05 01:10:11 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
@@ -38,14 +38,17 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)pl_4.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: pl_4.c,v 1.6 1997/10/13 21:04:17 christos Exp $");
|
||||
__RCSID("$NetBSD: pl_4.c,v 1.13 2001/02/05 01:10:11 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <ctype.h>
|
||||
#include "extern.h"
|
||||
#include "player.h"
|
||||
|
||||
void
|
||||
changesail()
|
||||
changesail(void)
|
||||
{
|
||||
int rig, full;
|
||||
|
||||
@@ -58,12 +61,12 @@ changesail()
|
||||
if (sgetch("Increase to Full sails? ",
|
||||
(struct ship *)0, 1) == 'y') {
|
||||
changed = 1;
|
||||
Write(W_FS, ms, 0, 1, 0, 0, 0);
|
||||
Write(W_FS, ms, 1, 0, 0, 0);
|
||||
}
|
||||
} else {
|
||||
if (sgetch("Reduce to Battle sails? ",
|
||||
(struct ship *)0, 1) == 'y') {
|
||||
Write(W_FS, ms, 0, 0, 0, 0, 0);
|
||||
Write(W_FS, ms, 0, 0, 0, 0);
|
||||
changed = 1;
|
||||
}
|
||||
}
|
||||
@@ -72,7 +75,7 @@ changesail()
|
||||
}
|
||||
|
||||
void
|
||||
acceptsignal()
|
||||
acceptsignal(void)
|
||||
{
|
||||
char buf[60];
|
||||
char *p = buf;
|
||||
@@ -83,11 +86,11 @@ acceptsignal()
|
||||
;
|
||||
p[-1] = '"';
|
||||
*p = 0;
|
||||
Write(W_SIGNAL, ms, 1, (long)buf, 0, 0, 0);
|
||||
Writestr(W_SIGNAL, ms, buf);
|
||||
}
|
||||
|
||||
void
|
||||
lookout()
|
||||
lookout(void)
|
||||
{
|
||||
struct ship *sp;
|
||||
char buf[3];
|
||||
@@ -104,10 +107,8 @@ lookout()
|
||||
}
|
||||
}
|
||||
|
||||
char *
|
||||
saywhat(sp, flag)
|
||||
struct ship *sp;
|
||||
char flag;
|
||||
const char *
|
||||
saywhat(struct ship *sp, int flag)
|
||||
{
|
||||
if (sp->file->captain[0])
|
||||
return sp->file->captain;
|
||||
@@ -122,8 +123,7 @@ char flag;
|
||||
}
|
||||
|
||||
void
|
||||
eyeball(ship)
|
||||
struct ship *ship;
|
||||
eyeball(struct ship *ship)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
63
sail/pl_5.c
63
sail/pl_5.c
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pl_5.c,v 1.6 1997/10/13 21:04:24 christos Exp $ */
|
||||
/* $NetBSD: pl_5.c,v 1.15 2001/02/05 01:10:11 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
@@ -38,16 +38,25 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)pl_5.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: pl_5.c,v 1.6 1997/10/13 21:04:24 christos Exp $");
|
||||
__RCSID("$NetBSD: pl_5.c,v 1.15 2001/02/05 01:10:11 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include <ctype.h>
|
||||
#include <curses.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "extern.h"
|
||||
#include "player.h"
|
||||
#include "display.h"
|
||||
|
||||
#define turnfirst(x) (*x == 'r' || *x == 'l')
|
||||
|
||||
static void parties(struct ship *, int *, int, int);
|
||||
|
||||
void
|
||||
acceptmove()
|
||||
acceptmove(void)
|
||||
{
|
||||
int ta;
|
||||
int ma;
|
||||
@@ -65,7 +74,7 @@ acceptmove()
|
||||
|
||||
ta = maxturns(ms, &af);
|
||||
ma = maxmove(ms, mf->dir, 0);
|
||||
(void) sprintf(prompt, "move (%d,%c%d): ", ma, af ? '\'' : ' ', ta);
|
||||
sprintf(prompt, "move (%d,%c%d): ", ma, af ? '\'' : ' ', ta);
|
||||
sgetstr(prompt, buf, sizeof buf);
|
||||
dir = mf->dir;
|
||||
vma = ma;
|
||||
@@ -127,7 +136,7 @@ acceptmove()
|
||||
Msg("Movement error.");
|
||||
if (ta < 0 && moved) {
|
||||
if (mf->FS == 1) {
|
||||
Write(W_FS, ms, 0, 0, 0, 0, 0);
|
||||
Write(W_FS, ms, 0, 0, 0, 0);
|
||||
Msg("No hands to set full sails.");
|
||||
}
|
||||
} else if (ma >= 0)
|
||||
@@ -135,20 +144,20 @@ acceptmove()
|
||||
}
|
||||
if (af && !moved) {
|
||||
if (mf->FS == 1) {
|
||||
Write(W_FS, ms, 0, 0, 0, 0, 0);
|
||||
Write(W_FS, ms, 0, 0, 0, 0);
|
||||
Msg("No hands to set full sails.");
|
||||
}
|
||||
}
|
||||
if (*buf)
|
||||
(void) strcpy(movebuf, buf);
|
||||
strcpy(movebuf, buf);
|
||||
else
|
||||
(void) strcpy(movebuf, "d");
|
||||
Write(W_MOVE, ms, 1, (long)movebuf, 0, 0, 0);
|
||||
strcpy(movebuf, "d");
|
||||
Writestr(W_MOVE, ms, movebuf);
|
||||
Msg("Helm: %s.", movebuf);
|
||||
}
|
||||
|
||||
void
|
||||
acceptboard()
|
||||
acceptboard(void)
|
||||
{
|
||||
struct ship *sp;
|
||||
int n;
|
||||
@@ -184,28 +193,24 @@ acceptboard()
|
||||
if (meleeing(ms, sp) && crew[2]) {
|
||||
c = sgetch("How many more to board the $$? ",
|
||||
sp, 1);
|
||||
parties(crew, sp, 0, c);
|
||||
parties(sp, crew, 0, c);
|
||||
} else if ((fouled2(ms, sp) || grappled2(ms, sp)) && crew[2]) {
|
||||
c = sgetch("Crew sections to board the $$ (3 max) ?", sp, 1);
|
||||
parties(crew, sp, 0, c);
|
||||
parties(sp, crew, 0, c);
|
||||
}
|
||||
}
|
||||
if (crew[2]) {
|
||||
c = sgetch("How many sections to repel boarders? ",
|
||||
(struct ship *)0, 1);
|
||||
parties(crew, ms, 1, c);
|
||||
parties(ms, crew, 1, c);
|
||||
}
|
||||
blockalarm();
|
||||
draw_slot();
|
||||
unblockalarm();
|
||||
}
|
||||
|
||||
void
|
||||
parties(crew, to, isdefense, buf)
|
||||
struct ship *to;
|
||||
int crew[3];
|
||||
char isdefense;
|
||||
char buf;
|
||||
static void
|
||||
parties(struct ship *to, int *crew, int isdefense, int buf)
|
||||
{
|
||||
int k, j, men;
|
||||
struct BP *ptr;
|
||||
@@ -228,29 +233,29 @@ char buf;
|
||||
}
|
||||
if (buf > '0')
|
||||
Msg("Sending all crew sections.");
|
||||
Write(isdefense ? W_DBP : W_OBP, ms, 0,
|
||||
Write(isdefense ? W_DBP : W_OBP, ms,
|
||||
j, turn, to->file->index, men);
|
||||
if (isdefense) {
|
||||
(void) wmove(slot_w, 2, 0);
|
||||
wmove(slot_w, 2, 0);
|
||||
for (k=0; k < NBP; k++)
|
||||
if (temp[k] && !crew[k])
|
||||
(void) waddch(slot_w, k + '1');
|
||||
waddch(slot_w, k + '1');
|
||||
else
|
||||
(void) wmove(slot_w, 2, 1 + k);
|
||||
(void) mvwaddstr(slot_w, 3, 0, "DBP");
|
||||
wmove(slot_w, 2, 1 + k);
|
||||
mvwaddstr(slot_w, 3, 0, "DBP");
|
||||
makemsg(ms, "repelling boarders");
|
||||
} else {
|
||||
(void) wmove(slot_w, 0, 0);
|
||||
wmove(slot_w, 0, 0);
|
||||
for (k=0; k < NBP; k++)
|
||||
if (temp[k] && !crew[k])
|
||||
(void) waddch(slot_w, k + '1');
|
||||
waddch(slot_w, k + '1');
|
||||
else
|
||||
(void) wmove(slot_w, 0, 1 + k);
|
||||
(void) mvwaddstr(slot_w, 1, 0, "OBP");
|
||||
wmove(slot_w, 0, 1 + k);
|
||||
mvwaddstr(slot_w, 1, 0, "OBP");
|
||||
makesignal(ms, "boarding the $$", to);
|
||||
}
|
||||
blockalarm();
|
||||
(void) wrefresh(slot_w);
|
||||
wrefresh(slot_w);
|
||||
unblockalarm();
|
||||
} else
|
||||
Msg("Sending no crew sections.");
|
||||
|
||||
30
sail/pl_6.c
30
sail/pl_6.c
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pl_6.c,v 1.4 1997/10/13 19:45:33 christos Exp $ */
|
||||
/* $NetBSD: pl_6.c,v 1.10 2001/02/05 01:10:11 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
@@ -38,14 +38,18 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)pl_6.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: pl_6.c,v 1.4 1997/10/13 19:45:33 christos Exp $");
|
||||
__RCSID("$NetBSD: pl_6.c,v 1.10 2001/02/05 01:10:11 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include <signal.h>
|
||||
#include "extern.h"
|
||||
#include "player.h"
|
||||
|
||||
static int turned(void);
|
||||
|
||||
void
|
||||
repair()
|
||||
repair(void)
|
||||
{
|
||||
char c;
|
||||
char *repairs;
|
||||
@@ -81,7 +85,7 @@ repair()
|
||||
int max = ptr->guns/4;
|
||||
if (ptr->hull < max) {
|
||||
FIX(hull, max);
|
||||
Write(W_HULL, ms, 0, ptr->hull, 0, 0, 0);
|
||||
Write(W_HULL, ms, ptr->hull, 0, 0, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -90,14 +94,14 @@ repair()
|
||||
int max = ptr->guns/5 - ptr->carL;
|
||||
if (ptr->gunL < max) {
|
||||
FIX(gunL, max);
|
||||
Write(W_GUNL, ms, 0, ptr->gunL,
|
||||
Write(W_GUNL, ms, ptr->gunL,
|
||||
ptr->carL, 0, 0);
|
||||
}
|
||||
} else {
|
||||
int max = ptr->guns/5 - ptr->carR;
|
||||
if (ptr->gunR < max) {
|
||||
FIX(gunR, max);
|
||||
Write(W_GUNR, ms, 0, ptr->gunR,
|
||||
Write(W_GUNR, ms, ptr->gunR,
|
||||
ptr->carR, 0, 0);
|
||||
}
|
||||
}
|
||||
@@ -106,19 +110,19 @@ repair()
|
||||
#define X 2
|
||||
if (ptr->rig4 >= 0 && ptr->rig4 < X) {
|
||||
FIX(rig4, X);
|
||||
Write(W_RIG4, ms, 0, ptr->rig4, 0, 0, 0);
|
||||
Write(W_RIG4, ms, ptr->rig4, 0, 0, 0);
|
||||
}
|
||||
if (count && ptr->rig3 < X) {
|
||||
FIX(rig3, X);
|
||||
Write(W_RIG3, ms, 0, ptr->rig3, 0, 0, 0);
|
||||
Write(W_RIG3, ms, ptr->rig3, 0, 0, 0);
|
||||
}
|
||||
if (count && ptr->rig2 < X) {
|
||||
FIX(rig2, X);
|
||||
Write(W_RIG2, ms, 0, ptr->rig2, 0, 0, 0);
|
||||
Write(W_RIG2, ms, ptr->rig2, 0, 0, 0);
|
||||
}
|
||||
if (count && ptr->rig1 < X) {
|
||||
FIX(rig1, X);
|
||||
Write(W_RIG1, ms, 0, ptr->rig1, 0, 0, 0);
|
||||
Write(W_RIG1, ms, ptr->rig1, 0, 0, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -138,8 +142,8 @@ repair()
|
||||
repaired = 1;
|
||||
}
|
||||
|
||||
int
|
||||
turned()
|
||||
static int
|
||||
turned(void)
|
||||
{
|
||||
char *p;
|
||||
|
||||
@@ -150,7 +154,7 @@ turned()
|
||||
}
|
||||
|
||||
void
|
||||
loadplayer()
|
||||
loadplayer(void)
|
||||
{
|
||||
char c;
|
||||
int loadL, loadR, ready, load;
|
||||
|
||||
358
sail/pl_7.c
358
sail/pl_7.c
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pl_7.c,v 1.9 1998/08/30 09:19:40 veego Exp $ */
|
||||
/* $NetBSD: pl_7.c,v 1.26 2001/12/06 12:21:00 blymn Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
@@ -38,31 +38,52 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)pl_7.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: pl_7.c,v 1.9 1998/08/30 09:19:40 veego Exp $");
|
||||
__RCSID("$NetBSD: pl_7.c,v 1.26 2001/12/06 12:21:00 blymn Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/ttydefaults.h>
|
||||
#include "player.h"
|
||||
#ifdef __STDC__
|
||||
#include <curses.h>
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include "extern.h"
|
||||
#include "player.h"
|
||||
#include "display.h"
|
||||
|
||||
static void Scroll(void);
|
||||
static void endprompt(int);
|
||||
static void adjustview(void);
|
||||
|
||||
/*
|
||||
* Display interface
|
||||
*/
|
||||
|
||||
static char sc_hasprompt;
|
||||
static char *sc_prompt;
|
||||
static char *sc_buf;
|
||||
static const char *sc_prompt;
|
||||
static const char *sc_buf;
|
||||
static int sc_line;
|
||||
|
||||
WINDOW *view_w;
|
||||
WINDOW *slot_w;
|
||||
WINDOW *scroll_w;
|
||||
WINDOW *stat_w;
|
||||
WINDOW *turn_w;
|
||||
|
||||
int done_curses;
|
||||
int loaded, fired, changed, repaired;
|
||||
int dont_adjust;
|
||||
int viewrow, viewcol;
|
||||
char movebuf[sizeof SHIP(0)->file->movebuf];
|
||||
int player;
|
||||
struct ship *ms; /* memorial structure, &cc->ship[player] */
|
||||
struct File *mf; /* ms->file */
|
||||
struct shipspecs *mc; /* ms->specs */
|
||||
|
||||
void
|
||||
initscreen()
|
||||
initscreen(void)
|
||||
{
|
||||
if (!SCREENTEST()) {
|
||||
printf("Can't sail on this terminal.\n");
|
||||
@@ -75,21 +96,21 @@ initscreen()
|
||||
stat_w = newwin(STAT_Y, STAT_X, STAT_T, STAT_L);
|
||||
turn_w = newwin(TURN_Y, TURN_X, TURN_T, TURN_L);
|
||||
done_curses++;
|
||||
(void) leaveok(view_w, 1);
|
||||
(void) leaveok(slot_w, 1);
|
||||
(void) leaveok(stat_w, 1);
|
||||
(void) leaveok(turn_w, 1);
|
||||
leaveok(view_w, 1);
|
||||
leaveok(slot_w, 1);
|
||||
leaveok(stat_w, 1);
|
||||
leaveok(turn_w, 1);
|
||||
noecho();
|
||||
crmode();
|
||||
cbreak();
|
||||
}
|
||||
|
||||
void
|
||||
cleanupscreen()
|
||||
cleanupscreen(void)
|
||||
{
|
||||
/* alarm already turned off */
|
||||
if (done_curses) {
|
||||
(void) wmove(scroll_w, SCROLL_Y - 1, 0);
|
||||
(void) wclrtoeol(scroll_w);
|
||||
wmove(scroll_w, SCROLL_Y - 1, 0);
|
||||
wclrtoeol(scroll_w);
|
||||
draw_screen();
|
||||
endwin();
|
||||
}
|
||||
@@ -97,13 +118,12 @@ cleanupscreen()
|
||||
|
||||
/*ARGSUSED*/
|
||||
void
|
||||
newturn(n)
|
||||
int n __attribute__((unused));
|
||||
newturn(int n __attribute__((__unused__)))
|
||||
{
|
||||
repaired = loaded = fired = changed = 0;
|
||||
movebuf[0] = '\0';
|
||||
|
||||
(void) alarm(0);
|
||||
alarm(0);
|
||||
if (mf->readyL & R_LOADING) {
|
||||
if (mf->readyL & R_DOUBLE)
|
||||
mf->readyL = R_LOADING;
|
||||
@@ -117,25 +137,25 @@ newturn(n)
|
||||
mf->readyR = R_LOADED;
|
||||
}
|
||||
if (!hasdriver)
|
||||
Write(W_DDEAD, SHIP(0), 0, 0, 0, 0, 0);
|
||||
Write(W_DDEAD, SHIP(0), 0, 0, 0, 0);
|
||||
|
||||
if (sc_hasprompt) {
|
||||
(void) wmove(scroll_w, sc_line, 0);
|
||||
(void) wclrtoeol(scroll_w);
|
||||
wmove(scroll_w, sc_line, 0);
|
||||
wclrtoeol(scroll_w);
|
||||
}
|
||||
if (Sync() < 0)
|
||||
leave(LEAVE_SYNC);
|
||||
if (!hasdriver)
|
||||
leave(LEAVE_DRIVER);
|
||||
if (sc_hasprompt)
|
||||
(void) wprintw(scroll_w, "%s%s", sc_prompt, sc_buf);
|
||||
wprintw(scroll_w, "%s%s", sc_prompt, sc_buf);
|
||||
|
||||
if (turn % 50 == 0)
|
||||
Write(W_ALIVE, SHIP(0), 0, 0, 0, 0, 0);
|
||||
Write(W_ALIVE, SHIP(0), 0, 0, 0, 0);
|
||||
if (mf->FS && (!mc->rig1 || windspeed == 6))
|
||||
Write(W_FS, ms, 0, 0, 0, 0, 0);
|
||||
Write(W_FS, ms, 0, 0, 0, 0);
|
||||
if (mf->FS == 1)
|
||||
Write(W_FS, ms, 0, 2, 0, 0, 0);
|
||||
Write(W_FS, ms, 2, 0, 0, 0);
|
||||
|
||||
if (mf->struck)
|
||||
leave(LEAVE_QUIT);
|
||||
@@ -147,82 +167,55 @@ newturn(n)
|
||||
adjustview();
|
||||
draw_screen();
|
||||
|
||||
(void) signal(SIGALRM, newturn);
|
||||
(void) alarm(7);
|
||||
signal(SIGALRM, newturn);
|
||||
alarm(7);
|
||||
}
|
||||
|
||||
/*VARARGS2*/
|
||||
void
|
||||
#ifdef __STDC__
|
||||
Signal(const char *fmt, struct ship *ship, ...)
|
||||
#else
|
||||
Signal(va_alist)
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list ap;
|
||||
char format[BUFSIZ];
|
||||
#ifndef __STDC__
|
||||
const char *fmt;
|
||||
struct ship *ship;
|
||||
|
||||
va_start(ap);
|
||||
fmt = va_arg(ap, const char *);
|
||||
ship = va_arg(ap, struct ship *);
|
||||
#else
|
||||
va_start(ap, ship);
|
||||
#endif
|
||||
if (!done_curses)
|
||||
return;
|
||||
va_start(ap, ship);
|
||||
if (*fmt == '\7')
|
||||
putchar(*fmt++);
|
||||
fmtship(format, sizeof(format), fmt, ship);
|
||||
(void) vwprintw(scroll_w, format, ap);
|
||||
vwprintw(scroll_w, format, ap);
|
||||
va_end(ap);
|
||||
Scroll();
|
||||
}
|
||||
|
||||
/*VARARGS2*/
|
||||
void
|
||||
#ifdef __STDC__
|
||||
Msg(const char *fmt, ...)
|
||||
#else
|
||||
Msg(va_alist)
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list ap;
|
||||
#ifndef __STDC__
|
||||
const char *fmt;
|
||||
|
||||
va_start(ap);
|
||||
fmt = va_arg(ap, const char *);
|
||||
#else
|
||||
va_start(ap, fmt);
|
||||
#endif
|
||||
|
||||
if (!done_curses)
|
||||
return;
|
||||
va_start(ap, fmt);
|
||||
if (*fmt == '\7')
|
||||
putchar(*fmt++);
|
||||
(void) vwprintw(scroll_w, fmt, ap);
|
||||
vwprintw(scroll_w, fmt, ap);
|
||||
va_end(ap);
|
||||
Scroll();
|
||||
}
|
||||
|
||||
void
|
||||
Scroll()
|
||||
static void
|
||||
Scroll(void)
|
||||
{
|
||||
if (++sc_line >= SCROLL_Y)
|
||||
sc_line = 0;
|
||||
(void) wmove(scroll_w, sc_line, 0);
|
||||
(void) wclrtoeol(scroll_w);
|
||||
wmove(scroll_w, sc_line, 0);
|
||||
wclrtoeol(scroll_w);
|
||||
}
|
||||
|
||||
void
|
||||
prompt(p, ship)
|
||||
char *p;
|
||||
struct ship *ship;
|
||||
prompt(const char *p, struct ship *ship)
|
||||
{
|
||||
static char buf[BUFSIZ];
|
||||
|
||||
@@ -230,12 +223,11 @@ struct ship *ship;
|
||||
sc_prompt = buf;
|
||||
sc_buf = "";
|
||||
sc_hasprompt = 1;
|
||||
(void) waddstr(scroll_w, buf);
|
||||
waddstr(scroll_w, buf);
|
||||
}
|
||||
|
||||
void
|
||||
endprompt(flag)
|
||||
char flag;
|
||||
static void
|
||||
endprompt(int flag)
|
||||
{
|
||||
sc_hasprompt = 0;
|
||||
if (flag)
|
||||
@@ -243,29 +235,23 @@ char flag;
|
||||
}
|
||||
|
||||
int
|
||||
sgetch(p, ship, flag)
|
||||
char *p;
|
||||
struct ship *ship;
|
||||
char flag;
|
||||
sgetch(const char *p, struct ship *ship, int flag)
|
||||
{
|
||||
int c;
|
||||
prompt(p, ship);
|
||||
blockalarm();
|
||||
(void) wrefresh(scroll_w);
|
||||
wrefresh(scroll_w);
|
||||
unblockalarm();
|
||||
while ((c = wgetch(scroll_w)) == EOF)
|
||||
;
|
||||
if (flag && c >= ' ' && c < 0x7f)
|
||||
(void) waddch(scroll_w, c);
|
||||
waddch(scroll_w, c);
|
||||
endprompt(flag);
|
||||
return c;
|
||||
}
|
||||
|
||||
void
|
||||
sgetstr(pr, buf, n)
|
||||
char *pr;
|
||||
char *buf;
|
||||
int n;
|
||||
sgetstr(const char *pr, char *buf, int n)
|
||||
{
|
||||
int c;
|
||||
char *p = buf;
|
||||
@@ -275,7 +261,7 @@ int n;
|
||||
for (;;) {
|
||||
*p = 0;
|
||||
blockalarm();
|
||||
(void) wrefresh(scroll_w);
|
||||
wrefresh(scroll_w);
|
||||
unblockalarm();
|
||||
while ((c = wgetch(scroll_w)) == EOF)
|
||||
;
|
||||
@@ -286,248 +272,248 @@ int n;
|
||||
return;
|
||||
case '\b':
|
||||
if (p > buf) {
|
||||
(void) waddstr(scroll_w, "\b \b");
|
||||
waddstr(scroll_w, "\b \b");
|
||||
p--;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (c >= ' ' && c < 0x7f && p < buf + n - 1) {
|
||||
*p++ = c;
|
||||
(void) waddch(scroll_w, c);
|
||||
waddch(scroll_w, c);
|
||||
} else
|
||||
(void) putchar('\a');
|
||||
putchar('\a');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
draw_screen()
|
||||
draw_screen(void)
|
||||
{
|
||||
draw_view();
|
||||
draw_turn();
|
||||
draw_stat();
|
||||
draw_slot();
|
||||
(void) wrefresh(scroll_w); /* move the cursor */
|
||||
wrefresh(scroll_w); /* move the cursor */
|
||||
}
|
||||
|
||||
void
|
||||
draw_view()
|
||||
draw_view(void)
|
||||
{
|
||||
struct ship *sp;
|
||||
|
||||
(void) werase(view_w);
|
||||
werase(view_w);
|
||||
foreachship(sp) {
|
||||
if (sp->file->dir
|
||||
&& sp->file->row > viewrow
|
||||
&& sp->file->row < viewrow + VIEW_Y
|
||||
&& sp->file->col > viewcol
|
||||
&& sp->file->col < viewcol + VIEW_X) {
|
||||
(void) wmove(view_w, sp->file->row - viewrow,
|
||||
wmove(view_w, sp->file->row - viewrow,
|
||||
sp->file->col - viewcol);
|
||||
(void) waddch(view_w, colours(sp));
|
||||
(void) wmove(view_w,
|
||||
waddch(view_w, colours(sp));
|
||||
wmove(view_w,
|
||||
sternrow(sp) - viewrow,
|
||||
sterncol(sp) - viewcol);
|
||||
(void) waddch(view_w, sterncolour(sp));
|
||||
waddch(view_w, sterncolour(sp));
|
||||
}
|
||||
}
|
||||
(void) wrefresh(view_w);
|
||||
wrefresh(view_w);
|
||||
}
|
||||
|
||||
void
|
||||
draw_turn()
|
||||
draw_turn(void)
|
||||
{
|
||||
(void) wmove(turn_w, 0, 0);
|
||||
(void) wprintw(turn_w, "%cTurn %d", dont_adjust?'*':'-', turn);
|
||||
(void) wrefresh(turn_w);
|
||||
wmove(turn_w, 0, 0);
|
||||
wprintw(turn_w, "%cTurn %d", dont_adjust?'*':'-', turn);
|
||||
wrefresh(turn_w);
|
||||
}
|
||||
|
||||
void
|
||||
draw_stat()
|
||||
draw_stat(void)
|
||||
{
|
||||
(void) wmove(stat_w, STAT_1, 0);
|
||||
(void) wprintw(stat_w, "Points %3d\n", mf->points);
|
||||
(void) wprintw(stat_w, "Fouls %2d\n", fouled(ms));
|
||||
(void) wprintw(stat_w, "Grapples %2d\n", grappled(ms));
|
||||
wmove(stat_w, STAT_1, 0);
|
||||
wprintw(stat_w, "Points %3d\n", mf->points);
|
||||
wprintw(stat_w, "Fouls %2d\n", fouled(ms));
|
||||
wprintw(stat_w, "Grapples %2d\n", grappled(ms));
|
||||
|
||||
(void) wmove(stat_w, STAT_2, 0);
|
||||
(void) wprintw(stat_w, " 0 %c(%c)\n",
|
||||
wmove(stat_w, STAT_2, 0);
|
||||
wprintw(stat_w, " 0 %c(%c)\n",
|
||||
maxmove(ms, winddir + 3, -1) + '0',
|
||||
maxmove(ms, winddir + 3, 1) + '0');
|
||||
(void) waddstr(stat_w, " \\|/\n");
|
||||
(void) wprintw(stat_w, " -^-%c(%c)\n",
|
||||
waddstr(stat_w, " \\|/\n");
|
||||
wprintw(stat_w, " -^-%c(%c)\n",
|
||||
maxmove(ms, winddir + 2, -1) + '0',
|
||||
maxmove(ms, winddir + 2, 1) + '0');
|
||||
(void) waddstr(stat_w, " /|\\\n");
|
||||
(void) wprintw(stat_w, " | %c(%c)\n",
|
||||
waddstr(stat_w, " /|\\\n");
|
||||
wprintw(stat_w, " | %c(%c)\n",
|
||||
maxmove(ms, winddir + 1, -1) + '0',
|
||||
maxmove(ms, winddir + 1, 1) + '0');
|
||||
(void) wprintw(stat_w, " %c(%c)\n",
|
||||
wprintw(stat_w, " %c(%c)\n",
|
||||
maxmove(ms, winddir, -1) + '0',
|
||||
maxmove(ms, winddir, 1) + '0');
|
||||
|
||||
(void) wmove(stat_w, STAT_3, 0);
|
||||
(void) wprintw(stat_w, "Load %c%c %c%c\n",
|
||||
wmove(stat_w, STAT_3, 0);
|
||||
wprintw(stat_w, "Load %c%c %c%c\n",
|
||||
loadname[mf->loadL], readyname(mf->readyL),
|
||||
loadname[mf->loadR], readyname(mf->readyR));
|
||||
(void) wprintw(stat_w, "Hull %2d\n", mc->hull);
|
||||
(void) wprintw(stat_w, "Crew %2d %2d %2d\n",
|
||||
wprintw(stat_w, "Hull %2d\n", mc->hull);
|
||||
wprintw(stat_w, "Crew %2d %2d %2d\n",
|
||||
mc->crew1, mc->crew2, mc->crew3);
|
||||
(void) wprintw(stat_w, "Guns %2d %2d\n", mc->gunL, mc->gunR);
|
||||
(void) wprintw(stat_w, "Carr %2d %2d\n", mc->carL, mc->carR);
|
||||
(void) wprintw(stat_w, "Rigg %d %d %d ", mc->rig1, mc->rig2, mc->rig3);
|
||||
wprintw(stat_w, "Guns %2d %2d\n", mc->gunL, mc->gunR);
|
||||
wprintw(stat_w, "Carr %2d %2d\n", mc->carL, mc->carR);
|
||||
wprintw(stat_w, "Rigg %d %d %d ", mc->rig1, mc->rig2, mc->rig3);
|
||||
if (mc->rig4 < 0)
|
||||
(void) waddch(stat_w, '-');
|
||||
waddch(stat_w, '-');
|
||||
else
|
||||
(void) wprintw(stat_w, "%d", mc->rig4);
|
||||
(void) wrefresh(stat_w);
|
||||
wprintw(stat_w, "%d", mc->rig4);
|
||||
wrefresh(stat_w);
|
||||
}
|
||||
|
||||
void
|
||||
draw_slot()
|
||||
draw_slot(void)
|
||||
{
|
||||
if (!boarding(ms, 0)) {
|
||||
(void) mvwaddstr(slot_w, 0, 0, " ");
|
||||
(void) mvwaddstr(slot_w, 1, 0, " ");
|
||||
mvwaddstr(slot_w, 0, 0, " ");
|
||||
mvwaddstr(slot_w, 1, 0, " ");
|
||||
} else
|
||||
(void) mvwaddstr(slot_w, 1, 0, "OBP");
|
||||
mvwaddstr(slot_w, 1, 0, "OBP");
|
||||
if (!boarding(ms, 1)) {
|
||||
(void) mvwaddstr(slot_w, 2, 0, " ");
|
||||
(void) mvwaddstr(slot_w, 3, 0, " ");
|
||||
mvwaddstr(slot_w, 2, 0, " ");
|
||||
mvwaddstr(slot_w, 3, 0, " ");
|
||||
} else
|
||||
(void) mvwaddstr(slot_w, 3, 0, "DBP");
|
||||
mvwaddstr(slot_w, 3, 0, "DBP");
|
||||
|
||||
(void) wmove(slot_w, SLOT_Y-4, 0);
|
||||
wmove(slot_w, SLOT_Y-4, 0);
|
||||
if (mf->RH)
|
||||
(void) wprintw(slot_w, "%dRH", mf->RH);
|
||||
wprintw(slot_w, "%dRH", mf->RH);
|
||||
else
|
||||
(void) waddstr(slot_w, " ");
|
||||
(void) wmove(slot_w, SLOT_Y-3, 0);
|
||||
waddstr(slot_w, " ");
|
||||
wmove(slot_w, SLOT_Y-3, 0);
|
||||
if (mf->RG)
|
||||
(void) wprintw(slot_w, "%dRG", mf->RG);
|
||||
wprintw(slot_w, "%dRG", mf->RG);
|
||||
else
|
||||
(void) waddstr(slot_w, " ");
|
||||
(void) wmove(slot_w, SLOT_Y-2, 0);
|
||||
waddstr(slot_w, " ");
|
||||
wmove(slot_w, SLOT_Y-2, 0);
|
||||
if (mf->RR)
|
||||
(void) wprintw(slot_w, "%dRR", mf->RR);
|
||||
wprintw(slot_w, "%dRR", mf->RR);
|
||||
else
|
||||
(void) waddstr(slot_w, " ");
|
||||
waddstr(slot_w, " ");
|
||||
|
||||
#define Y (SLOT_Y/2)
|
||||
(void) wmove(slot_w, 7, 1);
|
||||
(void) wprintw(slot_w,"%d", windspeed);
|
||||
(void) mvwaddch(slot_w, Y, 0, ' ');
|
||||
(void) mvwaddch(slot_w, Y, 2, ' ');
|
||||
(void) mvwaddch(slot_w, Y-1, 0, ' ');
|
||||
(void) mvwaddch(slot_w, Y-1, 1, ' ');
|
||||
(void) mvwaddch(slot_w, Y-1, 2, ' ');
|
||||
(void) mvwaddch(slot_w, Y+1, 0, ' ');
|
||||
(void) mvwaddch(slot_w, Y+1, 1, ' ');
|
||||
(void) mvwaddch(slot_w, Y+1, 2, ' ');
|
||||
(void) wmove(slot_w, Y - dr[winddir], 1 - dc[winddir]);
|
||||
wmove(slot_w, 7, 1);
|
||||
wprintw(slot_w,"%d", windspeed);
|
||||
mvwaddch(slot_w, Y, 0, ' ');
|
||||
mvwaddch(slot_w, Y, 2, ' ');
|
||||
mvwaddch(slot_w, Y-1, 0, ' ');
|
||||
mvwaddch(slot_w, Y-1, 1, ' ');
|
||||
mvwaddch(slot_w, Y-1, 2, ' ');
|
||||
mvwaddch(slot_w, Y+1, 0, ' ');
|
||||
mvwaddch(slot_w, Y+1, 1, ' ');
|
||||
mvwaddch(slot_w, Y+1, 2, ' ');
|
||||
wmove(slot_w, Y - dr[winddir], 1 - dc[winddir]);
|
||||
switch (winddir) {
|
||||
case 1:
|
||||
case 5:
|
||||
(void) waddch(slot_w, '|');
|
||||
waddch(slot_w, '|');
|
||||
break;
|
||||
case 2:
|
||||
case 6:
|
||||
(void) waddch(slot_w, '/');
|
||||
waddch(slot_w, '/');
|
||||
break;
|
||||
case 3:
|
||||
case 7:
|
||||
(void) waddch(slot_w, '-');
|
||||
waddch(slot_w, '-');
|
||||
break;
|
||||
case 4:
|
||||
case 8:
|
||||
(void) waddch(slot_w, '\\');
|
||||
waddch(slot_w, '\\');
|
||||
break;
|
||||
}
|
||||
(void) mvwaddch(slot_w, Y + dr[winddir], 1 + dc[winddir], '+');
|
||||
(void) wrefresh(slot_w);
|
||||
mvwaddch(slot_w, Y + dr[winddir], 1 + dc[winddir], '+');
|
||||
wrefresh(slot_w);
|
||||
}
|
||||
|
||||
void
|
||||
draw_board()
|
||||
draw_board(void)
|
||||
{
|
||||
int n;
|
||||
|
||||
(void) clear();
|
||||
(void) werase(view_w);
|
||||
(void) werase(slot_w);
|
||||
(void) werase(scroll_w);
|
||||
(void) werase(stat_w);
|
||||
(void) werase(turn_w);
|
||||
clear();
|
||||
werase(view_w);
|
||||
werase(slot_w);
|
||||
werase(scroll_w);
|
||||
werase(stat_w);
|
||||
werase(turn_w);
|
||||
|
||||
sc_line = 0;
|
||||
|
||||
(void) move(BOX_T, BOX_L);
|
||||
move(BOX_T, BOX_L);
|
||||
for (n = 0; n < BOX_X; n++)
|
||||
(void) addch('-');
|
||||
(void) move(BOX_B, BOX_L);
|
||||
addch('-');
|
||||
move(BOX_B, BOX_L);
|
||||
for (n = 0; n < BOX_X; n++)
|
||||
(void) addch('-');
|
||||
addch('-');
|
||||
for (n = BOX_T+1; n < BOX_B; n++) {
|
||||
(void) mvaddch(n, BOX_L, '|');
|
||||
(void) mvaddch(n, BOX_R, '|');
|
||||
mvaddch(n, BOX_L, '|');
|
||||
mvaddch(n, BOX_R, '|');
|
||||
}
|
||||
(void) mvaddch(BOX_T, BOX_L, '+');
|
||||
(void) mvaddch(BOX_T, BOX_R, '+');
|
||||
(void) mvaddch(BOX_B, BOX_L, '+');
|
||||
(void) mvaddch(BOX_B, BOX_R, '+');
|
||||
(void) refresh();
|
||||
mvaddch(BOX_T, BOX_L, '+');
|
||||
mvaddch(BOX_T, BOX_R, '+');
|
||||
mvaddch(BOX_B, BOX_L, '+');
|
||||
mvaddch(BOX_B, BOX_R, '+');
|
||||
refresh();
|
||||
|
||||
#define WSaIM "Wooden Ships & Iron Men"
|
||||
(void) wmove(view_w, 2, (VIEW_X - sizeof WSaIM - 1) / 2);
|
||||
(void) waddstr(view_w, WSaIM);
|
||||
(void) wmove(view_w, 4, (VIEW_X - strlen(cc->name)) / 2);
|
||||
(void) waddstr(view_w, cc->name);
|
||||
(void) wrefresh(view_w);
|
||||
wmove(view_w, 2, (VIEW_X - sizeof WSaIM - 1) / 2);
|
||||
waddstr(view_w, WSaIM);
|
||||
wmove(view_w, 4, (VIEW_X - strlen(cc->name)) / 2);
|
||||
waddstr(view_w, cc->name);
|
||||
wrefresh(view_w);
|
||||
|
||||
(void) move(LINE_T, LINE_L);
|
||||
(void) printw("Class %d %s (%d guns) '%s' (%c%c)",
|
||||
move(LINE_T, LINE_L);
|
||||
printw("Class %d %s (%d guns) '%s' (%c%c)",
|
||||
mc->class,
|
||||
classname[mc->class],
|
||||
mc->guns,
|
||||
ms->shipname,
|
||||
colours(ms),
|
||||
sterncolour(ms));
|
||||
(void) refresh();
|
||||
refresh();
|
||||
}
|
||||
|
||||
void
|
||||
centerview()
|
||||
centerview(void)
|
||||
{
|
||||
viewrow = mf->row - VIEW_Y / 2;
|
||||
viewcol = mf->col - VIEW_X / 2;
|
||||
}
|
||||
|
||||
void
|
||||
upview()
|
||||
upview(void)
|
||||
{
|
||||
viewrow -= VIEW_Y / 3;
|
||||
}
|
||||
|
||||
void
|
||||
downview()
|
||||
downview(void)
|
||||
{
|
||||
viewrow += VIEW_Y / 3;
|
||||
}
|
||||
|
||||
void
|
||||
leftview()
|
||||
leftview(void)
|
||||
{
|
||||
viewcol -= VIEW_X / 5;
|
||||
}
|
||||
|
||||
void
|
||||
rightview()
|
||||
rightview(void)
|
||||
{
|
||||
viewcol += VIEW_X / 5;
|
||||
}
|
||||
|
||||
void
|
||||
adjustview()
|
||||
static void
|
||||
adjustview(void)
|
||||
{
|
||||
if (dont_adjust)
|
||||
return;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pl_main.c,v 1.6 1997/10/13 19:45:48 christos Exp $ */
|
||||
/* $NetBSD: pl_main.c,v 1.15 2001/02/05 01:10:11 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
@@ -38,19 +38,25 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)pl_main.c 8.1 (Berkeley) 5/31/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: pl_main.c,v 1.6 1997/10/13 19:45:48 christos Exp $");
|
||||
__RCSID("$NetBSD: pl_main.c,v 1.15 2001/02/05 01:10:11 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include "player.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <setjmp.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "extern.h"
|
||||
#include "player.h"
|
||||
#include "restart.h"
|
||||
|
||||
static void initialize(void);
|
||||
|
||||
/*ARGSUSED*/
|
||||
int
|
||||
pl_main()
|
||||
pl_main(void)
|
||||
{
|
||||
|
||||
initialize();
|
||||
@@ -59,21 +65,21 @@ pl_main()
|
||||
return 0; /* for lint, play() never returns */
|
||||
}
|
||||
|
||||
void
|
||||
initialize()
|
||||
static void
|
||||
initialize(void)
|
||||
{
|
||||
register struct File *fp;
|
||||
register struct ship *sp;
|
||||
struct File *fp;
|
||||
struct ship *sp;
|
||||
char captain[80];
|
||||
char message[60];
|
||||
int load;
|
||||
register int n;
|
||||
int n;
|
||||
char *nameptr;
|
||||
int nat[NNATION];
|
||||
|
||||
if (game < 0) {
|
||||
(void) puts("Choose a scenario:\n");
|
||||
(void) puts("\n\tNUMBER\tSHIPS\tIN PLAY\tTITLE");
|
||||
puts("Choose a scenario:\n");
|
||||
puts("\n\tNUMBER\tSHIPS\tIN PLAY\tTITLE");
|
||||
for (n = 0; n < NSCENE; n++) {
|
||||
/* ( */
|
||||
printf("\t%d):\t%d\t%s\t%s\n", n, scene[n].vessels,
|
||||
@@ -82,13 +88,13 @@ initialize()
|
||||
}
|
||||
reprint:
|
||||
printf("\nScenario number? ");
|
||||
(void) fflush(stdout);
|
||||
(void) scanf("%d", &game);
|
||||
fflush(stdout);
|
||||
scanf("%d", &game);
|
||||
while (getchar() != '\n')
|
||||
;
|
||||
}
|
||||
if (game < 0 || game >= NSCENE) {
|
||||
(void) puts("Very funny.");
|
||||
puts("Very funny.");
|
||||
exit(1);
|
||||
}
|
||||
cc = &scene[game];
|
||||
@@ -99,7 +105,7 @@ reprint:
|
||||
foreachship(sp) {
|
||||
if (sp->file == NULL &&
|
||||
(sp->file = (struct File *)calloc(1, sizeof (struct File))) == NULL) {
|
||||
(void) puts("OUT OF MEMORY");
|
||||
puts("OUT OF MEMORY");
|
||||
exit(1);
|
||||
}
|
||||
sp->file->index = sp - SHIP(0);
|
||||
@@ -111,8 +117,8 @@ reprint:
|
||||
windspeed = cc->windspeed;
|
||||
winddir = cc->winddir;
|
||||
|
||||
(void) signal(SIGHUP, choke);
|
||||
(void) signal(SIGINT, choke);
|
||||
signal(SIGHUP, choke);
|
||||
signal(SIGINT, choke);
|
||||
|
||||
hasdriver = sync_exists(game);
|
||||
if (sync_open() < 0) {
|
||||
@@ -121,8 +127,8 @@ reprint:
|
||||
}
|
||||
|
||||
if (hasdriver) {
|
||||
(void) puts("Synchronizing with the other players...");
|
||||
(void) fflush(stdout);
|
||||
puts("Synchronizing with the other players...");
|
||||
fflush(stdout);
|
||||
if (Sync() < 0)
|
||||
leave(LEAVE_SYNC);
|
||||
}
|
||||
@@ -132,7 +138,7 @@ reprint:
|
||||
&& sp->file->captured == 0)
|
||||
break;
|
||||
if (sp >= ls) {
|
||||
(void) puts("All ships taken in that scenario.");
|
||||
puts("All ships taken in that scenario.");
|
||||
foreachship(sp)
|
||||
free((char *)sp->file);
|
||||
sync_close(0);
|
||||
@@ -151,12 +157,12 @@ reprint:
|
||||
sp->specs->pts,
|
||||
saywhat(sp, 1));
|
||||
printf("\nWhich ship (0-%d)? ", cc->vessels-1);
|
||||
(void) fflush(stdout);
|
||||
fflush(stdout);
|
||||
if (scanf("%d", &player) != 1 || player < 0
|
||||
|| player >= cc->vessels) {
|
||||
while (getchar() != '\n')
|
||||
;
|
||||
(void) puts("Say what?");
|
||||
puts("Say what?");
|
||||
player = -1;
|
||||
} else
|
||||
while (getchar() != '\n')
|
||||
@@ -168,7 +174,7 @@ reprint:
|
||||
leave(LEAVE_SYNC);
|
||||
fp = SHIP(player)->file;
|
||||
if (fp->captain[0] || fp->struck || fp->captured != 0)
|
||||
(void) puts("That ship is taken.");
|
||||
puts("That ship is taken.");
|
||||
else
|
||||
break;
|
||||
}
|
||||
@@ -177,11 +183,11 @@ reprint:
|
||||
mf = ms->file;
|
||||
mc = ms->specs;
|
||||
|
||||
Write(W_BEGIN, ms, 0, 0, 0, 0, 0);
|
||||
Write(W_BEGIN, ms, 0, 0, 0, 0);
|
||||
if (Sync() < 0)
|
||||
leave(LEAVE_SYNC);
|
||||
|
||||
(void) signal(SIGCHLD, child);
|
||||
signal(SIGCHLD, child);
|
||||
if (!hasdriver)
|
||||
switch (fork()) {
|
||||
case 0:
|
||||
@@ -199,25 +205,25 @@ reprint:
|
||||
ms->shipname, mc->guns, classname[mc->class],
|
||||
qualname[mc->qual]);
|
||||
if ((nameptr = (char *) getenv("SAILNAME")) && *nameptr)
|
||||
(void) strncpy(captain, nameptr, sizeof captain);
|
||||
strncpy(captain, nameptr, sizeof captain);
|
||||
else {
|
||||
(void) printf("Your name, Captain? ");
|
||||
(void) fflush(stdout);
|
||||
(void) fgets(captain, sizeof captain, stdin);
|
||||
printf("Your name, Captain? ");
|
||||
fflush(stdout);
|
||||
fgets(captain, sizeof captain, stdin);
|
||||
if (!*captain)
|
||||
(void) strcpy(captain, "no name");
|
||||
strcpy(captain, "no name");
|
||||
else
|
||||
captain[strlen(captain) - 1] = '\0';
|
||||
}
|
||||
captain[sizeof captain - 1] = '\0';
|
||||
Write(W_CAPTAIN, ms, 1, (long)captain, 0, 0, 0);
|
||||
Writestr(W_CAPTAIN, ms, captain);
|
||||
for (n = 0; n < 2; n++) {
|
||||
char buf[10];
|
||||
|
||||
printf("\nInitial broadside %s (grape, chain, round, double): ",
|
||||
n ? "right" : "left");
|
||||
(void) fflush(stdout);
|
||||
(void) scanf("%s", buf);
|
||||
fflush(stdout);
|
||||
scanf("%s", buf);
|
||||
switch (*buf) {
|
||||
case 'g':
|
||||
load = L_GRAPE;
|
||||
@@ -245,7 +251,8 @@ reprint:
|
||||
|
||||
initscreen();
|
||||
draw_board();
|
||||
(void) sprintf(message, "Captain %s assuming command", captain);
|
||||
Write(W_SIGNAL, ms, 1, (long)message, 0, 0, 0);
|
||||
snprintf(message, sizeof message, "Captain %s assuming command",
|
||||
captain);
|
||||
Writestr(W_SIGNAL, ms, message);
|
||||
newturn(0);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: player.h,v 1.6 1998/03/29 04:57:20 mrg Exp $ */
|
||||
/* $NetBSD: player.h,v 1.10 2001/01/04 05:34:56 jwise Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
@@ -35,9 +35,6 @@
|
||||
* @(#)player.h 8.2 (Berkeley) 5/3/95
|
||||
*/
|
||||
|
||||
#include <curses.h>
|
||||
#include "extern.h"
|
||||
|
||||
/* sizes and coordinates for the screen */
|
||||
|
||||
#define LINE_T 0
|
||||
@@ -92,28 +89,16 @@
|
||||
#define SLOT_B VIEW_B
|
||||
#define SLOT_R (SLOT_L+SLOT_X-1)
|
||||
|
||||
#ifdef SIGTSTP
|
||||
#define SCREENTEST() (initscr() != NULL && signal(SIGTSTP, SIG_DFL) != SIG_ERR && STAT_R < COLS && SCROLL_Y > 0)
|
||||
#else
|
||||
#define SCREENTEST() (initscr() != NULL && STAT_R < COLS && SCROLL_Y > 0)
|
||||
#endif
|
||||
|
||||
WINDOW *view_w;
|
||||
WINDOW *slot_w;
|
||||
WINDOW *scroll_w;
|
||||
WINDOW *stat_w;
|
||||
WINDOW *turn_w;
|
||||
|
||||
char done_curses;
|
||||
char loaded, fired, changed, repaired;
|
||||
char dont_adjust;
|
||||
int viewrow, viewcol;
|
||||
char movebuf[sizeof SHIP(0)->file->movebuf];
|
||||
extern int done_curses;
|
||||
extern int loaded, fired, changed, repaired;
|
||||
extern int dont_adjust;
|
||||
extern int viewrow, viewcol;
|
||||
extern char movebuf[sizeof SHIP(0)->file->movebuf];
|
||||
extern char version[];
|
||||
int player;
|
||||
struct ship *ms; /* memorial structure, &cc->ship[player] */
|
||||
struct File *mf; /* ms->file */
|
||||
struct shipspecs *mc; /* ms->specs */
|
||||
extern int player;
|
||||
extern struct ship *ms; /* memorial structure, &cc->ship[player] */
|
||||
extern struct File *mf; /* ms->file */
|
||||
extern struct shipspecs *mc; /* ms->specs */
|
||||
|
||||
/* condition codes for leave() */
|
||||
#define LEAVE_QUIT 0
|
||||
|
||||
503
sail/sail.6
503
sail/sail.6
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: sail.6,v 1.6 1997/01/07 12:42:25 tls Exp $
|
||||
.\" $NetBSD: sail.6,v 1.11 2002/09/26 16:33:54 wiz Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1988, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@@ -60,17 +60,19 @@ originally developed by S. Craig Taylor.
|
||||
Players of
|
||||
.I Sail
|
||||
take command of an old fashioned Man of War and fight other
|
||||
players or the computer. They may re-enact one of the many
|
||||
players or the computer.
|
||||
They may re-enact one of the many
|
||||
historical sea battles recorded in the game, or they can choose
|
||||
a fictional battle.
|
||||
.PP
|
||||
As a sea captain in the
|
||||
As a sea captain in the
|
||||
.I Sail
|
||||
Navy, the player has complete control over the workings of his ship.
|
||||
He must order every maneuver, change the set of his sails, and judge the
|
||||
right moment to let loose the terrible destruction of his broadsides.
|
||||
In addition to fighting the enemy, he must harness the powers of the wind
|
||||
and sea to make them work for him. The outcome of many battles during the
|
||||
and sea to make them work for him.
|
||||
The outcome of many battles during the
|
||||
age of sail was decided by the ability of one captain to hold the `weather
|
||||
gage.'
|
||||
.PP
|
||||
@@ -80,7 +82,8 @@ The flags are:
|
||||
Print the names and ships of the top ten sailors.
|
||||
.TP
|
||||
.B \-l
|
||||
Show the login name. Only effective with \fB-s\fP.
|
||||
Show the login name.
|
||||
Only effective with \fB-s\fP.
|
||||
.TP
|
||||
.B \-x
|
||||
Play the first available ship instead of prompting for a choice.
|
||||
@@ -89,8 +92,9 @@ Play the first available ship instead of prompting for a choice.
|
||||
No bells.
|
||||
.SH IMPLEMENTATION
|
||||
.I Sail
|
||||
is really two programs in one. Each player starts up a process which
|
||||
runs his own ship. In addition, a
|
||||
is really two programs in one.
|
||||
Each player starts up a process which runs his own ship.
|
||||
In addition, a
|
||||
.I driver
|
||||
process is forked (by the first player) to run the computer ships
|
||||
and take care of global bookkeeping.
|
||||
@@ -101,38 +105,41 @@ must calculate moves for each ship it controls, the
|
||||
more ships the computer is playing, the slower the game will appear.
|
||||
.PP
|
||||
If a player joins a game in progress, he will synchronize
|
||||
with the other players (a rather slow process for everyone), and
|
||||
with the other players (a rather slow process for everyone), and
|
||||
then he may play along with the rest.
|
||||
.PP
|
||||
To implement a multi-user game in Version 7 UNIX, which was the operating
|
||||
system
|
||||
.I Sail
|
||||
was first written under, the communicating processes must use a common
|
||||
temporary file as a place to read and write messages. In addition, a
|
||||
locking mechanism must be provided to ensure exclusive access to the
|
||||
shared file. For example,
|
||||
temporary file as a place to read and write messages.
|
||||
In addition, a locking mechanism must be provided to ensure exclusive
|
||||
access to the shared file.
|
||||
For example,
|
||||
.I Sail
|
||||
uses a temporary file named /tmp/#sailsink.21 for scenario 21, and
|
||||
corresponding file names for the other scenarios. To provide exclusive
|
||||
access to the temporary file,
|
||||
corresponding file names for the other scenarios.
|
||||
To provide exclusive
|
||||
access to the temporary file,
|
||||
.I Sail
|
||||
uses a technique stolen from an old game called "pubcaves" by Jeff Cohen.
|
||||
Processes do a busy wait in the loop
|
||||
.br
|
||||
.sp
|
||||
.ce 2
|
||||
for (n = 0; link(sync_file, sync_lock) < 0 && n < 30; n++)
|
||||
for (n = 0; link(sync_file, sync_lock) \*[Lt] 0 \*[Am]\*[Am] n \*[Lt] 30; n++)
|
||||
sleep(2);
|
||||
.br
|
||||
.sp
|
||||
until they are able to create a link to a file named "/tmp/#saillock.??".
|
||||
The "??" correspond to the scenario number of the game. Since UNIX
|
||||
The "??" correspond to the scenario number of the game.
|
||||
Since UNIX
|
||||
guarantees that a link will point to only one file, the process that succeeds
|
||||
in linking will have exclusive access to the temporary file.
|
||||
.PP
|
||||
Whether or not this really works is open to speculation. When ucbmiro
|
||||
was rebooted after a crash, the file system check program found 3 links
|
||||
between the
|
||||
Whether or not this really works is open to speculation.
|
||||
When ucbmiro was rebooted after a crash, the file system check program
|
||||
found 3 links between the
|
||||
.I Sail
|
||||
temporary file and its link file.
|
||||
.SH CONSEQUENCES OF SEPARATE PLAYER AND DRIVER PROCESSES
|
||||
@@ -141,24 +148,29 @@ the driver must coordinate the action with the other ships in the game.
|
||||
For example, if a player wants to move in a certain direction, he writes a
|
||||
message into the temporary file requesting the driver to move his ship.
|
||||
Each ``turn,'' the driver reads all the messages sent from the players and
|
||||
decides what happened. It then writes back into the temporary file new
|
||||
values of variables, etc.
|
||||
decides what happened.
|
||||
It then writes back into the temporary file new values of variables, etc.
|
||||
.PP
|
||||
The most noticeable effect this communication has on the game is the
|
||||
delay in moving. Suppose a player types a move for his ship and hits
|
||||
return. What happens then? The player process saves up messages to
|
||||
be written to the temporary file in a buffer. Every 7 seconds or so, the
|
||||
player process gets exclusive access to the temporary file and writes
|
||||
out its buffer to the file. The driver, running asynchronously, must
|
||||
read in the movement command, process it, and write out the results. This
|
||||
takes two exclusive accesses to the temporary file. Finally, when the player
|
||||
process gets around to doing another 7 second update, the results of the
|
||||
move are displayed on the screen. Hence, every movement requires four
|
||||
delay in moving.
|
||||
Suppose a player types a move for his ship and hits return.
|
||||
What happens then?
|
||||
The player process saves up messages to
|
||||
be written to the temporary file in a buffer.
|
||||
Every 7 seconds or so, the player process gets exclusive access to
|
||||
the temporary file and writes out its buffer to the file.
|
||||
The driver, running asynchronously, must
|
||||
read in the movement command, process it, and write out the results.
|
||||
This takes two exclusive accesses to the temporary file.
|
||||
Finally, when the player process gets around to doing another 7 second
|
||||
update, the results of the move are displayed on the screen.
|
||||
Hence, every movement requires four
|
||||
exclusive accesses to the temporary file (anywhere from 7 to 21 seconds
|
||||
depending upon asynchrony) before the player sees the results of his moves.
|
||||
.PP
|
||||
In practice, the delays are not as annoying as they would appear. There
|
||||
is room for "pipelining" in the movement. After the player writes out
|
||||
In practice, the delays are not as annoying as they would appear.
|
||||
There is room for "pipelining" in the movement.
|
||||
After the player writes out
|
||||
a first movement message, a second movement command can then be issued.
|
||||
The first message will be in the temporary file waiting for the driver, and
|
||||
the second will be in the file buffer waiting to be written to the file.
|
||||
@@ -166,19 +178,22 @@ Thus, by always typing moves a turn ahead of the time, the player can
|
||||
sail around quite quickly.
|
||||
.PP
|
||||
If the player types several movement commands between two 7 second updates,
|
||||
only the last movement command typed will be seen by the driver. Movement
|
||||
commands within the same update "overwrite" each other, in a sense.
|
||||
.SH THE HISTORY OF SAIL
|
||||
only the last movement command typed will be seen by the driver.
|
||||
Movement commands within the same update "overwrite" each other, in a sense.
|
||||
.SH THE HISTORY OF SAIL
|
||||
I wrote the first version of
|
||||
.I Sail
|
||||
on a PDP 11/70 in the fall of 1980. Needless to say, the code was horrendous,
|
||||
not portable in any sense of the word, and didn't work. The program was not
|
||||
very modular and had fseeks() and fwrites() every few lines. After a
|
||||
tremendous rewrite from the top down, I got the first working version up by
|
||||
1981. There were several annoying bugs concerning firing broadsides and
|
||||
on a PDP 11/70 in the fall of 1980.
|
||||
Needless to say, the code was horrendous,
|
||||
not portable in any sense of the word, and didn't work.
|
||||
The program was not
|
||||
very modular and had fseeks() and fwrites() every few lines.
|
||||
After a tremendous rewrite from the top down,
|
||||
I got the first working version up by 1981.
|
||||
There were several annoying bugs concerning firing broadsides and
|
||||
finding angles.
|
||||
.I Sail
|
||||
uses no floating point, by the way, so the direction routines are rather
|
||||
uses no floating point, by the way, so the direction routines are rather
|
||||
tricky.
|
||||
Ed Wang rewrote my angle() routine in 1981 to be more correct (although
|
||||
it still doesn't work perfectly), and he added code to let a player select
|
||||
@@ -187,12 +202,14 @@ available).
|
||||
.PP
|
||||
Captain Happy (Craig Leres) is responsible for making
|
||||
.I Sail
|
||||
portable for the first time. This was no easy task, by the way. Constants
|
||||
like 2 and 10 were very frequent in the code. I also became famous for
|
||||
using "Riggle Memorial Structures" in
|
||||
portable for the first time.
|
||||
This was no easy task, by the way.
|
||||
Constants like 2 and 10 were very frequent in the code.
|
||||
I also became famous for using "Riggle Memorial Structures" in
|
||||
.I Sail.
|
||||
Many of my structure references are so long that they run off the line
|
||||
printer page. Here is an example, if you promise not to laugh.
|
||||
printer page.
|
||||
Here is an example, if you promise not to laugh.
|
||||
.br
|
||||
.sp
|
||||
.ce
|
||||
@@ -202,15 +219,19 @@ specs[scene[flog.fgamenum].ship[flog.fshipnum].shipnum].pts
|
||||
.PP
|
||||
.I Sail
|
||||
received its fourth and most thorough rewrite in the summer and fall
|
||||
of 1983. Ed Wang rewrote and modularized the code (a monumental feat)
|
||||
almost from scratch. Although he introduced many new bugs, the final
|
||||
result was very much cleaner and (?) faster. He added window movement
|
||||
commands and find ship commands.
|
||||
of 1983.
|
||||
Ed Wang rewrote and modularized the code (a monumental feat)
|
||||
almost from scratch.
|
||||
Although he introduced many new bugs, the final result was very much
|
||||
cleaner and (?) faster.
|
||||
He added window movement commands and find ship commands.
|
||||
.SH HISTORICAL INFO
|
||||
Old Square Riggers were very maneuverable ships capable of intricate
|
||||
sailing. Their only disadvantage was an inability to sail very
|
||||
close to the wind. The design of a wooden ship allowed only for the
|
||||
guns to bear to the left and right sides. A few guns of small
|
||||
sailing.
|
||||
Their only disadvantage was an inability to sail very close to the wind.
|
||||
The design of a wooden ship allowed only for the
|
||||
guns to bear to the left and right sides.
|
||||
A few guns of small
|
||||
aspect (usually 6 or 9 pounders) could point forward, but their
|
||||
effect was small compared to a 68 gun broadside of 24 or 32 pounders.
|
||||
The guns bear approximately like so:
|
||||
@@ -229,9 +250,10 @@ The guns bear approximately like so:
|
||||
|
||||
.fi
|
||||
An interesting phenomenon occurred when a broadside was fired
|
||||
down the length of an enemy ship. The shot tended to bounce along
|
||||
the deck and did several times more damage. This phenomenon was called
|
||||
a rake. Because the bows of a ship are very strong and present a smaller
|
||||
down the length of an enemy ship.
|
||||
The shot tended to bounce along the deck and did several times more damage.
|
||||
This phenomenon was called a rake.
|
||||
Because the bows of a ship are very strong and present a smaller
|
||||
target than the stern, a stern rake (firing from the stern to the bow) causes
|
||||
more damage than a bow rake.
|
||||
.nf
|
||||
@@ -242,91 +264,109 @@ more damage than a bow rake.
|
||||
|
||||
.fi
|
||||
Most ships were equipped with carronades, which were very large, close
|
||||
range cannons. American ships from the revolution until the War of 1812
|
||||
range cannons.
|
||||
American ships from the revolution until the War of 1812
|
||||
were almost entirely armed with carronades.
|
||||
.PP
|
||||
The period of history covered in
|
||||
.I Sail
|
||||
is approximately from the 1770's until the end of Napoleonic France in 1815.
|
||||
There are many excellent books about the age of sail. My favorite author
|
||||
is Captain Frederick Marryat. More contemporary authors include C.S. Forester
|
||||
and Alexander Kent.
|
||||
There are many excellent books about the age of sail.
|
||||
My favorite author is Captain Frederick Marryat.
|
||||
More contemporary authors include C.S. Forester and Alexander Kent.
|
||||
.PP
|
||||
Fighting ships came in several sizes classed by armament. The mainstays of
|
||||
any fleet were its "Ships of the Line", or "Line of Battle Ships". They
|
||||
were so named because these ships fought together in great lines. They were
|
||||
Fighting ships came in several sizes classed by armament.
|
||||
The mainstays of
|
||||
any fleet were its "Ships of the Line", or "Line of Battle Ships".
|
||||
They were so named because these ships fought together in great lines.
|
||||
They were
|
||||
close enough for mutual support, yet every ship could fire both its broadsides.
|
||||
We get the modern words "ocean liner," or "liner," and "battleship" from
|
||||
"ship of the line." The most common size was the 74 gun two decked
|
||||
ship of the line. The two gun decks usually mounted 18 and 24 pounder guns.
|
||||
"ship of the line."
|
||||
The most common size was the 74 gun two decked ship of the line.
|
||||
The two gun decks usually mounted 18 and 24 pounder guns.
|
||||
.PP
|
||||
The pride of the fleet were the first rates. These were huge three decked
|
||||
ships of the line mounting 80 to 136 guns. The guns in the three tiers
|
||||
The pride of the fleet were the first rates.
|
||||
These were huge three decked ships of the line mounting 80 to 136 guns.
|
||||
The guns in the three tiers
|
||||
were usually 18, 24, and 32 pounders in that order from top to bottom.
|
||||
.PP
|
||||
Various other ships came next. They were almost all "razees," or ships
|
||||
of the line with one deck sawed off. They mounted 40-64 guns and were
|
||||
a poor cross between a frigate and a line of battle ship. They neither
|
||||
had the speed of the former nor the firepower of the latter.
|
||||
Various other ships came next.
|
||||
They were almost all "razees," or ships of the line with one deck sawed off.
|
||||
They mounted 40-64 guns and were
|
||||
a poor cross between a frigate and a line of battle ship.
|
||||
They neither had the speed of the former nor the firepower of the latter.
|
||||
.PP
|
||||
Next came the "eyes of the fleet." Frigates came in many sizes mounting
|
||||
anywhere from 32 to 44 guns. They were very handy vessels. They could
|
||||
outsail anything bigger and outshoot anything smaller. Frigates didn't
|
||||
fight in lines of battle as the much bigger 74's did. Instead, they
|
||||
harassed the enemy's rear or captured crippled ships. They were much
|
||||
more useful in missions away from the fleet, such as cutting out expeditions
|
||||
or boat actions. They could hit hard and get away fast.
|
||||
Next came the "eyes of the fleet."
|
||||
Frigates came in many sizes mounting anywhere from 32 to 44 guns.
|
||||
They were very handy vessels.
|
||||
They could outsail anything bigger and outshoot anything smaller.
|
||||
Frigates didn't fight in lines of battle as the much bigger 74's did.
|
||||
Instead, they harassed the enemy's rear or captured crippled ships.
|
||||
They were much more useful in missions away from the fleet,
|
||||
such as cutting out expeditions or boat actions.
|
||||
They could hit hard and get away fast.
|
||||
.PP
|
||||
Lastly, there were the corvettes, sloops, and brigs. These were smaller
|
||||
ships mounting typically fewer than 20 guns. A corvette was only slightly
|
||||
smaller than a frigate, so one might have up to 30 guns. Sloops were used
|
||||
for carrying dispatches or passengers. Brigs were something you built for
|
||||
land-locked lakes.
|
||||
Lastly, there were the corvettes, sloops, and brigs.
|
||||
These were smaller ships mounting typically fewer than 20 guns.
|
||||
A corvette was only slightly
|
||||
smaller than a frigate, so one might have up to 30 guns.
|
||||
Sloops were used for carrying dispatches or passengers.
|
||||
Brigs were something you built for land-locked lakes.
|
||||
.SH SAIL PARTICULARS
|
||||
Ships in
|
||||
.I Sail
|
||||
are represented by two characters. One character represents the bow of
|
||||
the ship, and the other represents the stern. Ships have nationalities
|
||||
and numbers. The first ship of a nationality is number 0, the second
|
||||
number 1, etc. Therefore, the first British ship in a game would be
|
||||
printed as "b0". The second Brit would be "b1", and the fifth Don
|
||||
would be "s4".
|
||||
are represented by two characters.
|
||||
One character represents the bow of
|
||||
the ship, and the other represents the stern.
|
||||
Ships have nationalities and numbers.
|
||||
The first ship of a nationality is number 0, the second
|
||||
number 1, etc.
|
||||
Therefore, the first British ship in a game would be printed as "b0".
|
||||
The second Brit would be "b1", and the fifth Don would be "s4".
|
||||
.PP
|
||||
Ships can set normal sails, called Battle Sails, or bend on extra canvas
|
||||
called Full Sails. A ship under full sail is a beautiful sight indeed,
|
||||
and it can move much faster than a ship under Battle Sails. The only
|
||||
trouble is, with full sails set, there is so much tension on sail and
|
||||
called Full Sails.
|
||||
A ship under full sail is a beautiful sight indeed,
|
||||
and it can move much faster than a ship under Battle Sails.
|
||||
The only trouble is, with full sails set, there is so much tension on sail and
|
||||
rigging that a well aimed round shot can burst a sail into ribbons where
|
||||
it would only cause a little hole in a loose sail. For this reason,
|
||||
rigging damage is doubled on a ship with full sails set. Don't let
|
||||
that discourage you from using full sails. I like to keep them up
|
||||
right into the heat of battle. A ship
|
||||
with full sails set has a capital letter for its nationality. E.g.,
|
||||
a Frog, "f0", with full sails set would be printed as "F0".
|
||||
it would only cause a little hole in a loose sail.
|
||||
For this reason, rigging damage is doubled on a ship with full sails set.
|
||||
Don't let that discourage you from using full sails.
|
||||
I like to keep them up right into the heat of battle.
|
||||
A ship with full sails set has a capital letter for its nationality.
|
||||
E.g., a Frog, "f0", with full sails set would be printed as "F0".
|
||||
.PP
|
||||
When a ship is battered into a listing hulk, the last man aboard "strikes
|
||||
the colors." This ceremony is the ship's formal surrender. The nationality
|
||||
character
|
||||
of a surrendered ship is printed as "!". E.g., the Frog of our last example
|
||||
would soon be "!0".
|
||||
the colors."
|
||||
This ceremony is the ship's formal surrender.
|
||||
The nationality character of a surrendered ship is printed as "!".
|
||||
E.g., the Frog of our last example would soon be "!0".
|
||||
.PP
|
||||
A ship has a random chance of catching fire or sinking when it reaches the
|
||||
stage of listing hulk. A sinking ship has a "~" printed for its nationality,
|
||||
stage of listing hulk.
|
||||
A sinking ship has a "~" printed for its nationality,
|
||||
and a ship on fire and about to explode has a "#" printed.
|
||||
.PP
|
||||
Captured ships become the nationality of the prize crew. Therefore, if
|
||||
Captured ships become the nationality of the prize crew.
|
||||
Therefore, if
|
||||
an American ship captures a British ship, the British ship will have an
|
||||
"a" printed for its nationality. In addition, the ship number is changed
|
||||
to "&","'", "(", ,")", "*", or "+" depending upon the original number,
|
||||
be it 0,1,2,3,4, or 5. E.g., the "b0" captured by an American becomes the
|
||||
"a&". The "s4" captured by a Frog becomes the "f*".
|
||||
"a" printed for its nationality.
|
||||
In addition, the ship number is changed
|
||||
to "\*[Am]","'", "(", ,")", "*", or "+" depending upon the original number,
|
||||
be it 0,1,2,3,4, or 5.
|
||||
E.g., the "b0" captured by an American becomes the
|
||||
"a\*[Am]".
|
||||
The "s4" captured by a Frog becomes the "f*".
|
||||
.PP
|
||||
The ultimate example is, of course, an exploding Brit captured by an
|
||||
American: "#&".
|
||||
American: "#\*[Am]".
|
||||
.SH MOVEMENT
|
||||
Movement is the most confusing part of
|
||||
Movement is the most confusing part of
|
||||
.I Sail
|
||||
to many. Ships can head in 8 directions:
|
||||
to many.
|
||||
Ships can head in 8 directions:
|
||||
.nf
|
||||
|
||||
0 0 0
|
||||
@@ -334,26 +374,31 @@ to many. Ships can head in 8 directions:
|
||||
0 0 0
|
||||
|
||||
.fi
|
||||
The stern of a ship moves when it turns. The bow remains stationary.
|
||||
The stern of a ship moves when it turns.
|
||||
The bow remains stationary.
|
||||
Ships can always turn, regardless of the wind (unless they are becalmed).
|
||||
All ships drift when they lose headway. If a ship doesn't move forward
|
||||
at all for two turns, it will begin to drift. If a ship has begun to
|
||||
All ships drift when they lose headway.
|
||||
If a ship doesn't move forward at all for two turns, it will begin to drift.
|
||||
If a ship has begun to
|
||||
drift, then it must move forward before it turns, if it plans to do
|
||||
more than make a right or left turn, which is always possible.
|
||||
.PP
|
||||
Movement commands to
|
||||
Movement commands to
|
||||
.I Sail
|
||||
are a string of forward moves and turns. An example is "l3". It will
|
||||
turn a ship left and then move it ahead 3 spaces. In the drawing above,
|
||||
the "b0" made 7 successive left turns. When
|
||||
are a string of forward moves and turns.
|
||||
An example is "l3".
|
||||
It will turn a ship left and then move it ahead 3 spaces.
|
||||
In the drawing above, the "b0" made 7 successive left turns.
|
||||
When
|
||||
.I Sail
|
||||
prompts you for a move, it prints three characters of import. E.g.,
|
||||
prompts you for a move, it prints three characters of import.
|
||||
E.g.,
|
||||
.nf
|
||||
move (7, 4):
|
||||
move (7, 4):
|
||||
.fi
|
||||
The first number is the maximum number of moves you can make,
|
||||
including turns. The second number is the maximum number of turns
|
||||
you can make. Between the numbers is sometimes printed a quote "'".
|
||||
The first number is the maximum number of moves you can make, including turns.
|
||||
The second number is the maximum number of turns you can make.
|
||||
Between the numbers is sometimes printed a quote "'".
|
||||
If the quote is present, it means that your ship has been drifting, and
|
||||
you must move ahead to regain headway before you turn (see note above).
|
||||
Some of the possible moves for the example above are as follows:
|
||||
@@ -371,7 +416,8 @@ Some of the possible moves for the example above are as follows:
|
||||
.fi
|
||||
Because square riggers performed so poorly sailing into the wind, if at
|
||||
any point in a movement command you turn into the wind, the movement stops
|
||||
there. E.g.,
|
||||
there.
|
||||
E.g.,
|
||||
.ne 1i
|
||||
.nf
|
||||
|
||||
@@ -381,17 +427,20 @@ there. E.g.,
|
||||
|
||||
.fi
|
||||
Moreover, whenever you make a turn, your movement allowance drops to
|
||||
min(what's left, what you would have at the new attitude). In short,
|
||||
if you turn closer to the wind, you most likely won't be able to sail the
|
||||
full allowance printed in the "move" prompt.
|
||||
min(what's left, what you would have at the new attitude).
|
||||
In short, if you turn closer to the wind, you most likely won't be able
|
||||
to sail the full allowance printed in the "move" prompt.
|
||||
.PP
|
||||
Old sailing captains had to keep an eye constantly on the wind. Captains
|
||||
in
|
||||
Old sailing captains had to keep an eye constantly on the wind.
|
||||
Captains in
|
||||
.I Sail
|
||||
are no different. A ship's ability to move depends on its attitude to the
|
||||
wind. The best angle possible is to have the wind off your quarter, that is,
|
||||
just off the stern. The direction rose on the side of the screen gives the
|
||||
possible movements for your ship at all positions to the wind. Battle
|
||||
are no different.
|
||||
A ship's ability to move depends on its attitude to the wind.
|
||||
The best angle possible is to have the wind off your quarter, that is,
|
||||
just off the stern.
|
||||
The direction rose on the side of the screen gives the
|
||||
possible movements for your ship at all positions to the wind.
|
||||
Battle
|
||||
sail speeds are given first, and full sail speeds are given in parenthesis.
|
||||
.nf
|
||||
|
||||
@@ -400,21 +449,25 @@ sail speeds are given first, and full sail speeds are given in parenthesis.
|
||||
-^-3(6)
|
||||
/|\\
|
||||
| 4(7)
|
||||
3(6)
|
||||
3(6)
|
||||
|
||||
.fi
|
||||
Pretend the bow of your ship (the "^") is pointing upward and the wind is
|
||||
blowing from the bottom to the top of the page. The
|
||||
numbers at the bottom "3(6)" will be your speed under battle or full
|
||||
sails in such a situation. If the wind is off your quarter, then you
|
||||
can move "4(7)". If the wind is off your beam, "3(6)". If the wind is
|
||||
off your bow, then you can only move "1(2)". Facing into the wind, you
|
||||
can't move at all. Ships facing into the wind were said to be "in irons".
|
||||
blowing from the bottom to the top of the page.
|
||||
The numbers at the bottom "3(6)" will be your speed under battle or full
|
||||
sails in such a situation.
|
||||
If the wind is off your quarter, then you can move "4(7)".
|
||||
If the wind is off your beam, "3(6)".
|
||||
If the wind is off your bow, then you can only move "1(2)".
|
||||
Facing into the wind, you can't move at all.
|
||||
Ships facing into the wind were said to be "in irons".
|
||||
.SH WINDSPEED AND DIRECTION
|
||||
The windspeed and direction is displayed as a little weather vane on the
|
||||
side of the screen. The number in the middle of the vane indicates the wind
|
||||
speed, and the + to - indicates the wind direction. The wind blows from
|
||||
the + sign (high pressure) to the - sign (low pressure). E.g.,
|
||||
side of the screen.
|
||||
The number in the middle of the vane indicates the wind
|
||||
speed, and the + to - indicates the wind direction.
|
||||
The wind blows from the + sign (high pressure) to the - sign (low pressure).
|
||||
E.g.,
|
||||
.nf
|
||||
|
||||
|
|
||||
@@ -426,9 +479,11 @@ The wind speeds are 0 = becalmed, 1 = light breeze, 2 = moderate breeze,
|
||||
3 = fresh breeze, 4 = strong breeze, 5 = gale, 6 = full gale, 7 = hurricane.
|
||||
If a hurricane shows up, all ships are destroyed.
|
||||
.SH GRAPPLING AND FOULING
|
||||
If two ships collide, they run the risk of becoming tangled together. This
|
||||
is called "fouling." Fouled ships are stuck together, and neither can move.
|
||||
They can unfoul each other if they want to. Boarding parties can only be
|
||||
If two ships collide, they run the risk of becoming tangled together.
|
||||
This is called "fouling."
|
||||
Fouled ships are stuck together, and neither can move.
|
||||
They can unfoul each other if they want to.
|
||||
Boarding parties can only be
|
||||
sent across to ships when the antagonists are either fouled or grappled.
|
||||
.PP
|
||||
Ships can grapple each other by throwing grapnels into the rigging of
|
||||
@@ -437,8 +492,8 @@ the other.
|
||||
The number of fouls and grapples you have are displayed on the upper
|
||||
right of the screen.
|
||||
.SH BOARDING
|
||||
Boarding was a very costly venture in terms of human life. Boarding parties
|
||||
may be formed in
|
||||
Boarding was a very costly venture in terms of human life.
|
||||
Boarding parties may be formed in
|
||||
.I Sail
|
||||
to either board an enemy ship or to defend your own ship against attack.
|
||||
Men organized as Defensive Boarding Parties fight twice as hard to save
|
||||
@@ -447,102 +502,122 @@ their ship as men left unorganized.
|
||||
The boarding strength of a crew depends upon its quality and upon the
|
||||
number of men sent.
|
||||
.SH CREW QUALITY
|
||||
The British seaman was world renowned for his sailing abilities. American
|
||||
sailors, however, were actually the best seamen in the world. Because the
|
||||
American Navy offered twice the wages of the Royal Navy, British seamen
|
||||
The British seaman was world renowned for his sailing abilities.
|
||||
American sailors, however, were actually the best seamen in the world.
|
||||
Because the
|
||||
American Navy offered twice the wages of the Royal Navy, British seamen
|
||||
who liked the sea defected to America by the thousands.
|
||||
.PP
|
||||
In
|
||||
In
|
||||
.I Sail,
|
||||
crew quality is quantized into 5 energy levels. "Elite" crews can outshoot
|
||||
and outfight all other sailors. "Crack" crews are next. "Mundane" crews
|
||||
are average, and "Green" and "Mutinous" crews are below average. A good
|
||||
rule of thumb is that "Crack" or "Elite" crews get one extra hit
|
||||
per broadside compared to "Mundane" crews. Don't expect too much from
|
||||
crew quality is quantized into 5 energy levels.
|
||||
"Elite" crews can outshoot and outfight all other sailors.
|
||||
"Crack" crews are next.
|
||||
"Mundane" crews
|
||||
are average, and "Green" and "Mutinous" crews are below average.
|
||||
A good rule of thumb is that "Crack" or "Elite" crews get one extra hit
|
||||
per broadside compared to "Mundane" crews.
|
||||
Don't expect too much from
|
||||
"Green" crews.
|
||||
.pl -1
|
||||
.SH BROADSIDES
|
||||
Your two broadsides may be loaded with four kinds of shot: grape, chain,
|
||||
round, and double. You have guns and carronades in both the port and starboard
|
||||
batteries. Carronades only have a range of two, so you have to get in
|
||||
close to be able to fire them. You have the choice of firing at the hull
|
||||
or rigging of another ship. If the range of the ship is greater than 6,
|
||||
round, and double.
|
||||
You have guns and carronades in both the port and starboard batteries.
|
||||
Carronades only have a range of two, so you have to get in
|
||||
close to be able to fire them.
|
||||
You have the choice of firing at the hull or rigging of another ship.
|
||||
If the range of the ship is greater than 6,
|
||||
then you may only shoot at the rigging.
|
||||
.PP
|
||||
The types of shot and their advantages are:
|
||||
.SH ROUND
|
||||
Range of 10. Good for hull or rigging hits.
|
||||
Range of 10.
|
||||
Good for hull or rigging hits.
|
||||
.SH DOUBLE
|
||||
Range of 1. Extra good for hull or rigging hits.
|
||||
Range of 1.
|
||||
Extra good for hull or rigging hits.
|
||||
Double takes two turns to load.
|
||||
.SH CHAIN
|
||||
Range of 3. Excellent for tearing down rigging.
|
||||
Range of 3.
|
||||
Excellent for tearing down rigging.
|
||||
Cannot damage hull or guns, though.
|
||||
.SH GRAPE
|
||||
Range of 1. Sometimes devastating against enemy crews.
|
||||
Range of 1.
|
||||
Sometimes devastating against enemy crews.
|
||||
.PP
|
||||
On the side of the screen is displayed some vital information about your
|
||||
ship:
|
||||
.nf
|
||||
|
||||
Load D! R!
|
||||
Hull 9
|
||||
Hull 9
|
||||
Crew 4 4 2
|
||||
Guns 4 4
|
||||
Carr 2 2
|
||||
Guns 4 4
|
||||
Carr 2 2
|
||||
Rigg 5 5 5 5
|
||||
|
||||
.fi
|
||||
"Load" shows what your port (left) and starboard (right) broadsides are
|
||||
loaded with. A "!" after the type of shot indicates that it is an initial
|
||||
broadside. Initial broadside were loaded with care before battle and before
|
||||
the decks ran red with blood. As a consequence, initial broadsides are a
|
||||
little more effective than broadsides loaded later. A "*" after the type of
|
||||
shot indicates that the gun
|
||||
crews are still loading it, and you cannot fire yet. "Hull" shows how much
|
||||
hull you have left. "Crew" shows your three sections of crew. As your
|
||||
crew dies off, your ability to fire decreases. "Guns" and "Carr" show
|
||||
your port and starboard guns. As you lose guns, your ability to fire
|
||||
decreases. "Rigg" shows how much rigging you have on your 3 or 4 masts.
|
||||
loaded with.
|
||||
A "!" after the type of shot indicates that it is an initial broadside.
|
||||
Initial broadside were loaded with care before battle and before
|
||||
the decks ran red with blood.
|
||||
As a consequence, initial broadsides are a
|
||||
little more effective than broadsides loaded later.
|
||||
A "*" after the type of shot indicates that the gun
|
||||
crews are still loading it, and you cannot fire yet.
|
||||
"Hull" shows how much hull you have left.
|
||||
"Crew" shows your three sections of crew.
|
||||
As your crew dies off, your ability to fire decreases.
|
||||
"Guns" and "Carr" show your port and starboard guns.
|
||||
As you lose guns, your ability to fire decreases.
|
||||
"Rigg" shows how much rigging you have on your 3 or 4 masts.
|
||||
As rigging is shot away, you lose mobility.
|
||||
.SH EFFECTIVENESS OF FIRE
|
||||
It is very dramatic when a ship fires its thunderous broadsides, but the
|
||||
mere opportunity to fire them does not guarantee any hits. Many factors
|
||||
influence the destructive force of a broadside. First of all, and the chief
|
||||
factor, is distance. It is harder to hit a ship at range ten than it is
|
||||
to hit one sloshing alongside. Next is raking. Raking fire, as
|
||||
mentioned before,
|
||||
can sometimes dismast a ship at range ten. Next, crew size and quality affects
|
||||
the damage done by a broadside. The number of guns firing also bears on the
|
||||
point,
|
||||
so to speak. Lastly, weather affects the accuracy of a broadside. If the
|
||||
seas are high (5 or 6), then the lower gunports of ships of the line can't
|
||||
even be opened to run out the guns. This gives frigates and other flush
|
||||
decked vessels an advantage in a storm. The scenario
|
||||
mere opportunity to fire them does not guarantee any hits.
|
||||
Many factors influence the destructive force of a broadside.
|
||||
First of all, and the chief factor, is distance.
|
||||
It is harder to hit a ship at range ten than it is
|
||||
to hit one sloshing alongside.
|
||||
Next is raking.
|
||||
Raking fire, as mentioned before, can sometimes dismast a ship at range ten.
|
||||
Next, crew size and quality affects the damage done by a broadside.
|
||||
The number of guns firing also bears on the point, so to speak.
|
||||
Lastly, weather affects the accuracy of a broadside.
|
||||
If the seas are high (5 or 6), then the lower gunports
|
||||
of ships of the line can't even be opened to run out the guns.
|
||||
This gives frigates and other flush decked vessels an advantage in a storm.
|
||||
The scenario
|
||||
.I Pellew vs. The Droits de L'Homme
|
||||
takes advantage of this peculiar circumstance.
|
||||
.SH REPAIRS
|
||||
Repairs may be made to your Hull, Guns, and Rigging at the slow rate of
|
||||
two points per three turns. The message "Repairs Completed" will be
|
||||
printed if no more repairs can be made.
|
||||
two points per three turns.
|
||||
The message "Repairs Completed" will be printed if no more repairs can be made.
|
||||
.SH PECULIARITIES OF COMPUTER SHIPS
|
||||
Computer ships in
|
||||
Computer ships in
|
||||
.I Sail
|
||||
follow all the rules above with a few exceptions. Computer ships never
|
||||
repair damage. If they did, the players could never beat them. They
|
||||
play well enough as it is. As a consolation, the computer ships can fire double
|
||||
shot every turn. That fluke is a good reason to keep your distance. The
|
||||
.I
|
||||
Driver
|
||||
figures out the moves of the computer ships. It computes them with a typical
|
||||
A.I. distance function and a depth first search to find the maximum "score."
|
||||
follow all the rules above with a few exceptions.
|
||||
Computer ships never repair damage.
|
||||
If they did, the players could never beat them.
|
||||
They play well enough as it is.
|
||||
As a consolation, the computer ships can fire double shot every turn.
|
||||
That fluke is a good reason to keep your distance.
|
||||
The
|
||||
.I Driver
|
||||
figures out the moves of the computer ships.
|
||||
It computes them with a typical A.I. distance
|
||||
function and a depth first search to find the maximum "score."
|
||||
It seems to work fairly well, although I'll be the first to admit it isn't
|
||||
perfect.
|
||||
.SH HOW TO PLAY
|
||||
Commands are given to
|
||||
Commands are given to
|
||||
.I Sail
|
||||
by typing a single character. You will then be prompted for further
|
||||
input. A brief summary of the commands follows.
|
||||
by typing a single character.
|
||||
You will then be prompted for further input.
|
||||
A brief summary of the commands follows.
|
||||
.br
|
||||
.SH COMMAND SUMMARY
|
||||
.nf
|
||||
@@ -550,7 +625,7 @@ input. A brief summary of the commands follows.
|
||||
'f' Fire broadsides if they bear
|
||||
'l' Reload
|
||||
'L' Unload broadsides (to change ammo)
|
||||
'm' Move
|
||||
'm' Move
|
||||
'i' Print the closest ship
|
||||
'I' Print all ships
|
||||
'F' Find a particular ship or ships (e.g. "a?" for all Americans)
|
||||
@@ -575,7 +650,7 @@ input. A brief summary of the commands follows.
|
||||
.fi
|
||||
.bg
|
||||
.SH SCENARIOS
|
||||
Here is a summary of the scenarios in
|
||||
Here is a summary of the scenarios in
|
||||
.I Sail:
|
||||
|
||||
.br
|
||||
@@ -590,7 +665,8 @@ Wind from the N, blowing a fresh breeze.
|
||||
Wind from the S, blowing a fresh breeze.
|
||||
|
||||
.fi
|
||||
This is John Paul Jones' first famous battle. Aboard the Bonhomme
|
||||
This is John Paul Jones' first famous battle.
|
||||
Aboard the Bonhomme
|
||||
Richard, he was able to overcome the Serapis's greater firepower
|
||||
by quickly boarding her.
|
||||
.nf
|
||||
@@ -761,8 +837,9 @@ Wind from the N, blowing a fresh breeze.
|
||||
Wind from the E, blowing a gale.
|
||||
|
||||
.fi
|
||||
A scenario for you Horny fans. Remember, he sank the Natividad
|
||||
against heavy odds and winds. Hint: don't try to board the Natividad,
|
||||
A scenario for you Horny fans.
|
||||
Remember, he sank the Natividad against heavy odds and winds.
|
||||
Hint: don't try to board the Natividad,
|
||||
her crew is much bigger, albeit green.
|
||||
.nf
|
||||
|
||||
@@ -788,8 +865,10 @@ Wind from the S, blowing a strong breeze.
|
||||
.nf
|
||||
Wind from the E, blowing a fresh breeze.
|
||||
|
||||
The only battle Hornblower ever lost. He was able to dismast one
|
||||
ship and stern rake the others though. See if you can do as well.
|
||||
.fi
|
||||
The only battle Hornblower ever lost.
|
||||
He was able to dismast one ship and stern rake the others though.
|
||||
See if you can do as well.
|
||||
.nf
|
||||
|
||||
(b) Sutherland 74 gun Ship of the Line (crack crew) (26 pts)
|
||||
@@ -871,7 +950,7 @@ has been a group effort.
|
||||
.SH AUTHOR
|
||||
Dave Riggle
|
||||
.SH CO-AUTHOR
|
||||
Ed Wang
|
||||
Ed Wang
|
||||
.SH REFITTING
|
||||
Craig Leres
|
||||
.SH CONSULTANTS
|
||||
@@ -881,9 +960,9 @@ Captain Happy
|
||||
Horatio Nelson
|
||||
and many valiant others...
|
||||
.fi
|
||||
.SH "REFERENCES"
|
||||
.SH REFERENCES
|
||||
.nf
|
||||
Wooden Ships & Iron Men, by Avalon Hill
|
||||
Wooden Ships \*[Am] Iron Men, by Avalon Hill
|
||||
Captain Horatio Hornblower Novels, (13 of them) by C.S. Forester
|
||||
Captain Richard Bolitho Novels, (12 of them) by Alexander Kent
|
||||
The Complete Works of Captain Frederick Marryat, (about 20) especially
|
||||
|
||||
Reference in New Issue
Block a user