From e7822ff2bff9f5ded83125bf3a2826f518cfbba6 Mon Sep 17 00:00:00 2001 From: Spoike Date: Tue, 6 Jul 2021 00:04:41 +0000 Subject: [PATCH] Fix some bugs that are exhibited in taov. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5949 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/common/com_bih.c | 23 ++++++----------------- engine/server/pr_cmds.c | 26 ++++++++++++++++---------- 2 files changed, 22 insertions(+), 27 deletions(-) diff --git a/engine/common/com_bih.c b/engine/common/com_bih.c index cee913a73..63de81383 100644 --- a/engine/common/com_bih.c +++ b/engine/common/com_bih.c @@ -1231,13 +1231,9 @@ static qboolean BIH_Trace(model_t *model, int forcehullnum, const framestate_t * tr.trace.fraction = tr.trace.truefraction = 1; tr.trace.surface = &(nullsurface.c); - if (!model) // map not loaded - VectorCopy (end, tr.trace.endpos); - else + if (model) // map is loaded... { tr.hitcontents = contents; - VectorCopy (start, tr.startpos); - VectorCopy (end, tr.endpos); VectorCopy (mins, tr.size.min); VectorCopy (maxs, tr.size.max); @@ -1320,9 +1316,9 @@ static qboolean BIH_Trace(model_t *model, int forcehullnum, const framestate_t * for (i = 0; i < 3; i++) - tr.negativedir[i] = (end[i] - start[i]) < 0; - VectorSubtract(end, start, tr.totalmove); - if (start[0] == end[0] && start[1] == end[1] && start[2] == end[2]) + tr.negativedir[i] = (tr.endpos[i] - tr.startpos[i]) < 0; + VectorSubtract(tr.endpos, tr.startpos, tr.totalmove); + if (tr.startpos[0] == tr.endpos[0] && tr.startpos[1] == tr.endpos[1] && tr.startpos[2] == tr.endpos[2]) BIH_RecursiveTest(&tr, model->cnodes); else { @@ -1332,15 +1328,8 @@ static qboolean BIH_Trace(model_t *model, int forcehullnum, const framestate_t * BIH_RecursiveTrace(&tr, model->cnodes, &tr.bounds, &worldsize); } - if (tr.trace.fraction == 1) - VectorCopy (end, tr.trace.endpos); - else - { - if (tr.trace.fraction<0) - tr.trace.fraction=0; - for (i=0 ; i<3 ; i++) - tr.trace.endpos[i] = start[i] + tr.trace.fraction * (end[i] - start[i]); - } + if (tr.trace.fraction<0) + tr.trace.fraction=0; } *out_trace = tr.trace; diff --git a/engine/server/pr_cmds.c b/engine/server/pr_cmds.c index d49ed5696..ddbf52482 100644 --- a/engine/server/pr_cmds.c +++ b/engine/server/pr_cmds.c @@ -4231,21 +4231,27 @@ static void QCBUILTIN PF_cvar (pubprogfuncs_t *prinst, struct globalvars_s *pr_g static void QCBUILTIN PF_sv_getlight (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals) { +#ifdef HAVE_CLIENT /*not shared with client - clients get more lights*/ float *point = G_VECTOR(OFS_PARM0); vec3_t diffuse, ambient, dir; - if (sv.world.worldmodel && sv.world.worldmodel->funcs.LightPointValues) + model_t *wm = sv.world.worldmodel; + + if (wm && wm->loadstate == MLS_LOADED && wm->funcs.LightPointValues) { - sv.world.worldmodel->funcs.LightPointValues(sv.world.worldmodel, point, diffuse, ambient, dir); - VectorMA(ambient, 0.5, diffuse, G_VECTOR(OFS_RETURN)); - } - else - { - G_FLOAT(OFS_RETURN+0) = 128; - G_FLOAT(OFS_RETURN+1) = 128; - G_FLOAT(OFS_RETURN+2) = 128; - return; + 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); + VectorMA(ambient, 0.5, diffuse, G_VECTOR(OFS_RETURN)); + return; + } } +#endif + + //something failed. + G_FLOAT(OFS_RETURN+0) = 128; + G_FLOAT(OFS_RETURN+1) = 128; + G_FLOAT(OFS_RETURN+2) = 128; } #ifdef HAVE_LEGACY