Skip to content

Commit

Permalink
[13965] Add questgiver_greeting and locales to properly handle SMSG_Q…
Browse files Browse the repository at this point in the history
…UESTGIVER_QUEST_LIST

TODO: Remove npc_gossip
  • Loading branch information
killerwife committed Sep 10, 2017
1 parent 5808b86 commit 40ae84a
Show file tree
Hide file tree
Showing 10 changed files with 327 additions and 35 deletions.
35 changes: 34 additions & 1 deletion sql/base/mangos.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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_13964_01_mangos_comments` bit(1) DEFAULT NULL
`required_13965_01_mangos_questgiver_greeting` bit(1) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Used DB version notes';

--
Expand Down Expand Up @@ -3857,6 +3857,25 @@ LOCK TABLES `locales_quest` WRITE;
/*!40000 ALTER TABLE `locales_quest` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `locales_questgiver_greeting`
--

DROP TABLE IF EXISTS `locales_questgiver_greeting`;
CREATE TABLE `locales_questgiver_greeting` (
`Entry` INT(11) UNSIGNED NOT NULL COMMENT 'Entry of Questgiver',
`Type` INT(11) UNSIGNED NOT NULL COMMENT 'Type of entry',
`Text_loc1` LONGTEXT COMMENT 'Text of the greeting locale 1',
`Text_loc2` LONGTEXT COMMENT 'Text of the greeting locale 2',
`Text_loc3` LONGTEXT COMMENT 'Text of the greeting locale 3',
`Text_loc4` LONGTEXT COMMENT 'Text of the greeting locale 4',
`Text_loc5` LONGTEXT COMMENT 'Text of the greeting locale 5',
`Text_loc6` LONGTEXT COMMENT 'Text of the greeting locale 6',
`Text_loc7` LONGTEXT COMMENT 'Text of the greeting locale 7',
`Text_loc8` LONGTEXT COMMENT 'Text of the greeting locale 8',
PRIMARY KEY(`Entry`,`Type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='Quest and Gossip system';

