Skip to content

Commit 231e248

Browse files
author
Github Actions
committed
Merge 3.3.5-base_patch to 3.3.5-passive_anticheat
2 parents 3e8ebca + b10dbb3 commit 231e248

File tree

37 files changed

+131
-200
lines changed

37 files changed

+131
-200
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
-- Shift existing rows by 3 bits to reserve space for 3 other tables
2+
UPDATE `waypoint_data` SET `id`=(`id` << 3) ORDER BY `id` DESC;
3+
UPDATE `creature_addon` SET `path_id`=(`path_id` << 3);
4+
UPDATE `event_scripts` SET `datalong`=(`datalong` << 3) WHERE `command`=20 AND `datalong` > 0;
5+
UPDATE `event_scripts` SET `dataint`=(`dataint` << 3) WHERE `command`=35 AND `datalong`=2 AND `dataint` > 0;
6+
UPDATE `spell_scripts` SET `datalong`=(`datalong` << 3) WHERE `command`=20 AND `datalong` > 0;
7+
UPDATE `spell_scripts` SET `dataint`=(`dataint` << 3) WHERE `command`=35 AND `datalong`=2 AND `dataint` > 0;
8+
UPDATE `waypoint_scripts` SET `datalong`=(`datalong` << 3) WHERE `command`=20 AND `datalong` > 0;
9+
UPDATE `waypoint_scripts` SET `dataint`=(`dataint` << 3) WHERE `command`=35 AND `datalong`=2 AND `dataint` > 0;
10+
11+
-- use bit 0 for waypoints
12+
DELETE FROM `waypoint_data` WHERE `id` & 1;
13+
INSERT INTO `waypoint_data` (`id`, `point`, `position_x`, `position_y`, `position_z`, `orientation`, `delay`, `move_type`)
14+
SELECT ((w.`entry` << 3) | 1), w.`pointid`, w.`position_x`, w.`position_y`, w.`position_z`, w.`orientation`, w.`delay`, MAX(IFNULL(ss.`action_param1`, 0))
15+
FROM `waypoints` w
16+
LEFT JOIN `smart_scripts` ss ON w.`entry`=ss.`action_param2` AND ss.`action_type`=53 AND ss.`action_param2` > 0
17+
GROUP BY ((w.`entry` << 3) | 1), w.`pointid`, w.`position_x`, w.`position_y`, w.`position_z`, w.`orientation`, w.`delay`;
18+
19+
UPDATE `smart_scripts` SET `action_param2`=((`action_param2` << 3) | 1) WHERE `action_type`=53 AND `action_param2` > 0;
20+
UPDATE `smart_scripts` SET `action_param1`=((`action_param1` << 3) | 1) WHERE `action_type`=113 AND `action_param1` > 0;
21+
UPDATE `smart_scripts` SET `action_param2`=((`action_param2` << 3) | 1) WHERE `action_type`=113 AND `action_param2` > 0;
22+
UPDATE `smart_scripts` SET `action_param3`=((`action_param3` << 3) | 1) WHERE `action_type`=113 AND `action_param3` > 0;
23+
UPDATE `smart_scripts` SET `action_param4`=((`action_param4` << 3) | 1) WHERE `action_type`=113 AND `action_param4` > 0;
24+
UPDATE `smart_scripts` SET `action_param5`=((`action_param5` << 3) | 1) WHERE `action_type`=113 AND `action_param5` > 0;
25+
UPDATE `smart_scripts` SET `action_param6`=((`action_param6` << 3) | 1) WHERE `action_type`=113 AND `action_param6` > 0;
26+
UPDATE `smart_scripts` SET `event_param2`=((`event_param2` << 3) | 1) WHERE `event_type` IN(40, 55, 56, 57, 58) AND `event_param2` > 0;
27+
28+
DROP TABLE IF EXISTS `waypoints`;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- move missing pathids in template_addon
2+
UPDATE `creature_template_addon` SET `path_id`=(`path_id` << 3);

src/common/GitRevision.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,13 @@ char const* GitRevision::GetCMakeVersion()
4545

