Skip to content

Commit

Permalink
Fix broken ACF_OnUpdate[Realm]Data hooks
Browse files Browse the repository at this point in the history
Fixes the weapons menus being broken after merging #430
  • Loading branch information
thecraftianman committed Jan 22, 2025
1 parent ffe1345 commit d158650
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
10 changes: 5 additions & 5 deletions lua/acf/core/networking/data_vars/data_vars_cl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ do -- Server data var syncronization
if Values[K] ~= V then
Values[K] = V

hook.Run("ACF_OnServerDataUpdate", nil, K, V)
hook.Run("ACF_OnUpdateServerData", nil, K, V)
end

Received[K] = nil
Expand Down Expand Up @@ -123,7 +123,7 @@ end

do -- Client data setter function
--- Sets a client data var and networks it to the server.
--- Internally calls the ACF_OnClientDataUpdate hook
--- Internally calls the ACF_OnUpdateClientData hook
--- @param Key string The key of the datavar
--- @param Value any The value the datavar
--- @param Forced boolean Whether to send regardless of if the value has changed
Expand All @@ -135,7 +135,7 @@ do -- Client data setter function
if Forced or Client[Key] ~= Value then
Client[Key] = Value

hook.Run("ACF_OnClientUpdateData", LocalPlayer(), Key, Value)
hook.Run("ACF_OnUpdateClientData", LocalPlayer(), Key, Value)

NetworkData(Key)
end
Expand All @@ -144,7 +144,7 @@ end

do -- Server data setter function
--- Proposes changes to server datavars and networks them to server.
--- Internally calls the ACF_OnServerDataUpdate hook.
--- Internally calls the ACF_OnUpdateServerData hook.
--- @param Key string The key of the datavar
--- @param Value any The value of the datavar
--- @param Forced boolean Whether to send regardless of if the value has changed
Expand All @@ -162,7 +162,7 @@ do -- Server data setter function
if Forced or Server[Key] ~= Value then
Server[Key] = Value

hook.Run("ACF_OnServerDataUpdate", Player, Key, Value)
hook.Run("ACF_OnUpdateServerData", Player, Key, Value)

NetworkData(Key, true)
end
Expand Down
4 changes: 2 additions & 2 deletions lua/acf/core/networking/data_vars/data_vars_sh.lua
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ do -- Data persisting
Keys[Key] = Default
end

hook.Add("ACF_On" .. Realm .. "DataUpdate", "ACF Persisted Data", function(_, Key)
hook.Add("ACF_OnUpdate" .. Realm .. "Data", "ACF Persisted Data", function(_, Key)
UpdateData(Key)
end)

Expand Down Expand Up @@ -202,7 +202,7 @@ do -- Data callbacks
Store[Name] = nil
end

hook.Add("ACF_On" .. Realm .. "DataUpdate", "ACF Data Callbacks", function(Player, Key, Value)
hook.Add("ACF_OnUpdate" .. Realm .. "Data", "ACF Data Callbacks", function(Player, Key, Value)
if not Callback[Key] then return end

local Data = Queue[Key]
Expand Down
6 changes: 3 additions & 3 deletions lua/acf/core/networking/data_vars/data_vars_sv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ do -- Data syncronization

if not Data then return end

local Hook = "ACF_On" .. Type .. "DataUpdate"
local Hook = "ACF_OnUpdate" .. Type .. "Data"

for K, V in pairs(Data) do
if Values[K] ~= V then
Expand Down Expand Up @@ -186,7 +186,7 @@ end
do -- Server data setter function
--- Sets a server datavar and networks it to the client
--- The server cannot modify the client because we don't want ACF to natively support servers modifying the client
--- Internally calls the ACF_OnServerDataUpdate hook
--- Internally calls the ACF_OnUpdateServerData hook
--- @param Key string The key of the datavar
--- @param Value any The value the datavar
--- @param Forced boolean Whether to send regardless of difference checks
Expand All @@ -198,7 +198,7 @@ do -- Server data setter function
if Forced or Server[Key] ~= Value then
Server[Key] = Value

hook.Run("ACF_OnServerDataUpdate", nil, Key, Value)
hook.Run("ACF_OnUpdateServerData", nil, Key, Value)

NetworkData(Key)
end
Expand Down
2 changes: 1 addition & 1 deletion lua/acf/core/networking/data_vars/panel_functions_cl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ do -- Tracker and Setter panel functions
HijackFunctions(Panel, Setter or "SetValue")
end

hook.Add("ACF_On" .. Realm .. "DataUpdate", "ACF Update Panel Values", function(_, Key, Value)
hook.Add("ACF_OnUpdate" .. Realm .. "Data", "ACF Update Panel Values", function(_, Key, Value)
local Data = DataPanels[Realm][Key]

if not Data then return end -- This variable is not being set or tracked by panels
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 @@ -178,7 +178,7 @@ function ACF.UpdateThickness(Entity, PhysObj, Area, Ductility)
return math.Clamp(Armor, MinimumArmor, MaximumArmor)
end

hook.Add("ACF_OnServerDataUpdate", "ACF_MaxThickness", function(_, Key, Value)
hook.Add("ACF_OnUpdateServerData", "ACF_MaxThickness", function(_, Key, Value)
if Key ~= "MaxThickness" then return end

MaximumArmor = math.floor(ACF.CheckNumber(Value, ACF.MaximumArmor))
Expand Down
2 changes: 1 addition & 1 deletion lua/acf/menu/tool_functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ end
do -- Clientside Tool interaction
if SERVER then
-- When the client specifies a new tool mode, switch to the new stage and operation.
hook.Add("ACF_OnClientUpdateData", "ACF ToolMode", function(Player, Key, Value)
hook.Add("ACF_OnUpdateClientData", "ACF ToolMode", function(Player, Key, Value)
--- Check if the key is of the form (e.g. "ToolMode:acf_menu"/"ToolMode:acf_copy")
local Header, Name = unpack(string.Explode(":", Key), 1, 2)
if Header ~= "ToolMode" then return end
Expand Down
2 changes: 1 addition & 1 deletion lua/weapons/gmod_tool/stools/acfarmorprop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ local function UpdateArmor(_, Entity, Data)
duplicator.StoreEntityModifier(Entity, "ACF_Armor", { Thickness = Data.Thickness, Ductility = Ductility })
end

hook.Add("ACF_OnServerDataUpdate", "ACF_ArmorTool_MaxThickness", function(_, Key, Value)
hook.Add("ACF_OnUpdateServerData", "ACF_ArmorTool_MaxThickness", function(_, Key, Value)
if Key ~= "MaxThickness" then return end

MaximumArmor = math.floor(ACF.CheckNumber(Value, ACF.MaximumArmor))
Expand Down

0 comments on commit d158650

Please sign in to comment.