Skip to content

Commit

Permalink
Update scripts to co-operate with launcher changes
Browse files Browse the repository at this point in the history
  • Loading branch information
EladNLG committed Dec 7, 2024
1 parent a66eb36 commit 46512b5
Showing 1 changed file with 10 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,30 +130,20 @@ void function CodeCallback_PredictWeaponMods( entity weapon )
#endif

#if SERVER
// called every TICK (NOT script frame) for every player.
// called every TICK (NOT script frame) for every weapon.
// used for calculating a player's weaponvars for
// their active and selected (weapon being switched to)
// weapons.
void function CodeCallback_DoWeaponModsForPlayer( entity player )
// all of their weapons.
void function CodeCallback_CalcWeaponModsForWeapon( entity weapon )
{
if (!IsValid(player))
if (!IsValid(weapon))
return
if (!IsValid(player.GetActiveWeapon()))
// only recalculate mods for weapons owned by players
if (!IsValid(weapon.GetWeaponOwner()) || !weapon.GetWeaponOwner().IsPlayer())
return

// recalculating mods is slightly expensive - enough
// that doing it for all weapons for all players
// is a bad idea. so offloading mod recalculation
// responsibility to the modder is better imo.
// we do it for the active weapon to not cause mispredictions.
// However, client does it every frame for the all of their weapons.
// (done in native, we arent in control of it.)
ModWeaponVars_CalculateWeaponMods( player.GetActiveWeapon() )

// the weapon the player is about to switch to
if (IsValid(player.GetSelectedWeapon()))
{
ModWeaponVars_CalculateWeaponMods( player.GetSelectedWeapon() )
}
// recalculating mods is slightly expensive? i think?
// TODO: check performance at high player counts?
// 32 * (max 6 offhand + 4 main weapons) = 320 calls per tick <-- a lot!!!!!
ModWeaponVars_CalculateWeaponMods( weapon )
}
#endif

0 comments on commit 46512b5

Please sign in to comment.