Skip to content

fix: Repair the XP rate cap and SQL install step - #49

Merged
Helias merged 2 commits into
azerothcore:masterfrom
EricksOliveira:fix-weekend-xp-rate-cap
Oct 18, 2026
Merged

Helias merged 2 commits into
azerothcore:masterfrom
EricksOliveira:fix-weekend-xp-rate-cap

Conversation

@EricksOliveira

@EricksOliveira EricksOliveira commented Oct 17, 2026 •

Copy link
Copy Markdown

What and why

Closes #9, which has two parts.

The README still told admins to import the SQL by hand or with db_assembler.sh, which AzerothCore doesn't have anymore. The module has shipped its SQL in data/sql/db-world/ since #11, and the worldserver applies it at startup, so the install steps now say that.

Players being told about the bonus without getting it has a real cause in today's code. With XPWeekend.IndividualXPEnabled = 1, the rate cap added in #41 saved the capped rate as a plain integer instead of the float bits the module reads back. The next read turned 2 into about 2.8e-45, so XP was multiplied down to 0 and the player gained no XP at all while the login text still announced the bonus.

Decisions worth knowing

  • The cap now saves through PlayerSettingSetRate, so the stored setting still matches the applied rate, which is what Sync player setting when capping XP rate #41 wanted.
  • A stored rate that isn't a normal positive float counts as never set. It falls back to XPWeekend.xpAmount, capped at MaxAllowedRate, and gets saved again, so characters already broken by the old cap recover on their own with no DB edit. That's the same rate a player who never used .weekendxp rate gets.
  • The fallback doesn't try to read the broken integer back as the old capped rate. It would be wrong for a fractional cap anyway (1.5 was saved as 1), and the player can set the rate again with .weekendxp rate.
  • No SQL file is added, since the one the issue asks for already exists.

Review guide

  • src/mod-double-xp-weekend.cpp, the ConfigIndividualXPEnabled() block in GetExperienceRate. The login text, .weekendxp config and the XP hook all go through it. std::isnormal catches every value the old cap could have written, since any integer below 0x00800000 reads back as zero or a subnormal float.
  • README.md is mechanical.

Known gaps

  • Not tested in game with EnablePlayerSettings = 0. The changed path only touches the in-memory setting there, and the rate is seeded again at every login like before.

EricksOliveira and others added 2 commits October 16, 2026 18:27
The README told users to import the SQL by hand or with
db_assembler.sh, which no longer exists. The module ships its SQL in
data/sql/db-world/ and the worldserver's DB updater applies it to the
world database at startup when world DB updates are enabled
(Updates.EnableDatabases), so describe that instead.

Closes azerothcore#9

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The rate cap added in azerothcore#41 wrote the capped rate back as an integer
instead of copying the float's bits. Later reads decoded it as ~0, so
affected players gained no XP at all during the event, not just no
bonus, while the login text announced the bonus.

The cap now stores the rate with the bit encoding. Stored rates that
are not a normal positive float, such as those written by the old
cap, fall back to XPWeekend.xpAmount (capped to MaxAllowedRate) and
are rewritten, so affected characters recover on their own.

Closes azerothcore#9

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3bdecb92-55dc-4cb1-b468-eebff2934ad5
📥 Commits

Reviewing files that changed from the base of the PR and between 7442879 and c0fa2fb.

📒 Files selected for processing: 2
  • README.md
  • src/mod-double-xp-weekend.cpp

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

The README now describes startup application of the module’s world SQL when world database updates are enabled. GetExperienceRate now validates stored individual XP rates and stores fallback or capped values through PlayerSettingSetRate.

Changes: XP module setup and rate validation

Layer / File(s) Summary
World SQL setup instructions
README.md
The installation instructions retain the module placement and rebuild steps, and state that worldserver applies the module’s world SQL at startup when world database updates are enabled.
Stored individual XP rate validation
src/mod-double-xp-weekend.cpp
GetExperienceRate restores the configured rate for stored values that are not normal positive floats. It caps values above the configured maximum. Both values are stored through PlayerSettingSetRate.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: nyeriah

Merge Risk: ⚪ Minimal · up to c0fa2

