Damage Indicator

by Dummiez

Shows fancy, reactive floating damage numbers when entities get hit. Easily configurable/mod compatible.

Utilities
a month ago
2.0 - 2.1
1.36K
Combat Enemies

b ✅ Multiplayer desync when viewport culling is on

a month ago
(updated a month ago)

Title: Multiplayer desync when viewport culling is on

The bug:
With the "viewport culling" startup setting enabled, the mod can desync a multiplayer game during combat.

In scripts/viewer_utils.lua, get_player_viewport() reads player.display_resolution, player.zoom, and player.display_scale. These describe each player's local screen and are not synced across the network, so the server and each client calculate a different on-screen area for the same player. is_inside_player_view() then uses that area to decide whether to draw a damage number. When a hit lands near the edge of a player's screen, one peer draws it and another does not. That creates a render object on only one machine, which desyncs the game. add_indicator() also calls math.random() per event, so the mismatch can throw off the shared random state too.

This is hard to reproduce on demand. It only triggers when a hit sits right on the on-screen boundary, which depends on each player's resolution, zoom, and screen position. So it appears as an occasional combat desync, not a repeatable one.

Workaround:
Turn off the "viewport culling" startup setting. This is not taxing, because the "radius" setting (default 80 tiles) already limits damage numbers to hits near the player, and that check is synced across all peers.

Suggested fix:
Remove the on-screen check in is_inside_player_view(). It must not read display_resolution, zoom, or display_scale, because those values differ per peer, so creating a render object based on them desyncs the game. The "players = viewers" field already shows each draw only to the right players, so the check is not needed. If you still want culling, base it on player.position and a fixed tile distance (like the existing radius), which is the same on every peer.

a month ago

This should be fixed in 1.4.1

a month ago
(updated a month ago)

Excellent. Thanks for fixing, love your mod.

New response