Misc updates/fixes
This commit is contained in:
@@ -27,11 +27,8 @@ namespace Game.Chat
|
||||
class CastCommands
|
||||
{
|
||||
[Command("", RBACPermissions.CommandCast)]
|
||||
static bool HandleCastCommand(CommandHandler handler, StringArguments args)
|
||||
static bool HandleCastCommand(CommandHandler handler, SpellInfo spell, string triggeredStr)
|
||||
{
|
||||
if (args.Empty())
|
||||
return false;
|
||||
|
||||
Unit target = handler.GetSelectedUnit();
|
||||
if (!target)
|
||||
{
|
||||
@@ -39,22 +36,19 @@ namespace Game.Chat
|
||||
return false;
|
||||
}
|
||||
|
||||
// number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
|
||||
uint spellId = handler.ExtractSpellIdFromLink(args);
|
||||
if (spellId == 0)
|
||||
if (!CheckSpellExistsAndIsValid(handler, spell))
|
||||
return false;
|
||||
|
||||
if (!CheckSpellExistsAndIsValid(handler, spellId))
|
||||
return false;
|
||||
|
||||
string triggeredStr = args.NextString();
|
||||
if (!string.IsNullOrEmpty(triggeredStr))
|
||||
TriggerCastFlags triggerFlags = TriggerCastFlags.None;
|
||||
if (!triggeredStr.IsEmpty())
|
||||
{
|
||||
if (triggeredStr != "triggered")
|
||||
if ("triggered".Contains(triggeredStr)) // check if "triggered" starts with *triggeredStr (e.g. "trig", "trigger", etc.)
|
||||
triggerFlags = TriggerCastFlags.FullDebugMask;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
handler.GetSession().GetPlayer().CastSpell(target, spellId, !triggeredStr.IsEmpty());
|
||||
handler.GetSession().GetPlayer().CastSpell(target, spell.Id, new CastSpellExtraArgs(triggerFlags));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -228,7 +222,11 @@ namespace Game.Chat
|
||||
|
||||
static bool CheckSpellExistsAndIsValid(CommandHandler handler, uint spellId)
|
||||
{
|
||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId, Difficulty.None);
|
||||
return CheckSpellExistsAndIsValid(handler, Global.SpellMgr.GetSpellInfo(spellId, Difficulty.None));
|
||||
}
|
||||
|
||||
static bool CheckSpellExistsAndIsValid(CommandHandler handler, SpellInfo spellInfo)
|
||||
{
|
||||
if (spellInfo == null)
|
||||
{
|
||||
handler.SendSysMessage(CypherStrings.CommandNospellfound);
|
||||
@@ -237,7 +235,7 @@ namespace Game.Chat
|
||||
|
||||
if (!Global.SpellMgr.IsSpellValid(spellInfo, handler.GetPlayer()))
|
||||
{
|
||||
handler.SendSysMessage(CypherStrings.CommandSpellBroken, spellId);
|
||||
handler.SendSysMessage(CypherStrings.CommandSpellBroken, spellInfo.Id);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -144,7 +144,7 @@ namespace Game.Chat
|
||||
target.SetName(newName);
|
||||
session = target.GetSession();
|
||||
if (session != null)
|
||||
session.KickPlayer();
|
||||
session.KickPlayer("HandleCharacterRenameCommand GM Command renaming character");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -463,7 +463,7 @@ namespace Game.Chat
|
||||
{
|
||||
characterGuid = player.GetGUID();
|
||||
accountId = player.GetSession().GetAccountId();
|
||||
player.GetSession().KickPlayer();
|
||||
player.GetSession().KickPlayer("HandleCharacterEraseCommand GM Command deleting character");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1331,6 +1331,41 @@ namespace Game.Chat
|
||||
}
|
||||
}
|
||||
|
||||
[CommandGroup("pvp", RBACPermissions.CommandDebug)]
|
||||
class PvpCommands
|
||||
{
|
||||
[Command("warmode", RBACPermissions.CommandDebug)]
|
||||
static bool HandleDebugWarModeFactionBalanceCommand(CommandHandler handler, string command, int rewardValue = 0)
|
||||
{
|
||||
// USAGE: .debug pvp fb <alliance|horde|neutral|off> [pct]
|
||||
// neutral Sets faction balance off.
|
||||
// alliance Set faction balance to alliance.
|
||||
// horde Set faction balance to horde.
|
||||
// off Reset the faction balance and use the calculated value of it
|
||||
switch (command.ToLower())
|
||||
{
|
||||
default: // workaround for Variant of only ExactSequences not being supported
|
||||
handler.SendSysMessage(CypherStrings.BadValue);
|
||||
return false;
|
||||
case "alliance":
|
||||
Global.WorldMgr.SetForcedWarModeFactionBalanceState(TeamId.Alliance, rewardValue);
|
||||
break;
|
||||
case "horde":
|
||||
Global.WorldMgr.SetForcedWarModeFactionBalanceState(TeamId.Horde, rewardValue);
|
||||
break;
|
||||
case "neutral":
|
||||
Global.WorldMgr.SetForcedWarModeFactionBalanceState(TeamId.Neutral);
|
||||
break;
|
||||
case "off":
|
||||
Global.WorldMgr.DisableForcedWarModeFactionBalanceState();
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[CommandGroup("send", RBACPermissions.CommandDebugSend)]
|
||||
class SendCommands
|
||||
{
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace Game.Chat.Commands
|
||||
return DoTeleport(handler, new Position(at.Pos.X, at.Pos.Y, at.Pos.Z), at.ContinentID);
|
||||
}
|
||||
|
||||
[Command("areatrigger", RBACPermissions.CommandGo)]
|
||||
[Command("boss", RBACPermissions.CommandGo)]
|
||||
static bool HandleGoBossCommand(CommandHandler handler, string[] needles)
|
||||
{
|
||||
if (needles.Empty())
|
||||
|
||||
@@ -1115,7 +1115,7 @@ namespace Game.Chat
|
||||
else
|
||||
handler.SendSysMessage(CypherStrings.CommandKickmessage, playerName);
|
||||
|
||||
target.GetSession().KickPlayer();
|
||||
target.GetSession().KickPlayer("HandleKickPlayerCommand GM Command");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -114,6 +114,50 @@ namespace Game.Chat
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool CheckAllLinks(string str)
|
||||
{
|
||||
// Step 1: Disallow all control sequences except ||, |H, |h, |c and |r
|
||||
{
|
||||
int pos = 0;
|
||||
while ((pos = str.IndexOf('|', pos)) != -1)
|
||||
{
|
||||
char next = str[pos + 1];
|
||||
if (next == 'H' || next == 'h' || next == 'c' || next == 'r' || next == '|')
|
||||
pos += 2;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Step 2: Parse all link sequences
|
||||
// They look like this: |c<color>|H<linktag>:<linkdata>|h[<linktext>]|h|r
|
||||
// - <color> is 8 hex characters AARRGGBB
|
||||
// - <linktag> is arbitrary length [a-z_]
|
||||
// - <linkdata> is arbitrary length, no | contained
|
||||
// - <linktext> is printable
|
||||
{
|
||||
int pos = 0;
|
||||
while ((pos = str.IndexOf('|', pos)) != -1)
|
||||
{
|
||||
if (str[pos + 1] == '|') // this is an escaped pipe character (||)
|
||||
{
|
||||
pos += 2;
|
||||
continue;
|
||||
}
|
||||
|
||||
HyperlinkInfo info = ParseHyperlink(str.Substring(pos));
|
||||
if (info == null)// todo fix me || !ValidateLinkInfo(info))
|
||||
return false;
|
||||
|
||||
// tag is fine, find the next one
|
||||
pos = str.Length - info.next.Length;
|
||||
}
|
||||
}
|
||||
|
||||
// all tags are valid
|
||||
return true;
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user