+
+/*
+ * 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_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;
+}
+
+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;
+}