diff --git a/nq/include/client.h b/nq/include/client.h index 0c2637785..b444431d5 100644 --- a/nq/include/client.h +++ b/nq/include/client.h @@ -200,6 +200,9 @@ typedef struct struct model_s *model_precache[MAX_MODELS]; struct sfx_s *sound_precache[MAX_SOUNDS]; + struct plitem_s *edicts; + struct plitem_s *worldspawn; + char levelname[40]; // for display on solo scoreboard int viewentity; // cl_entitites[cl.viewentity] = player int maxclients; diff --git a/nq/source/cl_main.c b/nq/source/cl_main.c index 10be10a9e..3a9a8ad3c 100644 --- a/nq/source/cl_main.c +++ b/nq/source/cl_main.c @@ -39,6 +39,7 @@ static __attribute__ ((used)) const char rcsid[] = #include "QF/keys.h" #include "QF/msg.h" #include "QF/plugin.h" +#include "QF/qfplist.h" #include "QF/render.h" #include "QF/screen.h" #include "QF/skin.h" @@ -149,6 +150,9 @@ CL_ClearState (void) if (!sv.active) Host_ClearMemory (); + if (cl.edicts) + PL_Free (cl.edicts); + // wipe the entire cl structure memset (&cl, 0, sizeof (cl)); r_force_fullscreen = 0; diff --git a/nq/source/cl_parse.c b/nq/source/cl_parse.c index 022ad4d4a..c8f1eb7d4 100644 --- a/nq/source/cl_parse.c +++ b/nq/source/cl_parse.c @@ -47,6 +47,7 @@ static __attribute__ ((used)) const char rcsid[] = #include "QF/idparse.h" #include "QF/input.h" #include "QF/msg.h" +#include "QF/qfplist.h" #include "QF/sys.h" #include "QF/screen.h" #include "QF/skin.h" @@ -122,6 +123,24 @@ const char *svc_strings[] = { float r_gravity; 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 @@ -282,6 +301,16 @@ CL_NewMap (const char *mapname) Con_NewMap (); 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); }