Skip to content

Commit

Permalink
Updated a few serverside hooks
Browse files Browse the repository at this point in the history
- ACF_OnPlayerLoaded => ACF_OnLoadPlayer
- ACF_IsLegal => ACF_OnCheckLegal
- ACF_KEShove => ACF_OnPushEntity
  • Loading branch information
TwistedTail committed Feb 18, 2024
1 parent 272299a commit 1d49605
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions lua/acf/core/globals.lua
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ do -- Player loaded hook
util.AddNetworkString("ACF_PlayerLoaded")

net.Receive("ACF_PlayerLoaded", function(_, Player)
hook.Run("ACF_OnPlayerLoaded", Player)
hook.Run("ACF_OnLoadPlayer", Player)
end)
else
hook.Add("InitPostEntity", "ACF Player Loaded", function()
Expand Down Expand Up @@ -280,7 +280,7 @@ do -- Smoke/Wind -----------------------------------
end
end)

hook.Add("ACF_OnPlayerLoaded", "ACF Send Smoke Wind", function(Player)
hook.Add("ACF_OnLoadPlayer", "ACF Send Smoke Wind", function(Player)
net.Start("acf_smokewind")
net.WriteFloat(ACF.SmokeWind)
net.Send(Player)
Expand Down
2 changes: 1 addition & 1 deletion lua/acf/core/networking/data_vars/data_vars_sv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ do -- Data syncronization
end
})

hook.Add("ACF_OnPlayerLoaded", "ACF Data Var Syncronization", function(Player)
hook.Add("ACF_OnLoadPlayer", "ACF Data Var Syncronization", function(Player)
-- Server data var syncronization
for Key in pairs(Server) do
NetworkData(Key, Player)
Expand Down
2 changes: 1 addition & 1 deletion lua/acf/core/validation_sv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function ACF.IsLegal(Entity)
if Entity.IsACFWeapon and not ACF.GunsCanFire then return false, "Cannot fire", "Firing disabled by the servers ACF settings." end
if Entity.IsRack and not ACF.RacksCanFire then return false, "Cannot fire", "Firing disabled by the servers ACF settings." end

local Legal, Reason, Message, Timeout = hook.Run("ACF_IsLegal", Entity)
local Legal, Reason, Message, Timeout = hook.Run("ACF_OnCheckLegal", Entity)

if not Legal then return Legal, Reason, Message, Timeout end

Expand Down
2 changes: 1 addition & 1 deletion lua/acf/core/version/version_sv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ end
do -- Client syncronization
util.AddNetworkString("ACF_VersionSync")

hook.Add("ACF_OnPlayerLoaded", "ACF_VersionSync", function(Player)
hook.Add("ACF_OnLoadPlayer", "ACF_VersionSync", function(Player)
local JSON = util.TableToJSON(Repos)

net.Start("ACF_VersionSync")
Expand Down
2 changes: 1 addition & 1 deletion lua/acf/damage/damage_sv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ function Damage.dealDamage(Entity, DmgResult, DmgInfo)
return HitRes or DmgResult:GetBlank()
end

hook.Add("ACF_OnPlayerLoaded", "ACF Render Damage", function(Player)
hook.Add("ACF_OnLoadPlayer", "ACF Render Damage", function(Player)
for _, Entity in ipairs(ents.GetAll()) do
local Data = Entity.ACF

Expand Down
2 changes: 1 addition & 1 deletion lua/acf/damage/ke_shove_sv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local Clock = ACF.Utilities.Clock
function ACF.KEShove(Target, Pos, Vec, KE)
if not IsValid(Target) then return end

if hook.Run("ACF_KEShove", Target, Pos, Vec, KE) == false then return end
if hook.Run("ACF_OnPushEntity", Target, Pos, Vec, KE) == false then return end

local Ancestor = ACF_GetAncestor(Target)
local Phys = Ancestor:GetPhysicsObject()
Expand Down
6 changes: 3 additions & 3 deletions lua/acf/hooks/hooks_sv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Hooks.Add("ACF_Base_Server", function(Gamemode)
--- Called when the player has properly loaded onto the server.
-- It's possible to use network messages in this hook, unlike PlayerInitialSpawn.
-- @param Player The player entity that just finished loading.
function Gamemode:ACF_OnPlayerLoaded()
function Gamemode:ACF_OnLoadPlayer()
end

--- Called when the bullet will attempt to use the default flight behavior
Expand All @@ -24,7 +24,7 @@ Hooks.Add("ACF_Base_Server", function(Gamemode)
-- @return The reason why the entity is illegal. Not required if legal.
-- @return A short explanation on why the entity is illegal. Not required if legal.
-- @return Optionally, the amount of time in seconds the entity will remain illegal for. Not required if legal.
function Gamemode:ACF_IsLegal()
function Gamemode:ACF_OnCheckLegal()
return true
end

Expand Down Expand Up @@ -76,7 +76,7 @@ Hooks.Add("ACF_Base_Server", function(Gamemode)
-- @param Direction The direction in which the entity is attempting to be pushed.
-- @param Energy The kinetic energy that's attempting to be applied to the entity.
-- @return True if the entity should be pushed by kinetic energy, false otherwise.
function Gamemode:ACF_KEShove()
function Gamemode:ACF_OnPushEntity()
return true
end

Expand Down
2 changes: 1 addition & 1 deletion lua/acf/menu/operations/acf_copy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if SERVER then
DisabledData[Data] = State
end)

hook.Add("ACF_OnPlayerLoaded", "ACF Copy Data", function(Player)
hook.Add("ACF_OnLoadPlayer", "ACF Copy Data", function(Player)
CopiedData[Player] = {}
Disabled[Player] = {}
end)
Expand Down
6 changes: 3 additions & 3 deletions lua/tests/acf/core/validation_sv/is_legal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ return {
},

{
name = "Is not Legal when ACF_IsLegal hook returns",
name = "Is not Legal when ACF_OnCheckLegal hook returns",
func = function( State )
hook.Add( "ACF_IsLegal", "TestFailure", function()
hook.Add( "ACF_OnCheckLegal", "TestFailure", function()
return false, "Test reason", "Test message", "Test timeout"
end )

Expand All @@ -169,7 +169,7 @@ return {
expect( Timeout ).to.equal( "Test timeout" )
end,

cleanup = function() hook.Remove( "ACF_IsLegal", "TestFailure" ) end
cleanup = function() hook.Remove( "ACF_OnCheckLegal", "TestFailure" ) end
},

{
Expand Down
4 changes: 2 additions & 2 deletions lua/tests/acf/damage/damage_sv/acf_keshove.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ return {
{
name = "Does not shove the entity if ACF_KEShove hook returns false",
func = function( State )
hook.Add( "ACF_KEShove", "Test", function() return false end )
hook.Add( "ACF_OnPushEntity", "Test", function() return false end )
local Ent = State.Ent

ACF.KEShove( Ent, Ones, Ones, 1 )
Expand All @@ -61,7 +61,7 @@ return {
end,

cleanup = function()
hook.Remove( "ACF_KEShove", "Test" )
hook.Remove( "ACF_OnPushEntity", "Test" )
end
},

Expand Down

0 comments on commit 1d49605

Please sign in to comment.