4646
char const* GitRevision::GetHostOSVersion()
4747
{
48-
return
48+
return ""
4949
#ifdef TRINITY_BUILD_HOST_DISTRO_NAME
50-
TRINITY_BUILD_HOST_DISTRO_NAME " " TRINITY_BUILD_HOST_DISTRO_VERSION_ID "; "
50+
TRINITY_BUILD_HOST_DISTRO_NAME
51+
#ifdef TRINITY_BUILD_HOST_DISTRO_VERSION_ID
52+
" " TRINITY_BUILD_HOST_DISTRO_VERSION_ID
53+
#endif
54+
"; "
5155
#endif
5256
TRINITY_BUILD_HOST_SYSTEM " " TRINITY_BUILD_HOST_SYSTEM_VERSION
5357
;

src/server/database/Database/Implementation/WorldDatabase.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ void WorldDatabaseConnection::DoPrepareStatements()
2828
PrepareStatement(WORLD_REP_LINKED_RESPAWN, "REPLACE INTO linked_respawn (guid, linkedGuid, linkType) VALUES (?, ?, ?)", CONNECTION_ASYNC);
2929
PrepareStatement(WORLD_SEL_CREATURE_TEXT, "SELECT CreatureID, GroupID, ID, Text, Type, Language, Probability, Emote, Duration, Sound, BroadcastTextId, TextRange FROM creature_text", CONNECTION_SYNCH);
3030
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);
31-
PrepareStatement(WORLD_SEL_SMARTAI_WP, "SELECT entry, pointid, position_x, position_y, position_z, orientation, delay FROM waypoints ORDER BY entry, pointid", CONNECTION_SYNCH);
3231
PrepareStatement(WORLD_DEL_GAMEOBJECT, "DELETE FROM gameobject WHERE guid = ?", CONNECTION_ASYNC);
3332
PrepareStatement(WORLD_DEL_EVENT_GAMEOBJECT, "DELETE FROM game_event_gameobject WHERE guid = ?", CONNECTION_ASYNC);
3433
PrepareStatement(WORLD_INS_GRAVEYARD_ZONE, "INSERT INTO graveyard_zone (ID, GhostZone, Faction) VALUES (?, ?, ?)", CONNECTION_ASYNC);

src/server/database/Database/Implementation/WorldDatabase.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ enum WorldDatabaseStatements : uint32
3333
WORLD_REP_LINKED_RESPAWN,
3434
WORLD_SEL_CREATURE_TEXT,
3535
WORLD_SEL_SMART_SCRIPTS,
36-
WORLD_SEL_SMARTAI_WP,
3736
WORLD_DEL_GAMEOBJECT,
3837
WORLD_DEL_EVENT_GAMEOBJECT,
3938
WORLD_INS_GRAVEYARD_ZONE,

src/server/game/AI/SmartScripts/SmartAI.cpp

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "ScriptMgr.h"
3030
#include "SpellAuras.h"
3131
#include "Vehicle.h"
32+
#include "WaypointManager.h"
3233

3334
SmartAI::SmartAI(Creature* creature) : CreatureAI(creature), _charmed(false), _followCreditType(0), _followArrivedTimer(0), _followCredit(0), _followArrivedEntry(0), _followDistance(0.f), _followAngle(0.f),
3435
_escortState(SMART_ESCORT_NONE), _escortNPCFlags(0), _escortInvokerCheckTimer(1000), _currentWaypointNode(0), _waypointReached(false), _waypointPauseTimer(0), _waypointPauseForced(false), _repeatWaypointPath(false),
@@ -43,20 +44,16 @@ bool SmartAI::IsAIControlled() const
4344
return !_charmed;
4445
}
4546

