Core/Battlegrounds: Move to scripts And a lot of misc commits i couldn't recover.
Port From (https://github.com/TrinityCore/TrinityCore/commit/d0d5d309bb5877dc2fcb27f6cb123707a31ec1e8)
This commit is contained in:
@@ -90,15 +90,15 @@ namespace Game.Chat
|
||||
public static ChannelManager ForTeam(Team team)
|
||||
{
|
||||
if (WorldConfig.GetBoolValue(WorldCfg.AllowTwoSideInteractionChannel))
|
||||
return allianceChannelMgr; // cross-faction
|
||||
return neutralChannelMgr; // cross-faction
|
||||
|
||||
if (team == Team.Alliance)
|
||||
return allianceChannelMgr;
|
||||
|
||||
if (team == Team.Horde)
|
||||
return hordeChannelMgr;
|
||||
|
||||
return null;
|
||||
return team switch
|
||||
{
|
||||
Team.Alliance => allianceChannelMgr,
|
||||
Team.Horde => hordeChannelMgr,
|
||||
Team.PandariaNeutral => neutralChannelMgr,
|
||||
_ => null
|
||||
};
|
||||
}
|
||||
|
||||
public static Channel GetChannelForPlayerByNamePart(string namePart, Player playerSearcher)
|
||||
@@ -239,5 +239,6 @@ namespace Game.Chat
|
||||
|
||||
static ChannelManager allianceChannelMgr = new(Team.Alliance);
|
||||
static ChannelManager hordeChannelMgr = new(Team.Horde);
|
||||
static ChannelManager neutralChannelMgr = new(Team.PandariaNeutral);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -683,17 +683,11 @@ namespace Game.Chat
|
||||
|
||||
if (linked == "linked")
|
||||
{
|
||||
Battleground bg = player.GetBattleground();
|
||||
if (bg != null)
|
||||
nearestLoc = bg.GetClosestGraveyard(player);
|
||||
BattleField bf = Global.BattleFieldMgr.GetBattlefieldToZoneId(player.GetMap(), player.GetZoneId());
|
||||
if (bf != null)
|
||||
nearestLoc = bf.GetClosestGraveyard(player);
|
||||
else
|
||||
{
|
||||
BattleField bf = Global.BattleFieldMgr.GetBattlefieldToZoneId(player.GetMap(), player.GetZoneId());
|
||||
if (bf != null)
|
||||
nearestLoc = bf.GetClosestGraveyard(player);
|
||||
else
|
||||
nearestLoc = Global.ObjectMgr.GetClosestGraveyard(player, player.GetTeam(), player);
|
||||
}
|
||||
nearestLoc = Global.ObjectMgr.GetClosestGraveyard(player, player.GetTeam(), player);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -788,11 +782,7 @@ namespace Game.Chat
|
||||
return false;
|
||||
}
|
||||
|
||||
var playerConditionEntry = CliDB.PlayerConditionStorage.LookupByKey(playerConditionId);
|
||||
if (playerConditionEntry == null)
|
||||
return false;
|
||||
|
||||
if (ConditionManager.IsPlayerMeetingCondition(target, playerConditionEntry))
|
||||
if (ConditionManager.IsPlayerMeetingCondition(target, playerConditionId))
|
||||
handler.SendSysMessage($"PlayerCondition {playerConditionId} met");
|
||||
else
|
||||
handler.SendSysMessage($"PlayerCondition {playerConditionId} not met");
|
||||
|
||||
@@ -123,7 +123,7 @@ namespace Game.Chat
|
||||
|
||||
if (normalizePlayerName(*playerNameArg))
|
||||
{
|
||||
if (Player * player = ObjectAccessor::FindPlayerByName(*playerNameArg))
|
||||
if (Player * player = Global.ObjAccessor.FindPlayerByName(*playerNameArg))
|
||||
{
|
||||
handler->GetSession()->GetPlayer()->RemoveFromWhisperWhiteList(player->GetGUID());
|
||||
handler->PSendSysMessage(LANG_COMMAND_WHISPEROFFPLAYER, playerNameArg->c_str());
|
||||
|
||||
@@ -839,8 +839,7 @@ namespace Game.Chat
|
||||
{
|
||||
if (a.GetMovementGeneratorType() == MovementGeneratorType.Follow)
|
||||
{
|
||||
FollowMovementGenerator followMovement = a as FollowMovementGenerator;
|
||||
return followMovement != null && followMovement.GetTarget() == player;
|
||||
return a is FollowMovementGenerator followMovement && followMovement.GetTarget() == player;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
@@ -17,35 +17,10 @@ namespace Game.Chat
|
||||
if (info == null)
|
||||
return default;
|
||||
|
||||
ChatCommandResult errorResult = ChatCommandResult.FromErrorMessage(handler.GetCypherString(CypherStrings.CmdparserLinkdataInvalid));
|
||||
|
||||
// store value
|
||||
switch (Type.GetTypeCode(type))
|
||||
{
|
||||
case TypeCode.UInt32:
|
||||
{
|
||||
if (!uint.TryParse(info.Data, out uint tempValue))
|
||||
return errorResult;
|
||||
|
||||
value = tempValue;
|
||||
break;
|
||||
}
|
||||
case TypeCode.UInt64:
|
||||
{
|
||||
if (!ulong.TryParse(info.Data, out ulong tempValue))
|
||||
return errorResult;
|
||||
|
||||
value = tempValue;
|
||||
break;
|
||||
}
|
||||
case TypeCode.String:
|
||||
{
|
||||
value = info.Data;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return errorResult;
|
||||
}
|
||||
HyperlinkDataTokenizer t = new(info.Data, true);
|
||||
if (!t.TryConsumeTo(out value, type))
|
||||
return new ChatCommandResult(handler.GetCypherString(CypherStrings.CmdparserLinkdataInvalid));
|
||||
|
||||
// finally, skip any potential delimiters
|
||||
var (token, next) = info.Tail.Tokenize();
|
||||
@@ -101,7 +76,6 @@ namespace Game.Chat
|
||||
|
||||
static byte toHex(char c) { return (byte)((c >= '0' && c <= '9') ? c - '0' + 0x10 : (c >= 'a' && c <= 'f') ? c - 'a' + 0x1a : 0x00); }
|
||||
|
||||
//|color|Henchant:recipe_spell_id|h[prof_name: recipe_name]|h|r
|
||||
public static HyperlinkInfo ParseHyperlink(string currentString)
|
||||
{
|
||||
if (currentString.IsEmpty())
|
||||
|
||||
@@ -2,7 +2,11 @@
|
||||
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
|
||||
|
||||
using Framework.IO;
|
||||
using Game.DataStorage;
|
||||
using Game.Entities;
|
||||
using Game.Spells;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Game.Chat
|
||||
{
|
||||
@@ -14,136 +18,95 @@ namespace Game.Chat
|
||||
_allowEmptyTokens = allowEmptyTokens;
|
||||
}
|
||||
|
||||
public bool TryConsumeTo(out byte val)
|
||||
public bool TryConsumeTo(out dynamic val, Type type)
|
||||
{
|
||||
val = default;
|
||||
|
||||
if (IsEmpty())
|
||||
{
|
||||
val = default;
|
||||
return _allowEmptyTokens;
|
||||
|
||||
switch (Type.GetTypeCode(type))
|
||||
{
|
||||
case TypeCode.SByte:
|
||||
val = _arg.NextByte(":");
|
||||
return true;
|
||||
case TypeCode.Int16:
|
||||
val = _arg.NextUInt16(":");
|
||||
return true;
|
||||
case TypeCode.Int32:
|
||||
val = _arg.NextUInt32(":");
|
||||
return true;
|
||||
case TypeCode.Int64:
|
||||
val = _arg.NextUInt64(":");
|
||||
return true;
|
||||
case TypeCode.Byte:
|
||||
val = _arg.NextByte(":");
|
||||
return true;
|
||||
case TypeCode.UInt16:
|
||||
val = _arg.NextUInt16(":");
|
||||
return true;
|
||||
case TypeCode.UInt32:
|
||||
val = _arg.NextUInt32(":");
|
||||
return true;
|
||||
case TypeCode.UInt64:
|
||||
val = _arg.NextUInt64(":");
|
||||
return true;
|
||||
case TypeCode.Single:
|
||||
val = _arg.NextSingle(":");
|
||||
return true;
|
||||
case TypeCode.Double:
|
||||
val = _arg.NextDouble(":");
|
||||
return true;
|
||||
case TypeCode.String:
|
||||
val = _arg.NextString(":");
|
||||
return true;
|
||||
case TypeCode.Object:
|
||||
{
|
||||
switch (type.Name)
|
||||
{
|
||||
case nameof(AchievementRecord):
|
||||
val = CliDB.AchievementStorage.LookupByKey(_arg.NextUInt32(":"));
|
||||
if (val != null)
|
||||
return true;
|
||||
break;
|
||||
case nameof(CurrencyTypesRecord):
|
||||
val = CliDB.CurrencyTypesStorage.LookupByKey(_arg.NextUInt32(":"));
|
||||
if (val != null)
|
||||
return true;
|
||||
break;
|
||||
case nameof(GameTele):
|
||||
val = Global.ObjectMgr.GetGameTele(_arg.NextUInt32(":"));
|
||||
if (val != null)
|
||||
return true;
|
||||
break;
|
||||
case nameof(ItemTemplate):
|
||||
val = Global.ObjectMgr.GetItemTemplate(_arg.NextUInt32(":"));
|
||||
if (val != null)
|
||||
return true;
|
||||
break;
|
||||
case nameof(Quest):
|
||||
val = Global.ObjectMgr.GetQuestTemplate(_arg.NextUInt32(":"));
|
||||
if (val != null)
|
||||
return true;
|
||||
break;
|
||||
case nameof(SpellInfo):
|
||||
val = Global.SpellMgr.GetSpellInfo(_arg.NextUInt32(":"), Framework.Constants.Difficulty.None);
|
||||
if (val != null)
|
||||
return true;
|
||||
break;
|
||||
case nameof(ObjectGuid):
|
||||
val = ObjectGuid.FromString(_arg.NextString(":"));
|
||||
if (val != ObjectGuid.FromStringFailed)
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
val = _arg.NextByte(":");
|
||||
return true;
|
||||
}
|
||||
public bool TryConsumeTo(out ushort val)
|
||||
{
|
||||
if (IsEmpty())
|
||||
{
|
||||
val = default;
|
||||
return _allowEmptyTokens;
|
||||
}
|
||||
val = _arg.NextUInt16(":");
|
||||
return true;
|
||||
}
|
||||
public bool TryConsumeTo(out uint val)
|
||||
{
|
||||
if (IsEmpty())
|
||||
{
|
||||
val = default;
|
||||
return _allowEmptyTokens;
|
||||
}
|
||||
|
||||
val = _arg.NextUInt32(":");
|
||||
return true;
|
||||
}
|
||||
public bool TryConsumeTo(out ulong val)
|
||||
{
|
||||
if (IsEmpty())
|
||||
{
|
||||
val = default;
|
||||
return _allowEmptyTokens;
|
||||
}
|
||||
|
||||
val = _arg.NextUInt64(":");
|
||||
return true;
|
||||
}
|
||||
public bool TryConsumeTo(out sbyte val)
|
||||
{
|
||||
if (IsEmpty())
|
||||
{
|
||||
val = default;
|
||||
return _allowEmptyTokens;
|
||||
}
|
||||
|
||||
val = _arg.NextSByte(":");
|
||||
return true;
|
||||
}
|
||||
public bool TryConsumeTo(out short val)
|
||||
{
|
||||
if (IsEmpty())
|
||||
{
|
||||
val = default;
|
||||
return _allowEmptyTokens;
|
||||
}
|
||||
|
||||
val = _arg.NextInt16(":");
|
||||
return true;
|
||||
}
|
||||
public bool TryConsumeTo(out int val)
|
||||
{
|
||||
if (IsEmpty())
|
||||
{
|
||||
val = default;
|
||||
return _allowEmptyTokens;
|
||||
}
|
||||
|
||||
val = _arg.NextInt32(":");
|
||||
return true;
|
||||
}
|
||||
public bool TryConsumeTo(out long val)
|
||||
{
|
||||
if (IsEmpty())
|
||||
{
|
||||
val = default;
|
||||
return _allowEmptyTokens;
|
||||
}
|
||||
|
||||
val = _arg.NextInt64(":");
|
||||
return true;
|
||||
}
|
||||
public bool TryConsumeTo(out float val)
|
||||
{
|
||||
if (IsEmpty())
|
||||
{
|
||||
val = default;
|
||||
return _allowEmptyTokens;
|
||||
}
|
||||
|
||||
val = _arg.NextSingle(":");
|
||||
return true;
|
||||
}
|
||||
public bool TryConsumeTo(out ObjectGuid val)
|
||||
{
|
||||
if (IsEmpty())
|
||||
{
|
||||
val = default;
|
||||
return _allowEmptyTokens;
|
||||
}
|
||||
|
||||
val = ObjectGuid.FromString(_arg.NextString(":"));
|
||||
return true;
|
||||
}
|
||||
public bool TryConsumeTo(out string val)
|
||||
{
|
||||
if (IsEmpty())
|
||||
{
|
||||
val = default;
|
||||
return _allowEmptyTokens;
|
||||
}
|
||||
|
||||
val = _arg.NextString(":");
|
||||
return true;
|
||||
}
|
||||
public bool TryConsumeTo(out bool val)
|
||||
{
|
||||
if (IsEmpty())
|
||||
{
|
||||
val = default;
|
||||
return _allowEmptyTokens;
|
||||
}
|
||||
|
||||
val = _arg.NextBoolean(":");
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool IsEmpty() { return _arg.Empty(); }
|
||||
@@ -151,4 +114,4 @@ namespace Game.Chat
|
||||
StringArguments _arg;
|
||||
bool _allowEmptyTokens;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user