Core/Commands: Fixes npc delete command not working. Also addes missing TeleCommands.
This commit is contained in:
@@ -503,7 +503,7 @@ namespace Framework.Constants
|
|||||||
CommandZonenografaction = 461,
|
CommandZonenografaction = 461,
|
||||||
CommandTpAlreadyexist = 462,
|
CommandTpAlreadyexist = 462,
|
||||||
CommandTpAdded = 463,
|
CommandTpAdded = 463,
|
||||||
CommandTpAddederr = 464,
|
CommandTpAddedError = 464,
|
||||||
CommandTpDeleted = 465,
|
CommandTpDeleted = 465,
|
||||||
CommandNotaxinodefound = 466,
|
CommandNotaxinodefound = 466,
|
||||||
CommandTargetListauras = 467,
|
CommandTargetListauras = 467,
|
||||||
|
|||||||
@@ -863,7 +863,7 @@ namespace Game.Chat
|
|||||||
[CommandGroup("delete", RBACPermissions.CommandNpcDelete)]
|
[CommandGroup("delete", RBACPermissions.CommandNpcDelete)]
|
||||||
class DeleteCommands
|
class DeleteCommands
|
||||||
{
|
{
|
||||||
[Command("delete", RBACPermissions.CommandNpcDelete)]
|
[Command("", RBACPermissions.CommandNpcDelete)]
|
||||||
static bool HandleNpcDeleteCommand(StringArguments args, CommandHandler handler)
|
static bool HandleNpcDeleteCommand(StringArguments args, CommandHandler handler)
|
||||||
{
|
{
|
||||||
Creature creature;
|
Creature creature;
|
||||||
|
|||||||
@@ -16,10 +16,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
using Framework.Constants;
|
using Framework.Constants;
|
||||||
|
using Framework.Database;
|
||||||
using Framework.IO;
|
using Framework.IO;
|
||||||
using Game.DataStorage;
|
using Game.DataStorage;
|
||||||
using Game.Entities;
|
using Game.Entities;
|
||||||
using Game.Groups;
|
using Game.Groups;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Game.Chat
|
namespace Game.Chat
|
||||||
@@ -73,13 +75,60 @@ namespace Game.Chat
|
|||||||
[Command("add", RBACPermissions.CommandTeleAdd)]
|
[Command("add", RBACPermissions.CommandTeleAdd)]
|
||||||
static bool HandleTeleAddCommand(StringArguments args, CommandHandler handler)
|
static bool HandleTeleAddCommand(StringArguments args, CommandHandler handler)
|
||||||
{
|
{
|
||||||
return false;
|
if (args.Empty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Player player = handler.GetSession().GetPlayer();
|
||||||
|
if (player == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
string name = args.NextString();
|
||||||
|
|
||||||
|
if (Global.ObjectMgr.GetGameTele(name) != null)
|
||||||
|
{
|
||||||
|
handler.SendSysMessage(CypherStrings.CommandTpAlreadyexist);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameTele tele = new GameTele();
|
||||||
|
tele.posX = player.GetPositionX();
|
||||||
|
tele.posY = player.GetPositionY();
|
||||||
|
tele.posZ = player.GetPositionZ();
|
||||||
|
tele.orientation = player.GetOrientation();
|
||||||
|
tele.mapId = player.GetMapId();
|
||||||
|
tele.name = name;
|
||||||
|
tele.nameLow = name.ToLowerInvariant();
|
||||||
|
|
||||||
|
if (Global.ObjectMgr.AddGameTele(tele))
|
||||||
|
{
|
||||||
|
handler.SendSysMessage(CypherStrings.CommandTpAdded);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
handler.SendSysMessage(CypherStrings.CommandTpAddedError);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Command("del", RBACPermissions.CommandTeleDel, true)]
|
[Command("del", RBACPermissions.CommandTeleDel, true)]
|
||||||
static bool HandleTeleDelCommand(StringArguments args, CommandHandler handler)
|
static bool HandleTeleDelCommand(StringArguments args, CommandHandler handler)
|
||||||
{
|
{
|
||||||
return false;
|
if (args.Empty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
|
||||||
|
GameTele tele = handler.ExtractGameTeleFromLink(args);
|
||||||
|
if (tele == null)
|
||||||
|
{
|
||||||
|
handler.SendSysMessage(CypherStrings.CommandTeleNotfound);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Global.ObjectMgr.DeleteGameTele(tele.name);
|
||||||
|
handler.SendSysMessage(CypherStrings.CommandTpDeleted);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Command("group", RBACPermissions.CommandTeleGroup)]
|
[Command("group", RBACPermissions.CommandTeleGroup)]
|
||||||
@@ -164,7 +213,88 @@ namespace Game.Chat
|
|||||||
[Command("name", RBACPermissions.CommandTeleName, true)]
|
[Command("name", RBACPermissions.CommandTeleName, true)]
|
||||||
static bool HandleTeleNameCommand(StringArguments args, CommandHandler handler)
|
static bool HandleTeleNameCommand(StringArguments args, CommandHandler handler)
|
||||||
{
|
{
|
||||||
return false;
|
handler.ExtractOptFirstArg(args, out string nameStr, out string teleStr);
|
||||||
|
if (teleStr.IsEmpty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!handler.ExtractPlayerTarget(new StringArguments(nameStr), out Player target, out ObjectGuid targetGuid, out string targetName))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (teleStr.Equals("$home")) // References target's homebind
|
||||||
|
{
|
||||||
|
if (target)
|
||||||
|
target.TeleportTo(target.GetHomebind());
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_CHAR_HOMEBIND);
|
||||||
|
stmt.AddValue(0, targetGuid.GetCounter());
|
||||||
|
SQLResult result = DB.Characters.Query(stmt);
|
||||||
|
|
||||||
|
if (!result.IsEmpty())
|
||||||
|
{
|
||||||
|
WorldLocation loc = new WorldLocation(result.Read<ushort>(0), result.Read<float>(2), result.Read<float>(3), result.Read<float>(4), 0.0f);
|
||||||
|
uint zoneId = result.Read<ushort>(1);
|
||||||
|
|
||||||
|
Player.SavePositionInDB(loc, zoneId, targetGuid, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
|
||||||
|
GameTele tele = handler.ExtractGameTeleFromLink(new StringArguments(teleStr));
|
||||||
|
if (tele == null)
|
||||||
|
{
|
||||||
|
handler.SendSysMessage(CypherStrings.CommandTeleNotfound);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target)
|
||||||
|
{
|
||||||
|
// check online security
|
||||||
|
if (handler.HasLowerSecurity(target, ObjectGuid.Empty))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
string chrNameLink = handler.PlayerLink(targetName);
|
||||||
|
|
||||||
|
if (target.IsBeingTeleported() == true)
|
||||||
|
{
|
||||||
|
handler.SendSysMessage(CypherStrings.IsTeleported, chrNameLink);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
handler.SendSysMessage(CypherStrings.TeleportingTo, chrNameLink, "", tele.name);
|
||||||
|
if (handler.NeedReportToTarget(target))
|
||||||
|
target.SendSysMessage(CypherStrings.TeleportedToBy, handler.GetNameLink());
|
||||||
|
|
||||||
|
// stop flight if need
|
||||||
|
if (target.IsInFlight())
|
||||||
|
{
|
||||||
|
target.GetMotionMaster().MovementExpired();
|
||||||
|
target.CleanupAfterTaxiFlight();
|
||||||
|
}
|
||||||
|
// save only in non-flight case
|
||||||
|
else
|
||||||
|
target.SaveRecallPosition();
|
||||||
|
|
||||||
|
target.TeleportTo(tele.mapId, tele.posX, tele.posY, tele.posZ, tele.orientation);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// check offline security
|
||||||
|
if (handler.HasLowerSecurity(null, targetGuid))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
string nameLink = handler.PlayerLink(targetName);
|
||||||
|
|
||||||
|
handler.SendSysMessage(CypherStrings.TeleportingTo, nameLink, handler.GetCypherString(CypherStrings.Offline), tele.name);
|
||||||
|
|
||||||
|
Player.SavePositionInDB(new WorldLocation(tele.mapId, tele.posX, tele.posY, tele.posZ, tele.orientation),
|
||||||
|
Global.MapMgr.GetZoneId(PhasingHandler.EmptyPhaseShift, tele.mapId, tele.posX, tele.posY, tele.posZ), targetGuid, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4976,6 +4976,8 @@ namespace Game
|
|||||||
gt.mapId = result.Read<uint>(5);
|
gt.mapId = result.Read<uint>(5);
|
||||||
gt.name = result.Read<string>(6);
|
gt.name = result.Read<string>(6);
|
||||||
|
|
||||||
|
gt.nameLow = gt.name.ToLowerInvariant();
|
||||||
|
|
||||||
if (!GridDefines.IsValidMapCoord(gt.mapId, gt.posX, gt.posY, gt.posZ, gt.orientation))
|
if (!GridDefines.IsValidMapCoord(gt.mapId, gt.posX, gt.posY, gt.posZ, gt.orientation))
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.Sql, "Wrong position for id {0} (name: {1}) in `game_tele` table, ignoring.", id, gt.name);
|
Log.outError(LogFilter.Sql, "Wrong position for id {0} (name: {1}) in `game_tele` table, ignoring.", id, gt.name);
|
||||||
@@ -5438,7 +5440,53 @@ namespace Game
|
|||||||
}
|
}
|
||||||
public GameTele GetGameTele(string name)
|
public GameTele GetGameTele(string name)
|
||||||
{
|
{
|
||||||
return gameTeleStorage.Values.FirstOrDefault(p => p.name.ToLower() == name.ToLower());
|
return gameTeleStorage.Values.FirstOrDefault(p => p.nameLow == name.ToLower());
|
||||||
|
}
|
||||||
|
public bool AddGameTele(GameTele tele)
|
||||||
|
{
|
||||||
|
// find max id
|
||||||
|
uint newId = 0;
|
||||||
|
foreach (var itr in gameTeleStorage)
|
||||||
|
if (itr.Key > newId)
|
||||||
|
newId = itr.Key;
|
||||||
|
|
||||||
|
// use next
|
||||||
|
++newId;
|
||||||
|
|
||||||
|
gameTeleStorage[newId] = tele;
|
||||||
|
|
||||||
|
PreparedStatement stmt = DB.World.GetPreparedStatement(WorldStatements.INS_GAME_TELE);
|
||||||
|
|
||||||
|
stmt.AddValue(0, newId);
|
||||||
|
stmt.AddValue(1, tele.posX);
|
||||||
|
stmt.AddValue(2, tele.posY);
|
||||||
|
stmt.AddValue(3, tele.posZ);
|
||||||
|
stmt.AddValue(4, tele.orientation);
|
||||||
|
stmt.AddValue(5, tele.mapId);
|
||||||
|
stmt.AddValue(6, tele.name);
|
||||||
|
|
||||||
|
DB.World.Execute(stmt);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool DeleteGameTele(string name)
|
||||||
|
{
|
||||||
|
name = name.ToLowerInvariant();
|
||||||
|
|
||||||
|
foreach (var pair in gameTeleStorage.ToList())
|
||||||
|
{
|
||||||
|
if (pair.Value.nameLow == name)
|
||||||
|
{
|
||||||
|
PreparedStatement stmt = DB.World.GetPreparedStatement(WorldStatements.DEL_GAME_TELE);
|
||||||
|
stmt.AddValue(0, pair.Value.name);
|
||||||
|
DB.World.Execute(stmt);
|
||||||
|
|
||||||
|
gameTeleStorage.Remove(pair.Key);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
public List<DungeonEncounter> GetDungeonEncounterList(uint mapId, Difficulty difficulty)
|
public List<DungeonEncounter> GetDungeonEncounterList(uint mapId, Difficulty difficulty)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user