shithub: choc

Download patch

ref: c33d1935292af81142783137e09dec828df298bc
parent: c253a1522f6f286258bb6d753e5b01fbd887a880
author: Simon Howard <[email protected]>
date: Fri Sep 26 21:54:19 EDT 2008

Save Heretic configuration files on exit.

Subversion-branch: /branches/raven-branch
Subversion-revision: 1294

--- a/src/doom/d_main.c
+++ b/src/doom/d_main.c
@@ -1011,6 +1011,7 @@
 
     // Load configuration files before initialising other subsystems.
     printf(DEH_String("M_LoadDefaults: Load system defaults.\n"));
+    M_SetConfigFilenames("default.cfg", PROGRAM_PREFIX "doom.cfg");
     D_BindVariables();
     M_LoadDefaults();
 
--- a/src/heretic/d_main.c
+++ b/src/heretic/d_main.c
@@ -26,6 +26,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+#include "config.h"
 #include "ct_chat.h"
 #include "doomdef.h"
 #include "i_system.h"
@@ -652,7 +653,7 @@
     _setbkcolor(4);             // Red
     _settextcolor(14);          // Yellow
     _settextposition(3, 47);
-    _outtext(VERSION_TEXT);
+    _outtext(HERETIC_VERSION_TEXT);
 
     // Hide cursor
     _settextcursor(0x2000);
@@ -914,9 +915,11 @@
 
     // Load defaults before initing other systems
     printf("M_LoadDefaults: Load system defaults.\n");
+    D_BindVariables();
+    M_SetConfigFilenames("heretic.cfg", PROGRAM_PREFIX "heretic.cfg");
     M_LoadDefaults();
 
-    //I_AtExit(M_SaveDefaults, false);
+    I_AtExit(M_SaveDefaults, false);
 
     printf("Z_Init: Init zone memory allocation daemon.\n");
     Z_Init();
--- a/src/heretic/d_net.c
+++ b/src/heretic/d_net.c
@@ -521,7 +521,7 @@
                 continue;
             if (netbuffer->checksum & NCMD_SETUP)
             {
-                if (netbuffer->player != VERSION)
+                if (netbuffer->player != HERETIC_VERSION)
                     I_Error
                         ("Different DOOM versions cannot play a net game!");
                 startskill = netbuffer->retransmitfrom & 15;
@@ -553,7 +553,7 @@
                     netbuffer->retransmitfrom |= 0x10;
                 //netbuffer->starttic = startepisode * 64 + startmap;
                 netbuffer->starttic = (startepisode << 4) + startmap;
-                netbuffer->player = VERSION;
+                netbuffer->player = HERETIC_VERSION;
                 netbuffer->numtics = 0;
                 HSendPacket(i, NCMD_SETUP);
             }
--- a/src/heretic/doomdef.h
+++ b/src/heretic/doomdef.h
@@ -34,8 +34,8 @@
 #endif
 #include <limits.h>
 
-#define VERSION 130
-#define VERSION_TEXT "v1.3"
+#define HERETIC_VERSION 130
+#define HERETIC_VERSION_TEXT "v1.3"
 
 // if rangecheck is undefined, most parameter validation debugging code
 // will not be compiled
--- a/src/heretic/g_game.c
+++ b/src/heretic/g_game.c
@@ -1487,7 +1487,7 @@
     save_p = savebuffer + SAVESTRINGSIZE;
     // Skip the description field
     memset(vcheck, 0, sizeof(vcheck));
-    sprintf(vcheck, "version %i", VERSION);
+    sprintf(vcheck, "version %i", HERETIC_VERSION);
     if (strcmp((char *) save_p, vcheck) != 0)
     {                           // Bad version
         return;
@@ -1861,7 +1861,7 @@
     SV_Open(name);
     SV_Write(description, SAVESTRINGSIZE);
     memset(verString, 0, sizeof(verString));
-    sprintf(verString, "version %i", VERSION);
+    sprintf(verString, "version %i", HERETIC_VERSION);
     SV_Write(verString, VERSIONSIZE);
     SV_WriteByte(gameskill);
     SV_WriteByte(gameepisode);
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -51,6 +51,11 @@
 
 char *configdir;
 
+// Default filenames for configuration files.
+
+static char *default_main_config;
+static char *default_extra_config;
+
 typedef enum 
 {
     DEFAULT_INT,
@@ -916,6 +921,14 @@
     fclose (f);
 }
 
+// Set the default filenames to use for configuration files.
+
+void M_SetConfigFilenames(char *main_config, char *extra_config)
+{
+    default_main_config = main_config;
+    default_extra_config = extra_config;
+}
+
 //
 // M_SaveDefaults
 //
@@ -940,8 +953,8 @@
     // @arg <file>
     // @vanilla
     //
-    // Load configuration from the specified file, instead of
-    // default.cfg.
+    // Load configuration from the specified file.  The default 
+    // configuration file (for Doom) is named default.cfg.
     //
 
     i = M_CheckParm ("-config");
@@ -953,8 +966,9 @@
     }
     else
     {
-        doom_defaults.filename = malloc(strlen(configdir) + 20);
-        sprintf(doom_defaults.filename, "%sdefault.cfg", configdir);
+        doom_defaults.filename
+            = malloc(strlen(configdir) + strlen(default_main_config) + 1);
+        sprintf(doom_defaults.filename, "%s%s", configdir, default_main_config);
     }
 
     printf("saving config in %s\n", doom_defaults.filename);
@@ -962,8 +976,8 @@
     //!
     // @arg <file>
     //
-    // Load extra configuration from the specified file, instead 
-    // of chocolate-doom.cfg.
+    // Load extra configuration from the specified file.  The default
+    // configuration file for Doom is named chocolate-doom.cfg.
     //
 
     i = M_CheckParm("-extraconfig");
@@ -977,9 +991,9 @@
     else
     {
         extra_defaults.filename 
-            = malloc(strlen(configdir) + strlen(PACKAGE_TARNAME) + 10);
-        sprintf(extra_defaults.filename, "%s%s.cfg", 
-                configdir, PACKAGE_TARNAME);
+            = malloc(strlen(configdir) + strlen(default_extra_config) + 1);
+        sprintf(extra_defaults.filename, "%s%s", 
+                configdir, default_extra_config);
     }
 
     LoadDefaultCollection(&doom_defaults);
--- a/src/m_config.h
+++ b/src/m_config.h
@@ -32,6 +32,7 @@
 void M_SaveDefaults(void);
 void M_SetConfigDir(void);
 void M_BindVariable(char *name, void *variable);
+void M_SetConfigFilenames(char *main_config, char *extra_config);
 
 extern char *configdir;