mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Conversation: Implemented conversation flags (#29552)
This commit is contained in:
1
sql/updates/world/master/2024_01_09_04_world.sql
Normal file
1
sql/updates/world/master/2024_01_09_04_world.sql
Normal file
@@ -0,0 +1 @@
|
||||
ALTER TABLE `conversation_template` ADD COLUMN `Flags` tinyint NOT NULL DEFAULT 0 AFTER `TextureKitId`;
|
||||
@@ -230,13 +230,17 @@ void Conversation::Create(ObjectGuid::LowType lowGuid, uint32 conversationEntry,
|
||||
|
||||
bool Conversation::Start()
|
||||
{
|
||||
for (UF::ConversationLine const& line : *m_conversationData->Lines)
|
||||
ConversationTemplate const* conversationTemplate = sConversationDataStore->GetConversationTemplate(GetEntry()); // never null, already checked in ::Create / ::CreateConversation
|
||||
if (!conversationTemplate->Flags.HasFlag(ConversationFlags::AllowWithoutSpawnedActor))
|
||||
{
|
||||
UF::ConversationActor const* actor = line.ActorIndex < m_conversationData->Actors.size() ? &m_conversationData->Actors[line.ActorIndex] : nullptr;
|
||||
if (!actor || (!actor->CreatureID && actor->ActorGUID.IsEmpty() && !actor->NoActorObject))
|
||||
for (UF::ConversationLine const& line : *m_conversationData->Lines)
|
||||
{
|
||||
TC_LOG_ERROR("entities.conversation", "Failed to create conversation (Id: {}) due to missing actor (Idx: {}).", GetEntry(), line.ActorIndex);
|
||||
return false;
|
||||
UF::ConversationActor const* actor = line.ActorIndex < m_conversationData->Actors.size() ? &m_conversationData->Actors[line.ActorIndex] : nullptr;
|
||||
if (!actor || (!actor->CreatureID && actor->ActorGUID.IsEmpty() && !actor->NoActorObject))
|
||||
{
|
||||
TC_LOG_ERROR("entities.conversation", "Failed to create conversation (Id: {}) due to missing actor (Idx: {}).", GetEntry(), line.ActorIndex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -212,7 +212,7 @@ void ConversationDataStore::LoadConversationTemplates()
|
||||
return lineId;
|
||||
};
|
||||
|
||||
if (QueryResult templates = WorldDatabase.Query("SELECT Id, FirstLineId, TextureKitId, ScriptName FROM conversation_template"))
|
||||
if (QueryResult templates = WorldDatabase.Query("SELECT Id, FirstLineId, TextureKitId, Flags, ScriptName FROM conversation_template"))
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
@@ -224,7 +224,8 @@ void ConversationDataStore::LoadConversationTemplates()
|
||||
conversationTemplate.Id = fields[0].GetUInt32();
|
||||
conversationTemplate.FirstLineId = fields[1].GetUInt32();
|
||||
conversationTemplate.TextureKitId = fields[2].GetUInt32();
|
||||
conversationTemplate.ScriptId = sObjectMgr->GetScriptId(fields[3].GetString());
|
||||
conversationTemplate.Flags = (ConversationFlags)fields[3].GetUInt8();
|
||||
conversationTemplate.ScriptId = sObjectMgr->GetScriptId(fields[4].GetString());
|
||||
|
||||
conversationTemplate.Actors = std::move(actorsByConversation[conversationTemplate.Id]);
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#define ConversationDataStore_h__
|
||||
|
||||
#include "Define.h"
|
||||
#include "EnumFlag.h"
|
||||
#include "ObjectGuid.h"
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
@@ -74,11 +75,22 @@ struct ConversationLineTemplate
|
||||
uint8 ChatType;
|
||||
};
|
||||
|
||||
enum class ConversationFlags : uint8
|
||||
{
|
||||
None = 0x00,
|
||||
MultipleConversationType = 0x01, // NYI purpose unknown
|
||||
IsTalkingHeadConversation = 0x02, // implicitly implemented when conversation_actors.ActivePlayerObject == 0 && conversation_actors.NoActorObject == 0 && conversation_actors.ConversationActorGuid == 0
|
||||
AllowWithoutSpawnedActor = 0x04,
|
||||
};
|
||||
|
||||
DEFINE_ENUM_FLAG(ConversationFlags);
|
||||
|
||||
struct ConversationTemplate
|
||||
{
|
||||
uint32 Id;
|
||||
uint32 FirstLineId; // Link to ConversationLine.db2
|
||||
uint32 TextureKitId; // Background texture
|
||||
EnumFlag<ConversationFlags> Flags = ConversationFlags::None;
|
||||
|
||||
std::vector<ConversationActorTemplate> Actors;
|
||||
std::vector<ConversationLineTemplate const*> Lines;
|
||||
|
||||
Reference in New Issue
Block a user