mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-25 22:56:24 +00:00
refactor(Core/Game): restyle game lib with astyle (#3466)
This commit is contained in:
@@ -83,7 +83,7 @@ InstanceSave* InstanceSaveManager::AddInstanceSave(uint32 mapId, uint32 instance
|
||||
}
|
||||
else
|
||||
{
|
||||
resetTime = time(nullptr) + 3*DAY; // normals expire after 3 days even if someone is still bound to them, cleared on startup
|
||||
resetTime = time(nullptr) + 3 * DAY; // normals expire after 3 days even if someone is still bound to them, cleared on startup
|
||||
extendedResetTime = 0;
|
||||
}
|
||||
InstanceSave* save = new InstanceSave(mapId, instanceId, difficulty, resetTime, extendedResetTime);
|
||||
@@ -132,7 +132,7 @@ bool InstanceSaveManager::DeleteInstanceSaveIfNeeded(InstanceSave* save, bool sk
|
||||
}
|
||||
|
||||
InstanceSave::InstanceSave(uint16 MapId, uint32 InstanceId, Difficulty difficulty, time_t resetTime, time_t extendedResetTime)
|
||||
: m_resetTime(resetTime), m_extendedResetTime(extendedResetTime), m_instanceid(InstanceId), m_mapid(MapId), m_difficulty(IsSharedDifficultyMap(MapId) ? Difficulty(difficulty%2) : difficulty), m_canReset(true), m_instanceData(""), m_completedEncounterMask(0)
|
||||
: m_resetTime(resetTime), m_extendedResetTime(extendedResetTime), m_instanceid(InstanceId), m_mapid(MapId), m_difficulty(IsSharedDifficultyMap(MapId) ? Difficulty(difficulty % 2) : difficulty), m_canReset(true), m_instanceData(""), m_completedEncounterMask(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -284,7 +284,7 @@ void InstanceSaveManager::LoadResetTimes()
|
||||
continue;
|
||||
|
||||
// the reset_delay must be at least one day
|
||||
uint32 period = uint32(((mapDiff->resetTime * sWorld->getRate(RATE_INSTANCE_RESET_TIME))/DAY) * DAY);
|
||||
uint32 period = uint32(((mapDiff->resetTime * sWorld->getRate(RATE_INSTANCE_RESET_TIME)) / DAY) * DAY);
|
||||
if (period < DAY)
|
||||
period = DAY;
|
||||
|
||||
@@ -311,10 +311,10 @@ void InstanceSaveManager::LoadResetTimes()
|
||||
// schedule the global reset/warning
|
||||
uint8 type;
|
||||
for (type = 1; type < 5; ++type)
|
||||
if (now + ResetTimeDelay[type-1] < t)
|
||||
if (now + ResetTimeDelay[type - 1] < t)
|
||||
break;
|
||||
|
||||
ScheduleReset(t - ResetTimeDelay[type-1], InstResetEvent(type, mapid, difficulty));
|
||||
ScheduleReset(t - ResetTimeDelay[type - 1], InstResetEvent(type, mapid, difficulty));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -345,8 +345,7 @@ void InstanceSaveManager::LoadInstanceSaves()
|
||||
if (resettime > 0)
|
||||
save->SetResetTime(resettime);
|
||||
}
|
||||
}
|
||||
while (result->NextRow());
|
||||
} while (result->NextRow());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -396,8 +395,7 @@ void InstanceSaveManager::LoadCharacterBinds()
|
||||
if (perm)
|
||||
save->SetCanReset(false);
|
||||
}
|
||||
}
|
||||
while (result->NextRow());
|
||||
} while (result->NextRow());
|
||||
}
|
||||
|
||||
lock_instLists = false;
|
||||
@@ -420,7 +418,7 @@ void InstanceSaveManager::Update()
|
||||
if (t >= now)
|
||||
break;
|
||||
|
||||
InstResetEvent &event = m_resetTimeQueue.begin()->second;
|
||||
InstResetEvent& event = m_resetTimeQueue.begin()->second;
|
||||
if (event.type)
|
||||
{
|
||||
// global reset/warning for a certain map
|
||||
@@ -431,7 +429,7 @@ void InstanceSaveManager::Update()
|
||||
{
|
||||
// schedule the next warning/reset
|
||||
++event.type;
|
||||
ScheduleReset(resetTime - ResetTimeDelay[event.type-1], event);
|
||||
ScheduleReset(resetTime - ResetTimeDelay[event.type - 1], event);
|
||||
}
|
||||
else
|
||||
resetOccurred = true;
|
||||
@@ -453,11 +451,11 @@ void InstanceSaveManager::Update()
|
||||
}
|
||||
}
|
||||
|
||||
void InstanceSaveManager::_ResetSave(InstanceSaveHashMap::iterator &itr)
|
||||
void InstanceSaveManager::_ResetSave(InstanceSaveHashMap::iterator& itr)
|
||||
{
|
||||
lock_instLists = true;
|
||||
|
||||
InstanceSave::PlayerListType &pList = itr->second->m_playerList;
|
||||
InstanceSave::PlayerListType& pList = itr->second->m_playerList;
|
||||
for (InstanceSave::PlayerListType::iterator iter = pList.begin(), iter2; iter != pList.end(); )
|
||||
{
|
||||
iter2 = iter++;
|
||||
@@ -523,14 +521,14 @@ void InstanceSaveManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficulty, b
|
||||
// calculate the next reset time
|
||||
uint32 diff = sWorld->getIntConfig(CONFIG_INSTANCE_RESET_TIME_HOUR) * HOUR;
|
||||
|
||||
uint32 period = uint32(((mapDiff->resetTime * sWorld->getRate(RATE_INSTANCE_RESET_TIME))/DAY) * DAY);
|
||||
uint32 period = uint32(((mapDiff->resetTime * sWorld->getRate(RATE_INSTANCE_RESET_TIME)) / DAY) * DAY);
|
||||
if (period < DAY)
|
||||
period = DAY;
|
||||
|
||||
uint32 next_reset = uint32(((resetTime + MINUTE) / DAY * DAY) + period + diff);
|
||||
SetResetTimeFor(mapid, difficulty, next_reset);
|
||||
SetExtendedResetTimeFor(mapid, difficulty, next_reset + period);
|
||||
ScheduleReset(time_t(next_reset-3600), InstResetEvent(1, mapid, difficulty));
|
||||
ScheduleReset(time_t(next_reset - 3600), InstResetEvent(1, mapid, difficulty));
|
||||
|
||||
// update it in the DB
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GLOBAL_INSTANCE_RESETTIME);
|
||||
@@ -551,7 +549,7 @@ void InstanceSaveManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficulty, b
|
||||
|
||||
// now loop all existing maps to warn / reset
|
||||
Map const* map = sMapMgr->CreateBaseMap(mapid);
|
||||
MapInstanced::InstancedMaps &instMaps = ((MapInstanced*)map)->GetInstancedMaps();
|
||||
MapInstanced::InstancedMaps& instMaps = ((MapInstanced*)map)->GetInstancedMaps();
|
||||
MapInstanced::InstancedMaps::iterator mitr;
|
||||
uint32 timeLeft;
|
||||
|
||||
@@ -573,7 +571,7 @@ void InstanceSaveManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficulty, b
|
||||
else
|
||||
{
|
||||
InstanceSave* save = GetInstanceSave(map2->GetInstanceId());
|
||||
map2->ToInstanceMap()->Reset(INSTANCE_RESET_GLOBAL, (save ? &(save->m_playerList) : nullptr));
|
||||
map2->ToInstanceMap()->Reset(INSTANCE_RESET_GLOBAL, (save ? & (save->m_playerList) : nullptr));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -692,7 +690,7 @@ void InstanceSaveManager::PlayerUnbindInstanceNotExtended(uint32 guidLow, uint32
|
||||
|
||||
InstancePlayerBind* InstanceSaveManager::PlayerGetBoundInstance(uint32 guidLow, uint32 mapid, Difficulty difficulty)
|
||||
{
|
||||
Difficulty difficulty_fixed = ( IsSharedDifficultyMap(mapid) ? Difficulty(difficulty%2) : difficulty);
|
||||
Difficulty difficulty_fixed = ( IsSharedDifficultyMap(mapid) ? Difficulty(difficulty % 2) : difficulty);
|
||||
|
||||
MapDifficulty const* mapDiff = GetDownscaledMapDifficultyData(mapid, difficulty_fixed);
|
||||
if (!mapDiff)
|
||||
@@ -713,7 +711,7 @@ InstancePlayerBind* InstanceSaveManager::PlayerGetBoundInstance(uint32 guidLow,
|
||||
}
|
||||
|
||||
bool InstanceSaveManager::PlayerIsPermBoundToInstance(uint32 guidLow, uint32 mapid, Difficulty difficulty)
|
||||
{
|
||||
{
|
||||
if (InstancePlayerBind* bind = PlayerGetBoundInstance(guidLow, mapid, difficulty))
|
||||
if (bind->perm)
|
||||
return true;
|
||||
@@ -773,7 +771,7 @@ void InstanceSaveManager::CopyBinds(uint32 from, uint32 to, Player* toPlr)
|
||||
|
||||
void InstanceSaveManager::UnbindAllFor(InstanceSave* save)
|
||||
{
|
||||
InstanceSave::PlayerListType &pList = save->m_playerList;
|
||||
InstanceSave::PlayerListType& pList = save->m_playerList;
|
||||
while (!pList.empty())
|
||||
PlayerUnbindInstance(*(pList.begin()), save->GetMapId(), save->GetDifficulty(), true, ObjectAccessor::GetObjectInOrOutOfWorld(MAKE_NEW_GUID(*(pList.begin()), 0, HIGHGUID_PLAYER), (Player*)NULL));
|
||||
}
|
||||
|
||||
@@ -45,53 +45,53 @@ typedef std::unordered_map< uint32 /*guidLow*/, BoundInstancesMapWrapper* > Play
|
||||
class InstanceSave
|
||||
{
|
||||
friend class InstanceSaveManager;
|
||||
public:
|
||||
public:
|
||||
|
||||
InstanceSave(uint16 MapId, uint32 InstanceId, Difficulty difficulty, time_t resetTime, time_t extendedResetTime);
|
||||
~InstanceSave();
|
||||
uint32 GetInstanceId() const { return m_instanceid; }
|
||||
uint32 GetMapId() const { return m_mapid; }
|
||||
Difficulty GetDifficulty() const { return m_difficulty; }
|
||||
InstanceSave(uint16 MapId, uint32 InstanceId, Difficulty difficulty, time_t resetTime, time_t extendedResetTime);
|
||||
~InstanceSave();
|
||||
uint32 GetInstanceId() const { return m_instanceid; }
|
||||
uint32 GetMapId() const { return m_mapid; }
|
||||
Difficulty GetDifficulty() const { return m_difficulty; }
|
||||
|
||||
/* Saved when the instance is generated for the first time */
|
||||
void InsertToDB();
|
||||
// pussywizard: deleting is done internally when there are no binds left
|
||||
/* Saved when the instance is generated for the first time */
|
||||
void InsertToDB();
|
||||
// pussywizard: deleting is done internally when there are no binds left
|
||||
|
||||
std::string GetInstanceData() const { return m_instanceData; }
|
||||
void SetInstanceData(std::string str) { m_instanceData = str; }
|
||||
uint32 GetCompletedEncounterMask() const { return m_completedEncounterMask; }
|
||||
void SetCompletedEncounterMask(uint32 mask) { m_completedEncounterMask = mask; }
|
||||
std::string GetInstanceData() const { return m_instanceData; }
|
||||
void SetInstanceData(std::string str) { m_instanceData = str; }
|
||||
uint32 GetCompletedEncounterMask() const { return m_completedEncounterMask; }
|
||||
void SetCompletedEncounterMask(uint32 mask) { m_completedEncounterMask = mask; }
|
||||
|
||||
// pussywizard: for normal instances this corresponds to 0, for raid/heroic instances this caches the global reset time for the map
|
||||
time_t GetResetTime() const { return m_resetTime; }
|
||||
time_t GetExtendedResetTime() const { return m_extendedResetTime; }
|
||||
time_t GetResetTimeForDB();
|
||||
void SetResetTime(time_t resetTime) { m_resetTime = resetTime; }
|
||||
void SetExtendedResetTime(time_t extendedResetTime) { m_extendedResetTime = extendedResetTime; }
|
||||
// pussywizard: for normal instances this corresponds to 0, for raid/heroic instances this caches the global reset time for the map
|
||||
time_t GetResetTime() const { return m_resetTime; }
|
||||
time_t GetExtendedResetTime() const { return m_extendedResetTime; }
|
||||
time_t GetResetTimeForDB();
|
||||
void SetResetTime(time_t resetTime) { m_resetTime = resetTime; }
|
||||
void SetExtendedResetTime(time_t extendedResetTime) { m_extendedResetTime = extendedResetTime; }
|
||||
|
||||
bool CanReset() const { return m_canReset; }
|
||||
void SetCanReset(bool canReset) { m_canReset = canReset; }
|
||||
bool CanReset() const { return m_canReset; }
|
||||
void SetCanReset(bool canReset) { m_canReset = canReset; }
|
||||
|
||||
InstanceTemplate const* GetTemplate();
|
||||
MapEntry const* GetMapEntry();
|
||||
InstanceTemplate const* GetTemplate();
|
||||
MapEntry const* GetMapEntry();
|
||||
|
||||
void AddPlayer(uint32 guidLow);
|
||||
bool RemovePlayer(uint32 guidLow, InstanceSaveManager* ism);
|
||||
void AddPlayer(uint32 guidLow);
|
||||
bool RemovePlayer(uint32 guidLow, InstanceSaveManager* ism);
|
||||
|
||||
typedef std::list<uint32> PlayerListType;
|
||||
private:
|
||||
typedef std::list<uint32> PlayerListType;
|
||||
private:
|
||||
|
||||
PlayerListType m_playerList;
|
||||
time_t m_resetTime;
|
||||
time_t m_extendedResetTime;
|
||||
uint32 m_instanceid;
|
||||
uint32 m_mapid;
|
||||
Difficulty m_difficulty;
|
||||
bool m_canReset;
|
||||
std::string m_instanceData;
|
||||
uint32 m_completedEncounterMask;
|
||||
PlayerListType m_playerList;
|
||||
time_t m_resetTime;
|
||||
time_t m_extendedResetTime;
|
||||
uint32 m_instanceid;
|
||||
uint32 m_mapid;
|
||||
Difficulty m_difficulty;
|
||||
bool m_canReset;
|
||||
std::string m_instanceData;
|
||||
uint32 m_completedEncounterMask;
|
||||
|
||||
ACE_Thread_Mutex _lock;
|
||||
ACE_Thread_Mutex _lock;
|
||||
};
|
||||
|
||||
typedef std::unordered_map<uint32 /*PAIR32(map, difficulty)*/, time_t /*resetTime*/> ResetTimeByMapDifficultyMap;
|
||||
@@ -100,94 +100,94 @@ class InstanceSaveManager
|
||||
{
|
||||
friend class InstanceSave;
|
||||
|
||||
private:
|
||||
InstanceSaveManager() : lock_instLists(false) {};
|
||||
~InstanceSaveManager();
|
||||
private:
|
||||
InstanceSaveManager() : lock_instLists(false) {};
|
||||
~InstanceSaveManager();
|
||||
|
||||
public:
|
||||
static InstanceSaveManager* instance();
|
||||
|
||||
typedef std::unordered_map<uint32 /*InstanceId*/, InstanceSave*> InstanceSaveHashMap;
|
||||
public:
|
||||
static InstanceSaveManager* instance();
|
||||
|
||||
struct InstResetEvent
|
||||
{
|
||||
uint8 type; // 0 - unused, 1-4 warnings about pending reset, 5 - reset
|
||||
Difficulty difficulty:8;
|
||||
uint16 mapid;
|
||||
typedef std::unordered_map<uint32 /*InstanceId*/, InstanceSave*> InstanceSaveHashMap;
|
||||
|
||||
InstResetEvent() : type(0), difficulty(DUNGEON_DIFFICULTY_NORMAL), mapid(0) {}
|
||||
InstResetEvent(uint8 t, uint32 _mapid, Difficulty d)
|
||||
: type(t), difficulty(d), mapid(_mapid) {}
|
||||
};
|
||||
typedef std::multimap<time_t /*resetTime*/, InstResetEvent> ResetTimeQueue;
|
||||
struct InstResetEvent
|
||||
{
|
||||
uint8 type; // 0 - unused, 1-4 warnings about pending reset, 5 - reset
|
||||
Difficulty difficulty: 8;
|
||||
uint16 mapid;
|
||||
|
||||
void LoadInstances();
|
||||
void LoadResetTimes();
|
||||
void LoadInstanceSaves();
|
||||
void LoadCharacterBinds();
|
||||
InstResetEvent() : type(0), difficulty(DUNGEON_DIFFICULTY_NORMAL), mapid(0) {}
|
||||
InstResetEvent(uint8 t, uint32 _mapid, Difficulty d)
|
||||
: type(t), difficulty(d), mapid(_mapid) {}
|
||||
};
|
||||
typedef std::multimap<time_t /*resetTime*/, InstResetEvent> ResetTimeQueue;
|
||||
|
||||
time_t GetResetTimeFor(uint32 mapid, Difficulty d) const
|
||||
{
|
||||
ResetTimeByMapDifficultyMap::const_iterator itr = m_resetTimeByMapDifficulty.find(MAKE_PAIR32(mapid, d));
|
||||
return itr != m_resetTimeByMapDifficulty.end() ? itr->second : 0;
|
||||
}
|
||||
void LoadInstances();
|
||||
void LoadResetTimes();
|
||||
void LoadInstanceSaves();
|
||||
void LoadCharacterBinds();
|
||||
|
||||
time_t GetExtendedResetTimeFor(uint32 mapid, Difficulty d) const
|
||||
{
|
||||
ResetTimeByMapDifficultyMap::const_iterator itr = m_resetExtendedTimeByMapDifficulty.find(MAKE_PAIR32(mapid, d));
|
||||
return itr != m_resetExtendedTimeByMapDifficulty.end() ? itr->second : 0;
|
||||
}
|
||||
time_t GetResetTimeFor(uint32 mapid, Difficulty d) const
|
||||
{
|
||||
ResetTimeByMapDifficultyMap::const_iterator itr = m_resetTimeByMapDifficulty.find(MAKE_PAIR32(mapid, d));
|
||||
return itr != m_resetTimeByMapDifficulty.end() ? itr->second : 0;
|
||||
}
|
||||
|
||||
void SetResetTimeFor(uint32 mapid, Difficulty d, time_t t)
|
||||
{
|
||||
m_resetTimeByMapDifficulty[MAKE_PAIR32(mapid, d)] = t;
|
||||
}
|
||||
time_t GetExtendedResetTimeFor(uint32 mapid, Difficulty d) const
|
||||
{
|
||||
ResetTimeByMapDifficultyMap::const_iterator itr = m_resetExtendedTimeByMapDifficulty.find(MAKE_PAIR32(mapid, d));
|
||||
return itr != m_resetExtendedTimeByMapDifficulty.end() ? itr->second : 0;
|
||||
}
|
||||
|
||||
void SetExtendedResetTimeFor(uint32 mapid, Difficulty d, time_t t)
|
||||
{
|
||||
m_resetExtendedTimeByMapDifficulty[MAKE_PAIR32(mapid, d)] = t;
|
||||
}
|
||||
void SetResetTimeFor(uint32 mapid, Difficulty d, time_t t)
|
||||
{
|
||||
m_resetTimeByMapDifficulty[MAKE_PAIR32(mapid, d)] = t;
|
||||
}
|
||||
|
||||
ResetTimeByMapDifficultyMap const& GetResetTimeMap() const
|
||||
{
|
||||
return m_resetTimeByMapDifficulty;
|
||||
}
|
||||
void SetExtendedResetTimeFor(uint32 mapid, Difficulty d, time_t t)
|
||||
{
|
||||
m_resetExtendedTimeByMapDifficulty[MAKE_PAIR32(mapid, d)] = t;
|
||||
}
|
||||
|
||||
void ScheduleReset(time_t time, InstResetEvent event);
|
||||
ResetTimeByMapDifficultyMap const& GetResetTimeMap() const
|
||||
{
|
||||
return m_resetTimeByMapDifficulty;
|
||||
}
|
||||
|
||||
void Update();
|
||||
void ScheduleReset(time_t time, InstResetEvent event);
|
||||
|
||||
InstanceSave* AddInstanceSave(uint32 mapId, uint32 instanceId, Difficulty difficulty, bool startup = false);
|
||||
bool DeleteInstanceSaveIfNeeded(uint32 InstanceId, bool skipMapCheck);
|
||||
bool DeleteInstanceSaveIfNeeded(InstanceSave* save, bool skipMapCheck);
|
||||
void Update();
|
||||
|
||||
InstanceSave* GetInstanceSave(uint32 InstanceId);
|
||||
InstanceSave* AddInstanceSave(uint32 mapId, uint32 instanceId, Difficulty difficulty, bool startup = false);
|
||||
bool DeleteInstanceSaveIfNeeded(uint32 InstanceId, bool skipMapCheck);
|
||||
bool DeleteInstanceSaveIfNeeded(InstanceSave* save, bool skipMapCheck);
|
||||
|
||||
InstancePlayerBind* PlayerBindToInstance(uint32 guidLow, InstanceSave* save, bool permanent, Player* player = nullptr);
|
||||
void PlayerUnbindInstance(uint32 guidLow, uint32 mapid, Difficulty difficulty, bool deleteFromDB, Player* player = nullptr);
|
||||
void PlayerUnbindInstanceNotExtended(uint32 guidLow, uint32 mapid, Difficulty difficulty, Player* player = nullptr);
|
||||
InstancePlayerBind* PlayerGetBoundInstance(uint32 guidLow, uint32 mapid, Difficulty difficulty);
|
||||
bool PlayerIsPermBoundToInstance(uint32 guidLow, uint32 mapid, Difficulty difficulty);
|
||||
BoundInstancesMap const& PlayerGetBoundInstances(uint32 guidLow, Difficulty difficulty);
|
||||
void PlayerCreateBoundInstancesMaps(uint32 guidLow);
|
||||
InstanceSave* PlayerGetInstanceSave(uint32 guidLow, uint32 mapid, Difficulty difficulty);
|
||||
uint32 PlayerGetDestinationInstanceId(Player* player, uint32 mapid, Difficulty difficulty);
|
||||
void CopyBinds(uint32 from, uint32 to, Player* toPlr = nullptr);
|
||||
void UnbindAllFor(InstanceSave* save);
|
||||
InstanceSave* GetInstanceSave(uint32 InstanceId);
|
||||
|
||||
protected:
|
||||
static uint16 ResetTimeDelay[];
|
||||
static PlayerBindStorage playerBindStorage;
|
||||
static BoundInstancesMap emptyBoundInstancesMap;
|
||||
InstancePlayerBind* PlayerBindToInstance(uint32 guidLow, InstanceSave* save, bool permanent, Player* player = nullptr);
|
||||
void PlayerUnbindInstance(uint32 guidLow, uint32 mapid, Difficulty difficulty, bool deleteFromDB, Player* player = nullptr);
|
||||
void PlayerUnbindInstanceNotExtended(uint32 guidLow, uint32 mapid, Difficulty difficulty, Player* player = nullptr);
|
||||
InstancePlayerBind* PlayerGetBoundInstance(uint32 guidLow, uint32 mapid, Difficulty difficulty);
|
||||
bool PlayerIsPermBoundToInstance(uint32 guidLow, uint32 mapid, Difficulty difficulty);
|
||||
BoundInstancesMap const& PlayerGetBoundInstances(uint32 guidLow, Difficulty difficulty);
|
||||
void PlayerCreateBoundInstancesMaps(uint32 guidLow);
|
||||
InstanceSave* PlayerGetInstanceSave(uint32 guidLow, uint32 mapid, Difficulty difficulty);
|
||||
uint32 PlayerGetDestinationInstanceId(Player* player, uint32 mapid, Difficulty difficulty);
|
||||
void CopyBinds(uint32 from, uint32 to, Player* toPlr = nullptr);
|
||||
void UnbindAllFor(InstanceSave* save);
|
||||
|
||||
private:
|
||||
void _ResetOrWarnAll(uint32 mapid, Difficulty difficulty, bool warn, time_t resetTime);
|
||||
void _ResetSave(InstanceSaveHashMap::iterator &itr);
|
||||
bool lock_instLists;
|
||||
InstanceSaveHashMap m_instanceSaveById;
|
||||
ResetTimeByMapDifficultyMap m_resetTimeByMapDifficulty;
|
||||
ResetTimeByMapDifficultyMap m_resetExtendedTimeByMapDifficulty;
|
||||
ResetTimeQueue m_resetTimeQueue;
|
||||
protected:
|
||||
static uint16 ResetTimeDelay[];
|
||||
static PlayerBindStorage playerBindStorage;
|
||||
static BoundInstancesMap emptyBoundInstancesMap;
|
||||
|
||||
private:
|
||||
void _ResetOrWarnAll(uint32 mapid, Difficulty difficulty, bool warn, time_t resetTime);
|
||||
void _ResetSave(InstanceSaveHashMap::iterator& itr);
|
||||
bool lock_instLists;
|
||||
InstanceSaveHashMap m_instanceSaveById;
|
||||
ResetTimeByMapDifficultyMap m_resetTimeByMapDifficulty;
|
||||
ResetTimeByMapDifficultyMap m_resetExtendedTimeByMapDifficulty;
|
||||
ResetTimeQueue m_resetTimeQueue;
|
||||
};
|
||||
|
||||
#define sInstanceSaveMgr InstanceSaveManager::instance()
|
||||
|
||||
@@ -42,7 +42,8 @@ void InstanceScript::HandleGameObject(uint64 GUID, bool open, GameObject* go)
|
||||
go = instance->GetGameObject(GUID);
|
||||
if (go)
|
||||
go->SetGoState(open ? GO_STATE_ACTIVE : GO_STATE_READY);
|
||||
else {
|
||||
else
|
||||
{
|
||||
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
|
||||
sLog->outDebug(LOG_FILTER_TSCR, "TSCR: InstanceScript: HandleGameObject failed");
|
||||
#endif
|
||||
@@ -230,7 +231,7 @@ bool InstanceScript::SetBossState(uint32 id, EncounterState state)
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string InstanceScript::LoadBossState(const char * data)
|
||||
std::string InstanceScript::LoadBossState(const char* data)
|
||||
{
|
||||
if (!data)
|
||||
return nullptr;
|
||||
@@ -281,7 +282,7 @@ void InstanceScript::DoRespawnGameObject(uint64 uiGuid, uint32 uiTimeToDespawn)
|
||||
{
|
||||
//not expect any of these should ever be handled
|
||||
if (go->GetGoType() == GAMEOBJECT_TYPE_FISHINGNODE || go->GetGoType() == GAMEOBJECT_TYPE_DOOR ||
|
||||
go->GetGoType() == GAMEOBJECT_TYPE_BUTTON || go->GetGoType() == GAMEOBJECT_TYPE_TRAP)
|
||||
go->GetGoType() == GAMEOBJECT_TYPE_BUTTON || go->GetGoType() == GAMEOBJECT_TYPE_TRAP)
|
||||
return;
|
||||
|
||||
if (go->isSpawned())
|
||||
@@ -301,7 +302,8 @@ void InstanceScript::DoUpdateWorldState(uint32 uiStateId, uint32 uiStateData)
|
||||
if (Player* player = itr->GetSource())
|
||||
player->SendUpdateWorldState(uiStateId, uiStateData);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
|
||||
sLog->outDebug(LOG_FILTER_TSCR, "TSCR: DoUpdateWorldState attempt send data but no players in map.");
|
||||
#endif
|
||||
@@ -329,7 +331,7 @@ void InstanceScript::DoSendNotifyToInstance(char const* format, ...)
|
||||
// Update Achievement Criteria for all players in instance
|
||||
void InstanceScript::DoUpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscValue1 /*= 0*/, uint32 miscValue2 /*= 0*/, Unit* unit /*= NULL*/)
|
||||
{
|
||||
Map::PlayerList const &PlayerList = instance->GetPlayers();
|
||||
Map::PlayerList const& PlayerList = instance->GetPlayers();
|
||||
|
||||
if (!PlayerList.isEmpty())
|
||||
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
|
||||
@@ -340,7 +342,7 @@ void InstanceScript::DoUpdateAchievementCriteria(AchievementCriteriaTypes type,
|
||||
// Start timed achievement for all players in instance
|
||||
void InstanceScript::DoStartTimedAchievement(AchievementCriteriaTimedTypes type, uint32 entry)
|
||||
{
|
||||
Map::PlayerList const &PlayerList = instance->GetPlayers();
|
||||
Map::PlayerList const& PlayerList = instance->GetPlayers();
|
||||
|
||||
if (!PlayerList.isEmpty())
|
||||
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
|
||||
@@ -351,7 +353,7 @@ void InstanceScript::DoStartTimedAchievement(AchievementCriteriaTimedTypes type,
|
||||
// Stop timed achievement for all players in instance
|
||||
void InstanceScript::DoStopTimedAchievement(AchievementCriteriaTimedTypes type, uint32 entry)
|
||||
{
|
||||
Map::PlayerList const &PlayerList = instance->GetPlayers();
|
||||
Map::PlayerList const& PlayerList = instance->GetPlayers();
|
||||
|
||||
if (!PlayerList.isEmpty())
|
||||
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
|
||||
@@ -380,7 +382,7 @@ void InstanceScript::DoRemoveAurasDueToSpellOnPlayers(uint32 spell)
|
||||
// Cast spell on all players in instance
|
||||
void InstanceScript::DoCastSpellOnPlayers(uint32 spell)
|
||||
{
|
||||
Map::PlayerList const &PlayerList = instance->GetPlayers();
|
||||
Map::PlayerList const& PlayerList = instance->GetPlayers();
|
||||
|
||||
if (!PlayerList.isEmpty())
|
||||
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
|
||||
@@ -391,7 +393,7 @@ void InstanceScript::DoCastSpellOnPlayers(uint32 spell)
|
||||
bool InstanceScript::CheckAchievementCriteriaMeet(uint32 criteria_id, Player const* /*source*/, Unit const* /*target*/ /*= NULL*/, uint32 /*miscvalue1*/ /*= 0*/)
|
||||
{
|
||||
sLog->outError("Achievement system call InstanceScript::CheckAchievementCriteriaMeet but instance script for map %u not have implementation for achievement criteria %u",
|
||||
instance->GetId(), criteria_id);
|
||||
instance->GetId(), criteria_id);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -120,116 +120,116 @@ typedef std::map<uint32 /*entry*/, MinionInfo> MinionInfoMap;
|
||||
|
||||
class InstanceScript : public ZoneScript
|
||||
{
|
||||
public:
|
||||
public:
|
||||
|
||||
explicit InstanceScript(Map* map) : instance(map), completedEncounters(0) {}
|
||||
explicit InstanceScript(Map* map) : instance(map), completedEncounters(0) {}
|
||||
|
||||
virtual ~InstanceScript() {}
|
||||
virtual ~InstanceScript() {}
|
||||
|
||||
Map* instance;
|
||||
Map* instance;
|
||||
|
||||
//On creation, NOT load.
|
||||
virtual void Initialize() {}
|
||||
//On creation, NOT load.
|
||||
virtual void Initialize() {}
|
||||
|
||||
//On load
|
||||
virtual void Load(char const* data) { LoadBossState(data); }
|
||||
//On load
|
||||
virtual void Load(char const* data) { LoadBossState(data); }
|
||||
|
||||
//Called when creature is Looted
|
||||
virtual void CreatureLooted(Creature* /*creature*/, LootType) {}
|
||||
//Called when creature is Looted
|
||||
virtual void CreatureLooted(Creature* /*creature*/, LootType) {}
|
||||
|
||||
//When save is needed, this function generates the data
|
||||
virtual std::string GetSaveData() { return GetBossSaveData(); }
|
||||
//When save is needed, this function generates the data
|
||||
virtual std::string GetSaveData() { return GetBossSaveData(); }
|
||||
|
||||
void SaveToDB();
|
||||
void SaveToDB();
|
||||
|
||||
virtual void Update(uint32 /*diff*/) {}
|
||||
virtual void Update(uint32 /*diff*/) {}
|
||||
|
||||
//Used by the map's CanEnter function.
|
||||
//This is to prevent players from entering during boss encounters.
|
||||
virtual bool IsEncounterInProgress() const;
|
||||
//Used by the map's CanEnter function.
|
||||
//This is to prevent players from entering during boss encounters.
|
||||
virtual bool IsEncounterInProgress() const;
|
||||
|
||||
//Called when a player successfully enters the instance.
|
||||
virtual void OnPlayerEnter(Player* /*player*/) {}
|
||||
//Called when a player successfully enters the instance.
|
||||
virtual void OnPlayerEnter(Player* /*player*/) {}
|
||||
|
||||
virtual void OnPlayerAreaUpdate(Player* /*player*/, uint32 /*oldArea*/, uint32 /*newArea*/) {}
|
||||
virtual void OnPlayerAreaUpdate(Player* /*player*/, uint32 /*oldArea*/, uint32 /*newArea*/) {}
|
||||
|
||||
//Handle open / close objects
|
||||
//use HandleGameObject(0, boolen, GO); in OnObjectCreate in instance scripts
|
||||
//use HandleGameObject(GUID, boolen, nullptr); in any other script
|
||||
void HandleGameObject(uint64 guid, bool open, GameObject* go = nullptr);
|
||||
//Handle open / close objects
|
||||
//use HandleGameObject(0, boolen, GO); in OnObjectCreate in instance scripts
|
||||
//use HandleGameObject(GUID, boolen, nullptr); in any other script
|
||||
void HandleGameObject(uint64 guid, bool open, GameObject* go = nullptr);
|
||||
|
||||
//change active state of doors or buttons
|
||||
void DoUseDoorOrButton(uint64 guid, uint32 withRestoreTime = 0, bool useAlternativeState = false);
|
||||
//change active state of doors or buttons
|
||||
void DoUseDoorOrButton(uint64 guid, uint32 withRestoreTime = 0, bool useAlternativeState = false);
|
||||
|
||||
//Respawns a GO having negative spawntimesecs in gameobject-table
|
||||
void DoRespawnGameObject(uint64 guid, uint32 timeToDespawn = MINUTE);
|
||||
//Respawns a GO having negative spawntimesecs in gameobject-table
|
||||
void DoRespawnGameObject(uint64 guid, uint32 timeToDespawn = MINUTE);
|
||||
|
||||
//sends world state update to all players in instance
|
||||
void DoUpdateWorldState(uint32 worldstateId, uint32 worldstateValue);
|
||||
//sends world state update to all players in instance
|
||||
void DoUpdateWorldState(uint32 worldstateId, uint32 worldstateValue);
|
||||
|
||||
// Send Notify to all players in instance
|
||||
void DoSendNotifyToInstance(char const* format, ...);
|
||||
// Send Notify to all players in instance
|
||||
void DoSendNotifyToInstance(char const* format, ...);
|
||||
|
||||
// Update Achievement Criteria for all players in instance
|
||||
void DoUpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscValue1 = 0, uint32 miscValue2 = 0, Unit* unit = nullptr);
|
||||
// Update Achievement Criteria for all players in instance
|
||||
void DoUpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscValue1 = 0, uint32 miscValue2 = 0, Unit* unit = nullptr);
|
||||
|
||||
// Start/Stop Timed Achievement Criteria for all players in instance
|
||||
void DoStartTimedAchievement(AchievementCriteriaTimedTypes type, uint32 entry);
|
||||
void DoStopTimedAchievement(AchievementCriteriaTimedTypes type, uint32 entry);
|
||||
// Start/Stop Timed Achievement Criteria for all players in instance
|
||||
void DoStartTimedAchievement(AchievementCriteriaTimedTypes type, uint32 entry);
|
||||
void DoStopTimedAchievement(AchievementCriteriaTimedTypes type, uint32 entry);
|
||||
|
||||
// Remove Auras due to Spell on all players in instance
|
||||
void DoRemoveAurasDueToSpellOnPlayers(uint32 spell);
|
||||
// Remove Auras due to Spell on all players in instance
|
||||
void DoRemoveAurasDueToSpellOnPlayers(uint32 spell);
|
||||
|
||||
// Cast spell on all players in instance
|
||||
void DoCastSpellOnPlayers(uint32 spell);
|
||||
// Cast spell on all players in instance
|
||||
void DoCastSpellOnPlayers(uint32 spell);
|
||||
|
||||
// Return wether server allow two side groups or not
|
||||
bool ServerAllowsTwoSideGroups() { return sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP); }
|
||||
// Return wether server allow two side groups or not
|
||||
bool ServerAllowsTwoSideGroups() { return sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP); }
|
||||
|
||||
virtual bool SetBossState(uint32 id, EncounterState state);
|
||||
EncounterState GetBossState(uint32 id) const { return id < bosses.size() ? bosses[id].state : TO_BE_DECIDED; }
|
||||
static std::string GetBossStateName(uint8 state);
|
||||
BossBoundaryMap const* GetBossBoundary(uint32 id) const { return id < bosses.size() ? &bosses[id].boundary : nullptr; }
|
||||
BossInfo const* GetBossInfo(uint32 id) const { return &bosses[id]; }
|
||||
virtual bool SetBossState(uint32 id, EncounterState state);
|
||||
EncounterState GetBossState(uint32 id) const { return id < bosses.size() ? bosses[id].state : TO_BE_DECIDED; }
|
||||
static std::string GetBossStateName(uint8 state);
|
||||
BossBoundaryMap const* GetBossBoundary(uint32 id) const { return id < bosses.size() ? &bosses[id].boundary : nullptr; }
|
||||
BossInfo const* GetBossInfo(uint32 id) const { return &bosses[id]; }
|
||||
|
||||
// Achievement criteria additional requirements check
|
||||
// NOTE: not use this if same can be checked existed requirement types from AchievementCriteriaRequirementType
|
||||
virtual bool CheckAchievementCriteriaMeet(uint32 /*criteria_id*/, Player const* /*source*/, Unit const* /*target*/ = NULL, uint32 /*miscvalue1*/ = 0);
|
||||
// Achievement criteria additional requirements check
|
||||
// NOTE: not use this if same can be checked existed requirement types from AchievementCriteriaRequirementType
|
||||
virtual bool CheckAchievementCriteriaMeet(uint32 /*criteria_id*/, Player const* /*source*/, Unit const* /*target*/ = NULL, uint32 /*miscvalue1*/ = 0);
|
||||
|
||||
// Checks boss requirements (one boss required to kill other)
|
||||
virtual bool CheckRequiredBosses(uint32 /*bossId*/, Player const* /*player*/ = nullptr) const { return true; }
|
||||
// Checks boss requirements (one boss required to kill other)
|
||||
virtual bool CheckRequiredBosses(uint32 /*bossId*/, Player const* /*player*/ = nullptr) const { return true; }
|
||||
|
||||
void SetCompletedEncountersMask(uint32 newMask, bool save);
|
||||
void SetCompletedEncountersMask(uint32 newMask, bool save);
|
||||
|
||||
// Returns completed encounters mask for packets
|
||||
uint32 GetCompletedEncounterMask() const { return completedEncounters; }
|
||||
// Returns completed encounters mask for packets
|
||||
uint32 GetCompletedEncounterMask() const { return completedEncounters; }
|
||||
|
||||
void SendEncounterUnit(uint32 type, Unit* unit = NULL, uint8 param1 = 0, uint8 param2 = 0);
|
||||
void SendEncounterUnit(uint32 type, Unit* unit = NULL, uint8 param1 = 0, uint8 param2 = 0);
|
||||
|
||||
virtual void FillInitialWorldStates(WorldPacket& /*data*/) {}
|
||||
virtual void FillInitialWorldStates(WorldPacket& /*data*/) {}
|
||||
|
||||
uint32 GetEncounterCount() const { return bosses.size(); }
|
||||
uint32 GetEncounterCount() const { return bosses.size(); }
|
||||
|
||||
// Allows to perform particular actions
|
||||
virtual void DoAction(int32 /*action*/) {}
|
||||
protected:
|
||||
void SetBossNumber(uint32 number) { bosses.resize(number); }
|
||||
void LoadDoorData(DoorData const* data);
|
||||
void LoadMinionData(MinionData const* data);
|
||||
// Allows to perform particular actions
|
||||
virtual void DoAction(int32 /*action*/) {}
|
||||
protected:
|
||||
void SetBossNumber(uint32 number) { bosses.resize(number); }
|
||||
void LoadDoorData(DoorData const* data);
|
||||
void LoadMinionData(MinionData const* data);
|
||||
|
||||
void AddDoor(GameObject* door, bool add);
|
||||
void AddMinion(Creature* minion, bool add);
|
||||
void AddDoor(GameObject* door, bool add);
|
||||
void AddMinion(Creature* minion, bool add);
|
||||
|
||||
void UpdateDoorState(GameObject* door);
|
||||
void UpdateMinionState(Creature* minion, EncounterState state);
|
||||
void UpdateDoorState(GameObject* door);
|
||||
void UpdateMinionState(Creature* minion, EncounterState state);
|
||||
|
||||
std::string LoadBossState(char const* data);
|
||||
std::string GetBossSaveData();
|
||||
private:
|
||||
std::vector<BossInfo> bosses;
|
||||
DoorInfoMap doors;
|
||||
MinionInfoMap minions;
|
||||
uint32 completedEncounters; // completed encounter mask, bit indexes are DungeonEncounter.dbc boss numbers, used for packets
|
||||
std::string LoadBossState(char const* data);
|
||||
std::string GetBossSaveData();
|
||||
private:
|
||||
std::vector<BossInfo> bosses;
|
||||
DoorInfoMap doors;
|
||||
MinionInfoMap minions;
|
||||
uint32 completedEncounters; // completed encounter mask, bit indexes are DungeonEncounter.dbc boss numbers, used for packets
|
||||
};
|
||||
|
||||
template<class AI, class T>
|
||||
|
||||
Reference in New Issue
Block a user