omnium updates
This commit is contained in:
@@ -17,11 +17,15 @@
|
||||
|
||||
#include "OmniumFolioMgr.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "DB2Stores.h"
|
||||
#include "DBCEnums.h"
|
||||
#include "Log.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "ObjectGuid.h"
|
||||
#include "Player.h"
|
||||
#include "SpellInfo.h"
|
||||
#include "SpellMgr.h"
|
||||
#include <algorithm>
|
||||
|
||||
// The five weekly-unlock achievements that each source +1 "Mote of Omnial Inquiry"
|
||||
// (TraitCurrency 4230) via DB2 TraitCurrencySource. Kept here for reference; the
|
||||
@@ -30,6 +34,41 @@
|
||||
namespace
|
||||
{
|
||||
[[maybe_unused]] constexpr uint32 MoteAchievements[5] = { 62606, 62607, 62608, 62609, 62610 };
|
||||
|
||||
// The schedule row must name a trait tree/system the client DB2 actually contains, and the
|
||||
// tree must belong to that system: the minted config is recognised by TraitSystemId
|
||||
// (HasFolioConfig / IsFolioTraitSystem) while the unlock spell creates it from its own
|
||||
// effect misc value (TraitTreeId).
|
||||
bool IsScheduleValid(int32 traitTreeId, int32 traitSystemId, uint32 unlockSpellId)
|
||||
{
|
||||
if (!traitTreeId || !traitSystemId || !unlockSpellId)
|
||||
return false;
|
||||
|
||||
TraitTreeEntry const* traitTree = sTraitTreeStore.LookupEntry(uint32(traitTreeId));
|
||||
if (!traitTree || !sTraitSystemStore.LookupEntry(uint32(traitSystemId))
|
||||
|| traitTree->TraitSystemID != uint32(traitSystemId))
|
||||
return false;
|
||||
|
||||
// The unlock spell must actually create this tree's config. Spell::EffectCreateTraitTreeConfig
|
||||
// calls AssertEntry(effectInfo->MiscValue), so a spell whose effect misc value is not a
|
||||
// valid TraitTree aborts the server rather than merely failing to mint.
|
||||
SpellInfo const* unlockSpell = sSpellMgr->GetSpellInfo(unlockSpellId, DIFFICULTY_NONE);
|
||||
if (!unlockSpell)
|
||||
return false;
|
||||
|
||||
return std::ranges::any_of(unlockSpell->GetEffects(), [traitTreeId](SpellEffectInfo const& effect)
|
||||
{
|
||||
return effect.Effect == SPELL_EFFECT_CREATE_TRAIT_TREE_CONFIG && effect.MiscValue == traitTreeId;
|
||||
});
|
||||
}
|
||||
|
||||
void LogInvalidSchedule(uint32 seasonId, int32 traitTreeId, int32 traitSystemId, uint32 unlockSpellId)
|
||||
{
|
||||
TC_LOG_ERROR("server.loading", ">> Omnium Folio: season {} has an invalid schedule (trait tree {}, trait system {}, "
|
||||
"unlock spell {}); system idle until the row is fixed. The row must name a tree and system that exist in "
|
||||
"client DB2, the tree must belong to that system, and the unlock spell must create that tree's config.",
|
||||
seasonId, traitTreeId, traitSystemId, unlockSpellId);
|
||||
}
|
||||
}
|
||||
|
||||
OmniumFolioMgr* OmniumFolioMgr::instance()
|
||||
@@ -41,11 +80,12 @@ OmniumFolioMgr* OmniumFolioMgr::instance()
|
||||
bool OmniumFolioMgr::ReadSeasonSchedule()
|
||||
{
|
||||
// Optional per-fork schedule: a single row keyed by descending SeasonId, newest row wins.
|
||||
// Absent table/row leaves the season/flag at zero/false, restores the folio identity
|
||||
// columns to their DB2-anchored defaults and clears _schedulePresent, so the shared realm
|
||||
// never carries stale state forward -- and never polls a table it does not have (that
|
||||
// would put one "table doesn't exist" error per poll in the log).
|
||||
_schedulePresent = false;
|
||||
// Every call resets the season/flag to zero/false and restores the folio identity columns
|
||||
// to their DB2-anchored defaults, so the shared realm never carries stale state forward
|
||||
// when the row disappears. _schedulePollActive is sticky: once the table has been read,
|
||||
// Update() keeps polling so a re-added row (or a transient query failure) recovers without
|
||||
// a restart. A table that was absent at startup stays unpolled, which keeps one
|
||||
// "table doesn't exist" error per poll out of the log.
|
||||
_seasonId = 0;
|
||||
_enabled = false;
|
||||
_traitTreeId = TRAIT_TREE_ID;
|
||||
@@ -65,7 +105,10 @@ bool OmniumFolioMgr::ReadSeasonSchedule()
|
||||
_traitTreeId = fields[2].GetInt32();
|
||||
_traitSystemId = fields[3].GetInt32();
|
||||
_unlockSpellId = fields[4].GetUInt32();
|
||||
_schedulePresent = true;
|
||||
_schedulePollActive = true;
|
||||
|
||||
// Parse only. Validation needs client DB2 and is done by the caller (LoadFromDB /
|
||||
// Update), so a bad row does not log once per 60s poll.
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -84,6 +127,17 @@ void OmniumFolioMgr::LoadFromDB()
|
||||
return;
|
||||
}
|
||||
|
||||
// A row that names the wrong tree/system would mint a config this manager can never
|
||||
// recognise: HasFolioConfig() keys off TraitSystemId while the unlock spell creates the
|
||||
// config from its own effect misc value (TraitTreeId). Stay idle (but keep polling) until
|
||||
// the row is fixed.
|
||||
if (!IsScheduleValid(_traitTreeId, _traitSystemId, _unlockSpellId))
|
||||
{
|
||||
LogInvalidSchedule(_seasonId, _traitTreeId, _traitSystemId, _unlockSpellId);
|
||||
_enabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
TC_LOG_INFO("server.loading", ">> Omnium Folio: season {} loaded (enabled={}); trait tree {}, trait system {}, unlock spell {}.",
|
||||
_seasonId, uint32(_enabled), _traitTreeId, _traitSystemId, _unlockSpellId);
|
||||
}
|
||||
@@ -91,9 +145,10 @@ void OmniumFolioMgr::LoadFromDB()
|
||||
void OmniumFolioMgr::Update(uint32 diff)
|
||||
{
|
||||
// Poll even while disabled so an operator flipping Enabled (or bumping SeasonId to open a
|
||||
// new season) takes effect without a server restart -- but only once the schedule table is
|
||||
// known to exist. Creating it later requires a restart, same as any other core table.
|
||||
if (!_schedulePresent)
|
||||
// new season) takes effect without a server restart -- but only once the schedule table has
|
||||
// been read at least once. Creating it later requires a restart, same as any other core
|
||||
// table; once it has been seen, polling is sticky so a deleted/re-added row recovers too.
|
||||
if (!_schedulePollActive)
|
||||
return;
|
||||
|
||||
_seasonPollTimer += diff;
|
||||
@@ -108,6 +163,12 @@ void OmniumFolioMgr::Update(uint32 diff)
|
||||
|
||||
ReadSeasonSchedule();
|
||||
|
||||
// Re-validate after every poll. A row edited into an invalid state disables the system
|
||||
// without a restart, and stays disabled (but keeps polling) until it is fixed.
|
||||
bool const scheduleValid = IsScheduleValid(_traitTreeId, _traitSystemId, _unlockSpellId);
|
||||
if (!scheduleValid)
|
||||
_enabled = false;
|
||||
|
||||
if (_seasonId == previousSeasonId && _enabled == previousEnabled
|
||||
&& _traitSystemId == previousTraitSystemId && _unlockSpellId == previousUnlockSpellId)
|
||||
return;
|
||||
@@ -116,6 +177,12 @@ void OmniumFolioMgr::Update(uint32 diff)
|
||||
previousSeasonId, _seasonId, uint32(previousEnabled), uint32(_enabled),
|
||||
previousTraitSystemId, _traitSystemId, previousUnlockSpellId, _unlockSpellId);
|
||||
|
||||
if (!scheduleValid)
|
||||
{
|
||||
LogInvalidSchedule(_seasonId, _traitTreeId, _traitSystemId, _unlockSpellId);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_enabled)
|
||||
return;
|
||||
|
||||
@@ -180,7 +247,8 @@ void OmniumFolioMgr::EnsureFolioForPlayer(Player* player)
|
||||
// * Node runes apply through Player::ApplyTraitConfig -> LearnSpell on each
|
||||
// node's TraitDefinition.SpellID (already implemented).
|
||||
// * Motes (TraitCurrency 4230) are computed live from TraitCurrencySource
|
||||
// (achievements 62606..62610 + level-1 base) inside TraitMgr -- no store.
|
||||
// (one per achievement 62606..62610; the level-1 row is Amount 0) inside
|
||||
// TraitMgr -- no store.
|
||||
//
|
||||
// This coordinator only decides WHETHER to mint: season active + player eligible
|
||||
// + no existing folio config. Everything it calls already exists in core.
|
||||
@@ -213,7 +281,25 @@ void OmniumFolioMgr::EnsureFolioForPlayer(Player* player)
|
||||
// No folio config yet -> mint it via stock trait code. The effect itself also
|
||||
// guards against duplicating a config for this TraitSystemId, so this stays
|
||||
// idempotent even if bookkeeping and update-fields ever disagree.
|
||||
player->CastSpell(player, _unlockSpellId, true);
|
||||
if (!_unlockSpellId)
|
||||
{
|
||||
TC_LOG_ERROR("entities.player", "Omnium Folio: season {} has no unlock spell; cannot mint the folio config for {}.",
|
||||
_seasonId, player->GetGUID().ToString());
|
||||
return;
|
||||
}
|
||||
|
||||
uint32 const castResult = uint32(player->CastSpell(player, _unlockSpellId, true));
|
||||
|
||||
// Only mark the season as minted once the config really exists. A failed cast, or the
|
||||
// "traits not loaded yet" early-out inside EffectCreateTraitTreeConfig, would otherwise
|
||||
// record a successful mint for a character that still has no folio.
|
||||
if (!HasFolioConfig(player))
|
||||
{
|
||||
TC_LOG_ERROR("entities.player", "Omnium Folio: unlock spell {} (cast result {}) did not create the trait config "
|
||||
"(system {}) for {}; season {} bookkeeping not updated.",
|
||||
_unlockSpellId, castResult, _traitSystemId, player->GetGUID().ToString(), _seasonId);
|
||||
return;
|
||||
}
|
||||
|
||||
SaveSeasonBookkeeping(player->GetGUID(), _seasonId);
|
||||
}
|
||||
@@ -233,8 +319,17 @@ void OmniumFolioMgr::ResetForNewSeason(Player* player)
|
||||
// has none) and advance the season bookkeeping so the new season's achievement
|
||||
// motes become spendable on the existing ledger. This is realm-safe and
|
||||
// non-lossy; a confirmed wipe can be layered on later behind the same seam.
|
||||
if (!HasFolioConfig(player))
|
||||
if (!HasFolioConfig(player) && _unlockSpellId)
|
||||
player->CastSpell(player, _unlockSpellId, true);
|
||||
|
||||
// Same rule as EnsureFolioForPlayer: never advance the season counter for a character
|
||||
// that still has no folio config (for example when the unlock spell could not be cast).
|
||||
if (!HasFolioConfig(player))
|
||||
{
|
||||
TC_LOG_ERROR("entities.player", "Omnium Folio: could not provision season {} for {} (trait system {} missing); "
|
||||
"bookkeeping not updated.", _seasonId, player->GetGUID().ToString(), _traitSystemId);
|
||||
return;
|
||||
}
|
||||
|
||||
SaveSeasonBookkeeping(player->GetGUID(), _seasonId);
|
||||
}
|
||||
|
||||
@@ -28,14 +28,15 @@ class ObjectGuid;
|
||||
// Omnium Folio -- Midnight (patch 12.0.7 "Revelations") Season 1 seasonal
|
||||
// "rune ledger" power system. Characters are measurably weaker without it.
|
||||
//
|
||||
// Evidence anchors (client build 12.0.7.68887, wago.tools DB2 + fork source):
|
||||
// Evidence anchors (client build 12.1.5.70077 on disk; the same ids are present in
|
||||
// 12.0.7.68887, wago.tools DB2 + fork source):
|
||||
// * TraitTree 1186 / TraitSystem 48 (WidgetSetID 2200) = the folio rune tree.
|
||||
// 5 nodes = 5 weekly rows; node 110273 is a no-choice (type 0) row.
|
||||
// * TraitCurrency 4230 ("Mote of Omnial Inquiry", Type 2 = TraitSourced) =
|
||||
// the ledger currency. It is COMPUTED, never stored: TraitMgr derives
|
||||
// the balance live from TraitCurrencySource rows 37084/37158..37162:
|
||||
// PlayerLevel-1 base + 1 mote per completed achievement 62606..62610
|
||||
// (the five weekly-unlock gates).
|
||||
// the balance live from TraitCurrencySource rows 37084/37158..37162.
|
||||
// Row 37084 (PlayerLevel 1) has Amount 0, so all motes come from the
|
||||
// five weekly achievements 62606..62610 (1 each), not from the level.
|
||||
// * Spell 1279717 carries SPELL_EFFECT_CREATE_TRAIT_TREE_CONFIG (303) with
|
||||
// MiscValue_0 = 1186, i.e. casting it mints the generic TraitConfig
|
||||
// (Spell::EffectCreateTraitTreeConfig -> Player::CreateTraitConfig).
|
||||
@@ -50,7 +51,8 @@ class ObjectGuid;
|
||||
// already implemented for TraitConfigType::Generic). This manager is therefore
|
||||
// a thin coordinator / seam covering only what the stock trait system does not:
|
||||
// (1) per-character eligibility + config-ensure on login,
|
||||
// (2) the seasonal-reset hook (wipe & re-mint the generic config on rollover).
|
||||
// (2) the seasonal-reset hook (guarantee the generic config and advance the
|
||||
// per-character season bookkeeping on rollover; non-destructive today).
|
||||
// The heavy lifting (power grant, persistence, opcodes) stays in TraitMgr.
|
||||
//
|
||||
// Realm-safety: LoadFromDB() tolerates an absent seasonal table (no-op), so this
|
||||
@@ -88,17 +90,18 @@ public:
|
||||
void LoadFromDB();
|
||||
|
||||
// Seasonal-reset tick. Re-reads the schedule row at SEASON_POLL_INTERVAL and, when the
|
||||
// season or the enabled flag changes, re-provisions every online character immediately --
|
||||
// otherwise a rollover would only take effect on the next relog.
|
||||
// season, enabled flag, trait system or unlock spell changes, re-provisions every online
|
||||
// character immediately -- otherwise a rollover would only take effect on the next relog.
|
||||
// An invalid row disables the system without a restart and is re-checked on every poll.
|
||||
void Update(uint32 diff);
|
||||
|
||||
// Player load-path seam (called from Player::LoadFromDB after traits apply).
|
||||
void OnPlayerLogin(Player* player);
|
||||
|
||||
// Power-grant seam. Delegates to the trait system: when the player is eligible (unlock
|
||||
// achievement 62606 completed) and has no folio config yet, casting the schedule row's
|
||||
// UnlockSpellId mints the generic config. Idempotent -- safe to call on every schedule
|
||||
// change.
|
||||
// achievement 62606 or quest 96410 rewarded) and has no folio config yet, casting the
|
||||
// schedule row's UnlockSpellId mints the generic config. Idempotent -- safe to call on
|
||||
// every schedule change.
|
||||
void EnsureFolioForPlayer(Player* player);
|
||||
|
||||
// Seasonal-reset hook: guarantees a generic folio config exists and advances the
|
||||
@@ -131,15 +134,19 @@ private:
|
||||
static void SaveSeasonBookkeeping(ObjectGuid guid, uint32 seasonId);
|
||||
|
||||
// Reads omnium_folio_season into _seasonId / _enabled and the three schedule-driven
|
||||
// folio identity columns. Returns false when no row (or no table) exists, in which
|
||||
// case every member is reset to its zero/false/default state.
|
||||
// folio identity columns. Returns false when no row (or no table) exists, in which case
|
||||
// every member is reset to its zero/false/default state. A successful read arms the
|
||||
// sticky Update() poll flag.
|
||||
bool ReadSeasonSchedule();
|
||||
|
||||
// How often Update() re-reads the schedule row (1 minute: a single-row query).
|
||||
static constexpr uint32 SEASON_POLL_INTERVAL = 60 * IN_MILLISECONDS;
|
||||
|
||||
bool _enabled = false;
|
||||
bool _schedulePresent = false;
|
||||
// Sticky: set once the optional schedule table has been read successfully. While set,
|
||||
// Update() keeps polling so a deleted/re-added row (or a transient query failure) recovers
|
||||
// without a restart. A table absent at startup leaves it false -> no per-poll query errors.
|
||||
bool _schedulePollActive = false;
|
||||
uint32 _seasonId = 0;
|
||||
uint32 _seasonPollTimer = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user