Skip to content

Commit

Permalink
Make starfall error hook use 'world' for server errors (#1833)
Browse files Browse the repository at this point in the history
* Make starfall error hook use 'world' for server errors

* Use world instead of false for server errors
  • Loading branch information
thegrb93 authored Aug 22, 2024
1 parent 7195792 commit 334a686
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lua/entities/starfall_processor/cl_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ hook.Add("StarfallError", "StarfallErrorReport", function(_, owner, client, main
if not IsValid(owner) then return end
local local_player = LocalPlayer()
if owner == local_player then
if not client or client == owner then
if client:IsWorld() or client == owner then
SF.AddNotify(owner, message, "ERROR", 7, "ERROR1")
elseif client then
if should_notify then
Expand Down
2 changes: 1 addition & 1 deletion lua/entities/starfall_processor/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ function ENT:Error(err)
self:SetColor(Color(255, 0, 0, 255))
end

hook.Run("StarfallError", self, self.owner, CLIENT and LocalPlayer() or false, self.sfdata and self.sfdata.mainfile or "", msg, traceback)
hook.Run("StarfallError", self, self.owner, CLIENT and LocalPlayer() or Entity(0), self.sfdata and self.sfdata.mainfile or "", msg, traceback)
SF.SendError(self, msg, traceback)
end

Expand Down
4 changes: 2 additions & 2 deletions lua/starfall/libs_sh/hook.lua
Original file line number Diff line number Diff line change
Expand Up @@ -572,10 +572,10 @@ add("Tick")
-- @class hook
-- @shared
-- @param Entity ent Starfall chip that errored
-- @param Player ply Who's fault it errored. Owner of the chip if on server, or player that the script errored if on client
-- @param Player|Entity ply Who's fault it errored. World-entity if it was a server error, or player that the script errored if on client
-- @param string err Error message
add("StarfallError", nil, function(instance, ent, owner, errply, _, err)
return true, {instance.WrapObject(ent), instance.WrapObject(errply or owner), err}
return true, {instance.WrapObject(ent), instance.WrapObject(errply), err}
end)

-- Game Events
Expand Down
1 change: 0 additions & 1 deletion lua/starfall/transfer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ else
callback = callback - 1
if callback>0 then return end
if chip and owner and client then
if client:IsWorld() then client = nil end
hook.Run("StarfallError", chip, owner, client, mainfile, message, traceback, should_notify)
end
end
Expand Down

0 comments on commit 334a686

Please sign in to comment.