Skip to content

Commit 2034fb8

Browse files
committed
Fix FPS sync
Used the wrong event for counting frames, see The-Powder-Toy/The-Powder-Toy@f137bad7f849 and The-Powder-Toy/The-Powder-Toy@63661a752c89.
1 parent f4ec3b8 commit 2034fb8

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

tptmp/client/client.lua

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1249,6 +1249,12 @@ function client_i:tick_fpssync_invalidate_()
12491249
end
12501250
end
12511251

1252+
function client_i:aftersim_fpssync_()
1253+
if self.registered_ and self.fps_sync_ then
1254+
self.fps_sync_count_ = self.fps_sync_count_ + 1
1255+
end
1256+
end
1257+
12521258
function client_i:tick_fpssync_()
12531259
if self.registered_ then
12541260
if self.fps_sync_ then
@@ -1263,7 +1269,6 @@ function client_i:tick_fpssync_()
12631269
end
12641270
end
12651271
end
1266-
self.fps_sync_count_ = self.fps_sync_count_ + 1
12671272
if now_msec >= self.fps_sync_last_ + 1000 then
12681273
self:send_fpssync(now_msec - self.fps_sync_first_, self.fps_sync_count_)
12691274
self.fps_sync_last_ = now_msec
@@ -1304,6 +1309,13 @@ function client_i:tick_fpssync_()
13041309
end
13051310
end
13061311

1312+
function client_i:aftersim()
1313+
if self.status_ ~= "running" then
1314+
return
1315+
end
1316+
self:aftersim_fpssync_()
1317+
end
1318+
13071319
function client_i:tick()
13081320
if self.status_ ~= "running" then
13091321
return

tptmp/client/init.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,12 @@ local function run()
270270
end
271271
end
272272

273+
local handle_aftersim = modulepack.xpcall_wrap(function()
274+
if cli then
275+
cli:aftersim()
276+
end
277+
end)
278+
273279
local pcur_r, pcur_g, pcur_b, pcur_a = unpack(colours.common.player_cursor)
274280
local bmode_to_repr = {
275281
[ 0 ] = "",
@@ -411,6 +417,7 @@ local function run()
411417

412418
local event_handlers = {
413419
{ event = evt.TICK, handle = handle_tick },
420+
{ event = evt.AFTERSIM, handle = handle_aftersim },
414421
}
415422

416423
local function handle_simple(event, handler)

0 commit comments

Comments
 (0)