Skip to content

[81] Rested XP and offline rest-state parity#86

Open
alseif0x wants to merge 9 commits into
3.4.3from
81-follow-up-rested-xp-+-offline-rest-state-parity
Open

[81] Rested XP and offline rest-state parity#86
alseif0x wants to merge 9 commits into
3.4.3from
81-follow-up-rested-xp-+-offline-rest-state-parity

Conversation

@alseif0x

@alseif0x alseif0x commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Refs #81

QA pending: do not merge until manual client validation, capture-diff review, CI, and Codex reviewer verdict are complete.

Summary:

  • Re-anchors rested XP load/save and offline accrual to C++ RestMgr/Player::LoadFromDB behavior.
  • Loads AreaTrigger.db2-backed tavern triggers and applies tavern/city/faction rest flags.
  • Sends ActivePlayer RestInfo/NextLevelXP in create/update paths and preserves health/power across offline rest.

Validation already run locally:

  • PROTOC=/home/cdmonio/.local/protoc/bin/protoc cargo test -p wow-world --lib
  • PROTOC=/home/cdmonio/.local/protoc/bin/protoc cargo test -p wow-data tavern_area_trigger_store_validates_ids_like_cpp --lib
  • PROTOC=/home/cdmonio/.local/protoc/bin/protoc cargo test -p wow-database character_save_statements_match_cpp_sql_exactly --lib
  • PROTOC=/home/cdmonio/.local/protoc/bin/protoc cargo test -p wow-packet player_create_playerdata_self_layout_ends_with_dungeon_score_like_cpp --lib
  • PROTOC=/home/cdmonio/.local/protoc/bin/protoc cargo check -p world-server
  • cargo fmt --all -- --check
  • git diff --check

Manual QA pending:

  • Relog in/out of rest area; verify health/mana do not refill.
  • Verify rested state/rest bonus logs and client behavior.
  • Capture-clean comparison vs C++.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 836b63d2e5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/wow-world/src/handlers/character.rs
Comment thread crates/wow-world/src/handlers/misc.rs Outdated
Comment thread crates/wow-world/src/session.rs
Comment thread crates/wow-world/src/handlers/character.rs
Comment thread crates/wow-world/src/session.rs
@alseif0x

alseif0x commented Jul 4, 2026

Copy link
Copy Markdown
Owner Author

@codex review\n\nPushed review fixes in 11f09ac. Addressed logout_time=0 accrual, restoring saved logout resting flag, tavern triggers outside the teleport store gate, and rested-XP spend on victim XP grants. The rested XP cap remains next_level_xp * 1.5 / 2 because this matches /home/server/woltk-trinity-legacy/src/server/game/Entities/Player/RestMgr.cpp::SetRestBonus.

alseif0x commented Jul 4, 2026

Copy link
Copy Markdown
Owner Author

QA validation checklist:

  • Log in with a character that logged out in a rest area; it should still be treated as resting after login and after a logout/relogin cycle.
  • Log in with a fresh/no-previous-logout character; it must not start with a huge rested XP pool.
  • Kill an XP-granting creature with rested bonus available; the XP gain should include the rested bonus and the rested pool should decrease.
  • Grant/earn XP without a creature victim path where possible; it should not spend rested kill XP.
  • Verify normal login, movement, combat, logout, and relog still work.

Note: this PR still needs the current-head Codex reviewer verdict before it is merge-ready.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 11f09ac8a0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/wow-world/src/session.rs
Comment thread crates/wow-world/src/handlers/misc.rs
Comment thread crates/wow-world/src/session.rs Outdated
Comment thread crates/wow-world/src/session.rs Outdated
@alseif0x

alseif0x commented Jul 4, 2026

Copy link
Copy Markdown
Owner Author

@codex review

Pushed b77a6cd to address the four actionable comments: rest-state sync now runs after login player setup, tavern area triggers require the authoritative trigger and position validation before setting rest, LogXPGain now sends base XP in original and rested-total XP in amount, and city rest is gated by linked-chat plus non-hostile/sanctuary area flags.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b77a6cd62b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/wow-world/src/handlers/misc.rs
Comment thread crates/wow-world/src/session.rs
Comment thread crates/wow-world/src/session.rs Outdated
Comment thread crates/wow-world/src/session.rs
Comment thread crates/wow-world/src/session.rs
Comment thread crates/wow-world/src/session.rs
Comment thread crates/wow-world/src/session.rs
@alseif0x

alseif0x commented Jul 4, 2026

Copy link
Copy Markdown
Owner Author

