Skip to content

Commit

Permalink
Core/Conditions: Added conversation line source type (TrinityCore#27167)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdX7 authored Oct 25, 2021
1 parent f91faa1 commit 03c0f78
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/server/game/Conditions/ConditionMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "AreaTrigger.h"
#include "AreaTriggerDataStore.h"
#include "Containers.h"
#include "ConversationDataStore.h"
#include "DatabaseEnv.h"
#include "DB2Stores.h"
#include "GameEventMgr.h"
Expand Down Expand Up @@ -79,6 +80,7 @@ char const* const ConditionMgr::StaticSourceTypeData[CONDITION_SOURCE_TYPE_MAX]
"Phase",
"Graveyard",
"AreaTrigger",
"ConversationLine"
};

ConditionMgr::ConditionTypeInfo const ConditionMgr::StaticConditionTypeData[CONDITION_MAX] =
Expand Down Expand Up @@ -1915,6 +1917,13 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond) const
return false;
}
break;
case CONDITION_SOURCE_TYPE_CONVERSATION_LINE:
if (!sConversationDataStore->GetConversationLineTemplate(cond->SourceEntry))
{
TC_LOG_ERROR("sql.sql", "%s does not exist in `conversation_line_template`, ignoring.", cond->ToString().c_str());
return false;
}
break;
default:
TC_LOG_ERROR("sql.sql", "%s Invalid ConditionSourceType in `condition` table, ignoring.", cond->ToString().c_str());
return false;
Expand Down
3 changes: 2 additions & 1 deletion src/server/game/Conditions/ConditionMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ enum ConditionSourceType
CONDITION_SOURCE_TYPE_PHASE = 26,
CONDITION_SOURCE_TYPE_GRAVEYARD = 27,
CONDITION_SOURCE_TYPE_AREATRIGGER = 28,
CONDITION_SOURCE_TYPE_MAX = 29 // MAX
CONDITION_SOURCE_TYPE_CONVERSATION_LINE = 29,
CONDITION_SOURCE_TYPE_MAX = 30 // MAX
};

enum RelationType
Expand Down
4 changes: 4 additions & 0 deletions src/server/game/Entities/Conversation/Conversation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

#include "Conversation.h"
#include "ConditionMgr.h"
#include "ConversationDataStore.h"
#include "Creature.h"
#include "IteratorPair.h"
Expand Down Expand Up @@ -152,6 +153,9 @@ bool Conversation::Create(ObjectGuid::LowType lowGuid, uint32 conversationEntry,
std::vector<UF::ConversationLine> lines;
for (ConversationLineTemplate const* line : conversationTemplate->Lines)
{
if (!sConditionMgr->IsObjectMeetingNotGroupedConditions(CONDITION_SOURCE_TYPE_CONVERSATION_LINE, line->Id, creator))
continue;

actorIndices.insert(line->ActorIdx);
lines.emplace_back();
UF::ConversationLine& lineField = lines.back();
Expand Down
5 changes: 5 additions & 0 deletions src/server/game/Globals/ConversationDataStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@ ConversationTemplate const* ConversationDataStore::GetConversationTemplate(uint3
return Trinity::Containers::MapGetValuePtr(_conversationTemplateStore, conversationId);
}

ConversationLineTemplate const* ConversationDataStore::GetConversationLineTemplate(uint32 conversationLineId) const
{
return Trinity::Containers::MapGetValuePtr(_conversationLineTemplateStore, conversationLineId);
}

ConversationDataStore* ConversationDataStore::Instance()
{
static ConversationDataStore instance;
Expand Down
1 change: 1 addition & 0 deletions src/server/game/Globals/ConversationDataStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class TC_GAME_API ConversationDataStore
void LoadConversationTemplates();

ConversationTemplate const* GetConversationTemplate(uint32 conversationId) const;
ConversationLineTemplate const* GetConversationLineTemplate(uint32 conversationLineId) const;

static ConversationDataStore* Instance();
};
Expand Down

0 comments on commit 03c0f78

Please sign in to comment.