From 621e97d7ad1c7e61eda478d14888f17a9aadddb9 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sun, 19 Jun 2005 06:29:50 +0000 Subject: [PATCH] break out map_cfg from cl_parse.c so the server can use it too. (at the behest of DrSpliff:) --- qw/include/Makefile.am | 4 +-- qw/include/map_cfg.h | 37 +++++++++++++++++++++ qw/source/Makefile.am | 3 +- qw/source/cl_parse.c | 25 +------------- qw/source/map_cfg.c | 75 ++++++++++++++++++++++++++++++++++++++++++ qw/source/sv_init.c | 3 ++ 6 files changed, 120 insertions(+), 27 deletions(-) create mode 100644 qw/include/map_cfg.h create mode 100644 qw/source/map_cfg.c diff --git a/qw/include/Makefile.am b/qw/include/Makefile.am index 8a9d90813..31abab5c8 100644 --- a/qw/include/Makefile.am +++ b/qw/include/Makefile.am @@ -4,5 +4,5 @@ AUTOMAKE_OPTIONS= foreign EXTRA_DIST = \ cl_cam.h cl_chat.h cl_demo.h cl_ents.h cl_input.h \ cl_main.h cl_parse.h cl_pred.h cl_skin.h cl_slist.h cl_tent.h \ - client.h crudefile.h game.h host.h server.h sv_gib.h sv_demo.h \ - sv_pr_cmds.h sv_pr_qwe.h sv_progs.h sv_qtv.h + client.h crudefile.h game.h host.h map_cfg.h server.h sv_gib.h \ + sv_demo.h sv_pr_cmds.h sv_pr_qwe.h sv_progs.h sv_qtv.h diff --git a/qw/include/map_cfg.h b/qw/include/map_cfg.h new file mode 100644 index 000000000..6c785f3f8 --- /dev/null +++ b/qw/include/map_cfg.h @@ -0,0 +1,37 @@ +/* + map_cfg.h + + map config file handling + + Copyright (C) 2005 Bill Currie + + Author: Bill Currie + Date: 2005/06/19 + + 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 __map_cfg_h +#define __map_cfg_h + +void map_cfg (const char *mapname, int all); + +#endif//__map_cfg_h; diff --git a/qw/source/Makefile.am b/qw/source/Makefile.am index c6467eea0..634292fa1 100644 --- a/qw/source/Makefile.am +++ b/qw/source/Makefile.am @@ -51,7 +51,8 @@ EXTRA_LIBRARIES=libasm.a libqw_client.a libqw_common.a libqw_sdl.a libqw_server. libasm_a_SOURCES= worlda.S libasm_la_CCASFLAGS=@PREFER_NON_PIC@ -libqw_common_a_SOURCES= com.c game.c pmove.c pmovetst.c net_packetlog.c +libqw_common_a_SOURCES=\ + com.c game.c map_cfg.c pmove.c pmovetst.c net_packetlog.c libqw_sdl_a_SOURCES=cl_sys_sdl.c libqw_sdl_a_CFLAGS=$(SDL_CFLAGS) diff --git a/qw/source/cl_parse.c b/qw/source/cl_parse.c index 457685651..b3fb9f0e8 100644 --- a/qw/source/cl_parse.c +++ b/qw/source/cl_parse.c @@ -73,6 +73,7 @@ static __attribute__ ((unused)) const char rcsid[] = #include "client.h" #include "compat.h" #include "host.h" +#include "map_cfg.h" #include "qw/pmove.h" #include "qw/protocol.h" #include "sbar.h" @@ -256,30 +257,6 @@ CL_CheckOrDownloadFile (const char *filename) return false; } -static void -map_cfg (const char *mapname, int all) -{ - char *name = malloc (strlen (mapname) + 4 + 1); - QFile *f; - cbuf_t *cbuf = Cbuf_New (&id_interp); - - QFS_StripExtension (mapname, name); - strcat (name, ".cfg"); - QFS_FOpenFile (name, &f); - if (f) { - Qclose (f); - Cmd_Exec_File (cbuf, name, 1); - } else { - Cmd_Exec_File (cbuf, "maps_default.cfg", 1); - } - if (all) - Cbuf_Execute_Stack (cbuf); - else - Cbuf_Execute_Sets (cbuf); - free (name); - Cbuf_Delete(cbuf); -} - static void CL_NewMap (const char *mapname) { diff --git a/qw/source/map_cfg.c b/qw/source/map_cfg.c new file mode 100644 index 000000000..5e03208ca --- /dev/null +++ b/qw/source/map_cfg.c @@ -0,0 +1,75 @@ +/* + map_cfg.c + + map config file handling + + Copyright (C) 2005 Bill Currie + + Author: Bill Currie + Date: 2005/06/19 + + 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 + +*/ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +static __attribute__ ((unused)) const char rcsid[] = + "$Id$"; + +#include +#ifdef HAVE_STRING_H +# include "string.h" +#endif +#ifdef HAVE_STRINGS_H +# include "strings.h" +#endif + +#include "QF/cbuf.h" +#include "QF/cmd.h" +#include "QF/idparse.h" +#include "QF/quakefs.h" + +#include "map_cfg.h" + +void +map_cfg (const char *mapname, int all) +{ + char *name = malloc (strlen (mapname) + 4 + 1); + QFile *f; + cbuf_t *cbuf = Cbuf_New (&id_interp); + + QFS_StripExtension (mapname, name); + strcat (name, ".cfg"); + QFS_FOpenFile (name, &f); + if (f) { + Qclose (f); + Cmd_Exec_File (cbuf, name, 1); + } else { + Cmd_Exec_File (cbuf, "maps_default.cfg", 1); + } + if (all) + Cbuf_Execute_Stack (cbuf); + else + Cbuf_Execute_Sets (cbuf); + free (name); + Cbuf_Delete(cbuf); +} + diff --git a/qw/source/sv_init.c b/qw/source/sv_init.c index d6ecdbc8b..add7eebd8 100644 --- a/qw/source/sv_init.c +++ b/qw/source/sv_init.c @@ -48,6 +48,7 @@ static __attribute__ ((unused)) const char rcsid[] = #include "compat.h" #include "crudefile.h" +#include "map_cfg.h" #include "qw/pmove.h" #include "server.h" #include "sv_progs.h" @@ -368,7 +369,9 @@ SV_SpawnServer (const char *server) strncpy (sv.name, server, sizeof (sv.name)); snprintf (sv.modelname, sizeof (sv.modelname), "maps/%s.bsp", server); + map_cfg (sv.modelname, 0); sv.worldmodel = Mod_ForName (sv.modelname, true); + map_cfg (sv.modelname, 1); SV_CalcPHS (); // clear physics interaction links