diff options
author | 1997-10-13 21:02:57 +0000 | |
---|---|---|
committer | 1997-10-13 21:02:57 +0000 | |
commit | bd10b531314ec546d25fd238f27d94c74a726567 (patch) | |
tree | a6f88adfc60ca14d2851035c0a9fce98fcc96438 /sail/sync.c | |
parent | 7e5c0c57606f0f1e9335aa74ef5ea8c8048a9b2c (diff) | |
download | bsdgames-darwin-bd10b531314ec546d25fd238f27d94c74a726567.tar.gz bsdgames-darwin-bd10b531314ec546d25fd238f27d94c74a726567.tar.zst bsdgames-darwin-bd10b531314ec546d25fd238f27d94c74a726567.zip |
- make sure that the arguments to the printf like functions are correct
- add a makemsg() function to accompany makesignal.
Diffstat (limited to 'sail/sync.c')
-rw-r--r-- | sail/sync.c | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/sail/sync.c b/sail/sync.c index 641ab324..82ed9263 100644 --- a/sail/sync.c +++ b/sail/sync.c @@ -1,4 +1,4 @@ -/* $NetBSD: sync.c,v 1.6 1997/10/13 19:45:54 christos Exp $ */ +/* $NetBSD: sync.c,v 1.7 1997/10/13 21:04:40 christos Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)sync.c 8.2 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: sync.c,v 1.6 1997/10/13 19:45:54 christos Exp $"); +__RCSID("$NetBSD: sync.c,v 1.7 1997/10/13 21:04:40 christos Exp $"); #endif #endif /* not lint */ @@ -78,7 +78,7 @@ fmtship(buf, len, fmt, ship) *buf = '\0'; return; } - if (*fmt == '%' && fmt[1] == '$') { + if (*fmt == '$' && fmt[1] == '$') { size_t l = snprintf(buf, len, "%s (%c%c)", ship->shipname, colours(ship), sterncolour(ship)); buf += l; @@ -124,6 +124,30 @@ makesignal(va_alias) Write(W_SIGNAL, from, 1, (long)message, 0, 0, 0); } +void +#ifdef __STDC__ +makemsg(struct ship *from, const char *fmt, ...) +#else +makemsg(va_alias) + va_dcl +#endif +{ + char message[BUFSIZ]; + va_list ap; +#ifndef __STDC__ + struct ship *from; + const char *fmt; + + va_start(ap); + from = va_arg(ap, struct ship *); + fmt = va_arg(ap, const char *); +#else + va_start(ap, fmt); +#endif + (void) vsprintf(message, fmt, ap); + va_end(ap); + Write(W_SIGNAL, from, 1, (long)message, 0, 0, 0); +} int sync_exists(game) { @@ -351,9 +375,9 @@ sync_update(type, ship, a, b, c, d) case W_SIGNAL: if (mode == MODE_PLAYER) if (nobells) - Signal("%$: %s", ship, a); + Signal("$$: %s", ship, (char *) a); else - Signal("\7%$: %s", ship, a); + Signal("\7$$: %s", ship, (char *) a); break; case W_CREW: { struct shipspecs *s = ship->specs; |