From 280aed484ce7adb3fc52df1bca79c8770b4e8719 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Thu, 8 Jul 2021 15:34:50 +0200 Subject: [PATCH] Do not send useless HUDCHANGE packets Several mods set or unset the visibility of a HUD bar way too often (e.g. in a globalstep handler), causing the server to send a lot of superfluous HUDCHANGE packets to each client. Returning from hb.hide_hudbar() early if HUD bar visibility would not change prevents sending these packets. --- mods/HUD/hudbars/init.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mods/HUD/hudbars/init.lua b/mods/HUD/hudbars/init.lua index e52aa880..21a27ce3 100644 --- a/mods/HUD/hudbars/init.lua +++ b/mods/HUD/hudbars/init.lua @@ -413,6 +413,7 @@ function hb.hide_hudbar(player, identifier) local name = player:get_player_name() local hudtable = hb.get_hudtable(identifier) if hudtable == nil then return false end + if hudtable.hudstate[name].hidden == true then return true end if hb.settings.bar_type == "progress_bar" then if hudtable.hudids[name].icon ~= nil then player:hud_change(hudtable.hudids[name].icon, "scale", {x=0,y=0}) @@ -431,6 +432,7 @@ function hb.unhide_hudbar(player, identifier) local name = player:get_player_name() local hudtable = hb.get_hudtable(identifier) if hudtable == nil then return false end + if hudtable.hudstate[name].hidden == false then return true end local value = hudtable.hudstate[name].value local max = hudtable.hudstate[name].max if hb.settings.bar_type == "progress_bar" then