Skip to content

Instantly share code, notes, and snippets.

@Shauren
Last active August 19, 2023 11:48
Show Gist options
  • Save Shauren/4793f21640df0a35b5506099e734d589 to your computer and use it in GitHub Desktop.
Save Shauren/4793f21640df0a35b5506099e734d589 to your computer and use it in GitHub Desktop.
diff --git a/src/server/game/AI/CoreAI/UnitAI.h b/src/server/game/AI/CoreAI/UnitAI.h
index 0a7e10a34f..679497173f 100644
--- a/src/server/game/AI/CoreAI/UnitAI.h
+++ b/src/server/game/AI/CoreAI/UnitAI.h
@@ -257,6 +257,8 @@ class TC_GAME_API UnitAI
virtual std::string GetDebugInfo() const;
+ Unit* GetUnit() const { return me; }
+
private:
UnitAI(UnitAI const& right) = delete;
UnitAI& operator=(UnitAI const& right) = delete;
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 1e515b4858..8f6882b105 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -9508,6 +9508,8 @@ void Unit::AIUpdateTick(uint32 diff)
void Unit::PushAI(UnitAI* newAI)
{
+ ASSERT_NODEBUGINFO(!newAI || newAI->GetUnit() == this, "Attempting to use AI that does not belong to this unit. Me %s\nAI owner %s",
+ GetDebugInfo().c_str(), newAI->GetDebugInfo().c_str());
i_AIs.emplace(newAI);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment