Add support for map specified fog and skys to qw.

This commit is contained in:
Bill Currie 2011-08-28 21:11:08 +09:00
parent be8277c8c4
commit a55f490b47
3 changed files with 56 additions and 3 deletions

View file

@ -276,6 +276,9 @@ typedef struct
struct model_s *model_precache[MAX_MODELS]; struct model_s *model_precache[MAX_MODELS];
struct sfx_s *sound_precache[MAX_SOUNDS]; struct sfx_s *sound_precache[MAX_SOUNDS];
struct plitem_s *edicts;
struct plitem_s *worldspawn;
char levelname[40]; // for display on solo scoreboard char levelname[40]; // for display on solo scoreboard
int playernum; int playernum;
int viewentity; int viewentity;

View file

@ -55,6 +55,8 @@ static __attribute__ ((used)) const char rcsid[] =
#include "QF/hash.h" #include "QF/hash.h"
#include "QF/idparse.h" #include "QF/idparse.h"
#include "QF/msg.h" #include "QF/msg.h"
#include "QF/progs.h"
#include "QF/qfplist.h"
#include "QF/quakeio.h" #include "QF/quakeio.h"
#include "QF/screen.h" #include "QF/screen.h"
#include "QF/sound.h" #include "QF/sound.h"
@ -174,6 +176,23 @@ extern cvar_t *hud_scoreboard_uid;
entity_t *cl_static_entities; entity_t *cl_static_entities;
static entity_t **cl_static_tail; static entity_t **cl_static_tail;
static void
CL_LoadSky (void)
{
plitem_t *item;
const char *name = 0;
if (!cl.worldspawn) {
R_LoadSkys (0);
return;
}
if ((item = PL_ObjectForKey (cl.worldspawn, "sky")) // Q2/DarkPlaces
|| (item = PL_ObjectForKey (cl.worldspawn, "skyname")) // old QF
|| (item = PL_ObjectForKey (cl.worldspawn, "qlsky"))) /* QuakeLives */ {
name = PL_String (item);
}
R_LoadSkys (name);
}
int int
CL_CalcNet (void) CL_CalcNet (void)
@ -258,6 +277,26 @@ CL_CheckOrDownloadFile (const char *filename)
return false; return false;
} }
static plitem_t *
map_ent (const char *mapname)
{
static progs_t edpr;
char *name = malloc (strlen (mapname) + 4 + 1);
char *buf;
plitem_t *edicts = 0;
QFS_StripExtension (mapname, name);
strcat (name, ".ent");
if ((buf = (char *) QFS_LoadFile (name, 0))) {
edicts = ED_Parse (&edpr, buf);
free (buf);
} else {
edicts = ED_Parse (&edpr, cl.model_precache[1]->entities);
}
free (name);
return edicts;
}
static void static void
CL_NewMap (const char *mapname) CL_NewMap (const char *mapname)
{ {
@ -269,6 +308,15 @@ CL_NewMap (const char *mapname)
Hunk_Check (); // make sure nothing is hurt Hunk_Check (); // make sure nothing is hurt
Sbar_CenterPrint (0); Sbar_CenterPrint (0);
if (cl.model_precache[1] && cl.model_precache[1]->entities) {
cl.edicts = map_ent (mapname);
if (cl.edicts) {
cl.worldspawn = PL_ObjectAtIndex (cl.edicts, 0);
CL_LoadSky ();
Fog_ParseWorldspawn (cl.worldspawn);
}
}
map_cfg (mapname, 1); map_cfg (mapname, 1);
} }

View file

@ -186,12 +186,14 @@ parse_field (progs_t *pr, const char *key, const char *value)
If skyname is set, set what the map thinks the skybox name should If skyname is set, set what the map thinks the skybox name should
be. "qlsky" is supported since at least one other map uses it. be. "qlsky" is supported since at least one other map uses it.
*/ */
if (strcaseequal (key, "skyname") // QuakeForge if (strequal (key, "skyname") // QuakeForge
|| strcaseequal (key, "sky") // Q2/DarkPlaces || strequal (key, "sky") // Q2/DarkPlaces
|| strcaseequal (key, "qlsky")) { // QuakeLives || strequal (key, "qlsky")) { // QuakeLives
Info_SetValueForKey (svs.info, "sky", value, 0); Info_SetValueForKey (svs.info, "sky", value, 0);
return 1; return 1;
} }
if (strequal (key, "fog"))
return 1;
if (*key == '_') // ignore _fields if (*key == '_') // ignore _fields
return 1; return 1;
return 0; return 0;