diff options
author | hubertf <hubertf@NetBSD.org> | 1999-07-28 01:45:41 +0000 |
---|---|---|
committer | hubertf <hubertf@NetBSD.org> | 1999-07-28 01:45:41 +0000 |
commit | 932e74d4028472671e706b8d64965ef4a4293d0f (patch) | |
tree | 7155c281e751417d576084fd2feebae3a4e5159e /battlestar/init.c | |
parent | d0abda98e89948088de49cb3c2f192c15aa4518d (diff) | |
download | bsdgames-darwin-932e74d4028472671e706b8d64965ef4a4293d0f.tar.gz bsdgames-darwin-932e74d4028472671e706b8d64965ef4a4293d0f.tar.zst bsdgames-darwin-932e74d4028472671e706b8d64965ef4a4293d0f.zip |
This patch improves the handling of save files in battlestar(6), by
allowing the user to choose the name of the save file and specify it
on the command line when restoring. It also eliminates a buffer
overrun in determining the path to the save file, and any particular
arbitrary limit on the name length. In the name of a tidier home
directory, the default name is changed from "Bstar" to ".Bstar".
Patch supplied in PR 8085 by Joseph Myers <jsm28@cam.ac.uk>
Minor modification (s/startup/filename/ in initialize()) by me.
Diffstat (limited to 'battlestar/init.c')
-rw-r--r-- | battlestar/init.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/battlestar/init.c b/battlestar/init.c index 852b5b04..94d87309 100644 --- a/battlestar/init.c +++ b/battlestar/init.c @@ -1,4 +1,4 @@ -/* $NetBSD: init.c,v 1.8 1999/02/10 01:36:50 hubertf Exp $ */ +/* $NetBSD: init.c,v 1.9 1999/07/28 01:45:43 hubertf Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,17 +38,18 @@ #if 0 static char sccsid[] = "@(#)init.c 8.4 (Berkeley) 4/30/95"; #else -__RCSID("$NetBSD: init.c,v 1.8 1999/02/10 01:36:50 hubertf Exp $"); +__RCSID("$NetBSD: init.c,v 1.9 1999/07/28 01:45:43 hubertf Exp $"); #endif #endif /* not lint */ #include "extern.h" void -initialize(startup) - char startup; +initialize(filename) + const char *filename; { const struct objs *p; + char *savefile; puts("Version 4.2, fall 1984."); puts("First Adventure game written by His Lordship, the honorable"); @@ -57,7 +58,7 @@ initialize(startup) srand(getpid()); getutmp(uname); wordinit(); - if (startup) { + if (filename == NULL) { direction = NORTH; ourtime = 0; snooze = CYCLE * 1.5; @@ -67,8 +68,11 @@ initialize(startup) torps = TORPEDOES; for (p = dayobjs; p->room != 0; p++) setbit(location[p->room].objects, p->obj); - } else - restore(); + } else { + savefile = save_file_name(filename, strlen(filename)); + restore(savefile); + free(savefile); + } wiz = wizard(uname); signal(SIGINT, diesig); } |