Review fixes pushed in f714328.\n\nAddressed current Codex feedback:\n- CMSG_AREA_TRIGGER now validates against AreaTrigger.db2 before tavern/teleport handling; tavern triggers no longer depend on the teleport-only store.\n- Logout-rest restore no longer synthesizes REST_FLAG_IN_TAVERN; it uses a session-local restored bit and clears on authoritative area/zone/tavern updates.\n- Resting flag UpdateObject preserves current canonical player flags and only toggles PLAYER_FLAGS_RESTING.\n- LogXPGain fields restored to C++ order: Original=xp+bonus, Amount=xp.\n- Rest bonus consumption now flushes RestInfo and persists rest state after async XP gain.\n\nValidated locally:\n- PROTOC=/home/cdmonio/.local/protoc/bin/protoc cargo test -p wow-world area_trigger_tavern --lib\n- PROTOC=/home/cdmonio/.local/protoc/bin/protoc cargo test -p wow-world load_resting_logout_state_restores_current_rest_flag_like_cpp --lib\n- PROTOC=/home/cdmonio/.local/protoc/bin/protoc cargo test -p wow-world give_xp_runtime_ --lib\n- PROTOC=/home/cdmonio/.local/protoc/bin/protoc cargo test -p wow-world update_zone_linked_chat_sets_city_rest_only_when_not_hostile_like_cpp --lib\n- PROTOC=/home/cdmonio/.local/protoc/bin/protoc cargo test -p wow-world rested_xp --lib\n- cargo fmt --all -- --check\n- git diff --check\n- PROTOC=/home/cdmonio/.local/protoc/bin/protoc cargo check -p world-server\n\n@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f7143283f6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/wow-world/src/session.rs Outdated
Comment thread crates/wow-world/src/session.rs
Comment thread crates/wow-world/src/handlers/misc.rs Outdated
@alseif0x

alseif0x commented Jul 4, 2026

Copy link
Copy Markdown
Owner Author

@codex review

Pushed e092b0ff for the current review feedback:

  • Added represented C++ RestMgr::_restTime and online rested-XP accrual after at least 10s in a rest state (RATE_REST_INGAME represented as 1.0 until config rates are wired).
  • Character rest load now clears stale rest flags, inn trigger id, and rest time before optionally restoring characters.is_logout_resting, so a relog/character swap cannot inherit another character's rest mask.
  • LinkedChat/capital city rest now follows local C++ Player::UpdateZone: rest if not hostile or if the zone is sanctuary, without requiring faction rest bits.

I did not change leave-packet area-trigger validation: local C++ WorldSession::HandleAreaTriggerOpcode only runs IsInAreaTriggerRadius for packet.Entered, then removes tavern rest on leave. The existing Rust behavior matches that C++ branch.

Validation:

  • PROTOC=/home/cdmonio/.local/protoc/bin/protoc cargo test -p wow-world rested_xp --lib
  • PROTOC=/home/cdmonio/.local/protoc/bin/protoc cargo test -p wow-world update_zone_linked_chat_sets_city_rest_only_when_not_hostile_like_cpp --lib
  • PROTOC=/home/cdmonio/.local/protoc/bin/protoc cargo test -p wow-world area_trigger_tavern --lib
  • PROTOC=/home/cdmonio/.local/protoc/bin/protoc cargo test -p wow-world load_rest_state_clears_stale_rest_flags_between_characters_like_cpp --lib
  • PROTOC=/home/cdmonio/.local/protoc/bin/protoc cargo test -p wow-world give_xp_runtime_ --lib
  • cargo fmt --all -- --check
  • git diff --check
  • PROTOC=/home/cdmonio/.local/protoc/bin/protoc cargo check -p world-server

The rested cap remains next_level_xp * 1.5 / 2 because local C++ RestMgr::SetRestBonus clamps to that formula.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e092b0ff66

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/wow-world/src/session.rs Outdated
Comment thread crates/wow-database/src/statements/character.rs Outdated
Comment thread crates/wow-world/src/session.rs
@alseif0x

alseif0x commented Jul 4, 2026

Copy link
Copy Markdown
Owner Author

Updated in 1d7517c for the current Codex review:

  • Persist playerFlags together with the represented rest-state save so character enum can see PLAYER_FLAGS_RESTING after rested logout.
  • Revalidate the saved tavern area trigger during the session update and clear REST_FLAG_IN_TAVERN once the player is no longer inside it, matching the local C++ Player::Update tavern recheck.
  • Added focused tests for rest-state save flags and stale tavern trigger cleanup.

I intentionally kept these as-is after checking the local C++ source:

  • Rested state threshold/cap: local RestMgr::SetRestBonus uses rested at _restBonus >= 1 and caps with nextLevelXP * 1.5f / 2.
  • Area-trigger leave radius: local HandleAreaTriggerOpcode applies the radius guard only for packet.Entered.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1d7517cc15

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/wow-world/src/session.rs Outdated
Comment thread crates/wow-world/src/session.rs Outdated
Comment thread crates/wow-world/src/session.rs
@alseif0x

