summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Howard2006-10-23 18:00:30 +0000
committerSimon Howard2006-10-23 18:00:30 +0000
commit30b2e71c09f4de8d8f1d643da27e06ae6b0ea98e (patch)
treed56eedef69c53e3986824a2a7c1261d84f7bbbcf
parent9326506e95b39059718ce02a72a58c43e6f89424 (diff)
downloadchocolate-doom-30b2e71c09f4de8d8f1d643da27e06ae6b0ea98e.tar.gz
chocolate-doom-30b2e71c09f4de8d8f1d643da27e06ae6b0ea98e.tar.bz2
chocolate-doom-30b2e71c09f4de8d8f1d643da27e06ae6b0ea98e.zip
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
-rw-r--r--setup/Makefile.am2
-rw-r--r--setup/configfile.c72
-rw-r--r--setup/m_argv.c57
-rw-r--r--setup/m_argv.h42
4 files changed, 171 insertions, 2 deletions
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 <stdio.h>
#include <stdlib.h>
#include <ctype.h>
+#include <string.h>
// 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 <string.h>
+
+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<myargc;i++)
+ {
+ if ( !strcasecmp(check, myargv[i]) )
+ return i;
+ }
+
+ return 0;
+}
+
+
+
+
diff --git a/setup/m_argv.h b/setup/m_argv.h
new file mode 100644
index 00000000..bd1518b9
--- /dev/null
+++ b/setup/m_argv.h
@@ -0,0 +1,42 @@
+// 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:
+// Nil.
+//
+//-----------------------------------------------------------------------------
+
+
+#ifndef __M_ARGV__
+#define __M_ARGV__
+
+//
+// MISC
+//
+extern int myargc;
+extern char** myargv;
+
+// Returns the position of the given parameter
+// in the arg list (0 if not found).
+int M_CheckParm (char* check);
+
+
+#endif