mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-22 21:26:23 +00:00
Refactor(Core/Gossip): Replacing old macros with new (#1338)
* Correct support new macro
This commit is contained in:
@@ -8,13 +8,41 @@
|
||||
#include "Player.h"
|
||||
#include "Creature.h"
|
||||
|
||||
void ClearGossipMenuFor(Player* player) { player->PlayerTalkClass->ClearMenus(); }
|
||||
void ClearGossipMenuFor(Player* player)
|
||||
{
|
||||
player->PlayerTalkClass->ClearMenus();
|
||||
}
|
||||
|
||||
// Using provided text, not from DB
|
||||
void AddGossipItemFor(Player* player, uint32 icon, const char* text, uint32 sender, uint32 action) { player->PlayerTalkClass->GetGossipMenu().AddMenuItem(-1, icon, text, sender, action, "", 0); }
|
||||
void AddGossipItemFor(Player* player, uint32 icon, std::string const& text, uint32 sender, uint32 action)
|
||||
{
|
||||
player->PlayerTalkClass->GetGossipMenu().AddMenuItem(-1, icon, text, sender, action, "", 0);
|
||||
}
|
||||
|
||||
// Using provided texts, not from DB
|
||||
void AddGossipItemFor(Player* player, uint32 icon, const char* text, uint32 sender, uint32 action, const char* popupText, uint32 popupMoney, bool coded) { player->PlayerTalkClass->GetGossipMenu().AddMenuItem(-1, icon, text, sender, action, popupText, popupMoney, coded); }
|
||||
void AddGossipItemFor(Player* player, uint32 icon, std::string const& text, uint32 sender, uint32 action, std::string const& popupText, uint32 popupMoney, bool coded)
|
||||
{
|
||||
player->PlayerTalkClass->GetGossipMenu().AddMenuItem(-1, icon, text, sender, action, popupText, popupMoney, coded);
|
||||
}
|
||||
|
||||
// Uses gossip item info from DB
|
||||
void AddGossipItemFor(Player* player, uint32 gossipMenuID, uint32 gossipMenuItemID, uint32 sender, uint32 action) { player->PlayerTalkClass->GetGossipMenu().AddMenuItem(gossipMenuID, gossipMenuItemID, sender, action); }
|
||||
void SendGossipMenuFor(Player* player, uint32 npcTextID, uint64 const& guid) { player->PlayerTalkClass->SendGossipMenu(npcTextID, guid); }
|
||||
void SendGossipMenuFor(Player* player, uint32 npcTextID, Creature const* creature) { if (creature) SendGossipMenuFor(player, npcTextID, creature->GetGUID()); }
|
||||
void CloseGossipMenuFor(Player* player) { player->PlayerTalkClass->SendCloseGossip(); }
|
||||
void AddGossipItemFor(Player* player, uint32 gossipMenuID, uint32 gossipMenuItemID, uint32 sender, uint32 action)
|
||||
{
|
||||
player->PlayerTalkClass->GetGossipMenu().AddMenuItem(gossipMenuID, gossipMenuItemID, sender, action);
|
||||
}
|
||||
|
||||
void SendGossipMenuFor(Player* player, uint32 npcTextID, uint64 const& guid)
|
||||
{
|
||||
player->PlayerTalkClass->SendGossipMenu(npcTextID, guid);
|
||||
}
|
||||
|
||||
void SendGossipMenuFor(Player* player, uint32 npcTextID, Creature const* creature)
|
||||
{
|
||||
if (creature)
|
||||
SendGossipMenuFor(player, npcTextID, creature->GetGUID());
|
||||
}
|
||||
|
||||
void CloseGossipMenuFor(Player* player)
|
||||
{
|
||||
player->PlayerTalkClass->SendCloseGossip();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-GPL2
|
||||
*
|
||||
*
|
||||
*
|
||||
* This program is free software licensed under GPL version 2
|
||||
* Please see the included DOCS/LICENSE.TXT for more information */
|
||||
@@ -69,19 +69,27 @@ enum eTradeskill
|
||||
};
|
||||
|
||||
class Creature;
|
||||
|
||||
// Clear menu
|
||||
void ClearGossipMenuFor(Player* player);
|
||||
|
||||
// Using provided text, not from DB
|
||||
void AddGossipItemFor(Player* player, uint32 icon, const char* text, uint32 sender, uint32 action);
|
||||
void AddGossipItemFor(Player* player, uint32 icon, std::string const& text, uint32 sender, uint32 action);
|
||||
|
||||
// Using provided texts, not from DB
|
||||
void AddGossipItemFor(Player* player, uint32 icon, const char* text, uint32 sender, uint32 action, const char* popupText, uint32 popupMoney, bool coded);
|
||||
void AddGossipItemFor(Player* player, uint32 icon, std::string const& text, uint32 sender, uint32 action, std::string const& popupText, uint32 popupMoney, bool coded);
|
||||
|
||||
// Uses gossip item info from DB
|
||||
void AddGossipItemFor(Player* player, uint32 gossipMenuID, uint32 gossipMenuItemID, uint32 sender, uint32 action);
|
||||
|
||||
// Send menu text
|
||||
void SendGossipMenuFor(Player* player, uint32 npcTextID, uint64 const& guid);
|
||||
void SendGossipMenuFor(Player* player, uint32 npcTextID, Creature const* creature);
|
||||
|
||||
// Close menu
|
||||
void CloseGossipMenuFor(Player* player);
|
||||
|
||||
// Defined fuctions to use with player.
|
||||
|
||||
/// Old macro. Need delete later
|
||||
// This fuction add's a menu item,
|
||||
// a - Icon Id
|
||||
// b - Text
|
||||
@@ -89,13 +97,13 @@ void CloseGossipMenuFor(Player* player);
|
||||
// d - Action (identifys this Menu Item)
|
||||
// e - Text to be displayed in pop up box
|
||||
// f - Money value in pop up box
|
||||
#define ADD_GOSSIP_ITEM(a, b, c, d) PlayerTalkClass->GetGossipMenu().AddMenuItem(-1, a, b, c, d, "", 0)
|
||||
#define ADD_GOSSIP_ITEM(a, b, c, d) PlayerTalkClass->GetGossipMenu().AddMenuItem(-1, a, b, c, d, "", 0)
|
||||
#define ADD_GOSSIP_ITEM_EXTENDED(a, b, c, d, e, f, g) PlayerTalkClass->GetGossipMenu().AddMenuItem(-1, a, b, c, d, e, f, g)
|
||||
|
||||
// This fuction Sends the current menu to show to client, a - NPCTEXTID(uint32), b - npc guid(uint64)
|
||||
#define SEND_GOSSIP_MENU(a, b) PlayerTalkClass->SendGossipMenu(a, b)
|
||||
#define SEND_GOSSIP_MENU(a, b) PlayerTalkClass->SendGossipMenu(a, b)
|
||||
|
||||
// Closes the Menu
|
||||
#define CLOSE_GOSSIP_MENU() PlayerTalkClass->SendCloseGossip()
|
||||
#define CLOSE_GOSSIP_MENU() PlayerTalkClass->SendCloseGossip()
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2508,9 +2508,9 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
if (e.action.sendGossipMenu.gossipMenuId)
|
||||
player->PrepareGossipMenu(GetBaseObject(), e.action.sendGossipMenu.gossipMenuId, true);
|
||||
else
|
||||
player->PlayerTalkClass->ClearMenus();
|
||||
ClearGossipMenuFor(player);
|
||||
|
||||
player->SEND_GOSSIP_MENU(e.action.sendGossipMenu.gossipNpcTextId, GetBaseObject()->GetGUID());
|
||||
SendGossipMenuFor(player, e.action.sendGossipMenu.gossipNpcTextId, GetBaseObject()->GetGUID());
|
||||
}
|
||||
|
||||
delete targets;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "Formulas.h"
|
||||
#include "GameEventMgr.h"
|
||||
#include "GossipDef.h"
|
||||
#include "ScriptedGossip.h"
|
||||
#include "GridNotifiers.h"
|
||||
#include "GridNotifiersImpl.h"
|
||||
#include "Group.h"
|
||||
@@ -914,12 +915,12 @@ bool Creature::isCanInteractWithBattleMaster(Player* player, bool msg) const
|
||||
|
||||
if (!player->GetBGAccessByLevel(bgTypeId))
|
||||
{
|
||||
player->PlayerTalkClass->ClearMenus();
|
||||
ClearGossipMenuFor(player);
|
||||
switch (bgTypeId)
|
||||
{
|
||||
case BATTLEGROUND_AV: player->PlayerTalkClass->SendGossipMenu(7616, GetGUID()); break;
|
||||
case BATTLEGROUND_WS: player->PlayerTalkClass->SendGossipMenu(7599, GetGUID()); break;
|
||||
case BATTLEGROUND_AB: player->PlayerTalkClass->SendGossipMenu(7642, GetGUID()); break;
|
||||
case BATTLEGROUND_AV: SendGossipMenuFor(player, 7616, this); break;
|
||||
case BATTLEGROUND_WS: SendGossipMenuFor(player, 7599, this); break;
|
||||
case BATTLEGROUND_AB: SendGossipMenuFor(player, 7642, this); break;
|
||||
case BATTLEGROUND_EY:
|
||||
case BATTLEGROUND_NA:
|
||||
case BATTLEGROUND_BE:
|
||||
@@ -927,7 +928,7 @@ bool Creature::isCanInteractWithBattleMaster(Player* player, bool msg) const
|
||||
case BATTLEGROUND_RL:
|
||||
case BATTLEGROUND_SA:
|
||||
case BATTLEGROUND_DS:
|
||||
case BATTLEGROUND_RV: player->PlayerTalkClass->SendGossipMenu(10024, GetGUID()); break;
|
||||
case BATTLEGROUND_RV: SendGossipMenuFor(player, 10024, this); break;
|
||||
default: break;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "SpellInfo.h"
|
||||
#include "SpellScript.h"
|
||||
#include "GossipDef.h"
|
||||
#include "ScriptedGossip.h"
|
||||
#include "CreatureAI.h"
|
||||
#include "Player.h"
|
||||
#include "WorldPacket.h"
|
||||
@@ -765,7 +766,7 @@ bool ScriptMgr::OnQuestAccept(Player* player, Item* item, Quest const* quest)
|
||||
#endif
|
||||
|
||||
GET_SCRIPT_RET(ItemScript, item->GetScriptId(), tmpscript, false);
|
||||
player->PlayerTalkClass->ClearMenus();
|
||||
ClearGossipMenuFor(player);
|
||||
return tmpscript->OnQuestAccept(player, item, quest);
|
||||
}
|
||||
|
||||
@@ -857,7 +858,7 @@ bool ScriptMgr::OnGossipHello(Player* player, Creature* creature)
|
||||
return true;
|
||||
#endif
|
||||
GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, false);
|
||||
player->PlayerTalkClass->ClearMenus();
|
||||
ClearGossipMenuFor(player);
|
||||
return tmpscript->OnGossipHello(player, creature);
|
||||
}
|
||||
|
||||
@@ -893,7 +894,7 @@ bool ScriptMgr::OnQuestAccept(Player* player, Creature* creature, Quest const* q
|
||||
ASSERT(quest);
|
||||
|
||||
GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, false);
|
||||
player->PlayerTalkClass->ClearMenus();
|
||||
ClearGossipMenuFor(player);
|
||||
return tmpscript->OnQuestAccept(player, creature, quest);
|
||||
}
|
||||
|
||||
@@ -904,7 +905,7 @@ bool ScriptMgr::OnQuestSelect(Player* player, Creature* creature, Quest const* q
|
||||
ASSERT(quest);
|
||||
|
||||
GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, false);
|
||||
player->PlayerTalkClass->ClearMenus();
|
||||
ClearGossipMenuFor(player);
|
||||
return tmpscript->OnQuestSelect(player, creature, quest);
|
||||
}
|
||||
|
||||
@@ -915,7 +916,7 @@ bool ScriptMgr::OnQuestComplete(Player* player, Creature* creature, Quest const*
|
||||
ASSERT(quest);
|
||||
|
||||
GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, false);
|
||||
player->PlayerTalkClass->ClearMenus();
|
||||
ClearGossipMenuFor(player);
|
||||
return tmpscript->OnQuestComplete(player, creature, quest);
|
||||
}
|
||||
|
||||
@@ -927,12 +928,12 @@ bool ScriptMgr::OnQuestReward(Player* player, Creature* creature, Quest const* q
|
||||
#ifdef ELUNA
|
||||
if (sEluna->OnQuestReward(player, creature, quest, opt))
|
||||
{
|
||||
player->PlayerTalkClass->ClearMenus();
|
||||
ClearGossipMenuFor(player);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, false);
|
||||
player->PlayerTalkClass->ClearMenus();
|
||||
ClearGossipMenuFor(player);
|
||||
return tmpscript->OnQuestReward(player, creature, quest, opt);
|
||||
}
|
||||
|
||||
@@ -942,7 +943,7 @@ uint32 ScriptMgr::GetDialogStatus(Player* player, Creature* creature)
|
||||
ASSERT(creature);
|
||||
|
||||
GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, DIALOG_STATUS_SCRIPTED_NO_STATUS);
|
||||
player->PlayerTalkClass->ClearMenus();
|
||||
ClearGossipMenuFor(player);
|
||||
return tmpscript->GetDialogStatus(player, creature);
|
||||
}
|
||||
|
||||
@@ -980,7 +981,7 @@ bool ScriptMgr::OnGossipHello(Player* player, GameObject* go)
|
||||
return true;
|
||||
#endif
|
||||
GET_SCRIPT_RET(GameObjectScript, go->GetScriptId(), tmpscript, false);
|
||||
player->PlayerTalkClass->ClearMenus();
|
||||
ClearGossipMenuFor(player);
|
||||
return tmpscript->OnGossipHello(player, go);
|
||||
}
|
||||
|
||||
@@ -1016,7 +1017,7 @@ bool ScriptMgr::OnQuestAccept(Player* player, GameObject* go, Quest const* quest
|
||||
ASSERT(quest);
|
||||
|
||||
GET_SCRIPT_RET(GameObjectScript, go->GetScriptId(), tmpscript, false);
|
||||
player->PlayerTalkClass->ClearMenus();
|
||||
ClearGossipMenuFor(player);
|
||||
return tmpscript->OnQuestAccept(player, go, quest);
|
||||
}
|
||||
|
||||
@@ -1034,7 +1035,7 @@ bool ScriptMgr::OnQuestReward(Player* player, GameObject* go, Quest const* quest
|
||||
return false;
|
||||
#endif
|
||||
GET_SCRIPT_RET(GameObjectScript, go->GetScriptId(), tmpscript, false);
|
||||
player->PlayerTalkClass->ClearMenus();
|
||||
ClearGossipMenuFor(player);
|
||||
return tmpscript->OnQuestReward(player, go, quest, opt);
|
||||
}
|
||||
|
||||
@@ -1044,7 +1045,7 @@ uint32 ScriptMgr::GetDialogStatus(Player* player, GameObject* go)
|
||||
ASSERT(go);
|
||||
|
||||
GET_SCRIPT_RET(GameObjectScript, go->GetScriptId(), tmpscript, DIALOG_STATUS_SCRIPTED_NO_STATUS);
|
||||
player->PlayerTalkClass->ClearMenus();
|
||||
ClearGossipMenuFor(player);
|
||||
return tmpscript->GetDialogStatus(player, go);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user