Core/Instances: Implemented hourly instance limit: players are limited to entering 5 instances per hour (account wide limit)

This commit is contained in:
Shauren
2011-01-24 11:20:30 +01:00
parent e5b4f8e84d
commit 464837077a
10 changed files with 171 additions and 36 deletions
+21 -1
View File
@@ -133,6 +133,9 @@ struct SpellCooldown
typedef std::map<uint32, SpellCooldown> SpellCooldowns;
#define MAX_INSTANCES_PER_HOUR 5
typedef UNORDERED_MAP<uint32 /*instanceId*/, time_t/*releaseTime*/> InstanceTimeMap;
enum TrainerSpellState
{
TRAINER_SPELL_GREEN = 0,
@@ -794,7 +797,8 @@ enum PlayerLoginQueryIndex
PLAYER_LOGIN_QUERY_LOADARENASTATS = 28,
PLAYER_LOGIN_QUERY_LOADBANNED = 29,
PLAYER_LOGIN_QUERY_LOADQUESTSTATUSREW = 30,
MAX_PLAYER_LOGIN_QUERY = 31
PLAYER_LOGIN_QUERY_LOADINSTANCELOCKTIMES = 31,
MAX_PLAYER_LOGIN_QUERY,
};
enum PlayerDelayedOperations
@@ -2303,6 +2307,18 @@ class Player : public Unit, public GridObject<Player>
static void ConvertInstancesToGroup(Player *player, Group *group = NULL, uint64 player_guid = 0);
bool Satisfy(AccessRequirement const* ar, uint32 target_map, bool report = false);
bool CheckInstanceLoginValid();
bool CheckInstanceCount(uint32 instanceId) const
{
if (_instanceResetTimes.size() < MAX_INSTANCES_PER_HOUR)
return true;
return _instanceResetTimes.find(instanceId) != _instanceResetTimes.end();
}
void AddInstanceEnterTime(uint32 instanceId, time_t enterTime)
{
if (_instanceResetTimes.find(instanceId) == _instanceResetTimes.end())
_instanceResetTimes.insert(InstanceTimeMap::value_type(instanceId, enterTime + HOUR));
}
// last used pet number (for BG's)
uint32 GetLastPetNumber() const { return m_lastpetnumber; }
@@ -2449,6 +2465,7 @@ class Player : public Unit, public GridObject<Player>
void _LoadBGData(PreparedQueryResult result);
void _LoadGlyphs(PreparedQueryResult result);
void _LoadTalents(PreparedQueryResult result);
void _LoadInstanceTimeRestrictions(PreparedQueryResult result);
/*********************************************************/
/*** SAVE SYSTEM ***/
@@ -2468,6 +2485,7 @@ class Player : public Unit, public GridObject<Player>
void _SaveGlyphs(SQLTransaction& trans);
void _SaveTalents(SQLTransaction& trans);
void _SaveStats(SQLTransaction& trans);
void _SaveInstanceTimeRestrictions(SQLTransaction& trans);
void _SetCreateBits(UpdateMask *updateMask, Player *target) const;
void _SetUpdateBits(UpdateMask *updateMask, Player *target) const;
@@ -2700,6 +2718,8 @@ class Player : public Unit, public GridObject<Player>
uint32 m_timeSyncTimer;
uint32 m_timeSyncClient;
uint32 m_timeSyncServer;
InstanceTimeMap _instanceResetTimes;
};
void AddItemsSetItem(Player*player,Item *item);