minetest-mods / anvil

Minetest mod providing an anvil with which to repair worn tools
GNU General Public License v3.0
14 stars 18 forks source link

Prevent HUD elements from getting stuck on the player's screen #27

Closed fluxionary closed 2 years ago

fluxionary commented 2 years ago

Currently, on occasion, the tool "health bar" gets stuck on the screen, and won't go away.

screenshot_20220207_090408

How to reproduce:

Result: A red/green bar in the center of the screen, that won't go away until I relog.

I think the cause of this is lag, coupled w/ the order that HUD create/destroy packets are sent to the client.

The fix is to update the HUD instead of stacking new HUDs on top of each other, and to remove the HUD with a globalstep instead of minetest.after().

I've only tested this with a 5.4.1 client/server (on linux), as I haven't yet found/built a 5.5 binary that doesn't crash immediately whenever I launch it. (EDIT: tested w/ 5.5 as well now)

I also normalized the code formatting, because it was a hodge-podge of different styles and I didn't know which style to copy. The formatting changes are in 1 commit, the bugfix is in another.