Skip to content

Commit c5eebb6

Browse files
S1M0N38Copilot
andcommitted
chore(log): improve comment about hand_rearrange hook hack
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 4bbe051 commit c5eebb6

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/lua/log.lua

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -273,12 +273,16 @@ function hook_hand_rearrange()
273273
arguments = { cards = cards },
274274
}
275275

276-
-- NOTE: we cannot schedule a log write because we don't have access to the
277-
-- state before the function call. We need to recreate it.
278-
279-
-- HACK: we cannot compute the timestamp before in the right way the function
280-
-- call because because this hook run with the game loop. So we use the
281-
-- timestamp for after and before
276+
-- NOTE: We cannot schedule a log write at this point because we do not have
277+
-- access to the game state before the function call. The game state is only
278+
-- available after the function executes, so we need to recreate the "before"
279+
-- state manually by using the most recent known state (LOG.game_state_before).
280+
281+
-- HACK: The timestamp for the log entry is problematic because this hook runs
282+
-- within the game loop, and we cannot accurately compute the "before" timestamp
283+
-- at the time of the function call. To address this, we use the same timestamp
284+
-- for both "before" and "after" states. This approach ensures that the log entry
285+
-- is consistent, but it may slightly reduce the accuracy of the timing information.
282286

283287
local timestamp_ms = math.floor(socket.gettime() * 1000)
284288

0 commit comments

Comments
 (0)