46-
void SmartAI::StartPath(bool run/* = false*/, uint32 pathId/* = 0*/, bool repeat/* = false*/, Unit* invoker/* = nullptr*/, uint32 nodeId/* = 1*/)
47+
void SmartAI::StartPath(uint32 pathId/* = 0*/, bool repeat/* = false*/, Unit* invoker/* = nullptr*/, uint32 nodeId/* = 1*/)
4748
{
4849
if (HasEscortState(SMART_ESCORT_ESCORTING))
4950
StopPath();
5051

51-
SetRun(run);
52-
53-
if (pathId)
54-
{
55-
if (!LoadPath(pathId))
56-
return;
57-
}
52+
if (!pathId)
53+
return;
5854

59-
if (_path.nodes.empty())
55+
WaypointPath const* path = LoadPath(pathId);
56+
if (!path)
6057
return;
6158

6259
_currentWaypointNode = nodeId;
@@ -73,32 +70,23 @@ void SmartAI::StartPath(bool run/* = false*/, uint32 pathId/* = 0*/, bool repeat
7370
me->ReplaceAllNpcFlags(UNIT_NPC_FLAG_NONE);
7471
}
7572

76-
me->GetMotionMaster()->MovePath(_path, _repeatWaypointPath);
73+
me->GetMotionMaster()->MovePath(pathId, _repeatWaypointPath);
7774
}
7875

79-
bool SmartAI::LoadPath(uint32 entry)
76+
WaypointPath const* SmartAI::LoadPath(uint32 entry)
8077
{
8178
if (HasEscortState(SMART_ESCORT_ESCORTING))
82-
return false;
79+
return nullptr;
8380

84-
WaypointPath const* path = sSmartWaypointMgr->GetPath(entry);
81+
WaypointPath const* path = sWaypointMgr->GetPath(entry);
8582
if (!path || path->nodes.empty())
8683
{
8784
GetScript()->SetPathId(0);
88-
return false;
89-
}
90-
91-
_path.id = path->id;
92-
_path.nodes = path->nodes;
93-
for (WaypointNode& waypoint : _path.nodes)
94-
{
95-
Trinity::NormalizeMapCoord(waypoint.x);
96-
Trinity::NormalizeMapCoord(waypoint.y);
97-
waypoint.moveType = _run ? WAYPOINT_MOVE_TYPE_RUN : WAYPOINT_MOVE_TYPE_WALK;
85+
return nullptr;
9886
}
9987

10088
GetScript()->SetPathId(entry);
101-
return true;
89+
return path;
10290
}
10391

10492
void SmartAI::PausePath(uint32 delay, bool forced)
@@ -189,7 +177,7 @@ void SmartAI::StopPath(uint32 DespawnTime, uint32 quest, bool fail)
189177
void SmartAI::EndPath(bool fail)
190178
{
191179
RemoveEscortState(SMART_ESCORT_ESCORTING | SMART_ESCORT_PAUSED | SMART_ESCORT_RETURNING);
192-
_path.nodes.clear();
180+
193181
_waypointPauseTimer = 0;
194182

195183
if (_escortNPCFlags)
@@ -251,7 +239,7 @@ void SmartAI::EndPath(bool fail)
251239
if (_repeatWaypointPath)
252240
{
253241
if (IsAIControlled())
254-
StartPath(_run, GetScript()->GetPathId(), _repeatWaypointPath);
242+
StartPath(GetScript()->GetPathId(), _repeatWaypointPath);
255243
}
256244
else if (pathid == GetScript()->GetPathId()) // if it's not the same pathid, our script wants to start another path; don't override it
257245
GetScript()->SetPathId(0);
@@ -373,7 +361,8 @@ void SmartAI::WaypointReached(uint32 nodeId, uint32 pathId)
373361
}
374362
else if (HasEscortState(SMART_ESCORT_ESCORTING) && me->GetMotionMaster()->GetCurrentMovementGeneratorType() == WAYPOINT_MOTION_TYPE)
375363
{
376-
if (_currentWaypointNode == _path.nodes.size())
364+
WaypointPath const* path = sWaypointMgr->GetPath(pathId);
365+
if (path && _currentWaypointNode == path->nodes.size())
377366
_waypointPathEnded = true;
378367
else
379368
SetRun(_run);
@@ -713,7 +702,7 @@ void SmartAI::OnCharmed(bool isNew)
713702
if (!charmed && !me->IsInEvadeMode())
714703
{
715704
if (_repeatWaypointPath)
716-
StartPath(_run, GetScript()->GetPathId(), true);
705+
StartPath(GetScript()->GetPathId(), true);
717706
else
718707
me->SetWalk(!_run);
719708

@@ -761,8 +750,6 @@ void SmartAI::SetRun(bool run)
761750
{
762751
me->SetWalk(!run);
763752
_run = run;
764-
for (auto& node : _path.nodes)
765-
node.moveType = run ? WAYPOINT_MOVE_TYPE_RUN : WAYPOINT_MOVE_TYPE_WALK;
766753
}
767754

768755
void SmartAI::SetDisableGravity(bool fly)

src/server/game/AI/SmartScripts/SmartAI.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ class TC_GAME_API SmartAI : public CreatureAI
4949
bool IsAIControlled() const;
5050

5151
// Start moving to the desired MovePoint
52-
void StartPath(bool run = false, uint32 pathId = 0, bool repeat = false, Unit* invoker = nullptr, uint32 nodeId = 1);
53-
bool LoadPath(uint32 entry);
52+
void StartPath(uint32 pathId = 0, bool repeat = false, Unit* invoker = nullptr, uint32 nodeId = 1);
53+
WaypointPath const* LoadPath(uint32 entry);
5454
void PausePath(uint32 delay, bool forced = false);
5555
bool CanResumePath();
5656
void StopPath(uint32 DespawnTime = 0, uint32 quest = 0, bool fail = false);
@@ -263,7 +263,6 @@ class TC_GAME_API SmartAI : public CreatureAI
263263
uint32 _escortState;
264264
uint32 _escortNPCFlags;
265265
uint32 _escortInvokerCheckTimer;
266-
WaypointPath _path;
267266
uint32 _currentWaypointNode;
268267
bool _waypointReached;
269268
uint32 _waypointPauseTimer;

src/server/game/AI/SmartScripts/SmartScript.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include "TemporarySummon.h"
4242
#include "Vehicle.h"
4343
#include "WaypointDefines.h"
44+
#include "WaypointManager.h"
4445
#include <G3D/Quat.h>
4546

4647
SmartScript::SmartScript()
@@ -1363,7 +1364,6 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
13631364
if (!IsSmart())
13641365
break;
13651366

1366-
bool run = e.action.wpStart.run != 0;
13671367
uint32 entry = e.action.wpStart.pathID;
13681368
bool repeat = e.action.wpStart.repeat != 0;
13691369

@@ -1376,7 +1376,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
13761376
}
13771377
}
13781378