alseif0x commented Jul 4, 2026

Copy link
Copy Markdown
Owner Author

Updated in 86df215 for the latest Codex review:

  • Loaded characters.playerFlags during character load, rehydrates the canonical player flags once the login player exists, and the partial rest-state save now preserves loaded DB flags until canonical has received them.
  • Loaded rest_bonus now goes through the represented SetRestBonus-style clamp before syncing RestInfo, so stale over-cap and max-level values normalize at login.
  • UpdateZone now recalculates represented hostile area state before applying city rest, while keeping local C++ AreaFlags::LinkedChat as the capital-city gate.

Validation: cargo test -p wow-world player_flags --lib, cargo test -p wow-world rest --lib, cargo fmt --check, git diff --check.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 86df215bc6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/wow-world/src/handlers/character.rs
Comment thread crates/wow-world/src/session.rs Outdated
Comment thread crates/wow-world/src/handlers/misc.rs
Comment thread crates/wow-world/src/session.rs Outdated
@alseif0x alseif0x force-pushed the 81-follow-up-rested-xp-+-offline-rest-state-parity branch from 86df215 to 18962c3 Compare July 4, 2026 12:13
@alseif0x

alseif0x commented Jul 4, 2026

Copy link
Copy Markdown
Owner Author

Updated in 18962c3a for the latest Codex feedback:

  • Self-create packets now carry loaded/canonical PlayerFlags and PlayerFlagsEx, including RESTING/GHOST/AFK/DND-style persisted bits.
  • Online rested-XP spend now persists only restState, playerFlags, and rest_bonus; it no longer stamps logout_time or is_logout_resting.
  • Far teleport world-port ack now resolves destination zone/area and recomputes represented rest flags before the destination self-create packet.
  • RAF-linked rest state is preserved when loading/normalizing rested bonus.

Validation after rebasing onto current 3.4.3:

  • cargo fmt --check
  • git diff --check
  • PROTOC=/home/cdmonio/.local/protoc/bin/protoc cargo test -p wow-world player_create_flags_use_loaded_and_canonical_bits_like_cpp --lib
  • PROTOC=/home/cdmonio/.local/protoc/bin/protoc cargo test -p wow-world online_rest_state_save_statement_does_not_touch_logout_columns_like_cpp --lib
  • PROTOC=/home/cdmonio/.local/protoc/bin/protoc cargo test -p wow-world load_raf_linked_rest_state_survives_rest_bonus_set_like_cpp --lib
  • PROTOC=/home/cdmonio/.local/protoc/bin/protoc cargo test -p wow-world world_port_response_recomputes_destination_rest_state_before_self_create_like_cpp --lib
  • PROTOC=/home/cdmonio/.local/protoc/bin/protoc cargo test -p wow-packet player_create_writes_loaded_player_flags_like_cpp --lib
  • PROTOC=/home/cdmonio/.local/protoc/bin/protoc cargo test -p wow-database character_save_statements_match_cpp_sql_exactly --lib
  • PROTOC=/home/cdmonio/.local/protoc/bin/protoc cargo check -p world-server

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 18962c3af4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/wow-world/src/session.rs
Comment thread crates/wow-world/src/session.rs Outdated
Comment thread crates/wow-world/src/session.rs
Comment thread crates/wow-world/src/session.rs
Comment thread crates/wow-world/src/handlers/misc.rs Outdated
@alseif0x

alseif0x commented Jul 4, 2026

Copy link
Copy Markdown
Owner Author

Addressed the latest Codex review follow-ups in 40870ed:

  • wired CONFIG_MAX_PLAYER_LEVEL and Rate.Rest.* into WorldSession rested-XP config
  • normalized RAF rest state from current RAF eligibility instead of preserving stale DB state
  • applied SPELL_AURA_MOD_RESTED_XP_CONSUMPTION to rested pool loss while preserving awarded bonus XP
  • guarded tavern area-trigger leave packets when the player is still inside the DB2 trigger radius

Validation:

  • PROTOC=/home/cdmonio/.local/protoc/bin/protoc cargo test -p wow-world rested_xp --lib
  • PROTOC=/home/cdmonio/.local/protoc/bin/protoc cargo test -p wow-world area_trigger_tavern --lib
  • PROTOC=/home/cdmonio/.local/protoc/bin/protoc cargo test -p wow-world stale_raf_linked_rest_state_recomputes_when_bonus_is_normalized_like_cpp --lib
  • PROTOC=/home/cdmonio/.local/protoc/bin/protoc cargo test -p wow-data spell_effect_constants_match_cpp_shared_defines --lib
  • PROTOC=/home/cdmonio/.local/protoc/bin/protoc cargo check -p world-server
  • cargo fmt --check
  • git diff --check

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 40870ed051

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[follow-up] Rested XP + offline rest-state parity

1 participant