--
-- Table structure for table `mail_level_reward`
--
Expand Down Expand Up @@ -15097,6 +15116,20 @@ LOCK TABLES `quest_template` WRITE;
/*!40000 ALTER TABLE `quest_template` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `questgiver_greeting`
--

DROP TABLE IF EXISTS `questgiver_greeting`;
CREATE TABLE `questgiver_greeting` (
`Entry` INT(11) UNSIGNED NOT NULL COMMENT 'Entry of Questgiver',
`Type` INT(11) UNSIGNED NOT NULL COMMENT 'Type of entry',
`Text` LONGTEXT COMMENT 'Text of the greeting',
`EmoteId` INT(11) UNSIGNED NOT NULL COMMENT 'Emote ID of greeting',
`EmoteDelay` INT(11) UNSIGNED NOT NULL COMMENT 'Emote delay of the greeting',
PRIMARY KEY(`Entry`,`Type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='Quest and Gossip system';

--
-- Table structure for table `reference_loot_template`
--
Expand Down
28 changes: 28 additions & 0 deletions sql/updates/mangos/13965_01_mangos_questgiver_greeting.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
ALTER TABLE db_version CHANGE COLUMN required_13964_01_mangos_comments required_13965_01_mangos_questgiver_greeting bit;

DROP TABLE IF EXISTS `questgiver_greeting`;
CREATE TABLE `questgiver_greeting` (
`Entry` INT(11) UNSIGNED NOT NULL COMMENT 'Entry of Questgiver',
`Type` INT(11) UNSIGNED NOT NULL COMMENT 'Type of entry',
`Text` LONGTEXT COMMENT 'Text of the greeting',
`EmoteId` INT(11) UNSIGNED NOT NULL COMMENT 'Emote ID of greeting',
`EmoteDelay` INT(11) UNSIGNED NOT NULL COMMENT 'Emote delay of the greeting',
PRIMARY KEY(`Entry`,`Type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='Quest and Gossip system';

DROP TABLE IF EXISTS `locales_questgiver_greeting`;
CREATE TABLE `locales_questgiver_greeting` (
`Entry` INT(11) UNSIGNED NOT NULL COMMENT 'Entry of Questgiver',
`Type` INT(11) UNSIGNED NOT NULL COMMENT 'Type of entry',
`Text_loc1` LONGTEXT COMMENT 'Text of the greeting locale 1',
`Text_loc2` LONGTEXT COMMENT 'Text of the greeting locale 2',
`Text_loc3` LONGTEXT COMMENT 'Text of the greeting locale 3',
`Text_loc4` LONGTEXT COMMENT 'Text of the greeting locale 4',
`Text_loc5` LONGTEXT COMMENT 'Text of the greeting locale 5',
`Text_loc6` LONGTEXT COMMENT 'Text of the greeting locale 6',
`Text_loc7` LONGTEXT COMMENT 'Text of the greeting locale 7',
`Text_loc8` LONGTEXT COMMENT 'Text of the greeting locale 8',
PRIMARY KEY(`Entry`,`Type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='Quest and Gossip system';


2 changes: 2 additions & 0 deletions src/game/Chat/Chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@ ChatCommand* ChatHandler::getCommandTable()
{ "locales_page_text", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLocalesPageTextCommand, "", nullptr },
{ "locales_points_of_interest", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLocalesPointsOfInterestCommand, "", nullptr },
{ "locales_quest", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLocalesQuestCommand, "", nullptr },
{ "locales_questgiver_greeting", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadQuestgiverGreetingLocalesCommand, "", nullptr },
{ "mail_level_reward", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadMailLevelRewardCommand, "", nullptr },
{ "mail_loot_template", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLootTemplatesMailCommand, "", nullptr },
{ "mangos_string", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadMangosStringCommand, "", nullptr },
Expand All @@ -602,6 +603,7 @@ ChatCommand* ChatHandler::getCommandTable()
{ "points_of_interest", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadPointsOfInterestCommand, "", nullptr },
{ "prospecting_loot_template", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLootTemplatesProspectingCommand, "", nullptr },
{ "quest_poi", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadQuestPOICommand, "", nullptr },
{ "questgiver_greeting", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadQuestgiverGreetingCommand, "", nullptr },
{ "quest_template", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadQuestTemplateCommand, "", nullptr },
{ "reference_loot_template", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLootTemplatesReferenceCommand, "", nullptr },
{ "reserved_name", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadReservedNameCommand, "", nullptr },
Expand Down
2 changes: 2 additions & 0 deletions src/game/Chat/Chat.h
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ class ChatHandler
bool HandleReloadGameGraveyardZoneCommand(char* args);
bool HandleReloadGameTeleCommand(char* args);
bool HandleReloadGossipMenuCommand(char* args);
bool HandleReloadQuestgiverGreetingCommand(char* args);
bool HandleReloadGOQuestRelationsCommand(char* args);
bool HandleReloadGOQuestInvRelationsCommand(char* args);
bool HandleReloadItemConvertCommand(char* args);
Expand All @@ -462,6 +463,7 @@ class ChatHandler
bool HandleReloadLocalesPageTextCommand(char* args);
bool HandleReloadLocalesPointsOfInterestCommand(char* args);
bool HandleReloadLocalesQuestCommand(char* args);
bool HandleReloadQuestgiverGreetingLocalesCommand(char* args);
bool HandleReloadLootTemplatesCreatureCommand(char* args);
bool HandleReloadLootTemplatesDisenchantCommand(char* args);
bool HandleReloadLootTemplatesFishingCommand(char* args);
Expand Down
14 changes: 14 additions & 0 deletions src/game/Chat/Level3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,20 @@ bool ChatHandler::HandleReloadGossipMenuCommand(char* /*args*/)
return true;
}

bool ChatHandler::HandleReloadQuestgiverGreetingCommand(char* /*args*/)
{
sObjectMgr.LoadQuestgiverGreeting();
SendGlobalSysMessage("DB table `questgiver_greeting` reloaded.");
return true;
}

bool ChatHandler::HandleReloadQuestgiverGreetingLocalesCommand(char* /*args*/)
{
sObjectMgr.LoadQuestgiverGreetingLocales();
SendGlobalSysMessage("DB table `locales_questgiver_greeting` reloaded.");
return true;
}

