From 30d198cfbd39968b5691f9596c29afa6ea07b19a Mon Sep 17 00:00:00 2001 From: hondacrx Date: Mon, 27 Dec 2021 16:41:32 -0500 Subject: [PATCH] Scripts/Commands: update .wp commands to use orientation field from DB Port From (https://github.com/TrinityCore/TrinityCore/commit/61cc88731c8941289352a1aaa6410bc3dce83faa) --- .../Framework/Database/Databases/WorldDatabase.cs | 8 ++++---- Source/Game/Chat/Commands/DebugCommands.cs | 2 +- Source/Game/Chat/Commands/WPCommands.cs | 14 ++++++++------ 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Source/Framework/Database/Databases/WorldDatabase.cs b/Source/Framework/Database/Databases/WorldDatabase.cs index f1588b295..fa9cf9e0e 100644 --- a/Source/Framework/Database/Databases/WorldDatabase.cs +++ b/Source/Framework/Database/Databases/WorldDatabase.cs @@ -44,16 +44,16 @@ namespace Framework.Database PrepareStatement(WorldStatements.UPD_CREATURE_SPAWN_DISTANCE, "UPDATE creature SET spawndist = ?, MovementType = ? WHERE guid = ?"); PrepareStatement(WorldStatements.UPD_CREATURE_SPAWN_TIME_SECS, "UPDATE creature SET spawntimesecs = ? WHERE guid = ?"); PrepareStatement(WorldStatements.INS_CREATURE_FORMATION, "INSERT INTO creature_formations (leaderGUID, memberGUID, dist, angle, groupAI) VALUES (?, ?, ?, ?, ?)"); - PrepareStatement(WorldStatements.INS_WAYPOINT_DATA, "INSERT INTO waypoint_data (id, point, position_x, position_y, position_z) VALUES (?, ?, ?, ?, ?)"); + PrepareStatement(WorldStatements.INS_WAYPOINT_DATA, "INSERT INTO waypoint_data (id, point, position_x, position_y, position_z, orientation) VALUES (?, ?, ?, ?, ?, ?)"); PrepareStatement(WorldStatements.DEL_WAYPOINT_DATA, "DELETE FROM waypoint_data WHERE id = ? AND point = ?"); PrepareStatement(WorldStatements.UPD_WAYPOINT_DATA_POINT, "UPDATE waypoint_data SET point = point - 1 WHERE id = ? AND point > ?"); - PrepareStatement(WorldStatements.UPD_WAYPOINT_DATA_POSITION, "UPDATE waypoint_data SET position_x = ?, position_y = ?, position_z = ? where id = ? AND point = ?"); + PrepareStatement(WorldStatements.UPD_WAYPOINT_DATA_POSITION, "UPDATE waypoint_data SET position_x = ?, position_y = ?, position_z = ?, orientation = ? where id = ? AND point = ?"); PrepareStatement(WorldStatements.UPD_WAYPOINT_DATA_WPGUID, "UPDATE waypoint_data SET wpguid = ? WHERE id = ? and point = ?"); PrepareStatement(WorldStatements.SEL_WAYPOINT_DATA_MAX_ID, "SELECT MAX(id) FROM waypoint_data"); PrepareStatement(WorldStatements.SEL_WAYPOINT_DATA_MAX_POINT, "SELECT MAX(point) FROM waypoint_data WHERE id = ?"); PrepareStatement(WorldStatements.SEL_WAYPOINT_DATA_BY_ID, "SELECT point, position_x, position_y, position_z, orientation, move_type, delay, action, action_chance FROM waypoint_data WHERE id = ? ORDER BY point"); - PrepareStatement(WorldStatements.SEL_WAYPOINT_DATA_POS_BY_ID, "SELECT point, position_x, position_y, position_z FROM waypoint_data WHERE id = ?"); - PrepareStatement(WorldStatements.SEL_WAYPOINT_DATA_POS_FIRST_BY_ID, "SELECT position_x, position_y, position_z FROM waypoint_data WHERE point = 1 AND id = ?"); + PrepareStatement(WorldStatements.SEL_WAYPOINT_DATA_POS_BY_ID, "SELECT point, position_x, position_y, position_z, orientation FROM waypoint_data WHERE id = ?"); + PrepareStatement(WorldStatements.SEL_WAYPOINT_DATA_POS_FIRST_BY_ID, "SELECT position_x, position_y, position_z, orientation FROM waypoint_data WHERE point = 1 AND id = ?"); PrepareStatement(WorldStatements.SEL_WAYPOINT_DATA_POS_LAST_BY_ID, "SELECT position_x, position_y, position_z, orientation FROM waypoint_data WHERE id = ? ORDER BY point DESC LIMIT 1"); PrepareStatement(WorldStatements.SEL_WAYPOINT_DATA_BY_WPGUID, "SELECT id, point FROM waypoint_data WHERE wpguid = ?"); PrepareStatement(WorldStatements.SEL_WAYPOINT_DATA_ALL_BY_WPGUID, "SELECT id, point, delay, move_type, action, action_chance FROM waypoint_data WHERE wpguid = ?"); diff --git a/Source/Game/Chat/Commands/DebugCommands.cs b/Source/Game/Chat/Commands/DebugCommands.cs index a5dea619b..0d290e651 100644 --- a/Source/Game/Chat/Commands/DebugCommands.cs +++ b/Source/Game/Chat/Commands/DebugCommands.cs @@ -1114,7 +1114,7 @@ namespace Game.Chat { Player player = handler.GetSession().GetPlayer(); - Log.outInfo(LogFilter.SqlDev, "(@PATH, XX, {0}, {1}, {2}, 0, 0, 0, 100, 0),", player.GetPositionX(), player.GetPositionY(), player.GetPositionZ()); + Log.outInfo(LogFilter.SqlDev, $"(@PATH, XX, {player.GetPositionX():3F}, {player.GetPositionY():3F}, {player.GetPositionZ():5F}, {player.GetOrientation():5F}, 0, 0, 0, 100, 0)"); handler.SendSysMessage("Waypoint SQL written to SQL Developer log"); return true; diff --git a/Source/Game/Chat/Commands/WPCommands.cs b/Source/Game/Chat/Commands/WPCommands.cs index ac104f3ac..c0722dd5c 100644 --- a/Source/Game/Chat/Commands/WPCommands.cs +++ b/Source/Game/Chat/Commands/WPCommands.cs @@ -87,6 +87,7 @@ namespace Game.Chat.Commands stmt.AddValue(2, player.GetPositionX()); stmt.AddValue(3, player.GetPositionY()); stmt.AddValue(4, player.GetPositionZ()); + stmt.AddValue(5, player.GetOrientation()); DB.World.Execute(stmt); @@ -579,8 +580,9 @@ namespace Game.Chat.Commands stmt.AddValue(0, chr.GetPositionX()); stmt.AddValue(1, chr.GetPositionY()); stmt.AddValue(2, chr.GetPositionZ()); - stmt.AddValue(3, pathid); - stmt.AddValue(4, point); + stmt.AddValue(3, chr.GetOrientation()); + stmt.AddValue(4, pathid); + stmt.AddValue(5, point); DB.World.Execute(stmt); handler.SendSysMessage(CypherStrings.WaypointChanged); @@ -753,14 +755,14 @@ namespace Game.Chat.Commands float x = result.Read(1); float y = result.Read(2); float z = result.Read(3); + float o = result.Read(4); uint id = 1; Player chr = handler.GetSession().GetPlayer(); Map map = chr.GetMap(); - Position pos = new(x, y, z, chr.GetOrientation()); - Creature creature = Creature.CreateCreature(id, map, pos); + Creature creature = Creature.CreateCreature(id, map, new Position(x, y, z, o)); if (!creature) { handler.SendSysMessage(CypherStrings.WaypointVpNotcreated, id); @@ -821,12 +823,12 @@ namespace Game.Chat.Commands float x = result.Read(0); float y = result.Read(1); float z = result.Read(2); + float o = result.Read(3); Player chr = handler.GetSession().GetPlayer(); Map map = chr.GetMap(); - Position pos = new(x, y, z, chr.GetOrientation()); - Creature creature = Creature.CreateCreature(1, map, pos); + Creature creature = Creature.CreateCreature(1, map, new Position(x, y, z, 0)); if (!creature) { handler.SendSysMessage(CypherStrings.WaypointVpNotcreated, 1);