1379-
ENSURE_AI(SmartAI, me->AI())->StartPath(run, entry, repeat, unit);
1379+
ENSURE_AI(SmartAI, me->AI())->StartPath(entry, repeat, unit);
13801380

13811381
uint32 quest = e.action.wpStart.quest;
13821382
uint32 DespawnTime = e.action.wpStart.despawnTime;
@@ -2008,7 +2008,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
20082008
{
20092009
for (uint32 pathId : waypoints)
20102010
{
2011-
WaypointPath const* path = sSmartWaypointMgr->GetPath(pathId);
2011+
WaypointPath const* path = sWaypointMgr->GetPath(pathId);
20122012
if (!path || path->nodes.empty())
20132013
continue;
20142014

@@ -2025,7 +2025,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
20252025
}
20262026

20272027
if (closest.first != 0)
2028-
ENSURE_AI(SmartAI, creature->AI())->StartPath(false, closest.first, true, nullptr, closest.second);
2028+
ENSURE_AI(SmartAI, creature->AI())->StartPath(closest.first, true, nullptr, closest.second);
20292029
}
20302030
}
20312031
}

src/server/game/AI/SmartScripts/SmartScriptMgr.cpp

Lines changed: 2 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "UnitDefines.h"
3232
#include "Unit.h"
3333
#include "WaypointDefines.h"
34+
#include "WaypointManager.h"
3435

3536
#define TC_SAI_IS_BOOLEAN_VALID(e, value) \
3637
{ \
@@ -42,77 +43,6 @@
4243
} \
4344
}
4445

