Skip to content

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

Description

@alseif0x

Follow-up from #79 live validation and the relog resource audit. There is no dedicated rested-XP/offline-rest issue yet; keep this separate from SpellPower/current-power persistence.

Context

While validating #79, mana/current power was fixed to persist across relog. That raised the adjacent question: should long offline time or logging out in a city refill resources? C++ says no for health/mana/power. Offline time is used for sober/rested-XP style state, while current health/powers are saved and restored separately.

C++ anchors

  • Player::LoadFromDB computes time_diff from logout_time, loads rest_bonus, and later applies offline rest bonus using is_logout_resting: /home/server/woltk-trinity-legacy/src/server/game/Entities/Player/Player.cpp
  • RestMgr::Update, RestMgr::LoadRestBonus, RestMgr::CalcExtraPerSec: /home/server/woltk-trinity-legacy/src/server/game/Entities/Player/RestMgr.cpp
  • WorldSession::HandleLogoutRequestOpcode makes logout instant only for valid C++ cases such as resting and not in combat: /home/server/woltk-trinity-legacy/src/server/game/Handlers/MiscHandler.cpp
  • WorldSession::HandleAreaTriggerOpcode sets/removes tavern rest flags on tavern area triggers: /home/server/woltk-trinity-legacy/src/server/game/Handlers/MiscHandler.cpp
  • DB fields involved include characters.rest_bonus, characters.logout_time, characters.is_logout_resting, and rest-state fields loaded into RestMgr.

Current Rust gap

Rust has some DB columns and represented logout/login plumbing, but there is no clearly C++-faithful offline rested-XP accrual path. Logout is also still simplified elsewhere (#54), and tavern/city rest flag behavior is not fully anchored to C++ area-trigger/rest logic.

Do

  • Re-anchor Rust rest-state load/save to C++ Player::LoadFromDB, Player::SaveToDB, and RestMgr behavior.
  • Save logout time and whether the player logged out resting using the C++ conditions.
  • On login, apply offline rested XP using C++ rates/shape:
    • resting/tavern/city path uses the tavern/city offline rate.
    • wilderness path uses the wilderness offline rate.
    • use a CalcExtraPerSec equivalent based on next-level XP.
  • Set/clear rest flags from tavern/city area-trigger behavior where Rust currently lacks it.
  • Do not refill health, mana, rage, energy, or runic power from offline time; those are separate saved current resource fields.

Tests

Add focused positive/negative tests for:

  • logout while resting/tavern/city grants more rested XP than wilderness after the same offline interval.
  • wilderness logout grants the lower C++ offline rested XP rate.
  • rested XP caps/thresholds are respected like C++.
  • max-level or no-next-level-XP cases do not accrue invalid rested XP.
  • offline rested-XP login does not modify current health or current power.

Related

Done means C++-anchored implementation, focused tests, PROTOC=/home/cdmonio/.local/protoc/bin/protoc cargo check/test, and live validation of relog/rest-state behavior against the running server.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions