From ce3d12bed02dc0e73ff23a4cc2d0fde3dcf9c4ba Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Thu, 26 Feb 2009 21:51:57 +0100 Subject: [PATCH] sail(6): Fix amd64 warnings. The Write() function was being used for printing both numbers and strings in an unportable way. Split it into Write() for numbers and Writestr() for strings. Taken-from: NetBSD --- games/sail/assorted.c | 30 +++++++++++------------ games/sail/dr_1.c | 16 ++++++------ games/sail/dr_2.c | 11 ++++----- games/sail/dr_3.c | 16 ++++++------ games/sail/dr_4.c | 4 +-- games/sail/dr_5.c | 4 +-- games/sail/externs.h | 3 ++- games/sail/parties.c | 2 +- games/sail/pl_1.c | 2 +- games/sail/pl_3.c | 4 +-- games/sail/pl_4.c | 6 ++--- games/sail/pl_5.c | 8 +++--- games/sail/pl_6.c | 14 +++++------ games/sail/pl_7.c | 8 +++--- games/sail/pl_main.c | 9 ++++--- games/sail/sync.c | 57 ++++++++++++++++++++++++++----------------- 16 files changed, 104 insertions(+), 90 deletions(-) diff --git a/games/sail/assorted.c b/games/sail/assorted.c index ee778c7ad6..f26cd73359 100644 --- a/games/sail/assorted.c +++ b/games/sail/assorted.c @@ -128,17 +128,17 @@ table(int rig, int shot, int hittable, 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 %s (%c%c)"; @@ -200,7 +200,7 @@ table(int rig, int shot, int hittable, 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"; @@ -216,12 +216,12 @@ void Cleansnag(struct ship *from, struct ship *to, char all, char 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)) { @@ -244,20 +244,20 @@ strike(struct ship *ship, struct ship *from) 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()) { 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!"); } diff --git a/games/sail/dr_1.c b/games/sail/dr_1.c index 15a99dd200..206bf62d90 100644 --- a/games/sail/dr_1.c +++ b/games/sail/dr_1.c @@ -184,7 +184,7 @@ fightitout(struct ship *from, struct ship *to, int key) makesignal(from, "boarders from %s repelled", to); 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) { @@ -193,7 +193,7 @@ fightitout(struct ship *from, struct ship *to, int key) subtract(to, totalto, crewto, tocap, pcto); if (key) { if (fromcap != from) - Write(W_POINTS, fromcap, 0, + Write(W_POINTS, fromcap, fromcap->file->points - from->file->struck ? from->specs->pts @@ -204,11 +204,11 @@ fightitout(struct ship *from, struct ship *to, 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); @@ -216,10 +216,10 @@ fightitout(struct ship *from, struct ship *to, int key) } sprintf(message, "captured by the %s!", to->shipname); - Write(W_SIGNAL, from, 1, (long) message, 0, 0, 0); + 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; } @@ -428,7 +428,7 @@ next(void) } return -1; } - Write(W_TURN, SHIP(0), 0, turn, 0, 0, 0); + Write(W_TURN, SHIP(0), turn, 0, 0, 0); if (turn % 7 == 0 && (die() >= cc->windchange || !windspeed)) { switch (die()) { case 1: @@ -466,7 +466,7 @@ next(void) } else windspeed++; - Write(W_WIND, SHIP(0), 0, winddir, windspeed, 0, 0); + Write(W_WIND, SHIP(0), winddir, windspeed, 0, 0); } return 0; } diff --git a/games/sail/dr_2.c b/games/sail/dr_2.c index 840d7441e0..b7a15f603a 100644 --- a/games/sail/dr_2.c +++ b/games/sail/dr_2.c @@ -92,8 +92,8 @@ checkup(void) continue; if (die() < 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); @@ -119,10 +119,9 @@ prizecheck(void) 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, - (int)"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); } } } diff --git a/games/sail/dr_3.c b/games/sail/dr_3.c index 7c0ccd60fa..d4f6a6d6bf 100644 --- a/games/sail/dr_3.c +++ b/games/sail/dr_3.c @@ -137,8 +137,8 @@ moveall(void) /* move all comp ships */ makesignal(sp, "fouled with %s (%c%c)", 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++; } @@ -169,13 +169,13 @@ moveall(void) /* 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++; } @@ -268,7 +268,7 @@ sendbp(struct ship *from, struct ship *to, int sections, 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) makesignal(from, "repelling boarders", @@ -344,6 +344,6 @@ checksails(void) } 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); } } diff --git a/games/sail/dr_4.c b/games/sail/dr_4.c index 3b466c52ba..2bd4f9cfc9 100644 --- a/games/sail/dr_4.c +++ b/games/sail/dr_4.c @@ -59,7 +59,7 @@ grap(struct ship *from, struct ship *to) { if (capship(from)->nationality != capship(to)->nationality && die() > 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 %s (%c%c)", to); } diff --git a/games/sail/dr_5.c b/games/sail/dr_5.c index e46d27cc41..a88c9d095b 100644 --- a/games/sail/dr_5.c +++ b/games/sail/dr_5.c @@ -52,11 +52,11 @@ subtract(struct ship *from, int totalfrom, int crewfrom[3], struct ship *fromcap 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); } } diff --git a/games/sail/externs.h b/games/sail/externs.h index 1af904516d..728a7176dc 100644 --- a/games/sail/externs.h +++ b/games/sail/externs.h @@ -412,5 +412,6 @@ void makesignal(struct ship *, const char *, struct ship *, ...); bool sync_exists(int); int sync_open(void); void sync_close(char); -void Write(int, struct ship *, char, int, int, int, int); +void Write(int, struct ship *, int, int, int, int); +void Writestr(int, struct ship *, const char *); int Sync(void); diff --git a/games/sail/parties.c b/games/sail/parties.c index 816789a2fe..b356e9ea7f 100644 --- a/games/sail/parties.c +++ b/games/sail/parties.c @@ -69,5 +69,5 @@ unboard(struct ship *ship, struct ship *to, char isdefense) 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); } diff --git a/games/sail/pl_1.c b/games/sail/pl_1.c index a793fda76c..b6f73d5f5f 100644 --- a/games/sail/pl_1.c +++ b/games/sail/pl_1.c @@ -104,7 +104,7 @@ leave(int conditions) if (conditions != LEAVE_SYNC) { makesignal(ms, "Captain %s relinquishing.", (struct ship *)0, mf->captain); - Write(W_END, ms, 0, 0, 0, 0, 0); + Write(W_END, ms, 0, 0, 0, 0); Sync(); } } diff --git a/games/sail/pl_3.c b/games/sail/pl_3.c index 390cda6888..7c3a42cca8 100644 --- a/games/sail/pl_3.c +++ b/games/sail/pl_3.c @@ -229,8 +229,8 @@ grapungrap(void) case 'g': if (die() < 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); Signal("Attempt succeeds!", (struct ship *)0); makesignal(ms, "grappled with %s (%c%c)", sp); } else diff --git a/games/sail/pl_4.c b/games/sail/pl_4.c index 3466032f02..390c0b92e0 100644 --- a/games/sail/pl_4.c +++ b/games/sail/pl_4.c @@ -51,12 +51,12 @@ changesail(void) 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; } } @@ -76,7 +76,7 @@ acceptsignal(void) ; p[-1] = '"'; *p = 0; - Write(W_SIGNAL, ms, 1, (long)buf, 0, 0, 0); + Writestr(W_SIGNAL, ms, buf); } void diff --git a/games/sail/pl_5.c b/games/sail/pl_5.c index 150bf99a7f..fd179d4338 100644 --- a/games/sail/pl_5.c +++ b/games/sail/pl_5.c @@ -125,7 +125,7 @@ acceptmove(void) Signal("Movement error.", (struct ship *)0); 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); Signal("No hands to set full sails.", (struct ship *)0); } @@ -134,7 +134,7 @@ acceptmove(void) } if (af && !moved) { if (mf->FS == 1) { - Write(W_FS, ms, 0, 0, 0, 0, 0); + Write(W_FS, ms, 0, 0, 0, 0); Signal("No hands to set full sails.", (struct ship *)0); } @@ -143,7 +143,7 @@ acceptmove(void) strcpy(movebuf, buf); else strcpy(movebuf, "d"); - Write(W_MOVE, ms, 1, (int)movebuf, 0, 0, 0); + Writestr(W_MOVE, ms, movebuf); Signal("Helm: %s.", (struct ship *)0, movebuf); } @@ -225,7 +225,7 @@ parties(int crew[3], struct ship *to, char isdefense, char buf) if (buf > '0') Signal("Sending all crew sections.", (struct ship *)0); - Write(isdefense ? W_DBP : W_OBP, ms, 0, + Write(isdefense ? W_DBP : W_OBP, ms, j, turn, to->file->index, men); if (isdefense) { wmove(slot_w, 2, 0); diff --git a/games/sail/pl_6.c b/games/sail/pl_6.c index 6542e3cf20..ffa702d2bf 100644 --- a/games/sail/pl_6.c +++ b/games/sail/pl_6.c @@ -76,7 +76,7 @@ repair(void) 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; } @@ -85,14 +85,14 @@ repair(void) 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); } } @@ -101,19 +101,19 @@ repair(void) #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; } diff --git a/games/sail/pl_7.c b/games/sail/pl_7.c index a94bdba5cd..bc2696c094 100644 --- a/games/sail/pl_7.c +++ b/games/sail/pl_7.c @@ -104,7 +104,7 @@ newturn(void) 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) { wmove(scroll_w, sc_line, 0); @@ -118,11 +118,11 @@ newturn(void) 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); diff --git a/games/sail/pl_main.c b/games/sail/pl_main.c index 7dca6f4a1f..04ba3e6069 100644 --- a/games/sail/pl_main.c +++ b/games/sail/pl_main.c @@ -174,7 +174,7 @@ 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); @@ -206,7 +206,7 @@ reprint: else 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]; @@ -241,7 +241,8 @@ reprint: initscreen(); draw_board(); - 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(); } diff --git a/games/sail/sync.c b/games/sail/sync.c index 9861d5a659..b8d119f42d 100644 --- a/games/sail/sync.c +++ b/games/sail/sync.c @@ -38,6 +38,8 @@ #include "externs.h" #include #include +#include +#include #define BUFSIZE 4096 @@ -50,7 +52,8 @@ static FILE *sync_fp; #define SF "/tmp/#sailsink.%d" #define LF "/tmp/#saillock.%d" -static int sync_update(int, struct ship *, long, long, long, long); +static int sync_update(int, struct ship *, const char *, long, long, long, + long); void fmtship(char *buf, size_t len, const char *fmt, struct ship *ship) @@ -91,11 +94,9 @@ makesignal(struct ship *from, const char *fmt, struct ship *ship, ...) vsprintf(message, format, ap); } va_end(ap); - Write(W_SIGNAL, from, 1, (long)message, 0, 0, 0); + Writestr(W_SIGNAL, from, message); } -#include -#include bool sync_exists(int lgame) { @@ -145,20 +146,28 @@ sync_close(char rm) } void -Write(int type, struct ship *ship, char isstr, int a, int b, int c, int d) +Write(int type, struct ship *ship, int a, int b, int c, int d) +{ + sprintf(sync_bp, "%d %d 0 %d %d %d %d\n", + type, ship->file->index, a, b, c, d); + while (*sync_bp++) + ; + sync_bp--; + if (sync_bp >= &sync_buf[sizeof sync_buf]) + abort(); + sync_update(type, ship, NULL, a, b, c, d); +} + +void +Writestr(int type, struct ship *ship, const char *a) { - if (isstr) - sprintf(sync_bp, "%d %d %d %s\n", - type, ship->file->index, isstr, (char *)a); - else - sprintf(sync_bp, "%d %d %d %d %d %d %d\n", - type, ship->file->index, isstr, a, b, c, d); + sprintf(sync_bp, "%d %d 1 %s\n", type, ship->file->index, a); while (*sync_bp++) ; sync_bp--; if (sync_bp >= &sync_buf[sizeof sync_buf]) abort(); - sync_update(type, ship, a, b, c, d); + sync_update(type, ship, a, 0, 0, 0, 0); } int @@ -167,6 +176,7 @@ Sync(void) sig_t sighup, sigint; int n; int type, shipnum, isstr, a, b, c, d; + char *astr; char buf[80]; char erred = 0; sighup = signal(SIGHUP, SIG_IGN); @@ -219,19 +229,21 @@ Sync(void) *p = 0; for (p = buf; *p == ' '; p++) ; - a = (long)p; - b = c = d = 0; - } else + astr = p; + a = b = c = d = 0; + } else { if (fscanf(sync_fp, "%d%d%d%d", &a, &b, &c, &d) != 4) goto bad; - if (sync_update(type, SHIP(shipnum), a, b, c, d) < 0) + astr = NULL; + } + if (sync_update(type, SHIP(shipnum), astr, a, b, c, d) < 0) goto bad; } bad: erred++; out: if (!erred && sync_bp != sync_buf) { - fseek(sync_fp, 0L, 2); + fseek(sync_fp, 0L, SEEK_END); fwrite(sync_buf, sizeof *sync_buf, sync_bp - sync_buf, sync_fp); fflush(sync_fp); @@ -249,7 +261,8 @@ out: } static int -sync_update(int type, struct ship *ship, long a, long b, long c, long d) +sync_update(int type, struct ship *ship, const char *astr, long a, long b, + long c, long d) { switch (type) { case W_DBP: { @@ -313,9 +326,9 @@ sync_update(int type, struct ship *ship, long a, long b, long c, long d) case W_SIGNAL: if (mode == MODE_PLAYER) { if (nobells) - Signal("%s (%c%c): %s", ship, a); + Signal("%s (%c%c): %s", ship, astr); else - Signal("\7%s (%c%c): %s", ship, a); + Signal("\7%s (%c%c): %s", ship, astr); } break; case W_CREW: { @@ -326,7 +339,7 @@ sync_update(int type, struct ship *ship, long a, long b, long c, long d) break; } case W_CAPTAIN: - strncpy(ship->file->captain, (char *)a, + strncpy(ship->file->captain, astr, sizeof ship->file->captain - 1); ship->file->captain[sizeof ship->file->captain - 1] = 0; break; @@ -365,7 +378,7 @@ sync_update(int type, struct ship *ship, long a, long b, long c, long d) ship->specs->hull = a; break; case W_MOVE: - strncpy(ship->file->movebuf, (char *)a, + strncpy(ship->file->movebuf, astr, sizeof ship->file->movebuf - 1); ship->file->movebuf[sizeof ship->file->movebuf - 1] = 0; break; -- 2.41.0