From 93bbff4cca74b2bbadc88f9bf36ebc016ba4795f Mon Sep 17 00:00:00 2001 From: acidmanifesto Date: Sat, 6 Nov 2021 07:43:45 -0400 Subject: [PATCH] feat(Core/SAI): Wp table add in orientation and delay collumn (#8927) ADD (Core) Wp table add in orientation and delay collumn TC Cherry pick of TrinityCore/TrinityCore@4b7d19c --- data/sql/updates/db_world/rev_1635951187866923861.sql | 4 ++++ .../database/Database/Implementation/WorldDatabase.cpp | 2 +- src/server/game/AI/SmartScripts/SmartScriptMgr.cpp | 6 ++++-- src/server/game/AI/SmartScripts/SmartScriptMgr.h | 6 +++++- 4 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 data/sql/updates/db_world/rev_1635951187866923861.sql diff --git a/data/sql/updates/db_world/rev_1635951187866923861.sql b/data/sql/updates/db_world/rev_1635951187866923861.sql new file mode 100644 index 000000000..f247d4a30 --- /dev/null +++ b/data/sql/updates/db_world/rev_1635951187866923861.sql @@ -0,0 +1,4 @@ +-- add revision +INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1635951187866923861'); +-- add orientation` and delay into existing wp table +ALTER TABLE `waypoints` ADD COLUMN `orientation` FLOAT DEFAULT 0 NOT NULL AFTER `position_z`, ADD COLUMN `delay` INT UNSIGNED DEFAULT 0 NOT NULL AFTER `orientation`; diff --git a/src/server/database/Database/Implementation/WorldDatabase.cpp b/src/server/database/Database/Implementation/WorldDatabase.cpp index cdbad128c..f2205cc0b 100644 --- a/src/server/database/Database/Implementation/WorldDatabase.cpp +++ b/src/server/database/Database/Implementation/WorldDatabase.cpp @@ -28,7 +28,7 @@ void WorldDatabaseConnection::DoPrepareStatements() PrepareStatement(WORLD_REP_CREATURE_LINKED_RESPAWN, "REPLACE INTO linked_respawn (guid, linkedGuid) VALUES (?, ?)", CONNECTION_ASYNC); PrepareStatement(WORLD_SEL_CREATURE_TEXT, "SELECT CreatureID, GroupID, ID, Text, Type, Language, Probability, Emote, Duration, Sound, BroadcastTextId, TextRange FROM creature_text", CONNECTION_SYNCH); PrepareStatement(WORLD_SEL_SMART_SCRIPTS, "SELECT entryorguid, source_type, id, link, event_type, event_phase_mask, event_chance, event_flags, event_param1, event_param2, event_param3, event_param4, event_param5, action_type, action_param1, action_param2, action_param3, action_param4, action_param5, action_param6, target_type, target_param1, target_param2, target_param3, target_param4, target_x, target_y, target_z, target_o FROM smart_scripts ORDER BY entryorguid, source_type, id, link", CONNECTION_SYNCH); - PrepareStatement(WORLD_SEL_SMARTAI_WP, "SELECT entry, pointid, position_x, position_y, position_z FROM waypoints ORDER BY entry, pointid", CONNECTION_SYNCH); + PrepareStatement(WORLD_SEL_SMARTAI_WP, "SELECT entry, pointid, position_x, position_y, position_z, orientation, delay FROM waypoints ORDER BY entry, pointid", CONNECTION_SYNCH); PrepareStatement(WORLD_DEL_GAMEOBJECT, "DELETE FROM gameobject WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(WORLD_DEL_EVENT_GAMEOBJECT, "DELETE FROM game_event_gameobject WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(WORLD_INS_GRAVEYARD_ZONE, "INSERT INTO graveyard_zone (ID, GhostZone, Faction) VALUES (?, ?, ?)", CONNECTION_ASYNC); diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp index dc66d22d9..e567b4a50 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp @@ -70,10 +70,12 @@ void SmartWaypointMgr::LoadFromDB() Field* fields = result->Fetch(); uint32 entry = fields[0].GetUInt32(); uint32 id = fields[1].GetUInt32(); - float x, y, z; + float x, y, z, o; x = fields[2].GetFloat(); y = fields[3].GetFloat(); z = fields[4].GetFloat(); + o = fields[5].GetFloat(); + uint32 delay = fields[6].GetUInt32(); if (last_entry != entry) { @@ -86,7 +88,7 @@ void SmartWaypointMgr::LoadFromDB() LOG_ERROR("sql.sql", "SmartWaypointMgr::LoadFromDB: Path entry %u, unexpected point id %u, expected %u.", entry, id, last_id); last_id++; - (*waypoint_map[entry])[id] = new WayPoint(id, x, y, z); + (*waypoint_map[entry])[id] = new WayPoint(id, x, y, z, o, delay); last_entry = entry; total++; diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h index ce9d229cc..4390de781 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h @@ -28,18 +28,22 @@ struct WayPoint { - WayPoint(uint32 _id, float _x, float _y, float _z) + WayPoint(uint32 _id, float _x, float _y, float _z, float _o, uint32 _delay) { id = _id; x = _x; y = _y; z = _z; + o = _o; + delay = _delay; } uint32 id; float x; float y; float z; + float o; + uint32 delay; }; enum SMART_EVENT_PHASE