aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Entities
diff options
context:
space:
mode:
authorr4dish <ovitnez@gmail.com>2024-06-19 18:38:19 +0300
committerShauren <shauren.trinity@gmail.com>2024-06-27 14:49:40 +0200
commit0327f16d110baa4479c73b4fcece6c99b2f89a8b (patch)
treef0e2d6bdaf24522153db0430c3e4480dfe81bcc5 /src/server/game/Entities
parentc6906948f7352eee52174434c4626ecf98eb8eab (diff)
Core/Misc: Move instance enter times handling from Player to WorldSession.
Diffstat (limited to 'src/server/game/Entities')
-rw-r--r--src/server/game/Entities/Player/Player.cpp71
-rw-r--r--src/server/game/Entities/Player/Player.h77
2 files changed, 35 insertions, 113 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 7884b183f4a..0849cd1952c 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -17255,9 +17255,6 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol
_LoadBoundInstances(holder.GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_BOUND_INSTANCES));
- _LoadInstanceTimeRestrictions(holder.GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_INSTANCE_LOCK_TIMES));
- UpdateInstanceEnterTimes();
-
_LoadBGData(holder.GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_BG_DATA));
GetSession()->SetPlayer(this);
@@ -19105,41 +19102,6 @@ bool Player::CheckInstanceValidity(bool /*isLogin*/)
return true;
}
-bool Player::UpdateAndCheckInstanceCount(uint32 instanceId)
-{
- UpdateInstanceEnterTimes();
-
- if (_instanceResetTimes.size() < sWorld->getIntConfig(CONFIG_MAX_INSTANCES_PER_HOUR))
- return true;
-
- if (instanceId == 0)
- return false;
-
- return _instanceResetTimes.find(instanceId) != _instanceResetTimes.end();
-}
-
-void Player::AddInstanceEnterTime(uint32 instanceId, time_t enterTime)
-{
- if (_instanceResetTimes.find(instanceId) == _instanceResetTimes.end())
- _instanceResetTimes.insert(InstanceTimeMap::value_type(instanceId, enterTime + HOUR));
-}
-
-void Player::UpdateInstanceEnterTimes()
-{
- if (_instanceResetTimes.empty())
- return;
-
- time_t now = GameTime::GetGameTime();
-
- for (InstanceTimeMap::iterator itr = _instanceResetTimes.begin(); itr != _instanceResetTimes.end();)
- {
- if (itr->second < now)
- itr = _instanceResetTimes.erase(itr);
- else
- ++itr;
- }
-}
-
bool Player::_LoadHomeBind(PreparedQueryResult result)
{
PlayerInfo const* info = sObjectMgr->GetPlayerInfo(GetRace(), GetClass());
@@ -19518,7 +19480,7 @@ void Player::SaveToDB(CharacterDatabaseTransaction trans, bool create /* = false
_SaveEquipmentSets(trans);
GetSession()->SaveTutorialsData(trans); // changed only while character in game
_SaveGlyphs(trans);
- _SaveInstanceTimeRestrictions(trans);
+ GetSession()->SaveInstanceTimeRestrictions(trans);
// check if stats should only be saved on logout
// save stats can be out of transaction
@@ -26443,18 +26405,6 @@ float Player::GetAverageItemLevel() const
return ((float)sum) / count;
}
-void Player::_LoadInstanceTimeRestrictions(PreparedQueryResult result)
-{
- if (!result)
- return;
-
- do
- {
- Field* fields = result->Fetch();
- _instanceResetTimes.insert(InstanceTimeMap::value_type(fields[0].GetUInt32(), fields[1].GetUInt64()));
- } while (result->NextRow());
-}
-
void Player::_LoadPetStable(uint8 petStableSlots, PreparedQueryResult result)
{
if (!petStableSlots && !result)
@@ -26504,25 +26454,6 @@ void Player::_LoadPetStable(uint8 petStableSlots, PreparedQueryResult result)
}
}
-void Player::_SaveInstanceTimeRestrictions(CharacterDatabaseTransaction trans)
-{
- if (_instanceResetTimes.empty())
- return;
-
- CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ACCOUNT_INSTANCE_LOCK_TIMES);
- stmt->setUInt32(0, GetSession()->GetAccountId());
- trans->Append(stmt);
-
- for (InstanceTimeMap::const_iterator itr = _instanceResetTimes.begin(); itr != _instanceResetTimes.end(); ++itr)
- {
- stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ACCOUNT_INSTANCE_LOCK_TIMES);
- stmt->setUInt32(0, GetSession()->GetAccountId());
- stmt->setUInt32(1, itr->first);
- stmt->setUInt64(2, itr->second);
- trans->Append(stmt);
- }
-}
-
bool Player::IsInWhisperWhiteList(ObjectGuid guid)
{
for (GuidList::const_iterator itr = WhisperList.begin(); itr != WhisperList.end(); ++itr)
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index ada2bb98d7c..8b8ebde8fe9 100644
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -155,8 +155,6 @@ typedef std::unordered_map<uint32, PlayerTalent*> PlayerTalentMap;
typedef std::unordered_map<uint32, PlayerSpell> PlayerSpellMap;
typedef std::unordered_set<SpellModifier*> SpellModContainer;
-typedef std::unordered_map<uint32 /*instanceId*/, time_t/*releaseTime*/> InstanceTimeMap;
-
enum ActionButtonUpdateState
{
ACTIONBUTTON_UNCHANGED = 0,
@@ -705,41 +703,40 @@ enum PlayedTimeIndex
// used at player loading query list preparing, and later result selection
enum PlayerLoginQueryIndex
{
- PLAYER_LOGIN_QUERY_LOAD_FROM = 0,
- PLAYER_LOGIN_QUERY_LOAD_GROUP = 1,
- PLAYER_LOGIN_QUERY_LOAD_BOUND_INSTANCES = 2,
- PLAYER_LOGIN_QUERY_LOAD_AURAS = 3,
- PLAYER_LOGIN_QUERY_LOAD_SPELLS = 4,
- PLAYER_LOGIN_QUERY_LOAD_QUEST_STATUS = 5,
- PLAYER_LOGIN_QUERY_LOAD_DAILY_QUEST_STATUS = 6,
- PLAYER_LOGIN_QUERY_LOAD_REPUTATION = 7,
- PLAYER_LOGIN_QUERY_LOAD_INVENTORY = 8,
- PLAYER_LOGIN_QUERY_LOAD_ACTIONS = 9,
- PLAYER_LOGIN_QUERY_LOAD_MAILS = 10,
- PLAYER_LOGIN_QUERY_LOAD_MAIL_ITEMS = 11,
- PLAYER_LOGIN_QUERY_LOAD_SOCIAL_LIST = 12,
- PLAYER_LOGIN_QUERY_LOAD_HOME_BIND = 13,
- PLAYER_LOGIN_QUERY_LOAD_SPELL_COOLDOWNS = 14,
- PLAYER_LOGIN_QUERY_LOAD_DECLINED_NAMES = 15,
- PLAYER_LOGIN_QUERY_LOAD_GUILD = 16,
- PLAYER_LOGIN_QUERY_LOAD_ARENA_INFO = 17,
- PLAYER_LOGIN_QUERY_LOAD_ACHIEVEMENTS = 18,
- PLAYER_LOGIN_QUERY_LOAD_CRITERIA_PROGRESS = 19,
- PLAYER_LOGIN_QUERY_LOAD_EQUIPMENT_SETS = 20,
- PLAYER_LOGIN_QUERY_LOAD_BG_DATA = 21,
- PLAYER_LOGIN_QUERY_LOAD_GLYPHS = 22,
- PLAYER_LOGIN_QUERY_LOAD_TALENTS = 23,
- PLAYER_LOGIN_QUERY_LOAD_ACCOUNT_DATA = 24,
- PLAYER_LOGIN_QUERY_LOAD_SKILLS = 25,
- PLAYER_LOGIN_QUERY_LOAD_WEEKLY_QUEST_STATUS = 26,
- PLAYER_LOGIN_QUERY_LOAD_RANDOM_BG = 27,
- PLAYER_LOGIN_QUERY_LOAD_BANNED = 28,
- PLAYER_LOGIN_QUERY_LOAD_QUEST_STATUS_REW = 29,
- PLAYER_LOGIN_QUERY_LOAD_INSTANCE_LOCK_TIMES = 30,
- PLAYER_LOGIN_QUERY_LOAD_SEASONAL_QUEST_STATUS = 31,
- PLAYER_LOGIN_QUERY_LOAD_MONTHLY_QUEST_STATUS = 32,
- PLAYER_LOGIN_QUERY_LOAD_CORPSE_LOCATION = 33,
- PLAYER_LOGIN_QUERY_LOAD_PET_SLOTS = 34,
+ PLAYER_LOGIN_QUERY_LOAD_FROM,
+ PLAYER_LOGIN_QUERY_LOAD_GROUP,
+ PLAYER_LOGIN_QUERY_LOAD_BOUND_INSTANCES,
+ PLAYER_LOGIN_QUERY_LOAD_AURAS,
+ PLAYER_LOGIN_QUERY_LOAD_SPELLS,
+ PLAYER_LOGIN_QUERY_LOAD_QUEST_STATUS,
+ PLAYER_LOGIN_QUERY_LOAD_DAILY_QUEST_STATUS,
+ PLAYER_LOGIN_QUERY_LOAD_REPUTATION,
+ PLAYER_LOGIN_QUERY_LOAD_INVENTORY,
+ PLAYER_LOGIN_QUERY_LOAD_ACTIONS,
+ PLAYER_LOGIN_QUERY_LOAD_MAILS,
+ PLAYER_LOGIN_QUERY_LOAD_MAIL_ITEMS,
+ PLAYER_LOGIN_QUERY_LOAD_SOCIAL_LIST,
+ PLAYER_LOGIN_QUERY_LOAD_HOME_BIND,
+ PLAYER_LOGIN_QUERY_LOAD_SPELL_COOLDOWNS,
+ PLAYER_LOGIN_QUERY_LOAD_DECLINED_NAMES,
+ PLAYER_LOGIN_QUERY_LOAD_GUILD,
+ PLAYER_LOGIN_QUERY_LOAD_ARENA_INFO,
+ PLAYER_LOGIN_QUERY_LOAD_ACHIEVEMENTS,
+ PLAYER_LOGIN_QUERY_LOAD_CRITERIA_PROGRESS,
+ PLAYER_LOGIN_QUERY_LOAD_EQUIPMENT_SETS,
+ PLAYER_LOGIN_QUERY_LOAD_BG_DATA,
+ PLAYER_LOGIN_QUERY_LOAD_GLYPHS,
+ PLAYER_LOGIN_QUERY_LOAD_TALENTS,
+ PLAYER_LOGIN_QUERY_LOAD_ACCOUNT_DATA,
+ PLAYER_LOGIN_QUERY_LOAD_SKILLS,
+ PLAYER_LOGIN_QUERY_LOAD_WEEKLY_QUEST_STATUS,
+ PLAYER_LOGIN_QUERY_LOAD_RANDOM_BG,
+ PLAYER_LOGIN_QUERY_LOAD_BANNED,
+ PLAYER_LOGIN_QUERY_LOAD_QUEST_STATUS_REW,
+ PLAYER_LOGIN_QUERY_LOAD_SEASONAL_QUEST_STATUS,
+ PLAYER_LOGIN_QUERY_LOAD_MONTHLY_QUEST_STATUS,
+ PLAYER_LOGIN_QUERY_LOAD_CORPSE_LOCATION,
+ PLAYER_LOGIN_QUERY_LOAD_PET_SLOTS,
MAX_PLAYER_LOGIN_QUERY
};
@@ -2090,9 +2087,6 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
void SendSavedInstances();
bool Satisfy(AccessRequirement const* ar, uint32 target_map, bool report = false);
bool CheckInstanceValidity(bool /*isLogin*/);
- bool UpdateAndCheckInstanceCount(uint32 instanceId);
- void AddInstanceEnterTime(uint32 instanceId, time_t enterTime);
- void UpdateInstanceEnterTimes();
// last used pet number (for BG's)
uint32 GetLastPetNumber() const { return m_lastpetnumber; }
@@ -2270,7 +2264,6 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
void _LoadBGData(PreparedQueryResult result);
void _LoadGlyphs(PreparedQueryResult result);
void _LoadTalents(PreparedQueryResult result);
- void _LoadInstanceTimeRestrictions(PreparedQueryResult result);
void _LoadPetStable(uint8 petStableSlots, PreparedQueryResult result);
/*********************************************************/
@@ -2293,7 +2286,6 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
void _SaveGlyphs(CharacterDatabaseTransaction trans) const;
void _SaveTalents(CharacterDatabaseTransaction trans);
void _SaveStats(CharacterDatabaseTransaction trans) const;
- void _SaveInstanceTimeRestrictions(CharacterDatabaseTransaction trans);
/*********************************************************/
/*** ENVIRONMENTAL SYSTEM ***/
@@ -2514,7 +2506,6 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
uint32 m_ChampioningFaction;
- InstanceTimeMap _instanceResetTimes;
uint32 _pendingBindId;
uint32 _pendingBindTimer;