Skip to content

Commit

Permalink
Refactor(Core/Gossip): Replacing old macros with new (#1338)
Browse files Browse the repository at this point in the history
* Correct support new macro
  • Loading branch information
Winfidonarleyan authored Mar 25, 2019
1 parent 4abe082 commit b6cb924
Show file tree
Hide file tree
Showing 99 changed files with 2,761 additions and 2,696 deletions.
42 changes: 35 additions & 7 deletions src/server/game/AI/ScriptedAI/ScriptedGossip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
24 changes: 16 additions & 8 deletions src/server/game/AI/ScriptedAI/ScriptedGossip.h
Original file line number Diff line number Diff line change
@@ -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 */
Expand Down Expand Up @@ -69,33 +69,41 @@ 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);
void CloseGossipMenuFor(Player* player);

// Defined fuctions to use with player.
// Close menu
void CloseGossipMenuFor(Player* player);

/// Old macro. Need delete later
// This fuction add's a menu item,
// a - Icon Id
// b - Text
// c - Sender(this is to identify the current Menu with this item)
// 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
4 changes: 2 additions & 2 deletions src/server/game/AI/SmartScripts/SmartScript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 6 additions & 5 deletions src/server/game/Entities/Creature/Creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -914,20 +915,20 @@ 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:
case BATTLEGROUND_AA:
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;
Expand Down
25 changes: 13 additions & 12 deletions src/server/game/Scripting/ScriptMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand Down
Loading

0 comments on commit b6cb924

Please sign in to comment.