trading post
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
--
|
||||
-- Great Vault (Weekly Rewards) -- character-side persistence.
|
||||
--
|
||||
-- Backs WeeklyRewardsMgr (src/server/game/WeeklyRewards/WeeklyRewardsMgr.cpp) and
|
||||
-- the prepared statements CHAR_SEL/REP_WEEKLY_REWARD_ACTIVITY and
|
||||
-- CHAR_SEL/REP_WEEKLY_REWARD_STATE in CharacterDatabase.cpp. The tables were
|
||||
-- previously only present on live characters DBs; this recreates them from the
|
||||
-- live 12.0.7.68275 schema so a fresh realm can run the vault.
|
||||
--
|
||||
-- character_weekly_reward_activity stores one row per (character, period, row
|
||||
-- type): row type 0 = Dungeon (Mythic+ runs), 1 = Raid (boss kills), 2 = World
|
||||
-- (delves). `levels` is the comma-separated per-run levels (high->low) used to
|
||||
-- derive each slot's reward level. Only the current period's rows are adopted at
|
||||
-- load time; older periods are treated as stale.
|
||||
-- character_weekly_reward_state stores the last period a reward was claimed for,
|
||||
-- so a claim cannot be repeated within the same week.
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `character_weekly_reward_activity` (
|
||||
`ownerGuid` bigint unsigned NOT NULL,
|
||||
`period` int unsigned NOT NULL DEFAULT 0,
|
||||
`activityType` tinyint unsigned NOT NULL DEFAULT 0,
|
||||
`count` int unsigned NOT NULL DEFAULT 0,
|
||||
`bestLevel` int unsigned NOT NULL DEFAULT 0,
|
||||
`levels` text COLLATE utf8mb4_unicode_ci,
|
||||
PRIMARY KEY (`ownerGuid`, `period`, `activityType`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `character_weekly_reward_state` (
|
||||
`ownerGuid` bigint unsigned NOT NULL DEFAULT 0 COMMENT 'Character Global Unique Identifier',
|
||||
`claimedPeriod` int unsigned NOT NULL DEFAULT 0 COMMENT 'Last weekly period a reward was claimed',
|
||||
PRIMARY KEY (`ownerGuid`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Player System';
|
||||
@@ -954,12 +954,32 @@ void CriteriaHandler::UpdateCriteria(Criteria const* criteria, uint64 miscValue1
|
||||
if (referencePlayer)
|
||||
{
|
||||
if (int32 milestoneActivityID = sPerksProgramMgr->GetThresholdActivityForCriteriaTree(tree->ID))
|
||||
{
|
||||
if (!referencePlayer->HasPerksMilestone(milestoneActivityID))
|
||||
{
|
||||
referencePlayer->AddPerksMilestone(milestoneActivityID);
|
||||
if (referencePlayer->GetSession())
|
||||
{
|
||||
referencePlayer->GetSession()->SendPerksProgramActivityComplete(milestoneActivityID);
|
||||
// Threshold milestones pay a bonus on top of the regular activity tender.
|
||||
if (referencePlayer->ModifyPerksCurrency(sPerksProgramMgr->PERKS_TENDER_PER_ACTIVITY + sPerksProgramMgr->PERKS_TENDER_PER_MILESTONE))
|
||||
referencePlayer->GetSession()->SendPerksProgramCurrencyUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (int32 mainActivityID = sPerksProgramMgr->GetMainActivityForCriteriaTree(tree->ID))
|
||||
{
|
||||
if (!referencePlayer->HasPerksMilestone(mainActivityID))
|
||||
{
|
||||
referencePlayer->AddPerksMilestone(mainActivityID);
|
||||
if (referencePlayer->GetSession())
|
||||
{
|
||||
referencePlayer->GetSession()->SendPerksProgramActivityComplete(mainActivityID);
|
||||
if (referencePlayer->ModifyPerksCurrency(sPerksProgramMgr->PERKS_TENDER_PER_ACTIVITY))
|
||||
referencePlayer->GetSession()->SendPerksProgramCurrencyUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include "Random.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "TemporarySummon.h"
|
||||
#include "WeeklyRewardsMgr.h"
|
||||
#include "InstancePackets.h"
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
@@ -522,6 +523,11 @@ void ChallengeMode::Complete()
|
||||
}
|
||||
}
|
||||
|
||||
// Great Vault Dungeon row: one completion per finished run at the actual keystone level. Recorded here (once
|
||||
// per run), not per boss kill in InstanceScript, so a multi-boss dungeon still counts once - and only
|
||||
// keystone runs reach this path, so ordinary dungeons no longer unlock vault slots.
|
||||
sWeeklyRewardsMgr.RecordActivity(player, WeeklyRewards::ActivityType::Dungeon, record.Level);
|
||||
|
||||
// Achievement criteria. All three are keyed off the run that just finished; the run-scoped
|
||||
// ModifierTree nodes (MythicPlusKeystoneLevelEqualOrGreaterThan 247, MythicPlusCompletedInTime 248,
|
||||
// MythicPlusMapChallengeMode 249) read the still-live ChallengeMode off the player's map, so these
|
||||
|
||||
@@ -34070,7 +34070,11 @@ bool Player::ModifyPerksCurrency(int32 amount)
|
||||
|
||||
// Use the core currency system ? this updates character_currencies and sends SetCurrency to client
|
||||
if (amount > 0)
|
||||
{
|
||||
AddCurrency(CURRENCY_TRADERS_TENDER, static_cast<uint32>(amount));
|
||||
_perksTotalEarned += amount;
|
||||
_perksCurrencyDirty = true;
|
||||
}
|
||||
else
|
||||
RemoveCurrency(CURRENCY_TRADERS_TENDER, -amount);
|
||||
|
||||
|
||||
@@ -156,9 +156,9 @@ void WorldSession::HandlePerksProgramRequestPurchase(WorldPackets::PerksProgram:
|
||||
return;
|
||||
}
|
||||
|
||||
if (vendorItem->PacketData.Disabled)
|
||||
if (!sPerksProgramMgr->IsVendorItemPurchasable(packet.VendorItemID, player->GetPerksFrozenVendorItemID()))
|
||||
{
|
||||
TC_LOG_DEBUG("network", "HandlePerksProgramRequestPurchase: VendorItemID {} is disabled.", packet.VendorItemID);
|
||||
TC_LOG_DEBUG("network", "HandlePerksProgramRequestPurchase: VendorItemID {} is not purchasable (disabled, expired, or not in current rotation).", packet.VendorItemID);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -213,9 +213,9 @@ void WorldSession::HandlePerksProgramRequestCartCheckout(WorldPackets::PerksProg
|
||||
for (int32 vendorItemID : packet.VendorItemIDs)
|
||||
{
|
||||
PerksProgramVendorItemData const* vendorItem = sPerksProgramMgr->GetVendorItem(vendorItemID);
|
||||
if (!vendorItem || vendorItem->PacketData.Disabled)
|
||||
if (!vendorItem || !sPerksProgramMgr->IsVendorItemPurchasable(vendorItemID, player->GetPerksFrozenVendorItemID()))
|
||||
{
|
||||
TC_LOG_DEBUG("network", "HandlePerksProgramRequestCartCheckout: VendorItemID {} invalid or disabled.", vendorItemID);
|
||||
TC_LOG_DEBUG("network", "HandlePerksProgramRequestCartCheckout: VendorItemID {} invalid or not purchasable.", vendorItemID);
|
||||
return;
|
||||
}
|
||||
if (HasAlreadyPurchased(player, vendorItemID))
|
||||
@@ -275,9 +275,9 @@ void WorldSession::HandlePerksProgramSetFrozenVendorItem(WorldPackets::PerksProg
|
||||
if (packet.IsFreezing)
|
||||
{
|
||||
PerksProgramVendorItemData const* vendorItem = sPerksProgramMgr->GetVendorItem(packet.VendorItemID);
|
||||
if (!vendorItem)
|
||||
if (!vendorItem || !sPerksProgramMgr->IsVendorItemPurchasable(packet.VendorItemID, player->GetPerksFrozenVendorItemID()))
|
||||
{
|
||||
TC_LOG_DEBUG("network", "HandlePerksProgramSetFrozenVendorItem: VendorItemID {} not found.", packet.VendorItemID);
|
||||
TC_LOG_DEBUG("network", "HandlePerksProgramSetFrozenVendorItem: VendorItemID {} not found or not purchasable.", packet.VendorItemID);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -462,11 +462,13 @@ bool InstanceScript::SetBossState(uint32 id, EncounterState state)
|
||||
if (!player->IsLockedToDungeonEncounter(dungeonEncounter->ID))
|
||||
player->UpdateCriteria(CriteriaType::DefeatDungeonEncounterWhileElegibleForLoot, dungeonEncounter->ID);
|
||||
|
||||
// Great Vault: credit the kill toward this week's raid or dungeon activity row. The
|
||||
// instance difficulty stands in for the reward tier (raid difficulty / keystone level).
|
||||
sWeeklyRewardsMgr.RecordActivity(player,
|
||||
isRaidEncounter ? WeeklyRewards::ActivityType::Raid : WeeklyRewards::ActivityType::Dungeon,
|
||||
uint32(instance->GetDifficultyID()));
|
||||
// Great Vault: raid bosses credit the raid row per kill (the difficulty stands in for the
|
||||
// reward tier). Dungeon/Mythic+ is NOT credited here - a normal dungeon clear is not a
|
||||
// vault run and a keystone run must count once per completed run at its keystone level,
|
||||
// which ChallengeMode::Complete records authoritatively.
|
||||
if (isRaidEncounter)
|
||||
sWeeklyRewardsMgr.RecordActivity(player, WeeklyRewards::ActivityType::Raid,
|
||||
uint32(instance->GetDifficultyID()));
|
||||
});
|
||||
|
||||
DoUpdateCriteria(CriteriaType::DefeatDungeonEncounter, dungeonEncounter->ID);
|
||||
|
||||
@@ -135,8 +135,16 @@ std::vector<PerksProgramVendorItemData const*> PerksProgramMgr::GetCurrentRotati
|
||||
{
|
||||
if (now >= entry.MonthStart && now < entry.MonthEnd)
|
||||
{
|
||||
if (PerksProgramVendorItemData const* item = GetVendorItem(entry.VendorItemID))
|
||||
items.push_back(item);
|
||||
PerksProgramVendorItemData const* item = GetVendorItem(entry.VendorItemID);
|
||||
if (!item)
|
||||
continue;
|
||||
|
||||
// Hide items whose own availability window has passed unless they never expire.
|
||||
time_t availableUntil = item->PacketData.AvailableUntil;
|
||||
if (!item->PacketData.DoesNotExpire && availableUntil != 0 && now >= uint32(availableUntil))
|
||||
continue;
|
||||
|
||||
items.push_back(item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,28 +308,40 @@ PerksProgramActivityLists PerksProgramMgr::GetCurrentMonthActivityLists() const
|
||||
void PerksProgramMgr::BuildCriteriaTreeMap()
|
||||
{
|
||||
_criteriaTreeToThresholdActivity.clear();
|
||||
_criteriaTreeToMainActivity.clear();
|
||||
|
||||
uint32 now = uint32(GameTime::GetGameTime());
|
||||
|
||||
std::unordered_set<uint32> mainIntervals;
|
||||
std::unordered_set<uint32> thresholdIntervals;
|
||||
for (ActivityIntervalEntry const& entry : _activityIntervals)
|
||||
if (entry.IsThreshold && now >= entry.MonthStart && now < entry.MonthEnd)
|
||||
thresholdIntervals.insert(entry.IntervalID);
|
||||
{
|
||||
if (now < entry.MonthStart || now >= entry.MonthEnd)
|
||||
continue;
|
||||
|
||||
if (thresholdIntervals.empty())
|
||||
if (entry.IsThreshold)
|
||||
thresholdIntervals.insert(entry.IntervalID);
|
||||
else
|
||||
mainIntervals.insert(entry.IntervalID);
|
||||
}
|
||||
|
||||
if (mainIntervals.empty() && thresholdIntervals.empty())
|
||||
return;
|
||||
|
||||
for (PerksActivityXIntervalEntry const* xiv : sPerksActivityXIntervalStore)
|
||||
{
|
||||
if (!thresholdIntervals.count(xiv->IntervalID))
|
||||
PerksActivityEntry const* activity = sPerksActivityStore.LookupEntry(uint32(xiv->PerksActivityID));
|
||||
if (!activity || activity->CriteriaTreeID == 0)
|
||||
continue;
|
||||
|
||||
if (PerksActivityEntry const* activity = sPerksActivityStore.LookupEntry(uint32(xiv->PerksActivityID)))
|
||||
if (activity->CriteriaTreeID != 0)
|
||||
_criteriaTreeToThresholdActivity[uint32(activity->CriteriaTreeID)] = xiv->PerksActivityID;
|
||||
if (thresholdIntervals.count(xiv->IntervalID))
|
||||
_criteriaTreeToThresholdActivity[uint32(activity->CriteriaTreeID)] = xiv->PerksActivityID;
|
||||
else if (mainIntervals.count(xiv->IntervalID))
|
||||
_criteriaTreeToMainActivity[uint32(activity->CriteriaTreeID)] = xiv->PerksActivityID;
|
||||
}
|
||||
|
||||
TC_LOG_INFO("server.loading", ">> Built perks criteria tree map: {} threshold activities mapped.", uint32(_criteriaTreeToThresholdActivity.size()));
|
||||
TC_LOG_INFO("server.loading", ">> Built perks criteria tree map: {} main + {} threshold activities mapped.",
|
||||
uint32(_criteriaTreeToMainActivity.size()), uint32(_criteriaTreeToThresholdActivity.size()));
|
||||
}
|
||||
|
||||
int32 PerksProgramMgr::GetThresholdActivityForCriteriaTree(uint32 criteriaTreeID) const
|
||||
@@ -329,3 +349,33 @@ int32 PerksProgramMgr::GetThresholdActivityForCriteriaTree(uint32 criteriaTreeID
|
||||
auto itr = _criteriaTreeToThresholdActivity.find(criteriaTreeID);
|
||||
return itr != _criteriaTreeToThresholdActivity.end() ? itr->second : 0;
|
||||
}
|
||||
|
||||
int32 PerksProgramMgr::GetMainActivityForCriteriaTree(uint32 criteriaTreeID) const
|
||||
{
|
||||
auto itr = _criteriaTreeToMainActivity.find(criteriaTreeID);
|
||||
return itr != _criteriaTreeToMainActivity.end() ? itr->second : 0;
|
||||
}
|
||||
|
||||
bool PerksProgramMgr::IsVendorItemPurchasable(int32 vendorItemID, int32 frozenVendorItemID) const
|
||||
{
|
||||
PerksProgramVendorItemData const* item = GetVendorItem(vendorItemID);
|
||||
if (!item || item->PacketData.Disabled)
|
||||
return false;
|
||||
|
||||
// Respect the item's own availability window unless flagged as permanent.
|
||||
time_t availableUntil = item->PacketData.AvailableUntil;
|
||||
if (!item->PacketData.DoesNotExpire && availableUntil != 0 && uint32(GameTime::GetGameTime()) >= uint32(availableUntil))
|
||||
return false;
|
||||
|
||||
// Frozen items stay purchasable for the player who pinned them even after they
|
||||
// rotate out; everything else must be part of the active monthly rotation.
|
||||
if (vendorItemID == frozenVendorItemID)
|
||||
return true;
|
||||
|
||||
uint32 now = uint32(GameTime::GetGameTime());
|
||||
for (PerksProgramRotationEntry const& entry : _rotationEntries)
|
||||
if (now >= entry.MonthStart && now < entry.MonthEnd && entry.VendorItemID == vendorItemID)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -57,6 +57,12 @@ public:
|
||||
|
||||
static PerksProgramMgr* Instance();
|
||||
|
||||
// Trader's Tender awarded per completed perks activity and per threshold milestone.
|
||||
// The retail reward amounts are not exposed in any DB2/hotfix table on this build,
|
||||
// so these are tunable constants until capture data provides exact values.
|
||||
static constexpr int32 PERKS_TENDER_PER_ACTIVITY = 100;
|
||||
static constexpr int32 PERKS_TENDER_PER_MILESTONE = 250;
|
||||
|
||||
void LoadVendorItems();
|
||||
void LoadMonthlyRotation();
|
||||
void LoadActivityIntervals();
|
||||
@@ -72,6 +78,8 @@ public:
|
||||
std::vector<PerksProgramVendorItemData const*> GetCurrentRotationItems() const;
|
||||
PerksProgramActivityLists GetCurrentMonthActivityLists() const;
|
||||
int32 GetThresholdActivityForCriteriaTree(uint32 criteriaTreeID) const;
|
||||
int32 GetMainActivityForCriteriaTree(uint32 criteriaTreeID) const;
|
||||
bool IsVendorItemPurchasable(int32 vendorItemID, int32 frozenVendorItemID = 0) const;
|
||||
|
||||
uint32 GetCurrentMonthStart() const { return _currentMonthStart; }
|
||||
uint32 GetCurrentMonthEnd() const { return _currentMonthEnd; }
|
||||
@@ -91,6 +99,7 @@ private:
|
||||
std::vector<PerksProgramRotationEntry> _rotationEntries;
|
||||
std::vector<ActivityIntervalEntry> _activityIntervals;
|
||||
std::unordered_map<uint32, int32> _criteriaTreeToThresholdActivity;
|
||||
std::unordered_map<uint32, int32> _criteriaTreeToMainActivity;
|
||||
uint32 _currentMonthStart = 0;
|
||||
uint32 _currentMonthEnd = 0;
|
||||
std::vector<uint32> _directMainActivities;
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include "DB2Stores.h"
|
||||
#include "DB2Structure.h"
|
||||
#include "DBCEnums.h"
|
||||
#include "GameTime.h"
|
||||
#include "Item.h"
|
||||
#include "ItemBonusMgr.h"
|
||||
#include "ItemDefines.h"
|
||||
@@ -37,6 +36,7 @@
|
||||
#include "StringConvert.h"
|
||||
#include "Timer.h"
|
||||
#include "Util.h"
|
||||
#include "World.h"
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
|
||||
@@ -144,10 +144,13 @@ WeeklyRewardsMgr& WeeklyRewardsMgr::Instance()
|
||||
|
||||
uint32 WeeklyRewardsMgr::GetCurrentPeriod()
|
||||
{
|
||||
// Week index since the unix epoch. Monotonic and identical for every character on the realm, so all vaults
|
||||
// roll over together (the real client tracks weeks since Cfg_RegionsEntry::ChallengeOrigin; the absolute base
|
||||
// does not matter here, only that the index advances once per week).
|
||||
return uint32(GameTime::GetGameTime() / (7 * DAY));
|
||||
// Anchor the period on the realm's weekly reset boundary, exactly like ChallengeModeMgr::GetCurrentWeekIndex
|
||||
// (minus the affix offset). A raw epoch week would flip on Thursday 00:00 UTC and split a realm week across two
|
||||
// periods, so a player raiding on Monday and again after reset would have the second reset mid-week instead of
|
||||
// at the reset. Deriving it from the reset time keeps every weekly system on the same boundary and makes the
|
||||
// index advance exactly once per reset for every character on the realm.
|
||||
int64 const weekStart = int64(sWorld->GetNextWeeklyQuestsResetTime()) - int64(WEEK);
|
||||
return uint32(std::max<int64>(weekStart / int64(WEEK), 0));
|
||||
}
|
||||
|
||||
void WeeklyRewardsMgr::RollPeriod(WeeklyRewards::CharacterVault& vault)
|
||||
|
||||
@@ -3374,6 +3374,15 @@ static time_t GetNextWeeklyResetTime(time_t t)
|
||||
|
||||
void World::ResetWeeklyQuests()
|
||||
{
|
||||
// Advance the weekly boundary FIRST. Everything below (player period roll, Mythic+ rollover, delve reset, ...)
|
||||
// is keyed on sWorld->GetNextWeeklyQuestsResetTime(); if we leave the old (just-passed) value in place the
|
||||
// rollover captures the week that is ending instead of starting the new one.
|
||||
time_t const now = GameTime::GetGameTime();
|
||||
time_t const next = GetNextWeeklyResetTime(now);
|
||||
ASSERT(now < next);
|
||||
m_NextWeeklyQuestReset = next;
|
||||
SetPersistentWorldVariable(NextWeeklyQuestResetTimeVarId, uint64(next));
|
||||
|
||||
// reset all saved quest status
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_RESET_CHARACTER_QUESTSTATUS_WEEKLY);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
@@ -3411,14 +3420,6 @@ void World::ResetWeeklyQuests()
|
||||
// Update faction balance
|
||||
UpdateWarModeRewardValues();
|
||||
|
||||
// store next reset time
|
||||
time_t now = GameTime::GetGameTime();
|
||||
time_t next = GetNextWeeklyResetTime(now);
|
||||
ASSERT(now < next);
|
||||
|
||||
m_NextWeeklyQuestReset = next;
|
||||
SetPersistentWorldVariable(NextWeeklyQuestResetTimeVarId, uint64(next));
|
||||
|
||||
TC_LOG_INFO("misc", "Weekly quests for all characters have been reset.");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user