[chocolate-doom] 08/13: Second configuration file to allow chocolate doom-specific settings. Adjust some existing command line logic (for graphics settings and novert) to adjust for this.

Jonathan Dowland jmtd at moszumanska.debian.org
Mon Jan 30 15:06:32 UTC 2017


This is an automated email from the git hooks/post-receive script.

jmtd pushed a commit to annotated tag chocolate-doom-0.0.2
in repository chocolate-doom.

commit c736059090d59a4eda2c15f924c1a4dfbdd9e61d
Author: Simon Howard <fraggle at gmail.com>
Date:   Sun Sep 11 20:25:56 2005 +0000

    Second configuration file to allow chocolate doom-specific settings.
    Adjust some existing command line logic (for graphics settings and
    novert) to adjust for this.
    
    Subversion-branch: /trunk/chocolate-doom
    Subversion-revision: 98
---
 src/d_main.c   |  45 +++++---------
 src/doomstat.h |   9 ++-
 src/g_game.c   |  12 +++-
 src/i_video.c  |  61 ++++++++++++++-----
 src/i_video.h  |   8 ++-
 src/m_misc.c   | 189 ++++++++++++++++++++++++++++++++++++++++++++-------------
 6 files changed, 232 insertions(+), 92 deletions(-)

diff --git a/src/d_main.c b/src/d_main.c
index 060b6c5..b6b17cf 100644
--- a/src/d_main.c
+++ b/src/d_main.c
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id: d_main.c 94 2005-09-08 22:05:17Z fraggle $
+// $Id: d_main.c 98 2005-09-11 20:25:56Z 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/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
+// novert) to adjust for this.
+//
 // Revision 1.13  2005/09/08 22:05:17  fraggle
 // Allow alt-tab away while running fullscreen
 //
@@ -77,7 +82,7 @@
 //-----------------------------------------------------------------------------
 
 
-static const char rcsid[] = "$Id: d_main.c 94 2005-09-08 22:05:17Z fraggle $";
+static const char rcsid[] = "$Id: d_main.c 98 2005-09-11 20:25:56Z fraggle $";
 
 #define	BGCOLOR		7
 #define	FGCOLOR		8
@@ -179,7 +184,6 @@ boolean		advancedemo;
 
 char		wadfile[1024];		// primary wad file
 char		mapdir[1024];           // directory of development maps
-char		basedefault[1024];      // default file
 
 
 void D_CheckNetGame (void);
@@ -897,24 +901,6 @@ void PrintBanner(char *msg)
     puts(msg);
 }
 
-// Set the default location for the configuration file
-
-void SetBaseDefault(void)
-{
-    char *homedir;
-
-    homedir = getenv("HOME");
-
-    if (homedir != NULL)
-    {
-        sprintf(basedefault, "%s/.doomrc", homedir);
-    }
-    else
-    {
-        strcpy(basedefault, "default.cfg");
-    }
-}
-
 //
 // D_DoomMain
 //
@@ -939,13 +925,6 @@ void D_DoomMain (void)
     else if (M_CheckParm ("-deathmatch"))
 	deathmatch = 1;
 
-    if (M_CheckParm("-novert"))
-        novert = 1;
-
-    // set the location for default.cfg
-
-    SetBaseDefault();
-
     // print banner
 
     PrintBanner(PACKAGE_STRING);
@@ -953,6 +932,8 @@ void D_DoomMain (void)
     if (devparm)
 	printf(D_DEVSTR);
     
+#if 0
+    // BROKEN: -cdrom option
     if (M_CheckParm("-cdrom"))
     {
 	printf(D_CDROM);
@@ -962,7 +943,8 @@ void D_DoomMain (void)
 	mkdir("c:\\doomdata",0);
 #endif
 	strcpy (basedefault,"c:/doomdata/default.cfg");
-    }	
+    }
+#endif     
     
     // turbo option
     if ( (p=M_CheckParm ("-turbo")) )
