fix(handlers): guard GetBoostTimeLimit against past boost_time

Live-server testing via protbot surfaced an inconsistency between
GetBoostTimeLimit and GetBoostRight: on the same character, the
former reported a far-future boost limit (2288912640 = year 2042)
while the latter correctly reported "expired / available". The two
handlers read the same boost_time row and disagreed.

Root cause: GetBoostTimeLimit was doing a naked uint32(int64) cast
on boostLimit.Unix(). The test character's boost_time was actually
year 1906 (a pre-1970 sentinel left behind by the pre-#187 bug),
whose negative int64 Unix timestamp wraps through uint32 to a huge
positive value the client interprets as a permanently active boost.

Harmonise the guard with GetBoostRight: return 0 whenever the stored
boost_time is not strictly after TimeAdjusted(), covering both the
pre-1970 wraparound and the "already expired" case.

Add a healing migration (0011_fix_stale_boost_time) that NULLs out
any boost_time column older than 1970 or more than 10 years in the
future, so affected characters recover on upgrade without waiting
for a fresh boost start.

Regression test uses the exact year-1906 value observed on the live
frontier.mogapedia.fr test account.
This commit is contained in:
Houmgaor
2026-04-06 18:26:15 +02:00
parent e2b0a8ad8c
commit 4ad0012f62
3 changed files with 49 additions and 3 deletions

View File

@@ -0,0 +1,18 @@
-- Heal characters whose boost_time column holds a nonsensical value left
-- over from the pre-#187 bug. Two cases observed on live servers:
--
-- 1. Pre-1970 timestamps (e.g. 1906-xx-xx) written when an uninitialised
-- time.Time wrapped through an int64->uint32 cast.
-- 2. Far-future timestamps that are not consistent with any legitimate
-- BoostTimeDuration config (BoostTimeDuration is capped at a few hours).
--
-- Both are meaningless and should be NULL so that the boost system is
-- treated as inactive until the character triggers a fresh boost start.
-- NULL is the default for characters that have never boosted; see
-- handlers_cafe.go handleMsgMhfGetBoostTimeLimit / handleMsgMhfGetBoostRight.
UPDATE public.characters
SET boost_time = NULL
WHERE boost_time IS NOT NULL
AND (boost_time < TIMESTAMP '1970-01-01 00:00:00'
OR boost_time > now() + interval '10 years');