summaryrefslogtreecommitdiffstats
path: root/sail
diff options
context:
space:
mode:
authordholland <dholland@NetBSD.org>2009-03-14 22:52:52 +0000
committerdholland <dholland@NetBSD.org>2009-03-14 22:52:52 +0000
commite98a44895c7ca5a00b080fce0b3cbb16bcdff859 (patch)
treea74a3e03e0056c3de3d2b751b6dea1f59baec1c7 /sail
parent5e8d1f0902b592fc872212ecccaca23c8ce85231 (diff)
downloadbsdgames-darwin-e98a44895c7ca5a00b080fce0b3cbb16bcdff859.tar.gz
bsdgames-darwin-e98a44895c7ca5a00b080fce0b3cbb16bcdff859.zip
Create some abstraction for sending messages.
Make a send and receive function for each possible message. Make these have useful argument signatures. Hide the list of message codes inside sync.c.
Diffstat (limited to 'sail')
-rw-r--r--sail/assorted.c42
-rw-r--r--sail/dr_1.c23
-rw-r--r--sail/dr_2.c21
-rw-r--r--sail/dr_3.c25
-rw-r--r--sail/dr_4.c8
-rw-r--r--sail/dr_5.c8
-rw-r--r--sail/extern.h84
-rw-r--r--sail/parties.c17
-rw-r--r--sail/pl_1.c6
-rw-r--r--sail/pl_3.c8
-rw-r--r--sail/pl_4.c10
-rw-r--r--sail/pl_5.c17
-rw-r--r--sail/pl_6.c20
-rw-r--r--sail/pl_7.c12
-rw-r--r--sail/pl_main.c10
-rw-r--r--sail/sync.c873
16 files changed, 843 insertions, 341 deletions
diff --git a/sail/assorted.c b/sail/assorted.c
index 008fa630..7aa68739 100644
--- a/sail/assorted.c
+++ b/sail/assorted.c
@@ -1,4 +1,4 @@
-/* $NetBSD: assorted.c,v 1.16 2009/03/14 19:35:13 dholland Exp $ */
+/* $NetBSD: assorted.c,v 1.17 2009/03/14 22:52:52 dholland Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)assorted.c 8.2 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: assorted.c,v 1.16 2009/03/14 19:35:13 dholland Exp $");
+__RCSID("$NetBSD: assorted.c,v 1.17 2009/03/14 22:52:52 dholland Exp $");
#endif
#endif /* not lint */
@@ -133,19 +133,23 @@ table(struct ship *from, struct ship *on,
ghits = 0;
}
hull -= ghits;
- if (Ghit)
- Write(portside(from, on, 0) ? W_GUNR : W_GUNL,
- on, guns, car, 0, 0);
+ if (Ghit) {
+ if (portside(from, on, 0)) {
+ send_gunr(on, guns, car);
+ } else {
+ send_gunl(on, guns, car);
+ }
+ }
hull -= hhits;
hull = hull < 0 ? 0 : hull;
if (on->file->captured != 0 && Chit)
- Write(W_PCREW, on, pc, 0, 0, 0);
+ send_pcrew(on, pc);
if (Hhit)
- Write(W_HULL, on, hull, 0, 0, 0);
+ send_hull(on, hull);
if (Chit)
- Write(W_CREW, on, crew[0], crew[1], crew[2], 0);
+ send_crew(on, crew[0], crew[1], crew[2]);
if (Rhit)
- Write(W_RIGG, on, rigg[0], rigg[1], rigg[2], rigg[3]);
+ send_rigg(on, rigg[0], rigg[1], rigg[2], rigg[3]);
switch (shot) {
case L_ROUND:
message = "firing round shot on $$";
@@ -213,7 +217,7 @@ table(struct ship *from, struct ship *on,
break;
case 5:
message = "rudder cables shot through";
- Write(W_TA, on, 0, 0, 0, 0);
+ send_ta(on, 0);
break;
case 6:
message = "shot holes below the water line";
@@ -245,12 +249,12 @@ void
Cleansnag(struct ship *from, struct ship *to, int all, int flag)
{
if (flag & 1) {
- Write(W_UNGRAP, from, to->file->index, all, 0, 0);
- Write(W_UNGRAP, to, from->file->index, all, 0, 0);
+ send_ungrap(from, to->file->index, all);
+ send_ungrap(to, from->file->index, all);
}
if (flag & 2) {
- Write(W_UNFOUL, from, to->file->index, all, 0, 0);
- Write(W_UNFOUL, to, from->file->index, all, 0, 0);
+ send_unfoul(from, to->file->index, all);
+ send_unfoul(to, from->file->index, all);
}
if (!snagged2(from, to)) {
if (!snagged(from)) {
@@ -273,20 +277,20 @@ strike(struct ship *ship, struct ship *from)
if (ship->file->struck)
return;
- Write(W_STRUCK, ship, 1, 0, 0, 0);
+ send_struck(ship, 1);
points = ship->specs->pts + from->file->points;
- Write(W_POINTS, from, points, 0, 0, 0);
+ send_points(from, points);
unboard(ship, ship, 0); /* all offense */
unboard(ship, ship, 1); /* all defense */
switch (dieroll()) {
case 3:
case 4: /* ship may sink */
- Write(W_SINK, ship, 1, 0, 0, 0);
+ send_sink(ship, 1);
break;
case 5:
case 6: /* ship may explode */
- Write(W_EXPLODE, ship, 1, 0, 0, 0);
+ send_explode(ship, 1);
break;
}
- Writestr(W_SIGNAL, ship, "striking her colours!");
+ send_signal(ship, "striking her colours!");
}
diff --git a/sail/dr_1.c b/sail/dr_1.c
index a1512821..3a332410 100644
--- a/sail/dr_1.c
+++ b/sail/dr_1.c
@@ -1,4 +1,4 @@
-/* $NetBSD: dr_1.c,v 1.26 2009/03/14 19:55:16 dholland Exp $ */
+/* $NetBSD: dr_1.c,v 1.27 2009/03/14 22:52:52 dholland Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)dr_1.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: dr_1.c,v 1.26 2009/03/14 19:55:16 dholland Exp $");
+__RCSID("$NetBSD: dr_1.c,v 1.27 2009/03/14 22:52:52 dholland Exp $");
#endif
#endif /* not lint */
@@ -193,7 +193,7 @@ fightitout(struct ship *from, struct ship *to, int key)
snprintf(message, sizeof(message),
"killed in melee: %d. %s: %d",
totalto, from->shipname, totalfrom);
- Writestr(W_SIGNAL, to, message);
+ send_signal(to, message);
if (key)
return 1;
} else if (strengthto >= fromstrength * 3) {
@@ -202,18 +202,17 @@ fightitout(struct ship *from, struct ship *to, int key)
subtract(to, tocap, totalto, crewto, pcto);
if (key) {
if (fromcap != from)
- Write(W_POINTS, fromcap,
+ send_points(fromcap,
fromcap->file->points -
from->file->struck
? from->specs->pts
- : 2 * from->specs->pts,
- 0, 0, 0);
+ : 2 * from->specs->pts);
- Write(W_CAPTURED, from, to->file->index, 0, 0, 0);
+ send_captured(from, to->file->index);
topoints = 2 * from->specs->pts + to->file->points;
if (from->file->struck)
topoints -= from->specs->pts;
- Write(W_POINTS, to, topoints, 0, 0, 0);
+ send_points(to, topoints);
mento = crewto[0] ? crewto[0] : crewto[1];
if (mento) {
subtract(to, tocap, mento, crewto, pcto);
@@ -221,11 +220,11 @@ fightitout(struct ship *from, struct ship *to, int key)
}
snprintf(message, sizeof(message),
"captured by the %s!", to->shipname);
- Writestr(W_SIGNAL, from, message);
+ send_signal(from, message);
snprintf(message, sizeof(message),
"killed in melee: %d. %s: %d",
totalto, from->shipname, totalfrom);
- Writestr(W_SIGNAL, to, message);
+ send_signal(to, message);
mento = 0;
return 0;
}
@@ -437,7 +436,7 @@ next(void)
}
return -1;
}
- Write(W_TURN, SHIP(0), turn, 0, 0, 0);
+ send_turn(turn);
if (turn % 7 == 0 && (dieroll() >= cc->windchange || !windspeed)) {
switch (dieroll()) {
case 1:
@@ -475,7 +474,7 @@ next(void)
}
else
windspeed++;
- Write(W_WIND, SHIP(0), winddir, windspeed, 0, 0);
+ send_wind( winddir, windspeed);
}
return 0;
}
diff --git a/sail/dr_2.c b/sail/dr_2.c
index 460f24ff..a761fb1d 100644
--- a/sail/dr_2.c
+++ b/sail/dr_2.c
@@ -1,4 +1,4 @@
-/* $NetBSD: dr_2.c,v 1.24 2009/03/14 20:04:43 dholland Exp $ */
+/* $NetBSD: dr_2.c,v 1.25 2009/03/14 22:52:52 dholland Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)dr_2.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: dr_2.c,v 1.24 2009/03/14 20:04:43 dholland Exp $");
+__RCSID("$NetBSD: dr_2.c,v 1.25 2009/03/14 22:52:52 dholland Exp $");
#endif
#endif /* not lint */
@@ -105,8 +105,12 @@ checkup(void)
continue;
if (dieroll() < 5)
continue;
- Write(sink == 1 ? W_SINK : W_EXPLODE, sp, 2, 0, 0, 0);
- Write(W_DIR, sp, 0, 0, 0, 0);
+ if (sink == 1) {
+ send_sink(sp, 2);
+ } else {
+ send_explode(sp, 2);
+ }
+ send_dir(sp, 0);
if (snagged(sp))
foreachship(sq)
cleansnag(sp, sq, 1);
@@ -136,12 +140,11 @@ prizecheck(void)
continue;
if (sp->specs->crew1 + sp->specs->crew2 + sp->specs->crew3 >
sp->file->pcrew * 6) {
- Writestr(W_SIGNAL, sp, "prize crew overthrown");
- Write(W_POINTS, sp->file->captured,
+ send_signal(sp, "prize crew overthrown");
+ send_points(sp->file->captured,
sp->file->captured->file->points
- - 2 * sp->specs->pts,
- 0, 0, 0);
- Write(W_CAPTURED, sp, -1, 0, 0, 0);
+ - 2 * sp->specs->pts);
+ send_captured(sp, -1);
}
}
}
diff --git a/sail/dr_3.c b/sail/dr_3.c
index 8d880c34..eb0280ea 100644
--- a/sail/dr_3.c
+++ b/sail/dr_3.c
@@ -1,4 +1,4 @@
-/* $NetBSD: dr_3.c,v 1.18 2009/03/14 20:04:43 dholland Exp $ */
+/* $NetBSD: dr_3.c,v 1.19 2009/03/14 22:52:52 dholland Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)dr_3.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: dr_3.c,v 1.18 2009/03/14 20:04:43 dholland Exp $");
+__RCSID("$NetBSD: dr_3.c,v 1.19 2009/03/14 22:52:52 dholland Exp $");
#endif
#endif /* not lint */
@@ -143,8 +143,8 @@ moveall(void)
if (dieroll() < 4) {
makesignal(sp, "fouled with $$",
sq);
- Write(W_FOUL, sp, l, 0, 0, 0);
- Write(W_FOUL, sq, n, 0, 0, 0);
+ send_foul(sp, l);
+ send_foul(sq, n);
}
snap++;
}
@@ -175,13 +175,13 @@ moveall(void)
if (sp->file->dir != 0) {
*sp->file->movebuf = 0;
if (row[n] != sp->file->row)
- Write(W_ROW, sp, sp->file->row, 0, 0, 0);
+ send_row(sp, sp->file->row);
if (col[n] != sp->file->col)
- Write(W_COL, sp, sp->file->col, 0, 0, 0);
+ send_col(sp, sp->file->col);
if (dir[n] != sp->file->dir)
- Write(W_DIR, sp, sp->file->dir, 0, 0, 0);
+ send_dir(sp, sp->file->dir);
if (drift[n] != sp->file->drift)
- Write(W_DRIFT, sp, sp->file->drift, 0, 0, 0);
+ send_drift(sp, sp->file->drift);
}
n++;
}
@@ -275,8 +275,11 @@ sendbp(struct ship *from, struct ship *to, int sections, int isdefense)
for (n = 0; n < NBP && bp[n].turnsent; n++)
;
if (n < NBP && sections) {
- Write(isdefense ? W_DBP : W_OBP, from,
- n, turn, to->file->index, sections);
+ if (isdefense) {
+ send_dbp(from, n, turn, to->file->index, sections);
+ } else {
+ send_obp(from, n, turn, to->file->index, sections);
+ }
if (isdefense)
makemsg(from, "repelling boarders");
else
@@ -352,6 +355,6 @@ checksails(void)
full = 0;
}
if ((sp->file->FS != 0) != full)
- Write(W_FS, sp, full, 0, 0, 0);
+ send_fs(sp, full);
}
}
diff --git a/sail/dr_4.c b/sail/dr_4.c
index 347ca86b..db45a258 100644
--- a/sail/dr_4.c
+++ b/sail/dr_4.c
@@ -1,4 +1,4 @@
-/* $NetBSD: dr_4.c,v 1.14 2009/03/14 19:35:13 dholland Exp $ */
+/* $NetBSD: dr_4.c,v 1.15 2009/03/14 22:52:52 dholland Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)dr_4.c 8.2 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: dr_4.c,v 1.14 2009/03/14 19:35:13 dholland Exp $");
+__RCSID("$NetBSD: dr_4.c,v 1.15 2009/03/14 22:52:52 dholland Exp $");
#endif
#endif /* not lint */
@@ -64,7 +64,7 @@ grap(struct ship *from, struct ship *to)
if (capship(from)->nationality != capship(to)->nationality &&
dieroll() > 2)
return;
- Write(W_GRAP, from, to->file->index, 0, 0, 0);
- Write(W_GRAP, to, from->file->index, 0, 0, 0);
+ send_grap(from, to->file->index);
+ send_grap(to, from->file->index);
makesignal(from, "grappled with $$", to);
}
diff --git a/sail/dr_5.c b/sail/dr_5.c
index 7fab0b48..5846ccbb 100644
--- a/sail/dr_5.c
+++ b/sail/dr_5.c
@@ -1,4 +1,4 @@
-/* $NetBSD: dr_5.c,v 1.13 2009/03/14 19:35:13 dholland Exp $ */
+/* $NetBSD: dr_5.c,v 1.14 2009/03/14 22:52:52 dholland Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)dr_5.c 8.2 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: dr_5.c,v 1.13 2009/03/14 19:35:13 dholland Exp $");
+__RCSID("$NetBSD: dr_5.c,v 1.14 2009/03/14 22:52:52 dholland Exp $");
#endif
#endif /* not lint */
@@ -57,11 +57,11 @@ subtract(struct ship *from, struct ship *fromcap, int totalfrom, int *crewfrom,
totalfrom = 0;
}
}
- Write(W_CREW, from, crewfrom[0], crewfrom[1], crewfrom[2], 0);
+ send_crew(from, crewfrom[0], crewfrom[1], crewfrom[2]);
} else if (totalfrom) {
pcfrom -= totalfrom;
pcfrom = pcfrom < 0 ? 0 : pcfrom;
- Write(W_PCREW, from, pcfrom, 0, 0, 0);
+ send_pcrew(from, pcfrom);
}
}
diff --git a/sail/extern.h b/sail/extern.h
index 485d7db6..04090f79 100644
--- a/sail/extern.h
+++ b/sail/extern.h
@@ -1,4 +1,4 @@
-/* $NetBSD: extern.h,v 1.31 2009/03/14 20:04:43 dholland Exp $ */
+/* $NetBSD: extern.h,v 1.32 2009/03/14 22:52:52 dholland Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -101,46 +101,6 @@ extern gid_t egid;
#define HULL 0
#define RIGGING 1
-#define W_CAPTAIN 1
-#define W_CAPTURED 2
-#define W_CLASS 3
-#define W_CREW 4
-#define W_DBP 5
-#define W_DRIFT 6
-#define W_EXPLODE 7
-#define W_FILE 8
-#define W_FOUL 9
-#define W_GUNL 10
-#define W_GUNR 11
-#define W_HULL 12
-#define W_MOVE 13
-#define W_OBP 14
-#define W_PCREW 15
-#define W_UNFOUL 16
-#define W_POINTS 17
-#define W_QUAL 18
-#define W_UNGRAP 19
-#define W_RIGG 20
-#define W_COL 21
-#define W_DIR 22
-#define W_ROW 23
-#define W_SIGNAL 24
-#define W_SINK 25
-#define W_STRUCK 26
-#define W_TA 27
-#define W_ALIVE 28
-#define W_TURN 29
-#define W_WIND 30
-#define W_FS 31
-#define W_GRAP 32
-#define W_RIG1 33
-#define W_RIG2 34
-#define W_RIG3 35
-#define W_RIG4 36
-#define W_BEGIN 37
-#define W_END 38
-#define W_DDEAD 39
-
#define NLOG 10
struct logs {
char l_name[20];
@@ -410,6 +370,44 @@ void makemsg(struct ship *, const char *, ...)
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);
+
+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_file(void);
+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_alive(void);
+void send_turn(long a);
+void send_wind(long a, long b);
+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);
+void send_ddead(void);
diff --git a/sail/parties.c b/sail/parties.c
index d55e4620..43e94416 100644
--- a/sail/parties.c
+++ b/sail/parties.c
@@ -1,4 +1,4 @@
-/* $NetBSD: parties.c,v 1.11 2003/08/07 09:37:43 agc Exp $ */
+/* $NetBSD: parties.c,v 1.12 2009/03/14 22:52:52 dholland Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)parties.c 8.2 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: parties.c,v 1.11 2003/08/07 09:37:43 agc Exp $");
+__RCSID("$NetBSD: parties.c,v 1.12 2009/03/14 22:52:52 dholland Exp $");
#endif
#endif /* not lint */
@@ -71,7 +71,14 @@ 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, n, 0, 0, 0);
+ for (n = 0; n < NBP; p++, n++) {
+ if (p->turnsent &&
+ (p->toship == to || isdefense || ship == to)) {
+ if (isdefense) {
+ send_dbp(ship, n, 0, 0, 0);
+ } else {
+ send_obp(ship, n, 0, 0, 0);
+ }
+ }
+ }
}
diff --git a/sail/pl_1.c b/sail/pl_1.c
index 8bb4b832..9dae48d9 100644
--- a/sail/pl_1.c
+++ b/sail/pl_1.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pl_1.c,v 1.20 2009/03/14 20:14:56 dholland Exp $ */
+/* $NetBSD: pl_1.c,v 1.21 2009/03/14 22:52:52 dholland Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)pl_1.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: pl_1.c,v 1.20 2009/03/14 20:14:56 dholland Exp $");
+__RCSID("$NetBSD: pl_1.c,v 1.21 2009/03/14 22:52:52 dholland Exp $");
#endif
#endif /* not lint */
@@ -107,7 +107,7 @@ leave(int conditions)
if (conditions != LEAVE_SYNC) {
makemsg(ms, "Captain %s relinquishing.",
mf->captain);
- Write(W_END, ms, 0, 0, 0, 0);
+ send_end(ms);
Sync();
}
}
diff --git a/sail/pl_3.c b/sail/pl_3.c
index 36552faa..58774e01 100644
--- a/sail/pl_3.c
+++ b/sail/pl_3.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pl_3.c,v 1.18 2009/03/14 19:35:13 dholland Exp $ */
+/* $NetBSD: pl_3.c,v 1.19 2009/03/14 22:52:52 dholland Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)pl_3.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: pl_3.c,v 1.18 2009/03/14 19:35:13 dholland Exp $");
+__RCSID("$NetBSD: pl_3.c,v 1.19 2009/03/14 22:52:52 dholland Exp $");
#endif
#endif /* not lint */
@@ -233,8 +233,8 @@ grapungrap(void)
case 'g':
if (dieroll() < 3
|| ms->nationality == capship(sp)->nationality) {
- Write(W_GRAP, ms, sp->file->index, 0, 0, 0);
- Write(W_GRAP, sp, player, 0, 0, 0);
+ send_grap(ms, sp->file->index);
+ send_grap(sp, player);
Msg("Attempt succeeds!");
makesignal(ms, "grappled with $$", sp);
} else
diff --git a/sail/pl_4.c b/sail/pl_4.c
index 7958b56e..710be027 100644
--- a/sail/pl_4.c
+++ b/sail/pl_4.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pl_4.c,v 1.15 2004/11/05 21:30:32 dsl Exp $ */
+/* $NetBSD: pl_4.c,v 1.16 2009/03/14 22:52:52 dholland Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)pl_4.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: pl_4.c,v 1.15 2004/11/05 21:30:32 dsl Exp $");
+__RCSID("$NetBSD: pl_4.c,v 1.16 2009/03/14 22:52:52 dholland Exp $");
#endif
#endif /* not lint */
@@ -57,12 +57,12 @@ changesail(void)
if (sgetch("Increase to Full sails? ",
(struct ship *)0, 1) == 'y') {
changed = 1;
- Write(W_FS, ms, 1, 0, 0, 0);
+ send_fs(ms, 1);
}
} else {
if (sgetch("Reduce to Battle sails? ",
(struct ship *)0, 1) == 'y') {
- Write(W_FS, ms, 0, 0, 0, 0);
+ send_fs(ms, 0);
changed = 1;
}
}
@@ -82,7 +82,7 @@ acceptsignal(void)
;
p[-1] = '"';
*p = 0;
- Writestr(W_SIGNAL, ms, buf);
+ send_signal(ms, buf);
}
void
diff --git a/sail/pl_5.c b/sail/pl_5.c
index 06b9fa51..09dd902f 100644
--- a/sail/pl_5.c
+++ b/sail/pl_5.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pl_5.c,v 1.22 2009/03/14 20:04:43 dholland Exp $ */
+/* $NetBSD: pl_5.c,v 1.23 2009/03/14 22:52:52 dholland Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)pl_5.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: pl_5.c,v 1.22 2009/03/14 20:04:43 dholland Exp $");
+__RCSID("$NetBSD: pl_5.c,v 1.23 2009/03/14 22:52:52 dholland Exp $");
#endif
#endif /* not lint */
@@ -133,7 +133,7 @@ acceptmove(void)
Msg("Movement error.");
if (ta < 0 && moved) {
if (mf->FS == 1) {
- Write(W_FS, ms, 0, 0, 0, 0);
+ send_fs(ms, 0);
Msg("No hands to set full sails.");
}
} else if (ma >= 0)
@@ -141,7 +141,7 @@ acceptmove(void)
}
if (af && !moved) {
if (mf->FS == 1) {
- Write(W_FS, ms, 0, 0, 0, 0);
+ send_fs(ms, 0);
Msg("No hands to set full sails.");
}
}
@@ -149,7 +149,7 @@ acceptmove(void)
strlcpy(movebuf, buf, sizeof(movebuf));
else
strlcpy(movebuf, "d", sizeof(movebuf));
- Writestr(W_MOVE, ms, movebuf);
+ send_move(ms, movebuf);
Msg("Helm: %s.", movebuf);
}
@@ -231,8 +231,11 @@ parties(struct ship *to, int *crew, int isdefense, int buf)
}
if (buf > '0')
Msg("Sending all crew sections.");
- Write(isdefense ? W_DBP : W_OBP, ms,
- j, turn, to->file->index, men);
+ if (isdefense) {
+ send_dbp(ms, j, turn, to->file->index, men);
+ } else {
+ send_obp(ms, j, turn, to->file->index, men);
+ }
if (isdefense) {
wmove(slot_w, 2, 0);
for (k=0; k < NBP; k++)
diff --git a/sail/pl_6.c b/sail/pl_6.c
index 1fc1cac6..0d65fcb6 100644
--- a/sail/pl_6.c
+++ b/sail/pl_6.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pl_6.c,v 1.12 2009/03/14 19:35:13 dholland Exp $ */
+/* $NetBSD: pl_6.c,v 1.13 2009/03/14 22:52:53 dholland Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)pl_6.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: pl_6.c,v 1.12 2009/03/14 19:35:13 dholland Exp $");
+__RCSID("$NetBSD: pl_6.c,v 1.13 2009/03/14 22:52:53 dholland Exp $");
#endif
#endif /* not lint */
@@ -81,7 +81,7 @@ repair(void)
int max = ptr->guns/4;
if (ptr->hull < max) {
FIX(hull, max);
- Write(W_HULL, ms, ptr->hull, 0, 0, 0);
+ send_hull(ms, ptr->hull);
}
break;
}
@@ -90,15 +90,13 @@ repair(void)
int max = ptr->guns/5 - ptr->carL;
if (ptr->gunL < max) {
FIX(gunL, max);
- Write(W_GUNL, ms, ptr->gunL,
- ptr->carL, 0, 0);
+ send_gunl(ms, ptr->gunL, ptr->carL);
}
} else {
int max = ptr->guns/5 - ptr->carR;
if (ptr->gunR < max) {
FIX(gunR, max);
- Write(W_GUNR, ms, ptr->gunR,
- ptr->carR, 0, 0);
+ send_gunr(ms, ptr->gunR, ptr->carR);
}
}
break;
@@ -106,19 +104,19 @@ repair(void)
#define X 2
if (ptr->rig4 >= 0 && ptr->rig4 < X) {
FIX(rig4, X);
- Write(W_RIG4, ms, ptr->rig4, 0, 0, 0);
+ send_rig4(ms, ptr->rig4);
}
if (count && ptr->rig3 < X) {
FIX(rig3, X);
- Write(W_RIG3, ms, ptr->rig3, 0, 0, 0);
+ send_rig3(ms, ptr->rig3);
}
if (count && ptr->rig2 < X) {
FIX(rig2, X);
- Write(W_RIG2, ms, ptr->rig2, 0, 0, 0);
+ send_rig2(ms, ptr->rig2);
}
if (count && ptr->rig1 < X) {
FIX(rig1, X);
- Write(W_RIG1, ms, ptr->rig1, 0, 0, 0);
+ send_rig1(ms, ptr->rig1);
}
break;
}
diff --git a/sail/pl_7.c b/sail/pl_7.c
index cf1d009c..cc2134e4 100644
--- a/sail/pl_7.c
+++ b/sail/pl_7.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pl_7.c,v 1.31 2009/03/14 19:57:14 dholland Exp $ */
+/* $NetBSD: pl_7.c,v 1.32 2009/03/14 22:52:53 dholland Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)pl_7.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: pl_7.c,v 1.31 2009/03/14 19:57:14 dholland Exp $");
+__RCSID("$NetBSD: pl_7.c,v 1.32 2009/03/14 22:52:53 dholland Exp $");
#endif
#endif /* not lint */
@@ -133,7 +133,7 @@ newturn(int n __unused)
mf->readyR = R_LOADED;
}
if (!hasdriver)
- Write(W_DDEAD, SHIP(0), 0, 0, 0, 0);
+ send_ddead();
if (sc_hasprompt) {
wmove(scroll_w, sc_line, 0);
@@ -147,11 +147,11 @@ newturn(int n __unused)
wprintw(scroll_w, "%s%s", sc_prompt, sc_buf);
if (turn % 50 == 0)
- Write(W_ALIVE, SHIP(0), 0, 0, 0, 0);
+ send_alive();
if (mf->FS && (!mc->rig1 || windspeed == 6))
- Write(W_FS, ms, 0, 0, 0, 0);
+ send_fs(ms, 0);
if (mf->FS == 1)
- Write(W_FS, ms, 2, 0, 0, 0);
+ send_fs(ms, 2);
if (mf->struck)
leave(LEAVE_QUIT);
diff --git a/sail/pl_main.c b/sail/pl_main.c
index 701d2d94..205a3cbe 100644
--- a/sail/pl_main.c
+++ b/sail/pl_main.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pl_main.c,v 1.24 2009/03/14 20:14:56 dholland Exp $ */
+/* $NetBSD: pl_main.c,v 1.25 2009/03/14 22:52:53 dholland Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)pl_main.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: pl_main.c,v 1.24 2009/03/14 20:14:56 dholland Exp $");
+__RCSID("$NetBSD: pl_main.c,v 1.25 2009/03/14 22:52:53 dholland Exp $");
#endif
#endif /* not lint */
@@ -180,7 +180,7 @@ reprint:
mf = ms->file;
mc = ms->specs;
- Write(W_BEGIN, ms, 0, 0, 0, 0);
+ send_begin(ms);
if (Sync() < 0)
leave(LEAVE_SYNC);
@@ -213,7 +213,7 @@ reprint:
else
captain[strlen(captain) - 1] = '\0';
}
- Writestr(W_CAPTAIN, ms, captain);
+ send_captain(ms, captain);
for (n = 0; n < 2; n++) {
char buf[10];
@@ -252,6 +252,6 @@ reprint:
draw_board();
snprintf(message, sizeof message, "Captain %s assuming command",
captain);
- Writestr(W_SIGNAL, ms, message);
+ send_signal(ms, message);
newturn(0);
}
diff --git a/sail/sync.c b/sail/sync.c
index 8f33df6d..83f9e19b 100644
--- a/sail/sync.c
+++ b/sail/sync.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sync.c,v 1.29 2009/03/14 19:57:14 dholland Exp $ */
+/* $NetBSD: sync.c,v 1.30 2009/03/14 22:52:53 dholland Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)sync.c 8.2 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: sync.c,v 1.29 2009/03/14 19:57:14 dholland Exp $");
+__RCSID("$NetBSD: sync.c,v 1.30 2009/03/14 22:52:53 dholland Exp $");
#endif
#endif /* not lint */
@@ -54,6 +54,91 @@ __RCSID("$NetBSD: sync.c,v 1.29 2009/03/14 19:57:14 dholland Exp $");
#define BUFSIZE 4096
+/* Message types */
+#define W_CAPTAIN 1
+#define W_CAPTURED 2
+#define W_CLASS 3
+#define W_CREW 4
+#define W_DBP 5
+#define W_DRIFT 6
+#define W_EXPLODE 7
+#define W_FILE 8
+#define W_FOUL 9
+#define W_GUNL 10
+#define W_GUNR 11
+#define W_HULL 12
+#define W_MOVE 13
+#define W_OBP 14
+#define W_PCREW 15
+#define W_UNFOUL 16
+#define W_POINTS 17
+#define W_QUAL 18
+#define W_UNGRAP 19
+#define W_RIGG 20
+#define W_COL 21
+#define W_DIR 22
+#define W_ROW 23
+#define W_SIGNAL 24
+#define W_SINK 25
+#define W_STRUCK 26
+#define W_TA 27
+#define W_ALIVE 28
+#define W_TURN 29
+#define W_WIND 30
+#define W_FS 31
+#define W_GRAP 32
+#define W_RIG1 33
+#define W_RIG2 34
+#define W_RIG3 35
+#define W_RIG4 36
+#define W_BEGIN 37
+#define W_END 38
+#define W_DDEAD 39
+
+
+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_file(void);
+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_alive(void);
+static void recv_turn(long a);
+static void recv_wind(long a, long b);
+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 recv_ddead(void);
+
+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 *,
long, long, long, long);
@@ -102,7 +187,7 @@ makesignal(struct ship *from, const char *fmt, struct ship *ship, ...)
fmtship(format, sizeof(format), fmt, ship);
vsnprintf(message, sizeof(message), format, ap);
va_end(ap);
- Writestr(W_SIGNAL, from, message);
+ send_signal(from, message);
}
/*VARARGS2*/
@@ -115,7 +200,7 @@ makemsg(struct ship *from, const char *fmt, ...)
va_start(ap, fmt);
vsnprintf(message, sizeof(message), fmt, ap);
va_end(ap);
- Writestr(W_SIGNAL, from, message);
+ send_signal(from, message);
}
int
@@ -178,13 +263,14 @@ sync_close(int doremove)
}
}
-void
+static void
Write(int type, struct ship *ship, long a, long b, long c, long d)
{
size_t max = sizeof(sync_buf) - (sync_bp - sync_buf);
+ int shipindex = (ship == NULL) ? 0 : ship->file->index;
snprintf(sync_bp, max, "%d %d 0 %ld %ld %ld %ld\n",
- type, ship->file->index, a, b, c, d);
+ type, shipindex, a, b, c, d);
while (*sync_bp++)
;
sync_bp--;
@@ -193,12 +279,13 @@ Write(int type, struct ship *ship, long a, long b, long c, long d)
sync_update(type, ship, NULL, a, b, c, d);
}
-void
+static void
Writestr(int type, struct ship *ship, const char *a)
{
size_t max = sizeof(sync_buf) - (sync_bp - sync_buf);
+ int shipindex = (ship == NULL) ? 0 : ship->file->index;
- snprintf(sync_bp, max, "%d %d 1 %s\n", type, ship->file->index, a);
+ snprintf(sync_bp, max, "%d %d 1 %s\n", type, shipindex, a);
while (*sync_bp++)
;
sync_bp--;
@@ -315,194 +402,594 @@ sync_update(int type, struct ship *ship, const char *astr,
long a, long b, long c, long d)
{
switch (type) {
- case W_DBP: {
- struct BP *p = &ship->file->DBP[a];
- p->turnsent = b;
- p->toship = SHIP(c);
- p->mensent = d;
- break;
- }
- case W_OBP: {
- struct BP *p = &ship->file->OBP[a];
- p->turnsent = b;
- p->toship = SHIP(c);
- p->mensent = d;
- break;
- }
- case W_FOUL: {
- struct snag *p = &ship->file->foul[a];
- if (SHIP(a)->file->dir == 0)
- break;
- if (p->sn_count++ == 0)
- p->sn_turn = turn;
- ship->file->nfoul++;
- break;
- }
- case W_GRAP: {
- struct snag *p = &ship->file->grap[a];
- if (SHIP(a)->file->dir == 0)
- break;
- if (p->sn_count++ == 0)
- p->sn_turn = turn;
- ship->file->ngrap++;
- break;
- }
- case W_UNFOUL: {
- struct snag *p = &ship->file->foul[a];
- if (p->sn_count > 0) {
- if (b) {
- ship->file->nfoul -= p->sn_count;
- p->sn_count = 0;
- } else {
- ship->file->nfoul--;
- p->sn_count--;
- }
- }
- break;
- }
- case W_UNGRAP: {
- struct snag *p = &ship->file->grap[a];
- if (p->sn_count > 0) {
- if (b) {
- ship->file->ngrap -= p->sn_count;
- p->sn_count = 0;
- } else {
- ship->file->ngrap--;
- p->sn_count--;
- }
- }
- break;
- }
- case W_SIGNAL:
- if (mode == MODE_PLAYER) {
- if (nobells)
- Signal("$$: %s", ship, astr);
- else
- Signal("\a$$: %s", ship, astr);
- }
- break;
- case W_CREW: {
- struct shipspecs *s = ship->specs;
- s->crew1 = a;
- s->crew2 = b;
- s->crew3 = c;
- break;
- }
- case W_CAPTAIN:
- strlcpy(ship->file->captain, astr,
- sizeof ship->file->captain);
- break;
- case W_CAPTURED:
- if (a < 0)
- ship->file->captured = 0;
- else
- ship->file->captured = SHIP(a);
- break;
- case W_CLASS:
- ship->specs->class = a;
- break;
- case W_DRIFT:
- ship->file->drift = a;
- break;
- case W_EXPLODE:
- if ((ship->file->explode = a) == 2)
- ship->file->dir = 0;
- break;
- case W_FS:
- ship->file->FS = a;
- break;
- case W_GUNL: {
- struct shipspecs *s = ship->specs;
- s->gunL = a;
- s->carL = b;
- break;
- }
- case W_GUNR: {
- struct shipspecs *s = ship->specs;
- s->gunR = a;
- s->carR = b;
- break;
- }
- case W_HULL:
- ship->specs->hull = a;
- break;
- case W_MOVE:
- strlcpy(ship->file->movebuf, astr,
- sizeof ship->file->movebuf);
- break;
- case W_PCREW:
- ship->file->pcrew = a;
- break;
- case W_POINTS:
- ship->file->points = a;
- break;
- case W_QUAL:
- ship->specs->qual = a;
- break;
- case W_RIGG: {
- struct shipspecs *s = ship->specs;
- s->rig1 = a;
- s->rig2 = b;
- s->rig3 = c;
- s->rig4 = d;
- break;
- }
- case W_RIG1:
- ship->specs->rig1 = a;
- break;
- case W_RIG2:
- ship->specs->rig2 = a;
- break;
- case W_RIG3:
- ship->specs->rig3 = a;
- break;
- case W_RIG4:
- ship->specs->rig4 = a;
- break;
- case W_COL:
- ship->file->col = a;
- break;
- case W_DIR:
- ship->file->dir = a;
- break;
- case W_ROW:
- ship->file->row = a;
- break;
- case W_SINK:
- if ((ship->file->sink = a) == 2)
- ship->file->dir = 0;
- break;
- case W_STRUCK:
- ship->file->struck = a;
- break;
- case W_TA:
- ship->specs->ta = a;
- break;
- case W_ALIVE:
- alive = 1;
- break;
- case W_TURN:
- turn = a;
- break;
- case W_WIND:
- winddir = a;
- windspeed = b;
- break;
- case W_BEGIN:
- strcpy(ship->file->captain, "begin");
- people++;
- break;
- case W_END:
- *ship->file->captain = 0;
- ship->file->points = 0;
- people--;
- break;
- case W_DDEAD:
- hasdriver = 0;
- break;
+ 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_FILE: recv_file(); 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_ALIVE: recv_alive(); break;
+ case W_TURN: recv_turn(a); break;
+ case W_WIND: recv_wind(a, b); 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;
+ case W_DDEAD: recv_ddead(); break;
default:
fprintf(stderr, "sync_update: unknown type %d\r\n", type);
return -1;
}
return 0;
}
+
+/*
+ * Messages to send
+ */
+
+void
+send_captain(struct ship *ship, const char *astr)
+{
+ Writestr(W_CAPTAIN, ship, astr);
+}
+
+void
+send_captured(struct ship *ship, long a)
+{
+ Write(W_CAPTURED, ship, a, 0, 0, 0);
+}
+
+void
+send_class(struct ship *ship, long a)
+{
+ Write(W_CLASS, ship, a, 0, 0, 0);
+}
+
+void
+send_crew(struct ship *ship, long a, long b, long c)
+{
+ Write(W_CREW, ship, a, b, c, 0);
+}
+
+void
+send_dbp(struct ship *ship, long a, long b, long c, long d)
+{
+ Write(W_DBP, ship, a, b, c, d);
+}
+
+void
+send_drift(struct ship *ship, long a)
+{
+ Write(W_DRIFT, ship, a, 0, 0, 0);
+}
+
+void
+send_explode(struct ship *ship, long a)
+{
+ Write(W_EXPLODE, ship, a, 0, 0, 0);
+}
+
+void
+send_file(void)
+{
+ Write(W_FILE, NULL, 0, 0, 0, 0);
+}
+
+void
+send_foul(struct ship *ship, long a)
+{
+ Write(W_FOUL, ship, a, 0, 0, 0);
+}
+
+void
+send_gunl(struct ship *ship, long a, long b)
+{
+ Write(W_GUNL, ship, a, b, 0, 0);
+}
+
+void
+send_gunr(struct ship *ship, long a, long b)
+{
+ Write(W_GUNR, ship, a, b, 0, 0);
+}
+
+void
+send_hull(struct ship *ship, long a)
+{
+ Write(W_HULL, ship, a, 0, 0, 0);
+}
+
+void
+send_move(struct ship *ship, const char *astr)
+{
+ Writestr(W_MOVE, ship, astr);
+}
+
+void
+send_obp(struct ship *ship, long a, long b, long c, long d)
+{
+ Write(W_OBP, ship, a, b, c, d);
+}
+
+void
+send_pcrew(struct ship *ship, long a)
+{
+ Write(W_PCREW, ship, a, 0, 0, 0);
+}
+
+void
+send_unfoul(struct ship *ship, long a, long b)
+{
+ Write(W_UNFOUL, ship, a, b, 0, 0);
+}
+
+void
+send_points(struct ship *ship, long a)
+{
+ Write(W_POINTS, ship, a, 0, 0, 0);
+}
+
+void
+send_qual(struct ship *ship, long a)
+{
+ Write(W_QUAL, ship, a, 0, 0, 0);
+}
+
+void
+send_ungrap(struct ship *ship, long a, long b)
+{
+ Write(W_UNGRAP, ship, a, b, 0, 0);
+}
+
+void
+send_rigg(struct ship *ship, long a, long b, long c, long d)
+{
+ Write(W_RIGG, ship, a, b, c, d);
+}
+
+void
+send_col(struct ship *ship, long a)
+{
+ Write(W_COL, ship, a, 0, 0, 0);
+}
+
+void
+send_dir(struct ship *ship, long a)
+{
+ Write(W_DIR, ship, a, 0, 0, 0);
+}
+
+void
+send_row(struct ship *ship, long a)
+{
+ Write(W_ROW, ship, a, 0, 0, 0);
+}
+
+void
+send_signal(struct ship *ship, const char *astr)
+{
+ Writestr(W_SIGNAL, ship, astr);
+}
+
+void
+send_sink(struct ship *ship, long a)
+{
+ Write(W_SINK, ship, a, 0, 0, 0);
+}
+
+void
+send_struck(struct ship *ship, long a)
+{
+ Write(W_STRUCK, ship, a, 0, 0, 0);
+}
+
+void
+send_ta(struct ship *ship, long a)
+{
+ Write(W_TA, ship, a, 0, 0, 0);
+}
+
+void
+send_alive(void)
+{
+ Write(W_ALIVE, NULL, 0, 0, 0, 0);
+}
+
+void
+send_turn(long a)
+{
+ Write(W_TURN, NULL, a, 0, 0, 0);
+}
+
+void
+send_wind(long a, long b)
+{
+ Write(W_WIND, NULL, a, b, 0, 0);
+}
+
+void
+send_fs(struct ship *ship, long a)
+{
+ Write(W_FS, ship, a, 0, 0, 0);
+}
+
+void
+send_grap(struct ship *ship, long a)
+{
+ Write(W_GRAP, ship, a, 0, 0, 0);
+}
+
+void
+send_rig1(struct ship *ship, long a)
+{
+ Write(W_RIG1, ship, a, 0, 0, 0);
+}
+
+void
+send_rig2(struct ship *ship, long a)
+{
+ Write(W_RIG2, ship, a, 0, 0, 0);
+}
+
+void
+send_rig3(struct ship *ship, long a)
+{
+ Write(W_RIG3, ship, a, 0, 0, 0);
+}
+
+void
+send_rig4(struct ship *ship, long a)
+{
+ Write(W_RIG4, ship, a, 0, 0, 0);
+}
+
+void
+send_begin(struct ship *ship)
+{
+ Write(W_BEGIN, ship, 0, 0, 0, 0);
+}
+
+void
+send_end(struct ship *ship)
+{
+ Write(W_END, ship, 0, 0, 0, 0);
+}
+
+void
+send_ddead(void)
+{
+ Write(W_DDEAD, NULL, 0, 0, 0, 0);
+}
+
+
+/*
+ * Actions upon message receipt
+ */
+
+static void
+recv_captain(struct ship *ship, const char *astr)
+{
+ strlcpy(ship->file->captain, astr, sizeof ship->file->captain);
+}
+
+static void
+recv_captured(struct ship *ship, long a)
+{
+ if (a < 0)
+ ship->file->captured = 0;
+ else
+ ship->file->captured = SHIP(a);
+}
+
+static void
+recv_class(struct ship *ship, long a)
+{
+ ship->specs->class = a;
+}
+
+static void
+recv_crew(struct ship *ship, long a, long b, long c)
+{
+ struct shipspecs *s = ship->specs;
+
+ s->crew1 = a;
+ s->crew2 = b;
+ s->crew3 = c;
+}
+
+static void
+recv_dbp(struct ship *ship, long a, long b, long c, long d)
+{
+ struct BP *p = &ship->file->DBP[a];
+
+ p->turnsent = b;
+ p->toship = SHIP(c);
+ p->mensent = d;
+}
+
+static void
+recv_drift(struct ship *ship, long a)
+{
+ ship->file->drift = a;
+}
+
+static void
+recv_explode(struct ship *ship, long a)
+{
+ if ((ship->file->explode = a) == 2)
+ ship->file->dir = 0;
+}
+
+// XXX why does this exist?
+static void
+recv_file(void)
+{
+}
+
+static void
+recv_foul(struct ship *ship, long a)
+{
+ struct snag *p = &ship->file->foul[a];
+
+ if (SHIP(a)->file->dir == 0)
+ return;
+ if (p->sn_count++ == 0)
+ p->sn_turn = turn;
+ ship->file->nfoul++;
+}
+
+static void
+recv_gunl(struct ship *ship, long a, long b)
+{
+ struct shipspecs *s = ship->specs;
+
+ s->gunL = a;
+ s->carL = b;
+}
+
+static void
+recv_gunr(struct ship *ship, long a, long b)
+{
+ struct shipspecs *s = ship->specs;
+
+ s->gunR = a;
+ s->carR = b;
+}
+
+static void
+recv_hull(struct ship *ship, long a)
+{
+ ship->specs->hull = a;
+}
+
+static void
+recv_move(struct ship *ship, const char *astr)
+{
+ strlcpy(ship->file->movebuf, astr, sizeof ship->file->movebuf);
+}
+
+static void
+recv_obp(struct ship *ship, long a, long b, long c, long d)
+{
+ struct BP *p = &ship->file->OBP[a];
+
+ p->turnsent = b;
+ p->toship = SHIP(c);
+ p->mensent = d;
+}
+
+static void
+recv_pcrew(struct ship *ship, long a)
+{
+ ship->file->pcrew = a;
+}
+
+static void
+recv_unfoul(struct ship *ship, long a, long b)
+{
+ struct snag *p = &ship->file->foul[a];
+
+ if (p->sn_count > 0) {
+ if (b) {
+ ship->file->nfoul -= p->sn_count;
+ p->sn_count = 0;
+ } else {
+ ship->file->nfoul--;
+ p->sn_count--;
+ }
+ }
+}
+
+static void
+recv_points(struct ship *ship, long a)
+{
+ ship->file->points = a;
+}
+
+static void
+recv_qual(struct ship *ship, long a)
+{
+ ship->specs->qual = a;
+}
+
+static void
+recv_ungrap(struct ship *ship, long a, long b)
+{
+ struct snag *p = &ship->file->grap[a];
+
+ if (p->sn_count > 0) {
+ if (b) {
+ ship->file->ngrap -= p->sn_count;
+ p->sn_count = 0;
+ } else {
+ ship->file->ngrap--;
+ p->sn_count--;
+ }
+ }
+}
+
+static void
+recv_rigg(struct ship *ship, long a, long b, long c, long d)
+{
+ struct shipspecs *s = ship->specs;
+
+ s->rig1 = a;
+ s->rig2 = b;
+ s->rig3 = c;
+ s->rig4 = d;
+}
+
+static void
+recv_col(struct ship *ship, long a)
+{
+ ship->file->col = a;
+}
+
+static void
+recv_dir(struct ship *ship, long a)
+{
+ ship->file->dir = a;
+}
+
+static void
+recv_row(struct ship *ship, long a)
+{
+ ship->file->row = a;
+}
+
+static void
+recv_signal(struct ship *ship, const char *astr)
+{
+ if (mode == MODE_PLAYER) {
+ if (nobells)
+ Signal("$$: %s", ship, astr);
+ else
+ Signal("\a$$: %s", ship, astr);
+ }
+}
+
+static void
+recv_sink(struct ship *ship, long a)
+{
+ if ((ship->file->sink = a) == 2)
+ ship->file->dir = 0;
+}
+
+static void
+recv_struck(struct ship *ship, long a)
+{
+ ship->file->struck = a;
+}
+
+static void
+recv_ta(struct ship *ship, long a)
+{
+ ship->specs->ta = a;
+}
+
+static void
+recv_alive(void)
+{
+ alive = 1;
+}
+
+static void
+recv_turn(long a)
+{
+ turn = a;
+}
+
+static void
+recv_wind(long a, long b)
+{
+ winddir = a;
+ windspeed = b;
+}
+
+static void
+recv_fs(struct ship *ship, long a)
+{
+ ship->file->FS = a;
+}
+
+static void
+recv_grap(struct ship *ship, long a)
+{
+ struct snag *p = &ship->file->grap[a];
+
+ if (SHIP(a)->file->dir == 0)
+ return;
+ if (p->sn_count++ == 0)
+ p->sn_turn = turn;
+ ship->file->ngrap++;
+}
+
+static void
+recv_rig1(struct ship *ship, long a)
+{
+ ship->specs->rig1 = a;
+}
+
+static void
+recv_rig2(struct ship *ship, long a)
+{
+ ship->specs->rig2 = a;
+}
+
+static void
+recv_rig3(struct ship *ship, long a)
+{
+ ship->specs->rig3 = a;
+}
+
+static void
+recv_rig4(struct ship *ship, long a)
+{
+ ship->specs->rig4 = a;
+}
+
+static void
+recv_begin(struct ship *ship)
+{
+ strcpy(ship->file->captain, "begin");
+ people++;
+}
+
+static void
+recv_end(struct ship *ship)
+{
+ *ship->file->captain = 0;
+ ship->file->points = 0;
+ people--;
+}
+
+static void
+recv_ddead(void)
+{
+ hasdriver = 0;
+}