@@ -1130,6 +1112,11 @@ void D_DoomMain (void)
 	autostart = true;
     }
 
+    if (M_CheckParm("-novert"))
+        novert = true;
+    else if (M_CheckParm("-nonovert"))
+        novert = false;
+
     printf ("===========================================================================\n");
 
     PrintBanner(gamedescription);
diff --git a/src/doomstat.h b/src/doomstat.h
index ad67857..eb8ef8d 100644
--- a/src/doomstat.h
+++ b/src/doomstat.h
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id: doomstat.h 69 2005-09-04 15:59:45Z fraggle $
+// $Id: doomstat.h 98 2005-09-11 20:25:56Z fraggle $
 //
 // Copyright(C) 1993-1996 Id Software, Inc.
 // Copyright(C) 2005 Simon Howard
@@ -86,7 +86,7 @@ extern  int		gameepisode;
 extern  int		gamemap;
 
 // vertical movement from mouse/joystick disabled
-extern  boolean         novert;
+extern  int             novert;
 
 // Nightmare mode flag, single player.
 extern  boolean         respawnmonsters;
@@ -295,6 +295,11 @@ extern	int		ticdup;
 //-----------------------------------------------------------------------------
 //
 // $Log$
+// 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
+// novert) to adjust for this.
+//
 // Revision 1.6  2005/09/04 15:59:45  fraggle
 // 'novert' command line option to disable vertical mouse movement
 //
diff --git a/src/g_game.c b/src/g_game.c
index 044d821..ebc75e9 100644
--- a/src/g_game.c
+++ b/src/g_game.c
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id: g_game.c 71 2005-09-04 18:44:23Z fraggle $
+// $Id: g_game.c 98 2005-09-11 20:25:56Z 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/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
+// novert) to adjust for this.
+//
 // Revision 1.8  2005/09/04 18:44:23  fraggle
 // shut up compiler warnings
 //
@@ -56,7 +61,7 @@
 
 
 static const char
-rcsid[] = "$Id: g_game.c 71 2005-09-04 18:44:23Z fraggle $";
+rcsid[] = "$Id: g_game.c 98 2005-09-11 20:25:56Z fraggle $";
 
 #include <string.h>
 #include <stdlib.h>
@@ -203,8 +208,9 @@ int             joybspeed;
 
 // fraggle: Disallow mouse and joystick movement to cause forward/backward
 // motion.  Specified with the '-novert' command line parameter.
+// This is an int to allow saving to config file
 
-boolean         novert;
+int             novert;
  
  
  
diff --git a/src/i_video.c b/src/i_video.c
index cd9397a..155731b 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id: i_video.c 94 2005-09-08 22:05:17Z fraggle $
+// $Id: i_video.c 98 2005-09-11 20:25:56Z fraggle $
 //
 // Copyright(C) 1993-1996 Id Software, Inc.
 // Copyright(C) 2005 Simon Howard
@@ -22,6 +22,11 @@
 // 02111-1307, USA.
 //
 // $Log$
+// Revision 1.25  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
+// novert) to adjust for this.
+//
 // Revision 1.24  2005/09/08 22:05:17  fraggle
 // Allow alt-tab away while running fullscreen
 //
@@ -110,7 +115,7 @@
 //-----------------------------------------------------------------------------
 
 static const char
-rcsid[] = "$Id: i_video.c 94 2005-09-08 22:05:17Z fraggle $";
+rcsid[] = "$Id: i_video.c 98 2005-09-11 20:25:56Z fraggle $";
 
 #include <ctype.h>
 #include <SDL.h>
@@ -145,15 +150,21 @@ static int windowwidth, windowheight;
 
 static boolean native_surface;
 
