mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 15:40:45 +01:00
Core/Instances: Implemented DungeonEncounter.dbc for creating completed encounters mask to use in packets
Core/Dungeon Finder: Implemented new way of giving random dungeon rewards, linked to DungeonEncounter.dbc
This commit is contained in:
@@ -24,14 +24,19 @@
|
||||
#include "Creature.h"
|
||||
#include "CreatureAI.h"
|
||||
#include "Log.h"
|
||||
#include "LFGMgr.h"
|
||||
|
||||
void InstanceScript::SaveToDB()
|
||||
{
|
||||
std::string data = GetSaveData();
|
||||
if (data.empty())
|
||||
return;
|
||||
CharacterDatabase.escape_string(data);
|
||||
CharacterDatabase.PExecute("UPDATE instance SET data = '%s' WHERE id = '%d'", data.c_str(), instance->GetInstanceId());
|
||||
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPDATE_INSTANCE_DATA);
|
||||
stmt->setUInt32(0, GetCompletedEncounterMask());
|
||||
stmt->setString(1, data);
|
||||
stmt->setUInt32(2, instance->GetInstanceId());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
void InstanceScript::HandleGameObject(uint64 GUID, bool open, GameObject *go)
|
||||
@@ -427,3 +432,29 @@ void InstanceScript::SendEncounterUnit(uint32 type, Unit* unit /*= NULL*/, uint8
|
||||
|
||||
instance->SendToPlayers(&data);
|
||||
}
|
||||
|
||||
void InstanceScript::UpdateEncounterState(EncounterCreditType type, uint32 creditEntry, Unit* source)
|
||||
{
|
||||
DungeonEncounterList const* encounters = sObjectMgr->GetDungeonEncounterList(instance->GetId(), instance->GetDifficulty());
|
||||
if (!encounters)
|
||||
return;
|
||||
|
||||
for (DungeonEncounterList::const_iterator itr = encounters->begin(); itr != encounters->end(); ++itr)
|
||||
{
|
||||
if ((*itr)->creditType == type && (*itr)->creditEntry == creditEntry)
|
||||
{
|
||||
completedEncounters |= 1 << (*itr)->dbcEntry->encounterIndex;
|
||||
sLog->outDebug("Instance %s (instanceId %u) completed encounter %s", instance->GetMapName(), instance->GetInstanceId(), (*itr)->dbcEntry->encounterName[0]);
|
||||
if (uint32 dungeonId = (*itr)->lastEncounterDungeon)
|
||||
{
|
||||
Map::PlayerList const& players = instance->GetPlayers();
|
||||
if (!players.isEmpty())
|
||||
for (Map::PlayerList::const_iterator i = players.begin(); i != players.end(); ++i)
|
||||
if (Player* player = i->getSource())
|
||||
if (!source || player->IsAtGroupRewardDistance(source))
|
||||
sLFGMgr->RewardDungeonDoneFor(dungeonId, player);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user