summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Howard2005-10-16 01:18:10 +0000
committerSimon Howard2005-10-16 01:18:10 +0000
commit8d9ee8259d629ef11a33e6710091f4f9bb15a1a2 (patch)
treed6ffea91332b2118fac999a289e19ff91f27ee02
parent6dfceb2ce609dcf05ce4b94ebeb2407f7990374f (diff)
downloadchocolate-doom-8d9ee8259d629ef11a33e6710091f4f9bb15a1a2.tar.gz
chocolate-doom-8d9ee8259d629ef11a33e6710091f4f9bb15a1a2.tar.bz2
chocolate-doom-8d9ee8259d629ef11a33e6710091f4f9bb15a1a2.zip
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
-rw-r--r--src/d_main.c68
-rw-r--r--src/doomstat.h8
-rw-r--r--src/g_game.c16
-rw-r--r--src/m_menu.c20
-rw-r--r--src/m_misc.c45
-rw-r--r--src/p_saveg.c23
-rw-r--r--src/p_saveg.h9
7 files changed, 139 insertions, 50 deletions
diff --git a/src/d_main.c b/src/d_main.c
index 2a0d1755..c0d6e8d4 100644
--- 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 @@ static const char rcsid[] = "$Id: d_main.c 200 2005-10-15 17:57:47Z fraggle $";
#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,9 +201,15 @@ static const char rcsid[] = "$Id: d_main.c 200 2005-10-15 17:57:47Z fraggle $";
//
void D_DoomLoop (void);
+// Location where all configuration data is stored -
+// default.cfg, savegames, etc.
+
+char * configdir;
-char* iwadfile;
-char* wadfiles[MAXWADFILES];
+// location of IWAD and WAD files
+
+char * iwadfile;
+char * wadfiles[MAXWADFILES];
boolean devparm; // started game with -devparm
@@ -550,7 +562,7 @@ void D_AdvanceDemo (void)
// 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,6 +1080,42 @@ void PrintDehackedBanners(void)
}
}
+//
+// 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
//
@@ -1112,6 +1160,10 @@ void D_DoomMain (void)
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 @@ void D_DoomMain (void)
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);
}
diff --git a/src/doomstat.h b/src/doomstat.h
index eb8ef8d4..3fa94c51 100644
--- 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 @@ extern int maxammo[NUMAMMO];
//
// File handling stuff.
+extern char * configdir;
extern char basedefault[1024];
extern FILE* debugfile;
@@ -295,6 +296,11 @@ extern int ticdup;
//-----------------------------------------------------------------------------
//
// $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
diff --git a/src/g_game.c b/src/g_game.c
index 6405343f..fac27351 100644
--- 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 @@ void G_DoSaveGame (void)
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;
diff --git a/src/m_menu.c b/src/m_menu.c
index 2f429c3e..2b0d4187 100644
--- 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 @@ rcsid[] = "$Id: m_menu.c 160 2005-10-03 21:39:39Z fraggle $";
#include "m_argv.h"
#include "m_swap.h"
+#include "p_saveg.h"
#include "s_sound.h"
@@ -549,10 +555,13 @@ void M_ReadSaveStrings(void)
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 @@ void M_LoadSelect(int choice)
{
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 ();
}
diff --git a/src/m_misc.c b/src/m_misc.c
index 95d13738..4af77c05 100644
--- 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_SaveDefaults (void)
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 @@ void M_LoadDefaults (void)
}
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 @@ void M_LoadDefaults (void)
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);
}
diff --git a/src/p_saveg.c b/src/p_saveg.c
index 41ff403b..0073e6e3 100644
--- 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"
@@ -53,6 +60,18 @@ byte* save_p;
#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;
+}
+
//
// P_ArchivePlayers
diff --git a/src/p_saveg.h b/src/p_saveg.h
index d3f53303..d6f95f11 100644
--- 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 @@ extern byte* save_p;
//-----------------------------------------------------------------------------
//
// $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
//