break out map_cfg from cl_parse.c so the server can use it too. (at the

behest of DrSpliff:)
This commit is contained in:
Bill Currie 2005-06-19 06:29:50 +00:00
parent 72e375d96a
commit 621e97d7ad
6 changed files with 120 additions and 27 deletions

View File

@ -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

37
qw/include/map_cfg.h Normal file
View File

@ -0,0 +1,37 @@
/*
map_cfg.h
map config file handling
Copyright (C) 2005 Bill Currie <bill@taniwha.org>
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;

View File

@ -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)

View File

@ -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)
{

75
qw/source/map_cfg.c Normal file
View File

@ -0,0 +1,75 @@
/*
map_cfg.c
map config file handling
Copyright (C) 2005 Bill Currie <bill@taniwha.org>
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 <stdlib.h>
#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);
}

View File

@ -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