diff options
| author | Giacomo Pozzoni <giacomopoz@gmail.com> | 2021-12-27 13:33:37 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-27 13:33:37 +0100 |
| commit | 19e99db821ba5975e88ec160df3f4ff78ed562b0 (patch) | |
| tree | 00d21b3b614c385f56858b81005616c29c0d2f37 /src/server/game/AI | |
| parent | a9c80e4402a8b6b3a8a2fb478b700c16fc5ddbb4 (diff) | |
Core/AI: Fix crashes caused by charmed Creatures having null AI for 1 map update tick (#27434)
Implement using ScheduledChangeAI instead of nullptr to signal a required AI change
Diffstat (limited to 'src/server/game/AI')
| -rw-r--r-- | src/server/game/AI/CoreAI/ScheduledChangeAI.cpp | 21 | ||||
| -rw-r--r-- | src/server/game/AI/CoreAI/ScheduledChangeAI.h | 40 | ||||
| -rw-r--r-- | src/server/game/AI/CreatureAIRegistry.cpp | 2 |
3 files changed, 63 insertions, 0 deletions
diff --git a/src/server/game/AI/CoreAI/ScheduledChangeAI.cpp b/src/server/game/AI/CoreAI/ScheduledChangeAI.cpp new file mode 100644 index 00000000000..c4f513fcfa6 --- /dev/null +++ b/src/server/game/AI/CoreAI/ScheduledChangeAI.cpp @@ -0,0 +1,21 @@ +/* + * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "ScheduledChangeAI.h" + +ScheduledChangeAI::ScheduledChangeAI(Creature* creature): CreatureAI(creature) +{ } diff --git a/src/server/game/AI/CoreAI/ScheduledChangeAI.h b/src/server/game/AI/CoreAI/ScheduledChangeAI.h new file mode 100644 index 00000000000..79b8344eab0 --- /dev/null +++ b/src/server/game/AI/CoreAI/ScheduledChangeAI.h @@ -0,0 +1,40 @@ +/* + * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef TRINITY_SCHEDULEDCHANGEAI_H +#define TRINITY_SCHEDULEDCHANGEAI_H + +#include "CreatureAI.h" + +class TC_GAME_API ScheduledChangeAI final : public CreatureAI +{ + public: + explicit ScheduledChangeAI(Creature* creature); + + void MoveInLineOfSight(Unit*) override { } + void AttackStart(Unit*) override { } + void JustStartedThreateningMe(Unit*) override { } + void JustEnteredCombat(Unit*) override { } + void UpdateAI(uint32) override { } + void JustAppeared() override { } + void EnterEvadeMode(EvadeReason /*why*/) override { } + void OnCharmed(bool /*isNew*/) override { } + + static int Permissible(Creature const* /*creature*/) { return PERMIT_BASE_NO; } +}; + +#endif diff --git a/src/server/game/AI/CreatureAIRegistry.cpp b/src/server/game/AI/CreatureAIRegistry.cpp index 2ae35369966..50b9c5b34c8 100644 --- a/src/server/game/AI/CreatureAIRegistry.cpp +++ b/src/server/game/AI/CreatureAIRegistry.cpp @@ -23,6 +23,7 @@ #include "PassiveAI.h" #include "PetAI.h" #include "ReactorAI.h" +#include "ScheduledChangeAI.h" #include "SmartAI.h" #include "TotemAI.h" @@ -46,6 +47,7 @@ namespace AIRegistry (new CreatureAIFactory<TurretAI>("TurretAI"))->RegisterSelf(); (new CreatureAIFactory<VehicleAI>("VehicleAI"))->RegisterSelf(); (new CreatureAIFactory<SmartAI>("SmartAI"))->RegisterSelf(); + (new CreatureAIFactory<ScheduledChangeAI, false>("ScheduledChangeAI"))->RegisterSelf(); (new GameObjectAIFactory<NullGameObjectAI>("NullGameObjectAI"))->RegisterSelf(); (new GameObjectAIFactory<GameObjectAI>("GameObjectAI"))->RegisterSelf(); |
