aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorOvahlord <dreadkiller@gmx.de>2023-11-16 12:49:49 +0100
committerOvahlord <dreadkiller@gmx.de>2023-11-16 12:49:49 +0100
commitfae00e6f17965ab4f92cd6d1f6051f49001cbe29 (patch)
tree3f24bab1278a7b0370dab575b0483d774da5bafa /src
parentfcc4d921dcd739aab910e5c4ff1b6ba6ddeb558d (diff)
Core/Quests: fixed structure of SMSG_QUERY_QUEST_INFO_RESPONSE and downgraded LoadRewardDisplaySpell handling
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/Player/Player.cpp10
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp4
-rw-r--r--src/server/game/Quests/QuestDef.cpp54
-rw-r--r--src/server/game/Quests/QuestDef.h13
-rw-r--r--src/server/game/Server/Packets/QuestPackets.cpp26
-rw-r--r--src/server/game/Server/Packets/QuestPackets.h11
-rw-r--r--src/server/game/Server/Protocol/Opcodes.cpp2
7 files changed, 22 insertions, 98 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 46554a6f506..dfcc972ad22 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -14690,13 +14690,9 @@ void Player::RewardQuest(Quest const* quest, LootItemType rewardType, uint32 rew
}
else
{
- for (QuestRewardDisplaySpell displaySpell : quest->RewardDisplaySpell)
+ for (int32 displaySpell : quest->RewardDisplaySpell)
{
- if (PlayerConditionEntry const* playerCondition = sPlayerConditionStore.LookupEntry(displaySpell.PlayerConditionId))
- if (!ConditionMgr::IsPlayerMeetingCondition(this, playerCondition))
- continue;
-
- SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(displaySpell.SpellId, GetMap()->GetDifficultyID());
+ SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(displaySpell, GetMap()->GetDifficultyID());
Unit* caster = this;
if (questGiver && questGiver->isType(TYPEMASK_UNIT) && !quest->HasFlag(QUEST_FLAGS_PLAYER_CAST_COMPLETE) && !spellInfo->HasTargetType(TARGET_UNIT_CASTER))
if (Unit* unit = questGiver->ToUnit())
@@ -20257,7 +20253,7 @@ void Player::_SaveStats(CharacterDatabaseTransaction trans) const
stmt->setFloat(index++, m_activePlayerData->ParryPercentage);
stmt->setFloat(index++, m_activePlayerData->CritPercentage);
stmt->setFloat(index++, m_activePlayerData->RangedCritPercentage);
- stmt->setFloat(index++, m_activePlayerData->SpellCritPercentage[0]); // @todo (3.4.3): in wotlk spell crit percentage was split by spell school
+ stmt->setFloat(index++, 0.f); // m_activePlayerData->SpellCritPercentage// @todo (3.4.3): in wotlk spell crit percentage was split by spell school
stmt->setUInt32(index++, m_unitData->AttackPower);
stmt->setUInt32(index++, m_unitData->RangedAttackPower);
stmt->setUInt32(index++, GetBaseSpellPowerBonus());
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index 7fa2f56f1fb..a84cc92e4aa 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -4547,8 +4547,8 @@ void ObjectMgr::LoadQuests()
// 0 1 2 3 4 5 6
{ "QuestID, Type1, Type2, Type3, Type4, Type5, Type6", "quest_reward_choice_items", "", "reward choice items", &Quest::LoadRewardChoiceItems },
- // 0 1 2 3
- { "QuestID, SpellID, PlayerConditionID, Type", "quest_reward_display_spell", "ORDER BY QuestID ASC, Idx ASC", "reward display spells", &Quest::LoadRewardDisplaySpell },
+ // 0 1 2
+ { "QuestID, SpellID, Idx", "quest_reward_display_spell", "ORDER BY QuestID ASC, Idx ASC", "reward display spells", &Quest::LoadRewardDisplaySpell },
// 0 1 2 3 4 5 6 7 8
{ "ID, Emote1, Emote2, Emote3, Emote4, EmoteDelay1, EmoteDelay2, EmoteDelay3, EmoteDelay4", "quest_details", "", "details", &Quest::LoadQuestDetails },
diff --git a/src/server/game/Quests/QuestDef.cpp b/src/server/game/Quests/QuestDef.cpp
index c8e27e41795..fa219749f9b 100644
--- a/src/server/game/Quests/QuestDef.cpp
+++ b/src/server/game/Quests/QuestDef.cpp
@@ -143,28 +143,21 @@ Quest::~Quest()
void Quest::LoadRewardDisplaySpell(Field* fields)
{
uint32 spellId = fields[1].GetUInt32();
- uint32 playerConditionId = fields[2].GetUInt32();
- uint32 type = fields[3].GetUInt32();
+ uint32 idx = fields[2].GetUInt32();
- if (!sSpellMgr->GetSpellInfo(spellId, DIFFICULTY_NONE))
+ if (idx >= QUEST_REWARD_DISPLAY_SPELL_COUNT)
{
- TC_LOG_ERROR("sql.sql", "Table `quest_reward_display_spell` has non-existing Spell ({}) set for quest {}. Skipped.", spellId, fields[0].GetUInt32());
+ TC_LOG_ERROR("sql.sql", "Table `quest_reward_display_spell` has a Spell ({}) set for quest {} at Index {} which is out of bounds. Skipped.", spellId, fields[0].GetUInt32(), idx);
return;
}
- if (playerConditionId && !sPlayerConditionStore.LookupEntry(playerConditionId))
- {
- TC_LOG_ERROR("sql.sql", "Table `quest_reward_display_spell` has non-existing PlayerCondition ({}) set for quest {} and spell {}. Set to 0.", playerConditionId, fields[0].GetUInt32(), spellId);
- playerConditionId = 0;
- }
-
- if (type >= AsUnderlyingType(QuestCompleteSpellType::Max))
+ if (!sSpellMgr->GetSpellInfo(spellId, DIFFICULTY_NONE))
{
- TC_LOG_ERROR("sql.sql", "Table `quest_reward_display_spell` invalid type value ({}) set for quest {} and spell {}. Set to 0.", type, fields[0].GetUInt32(), spellId);
- type = AsUnderlyingType(QuestCompleteSpellType::LegacyBehavior);
+ TC_LOG_ERROR("sql.sql", "Table `quest_reward_display_spell` has non-existing Spell ({}) set for quest {}. Skipped.", spellId, fields[0].GetUInt32());
+ return;
}
- RewardDisplaySpell.emplace_back(spellId, playerConditionId, QuestCompleteSpellType(type));
+ RewardDisplaySpell[idx] = spellId;
}
void Quest::LoadRewardChoiceItems(Field* fields)
@@ -461,17 +454,7 @@ void Quest::BuildQuestRewards(WorldPackets::Quest::QuestRewards& rewards, Player
rewards.ArtifactCategoryID = GetArtifactCategoryId();
rewards.Title = GetRewTitle();
rewards.FactionFlags = GetRewardReputationMask();
- auto displaySpellItr = rewards.SpellCompletionDisplayID.begin();
- for (QuestRewardDisplaySpell displaySpell : RewardDisplaySpell)
- {
- if (PlayerConditionEntry const* playerCondition = sPlayerConditionStore.LookupEntry(displaySpell.PlayerConditionId))
- if (!ConditionMgr::IsPlayerMeetingCondition(player, playerCondition))
- continue;
-
- *displaySpellItr = displaySpell.SpellId;
- if (++displaySpellItr == rewards.SpellCompletionDisplayID.end())
- break;
- }
+ rewards.SpellCompletionDisplayID = RewardDisplaySpell;
rewards.SpellCompletionID = GetRewSpell();
rewards.SkillLineID = GetRewardSkillId();
@@ -601,19 +584,6 @@ WorldPacket Quest::BuildQueryData(LocaleConstant loc, Player* player) const
response.Info.PortraitGiverName = GetPortraitGiverName();
response.Info.PortraitTurnInText = GetPortraitTurnInText();
response.Info.PortraitTurnInName = GetPortraitTurnInName();
- std::transform(GetConditionalQuestDescription().begin(), GetConditionalQuestDescription().end(), std::back_inserter(response.Info.ConditionalQuestDescription), [loc](QuestConditionalText const& text)
- {
- std::string_view content = text.Text[LOCALE_enUS];
- ObjectMgr::GetLocaleString(text.Text, loc, content);
- return WorldPackets::Quest::ConditionalQuestText { text.PlayerConditionId, text.QuestgiverCreatureId, content };
- });
-
- std::transform(GetConditionalQuestCompletionLog().begin(), GetConditionalQuestCompletionLog().end(), std::back_inserter(response.Info.ConditionalQuestCompletionLog), [loc](QuestConditionalText const& text)
- {
- std::string_view content = text.Text[LOCALE_enUS];
- ObjectMgr::GetLocaleString(text.Text, loc, content);
- return WorldPackets::Quest::ConditionalQuestText { text.PlayerConditionId, text.QuestgiverCreatureId, content };
- });
if (loc != LOCALE_enUS)
{
@@ -651,13 +621,7 @@ WorldPacket Quest::BuildQueryData(LocaleConstant loc, Player* player) const
response.Info.RewardMoneyDifficulty = GetRewMoneyDifficulty();
response.Info.RewardMoneyMultiplier = GetMoneyMultiplier();
response.Info.RewardBonusMoney = GetRewMoneyMaxLevel();
- for (QuestRewardDisplaySpell displaySpell : RewardDisplaySpell)
- {
- WorldPackets::Quest::QuestCompleteDisplaySpell& rewardDisplaySpell = response.Info.RewardDisplaySpell.emplace_back();
- rewardDisplaySpell.SpellID = displaySpell.SpellId;
- rewardDisplaySpell.PlayerConditionID = displaySpell.PlayerConditionId;
- rewardDisplaySpell.Type = int32(displaySpell.Type);
- }
+ response.Info.RewardDisplaySpell = RewardDisplaySpell;
response.Info.RewardSpell = GetRewSpell();
diff --git a/src/server/game/Quests/QuestDef.h b/src/server/game/Quests/QuestDef.h
index 0b327d31cd8..aa21e861ba3 100644
--- a/src/server/game/Quests/QuestDef.h
+++ b/src/server/game/Quests/QuestDef.h
@@ -44,6 +44,7 @@ namespace WorldPackets
#define QUEST_ITEM_DROP_COUNT 4
#define QUEST_REWARD_CHOICES_COUNT 6
+#define QUEST_REWARD_DISPLAY_SPELL_COUNT 3
#define QUEST_REWARD_ITEM_COUNT 4
#define QUEST_DEPLINK_COUNT 10
#define QUEST_REWARD_REPUTATIONS_COUNT 5
@@ -507,16 +508,6 @@ struct QuestObjective
using QuestObjectives = std::vector<QuestObjective>;
-struct QuestRewardDisplaySpell
-{
- QuestRewardDisplaySpell() : SpellId(0), PlayerConditionId(0), Type(QuestCompleteSpellType::LegacyBehavior) { }
- QuestRewardDisplaySpell(uint32 spellId, uint32 playerConditionId, QuestCompleteSpellType type) : SpellId(spellId), PlayerConditionId(playerConditionId), Type(type) { }
-
- uint32 SpellId;
- uint32 PlayerConditionId;
- QuestCompleteSpellType Type;
-};
-
struct QuestConditionalText
{
int32 PlayerConditionId = 0;
@@ -677,7 +668,7 @@ class TC_GAME_API Quest
bool CanIncreaseRewardedQuestCounters() const;
// multiple values
- std::vector<QuestRewardDisplaySpell> RewardDisplaySpell;
+ std::array<int32, QUEST_REWARD_DISPLAY_SPELL_COUNT> RewardDisplaySpell = { };
std::array<uint32, QUEST_REWARD_ITEM_COUNT> RewardItemId = { };
std::array<uint32, QUEST_REWARD_ITEM_COUNT> RewardItemCount = { };
std::array<uint32, QUEST_ITEM_DROP_COUNT> ItemDrop = { };
diff --git a/src/server/game/Server/Packets/QuestPackets.cpp b/src/server/game/Server/Packets/QuestPackets.cpp
index e8617fd1a8e..8968af8f890 100644
--- a/src/server/game/Server/Packets/QuestPackets.cpp
+++ b/src/server/game/Server/Packets/QuestPackets.cpp
@@ -20,15 +20,6 @@
namespace WorldPackets::Quest
{
-ByteBuffer& operator<<(ByteBuffer& data, QuestCompleteDisplaySpell const& questDisplaySpell)
-{
- data << int32(questDisplaySpell.SpellID);
- data << int32(questDisplaySpell.PlayerConditionID);
- data << int32(questDisplaySpell.Type);
-
- return data;
-}
-
ByteBuffer& operator<<(ByteBuffer& data, ConditionalQuestText const& conditionalQuestText)
{
data << int32(conditionalQuestText.PlayerConditionID);
@@ -119,7 +110,10 @@ WorldPacket const* QueryQuestInfoResponse::Write()
_worldPacket << int32(Info.RewardMoneyDifficulty);
_worldPacket << float(Info.RewardMoneyMultiplier);
_worldPacket << int32(Info.RewardBonusMoney);
- _worldPacket << uint32(Info.RewardDisplaySpell.size());
+
+ for (int32& rewardDisplaySpell : Info.RewardDisplaySpell)
+ _worldPacket << int32(rewardDisplaySpell);
+
_worldPacket << int32(Info.RewardSpell);
_worldPacket << int32(Info.RewardHonor);
_worldPacket << float(Info.RewardKillHonor);
@@ -191,12 +185,6 @@ WorldPacket const* QueryQuestInfoResponse::Write()
_worldPacket << int32(Info.QuestSessionBonus);
_worldPacket << int32(Info.QuestGiverCreatureID);
- _worldPacket << uint32(Info.ConditionalQuestDescription.size());
- _worldPacket << uint32(Info.ConditionalQuestCompletionLog.size());
-
- for (QuestCompleteDisplaySpell const& rewardDisplaySpell : Info.RewardDisplaySpell)
- _worldPacket << rewardDisplaySpell;
-
_worldPacket.WriteBits(Info.LogTitle.size(), 9);
_worldPacket.WriteBits(Info.LogDescription.size(), 12);
_worldPacket.WriteBits(Info.QuestDescription.size(), 12);
@@ -239,12 +227,6 @@ WorldPacket const* QueryQuestInfoResponse::Write()
_worldPacket.WriteString(Info.PortraitTurnInText);
_worldPacket.WriteString(Info.PortraitTurnInName);
_worldPacket.WriteString(Info.QuestCompletionLog);
-
- for (ConditionalQuestText const& conditionalQuestText : Info.ConditionalQuestDescription)
- _worldPacket << conditionalQuestText;
-
- for (ConditionalQuestText const& conditionalQuestText : Info.ConditionalQuestCompletionLog)
- _worldPacket << conditionalQuestText;
}
return &_worldPacket;
diff --git a/src/server/game/Server/Packets/QuestPackets.h b/src/server/game/Server/Packets/QuestPackets.h
index b488fe06d7e..7c7426cafdd 100644
--- a/src/server/game/Server/Packets/QuestPackets.h
+++ b/src/server/game/Server/Packets/QuestPackets.h
@@ -117,13 +117,6 @@ namespace WorldPackets
int32 DisplayID = 0;
};
- struct QuestCompleteDisplaySpell
- {
- int32 SpellID = 0;
- int32 PlayerConditionID = 0;
- int32 Type = 0;
- };
-
struct ConditionalQuestText
{
int32 PlayerConditionID = 0;
@@ -150,7 +143,7 @@ namespace WorldPackets
int32 RewardMoneyDifficulty = 0;
float RewardMoneyMultiplier = 1.0f;
int32 RewardBonusMoney = 0;
- std::vector<QuestCompleteDisplaySpell> RewardDisplaySpell; // reward spell, this spell will be displayed (icon)
+ std::array<int32, QUEST_REWARD_DISPLAY_SPELL_COUNT> RewardDisplaySpell = { }; // reward spell, this spell will be displayed (icon)
int32 RewardSpell = 0;
int32 RewardHonor = 0;
float RewardKillHonor = 0.0f;
@@ -194,8 +187,6 @@ namespace WorldPackets
int32 QuestSessionBonus = 0;
int32 QuestGiverCreatureID = 0; // used to select ConditionalQuestText
std::vector<QuestObjective> Objectives;
- std::vector<ConditionalQuestText> ConditionalQuestDescription;
- std::vector<ConditionalQuestText> ConditionalQuestCompletionLog;
int32 RewardItems[QUEST_REWARD_ITEM_COUNT] = { };
int32 RewardAmount[QUEST_REWARD_ITEM_COUNT] = { };
int32 ItemDrop[QUEST_ITEM_DROP_COUNT] = { };
diff --git a/src/server/game/Server/Protocol/Opcodes.cpp b/src/server/game/Server/Protocol/Opcodes.cpp
index 38ad59d1f4c..678f1c55ec9 100644
--- a/src/server/game/Server/Protocol/Opcodes.cpp
+++ b/src/server/game/Server/Protocol/Opcodes.cpp
@@ -1941,7 +1941,7 @@ void OpcodeTable::Initialize()
DEFINE_SERVER_OPCODE_HANDLER(SMSG_QUERY_PET_NAME_RESPONSE, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_QUERY_PLAYER_NAME_BY_COMMUNITY_ID_RESPONSE, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_QUERY_PLAYER_NAMES_RESPONSE, STATUS_NEVER, CONNECTION_TYPE_REALM);
- DEFINE_SERVER_OPCODE_HANDLER(SMSG_QUERY_QUEST_INFO_RESPONSE, STATUS_UNHANDLED, CONNECTION_TYPE_INSTANCE);
+ DEFINE_SERVER_OPCODE_HANDLER(SMSG_QUERY_QUEST_INFO_RESPONSE, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_QUERY_REALM_GUILD_MASTER_INFO_RESPONSE, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_QUERY_TIME_RESPONSE, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_QUEST_COMPLETION_NPC_RESPONSE, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);