Skip to content

Commit

Permalink
Fix for loading gameobject / creature in bg when bg has unloaded (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidonete authored and celguar committed Mar 25, 2024
1 parent 506b967 commit d8319af
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/game/Entities/Creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,17 @@ bool Creature::Create(uint32 dbGuid, uint32 guidlow, CreatureCreatePos& cPos, Cr

// Notify the pvp script
if (GetMap()->IsBattleGround())
static_cast<BattleGroundMap*>(GetMap())->GetBG()->HandleCreatureCreate(this);
{
BattleGround* bg = static_cast<BattleGroundMap*>(GetMap())->GetBG();
if (bg)
{
bg->HandleCreatureCreate(this);
}
else
{
return false;
}
}
else if (OutdoorPvP* outdoorPvP = sOutdoorPvPMgr.GetScript(GetZoneId()))
outdoorPvP->HandleCreatureCreate(this);

Expand Down
12 changes: 11 additions & 1 deletion src/game/Entities/GameObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,17 @@ bool GameObject::Create(uint32 dbGuid, uint32 guidlow, uint32 name_id, Map* map,

// Notify the battleground or outdoor pvp script
if (map->IsBattleGround())
((BattleGroundMap*)map)->GetBG()->HandleGameObjectCreate(this);
{
BattleGround* bg = static_cast<BattleGroundMap*>(GetMap())->GetBG();
if (bg)
{
bg->HandleGameObjectCreate(this);
}
else
{
return false;
}
}
else if (OutdoorPvP* outdoorPvP = sOutdoorPvPMgr.GetScript(GetZoneId()))
outdoorPvP->HandleGameObjectCreate(this);

Expand Down

0 comments on commit d8319af

Please sign in to comment.