Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send HUD flags only if changed #12037

Merged
merged 2 commits into from
Feb 8, 2022
Merged

Conversation

appgurueu
Copy link
Contributor

@corarona
Copy link
Contributor

corarona commented Feb 1, 2022

yes please <3

could this be done with all object properties? This is a very easy thing to do wrong for modders.

@corarona
Copy link
Contributor

corarona commented Feb 1, 2022

actually mtg itself is doing this wrong: luanti-org/minetest_game#2900

@lhofhansl
Copy link
Contributor

A looong time ago I fixed a bug in the nssm mod (explanation here, got merged in tenPlus1's fork later: NPXcoot/nssm#22).

Not the same, but similar problem, where a mod can send block updates that starve out all other block updates from the server (the client stopped loading any other blocks). Definitely something the engine should fix - to some extend (f.e. not sending blocks that have not changed).

(Posted on wrong issue before)

@appgurueu
Copy link
Contributor Author

actually mtg itself is doing this wrong: minetest/minetest_game#2900

I guess I do have to include reasoning as to why this belongs in the engine and not the games/mods using the API, so here it is:

  1. The engine can do it very efficiently, as it already operates on the bitsets (u32). Lua on the other hand operates on tables due to the provided API.
  2. This means all mods will automatically get this fixed without having to change their implementation. Abondoned mods or games might benefit from this.
  3. This avoids both code duplication (if player:hud_get_flags().something then ... end all the time) or having to create an API myapi.hud_set_flags_if_unchanged(player, flags) which would then have to be adopted or again be duplicated. Mod code can continue being straightforward, well-readable and fast.

@corarona
Copy link
Contributor

corarona commented Feb 2, 2022

  1. It isn't really helpful to have the (default) option to resend properties that haven't changed.

Literally every occurrence of hud_set_flags (and set_properties and set_bones and maybe others ?) in a game/mod needs to check first ideally (we usually don't if it just happens once but it is still redundant traffic).

Copy link
Member

@SmallJoker SmallJoker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As an optimization, this is fine by me. HUD flags are sent as reliable and often updated in mods. However, mods should still try to be efficient in general, especially because other functions do not have such redundancy checks (HUD elements).

@sfan5 sfan5 merged commit b9ee29a into luanti-org:master Feb 8, 2022
@appgurueu appgurueu deleted the hud-flag-perf branch March 31, 2024 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

unchanged minimap hud flags are sent to the client repeatedly
6 participants