Skip to content

Commit

Permalink
RULESETS: Restrict cl_rollangle (smackdown/td/qcon)
Browse files Browse the repository at this point in the history
Maximum value 5 in competitive rulesets
  • Loading branch information
meag committed Feb 9, 2021
1 parent f3ed6b5 commit 7f4dc7f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
4 changes: 2 additions & 2 deletions cl_view.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ float V_CalcRoll (vec3_t angles, vec3_t velocity) {
sign = side < 0 ? -1 : 1;
side = fabs(side);

side = (side < cl_rollspeed.value) ? side * cl_rollangle.value / cl_rollspeed.value : cl_rollangle.value;
side = (side < cl_rollspeed.value) ? side * Ruleset_RollAngle() / cl_rollspeed.value : Ruleset_RollAngle();

if (side > 45)
side = 45;
Expand Down Expand Up @@ -773,7 +773,7 @@ void V_CalcViewRoll (void) {
float side, adjspeed;

side = V_CalcRoll (cl.simangles, cl.simvel);
adjspeed = cl_rollalpha.value * bound (2, fabs(cl_rollangle.value), 45);
adjspeed = cl_rollalpha.value * bound (2, Ruleset_RollAngle(), 45);
if (side > cl.rollangle) {
cl.rollangle += cls.frametime * adjspeed;
if (cl.rollangle > side)
Expand Down
2 changes: 1 addition & 1 deletion menu_options.c
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ setting settfps_arr[] = {
ADDSET_NUMBER ("View Size (fov)", scr_fov, 40, 140, 2),
ADDSET_NUMBER ("Screen Size", scr_viewsize, 30, 120, 5),
ADDSET_ADVANCED_SECTION(),
ADDSET_NUMBER ("Rollangle", cl_rollangle, 0, 30, 2),
ADDSET_NUMBER ("Rollangle", cl_rollangle, 0, 10, 1),
ADDSET_NUMBER ("Rollspeed", cl_rollspeed, 0, 30, 2),
ADDSET_BOOL ("Gun Kick", v_gunkick),
ADDSET_NUMBER ("Kick Pitch", v_kickpitch, 0, 10, 0.5),
Expand Down
20 changes: 20 additions & 0 deletions rulesets.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ static rulesetDef_t rulesetDef = {
72.0,
false,
false,
false,
false
};

Expand Down Expand Up @@ -223,6 +224,7 @@ static void Rulesets_Smackdown(qbool enable)
rulesetDef.restrictPacket = true; // packet command could have been exploited for external timers
rulesetDef.restrictParticles = true;
rulesetDef.ruleset = rs_smackdown;
rulesetDef.restrictRollAngle = true;
} else {
for (i = 0; i < (sizeof(disabled_cvars) / sizeof(disabled_cvars[0])); i++)
Cvar_SetFlags(disabled_cvars[i].var, Cvar_GetFlags(disabled_cvars[i].var) & ~CVAR_ROM);
Expand All @@ -235,6 +237,7 @@ static void Rulesets_Smackdown(qbool enable)
rulesetDef.restrictPacket = false;
rulesetDef.restrictParticles = false;
rulesetDef.ruleset = rs_default;
rulesetDef.restrictRollAngle = false;
}
}

Expand Down Expand Up @@ -274,6 +277,7 @@ static void Rulesets_Qcon(qbool enable)
rulesetDef.restrictParticles = true;
rulesetDef.restrictSound = true;
rulesetDef.ruleset = rs_qcon;
rulesetDef.restrictRollAngle = true;
} else {
for (i = 0; i < (sizeof(disabled_cvars) / sizeof(disabled_cvars[0])); i++)
Cvar_SetFlags(disabled_cvars[i].var, Cvar_GetFlags(disabled_cvars[i].var) & ~CVAR_ROM);
Expand All @@ -287,6 +291,7 @@ static void Rulesets_Qcon(qbool enable)
rulesetDef.restrictParticles = false;
rulesetDef.restrictSound = false;
rulesetDef.ruleset = rs_default;
rulesetDef.restrictRollAngle = false;
}
}
static void Rulesets_Thunderdome(qbool enable)
Expand Down Expand Up @@ -322,6 +327,7 @@ static void Rulesets_Thunderdome(qbool enable)
rulesetDef.restrictPacket = true; // packet command could have been exploited for external timers
rulesetDef.restrictParticles = false;
rulesetDef.ruleset = rs_thunderdome;
rulesetDef.restrictRollAngle = true;
} else {
for (i = 0; i < (sizeof(disabled_cvars) / sizeof(disabled_cvars[0])); i++)
Cvar_SetFlags(disabled_cvars[i].var, Cvar_GetFlags(disabled_cvars[i].var) & ~CVAR_ROM);
Expand All @@ -334,6 +340,7 @@ static void Rulesets_Thunderdome(qbool enable)
rulesetDef.restrictPacket = false;
rulesetDef.restrictParticles = false;
rulesetDef.ruleset = rs_default;
rulesetDef.restrictRollAngle = false;
}
}
static void Rulesets_MTFL(qbool enable)
Expand Down Expand Up @@ -383,6 +390,7 @@ static void Rulesets_MTFL(qbool enable)
Cvar_SetFlags(limited_min_cvars[i].var, Cvar_GetFlags(limited_min_cvars[i].var) | CVAR_RULESET_MIN);
}

rulesetDef.restrictRollAngle = false;
rulesetDef.ruleset = rs_mtfl;
} else {
for (i = 0; i < (sizeof(disabled_cvars) / sizeof(disabled_cvars[0])); i++)
Expand All @@ -394,6 +402,7 @@ static void Rulesets_MTFL(qbool enable)
for (i = 0; i < (sizeof(limited_min_cvars) / sizeof(limited_min_cvars[0])); i++)
Cvar_SetFlags(limited_min_cvars[i].var, Cvar_GetFlags(limited_min_cvars[i].var) & ~CVAR_RULESET_MIN);

rulesetDef.restrictRollAngle = false;
rulesetDef.ruleset = rs_default;
}
}
Expand Down Expand Up @@ -685,3 +694,14 @@ qbool Ruleset_AllowPolygonOffset(entity_t* ent)
return ent->model && ent->model->isworldmodel;
}
}

float Ruleset_RollAngle(void)
{
extern cvar_t cl_rollangle;

if (cls.demoplayback || cl.spectator || !rulesetDef.restrictRollAngle) {
return fabs(cl_rollangle.value);
}

return bound(0.0f, cl_rollangle.value, 5.0f);
}
3 changes: 3 additions & 0 deletions rulesets.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ typedef struct rulesetDef_s {
qbool restrictPacket;
qbool restrictParticles;
qbool restrictSound;
qbool restrictRollAngle;
} rulesetDef_t;

void Rulesets_Init(void);
Expand Down Expand Up @@ -78,3 +79,5 @@ void Rulesets_OnChange_allow_scripts (cvar_t *var, char *value, qbool *cancel);
void Rulesets_OnChange_cl_fakeshaft (cvar_t *var, char *value, qbool *cancel);
void Rulesets_OnChange_cl_delay_packet(cvar_t *var, char *value, qbool *cancel);
void Rulesets_OnChange_cl_iDrive(cvar_t *var, char *value, qbool *cancel);

float Ruleset_RollAngle(void);

0 comments on commit 7f4dc7f

Please sign in to comment.