45-
SmartWaypointMgr* SmartWaypointMgr::instance()
46-
{
47-
static SmartWaypointMgr instance;
48-
return &instance;
49-
}
50-
51-
void SmartWaypointMgr::LoadFromDB()
52-
{
53-
uint32 oldMSTime = getMSTime();
54-
55-
_waypointStore.clear();
56-
57-
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_SMARTAI_WP);
58-
PreparedQueryResult result = WorldDatabase.Query(stmt);
59-
60-
if (!result)
61-
{
62-
TC_LOG_INFO("server.loading", ">> Loaded 0 SmartAI Waypoint Paths. DB table `waypoints` is empty.");
63-
64-
return;
65-
}
66-
67-
uint32 count = 0;
68-
uint32 total = 0;
69-
uint32 lastEntry = 0;
70-
uint32 lastId = 1;
71-
72-
do
73-
{
74-
Field* fields = result->Fetch();
75-
uint32 entry = fields[0].GetUInt32();
76-
uint32 id = fields[1].GetUInt32();
77-
float x = fields[2].GetFloat();
78-
float y = fields[3].GetFloat();
79-
float z = fields[4].GetFloat();
80-
Optional<float> o;
81-
if (!fields[5].IsNull())
82-
o = fields[5].GetFloat();
83-
uint32 delay = fields[6].GetUInt32();
84-
85-
if (lastEntry != entry)
86-
{
87-
lastId = 1;
88-
++count;
89-
}
90-
91-
if (lastId != id)
92-
TC_LOG_ERROR("sql.sql", "SmartWaypointMgr::LoadFromDB: Path entry {}, unexpected point id {}, expected {}.", entry, id, lastId);
93-
94-
++lastId;
95-
96-
WaypointPath& path = _waypointStore[entry];
97-
path.id = entry;
98-
path.nodes.emplace_back(id, x, y, z, o, delay);
99-
100-
lastEntry = entry;
101-
++total;
102-
}
103-
while (result->NextRow());
104-
105-
TC_LOG_INFO("server.loading", ">> Loaded {} SmartAI waypoint paths (total {} waypoints) in {} ms", count, total, GetMSTimeDiffToNow(oldMSTime));
106-
}
107-
108-
WaypointPath const* SmartWaypointMgr::GetPath(uint32 id)
109-
{
110-
auto itr = _waypointStore.find(id);
111-
if (itr != _waypointStore.end())
112-
return &itr->second;
113-
return nullptr;
114-
}
115-
11646
SmartAIMgr* SmartAIMgr::instance()
11747
{
11848
static SmartAIMgr instance;
@@ -1756,7 +1686,7 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
17561686
break;
17571687
case SMART_ACTION_WP_START:
17581688
{
1759-
WaypointPath const* path = sSmartWaypointMgr->GetPath(e.action.wpStart.pathID);
1689+
WaypointPath const* path = sWaypointMgr->GetPath(e.action.wpStart.pathID);
17601690
if (!path || path->nodes.empty())
17611691
{
17621692
TC_LOG_ERROR("sql.sql", "SmartAIMgr: Creature {} Event {} Action {} uses non-existent WaypointPath id {}, skipped.", e.entryOrGuid, e.event_id, e.GetActionType(), e.action.wpStart.pathID);

src/server/game/AI/SmartScripts/SmartScriptMgr.h

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ struct SmartAction
864864

865865
struct
866866
{
867-
SAIBool run;
867+
SAIBool run; // unused / overridden by waypoint_data
868868
uint32 pathID;
869869
SAIBool repeat;
870870
uint32 quest;
@@ -1646,24 +1646,6 @@ class ObjectGuidVector
16461646
};
16471647
typedef std::unordered_map<uint32, ObjectGuidVector> ObjectVectorMap;
16481648

1649-
class TC_GAME_API SmartWaypointMgr
1650-
{
1651-
public:
1652-
static SmartWaypointMgr* instance();
1653-
1654-
void LoadFromDB();
1655-
1656-
WaypointPath const* GetPath(uint32 id);
1657-
1658-
private:
1659-
SmartWaypointMgr() { }
1660-
~SmartWaypointMgr() { }
1661-
1662-
std::unordered_map<uint32, WaypointPath> _waypointStore;
1663-
};
1664-
1665-
#define sSmartWaypointMgr SmartWaypointMgr::instance()
1666-
16671649
// all events for a single entry
16681650
typedef std::vector<SmartScriptHolder> SmartAIEventList;
16691651
typedef std::vector<SmartScriptHolder> SmartAIEventStoredList;

0 commit comments

Comments
 (0)