ref: 8d9ee8259d629ef11a33e6710091f4f9bb15a1a2
parent: 6dfceb2ce609dcf05ce4b94ebeb2407f7990374f
author: Simon Howard <fraggle@gmail.com>
date: Sat Oct 15 21:18:10 EDT 2005
Global "configdir" variable with directory to store config files in. Create a function to find the filename for a savegame slot. Store savegames in the config dir. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 202
--- a/src/d_main.c
+++ b/src/d_main.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: d_main.c 200 2005-10-15 17:57:47Z fraggle $
+// $Id: d_main.c 202 2005-10-16 01:18:10Z fraggle $
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
@@ -22,6 +22,11 @@
// 02111-1307, USA.
//
// $Log$
+// Revision 1.28 2005/10/16 01:18:10 fraggle
+// Global "configdir" variable with directory to store config files in.
+// Create a function to find the filename for a savegame slot. Store
+// savegames in the config dir.
+//
// Revision 1.27 2005/10/15 17:57:47 fraggle
// Add warning message for WADs with FF_START or SS_START in, suggesting
// the -merge option.
@@ -125,7 +130,7 @@
//-----------------------------------------------------------------------------
-static const char rcsid[] = "$Id: d_main.c 200 2005-10-15 17:57:47Z fraggle $";
+static const char rcsid[] = "$Id: d_main.c 202 2005-10-16 01:18:10Z fraggle $";
#define BGCOLOR 7
#define FGCOLOR 8
@@ -166,6 +171,7 @@
#include "m_argv.h"
#include "m_misc.h"
#include "m_menu.h"
+#include "p_saveg.h"
#include "i_system.h"
#include "i_sound.h"
@@ -195,11 +201,17 @@
//
void D_DoomLoop (void);
+// Location where all configuration data is stored -
+// default.cfg, savegames, etc.
-char* iwadfile;
-char* wadfiles[MAXWADFILES];
+char * configdir;
+// location of IWAD and WAD files
+char * iwadfile;
+char * wadfiles[MAXWADFILES];
+
+
boolean devparm; // started game with -devparm
boolean nomonsters; // checkparm of -nomonsters
boolean respawnparm; // checkparm of -respawn
@@ -550,7 +562,7 @@
// This cycles through the demo sequences.
// FIXME - version dependend demo numbers?
//
- void D_DoAdvanceDemo (void)
+void D_DoAdvanceDemo (void)
{
players[consoleplayer].playerstate = PST_LIVE; // not reborn
advancedemo = false;
@@ -1068,7 +1080,43 @@
}
}
+//
+// SetConfigDir:
//
+// Sets the location of the configuration directory, where configuration
+// files are stored - default.cfg, chocolate-doom.cfg, savegames, etc.
+//
+
+static void SetConfigDir(void)
+{
+ char *homedir;
+ int i;
+
+ homedir = getenv("HOME");
+
+ if (homedir != NULL)
+ {
+ // put all configuration in a config directory off the
+ // homedir
+
+ configdir = malloc(strlen(homedir) + strlen(PACKAGE_TARNAME) + 5);
+
+ sprintf(configdir, "%s/.%s/", homedir, PACKAGE_TARNAME);
+
+ // make the directory if it doesnt already exist
+#ifdef _WIN32
+ mkdir(configdir);
+#else
+ mkdir(configdir, 0755);
+#endif
+ }
+ else
+ {
+ configdir = strdup("");
+ }
+}
+
+//
// D_DoomMain
//
void D_DoomMain (void)
@@ -1112,6 +1160,10 @@
strcpy (basedefault,"c:/doomdata/default.cfg");
}
#endif
+
+ // find which dir to use for config files
+
+ SetConfigDir();
// turbo option
if ( (p=M_CheckParm ("-turbo")) )
@@ -1378,10 +1430,14 @@
p = M_CheckParm ("-loadgame");
if (p && p < myargc-1)
{
+#if 0
+ // -cdrom currently broken
if (M_CheckParm("-cdrom"))
sprintf(file, "c:\\doomdata\\"SAVEGAMENAME"%c.dsg",myargv[p+1][0]);
else
- sprintf(file, SAVEGAMENAME"%c.dsg",myargv[p+1][0]);
+#endif
+
+ strcpy(file, P_SaveGameFile(atoi(myargv[p+1])));
G_LoadGame (file);
}
--- a/src/doomstat.h
+++ b/src/doomstat.h
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: doomstat.h 98 2005-09-11 20:25:56Z fraggle $
+// $Id: doomstat.h 202 2005-10-16 01:18:10Z fraggle $
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
@@ -244,6 +244,7 @@
//
// File handling stuff.
+extern char * configdir;
extern char basedefault[1024];
extern FILE* debugfile;
@@ -295,6 +296,11 @@
//-----------------------------------------------------------------------------
//
// $Log$
+// Revision 1.8 2005/10/16 01:18:10 fraggle
+// Global "configdir" variable with directory to store config files in.
+// Create a function to find the filename for a savegame slot. Store
+// savegames in the config dir.
+//
// Revision 1.7 2005/09/11 20:25:56 fraggle
// Second configuration file to allow chocolate doom-specific settings.
// Adjust some existing command line logic (for graphics settings and
--- a/src/g_game.c
+++ b/src/g_game.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: g_game.c 192 2005-10-13 23:12:30Z fraggle $
+// $Id: g_game.c 202 2005-10-16 01:18:10Z fraggle $
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
@@ -22,6 +22,11 @@
// 02111-1307, USA.
//
// $Log$
+// Revision 1.14 2005/10/16 01:18:10 fraggle
+// Global "configdir" variable with directory to store config files in.
+// Create a function to find the filename for a savegame slot. Store
+// savegames in the config dir.
+//
// Revision 1.13 2005/10/13 23:12:30 fraggle
// Fix Doom 1 skies
//
@@ -77,7 +82,7 @@
static const char
-rcsid[] = "$Id: g_game.c 192 2005-10-13 23:12:30Z fraggle $";
+rcsid[] = "$Id: g_game.c 202 2005-10-16 01:18:10Z fraggle $";
#include <string.h>
#include <stdlib.h>
@@ -1367,10 +1372,15 @@
int length;
int i;
+#if 0
+ // -cdrom currently broken
if (M_CheckParm("-cdrom"))
sprintf(name,"c:\\doomdata\\"SAVEGAMENAME"%d.dsg",savegameslot);
else
- sprintf (name,SAVEGAMENAME"%d.dsg",savegameslot);
+#endif
+
+ strcpy(name, P_SaveGameFile(savegameslot));
+
description = savedescription;
save_p = savebuffer = screens[1]+0x4000;
--- a/src/m_menu.c
+++ b/src/m_menu.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: m_menu.c 160 2005-10-03 21:39:39Z fraggle $
+// $Id: m_menu.c 202 2005-10-16 01:18:10Z fraggle $
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
@@ -22,6 +22,11 @@
// 02111-1307, USA.
//
// $Log$
+// Revision 1.9 2005/10/16 01:18:10 fraggle
+// Global "configdir" variable with directory to store config files in.
+// Create a function to find the filename for a savegame slot. Store
+// savegames in the config dir.
+//
// Revision 1.8 2005/10/03 21:39:39 fraggle
// Dehacked text substitutions
//
@@ -57,7 +62,7 @@
//-----------------------------------------------------------------------------
static const char
-rcsid[] = "$Id: m_menu.c 160 2005-10-03 21:39:39Z fraggle $";
+rcsid[] = "$Id: m_menu.c 202 2005-10-16 01:18:10Z fraggle $";
#include <stdlib.h>
#include <ctype.h>
@@ -84,6 +89,7 @@
#include "m_argv.h"
#include "m_swap.h"
+#include "p_saveg.h"
#include "s_sound.h"
@@ -549,10 +555,13 @@
for (i = 0;i < load_end;i++)
{
+#if 0
+ // -cdrom currently broken
if (M_CheckParm("-cdrom"))
sprintf(name,"c:\\doomdata\\"SAVEGAMENAME"%d.dsg",i);
else
- sprintf(name,SAVEGAMENAME"%d.dsg",i);
+#endif
+ strcpy(name, P_SaveGameFile(i));
handle = fopen(name, "rb");
if (handle == NULL)
@@ -612,10 +621,13 @@
{
char name[256];
+#if 0
if (M_CheckParm("-cdrom"))
sprintf(name,"c:\\doomdata\\"SAVEGAMENAME"%d.dsg",choice);
else
- sprintf(name,SAVEGAMENAME"%d.dsg",choice);
+#endif
+ strcpy(name, P_SaveGameFile(choice));
+
G_LoadGame (name);
M_ClearMenus ();
}
--- a/src/m_misc.c
+++ b/src/m_misc.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: m_misc.c 111 2005-09-17 20:50:46Z fraggle $
+// $Id: m_misc.c 202 2005-10-16 01:18:10Z fraggle $
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
@@ -23,6 +23,11 @@
//
//
// $Log$
+// Revision 1.13 2005/10/16 01:18:10 fraggle
+// Global "configdir" variable with directory to store config files in.
+// Create a function to find the filename for a savegame slot. Store
+// savegames in the config dir.
+//
// Revision 1.12 2005/09/17 20:50:46 fraggle
// Mouse acceleration code to emulate old DOS drivers
//
@@ -78,7 +83,7 @@
//-----------------------------------------------------------------------------
static const char
-rcsid[] = "$Id: m_misc.c 111 2005-09-17 20:50:46Z fraggle $";
+rcsid[] = "$Id: m_misc.c 202 2005-10-16 01:18:10Z fraggle $";
#include <stdio.h>
#include <stdlib.h>
@@ -586,33 +591,9 @@
void M_LoadDefaults (void)
{
- char *config_dir;
char *homedir;
int i;
-
- homedir = getenv("HOME");
-
- if (homedir != NULL)
- {
- // put all configuration in a config directory off the
- // homedir
-
- config_dir = malloc(strlen(homedir) + strlen(PACKAGE_TARNAME) + 5);
-
- sprintf(config_dir, "%s/.%s/", homedir, PACKAGE_TARNAME);
-
- // make the directory if it doesnt already exist
-#ifdef _WIN32
- mkdir(config_dir);
-#else
- mkdir(config_dir, 0755);
-#endif
- }
- else
- {
- config_dir = strdup("");
- }
-
+
// check for a custom default file
i = M_CheckParm ("-config");
@@ -623,8 +604,8 @@
}
else
{
- doom_defaults.filename = malloc(strlen(config_dir) + 10);
- sprintf(doom_defaults.filename, "%sdefault.cfg", config_dir);
+ doom_defaults.filename = malloc(strlen(configdir) + 10);
+ sprintf(doom_defaults.filename, "%sdefault.cfg", configdir);
}
printf("saving config in %s\n", doom_defaults.filename);
@@ -640,15 +621,13 @@
else
{
extra_defaults.filename
- = malloc(strlen(config_dir) + strlen(PACKAGE_TARNAME) + 10);
+ = malloc(strlen(configdir) + strlen(PACKAGE_TARNAME) + 10);
sprintf(extra_defaults.filename, "%s%s.cfg",
- config_dir, PACKAGE_TARNAME);
+ configdir, PACKAGE_TARNAME);
}
LoadDefaultCollection(&doom_defaults);
LoadDefaultCollection(&extra_defaults);
-
- free(config_dir);
}
--- a/src/p_saveg.c
+++ b/src/p_saveg.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: p_saveg.c 8 2005-07-23 16:44:57Z fraggle $
+// $Id: p_saveg.c 202 2005-10-16 01:18:10Z fraggle $
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
@@ -22,6 +22,11 @@
// 02111-1307, USA.
//
// $Log$
+// Revision 1.3 2005/10/16 01:18:10 fraggle
+// Global "configdir" variable with directory to store config files in.
+// Create a function to find the filename for a savegame slot. Store
+// savegames in the config dir.
+//
// Revision 1.2 2005/07/23 16:44:56 fraggle
// Update copyright to GNU GPL
//
@@ -35,8 +40,10 @@
//-----------------------------------------------------------------------------
static const char
-rcsid[] = "$Id: p_saveg.c 8 2005-07-23 16:44:57Z fraggle $";
+rcsid[] = "$Id: p_saveg.c 202 2005-10-16 01:18:10Z fraggle $";
+#include "dstrings.h"
+#include "deh_main.h"
#include "i_system.h"
#include "z_zone.h"
#include "p_local.h"
@@ -52,6 +59,18 @@
// so that the load/save works on SGI&Gecko.
#define PADSAVEP() save_p += (4 - ((int) save_p & 3)) & 3
+
+char *P_SaveGameFile(int slot)
+{
+ static char filename[256];
+ char basename[32];
+
+ sprintf(basename, DEH_String(SAVEGAMENAME "%d.dsg"), slot);
+
+ sprintf(filename, "%s%s", configdir, basename);
+
+ return filename;
+}
//
--- a/src/p_saveg.h
+++ b/src/p_saveg.h
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: p_saveg.h 18 2005-07-23 18:56:07Z fraggle $
+// $Id: p_saveg.h 202 2005-10-16 01:18:10Z fraggle $
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
@@ -30,7 +30,9 @@
#ifndef __P_SAVEG__
#define __P_SAVEG__
+// filename to use for a savegame slot
+char *P_SaveGameFile(int slot);
// Persistent storage/archiving.
@@ -51,6 +53,11 @@
//-----------------------------------------------------------------------------
//
// $Log$
+// Revision 1.4 2005/10/16 01:18:10 fraggle
+// Global "configdir" variable with directory to store config files in.
+// Create a function to find the filename for a savegame slot. Store
+// savegames in the config dir.
+//
// Revision 1.3 2005/07/23 18:56:07 fraggle
// Remove unneccessary pragmas
//