The change repairs invalid or over-cap stored XP rates and clarifies SQL installation. The untested disabled-settings mode does not establish a concrete failure, so no specific merge blocker is identified.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed Issue [#9] has two coding objectives. The README now directs administrators to place the module, rebuild AzerothCore, and let the worldserver apply SQL from data/sql/db-world/ when database updates …
Out of Scope Changes check Passed The README changes are limited to the installation instructions required by issue [#9]. The C++ changes are limited to validation and persistence of the individual XP rate required by the reported XP …
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes both main changes: repairing the XP rate cap and updating the SQL installation instructions.
Full details: Linked Issues check

Explanation

Issue [#9] has two coding objectives. The README now directs administrators to place the module, rebuild AzerothCore, and let the worldserver apply SQL from data/sql/db-world/ when database updates are enabled. The repository contains data/sql/db-world/mod-weekend-xp-texts.sql. GetExperienceRate now rejects non-normal or non-positive stored rates, falls back to the configured rate, caps rates above MaxAllowedRate, and persists both cases through PlayerSettingSetRate. This addresses the reported mismatch between the announced rate and the applied XP rate. The PR also reports in-game checks for normal, capped, recovered, relogged, and Joyous Journeys cases. No linked coding requirement remains unmet.

Full details: Out of Scope Changes check

Explanation

The README changes are limited to the installation instructions required by issue [#9]. The C++ changes are limited to validation and persistence of the individual XP rate required by the reported XP failure in issue [#9], plus the required &lt;cmath&gt; include. The SQL file listing confirms the documented existing SQL path. No unrelated change is demonstrated.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@EricksOliveira

Copy link
Copy Markdown
Author

Self-review — fix-weekend-xp-rate-cap → master

Outcome 2 findings — 1 fixed (commit message), 1 dismissed — single round, no code blockers

Fixes not re-reviewed finding 1: the reworded commit body, applied by amend in c0fa2fb

Reviewed c0fa2fb, stamped from 7c40caf (fix-weekend-xp-rate-cap vs azerothcore/mod-weekend-xp master, merge-base diff — 2 files, +21 −4)

By Claude Code, claude-opus-5-5 — self-review v0.14, 2026-10-16

Testing compiled and tested in-game by the author (2026-10-17, level-1 character vs level-1 mobs, base 50 XP, xpAmount 1.5, EnablePlayerSettings = 1), all as expected: never-set rate → 75; .weekendxp rate 3 → 150; MaxAllowedRate 3 → 2 + .reload config → 100 on two kills in a row (old code: 0 on the second); relog → login text, .weekendxp config and XP all at 2; character_settings row edited offline to the broken 2 0 1 → login text 1.5, 75 XP, row rewritten to 1069547520 0 1; .weekendxp rate 5 refused; .weekendxp rate 2 → 100; IndividualXPEnabled = 0 → 75 despite stored rate 2; Joyous Journeys on → applied rate 3, 150 XP. Module texts from the SQL showed in-game. Not tested: EnablePlayerSettings = 0. Linter codestyle-cpp.py: only 6 trailing-whitespace hits, all on pre-existing lines, none on changed lines.

Review details (1 round)

Intent Fix mod-weekend-xp #9: the README's SQL install step is out of date (the module SQL is auto-applied by the worldserver DB updater, db_assembler.sh is gone), and players announced the weekend bonus did not get it because the individual-rate cap stored the capped float rate as an integer; fix the encoding and let rates already stored that way recover automatically, with no other XP change.

Project rules .agents/docs/self-review-rules.md (core repo; the module repo has none) found and applied — pinned review, regression risk, upstream attribution, in-game testing

Diff cdd5096d61de4ef4b80d5fcae09d1f8933889067

Metadata b6bde5b7a551146f270f449ad0255482ab0bdebc

The module repo has no planning home, so this report lives in the core repo's .agents/plans/9-weekend-xp-no-sql-file/. No PR yet; metadata covers commit subjects only.

Round 1 — 7c40caf, 2 findings

  1. 7c40caf commit body — says players "got no extra XP", but the ~0 rate made OnPlayerGiveXP return 0 and Player::GiveXP drops xp < 1, so affected players gained no XP at all → fixed (draft: body reworded to "gained no XP at all during the event, not just no bonus"; applied by amend in c0fa2fb)
  2. src/mod-double-xp-weekend.cpp:724-729 — recovery resets a broken rate to xpAmount, not to the rate Sync player setting when capping XP rate #41 capped it to (e.g. xpAmount = 1 loses a capped rate of 2) → dismissed: per requirement 5 (author decision) an invalid stored rate counts as never set, matching MigratePlayerSettings; decoding it as an integer would still be wrong for fractional caps (1.5 was stored as 1), and the player can restore it with .weekendxp rate

@EricksOliveira

Copy link
Copy Markdown
Author

CC @Helias

@Helias
Helias merged commit d0ae9c6 into azerothcore:master Oct 18, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No sql file

2 participants