Misc fixes
This commit is contained in:
@@ -1558,6 +1558,22 @@ namespace Game.BattleGrounds
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RemoveObjectFromWorld(uint type)
|
||||
{
|
||||
if (BgObjects[type].IsEmpty())
|
||||
return true;
|
||||
|
||||
GameObject obj = GetBgMap().GetGameObject(BgObjects[type]);
|
||||
if (obj != null)
|
||||
{
|
||||
obj.RemoveFromWorld();
|
||||
BgObjects[type].Clear();
|
||||
return true;
|
||||
}
|
||||
Log.outInfo(LogFilter.Battleground, $"Battleground::RemoveObjectFromWorld: gameobject (type: {type}, {BgObjects[type]}) not found for BG (map: {GetMapId()}, instance id: {m_InstanceID})!");
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool AddSpiritGuide(int type, float x, float y, float z, float o, int teamIndex)
|
||||
{
|
||||
uint entry = (uint)(teamIndex == TeamId.Alliance ? BattlegroundCreatures.A_SpiritGuide : BattlegroundCreatures.H_SpiritGuide);
|
||||
|
||||
@@ -147,7 +147,7 @@ namespace Game.Chat
|
||||
if (tile != null)
|
||||
{
|
||||
handler.SendSysMessage("Dt [{0:D2},{1:D2}]", tile.header.x, tile.header.y);
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -624,7 +624,7 @@ namespace Game
|
||||
var pMenuItemBounds = Global.ObjectMgr.GetGossipMenuItemsMapBounds(cond.SourceGroup);
|
||||
foreach (var menuItems in pMenuItemBounds)
|
||||
{
|
||||
if (menuItems.MenuId == cond.SourceGroup && menuItems.OptionIndex == cond.SourceEntry)
|
||||
if (menuItems.MenuId == cond.SourceGroup && menuItems.OptionId == cond.SourceEntry)
|
||||
{
|
||||
menuItems.Conditions.Add(cond);
|
||||
return true;
|
||||
|
||||
@@ -29,22 +29,22 @@ namespace Game.Misc
|
||||
{
|
||||
public class GossipMenu
|
||||
{
|
||||
public uint AddMenuItem(int optionIndex, GossipOptionIcon icon, string message, uint sender, uint action, string boxMessage, uint boxMoney, bool coded = false)
|
||||
public uint AddMenuItem(int menuItemId, GossipOptionIcon icon, string message, uint sender, uint action, string boxMessage, uint boxMoney, bool coded = false)
|
||||
{
|
||||
Cypher.Assert(_menuItems.Count <= SharedConst.MaxGossipMenuItems);
|
||||
|
||||
// Find a free new id - script case
|
||||
if (optionIndex == -1)
|
||||
if (menuItemId == -1)
|
||||
{
|
||||
optionIndex = 0;
|
||||
menuItemId = 0;
|
||||
if (!_menuItems.Empty())
|
||||
{
|
||||
foreach (var item in _menuItems)
|
||||
{
|
||||
if (item.Key > optionIndex)
|
||||
if (item.Key > menuItemId)
|
||||
break;
|
||||
|
||||
optionIndex = (int)item.Key + 1;
|
||||
menuItemId = (int)item.Key + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,18 +59,18 @@ namespace Game.Misc
|
||||
menuItem.BoxMessage = boxMessage;
|
||||
menuItem.BoxMoney = boxMoney;
|
||||
|
||||
_menuItems[(uint)optionIndex] = menuItem;
|
||||
return (uint)optionIndex;
|
||||
_menuItems[(uint)menuItemId] = menuItem;
|
||||
return (uint)menuItemId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a localized gossip menu item from db by menu id and menu item id.
|
||||
/// </summary>
|
||||
/// <param name="menuId">menuId Gossip menu id.</param>
|
||||
/// <param name="optionIndex">menuItemId Gossip menu item id.</param>
|
||||
/// <param name="menuItemId">menuItemId Gossip menu item id.</param>
|
||||
/// <param name="sender">sender Identifier of the current menu.</param>
|
||||
/// <param name="action">action Custom action given to OnGossipHello.</param>
|
||||
public void AddMenuItem(uint menuId, uint optionIndex, uint sender, uint action)
|
||||
public void AddMenuItem(uint menuId, uint menuItemId, uint sender, uint action)
|
||||
{
|
||||
// Find items for given menu id.
|
||||
var bounds = Global.ObjectMgr.GetGossipMenuItemsMapBounds(menuId);
|
||||
@@ -82,7 +82,7 @@ namespace Game.Misc
|
||||
foreach (var item in bounds)
|
||||
{
|
||||
// Find the one with the given menu item id.
|
||||
if (item.OptionIndex != optionIndex)
|
||||
if (item.OptionId != menuItemId)
|
||||
continue;
|
||||
|
||||
// Store texts for localization.
|
||||
@@ -108,7 +108,7 @@ namespace Game.Misc
|
||||
if (optionBroadcastText == null)
|
||||
{
|
||||
// Find localizations from database.
|
||||
GossipMenuItemsLocale gossipMenuLocale = Global.ObjectMgr.GetGossipMenuItemsLocale(menuId, optionIndex);
|
||||
GossipMenuItemsLocale gossipMenuLocale = Global.ObjectMgr.GetGossipMenuItemsLocale(menuId, menuItemId);
|
||||
if (gossipMenuLocale != null)
|
||||
ObjectManager.GetLocaleString(gossipMenuLocale.OptionText, GetLocale(), ref strOptionText);
|
||||
}
|
||||
@@ -116,7 +116,7 @@ namespace Game.Misc
|
||||
if (boxBroadcastText == null)
|
||||
{
|
||||
// Find localizations from database.
|
||||
GossipMenuItemsLocale gossipMenuLocale = Global.ObjectMgr.GetGossipMenuItemsLocale(menuId, optionIndex);
|
||||
GossipMenuItemsLocale gossipMenuLocale = Global.ObjectMgr.GetGossipMenuItemsLocale(menuId, menuItemId);
|
||||
if (gossipMenuLocale != null)
|
||||
ObjectManager.GetLocaleString(gossipMenuLocale.BoxText, GetLocale(), ref strBoxText);
|
||||
}
|
||||
@@ -124,19 +124,19 @@ namespace Game.Misc
|
||||
}
|
||||
|
||||
// Add menu item with existing method. Menu item id -1 is also used in ADD_GOSSIP_ITEM macro.
|
||||
uint newOptionIndex = AddMenuItem(-1, item.OptionIcon, strOptionText, sender, action, strBoxText, item.BoxMoney, item.BoxCoded);
|
||||
AddGossipMenuItemData(newOptionIndex, item.ActionMenuId, item.ActionPoiId);
|
||||
uint newOptionId = AddMenuItem(-1, item.OptionIcon, strOptionText, sender, action, strBoxText, item.BoxMoney, item.BoxCoded);
|
||||
AddGossipMenuItemData(newOptionId, item.ActionMenuId, item.ActionPoiId);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddGossipMenuItemData(uint optionIndex, uint gossipActionMenuId, uint gossipActionPoi)
|
||||
public void AddGossipMenuItemData(uint menuItemId, uint gossipActionMenuId, uint gossipActionPoi)
|
||||
{
|
||||
GossipMenuItemData itemData = new();
|
||||
|
||||
itemData.GossipActionMenuId = gossipActionMenuId;
|
||||
itemData.GossipActionPoi = gossipActionPoi;
|
||||
|
||||
_menuItemData[optionIndex] = itemData;
|
||||
_menuItemData[menuItemId] = itemData;
|
||||
}
|
||||
|
||||
public uint GetMenuItemSender(uint menuItemId)
|
||||
@@ -728,7 +728,7 @@ namespace Game.Misc
|
||||
public class GossipMenuItems
|
||||
{
|
||||
public uint MenuId;
|
||||
public uint OptionIndex;
|
||||
public uint OptionId;
|
||||
public GossipOptionIcon OptionIcon;
|
||||
public string OptionText;
|
||||
public uint OptionBroadcastTextId;
|
||||
|
||||
@@ -2368,7 +2368,7 @@ namespace Game.Entities
|
||||
if (optionBroadcastText == null)
|
||||
{
|
||||
// Find localizations from database.
|
||||
GossipMenuItemsLocale gossipMenuLocale = Global.ObjectMgr.GetGossipMenuItemsLocale(menuId, menuItems.OptionIndex);
|
||||
GossipMenuItemsLocale gossipMenuLocale = Global.ObjectMgr.GetGossipMenuItemsLocale(menuId, menuItems.OptionId);
|
||||
if (gossipMenuLocale != null)
|
||||
ObjectManager.GetLocaleString(gossipMenuLocale.OptionText, locale, ref strOptionText);
|
||||
}
|
||||
@@ -2376,14 +2376,14 @@ namespace Game.Entities
|
||||
if (boxBroadcastText == null)
|
||||
{
|
||||
// Find localizations from database.
|
||||
GossipMenuItemsLocale gossipMenuLocale = Global.ObjectMgr.GetGossipMenuItemsLocale(menuId, menuItems.OptionIndex);
|
||||
GossipMenuItemsLocale gossipMenuLocale = Global.ObjectMgr.GetGossipMenuItemsLocale(menuId, menuItems.OptionId);
|
||||
if (gossipMenuLocale != null)
|
||||
ObjectManager.GetLocaleString(gossipMenuLocale.BoxText, locale, ref strBoxText);
|
||||
}
|
||||
}
|
||||
|
||||
menu.GetGossipMenu().AddMenuItem((int)menuItems.OptionIndex, menuItems.OptionIcon, strOptionText, 0, (uint)menuItems.OptionType, strBoxText, menuItems.BoxMoney, menuItems.BoxCoded);
|
||||
menu.GetGossipMenu().AddGossipMenuItemData(menuItems.OptionIndex, menuItems.ActionMenuId, menuItems.ActionPoiId);
|
||||
menu.GetGossipMenu().AddMenuItem((int)menuItems.OptionId, menuItems.OptionIcon, strOptionText, 0, (uint)menuItems.OptionType, strBoxText, menuItems.BoxMoney, menuItems.BoxCoded);
|
||||
menu.GetGossipMenu().AddGossipMenuItemData(menuItems.OptionId, menuItems.ActionMenuId, menuItems.ActionPoiId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2411,7 +2411,7 @@ namespace Game.Entities
|
||||
|
||||
PlayerTalkClass.SendGossipMenu(textId, source.GetGUID());
|
||||
}
|
||||
public void OnGossipSelect(WorldObject source, uint optionIndex, uint menuId)
|
||||
public void OnGossipSelect(WorldObject source, uint gossipListId, uint menuId)
|
||||
{
|
||||
GossipMenu gossipMenu = PlayerTalkClass.GetGossipMenu();
|
||||
|
||||
@@ -2419,7 +2419,7 @@ namespace Game.Entities
|
||||
if (menuId != gossipMenu.GetMenuId())
|
||||
return;
|
||||
|
||||
GossipMenuItem item = gossipMenu.GetItem(optionIndex);
|
||||
GossipMenuItem item = gossipMenu.GetItem(gossipListId);
|
||||
if (item == null)
|
||||
return;
|
||||
|
||||
@@ -2435,7 +2435,7 @@ namespace Game.Entities
|
||||
}
|
||||
}
|
||||
|
||||
GossipMenuItemData menuItemData = gossipMenu.GetItemData(optionIndex);
|
||||
GossipMenuItemData menuItemData = gossipMenu.GetItemData(gossipListId);
|
||||
if (menuItemData == null)
|
||||
return;
|
||||
|
||||
@@ -2463,7 +2463,7 @@ namespace Game.Entities
|
||||
break;
|
||||
}
|
||||
case GossipOption.Outdoorpvp:
|
||||
Global.OutdoorPvPMgr.HandleGossipOption(this, source.ToCreature(), optionIndex);
|
||||
Global.OutdoorPvPMgr.HandleGossipOption(this, source.ToCreature(), gossipListId);
|
||||
break;
|
||||
case GossipOption.Spirithealer:
|
||||
if (IsDead())
|
||||
@@ -2481,7 +2481,7 @@ namespace Game.Entities
|
||||
GetSession().SendStablePet(guid);
|
||||
break;
|
||||
case GossipOption.Trainer:
|
||||
GetSession().SendTrainerList(source.ToCreature(), Global.ObjectMgr.GetCreatureTrainerForGossipOption(source.GetEntry(), menuId, optionIndex));
|
||||
GetSession().SendTrainerList(source.ToCreature(), Global.ObjectMgr.GetCreatureTrainerForGossipOption(source.GetEntry(), menuId, gossipListId));
|
||||
break;
|
||||
case GossipOption.Learndualspec:
|
||||
break;
|
||||
|
||||
@@ -617,7 +617,7 @@ namespace Game
|
||||
GossipMenuItems gMenuItem = new();
|
||||
|
||||
gMenuItem.MenuId = result.Read<uint>(0);
|
||||
gMenuItem.OptionIndex = result.Read<uint>(1);
|
||||
gMenuItem.OptionId = result.Read<uint>(1);
|
||||
gMenuItem.OptionIcon = (GossipOptionIcon)result.Read<byte>(2);
|
||||
gMenuItem.OptionText = result.Read<string>(3);
|
||||
gMenuItem.OptionBroadcastTextId = result.Read<uint>(4);
|
||||
@@ -632,7 +632,7 @@ namespace Game
|
||||
|
||||
if (gMenuItem.OptionIcon >= GossipOptionIcon.Max)
|
||||
{
|
||||
Log.outError(LogFilter.Sql, $"Table gossip_menu_option for MenuId {gMenuItem.MenuId}, OptionIndex {gMenuItem.OptionIndex} has unknown icon id {gMenuItem.OptionIcon}. Replacing with GossipOptionIcon.Chat");
|
||||
Log.outError(LogFilter.Sql, $"Table gossip_menu_option for MenuId {gMenuItem.MenuId}, OptionIndex {gMenuItem.OptionId} has unknown icon id {gMenuItem.OptionIcon}. Replacing with GossipOptionIcon.Chat");
|
||||
gMenuItem.OptionIcon = GossipOptionIcon.None;
|
||||
}
|
||||
|
||||
@@ -640,17 +640,17 @@ namespace Game
|
||||
{
|
||||
if (!CliDB.BroadcastTextStorage.ContainsKey(gMenuItem.OptionBroadcastTextId))
|
||||
{
|
||||
Log.outError(LogFilter.Sql, $"Table `gossip_menu_option` for MenuId {gMenuItem.MenuId}, OptionIndex {gMenuItem.OptionIndex} has non-existing or incompatible OptionBroadcastTextId {gMenuItem.OptionBroadcastTextId}, ignoring.");
|
||||
Log.outError(LogFilter.Sql, $"Table `gossip_menu_option` for MenuId {gMenuItem.MenuId}, OptionIndex {gMenuItem.OptionId} has non-existing or incompatible OptionBroadcastTextId {gMenuItem.OptionBroadcastTextId}, ignoring.");
|
||||
gMenuItem.OptionBroadcastTextId = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (gMenuItem.OptionType >= GossipOption.Max)
|
||||
Log.outError(LogFilter.Sql, $"Table gossip_menu_option for MenuId {gMenuItem.MenuId}, OptionIndex {gMenuItem.OptionIndex} has unknown option id {gMenuItem.OptionType}. Option will not be used");
|
||||
Log.outError(LogFilter.Sql, $"Table gossip_menu_option for MenuId {gMenuItem.MenuId}, OptionIndex {gMenuItem.OptionId} has unknown option id {gMenuItem.OptionType}. Option will not be used");
|
||||
|
||||
if (gMenuItem.ActionPoiId != 0 && GetPointOfInterest(gMenuItem.ActionPoiId) == null)
|
||||
{
|
||||
Log.outError(LogFilter.Sql, $"Table gossip_menu_option for MenuId {gMenuItem.MenuId}, OptionIndex {gMenuItem.OptionIndex} use non-existing actionpoiid {gMenuItem.ActionPoiId}, ignoring");
|
||||
Log.outError(LogFilter.Sql, $"Table gossip_menu_option for MenuId {gMenuItem.MenuId}, OptionIndex {gMenuItem.OptionId} use non-existing actionpoiid {gMenuItem.ActionPoiId}, ignoring");
|
||||
gMenuItem.ActionPoiId = 0;
|
||||
}
|
||||
|
||||
@@ -658,7 +658,7 @@ namespace Game
|
||||
{
|
||||
if (!CliDB.BroadcastTextStorage.ContainsKey(gMenuItem.BoxBroadcastTextId))
|
||||
{
|
||||
Log.outError(LogFilter.Sql, $"Table `gossip_menu_option` for MenuId {gMenuItem.MenuId}, OptionIndex {gMenuItem.OptionIndex} has non-existing or incompatible BoxBroadcastTextId {gMenuItem.BoxBroadcastTextId}, ignoring.");
|
||||
Log.outError(LogFilter.Sql, $"Table `gossip_menu_option` for MenuId {gMenuItem.MenuId}, OptionIndex {gMenuItem.OptionId} has non-existing or incompatible BoxBroadcastTextId {gMenuItem.BoxBroadcastTextId}, ignoring.");
|
||||
gMenuItem.BoxBroadcastTextId = 0;
|
||||
}
|
||||
}
|
||||
@@ -3238,7 +3238,7 @@ namespace Game
|
||||
var gossipMenuItems = GetGossipMenuItemsMapBounds(gossipMenuId);
|
||||
var gossipOptionItr = gossipMenuItems.Find(entry =>
|
||||
{
|
||||
return entry.OptionIndex == gossipOptionIndex;
|
||||
return entry.OptionId == gossipOptionIndex;
|
||||
});
|
||||
|
||||
if (gossipOptionItr == null)
|
||||
|
||||
Reference in New Issue
Block a user