From a19dc7d165da9f317f288730fa58341cde26e140 Mon Sep 17 00:00:00 2001 From: IQuant Date: Sun, 10 Nov 2024 14:26:21 +0300 Subject: [PATCH] Extra check in local_health --- quant.ew/files/core/util.lua | 7 ++++++- quant.ew/files/system/local_health/local_health.lua | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/quant.ew/files/core/util.lua b/quant.ew/files/core/util.lua index a344d0bd..4bbf0b63 100644 --- a/quant.ew/files/core/util.lua +++ b/quant.ew/files/core/util.lua @@ -290,16 +290,21 @@ function util.log(...) if ctx.proxy_opt.debug then GamePrint(...) end + print(...) end function util.serialize_entity(ent) -- Serialized entities usually get sent to other clients, and it's a very bad idea to try and send them another WorldState. - if EntityHasTag(ent, "world_state") or EntityGetFirstComponentIncludingDisabled(ent, "WorldStateComponent") ~= nil then + if util.is_world_state_entity_like(ent) then error("Tried to serialize WorldStateEntity") end return np.SerializeEntity(ent) end +function util.is_world_state_entity_like(ent) + return EntityHasTag(ent, "world_state") or EntityGetFirstComponentIncludingDisabled(ent, "WorldStateComponent") ~= nil +end + function util.deserialize_entity(ent_data, x, y) local ent = EntityCreateNew() if x == nil or y == nil then diff --git a/quant.ew/files/system/local_health/local_health.lua b/quant.ew/files/system/local_health/local_health.lua index 16d3a8d1..d2f0e425 100644 --- a/quant.ew/files/system/local_health/local_health.lua +++ b/quant.ew/files/system/local_health/local_health.lua @@ -167,6 +167,10 @@ local function player_died() if ctx.my_player.entity == nil then return end + if util.is_world_state_entity_like(ctx.my_player.entity) then + util.log("Err: Current player is world state like.") + return + end rpc.remove_homing(false) -- Serialize inventory, perks, and max_hp, we'll need to copy it over to notplayer. local item_data = inventory_helper.get_item_data(ctx.my_player)