-boolean fullscreen = true;
-boolean grabmouse = true;
+// Run in full screen mode?  (int type for config code)
+int fullscreen = true;
+
+// Grab the mouse? (int type for config code)
+int grabmouse = true;
+
+// Flag indicating whether the screen is currently visible:
+// when the screen isnt visible, don't render the screen
 boolean screenvisible;
 
 // Blocky mode,
-// replace each 320x200 pixel with multiply*multiply pixels.
+// replace each 320x200 pixel with screenmultiply*screenmultiply pixels.
 // According to Dave Taylor, it still is a bonehead thing
 // to use ....
-static int	multiply=1;
+int screenmultiply = 1;
 
 // disk image data and background overwritten by the disk to be
 // restored by EndRead
@@ -548,7 +559,7 @@ void I_FinishUpdate (void)
     
     }
 
-    if (multiply == 1 && !native_surface)
+    if (screenmultiply == 1 && !native_surface)
     {
         byte *bufp, *screenp;
         int y;
@@ -572,7 +583,7 @@ void I_FinishUpdate (void)
 
     // scales the screen size before blitting it
 
-    if (multiply == 2)
+    if (screenmultiply == 2)
     {
         byte *bufp, *screenp, *screenp2;
         int x, y;
@@ -680,14 +691,28 @@ void I_InitGraphics(void)
 
     flags |= SDL_SWSURFACE | SDL_HWPALETTE | SDL_DOUBLEBUF;
 
-    // mouse grabbing, defaults to on
+    // mouse grabbing
 
-    grabmouse = !M_CheckParm("-nograbmouse");
+    if (M_CheckParm("-grabmouse"))
+    {
+        grabmouse = true;
+    }
+    else if (M_CheckParm("-nograbmouse"))
+    {
+        grabmouse = false;
+    }
 
     // default to fullscreen mode, allow override with command line
     // nofullscreen because we love prboom
 
-    fullscreen = !M_CheckParm("-window") && !M_CheckParm("-nofullscreen");
+    if (M_CheckParm("-window") || M_CheckParm("-nofullscreen"))
+    {
+        fullscreen = false;
+    }
+    else if (M_CheckParm("-fullscreen"))
+    {
+        fullscreen = true;
+    }
 
     if (fullscreen)
     {
@@ -696,13 +721,17 @@ void I_InitGraphics(void)
 
     // scale-by-2 mode
  
-    if (M_CheckParm("-2"))
+    if (M_CheckParm("-1"))
+    {
+        screenmultiply = 1;
+    }
+    else if (M_CheckParm("-2"))
     {
-        multiply = 2;
+        screenmultiply = 2;
     }
 
-    windowwidth = SCREENWIDTH * multiply;
-    windowheight = SCREENHEIGHT * multiply;
+    windowwidth = SCREENWIDTH * screenmultiply;
+    windowheight = SCREENHEIGHT * screenmultiply;
 
     screen = SDL_SetVideoMode(windowwidth, windowheight, 8, flags);
 
@@ -718,7 +747,7 @@ void I_InitGraphics(void)
 
     // Check if we have a native surface we can use
 
-    native_surface = multiply == 1 && screen->pitch == SCREENWIDTH;
+    native_surface = screenmultiply == 1 && screen->pitch == SCREENWIDTH;
 
     // If not, allocate a buffer and copy from that buffer to the 
     // screen when we do an update
diff --git a/src/i_video.h b/src/i_video.h
index d007cac..a5d9856 100644
--- a/src/i_video.h
+++ b/src/i_video.h
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id: i_video.h 97 2005-09-11 16:39:29Z fraggle $
+// $Id: i_video.h 98 2005-09-11 20:25:56Z fraggle $
 //
 // Copyright(C) 1993-1996 Id Software, Inc.
 // Copyright(C) 2005 Simon Howard
@@ -58,6 +58,7 @@ void I_BeginRead (void);
 void I_EndRead (void);
 
 extern boolean screenvisible;
+extern int screenmultiply;
 extern boolean fullscreen;
 extern boolean grabmouse;
 
@@ -66,6 +67,11 @@ extern boolean grabmouse;
 //-----------------------------------------------------------------------------
 //
 // $Log$
+// Revision 1.6  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
+// novert) to adjust for this.
+//
 // Revision 1.5  2005/09/11 16:39:29  fraggle
 // Fix declaration of I_Sleep (not I_Delay) and move to right header
 //
diff --git a/src/m_misc.c b/src/m_misc.c
index 92ecc39..7e0a4ce 100644
--- a/src/m_misc.c
+++ b/src/m_misc.c
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id: m_misc.c 85 2005-09-07 21:40:11Z fraggle $
+// $Id: m_misc.c 98 2005-09-11 20:25:56Z fraggle $
 //
 // Copyright(C) 1993-1996 Id Software, Inc.
 // Copyright(C) 2005 Simon Howard
@@ -23,6 +23,11 @@
 //
 //
 // $Log$
+// Revision 1.9  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
+// novert) to adjust for this.
+//
 // Revision 1.8  2005/09/07 21:40:11  fraggle
 // Remove non-ANSI C headers and functions
 //
@@ -60,13 +65,24 @@
 //-----------------------------------------------------------------------------
 
 static const char
-rcsid[] = "$Id: m_misc.c 85 2005-09-07 21:40:11Z fraggle $";
+rcsid[] = "$Id: m_misc.c 98 2005-09-11 20:25:56Z fraggle $";
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <ctype.h>
 
+// for mkdir:
+
+#ifdef _WIN32
+#include <io.h>
+#else
+#include <sys/stat.h>
+#include <sys/types.h>
+#endif
+
+
 
+#include "config.h"
 #include "doomdef.h"
 
 #include "z_zone.h"
@@ -136,10 +152,6 @@ M_DrawText
 //
 // M_WriteFile
 //
-#ifndef O_BINARY
-#define O_BINARY 0
-#endif
-
 boolean M_WriteFile(char const *name, void *source, int	length)
 {
     FILE *handle;
@@ -195,6 +207,9 @@ int M_ReadFile(char const *name, byte **buffer)
 //
 // DEFAULTS
 //
+
+// locations of config files
+
 int		usemouse;
 int		usejoystick;
 
@@ -258,7 +273,14 @@ typedef struct
     int         untranslated;
 } default_t;
 
-default_t	defaults[] =
+typedef struct
+{
+    default_t *defaults;
+    int        numdefaults;
+    char      *filename;
+} default_collection_t;
+
+static default_t	doom_defaults_list[] =
 {
     {"mouse_sensitivity",&mouseSensitivity, 5},
     {"sfx_volume",&snd_SfxVolume, 8},
@@ -316,8 +338,25 @@ default_t	defaults[] =
 
 };
 
-int	numdefaults;
-char*	defaultfile;
+static default_collection_t doom_defaults = 
+{
+    doom_defaults_list,
+    sizeof(doom_defaults_list) / sizeof(*doom_defaults_list),
+};
+
+static default_t extra_defaults_list[] = 
+{
+    {"grabmouse",   &grabmouse,      true},
+    {"fullscreen",  &fullscreen,     true},
+    {"screenmultiply", &screenmultiply, 1},
+    {"novert",      &novert,         false},
+};
+
+static default_collection_t extra_defaults =
+{
+    extra_defaults_list,
+    sizeof(extra_defaults_list) / sizeof(*extra_defaults_list),
+};
 
 static int scantokey[128] =
 {
@@ -340,22 +379,20 @@ static int scantokey[128] =
 };
 
 
-
-//
-// M_SaveDefaults
-//
-
-void M_SaveDefaults (void)
+static void SaveDefaultCollection(default_collection_t *collection)
 {
-    int		i;
-    int		v;
-    FILE*	f;
+    default_t *defaults;
+    int i;
+    int v;
+    FILE *f;
 	
-    f = fopen (defaultfile, "w");
+    f = fopen (collection->filename, "w");
     if (!f)
 	return; // can't write the file, but don't complain
+
+    defaults = collection->defaults;
 		
-    for (i=0 ; i<numdefaults ; i++)
+    for (i=0 ; i<collection->numdefaults ; i++)
     {
 	if (defaults[i].defaultvalue > -0xfff
 	    && defaults[i].defaultvalue < 0xfff)
@@ -401,13 +438,9 @@ void M_SaveDefaults (void)
     fclose (f);
 }
 
-
-//
-// M_LoadDefaults
-//
-
-void M_LoadDefaults (void)
+static void LoadDefaultCollection(default_collection_t *collection)
 {
+    default_t  *defaults = collection->defaults;
     int		i;
     int		len;
     FILE*	f;
@@ -416,26 +449,18 @@ void M_LoadDefaults (void)
     char*	newstring = "";
     int		parm;
     boolean	isstring;
-    
+
     // set everything to base values
-    numdefaults = sizeof(defaults)/sizeof(defaults[0]);
-    for (i=0 ; i<numdefaults ; i++)
+ 
+    for (i=0 ; i<collection->numdefaults ; i++)
     {
 	*((int *) defaults[i].location) = defaults[i].defaultvalue;
         defaults[i].untranslated = 0;
     }
-    // check for a custom default file
-    i = M_CheckParm ("-config");
-    if (i && i<myargc-1)
-    {
-	defaultfile = myargv[i+1];
-	printf ("	default file: %s\n",defaultfile);
-    }
-    else
-	defaultfile = basedefault;
-    
+
     // read the file in, overriding any set defaults
-    f = fopen (defaultfile, "r");
+    f = fopen(collection->filename, "r");
+
     if (f)
     {
 	while (!feof(f))
@@ -456,7 +481,7 @@ void M_LoadDefaults (void)
 		    sscanf(strparm+2, "%x", &parm);
 		else
 		    sscanf(strparm, "%i", &parm);
-		for (i=0 ; i<numdefaults ; i++)
+		for (i=0 ; i<collection->numdefaults ; i++)
 		    if (!strcmp(def, defaults[i].name))
 		    {
                         if (defaults[i].scantranslate)
@@ -481,6 +506,88 @@ void M_LoadDefaults (void)
     }
 }
 
+//
+// M_SaveDefaults
+//
+
+void M_SaveDefaults (void)
+{
+    SaveDefaultCollection(&doom_defaults);
+    SaveDefaultCollection(&extra_defaults);
+}
+
+
+//
+// M_LoadDefaults
+//
+
+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");
+
+    if (i && i<myargc-1)
+    {
+	doom_defaults.filename = myargv[i+1];
+	printf ("	default file: %s\n",doom_defaults.filename);
+    }
+    else
+    {
+        doom_defaults.filename = malloc(strlen(config_dir) + 10);
+        sprintf(doom_defaults.filename, "%sdefault.cfg", config_dir);
+    }
+
+    printf("saving config in %s\n", doom_defaults.filename);
+
+    i = M_CheckParm("-extraconfig");
+
+    if (i && i<myargc-1)
+    {
+        extra_defaults.filename = myargv[i+1];
+        printf("        extra configuration file: %s\n", 
+               extra_defaults.filename);
+    }
+    else
+    {
+        extra_defaults.filename 
+            = malloc(strlen(config_dir) + strlen(PACKAGE_TARNAME) + 10);
+        sprintf(extra_defaults.filename, "%s%s.cfg", 
+                config_dir, PACKAGE_TARNAME);
+    }
+
+    LoadDefaultCollection(&doom_defaults);
+    LoadDefaultCollection(&extra_defaults);
+
+    free(config_dir);
+}
+
 
 //
 // SCREEN SHOTS

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/chocolate-doom.git



More information about the Pkg-games-commits mailing list