Skip to content
Permalink
Browse files

mod: fixed previous exploit fix introducing no weapon on revive issue…

… #1288 + fixed riflenade disappearing for no reason (fast switch)
  • Loading branch information...
Aranud committed May 15, 2019
1 parent 6ff60b7 commit 125ad60eee49b758d52901440da8c770a6676029
Showing with 26 additions and 22 deletions.
  1. +10 −10 src/cgame/cg_weapons.c
  2. +16 −12 src/game/bg_pmove.c
@@ -3686,6 +3686,15 @@ void CG_AltWeapon_f(void)
return;
}

// don't allow another weapon switch when we're still swapping alt weap, to prevent animation breaking
// there we check the value of the animation to prevent any switch during raising and dropping alt weapon
// until the animation is ended
if ((cg.snap->ps.weapAnim & ~ANIM_TOGGLEBIT) == GetWeaponTableData(cg.snap->ps.weapon)->altSwitchFrom ||
(cg.snap->ps.weapAnim & ~ANIM_TOGGLEBIT) == GetWeaponTableData(cg.snap->ps.weapon)->altSwitchTo)
{
return;
}

// need ground for this
if (GetWeaponTableData(cg.weaponSelect)->type & WEAPON_TYPE_SETTABLE)
{
@@ -4098,7 +4107,7 @@ qboolean CG_CheckCanSwitch(void)
return qfalse;
}

if (GetWeaponTableData(cg.weaponSelect)->type & WEAPON_TYPE_SET)
if (GetWeaponTableData(cg.snap->ps.weapon)->type & WEAPON_TYPE_SET)
{
return qfalse;
}
@@ -4115,15 +4124,6 @@ qboolean CG_CheckCanSwitch(void)
return qfalse;
}

// there is an exploit permitting to fast change weapon right after firing the last bullet/missile.
// i.e: in case of MG set, it skip unset animation / in case of riflenade, the nade is fired and still loaded
// More precisly, it appear when the event "EV_NOAMMO" is reached. In this case, player can "overwrite"
// the value forced by autoswitch. To prevent it, we are waiting the game to return the current weapon "selected"
if (cg.weaponSelect != cg.snap->ps.weapon)
{
return qfalse;
}

return qtrue;
}

@@ -238,7 +238,7 @@ void PM_ClipVelocity(vec3_t in, vec3_t normal, vec3_t out, float overbounce)
* @param[in] ignoreent
* @param[in] tracemask
*/
void PM_TraceLegs(trace_t *trace, float *legsOffset, vec3_t start, vec3_t end, trace_t *bodytrace, vec3_t viewangles, void(tracefunc) (trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentMask), int ignoreent, int tracemask)
void PM_TraceLegs(trace_t *trace, float *legsOffset, vec3_t start, vec3_t end, trace_t *bodytrace, vec3_t viewangles, void (tracefunc) (trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentMask), int ignoreent, int tracemask)
{
vec3_t ofs, org, point;
vec3_t flatforward;
@@ -319,13 +319,13 @@ void PM_TraceLegs(trace_t *trace, float *legsOffset, vec3_t start, vec3_t end, t
* @param[in] tracemask
*/
void PM_TraceHead(trace_t *trace, vec3_t start, vec3_t end, trace_t *bodytrace, vec3_t viewangles,
void(tracefunc) (trace_t *results,
const vec3_t start,
const vec3_t mins,
const vec3_t maxs,
const vec3_t end,
int passEntityNum,
int contentMask),
void (tracefunc) (trace_t *results,
const vec3_t start,
const vec3_t mins,
const vec3_t maxs,
const vec3_t end,
int passEntityNum,
int contentMask),
int ignoreent,
int tracemask)
{
@@ -2383,10 +2383,9 @@ static void PM_BeginWeaponChange(weapon_t oldWeapon, weapon_t newWeapon, qboolea
if (!(GetWeaponTableData(oldWeapon)->type & WEAPON_TYPE_RIFLENADE) || pm->ps->ammoclip[GetWeaponTableData(oldWeapon)->ammoIndex])
{
PM_AddEvent(EV_CHANGE_WEAPON_2);
PM_StartWeaponAnim(GetWeaponTableData(oldWeapon)->altSwitchFrom);
}

PM_StartWeaponAnim(GetWeaponTableData(oldWeapon)->altSwitchFrom);

if (GetWeaponTableData(newWeapon)->type & WEAPON_TYPE_SET)
{
vec3_t axis[3];
@@ -2711,7 +2710,12 @@ static void PM_SwitchIfEmpty(void)
{
pm->ps->ammoclip[WP_SATCHEL_DET] = 1;
pm->ps->ammoclip[WP_SATCHEL] = 0;
PM_BeginWeaponChange(WP_SATCHEL, WP_SATCHEL_DET, qfalse);
}

// force switching to rifle
if (GetWeaponTableData(pm->ps->weapon)->type & WEAPON_TYPE_RIFLENADE)
{
PM_BeginWeaponChange(pm->ps->weapon, GetWeaponTableData(pm->ps->weapon)->weapAlts, qfalse);
}

PM_AddEvent(EV_NOAMMO);
@@ -3941,7 +3945,7 @@ void PM_UpdateLean(playerState_t *ps, usercmd_t *cmd, pmove_t *tpm)
*
* @note Tnused trace parameter
*/
void PM_UpdateViewAngles(playerState_t *ps, pmoveExt_t *pmext, usercmd_t *cmd, void(trace) (trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentMask), int tracemask) // modified
void PM_UpdateViewAngles(playerState_t *ps, pmoveExt_t *pmext, usercmd_t *cmd, void (trace) (trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentMask), int tracemask) // modified
{
short temp;
int i;

0 comments on commit 125ad60

Please sign in to comment.
You can’t perform that action at this time.