diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/server/game/Globals/ConversationDataStore.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/server/game/Globals/ConversationDataStore.cpp b/src/server/game/Globals/ConversationDataStore.cpp index 68a3b74cf65..dff5e3d919b 100644 --- a/src/server/game/Globals/ConversationDataStore.cpp +++ b/src/server/game/Globals/ConversationDataStore.cpp @@ -198,11 +198,27 @@ void ConversationDataStore::LoadConversationTemplates() TC_LOG_INFO("server.loading", ">> Loaded 0 Conversation actors. DB table `conversation_actors` is empty."); } + // TODO: Remove this hack when NextConversationLineID is changed to uint32 + auto getNextConversationLineId = [&](ConversationLineEntry const* conversationLine) + { + if (conversationLine && conversationLine->NextConversationLineID) + { + static constexpr uint32 FirstLineId = 60000; // Arbitrary id to cover the affected rows + + if (conversationLine->ID > FirstLineId && conversationLine->NextConversationLineID < (sConversationLineStore.GetNumRows() - USHRT_MAX - 1)) + return (uint32)(USHRT_MAX + conversationLine->NextConversationLineID + 1); + + return (uint32)conversationLine->NextConversationLineID; + } + + return 0u; + }; + // Validate FirstLineId std::unordered_map<uint32, uint32> prevConversationLineIds; for (ConversationLineEntry const* conversationLine : sConversationLineStore) - if (conversationLine->NextConversationLineID) - prevConversationLineIds[conversationLine->NextConversationLineID] = conversationLine->ID; + if (uint32 nextConversationLineId = getNextConversationLineId(conversationLine)) + prevConversationLineIds[nextConversationLineId] = conversationLine->ID; auto getFirstLineIdFromAnyLineId = [&](uint32 lineId) { @@ -248,10 +264,11 @@ void ConversationDataStore::LoadConversationTemplates() else TC_LOG_ERROR("sql.sql", "Table `conversation_line_template` has missing template for line (ID: {}) in Conversation {}, skipped", currentConversationLine->ID, conversationTemplate.Id); - if (!currentConversationLine->NextConversationLineID) + uint32 nextConversationLineId = getNextConversationLineId(currentConversationLine); + if (!nextConversationLineId) break; - currentConversationLine = sConversationLineStore.AssertEntry(currentConversationLine->NextConversationLineID); + currentConversationLine = sConversationLineStore.AssertEntry(nextConversationLineId); } _conversationTemplateStore[conversationTemplate.Id] = std::move(conversationTemplate); |
