Limit the search for lit and ent files.

The search for these files will stop in the vpath that contains the .bsp
file to which they belong. This will prevent problems with
id1/maps/start.lit being used for shadows/maps/start.bsp.
This commit is contained in:
Bill Currie 2014-01-23 13:13:00 +09:00
parent 8bea6a66ca
commit ab3f554a0e
5 changed files with 18 additions and 5 deletions

View file

@ -141,6 +141,7 @@ gl_Mod_LoadLighting (bsp_t *bsp)
dstring_t *litfilename = dstring_new ();
size_t i;
int ver;
QFile *lit_file;
dstring_copystr (litfilename, loadmodel->name);
loadmodel->lightdata = NULL;
@ -148,7 +149,8 @@ gl_Mod_LoadLighting (bsp_t *bsp)
// LordHavoc: check for a .lit file to load
QFS_StripExtension (litfilename->str, litfilename->str);
dstring_appendstr (litfilename, ".lit");
data = (byte *) QFS_LoadHunkFile (QFS_FOpenFile (litfilename->str));
lit_file = QFS_VOpenFile (litfilename->str, 0, loadmodel->vpath);
data = (byte *) QFS_LoadHunkFile (lit_file);
if (data) {
if (data[0] == 'Q' && data[1] == 'L' && data[2] == 'I'
&& data[3] == 'T') {

View file

@ -291,10 +291,12 @@ map_ent (const char *mapname)
char *name = malloc (strlen (mapname) + 4 + 1);
char *buf;
plitem_t *edicts = 0;
QFile *ent_file;
QFS_StripExtension (mapname, name);
strcat (name, ".ent");
if ((buf = (char *) QFS_LoadFile (QFS_FOpenFile (name), 0))) {
ent_file = QFS_VOpenFile (name, 0, cl.model_precache[1]->vpath);
if ((buf = (char *) QFS_LoadFile (ent_file, 0))) {
edicts = ED_Parse (&edpr, buf);
free (buf);
} else {

View file

@ -1102,9 +1102,11 @@ void
SV_SpawnServer (const char *server)
{
byte *buf;
QFile *ent_file;
int i;
edict_t *ent;
S_BlockSound ();
// let's not have any servers with no name
if (hostname->string[0] == 0)
@ -1211,7 +1213,9 @@ SV_SpawnServer (const char *server)
*sv_globals.serverflags = svs.serverflags;
*sv_globals.time = sv.time;
if ((buf = QFS_LoadFile (QFS_FOpenFile (va ("maps/%s.ent", server)), 0))) {
ent_file = QFS_VOpenFile (va ("maps/%s.ent", server), 0,
sv.worldmodel->vpath);
if ((buf = QFS_LoadFile (ent_file, 0))) {
ED_LoadFromFile (&sv_pr_state, (char *) buf);
free (buf);
} else {

View file

@ -277,10 +277,12 @@ map_ent (const char *mapname)
char *name = malloc (strlen (mapname) + 4 + 1);
char *buf;
plitem_t *edicts = 0;
QFile *ent_file;
QFS_StripExtension (mapname, name);
strcat (name, ".ent");
if ((buf = (char *) QFS_LoadFile (QFS_FOpenFile (name), 0))) {
ent_file = QFS_VOpenFile (name, 0, cl.model_precache[1]->vpath);
if ((buf = (char *) QFS_LoadFile (ent_file, 0))) {
edicts = ED_Parse (&edpr, buf);
free (buf);
} else {

View file

@ -319,6 +319,7 @@ SV_SpawnServer (const char *server)
int *so_sizes;
int max_so;
struct recorder_s *recorders;
QFile *ent_file;
Sys_MaskPrintf (SYS_DEV, "SpawnServer: %s\n", server);
@ -433,7 +434,9 @@ SV_SpawnServer (const char *server)
// load and spawn all other entities
*sv_globals.time = sv.time;
if ((buf = QFS_LoadFile (QFS_FOpenFile (va ("maps/%s.ent", server)), 0))) {
ent_file = QFS_VOpenFile (va ("maps/%s.ent", server), 0,
sv.worldmodel->vpath);
if ((buf = QFS_LoadFile (ent_file, 0))) {
ED_LoadFromFile (&sv_pr_state, (char *) buf);
free (buf);
} else {