Skip to content

Commit

Permalink
[10704] Add the option to close gossip window in gossip system
Browse files Browse the repository at this point in the history
Field action_menu_id in gossip_menu_option table can be set to -1 where close gossip is expected, instead of sending a new menu.

Signed-off-by: NoFantasy <nofantasy@nf.no>
  • Loading branch information
NoFantasy authored and tomrus88 committed Nov 15, 2010
1 parent ff1c6cd commit ac3ad4f
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 12 deletions.
4 changes: 2 additions & 2 deletions sql/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_10682_01_mangos_item_convert` bit(1) default NULL
`required_10704_01_mangos_gossip_menu_option` bit(1) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes';

--
Expand Down Expand Up @@ -2042,7 +2042,7 @@ CREATE TABLE gossip_menu_option (
option_text text,
option_id tinyint(3) unsigned NOT NULL default '0',
npc_option_npcflag int(10) unsigned NOT NULL default '0',
action_menu_id mediumint(8) unsigned NOT NULL default '0',
action_menu_id mediumint(8) NOT NULL default '0',
action_poi_id mediumint(8) unsigned NOT NULL default '0',
action_script_id mediumint(8) unsigned NOT NULL default '0',
box_coded tinyint(3) unsigned NOT NULL default '0',
Expand Down
3 changes: 3 additions & 0 deletions sql/updates/10704_01_mangos_gossip_menu_option.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ALTER TABLE db_version CHANGE COLUMN required_10682_01_mangos_item_convert required_10704_01_mangos_gossip_menu_option bit;

ALTER TABLE gossip_menu_option CHANGE COLUMN action_menu_id action_menu_id MEDIUMINT(8) NOT NULL DEFAULT '0';
2 changes: 2 additions & 0 deletions sql/updates/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ pkgdata_DATA = \
10679_01_mangos_npc_vendor_template.sql \
10679_02_mangos_creature_template.sql \
10682_01_mangos_item_convert.sql \
10704_01_mangos_gossip_menu_option.sql \
README

## Additional files to include when running 'make dist'
Expand Down Expand Up @@ -214,4 +215,5 @@ EXTRA_DIST = \
10679_01_mangos_npc_vendor_template.sql \
10679_02_mangos_creature_template.sql \
10682_01_mangos_item_convert.sql \
10704_01_mangos_gossip_menu_option.sql \
README
2 changes: 1 addition & 1 deletion src/game/GossipDef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void GossipMenu::AddMenuItem(uint8 Icon, const std::string& Message, uint32 dtSe
m_gItems.push_back(gItem);
}

void GossipMenu::AddGossipMenuItemData(uint32 action_menu, uint32 action_poi, uint32 action_script)
void GossipMenu::AddGossipMenuItemData(int32 action_menu, uint32 action_poi, uint32 action_script)
{
GossipMenuItemData pItemData;

Expand Down
4 changes: 2 additions & 2 deletions src/game/GossipDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ typedef std::vector<GossipMenuItem> GossipMenuItemList;

struct GossipMenuItemData
{
uint32 m_gAction_menu;
int32 m_gAction_menu; // negative for close gossip
uint32 m_gAction_poi;
uint32 m_gAction_script;
};
Expand Down Expand Up @@ -172,7 +172,7 @@ class MANGOS_DLL_SPEC GossipMenu
void SetMenuId(uint32 menu_id) { m_gMenuId = menu_id; }
uint32 GetMenuId() { return m_gMenuId; }

void AddGossipMenuItemData(uint32 action_menu, uint32 action_poi, uint32 action_script);
void AddGossipMenuItemData(int32 action_menu, uint32 action_poi, uint32 action_script);

unsigned int MenuItemCount() const
{
Expand Down
2 changes: 1 addition & 1 deletion src/game/ObjectMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9136,7 +9136,7 @@ void ObjectMgr::LoadGossipMenuItems()
gMenuItem.option_text = fields[3].GetCppString();
gMenuItem.option_id = fields[4].GetUInt32();
gMenuItem.npc_option_npcflag = fields[5].GetUInt32();
gMenuItem.action_menu_id = fields[6].GetUInt32();
gMenuItem.action_menu_id = fields[6].GetInt32();
gMenuItem.action_poi_id = fields[7].GetUInt32();
gMenuItem.action_script_id = fields[8].GetUInt32();
gMenuItem.box_coded = fields[9].GetUInt8() != 0;
Expand Down
2 changes: 1 addition & 1 deletion src/game/ObjectMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ struct GossipMenuItems
std::string option_text;
uint32 option_id;
uint32 npc_option_npcflag;
uint32 action_menu_id;
int32 action_menu_id;
uint32 action_poi_id;
uint32 action_script_id;
bool box_coded;
Expand Down
12 changes: 9 additions & 3 deletions src/game/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12770,7 +12770,7 @@ void Player::PrepareGossipMenu(WorldObject *pSource, uint32 menuId)
switch(itr->second.option_id)
{
case GOSSIP_OPTION_GOSSIP:
if (itr->second.action_menu_id) // has sub menu, so do not "talk" with this NPC yet
if (itr->second.action_menu_id != 0) // has sub menu (or close gossip), so do not "talk" with this NPC yet
canTalkToCredit = false;
break;
case GOSSIP_OPTION_QUESTGIVER:
Expand Down Expand Up @@ -12981,11 +12981,17 @@ void Player::OnGossipSelect(WorldObject* pSource, uint32 gossipListId, uint32 me
if (pMenuData.m_gAction_poi)
PlayerTalkClass->SendPointOfInterest(pMenuData.m_gAction_poi);

if (pMenuData.m_gAction_menu)
// send new menu || close gossip || stay at current menu
if (pMenuData.m_gAction_menu > 0)
{
PrepareGossipMenu(pSource, pMenuData.m_gAction_menu);
PrepareGossipMenu(pSource, uint32(pMenuData.m_gAction_menu));
SendPreparedGossip(pSource);
}
else if (pMenuData.m_gAction_menu < 0)
{
PlayerTalkClass->CloseGossip();
TalkedToCreature(pSource->GetEntry(), pSource->GetGUID());
}

if (pMenuData.m_gAction_script)
{
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "10703"
#define REVISION_NR "10704"
#endif // __REVISION_NR_H__
2 changes: 1 addition & 1 deletion src/shared/revision_sql.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef __REVISION_SQL_H__
#define __REVISION_SQL_H__
#define REVISION_DB_CHARACTERS "required_10664_01_characters_arena_team_stats"
#define REVISION_DB_MANGOS "required_10682_01_mangos_item_convert"
#define REVISION_DB_MANGOS "required_10704_01_mangos_gossip_menu_option"
#define REVISION_DB_REALMD "required_10008_01_realmd_realmd_db_version"
#endif // __REVISION_SQL_H__

0 comments on commit ac3ad4f

Please sign in to comment.