bool ChatHandler::HandleReloadGOQuestRelationsCommand(char* /*args*/)
{
sLog.outString("Loading Quests Relations... (`gameobject_questrelation`)");
Expand Down
83 changes: 51 additions & 32 deletions src/game/Entities/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13368,12 +13368,30 @@ void Player::SendPreparedQuest(ObjectGuid guid) const

uint32 icon = qmi0.m_qIcon;

// single element case
if (questMenu.MenuItemCount() == 1)
uint32 type;
if (guid.IsCreature())
type = QUESTGIVER_CREATURE;
else if (guid.IsGameObject())
type = QUESTGIVER_GAMEOBJECT;

if (QuestgiverGreeting const* data = sObjectMgr.GetQuestgiverGreetingData(guid.GetEntry(), type))
{
// Auto open -- maybe also should verify there is no greeting
uint32 quest_id = qmi0.m_qId;
Quest const* pQuest = sObjectMgr.GetQuestTemplate(quest_id);
QEmote qe;
qe._Delay = data->emoteDelay;
qe._Emote = data->emoteId;
std::string title = data->text;
int loc_idx = GetSession()->GetSessionDbLocaleIndex();
sObjectMgr.GetQuestgiverGreetingLocales(guid.GetEntry(), type, loc_idx, &title);
PlayerTalkClass->SendQuestGiverQuestList(qe, title, guid);
}
else
{
// single element case
if (questMenu.MenuItemCount() == 1)
{
// Auto open -- maybe also should verify there is no greeting
uint32 quest_id = qmi0.m_qId;
Quest const* pQuest = sObjectMgr.GetQuestTemplate(quest_id);

if (pQuest)
{
Expand All @@ -13388,41 +13406,42 @@ void Player::SendPreparedQuest(ObjectGuid guid) const
else
PlayerTalkClass->SendQuestGiverQuestDetails(pQuest, guid, true);
}
}
// multiply entries
else
{
QEmote qe;
qe._Delay = 0;
qe._Emote = 0;
std::string title = "";

// need pet case for some quests
if (Creature* pCreature = GetMap()->GetAnyTypeCreature(guid))
}
// multiply entries
else
{
uint32 textid = GetGossipTextId(pCreature);
QEmote qe;
qe._Delay = 0;
qe._Emote = 0;
std::string title = "";

GossipText const* gossiptext = sObjectMgr.GetGossipText(textid);
if (!gossiptext)
// need pet case for some quests
if (Creature* pCreature = GetMap()->GetAnyTypeCreature(guid))
{
qe._Delay = 0; // TEXTEMOTE_MESSAGE; // zyg: player emote
qe._Emote = 0; // TEXTEMOTE_HELLO; // zyg: NPC emote
title.clear();
}
else
{
qe = gossiptext->Options[0].Emotes[0];
uint32 textid = GetGossipTextId(pCreature);

int loc_idx = GetSession()->GetSessionDbLocaleIndex();
GossipText const* gossiptext = sObjectMgr.GetGossipText(textid);
if (!gossiptext)
{
qe._Delay = 0; // TEXTEMOTE_MESSAGE; // zyg: player emote
qe._Emote = 0; // TEXTEMOTE_HELLO; // zyg: NPC emote
title.clear();
}
else
{
qe = gossiptext->Options[0].Emotes[0];

std::string title0 = gossiptext->Options[0].Text_0;
std::string title1 = gossiptext->Options[0].Text_1;
sObjectMgr.GetNpcTextLocaleStrings0(textid, loc_idx, &title0, &title1);
int loc_idx = GetSession()->GetSessionDbLocaleIndex();

title = !title0.empty() ? title0 : title1;
std::string title0 = gossiptext->Options[0].Text_0;
std::string title1 = gossiptext->Options[0].Text_1;
sObjectMgr.GetNpcTextLocaleStrings0(textid, loc_idx, &title0, &title1);

title = !title0.empty() ? title0 : title1;
}
}
PlayerTalkClass->SendQuestGiverQuestList(qe, title, guid);
}
PlayerTalkClass->SendQuestGiverQuestList(qe, title, guid);
}
}

Expand Down

0 comments on commit 40ae84a

Please sign in to comment.