From 932e74d4028472671e706b8d64965ef4a4293d0f Mon Sep 17 00:00:00 2001 From: hubertf Date: Wed, 28 Jul 1999 01:45:41 +0000 Subject: 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 Minor modification (s/startup/filename/ in initialize()) by me. --- battlestar/init.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'battlestar/init.c') 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); } -- cgit v1.2.3