Skip to content

Commit

Permalink
FAKESHAFT: Don't perform 2 Info_ValueForKey lookups every frame
Browse files Browse the repository at this point in the history
  • Loading branch information
meag committed Jun 13, 2017
1 parent e1ac02f commit 44db95a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
2 changes: 2 additions & 0 deletions cl_main.c
Expand Up @@ -1127,6 +1127,8 @@ void CL_ClearState (void)
if (!com_serveractive)
Cvar_ForceSet (&host_mapname, ""); // Notice mapname not valid yet.

cl.fakeshaft_policy = 1;

CL_ProcessServerInfo(); // Force set some default variables, because server may not sent fullserverinfo.
}

Expand Down
15 changes: 15 additions & 0 deletions cl_parse.c
Expand Up @@ -2311,6 +2311,21 @@ void CL_ProcessServerInfo (void)

cl.racing = !strcmp(Info_ValueForKey(cl.serverinfo, "ktxmode"), "race");

// Update fakeshaft limits
{
char* p = Info_ValueForKey(cl.serverinfo, "fakeshaft");
if (!p[0]) {
p = Info_ValueForKey(cl.serverinfo, "truelightning");
}

if (p[0]) {
cl.fakeshaft_policy = bound(0, Q_atof(p), 1);
}
else {
cl.fakeshaft_policy = 1;
}
}

// Update skins if needed.
skin_refresh = ( !new_teamplay != !cl.teamplay || ( (newfpd ^ cl.fpd) & (FPD_NO_FORCE_COLOR|FPD_NO_FORCE_SKIN) ) );
cl.teamplay = new_teamplay;
Expand Down
12 changes: 5 additions & 7 deletions cl_tent.c
Expand Up @@ -727,14 +727,12 @@ void vectoangles(vec3_t vec, vec3_t ang);

static float fakeshaft_policy (void)
{
char *p;
if (cls.demoplayback || cl.spectator)
if (cls.demoplayback || cl.spectator) {
return 1;
else
return *(p = Info_ValueForKey(cl.serverinfo, "fakeshaft")) ?
bound(0, Q_atof(p), 1) :
*(p = Info_ValueForKey(cl.serverinfo, "truelightning")) ?
bound(0, Q_atof(p), 1) : 1;
}
else {
return cl.fakeshaft_policy;
}
}

void CL_UpdateBeams(void)
Expand Down
2 changes: 2 additions & 0 deletions client.h
Expand Up @@ -610,6 +610,8 @@ typedef struct {

qbool racing;
int race_pacemaker_ent;

float fakeshaft_policy;
} clientState_t;

extern clientState_t cl;
Expand Down

0 comments on commit 44db95a

Please sign in to comment.