Set the skybox from the map's worldspawn sky field.

This commit is contained in:
Bill Currie 2010-12-10 13:00:42 +09:00
parent 4af6c8c108
commit aad204e80c
3 changed files with 36 additions and 0 deletions

View file

@ -200,6 +200,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 viewentity; // cl_entitites[cl.viewentity] = player int viewentity; // cl_entitites[cl.viewentity] = player
int maxclients; int maxclients;

View file

@ -39,6 +39,7 @@ static __attribute__ ((used)) const char rcsid[] =
#include "QF/keys.h" #include "QF/keys.h"
#include "QF/msg.h" #include "QF/msg.h"
#include "QF/plugin.h" #include "QF/plugin.h"
#include "QF/qfplist.h"
#include "QF/render.h" #include "QF/render.h"
#include "QF/screen.h" #include "QF/screen.h"
#include "QF/skin.h" #include "QF/skin.h"
@ -149,6 +150,9 @@ CL_ClearState (void)
if (!sv.active) if (!sv.active)
Host_ClearMemory (); Host_ClearMemory ();
if (cl.edicts)
PL_Free (cl.edicts);
// wipe the entire cl structure // wipe the entire cl structure
memset (&cl, 0, sizeof (cl)); memset (&cl, 0, sizeof (cl));
r_force_fullscreen = 0; r_force_fullscreen = 0;

View file

@ -47,6 +47,7 @@ static __attribute__ ((used)) const char rcsid[] =
#include "QF/idparse.h" #include "QF/idparse.h"
#include "QF/input.h" #include "QF/input.h"
#include "QF/msg.h" #include "QF/msg.h"
#include "QF/qfplist.h"
#include "QF/sys.h" #include "QF/sys.h"
#include "QF/screen.h" #include "QF/screen.h"
#include "QF/skin.h" #include "QF/skin.h"
@ -122,6 +123,24 @@ const char *svc_strings[] = {
float r_gravity; float r_gravity;
dstring_t *centerprint; dstring_t *centerprint;
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"))
|| (item = PL_ObjectForKey (cl.worldspawn, "skyname"))
|| (item = PL_ObjectForKey (cl.worldspawn, "skyname"))) {
name = PL_String (item);
}
R_LoadSkys (name);
}
/* /*
CL_EntityNum CL_EntityNum
@ -282,6 +301,16 @@ CL_NewMap (const char *mapname)
Con_NewMap (); Con_NewMap ();
Sbar_CenterPrint (0); Sbar_CenterPrint (0);
if (cl.model_precache[1] && cl.model_precache[1]->entities) {
static progs_t edpr;
cl.edicts = ED_Parse (&edpr, cl.model_precache[1]->entities);
if (cl.edicts) {
cl.worldspawn = PL_ObjectAtIndex (cl.edicts, 0);
CL_LoadSky ();
}
}
map_cfg (mapname, 1); map_cfg (mapname, 1);
} }