mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
[11785] Implement dungeon encounters (DBC part), thanks to rsa for porting it to mangos
Signed-off-by: Laise <fenrisse@gmail.com>
This commit is contained in:
parent
dc932024ab
commit
8e4c46ff2a
18 changed files with 1457 additions and 20 deletions
|
|
@ -206,8 +206,8 @@ bool WorldPersistentState::CanBeUnload() const
|
|||
|
||||
//== DungeonPersistentState functions =====================
|
||||
|
||||
DungeonPersistentState::DungeonPersistentState( uint16 MapId, uint32 InstanceId, Difficulty difficulty, time_t resetTime, bool canReset )
|
||||
: MapPersistentState(MapId, InstanceId, difficulty), m_resetTime(resetTime), m_canReset(canReset)
|
||||
DungeonPersistentState::DungeonPersistentState( uint16 MapId, uint32 InstanceId, Difficulty difficulty, time_t resetTime, bool canReset, uint32 completedEncountersMask)
|
||||
: MapPersistentState(MapId, InstanceId, difficulty), m_resetTime(resetTime), m_canReset(canReset), m_completedEncountersMask(completedEncountersMask)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -249,7 +249,7 @@ void DungeonPersistentState::SaveToDB()
|
|||
}
|
||||
}
|
||||
|
||||
CharacterDatabase.PExecute("INSERT INTO instance VALUES ('%u', '%u', '"UI64FMTD"', '%u', '%s')", GetInstanceId(), GetMapId(), (uint64)GetResetTimeForDB(), GetDifficulty(), data.c_str());
|
||||
CharacterDatabase.PExecute("INSERT INTO instance VALUES ('%u', '%u', '"UI64FMTD"', '%u', '%u', '%s')", GetInstanceId(), GetMapId(), (uint64)GetResetTimeForDB(), GetDifficulty(), GetCompletedEncountersMask(), data.c_str());
|
||||
}
|
||||
|
||||
void DungeonPersistentState::DeleteRespawnTimes()
|
||||
|
|
@ -283,6 +283,31 @@ time_t DungeonPersistentState::GetResetTimeForDB() const
|
|||
return GetResetTime();
|
||||
}
|
||||
|
||||
void DungeonPersistentState::UpdateEncounterState(EncounterCreditType type, uint32 creditEntry)
|
||||
{
|
||||
DungeonEncounterMapBounds bounds = sObjectMgr.GetDungeonEncounterBounds(creditEntry);
|
||||
|
||||
for (DungeonEncounterMap::const_iterator iter = bounds.first; iter != bounds.second; ++iter)
|
||||
{
|
||||
DungeonEncounterEntry const* dbcEntry = iter->second->dbcEntry;
|
||||
|
||||
if (iter->second->creditType == type && dbcEntry->Difficulty == GetDifficulty() && dbcEntry->mapId == GetMapId())
|
||||
{
|
||||
m_completedEncountersMask |= 1 << dbcEntry->encounterIndex;
|
||||
|
||||
CharacterDatabase.PExecute("UPDATE instance SET encountersMask = '%u' WHERE id = '%u'", m_completedEncountersMask, GetInstanceId());
|
||||
|
||||
DEBUG_LOG("DungeonPersistentState: Dungeon %s (Id %u) completed encounter %s", GetMap()->GetMapName(), GetInstanceId(), dbcEntry->encounterName[sWorld.GetDefaultDbcLocale()]);
|
||||
if (uint32 dungeonId = iter->second->lastEncounterDungeon)
|
||||
{
|
||||
DEBUG_LOG("DungeonPersistentState:: Dungeon %s (Id %u) completed last encounter %s", GetMap()->GetMapName(), GetInstanceId(), dbcEntry->encounterName[sWorld.GetDefaultDbcLocale()]);
|
||||
// Place LFG reward here
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//== BattleGroundPersistentState functions =================
|
||||
|
||||
bool BattleGroundPersistentState::CanBeUnload() const
|
||||
|
|
@ -567,7 +592,7 @@ MapPersistentStateManager::~MapPersistentStateManager()
|
|||
- adding instance into manager
|
||||
- called from DungeonMap::Add, _LoadBoundInstances, LoadGroups
|
||||
*/
|
||||
MapPersistentState* MapPersistentStateManager::AddPersistentState(MapEntry const* mapEntry, uint32 instanceId, Difficulty difficulty, time_t resetTime, bool canReset, bool load /*=false*/, bool initPools /*= true*/)
|
||||
MapPersistentState* MapPersistentStateManager::AddPersistentState(MapEntry const* mapEntry, uint32 instanceId, Difficulty difficulty, time_t resetTime, bool canReset, bool load /*=false*/, bool initPools /*= true*/, uint32 completedEncountersMask /*= 0*/)
|
||||
{
|
||||
if (MapPersistentState *old_save = GetPersistentState(mapEntry->MapID, instanceId))
|
||||
return old_save;
|
||||
|
|
@ -594,7 +619,7 @@ MapPersistentState* MapPersistentStateManager::AddPersistentState(MapEntry const
|
|||
MapPersistentState *state;
|
||||
if (mapEntry->IsDungeon())
|
||||
{
|
||||
DungeonPersistentState* dungeonState = new DungeonPersistentState(mapEntry->MapID, instanceId, difficulty, resetTime, canReset);
|
||||
DungeonPersistentState* dungeonState = new DungeonPersistentState(mapEntry->MapID, instanceId, difficulty, completedEncountersMask, resetTime, canReset);
|
||||
if (!load)
|
||||
dungeonState->SaveToDB();
|
||||
state = dungeonState;
|
||||
|
|
@ -916,7 +941,7 @@ void MapPersistentStateManager::LoadCreatureRespawnTimes()
|
|||
|
||||
uint32 count = 0;
|
||||
|
||||
QueryResult *result = CharacterDatabase.Query("SELECT guid, respawntime, map, instance, difficulty, resettime FROM creature_respawn LEFT JOIN instance ON instance = id");
|
||||
QueryResult *result = CharacterDatabase.Query("SELECT guid, respawntime, map, instance, difficulty, resettime, encountersMask FROM creature_respawn LEFT JOIN instance ON instance = id");
|
||||
if (!result)
|
||||
{
|
||||
BarGoLink bar(1);
|
||||
|
|
@ -943,6 +968,8 @@ void MapPersistentStateManager::LoadCreatureRespawnTimes()
|
|||
|
||||
time_t resetTime = (time_t)fields[5].GetUInt64();
|
||||
|
||||
uint32 completedEncounters = fields[6].GetUInt32();
|
||||
|
||||
CreatureData const* data = sObjectMgr.GetCreatureData(loguid);
|
||||
if (!data)
|
||||
continue;
|
||||
|
|
@ -957,7 +984,7 @@ void MapPersistentStateManager::LoadCreatureRespawnTimes()
|
|||
if(difficulty >= (!mapEntry->Instanceable() ? REGULAR_DIFFICULTY : (mapEntry->IsRaid() ? MAX_RAID_DIFFICULTY : MAX_DUNGEON_DIFFICULTY)))
|
||||
continue;
|
||||
|
||||
MapPersistentState* state = AddPersistentState(mapEntry, instanceId, Difficulty(difficulty), resetTime, mapEntry->IsDungeon(), true);
|
||||
MapPersistentState* state = AddPersistentState(mapEntry, instanceId, Difficulty(difficulty), resetTime, mapEntry->IsDungeon(), true, true, completedEncounters);
|
||||
if (!state)
|
||||
continue;
|
||||
|
||||
|
|
@ -980,7 +1007,7 @@ void MapPersistentStateManager::LoadGameobjectRespawnTimes()
|
|||
|
||||
uint32 count = 0;
|
||||
|
||||
QueryResult *result = CharacterDatabase.Query("SELECT guid, respawntime, map, instance, difficulty, resettime FROM gameobject_respawn LEFT JOIN instance ON instance = id");
|
||||
QueryResult *result = CharacterDatabase.Query("SELECT guid, respawntime, map, instance, difficulty, resettime, encountersMask FROM gameobject_respawn LEFT JOIN instance ON instance = id");
|
||||
|
||||
if (!result)
|
||||
{
|
||||
|
|
@ -1008,6 +1035,8 @@ void MapPersistentStateManager::LoadGameobjectRespawnTimes()
|
|||
|
||||
time_t resetTime = (time_t)fields[5].GetUInt64();
|
||||
|
||||
uint32 completedEncounters = fields[6].GetUInt32();
|
||||
|
||||
GameObjectData const* data = sObjectMgr.GetGOData(loguid);
|
||||
if (!data)
|
||||
continue;
|
||||
|
|
@ -1022,7 +1051,7 @@ void MapPersistentStateManager::LoadGameobjectRespawnTimes()
|
|||
if(difficulty >= (!mapEntry->Instanceable() ? REGULAR_DIFFICULTY : (mapEntry->IsRaid() ? MAX_RAID_DIFFICULTY : MAX_DUNGEON_DIFFICULTY)))
|
||||
continue;
|
||||
|
||||
MapPersistentState* state = AddPersistentState(mapEntry, instanceId, Difficulty(difficulty), resetTime, mapEntry->IsDungeon(), true);
|
||||
MapPersistentState* state = AddPersistentState(mapEntry, instanceId, Difficulty(difficulty), resetTime, mapEntry->IsDungeon(), true, true, completedEncounters);
|
||||
if (!state)
|
||||
continue;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue