Skip to content

Commit

Permalink
Add fallback in case mod does not set cg.cgameClientLerpOrigin
Browse files Browse the repository at this point in the history
This is normally set in etmain so most mods should probably have it, but in case it's not, fallback to client origin
  • Loading branch information
Aciz committed Jun 4, 2024
1 parent b7427f8 commit 3a873e5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/client/cl_tc_vis.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,10 +480,17 @@ static qboolean CullFace(const visFace_t *face) {
}

static void draw(visBrushNode_t *brush, qhandle_t shader) {
vec3_t clientOrigin;
vec3_t clientOrigin = { 0.0f, 0.0f, 0.0f };
frustum = re.GetFrustum();

VectorCopy(cl.cgameClientLerpOrigin, clientOrigin);
// this should be set to cg.refdef.vieworg in cgame,
// but fallback to player origin in case a mod has removed the syscall that sets it
if (!VectorCompare(cl.cgameClientLerpOrigin, vec3_origin)) {
VectorCopy(cl.cgameClientLerpOrigin, clientOrigin);
} else if (cl.snap.valid) {
VectorCopy(cl.snap.ps.origin, clientOrigin);
clientOrigin[2] += (float)cl.snap.ps.viewheight;
}

while (brush) {
int i;
Expand Down

0 comments on commit 3a873e5

Please sign in to comment.