@@ -6,6 +6,7 @@ local KILLSTAT_REMOVAL_TIME = 30
6
6
7
7
local MAX_NAME_LENGTH = 19
8
8
local HUD_LINES = 6
9
+ local HUD_UPDATE_INTERVAL = 2
9
10
local HUD_LINE_HEIGHT = 36
10
11
local HUDNAME_FORMAT = " kill_list:%d,%d"
11
12
@@ -79,9 +80,19 @@ local function update_hud_line(player, idx, new)
79
80
end
80
81
end
81
82
83
+ local hudupdate_queue = {}
82
84
local function update_kill_list_hud (player )
83
- for i = 1 , HUD_LINES , 1 do
84
- update_hud_line (player , i , kill_list [i ])
85
+ local name = player :get_player_name ()
86
+
87
+ if not hudupdate_queue [name ] then
88
+ hudupdate_queue [name ] = minetest .after (HUD_UPDATE_INTERVAL , function ()
89
+ if minetest .get_player_by_name (name ) then
90
+ for i = 1 , HUD_LINES , 1 do
91
+ update_hud_line (player , i , kill_list [i ])
92
+ end
93
+ end
94
+ hudupdate_queue [name ] = nil
95
+ end )
85
96
end
86
97
end
87
98
@@ -108,14 +119,19 @@ minetest.register_globalstep(function(dtime)
108
119
109
120
table.remove (kill_list )
110
121
111
- for _ , p in pairs (minetest .get_connected_players ()) do
112
- update_kill_list_hud ( p )
122
+ for i , p in pairs (minetest .get_connected_players ()) do
123
+ minetest . after ( i / 40 , update_kill_list_hud , p ) -- spread out update across server steps
113
124
end
114
125
end
115
126
end )
116
127
117
128
ctf_api .register_on_match_end (function ()
118
129
kill_list = {}
130
+
131
+ for _ , job in pairs (hudupdate_queue ) do
132
+ job :cancel ()
133
+ end
134
+
119
135
hud :clear_all ()
120
136
end )
121
137
0 commit comments