Fix decoration reward timestamp to prevent duplicate rewards#658
Fix decoration reward timestamp to prevent duplicate rewards#658AngeloTadeucci merged 1 commit intomasterfrom
Conversation
At Rank 10, Home.GainExp() returned early without setting DecorationRewardTimestamp, leaving it at the daily-reset value of 0. The client saw timestamp=0 and kept showing the claim button as available, allowing unlimited reward claims. Fix: Move the timestamp update from GainExp into InteriorCheckIn and add a server-side check that prevents claiming when the timestamp is already set (non-zero) for the day. https://claude.ai/code/session_01DPS5yXmeVMzpihRr6UKrjj
📝 WalkthroughWalkthroughThe changes refactor decoration reward timestamp management by moving its update from the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@Maple2.Server.Game/Manager/HousingManager.cs`:
- Around line 474-476: After calling Home.GainExp(...) and setting
Home.DecorationRewardTimestamp, immediately persist the home to prevent
duplicate claims by calling SaveHome() (or the existing persistence method)
before sending the client reward packet; update the code path around
Home.GainExp, Home.DecorationRewardTimestamp and
session.Send(CubePacket.DesignRankReward(Home)) to invoke SaveHome() right after
setting the timestamp and ensure any SaveHome() errors are handled/logged.
- Around line 410-412: The current guard uses Home.DecorationRewardTimestamp !=
0 which permanently blocks future rewards; change it to compare the stored
timestamp against the current time window (e.g., same calendar day or
configurable cooldown) instead of checking non-zero. Locate the check around
Home.DecorationRewardTimestamp in HousingManager (the early return) and replace
it with logic like: convert DecorationRewardTimestamp to a
DateTime/DateTimeOffset, get the server local/UTC "today" boundary used by other
rewards, and return only if the stored timestamp falls within the same
day/cooldown as now; also ensure when awarding the decoration reward you update
Home.DecorationRewardTimestamp to the current Unix time (matching the stored
unit) so future comparisons work correctly.
…Community#658) Upstream: e6842a6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Summary by CodeRabbit