From 8465d95d9fababdd53568d4dab45964bab8a7aed Mon Sep 17 00:00:00 2001 From: NoFantasy Date: Mon, 8 Feb 2010 23:36:28 +0100 Subject: [PATCH] [9331] Implement DB storage of new quest fields RewRepValueIdN Value can be -9 to 9. Value point to actual rewarded value in dbc store. This id can then fully replace current use of RewRepValueN, as this field will most likely be reserved for custom reputation rewards (override RewRepValueId). Old system/DB data will still work like normal, but be aware this may change in not too far away future. Signed-off-by: NoFantasy --- sql/mangos.sql | 2 +- sql/updates/9331_01_mangos_quest_template.sql | 7 +++ sql/updates/Makefile.am | 2 + src/game/GossipDef.cpp | 37 ++++++++------- src/game/ObjectMgr.cpp | 36 +++++++-------- src/game/Player.cpp | 37 +++++++++++++-- src/game/QuestDef.cpp | 45 ++++++++++--------- src/game/QuestDef.h | 1 + src/shared/revision_nr.h | 2 +- src/shared/revision_sql.h | 2 +- 10 files changed, 109 insertions(+), 62 deletions(-) create mode 100644 sql/updates/9331_01_mangos_quest_template.sql diff --git a/sql/mangos.sql b/sql/mangos.sql index 51239692d..d98e5a7a3 100644 --- a/sql/mangos.sql +++ b/sql/mangos.sql @@ -24,7 +24,7 @@ CREATE TABLE `db_version` ( `version` varchar(120) default NULL, `creature_ai_version` varchar(120) default NULL, `cache_id` int(10) default '0', - `required_9329_01_mangos_spell_chain` bit(1) default NULL + `required_9331_01_mangos_quest_template` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes'; -- diff --git a/sql/updates/9331_01_mangos_quest_template.sql b/sql/updates/9331_01_mangos_quest_template.sql new file mode 100644 index 000000000..c775ebe8a --- /dev/null +++ b/sql/updates/9331_01_mangos_quest_template.sql @@ -0,0 +1,7 @@ +ALTER TABLE db_version CHANGE COLUMN required_9329_01_mangos_spell_chain required_9331_01_mangos_quest_template bit; + +ALTER TABLE quest_template ADD COLUMN RewRepValueId1 tinyint(3) NOT NULL default '0' AFTER RewRepFaction5; +ALTER TABLE quest_template ADD COLUMN RewRepValueId2 tinyint(3) NOT NULL default '0' AFTER RewRepValueId1; +ALTER TABLE quest_template ADD COLUMN RewRepValueId3 tinyint(3) NOT NULL default '0' AFTER RewRepValueId2; +ALTER TABLE quest_template ADD COLUMN RewRepValueId4 tinyint(3) NOT NULL default '0' AFTER RewRepValueId3; +ALTER TABLE quest_template ADD COLUMN RewRepValueId5 tinyint(3) NOT NULL default '0' AFTER RewRepValueId4; diff --git a/sql/updates/Makefile.am b/sql/updates/Makefile.am index 1b752beba..f081a73c5 100644 --- a/sql/updates/Makefile.am +++ b/sql/updates/Makefile.am @@ -264,6 +264,7 @@ pkgdata_DATA = \ 9310_01_mangos_spell_elixir.sql \ 9312_01_mangos_quest_template.sql \ 9329_01_mangos_spell_chain.sql \ + 9331_01_mangos_quest_template.sql \ README ## Additional files to include when running 'make dist' @@ -508,4 +509,5 @@ EXTRA_DIST = \ 9310_01_mangos_spell_elixir.sql \ 9312_01_mangos_quest_template.sql \ 9329_01_mangos_spell_chain.sql \ + 9331_01_mangos_quest_template.sql \ README diff --git a/src/game/GossipDef.cpp b/src/game/GossipDef.cpp index 33f857f58..a12353be1 100644 --- a/src/game/GossipDef.cpp +++ b/src/game/GossipDef.cpp @@ -537,14 +537,15 @@ void PlayerMenu::SendQuestGiverQuestDetails( Quest const *pQuest, uint64 npcGUID data << uint32(0); data << uint32(0); - for(int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) - data << uint32(0); + for(int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // reward factions ids + data << uint32(pQuest->RewRepFaction[i]); - for(int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) - data << uint32(0); + for(int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // columnid in QuestFactionReward.dbc (if negative, from second row) + data << int32(pQuest->RewRepValueId[i]); - for(int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) - data << uint32(0); + for(int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // reward reputation override. No bonus is expected given + data << int32(0); + //data << int32(pQuest->RewRepValue[i]); // current field for store of rep value, can be reused to implement "override value" data << uint32(QUEST_EMOTE_COUNT); @@ -660,14 +661,15 @@ void PlayerMenu::SendQuestQueryResponse( Quest const *pQuest ) } } - for(iI = 0; iI < QUEST_REPUTATIONS_COUNT; ++iI) // reward factions ids - data << uint32(0); + for(int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // reward factions ids + data << uint32(pQuest->RewRepFaction[i]); - for(iI = 0; iI < QUEST_REPUTATIONS_COUNT; ++iI) // column index in QuestFactionReward.dbc? - data << uint32(0); + for(int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // columnid in QuestFactionReward.dbc (if negative, from second row) + data << int32(pQuest->RewRepValueId[i]); - for(iI = 0; iI < QUEST_REPUTATIONS_COUNT; ++iI) // reward reputation override? - data << uint32(0); + for(int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // reward reputation override. No bonus is expected given + data << int32(0); + //data << int32(pQuest->RewRepValue[i]); // current field for store of rep value, can be reused to implement "override value" data << pQuest->GetPointMapId(); data << pQuest->GetPointX(); @@ -802,13 +804,14 @@ void PlayerMenu::SendQuestGiverOfferReward( Quest const* pQuest, uint64 npcGUID, data << uint32(0); // unknown for(int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // reward factions ids - data << uint32(0); + data << uint32(pQuest->RewRepFaction[i]); - for(int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // columnid in QuestFactionReward.dbc (zero based)? - data << uint32(0); + for(int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // columnid in QuestFactionReward.dbc (if negative, from second row) + data << int32(pQuest->RewRepValueId[i]); - for(int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // reward reputation override? - data << uint32(0); + for(int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // reward reputation override. No diplomacy bonus is expected given, reward also does not display in chat window + data << int32(0); + //data << int32(pQuest->RewRepValue[i]); pSession->SendPacket( &data ); sLog.outDebug( "WORLD: Sent SMSG_QUESTGIVER_OFFER_REWARD NPCGuid=%u, questid=%u", GUID_LOPART(npcGUID), pQuest->GetQuestId() ); diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 9a0bd5b5f..977a3d4e5 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -3326,19 +3326,23 @@ void ObjectMgr::LoadQuests() "RewChoiceItemCount1, RewChoiceItemCount2, RewChoiceItemCount3, RewChoiceItemCount4, RewChoiceItemCount5, RewChoiceItemCount6," // 85 86 87 88 89 90 91 92 "RewItemId1, RewItemId2, RewItemId3, RewItemId4, RewItemCount1, RewItemCount2, RewItemCount3, RewItemCount4," - // 93 94 95 96 97 98 99 100 101 102 - "RewRepFaction1, RewRepFaction2, RewRepFaction3, RewRepFaction4, RewRepFaction5, RewRepValue1, RewRepValue2, RewRepValue3, RewRepValue4, RewRepValue5," - // 103 104 105 106 107 108 + // 93 94 95 96 97 + "RewRepFaction1, RewRepFaction2, RewRepFaction3, RewRepFaction4, RewRepFaction5," + // 98 99 100 101 102 + "RewRepValueId1, RewRepValueId2, RewRepValueId3, RewRepValueId4, RewRepValueId5," + // 103 104 105 106 107 + "RewRepValue1, RewRepValue2, RewRepValue3, RewRepValue4, RewRepValue5," + // 108 109 110 111 112 113 "RewHonorAddition, RewHonorMultiplier, RewOrReqMoney, RewMoneyMaxLevel, RewSpell, RewSpellCast," - // 109 110 111 112 113 114 + // 114 115 116 117 118 119 "RewMailTemplateId, RewMailDelaySecs, PointMapId, PointX, PointY, PointOpt," - // 115 116 117 118 119 120 121 122 + // 120 121 122 123 124 125 126 127 "DetailsEmote1, DetailsEmote2, DetailsEmote3, DetailsEmote4, DetailsEmoteDelay1, DetailsEmoteDelay2, DetailsEmoteDelay3, DetailsEmoteDelay4," - // 123 124 125 126 127 128 + // 128 129 130 131 132 133 "IncompleteEmote, CompleteEmote, OfferRewardEmote1, OfferRewardEmote2, OfferRewardEmote3, OfferRewardEmote4," - // 129 130 131 132 + // 134 135 136 137 "OfferRewardEmoteDelay1, OfferRewardEmoteDelay2, OfferRewardEmoteDelay3, OfferRewardEmoteDelay4," - // 133 134 + // 138 139 "StartScript, CompleteScript" " FROM quest_template"); if(result == NULL) @@ -3787,23 +3791,19 @@ void ObjectMgr::LoadQuests() for(int j = 0; j < QUEST_REPUTATIONS_COUNT; ++j) { - if(qinfo->RewRepFaction[j]) + if (qinfo->RewRepFaction[j]) { - if(!qinfo->RewRepValue[j]) - { - sLog.outErrorDb("Quest %u has `RewRepFaction%d` = %u but `RewRepValue%d` = 0, quest will not reward this reputation.", - qinfo->GetQuestId(),j+1,qinfo->RewRepValue[j],j+1); - // no changes - } + if (abs(qinfo->RewRepValueId[j]) > 9) + sLog.outErrorDb("Quest %u has RewRepValueId%d = %i but value is not valid.", qinfo->GetQuestId(), j+1, qinfo->RewRepValueId[j]); - if(!sFactionStore.LookupEntry(qinfo->RewRepFaction[j])) + if (!sFactionStore.LookupEntry(qinfo->RewRepFaction[j])) { sLog.outErrorDb("Quest %u has `RewRepFaction%d` = %u but raw faction (faction.dbc) %u does not exist, quest will not reward reputation for this faction.", - qinfo->GetQuestId(),j+1,qinfo->RewRepFaction[j] ,qinfo->RewRepFaction[j] ); + qinfo->GetQuestId(),j+1,qinfo->RewRepFaction[j] ,qinfo->RewRepFaction[j]); qinfo->RewRepFaction[j] = 0; // quest will not reward this } } - else if(qinfo->RewRepValue[j]!=0) + else if (qinfo->RewRepValue[j] != 0) { sLog.outErrorDb("Quest %u has `RewRepFaction%d` = 0 but `RewRepValue%d` = %u.", qinfo->GetQuestId(),j+1,j+1,qinfo->RewRepValue[j]); diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 5f6d7fadd..b3991c2cc 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -6047,13 +6047,44 @@ void Player::RewardReputation(Quest const *pQuest) // quest reputation reward/loss for(int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) { - if(pQuest->RewRepFaction[i] && pQuest->RewRepValue[i] ) + if (!pQuest->RewRepFaction[i]) + continue; + + // For future, this row should be used as "override". Example quests are 10298 and 10870. + // Typically, no diplomacy mod must apply to the final value (flat). Note the formula must be (finalValue = DBvalue/100) + if (pQuest->RewRepValue[i]) { int32 rep = CalculateReputationGain(GetQuestLevelForPlayer(pQuest), pQuest->RewRepValue[i], pQuest->RewRepFaction[i], true); - FactionEntry const* factionEntry = sFactionStore.LookupEntry(pQuest->RewRepFaction[i]); - if(factionEntry) + + if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(pQuest->RewRepFaction[i])) GetReputationMgr().ModifyReputation(factionEntry, rep); } + else + { + uint32 row = 1; + int32 field = 0; + + if (pQuest->RewRepValueId[i] < 0) + { + ++row; + field = abs(pQuest->RewRepValueId[i]); + } + else + field = pQuest->RewRepValueId[i]; + + if (const QuestFactionRewardEntry *pRow = sQuestFactionRewardStore.LookupEntry(row)) + { + int32 repPoints = pRow->rewardValue[field]; + + if (!repPoints) + continue; + + repPoints = CalculateReputationGain(GetQuestLevelForPlayer(pQuest), repPoints, pQuest->RewRepFaction[i], true); + + if (const FactionEntry* factionEntry = sFactionStore.LookupEntry(pQuest->RewRepFaction[i])) + GetReputationMgr().ModifyReputation(factionEntry, repPoints); + } + } } // TODO: implement reputation spillover diff --git a/src/game/QuestDef.cpp b/src/game/QuestDef.cpp index b7f49b637..ff379a19e 100644 --- a/src/game/QuestDef.cpp +++ b/src/game/QuestDef.cpp @@ -100,38 +100,41 @@ Quest::Quest(Field * questRecord) RewRepFaction[i] = questRecord[93+i].GetUInt32(); for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) - RewRepValue[i] = questRecord[98+i].GetInt32(); + RewRepValueId[i] = questRecord[98+i].GetInt32(); - RewHonorAddition = questRecord[103].GetUInt32(); - RewHonorMultiplier = questRecord[104].GetFloat(); - RewOrReqMoney = questRecord[105].GetInt32(); - RewMoneyMaxLevel = questRecord[106].GetUInt32(); - RewSpell = questRecord[107].GetUInt32(); - RewSpellCast = questRecord[108].GetUInt32(); - RewMailTemplateId = questRecord[109].GetUInt32(); - RewMailDelaySecs = questRecord[110].GetUInt32(); - PointMapId = questRecord[111].GetUInt32(); - PointX = questRecord[112].GetFloat(); - PointY = questRecord[113].GetFloat(); - PointOpt = questRecord[114].GetUInt32(); + for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) + RewRepValue[i] = questRecord[103+i].GetInt32(); + + RewHonorAddition = questRecord[108].GetUInt32(); + RewHonorMultiplier = questRecord[109].GetFloat(); + RewOrReqMoney = questRecord[110].GetInt32(); + RewMoneyMaxLevel = questRecord[111].GetUInt32(); + RewSpell = questRecord[112].GetUInt32(); + RewSpellCast = questRecord[113].GetUInt32(); + RewMailTemplateId = questRecord[114].GetUInt32(); + RewMailDelaySecs = questRecord[115].GetUInt32(); + PointMapId = questRecord[116].GetUInt32(); + PointX = questRecord[117].GetFloat(); + PointY = questRecord[118].GetFloat(); + PointOpt = questRecord[119].GetUInt32(); for (int i = 0; i < QUEST_EMOTE_COUNT; ++i) - DetailsEmote[i] = questRecord[115+i].GetUInt32(); + DetailsEmote[i] = questRecord[120+i].GetUInt32(); for (int i = 0; i < QUEST_EMOTE_COUNT; ++i) - DetailsEmoteDelay[i] = questRecord[119+i].GetUInt32(); + DetailsEmoteDelay[i] = questRecord[124+i].GetUInt32(); - IncompleteEmote = questRecord[123].GetUInt32(); - CompleteEmote = questRecord[124].GetUInt32(); + IncompleteEmote = questRecord[128].GetUInt32(); + CompleteEmote = questRecord[129].GetUInt32(); for (int i = 0; i < QUEST_EMOTE_COUNT; ++i) - OfferRewardEmote[i] = questRecord[125+i].GetInt32(); + OfferRewardEmote[i] = questRecord[130+i].GetInt32(); for (int i = 0; i < QUEST_EMOTE_COUNT; ++i) - OfferRewardEmoteDelay[i] = questRecord[129+i].GetInt32(); + OfferRewardEmoteDelay[i] = questRecord[134+i].GetInt32(); - QuestStartScript = questRecord[133].GetUInt32(); - QuestCompleteScript = questRecord[134].GetUInt32(); + QuestStartScript = questRecord[138].GetUInt32(); + QuestCompleteScript = questRecord[139].GetUInt32(); QuestFlags |= SpecialFlags << 24; diff --git a/src/game/QuestDef.h b/src/game/QuestDef.h index a10188f06..9a042ba3f 100644 --- a/src/game/QuestDef.h +++ b/src/game/QuestDef.h @@ -254,6 +254,7 @@ class Quest uint32 RewItemId[QUEST_REWARDS_COUNT]; uint32 RewItemCount[QUEST_REWARDS_COUNT]; uint32 RewRepFaction[QUEST_REPUTATIONS_COUNT]; + int32 RewRepValueId[QUEST_REPUTATIONS_COUNT]; int32 RewRepValue[QUEST_REPUTATIONS_COUNT]; uint32 DetailsEmote[QUEST_EMOTE_COUNT]; uint32 DetailsEmoteDelay[QUEST_EMOTE_COUNT]; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index a5ae479d9..3cfc37817 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "9330" + #define REVISION_NR "9331" #endif // __REVISION_NR_H__ diff --git a/src/shared/revision_sql.h b/src/shared/revision_sql.h index 562ad87be..5cd449764 100644 --- a/src/shared/revision_sql.h +++ b/src/shared/revision_sql.h @@ -1,6 +1,6 @@ #ifndef __REVISION_SQL_H__ #define __REVISION_SQL_H__ #define REVISION_DB_CHARACTERS "required_9250_01_characters_character" - #define REVISION_DB_MANGOS "required_9329_01_mangos_spell_chain" + #define REVISION_DB_MANGOS "required_9331_01_mangos_quest_template" #define REVISION_DB_REALMD "required_9010_01_realmd_realmlist" #endif // __REVISION_SQL_H__