#ifndef lint
-static char *sccsid = "@(#)sync.c 1.1 83/10/10";
+static char *sccsid = "@(#)sync.c 2.2 83/11/01";
#endif
#include "externs.h"
Write(W_SIGNAL, from, 1, (int)message, 0, 0, 0);
}
+#include <sys/types.h>
+#include <sys/stat.h>
sync_exists(game)
{
char buf[sizeof sync_file];
+ struct stat s;
+ time_t t;
(void) sprintf(buf, SF, game);
- return access(buf, 0) >= 0;
+ time(&t);
+ if (stat(buf, &s) < 0)
+ return 0;
+ if (s.st_mtime < t - 60*60*2) { /* 2 hours */
+ unlink(buf);
+ return 0;
+ } else
+ return 1;
}
sync_open()
if (sync_fp == 0)
return -1;
sync_seek == 0;
+ return 0;
}
sync_close(remove)
char remove;
{
- (void) fclose(sync_fp);
+ if (sync_fp != 0)
+ (void) fclose(sync_fp);
if (remove)
(void) unlink(sync_file);
}
break;
}
case W_SIGNAL:
- (void) strncpy(ship->file->signal, (char *)a,
- sizeof ship->file->signal - 1);
- ship->file->signal[sizeof ship->file->signal - 1] = 0;
+ if (isplayer) {
+ Signal("\7%s (%c%c): %s", ship, a);
+ }
break;
case W_CREW: {
register struct shipspecs *s = ship->specs;
ship->file->captain[sizeof ship->file->captain - 1] = 0;
break;
case W_CAPTURED:
- ship->file->captured = SHIP(a);
+ if (a < 0)
+ ship->file->captured = 0;
+ else
+ ship->file->captured = SHIP(a);
break;
case W_CLASS:
ship->specs->class = a;