From b432d0ea17aa6311328eca77defe93830e879feb Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Fri, 30 Mar 2001 00:30:38 +0000 Subject: [PATCH] pull the game specific stuff out of quakefs.c in preparation for merging it --- include/QF/quakefs.h | 1 + nq/source/game.c | 17 +++++++- nq/source/quakefs.c | 21 +--------- qw/include/game.h | 42 +++++++++++++++++++ qw/source/Makefile.am | 2 +- qw/source/cl_main.c | 3 ++ qw/source/com.c | 1 - qw/source/game.c | 96 +++++++++++++++++++++++++++++++++++++++++++ qw/source/quakefs.c | 53 +----------------------- qw/source/sv_main.c | 2 + 10 files changed, 162 insertions(+), 76 deletions(-) create mode 100644 qw/include/game.h create mode 100644 qw/source/game.c diff --git a/include/QF/quakefs.h b/include/QF/quakefs.h index 6ef83fd73..23f5b98b9 100644 --- a/include/QF/quakefs.h +++ b/include/QF/quakefs.h @@ -73,5 +73,6 @@ void COM_Filesystem_Init (void); void COM_Filesystem_Init_Cvars (void); void COM_Path_f (void); void COM_Maplist_f (void); +void COM_CreateGameDirectory (char *gamename); #endif // __quakefs_h diff --git a/nq/source/game.c b/nq/source/game.c index 10ca6d3d0..25bdb1a60 100644 --- a/nq/source/game.c +++ b/nq/source/game.c @@ -32,6 +32,7 @@ # include #endif #include "QF/qargs.h" +#include "QF/quakefs.h" #include "game.h" qboolean standard_quake = false; @@ -42,6 +43,18 @@ qboolean standard_quake = false; void Game_Init (void) { - // This used to have the -hipnotic and -rogue checks, but they've been - // moved to quakefs.c for the time being.. + int i; + // FIXME: make this dependant on QF metadata in the mission packs + standard_quake = true; + if ((i = COM_CheckParm ("-hipnotic"))) { + COM_CreateGameDirectory ("hipnotic"); + standard_quake = false; + } + if ((i = COM_CheckParm ("-rogue"))) { + COM_CreateGameDirectory ("rogue"); + standard_quake = false; + } + if ((i = COM_CheckParm ("-abyss"))) { + COM_CreateGameDirectory ("abyss"); + } } diff --git a/nq/source/quakefs.c b/nq/source/quakefs.c index 89b7c9351..a99b4ccba 100644 --- a/nq/source/quakefs.c +++ b/nq/source/quakefs.c @@ -65,17 +65,15 @@ #include "QF/compat.h" #include "QF/console.h" #include "QF/cvar.h" -#include "draw.h" #include "QF/hash.h" -#include "host.h" #include "QF/info.h" #include "QF/qargs.h" #include "QF/qendian.h" #include "QF/qtypes.h" #include "QF/quakefs.h" -#include "server.h" #include "QF/sys.h" #include "QF/va.h" +#include "QF/zone.h" #ifndef HAVE_FNMATCH_PROTO int fnmatch (const char *__pattern, const char *__string, int __flags); @@ -679,10 +677,8 @@ COM_LoadFile (char *path, int usehunk) Sys_Error ("COM_LoadFile: not enough space for %s", path); ((byte *) buf)[len] = 0; - Draw_BeginDisc (); Qread (h, buf, len); Qclose (h); - Draw_EndDisc (); return buf; } @@ -941,12 +937,6 @@ COM_AddDirectory (char *dir) void COM_AddGameDirectory (char *dir) { - // FIXME: make this dependant on QF metadata in the mission packs - if (strequal (dir, "hipnotic") || strequal (dir, "rogue")) - standard_quake = false; - else - standard_quake = true; - Con_DPrintf ("COM_AddGameDirectory (\"%s/%s\")\n", fs_sharepath->string, dir); @@ -1031,15 +1021,6 @@ COM_Filesystem_Init (void) } free (gamedirs); } - if ((i = COM_CheckParm ("-hipnotic"))) { - COM_CreateGameDirectory ("hipnotic"); - } - if ((i = COM_CheckParm ("-rogue"))) { - COM_CreateGameDirectory ("rogue"); - } - if ((i = COM_CheckParm ("-abyss"))) { - COM_CreateGameDirectory ("abyss"); - } // any set gamedirs will be freed up to here com_base_searchpaths = com_searchpaths; } diff --git a/qw/include/game.h b/qw/include/game.h new file mode 100644 index 000000000..faded64c5 --- /dev/null +++ b/qw/include/game.h @@ -0,0 +1,42 @@ +/* + game.h + + (description) + + Copyright (C) 1996-1997 Id Software, Inc. + Copyright (C) 1999,2000 contributors of the QuakeForge project + Please see the file "AUTHORS" for a list of contributors + + 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: + + Free Software Foundation, Inc. + 59 Temple Place - Suite 330 + Boston, MA 02111-1307, USA + + $Id$ +*/ + +#ifndef __game_h +#define __game_h + +#include "QF/qtypes.h" +#include "QF/cvar.h" +#include "QF/qdefs.h" + +extern cvar_t *registered; + +void Game_Init (void); + +#endif // __game_h diff --git a/qw/source/Makefile.am b/qw/source/Makefile.am index 362df75f7..21d48af4e 100644 --- a/qw/source/Makefile.am +++ b/qw/source/Makefile.am @@ -50,7 +50,7 @@ if ASM_ARCH math_ASM = sys_x86.S endif common_SOURCES= buildnum.c com.c \ - model.c model_brush.c msg_ucmd.c \ + game.c model.c model_brush.c msg_ucmd.c \ pmove.c pmovetst.c quakefs.c \ $(math_ASM) $(packetlogger) diff --git a/qw/source/cl_main.c b/qw/source/cl_main.c index bfa28041d..a799b379c 100644 --- a/qw/source/cl_main.c +++ b/qw/source/cl_main.c @@ -76,6 +76,7 @@ #include "QF/console.h" #include "QF/cvar.h" #include "draw.h" +#include "game.h" #include "host.h" #include "input.h" #include "QF/keys.h" @@ -1602,6 +1603,8 @@ Host_Init (void) cl_Cmd_Init (); V_Init (); + COM_Filesystem_Init (); + Game_Init (); COM_Init (); NET_Init (PORT_CLIENT); diff --git a/qw/source/com.c b/qw/source/com.c index a7b5073e5..de68e0637 100644 --- a/qw/source/com.c +++ b/qw/source/com.c @@ -87,7 +87,6 @@ COM_Init (void) { Cmd_AddCommand ("path", COM_Path_f, "Show what paths Quake is using"); - COM_Filesystem_Init (); COM_CheckRegistered (); } diff --git a/qw/source/game.c b/qw/source/game.c new file mode 100644 index 000000000..8f6b53f4d --- /dev/null +++ b/qw/source/game.c @@ -0,0 +1,96 @@ +/* + game.c + + game specific support + + Copyright (C) 1996-1997 Id Software, Inc. + Copyright (C) 1999,2000 contributors of the QuakeForge project + Please see the file "AUTHORS" for a list of contributors + + 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: + + Free Software Foundation, Inc. + 59 Temple Place - Suite 330 + Boston, MA 02111-1307, USA + + $Id$ +*/ + +#ifdef HAVE_CONFIG_H +# include +#endif +#ifdef HAVE_STRING_H +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif + +#include "QF/cmd.h" +#include "QF/console.h" +#include "QF/info.h" +#include "QF/qargs.h" +#include "QF/quakefs.h" +#include "game.h" +#include "server.h" + +extern qboolean is_server; + +/* + SV_Gamedir_f + + Sets the gamedir and path to a different directory. +*/ + +void +SV_Gamedir_f (void) +{ + char *dir; + + if (Cmd_Argc () == 1) { + Con_Printf ("Current gamedir: %s\n", gamedirfile); + return; + } + + if (Cmd_Argc () != 2) { + Con_Printf ("Usage: gamedir \n"); + return; + } + + dir = Cmd_Argv (1); + + if (strstr (dir, "..") || strstr (dir, "/") + || strstr (dir, "\\") || strstr (dir, ":")) { + Con_Printf ("Gamedir should be a single filename, not a path\n"); + return; + } + + COM_Gamedir (dir); + + if (is_server) { + Info_SetValueForStarKey (svs_info, "*gamedir", dir, + MAX_SERVERINFO_STRING); + } +} + +/* + Game_Init +*/ +void +Game_Init (void) +{ + Cmd_AddCommand ("gamedir", SV_Gamedir_f, + "Specifies the directory to be used while playing."); +} diff --git a/qw/source/quakefs.c b/qw/source/quakefs.c index 82fa1b81f..405e8d148 100644 --- a/qw/source/quakefs.c +++ b/qw/source/quakefs.c @@ -62,29 +62,24 @@ #include #include "QF/cmd.h" -#include "commdef.h" #include "QF/compat.h" #include "QF/console.h" #include "QF/cvar.h" -#include "draw.h" #include "QF/hash.h" #include "QF/info.h" #include "QF/qargs.h" #include "QF/qendian.h" #include "QF/qtypes.h" #include "QF/quakefs.h" -#include "server.h" #include "QF/sys.h" #include "QF/va.h" +#include "QF/zone.h" #ifndef HAVE_FNMATCH_PROTO int fnmatch (const char *__pattern, const char *__string, int __flags); #endif -extern qboolean is_server; - - /* All of Quake's data access is through a hierchical file system, but the contents of the file system can be transparently merged from several @@ -683,14 +678,8 @@ COM_LoadFile (char *path, int usehunk) Sys_Error ("COM_LoadFile: not enough space for %s", path); ((byte *) buf)[len] = 0; - if (!is_server) { - Draw_BeginDisc (); - } Qread (h, buf, len); Qclose (h); - if (!is_server) { - Draw_EndDisc (); - } return buf; } @@ -1002,43 +991,6 @@ COM_Gamedir (char *dir) COM_AddGameDirectory (dir); } -/* - SV_Gamedir_f - - Sets the gamedir and path to a different directory. -*/ - -void -COM_Gamedir_f (void) -{ - char *dir; - - if (Cmd_Argc () == 1) { - Con_Printf ("Current gamedir: %s\n", gamedirfile); - return; - } - - if (Cmd_Argc () != 2) { - Con_Printf ("Usage: gamedir \n"); - return; - } - - dir = Cmd_Argv (1); - - if (strstr (dir, "..") || strstr (dir, "/") - || strstr (dir, "\\") || strstr (dir, ":")) { - Con_Printf ("Gamedir should be a single filename, not a path\n"); - return; - } - - COM_Gamedir (dir); - - if (is_server) { - Info_SetValueForStarKey (svs_info, "*gamedir", dir, - MAX_SERVERINFO_STRING); - } -} - /* COM_CreateGameDirectory */ @@ -1058,9 +1010,6 @@ COM_Filesystem_Init (void) { int i; - Cmd_AddCommand ("gamedir", COM_Gamedir_f, - "Specifies the directory to be used while playing."); - // start up with basegame->string by default COM_CreateGameDirectory (fs_basegame->string); diff --git a/qw/source/sv_main.c b/qw/source/sv_main.c index 6218a639a..543d1c27d 100644 --- a/qw/source/sv_main.c +++ b/qw/source/sv_main.c @@ -43,6 +43,7 @@ #include "buildnum.h" #include "QF/cmd.h" #include "QF/compat.h" +#include "game.h" #include "model.h" #include "net.h" #include "QF/msg.h" @@ -1926,6 +1927,7 @@ SV_Init (void) Cmd_StuffCmds_f (); Cbuf_Execute_Sets (); + COM_Filesystem_Init (); COM_Init (); PR_Init ();