From 30b2e71c09f4de8d8f1d643da27e06ae6b0ea98e Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Mon, 23 Oct 2006 18:00:30 +0000 Subject: Add m_argv.[ch] from Doom, fix up configfile.c so that it compiles properly. Add to build. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 719 --- setup/Makefile.am | 2 ++ setup/configfile.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- setup/m_argv.c | 57 ++++++++++++++++++++++++++++++++++++++++++ setup/m_argv.h | 42 +++++++++++++++++++++++++++++++ 4 files changed, 171 insertions(+), 2 deletions(-) create mode 100644 setup/m_argv.c create mode 100644 setup/m_argv.h (limited to 'setup') diff --git a/setup/Makefile.am b/setup/Makefile.am index 9dc5cb11..cb3f2e45 100644 --- a/setup/Makefile.am +++ b/setup/Makefile.am @@ -8,8 +8,10 @@ games_PROGRAMS = chocolate-setup chocolate_setup_LDADD = @LDFLAGS@ @SDL_LIBS@ ../textscreen/libtextscreen.a chocolate_setup_SOURCES = \ compatibility.c compatibility.h \ + configfile.c configfile.h \ display.c display.h \ keyboard.c keyboard.h \ + m_argv.c m_argv.h \ mainmenu.c \ mouse.c mouse.h \ multiplayer.c multiplayer.h \ diff --git a/setup/configfile.c b/setup/configfile.c index 3666c7d6..82a7963b 100644 --- a/setup/configfile.c +++ b/setup/configfile.c @@ -29,6 +29,7 @@ #include #include #include +#include // for mkdir: @@ -41,6 +42,7 @@ #include "config.h" #include "doomkeys.h" +#include "m_argv.h" #include "compatibility.h" #include "display.h" @@ -49,6 +51,71 @@ #include "multiplayer.h" #include "sound.h" +char *configdir; + +// +// Create a directory +// + +void M_MakeDirectory(char *path) +{ +#ifdef _WIN32 + mkdir(path); +#else + mkdir(path, 0755); +#endif +} + + +// +// SetConfigDir: +// +// Sets the location of the configuration directory, where configuration +// files are stored - default.cfg, chocolate-doom.cfg, savegames, etc. +// + +void M_SetConfigDir(void) +{ + char *homedir; + + 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 + + M_MakeDirectory(configdir); + } + else + { +#ifdef _WIN32 + // when given the -cdrom option, save config+savegames in + // c:\doomdata. This only applies under Windows. + + if (M_CheckParm("-cdrom") > 0) + { + printf(D_CDROM); + configdir = strdup("c:\\doomdata\\"); + + M_MakeDirectory(configdir); + } + else +#endif + { + configdir = strdup(""); + } + } +} + + + // // DEFAULTS // @@ -57,9 +124,10 @@ static int showMessages = 1; static int screenblocks = 9; -static int detaillevel = 0; +static int detailLevel = 0; static int usegamma = 0; -static int use_joystick = 0; + +static int usejoystick = 0; static int joybfire = 0; static int joybstrafe = 1; static int joybuse = 2; diff --git a/setup/m_argv.c b/setup/m_argv.c new file mode 100644 index 00000000..fd04631c --- /dev/null +++ b/setup/m_argv.c @@ -0,0 +1,57 @@ +// Emacs style mode select -*- C++ -*- +//----------------------------------------------------------------------------- +// +// Copyright(C) 1993-1996 Id Software, Inc. +// Copyright(C) 2005 Simon Howard +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA. +// +// DESCRIPTION: +// +//----------------------------------------------------------------------------- + + + +#include + +int myargc; +char** myargv; + + + + +// +// M_CheckParm +// Checks for the given parameter +// in the program's command line arguments. +// Returns the argument number (1 to argc-1) +// or 0 if not present +int M_CheckParm (char *check) +{ + int i; + + for (i = 1;i