Try to fix getlight builtin.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@6006 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2021-08-04 21:18:11 +00:00
parent 52ab543bd7
commit 662f7cfd75
2 changed files with 5 additions and 13 deletions

View file

@ -5430,12 +5430,7 @@ static void QCBUILTIN PF_cl_getlight (pubprogfuncs_t *prinst, struct globalvars_
{ {
vec3_t ambient, diffuse, dir; vec3_t ambient, diffuse, dir;
if (cl_max_lightstyles < csqc_world.worldmodel->lightmaps.maxstyle) { if (csqc_world.worldmodel->lightmaps.maxstyle >= cl_max_lightstyles || !csqc_world.worldmodel || csqc_world.worldmodel->loadstate != MLS_LOADED || !csqc_world.worldmodel->funcs.LightPointValues)
VectorSet(G_VECTOR(OFS_RETURN), 0, 0, 0);
return;
}
if (!csqc_world.worldmodel || csqc_world.worldmodel->loadstate != MLS_LOADED || !csqc_world.worldmodel->funcs.LightPointValues)
VectorSet(G_VECTOR(OFS_RETURN), 0, 0, 0); VectorSet(G_VECTOR(OFS_RETURN), 0, 0, 0);
else else
{ {

View file

@ -4205,15 +4205,12 @@ static void QCBUILTIN PF_sv_getlight (pubprogfuncs_t *prinst, struct globalvars_
vec3_t diffuse, ambient, dir; vec3_t diffuse, ambient, dir;
model_t *wm = sv.world.worldmodel; model_t *wm = sv.world.worldmodel;
if (wm && wm->loadstate == MLS_LOADED && wm->funcs.LightPointValues) if (wm && wm->loadstate == MLS_LOADED && wm->funcs.LightPointValues && wm->lightmaps.maxstyle<cl_max_lightstyles)
{
if (cl_max_lightstyles < wm->lightmaps.maxstyle) //client's light info might not be set up yet. this sucks.
{ {
wm->funcs.LightPointValues(wm, point, diffuse, ambient, dir); wm->funcs.LightPointValues(wm, point, diffuse, ambient, dir);
VectorMA(ambient, 0.5, diffuse, G_VECTOR(OFS_RETURN)); VectorMA(ambient, 0.5, diffuse, G_VECTOR(OFS_RETURN));
return; return;
} }
}
#endif #endif
//something failed. //something failed.