ship
Cleansnag(struct ship *from, struct ship *to, int all, int flag)
strike(struct ship *ship, struct ship *from)
if (ship->file->struck)
send_struck(ship, 1);
points = ship->specs->pts + from->file->points;
unboard(ship, ship, 0); /* all offense */
unboard(ship, ship, 1); /* all defense */
send_sink(ship, 1);
send_explode(ship, 1);
send_signal(ship, "striking her colours!");
static void strike(struct ship *, struct ship *);
table(struct ship *from, struct ship *on,
fightitout(struct ship *from, struct ship *to, int key)
struct ship *fromcap, *tocap;
struct ship *sp, *sq;
struct ship *sp;
struct ship *closest;
struct ship *s;
struct ship *bestship = NULL;
static int fightitout(struct ship *, struct ship *, int);
struct ship *sp;
struct ship *to;
struct ship *sp, *sq;
struct ship *sp;
closeon(struct ship *from, struct ship *to, char *command, size_t commandmax,
score(struct ship *ship, struct ship *to, char *movement, size_t movementmax,
struct File *fp = ship->file;
move_ship(ship, movement, &fp->dir, &fp->row, &fp->col, &drift);
ran = range(ship, to);
if (ran < 4 && gunsbear(ship, to))
if ((ran = portside(ship, to, 1) - fp->dir) == 4 || ran == -4)
move_ship(struct ship *ship, const char *p, unsigned char *dir,
if ((ship->specs->class >= 3 && !snagged(ship))
try(struct ship *f, struct ship *t,
static int score(struct ship *, struct ship *, char *, size_t, int);
static void move_ship(struct ship *, const char *, unsigned char *,
static void try(struct ship *f, struct ship *t,
struct ship *sp, *sq;
struct ship *sp, *sq;
struct ship *sp;
is_isolated(struct ship *ship)
struct ship *sp;
if (ship != sp && range(ship, sp) <= 10)
push(struct ship *from, struct ship *to)
step(struct ship *sp, int com, char *moved)
sendbp(struct ship *from, struct ship *to, int sections, int isdefense)
is_toughmelee(struct ship *ship, struct ship *to, int isdefense, int count)
qual = ship->specs->qual;
bp = isdefense ? ship->file->DBP : ship->file->OBP;
? ship->specs->crew1 * qual : 0;
? ship->specs->crew2 * qual : 0;
? ship->specs->crew3 * qual : 0;
OBP = is_toughmelee(to, ship, 0, count + 1);
dbp = is_toughmelee(ship, to, 1, count + 1);
DBP = is_toughmelee(to, ship, 1, count + 1);
struct ship *sp;
struct ship *sp;
struct ship *close;
static int is_isolated(struct ship *);
static int push(struct ship *, struct ship *);
static void step(struct ship *, int, char *);
struct ship *sp, *sq;
struct ship *closest;
ungrap(struct ship *from, struct ship *to)
grap(struct ship *from, struct ship *to)
subtract(struct ship *from, struct ship *fromcap, int totalfrom, int crewfrom[3],
mensent(struct ship *from, struct ship *to, int crew[3], struct ship **captured,
struct ship *sp;
struct ship *toship;
struct ship *captured; /* 68 */
struct ship ship[NSHIP]; /* 16 */
extern struct ship *ls; /* &cc->ship[cc->vessels] */
#define SHIP(s) (&cc->ship[s])
#define foreachship(sp) for ((sp) = cc->ship; (sp) < ls; (sp)++)
void table(struct ship *, struct ship *, int, int, int, int);
void Cleansnag(struct ship *, struct ship *, int, int);
void closeon(struct ship *, struct ship *, char *, size_t, int, int, bool);
void sendbp(struct ship *, struct ship *, int, int);
int is_toughmelee(struct ship *, struct ship *, int, int);
void ungrap(struct ship *, struct ship *);
void grap(struct ship *, struct ship *);
void subtract(struct ship *, struct ship *, int, int [3], int);
int mensent(struct ship *, struct ship *, int[3], struct ship **, int *, int);
int maxturns(struct ship *, bool *);
int maxmove(struct ship *, int, int);
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 *);
int meleeing(struct ship *, struct ship *);
int boarding(struct ship *, int);
void unboard(struct ship *, struct ship *, int);
const char *saywhat(struct ship *, int);
void eyeball(struct ship *);
void Signal(const char *, struct ship *, ...) __printflike(1,3);
int sgetch(const char *, struct ship *, int);
void fmtship(char *, size_t, const char *, struct ship *);
void makesignal(struct ship *, const char *, struct ship *, ...)
void makemsg(struct ship *, const char *, ...) __printflike(2, 3);
void send_captain(struct ship *ship, const char *astr);
void send_captured(struct ship *ship, long a);
void send_class(struct ship *ship, long a);
void send_crew(struct ship *ship, long a, long b, long c);
void send_dbp(struct ship *ship, long a, long b, long c, long d);
void send_drift(struct ship *ship, long a);
void send_explode(struct ship *ship, long a);
void send_foul(struct ship *ship, long a);
void send_gunl(struct ship *ship, long a, long b);
void send_gunr(struct ship *ship, long a, long b);
void send_hull(struct ship *ship, long a);
void send_move(struct ship *ship, const char *astr);
void send_obp(struct ship *ship, long a, long b, long c, long d);
void send_pcrew(struct ship *ship, long a);
void send_unfoul(struct ship *ship, long a, long b);
void send_points(struct ship *ship, long a);
void send_qual(struct ship *ship, long a);
void send_ungrap(struct ship *ship, long a, long b);
void send_rigg(struct ship *ship, long a, long b, long c, long d);
void send_col(struct ship *ship, long a);
void send_dir(struct ship *ship, long a);
void send_row(struct ship *ship, long a);
void send_signal(struct ship *ship, const char *astr);
void send_sink(struct ship *ship, long a);
void send_struck(struct ship *ship, long a);
void send_ta(struct ship *ship, long a);
void send_fs(struct ship *ship, long a);
void send_grap(struct ship *ship, long a);
void send_rig1(struct ship *ship, long a);
void send_rig2(struct ship *ship, long a);
void send_rig3(struct ship *ship, long a);
void send_rig4(struct ship *ship, long a);
void send_begin(struct ship *ship);
void send_end(struct ship *ship);
maxturns(struct ship *ship, bool *af)
turns = ship->specs->ta;
*af = (ship->file->drift > 1 && turns);
if (ship->file->FS == 1)
maxmove(struct ship *ship, int dir, int fs)
Move = ship->specs->bs;
if (!ship->specs->rig1)
if (!ship->specs->rig2)
if (!ship->specs->rig3)
if (!ship->specs->rig4)
if ((ship->file->FS || fs) && fs != -1) {
Move = ship->specs->fs;
Move -= 1 + WET[windspeed][ship->specs->class-1].B;
Move -= 1 + WET[windspeed][ship->specs->class-1].C;
Move = (flank ? 2 : 1) - WET[windspeed][ship->specs->class-1].D;
Move -= WET[windspeed][ship->specs->class-1].A;
struct ship *ls; /* &cc->ship[cc->vessels] */
ship = &scene[log.l_gamenum].ship[log.l_shipnum];
title[n++], sbuf, ship->shipname, log.l_netpoints,
(float) log.l_netpoints / ship->specs->pts);
struct ship *ship;
ship = &scene[log.l_gamenum].ship[log.l_shipnum];
title[n++], sbuf, ship->shipname, log.l_netpoints,
(float) log.l_netpoints / ship->specs->pts);
struct ship *ship;
gunsbear(struct ship *from, struct ship *to)
portside(struct ship *from, struct ship *on, int quick)
colours(struct ship *sp)
logger(struct ship *s)
/ scene[lp->l_gamenum].ship[lp->l_shipnum].specs->pts) {
range(struct ship *from, struct ship *to)
struct ship *
closestenemy(struct ship *from, int side, int anyship)
struct ship *sp;
struct ship *closest = 0;
meleeing(struct ship *from, struct ship *to)
boarding(struct ship *from, int isdefense)
unboard(struct ship *ship, struct ship *to, int isdefense)
struct BP *p = isdefense ? ship->file->DBP : ship->file->OBP;
(p->toship == to || isdefense || ship == to)) {
send_dbp(ship, n, 0, 0, 0);
send_obp(ship, n, 0, 0, 0);
struct ship *sp;
switch (sgetch("~ ", (struct ship *)0, 0)) {
(struct ship *)0, 1)) {
if (sgetch("Fire? ", (struct ship *)0, 1) == 'n') {
struct ship *sp;
struct ship *to;
struct ship *closest;
saywhat(struct ship *sp, int flag)
eyeball(struct ship *ship)
if (ship->file->dir != 0) {
range(ms, ship), saywhat(ship, 0));
i = portside(ms, ship, 1) - mf->dir;
ship, countryname[ship->nationality],
classname[ship->specs->class], directionname[i]);
(struct ship *)0, 1) == 'y') {
(struct ship *)0, 1) == 'y') {
struct ship *sp;
struct ship *sp;
(struct ship *)0, 1);
parties(struct ship *to, int *crew, int isdefense, int buf)
static void parties(struct ship *, int *, int, int);
(struct ship *)0, 1);
(struct ship *)0, 1);
c = sgetch("Repair (hull, guns, rigging)? ", (struct ship *)0, 1);
struct ship *ship;
ship = &scene[pickerpos].ship[i];
nationalityname(ship->nationality),
ship->shipname,
ship->specs->guns,
shortclassname[ship->specs->class],
qualname[ship->specs->qual],
ship->specs->pts);
Signal(const char *fmt, struct ship *ship, ...)
va_start(ap, ship);
fmtship(format, sizeof(format), fmt, ship);
prompt(const char *p, struct ship *ship)
fmtship(buf, sizeof(buf), p, ship);
sgetch(const char *p, struct ship *ship, int flag)
prompt(p, ship);
prompt(pr, (struct ship *)0);
struct ship *sp;
struct ship *sp;
struct ship *ms; /* memorial structure, &cc->ship[player] */
struct ship *sp;
struct ship *sp;
struct ship *sp;
extern struct ship *ms; /* memorial structure, &cc->ship[player] */
static void recv_captain(struct ship *ship, const char *astr);
static void recv_captured(struct ship *ship, long a);
static void recv_class(struct ship *ship, long a);
static void recv_crew(struct ship *ship, long a, long b, long c);
static void recv_dbp(struct ship *ship, long a, long b, long c, long d);
static void recv_drift(struct ship *ship, long a);
static void recv_explode(struct ship *ship, long a);
static void recv_foul(struct ship *ship, long a);
static void recv_gunl(struct ship *ship, long a, long b);
static void recv_gunr(struct ship *ship, long a, long b);
static void recv_hull(struct ship *ship, long a);
static void recv_move(struct ship *ship, const char *astr);
static void recv_obp(struct ship *ship, long a, long b, long c, long d);
static void recv_pcrew(struct ship *ship, long a);
static void recv_unfoul(struct ship *ship, long a, long b);
static void recv_points(struct ship *ship, long a);
static void recv_qual(struct ship *ship, long a);
static void recv_ungrap(struct ship *ship, long a, long b);
static void recv_rigg(struct ship *ship, long a, long b, long c, long d);
static void recv_col(struct ship *ship, long a);
static void recv_dir(struct ship *ship, long a);
static void recv_row(struct ship *ship, long a);
static void recv_signal(struct ship *ship, const char *astr);
static void recv_sink(struct ship *ship, long a);
static void recv_struck(struct ship *ship, long a);
static void recv_ta(struct ship *ship, long a);
static void recv_fs(struct ship *ship, long a);
static void recv_grap(struct ship *ship, long a);
static void recv_rig1(struct ship *ship, long a);
static void recv_rig2(struct ship *ship, long a);
static void recv_rig3(struct ship *ship, long a);
static void recv_rig4(struct ship *ship, long a);
static void recv_begin(struct ship *ship);
static void recv_end(struct ship *ship);
static void Write(int, struct ship *, long, long, long, long);
static void Writestr(int, struct ship *, const char *);
static int sync_update(int, struct ship *, const char *,
fmtship(char *buf, size_t len, const char *fmt, struct ship *ship)
ship->shipname, colours(ship), sterncolour(ship));
makesignal(struct ship *from, const char *fmt, struct ship *ship, ...)
va_start(ap, ship);
fmtship(format, sizeof(format), fmt, ship);
makemsg(struct ship *from, const char *fmt, ...)
Write(int type, struct ship *ship, long a, long b, long c, long d)
int shipindex = (ship == NULL) ? 0 : ship->file->index;
sync_update(type, ship, NULL, a, b, c, d);
Writestr(int type, struct ship *ship, const char *a)
int shipindex = (ship == NULL) ? 0 : ship->file->index;
sync_update(type, ship, a, 0, 0, 0, 0);
sync_update(int type, struct ship *ship, const char *astr,
case W_CAPTAIN: recv_captain(ship, astr); break;
case W_CAPTURED: recv_captured(ship, a); break;
case W_CLASS: recv_class(ship, a); break;
case W_CREW: recv_crew(ship, a, b, c); break;
case W_DBP: recv_dbp(ship, a, b, c, d); break;
case W_DRIFT: recv_drift(ship, a); break;
case W_EXPLODE: recv_explode(ship, a); break;
case W_FOUL: recv_foul(ship, a); break;
case W_GUNL: recv_gunl(ship, a, b); break;
case W_GUNR: recv_gunr(ship, a, b); break;
case W_HULL: recv_hull(ship, a); break;
case W_MOVE: recv_move(ship, astr); break;
case W_OBP: recv_obp(ship, a, b, c, d); break;
case W_PCREW: recv_pcrew(ship, a); break;
case W_UNFOUL: recv_unfoul(ship, a, b); break;
case W_POINTS: recv_points(ship, a); break;
case W_QUAL: recv_qual(ship, a); break;
case W_UNGRAP: recv_ungrap(ship, a, b); break;
case W_RIGG: recv_rigg(ship, a, b, c, d); break;
case W_COL: recv_col(ship, a); break;
case W_DIR: recv_dir(ship, a); break;
case W_ROW: recv_row(ship, a); break;
case W_SIGNAL: recv_signal(ship, astr); break;
case W_SINK: recv_sink(ship, a); break;
case W_STRUCK: recv_struck(ship, a); break;
case W_TA: recv_ta(ship, a); break;
case W_FS: recv_fs(ship, a); break;
case W_GRAP: recv_grap(ship, a); break;
case W_RIG1: recv_rig1(ship, a); break;
case W_RIG2: recv_rig2(ship, a); break;
case W_RIG3: recv_rig3(ship, a); break;
case W_RIG4: recv_rig4(ship, a); break;
case W_BEGIN: recv_begin(ship); break;
case W_END: recv_end(ship); break;
send_captain(struct ship *ship, const char *astr)
Writestr(W_CAPTAIN, ship, astr);
send_captured(struct ship *ship, long a)
Write(W_CAPTURED, ship, a, 0, 0, 0);
send_class(struct ship *ship, long a)
Write(W_CLASS, ship, a, 0, 0, 0);
send_crew(struct ship *ship, long a, long b, long c)
Write(W_CREW, ship, a, b, c, 0);
send_dbp(struct ship *ship, long a, long b, long c, long d)
Write(W_DBP, ship, a, b, c, d);
send_drift(struct ship *ship, long a)
Write(W_DRIFT, ship, a, 0, 0, 0);
send_explode(struct ship *ship, long a)
Write(W_EXPLODE, ship, a, 0, 0, 0);
send_foul(struct ship *ship, long a)
Write(W_FOUL, ship, a, 0, 0, 0);
send_gunl(struct ship *ship, long a, long b)
Write(W_GUNL, ship, a, b, 0, 0);
send_gunr(struct ship *ship, long a, long b)
Write(W_GUNR, ship, a, b, 0, 0);
send_hull(struct ship *ship, long a)
Write(W_HULL, ship, a, 0, 0, 0);
send_move(struct ship *ship, const char *astr)
Writestr(W_MOVE, ship, astr);
send_obp(struct ship *ship, long a, long b, long c, long d)
Write(W_OBP, ship, a, b, c, d);
send_pcrew(struct ship *ship, long a)
Write(W_PCREW, ship, a, 0, 0, 0);
send_unfoul(struct ship *ship, long a, long b)
Write(W_UNFOUL, ship, a, b, 0, 0);
send_points(struct ship *ship, long a)
Write(W_POINTS, ship, a, 0, 0, 0);
send_qual(struct ship *ship, long a)
Write(W_QUAL, ship, a, 0, 0, 0);
send_ungrap(struct ship *ship, long a, long b)
Write(W_UNGRAP, ship, a, b, 0, 0);
send_rigg(struct ship *ship, long a, long b, long c, long d)
Write(W_RIGG, ship, a, b, c, d);
send_col(struct ship *ship, long a)
Write(W_COL, ship, a, 0, 0, 0);
send_dir(struct ship *ship, long a)
Write(W_DIR, ship, a, 0, 0, 0);
send_row(struct ship *ship, long a)
Write(W_ROW, ship, a, 0, 0, 0);
send_signal(struct ship *ship, const char *astr)
Writestr(W_SIGNAL, ship, astr);
send_sink(struct ship *ship, long a)
Write(W_SINK, ship, a, 0, 0, 0);
send_struck(struct ship *ship, long a)
Write(W_STRUCK, ship, a, 0, 0, 0);
send_ta(struct ship *ship, long a)
Write(W_TA, ship, a, 0, 0, 0);
send_fs(struct ship *ship, long a)
Write(W_FS, ship, a, 0, 0, 0);
send_grap(struct ship *ship, long a)
Write(W_GRAP, ship, a, 0, 0, 0);
send_rig1(struct ship *ship, long a)
Write(W_RIG1, ship, a, 0, 0, 0);
send_rig2(struct ship *ship, long a)
Write(W_RIG2, ship, a, 0, 0, 0);
send_rig3(struct ship *ship, long a)
Write(W_RIG3, ship, a, 0, 0, 0);
send_rig4(struct ship *ship, long a)
Write(W_RIG4, ship, a, 0, 0, 0);
send_begin(struct ship *ship)
Write(W_BEGIN, ship, 0, 0, 0, 0);
send_end(struct ship *ship)
Write(W_END, ship, 0, 0, 0, 0);
recv_captain(struct ship *ship, const char *astr)
strlcpy(ship->file->captain, astr, sizeof ship->file->captain);
recv_captured(struct ship *ship, long a)
ship->file->captured = 0;
ship->file->captured = SHIP(a);
recv_class(struct ship *ship, long a)
ship->specs->class = a;
recv_crew(struct ship *ship, long a, long b, long c)
struct shipspecs *s = ship->specs;
recv_dbp(struct ship *ship, long a, long b, long c, long d)
struct BP *p = &ship->file->DBP[a];
recv_drift(struct ship *ship, long a)
ship->file->drift = a;
recv_explode(struct ship *ship, long a)
if ((ship->file->explode = a) == 2)
ship->file->dir = 0;
recv_foul(struct ship *ship, long a)
struct snag *p = &ship->file->foul[a];
ship->file->nfoul++;
recv_gunl(struct ship *ship, long a, long b)
struct shipspecs *s = ship->specs;
recv_gunr(struct ship *ship, long a, long b)
struct shipspecs *s = ship->specs;
recv_hull(struct ship *ship, long a)
ship->specs->hull = a;
recv_move(struct ship *ship, const char *astr)
strlcpy(ship->file->movebuf, astr, sizeof ship->file->movebuf);
recv_obp(struct ship *ship, long a, long b, long c, long d)
struct BP *p = &ship->file->OBP[a];
recv_pcrew(struct ship *ship, long a)
ship->file->pcrew = a;
recv_unfoul(struct ship *ship, long a, long b)
struct snag *p = &ship->file->foul[a];
ship->file->nfoul -= p->sn_count;
ship->file->nfoul--;
recv_points(struct ship *ship, long a)
ship->file->points = a;
recv_qual(struct ship *ship, long a)
ship->specs->qual = a;
recv_ungrap(struct ship *ship, long a, long b)
struct snag *p = &ship->file->grap[a];
ship->file->ngrap -= p->sn_count;
ship->file->ngrap--;
recv_rigg(struct ship *ship, long a, long b, long c, long d)
struct shipspecs *s = ship->specs;
recv_col(struct ship *ship, long a)
ship->file->col = a;
recv_dir(struct ship *ship, long a)
ship->file->dir = a;
recv_row(struct ship *ship, long a)
ship->file->row = a;
recv_signal(struct ship *ship, const char *astr)
Signal("$$: %s", ship, astr);
Signal("\a$$: %s", ship, astr);
recv_sink(struct ship *ship, long a)
if ((ship->file->sink = a) == 2)
ship->file->dir = 0;
recv_struck(struct ship *ship, long a)
ship->file->struck = a;
recv_ta(struct ship *ship, long a)
ship->specs->ta = a;
recv_fs(struct ship *ship, long a)
ship->file->FS = a;
recv_grap(struct ship *ship, long a)
struct snag *p = &ship->file->grap[a];
ship->file->ngrap++;
recv_rig1(struct ship *ship, long a)
ship->specs->rig1 = a;
recv_rig2(struct ship *ship, long a)
ship->specs->rig2 = a;
recv_rig3(struct ship *ship, long a)
ship->specs->rig3 = a;
recv_rig4(struct ship *ship, long a)
ship->specs->rig4 = a;
recv_begin(struct ship *ship)
strcpy(ship->file->captain, "begin");
recv_end(struct ship *ship)
*ship->file->captain = 0;
ship->file->points = 0;
Ship.ship = QUEENE;
if (Ship.ship == QUEENE) {
Sect[dx][dy] = Ship.ship;
Sect[Ship.sectx][Ship.secty] = Ship.ship;
Sect[Ship.sectx][Ship.secty] = Ship.ship;
if (Ship.ship != ENTERPRISE) {
Ship.ship = ENTERPRISE;
if (Ship.ship == QUEENE) {
char ship; /* current starship */
s >= 1000 && Ship.ship == ENTERPRISE) {