Skip to content

Commit

Permalink
Fix crashes on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
Niam5 committed Feb 6, 2024
1 parent ab41917 commit f37c02f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 21 deletions.
7 changes: 6 additions & 1 deletion src/game/BattleGround/BattleGround.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,11 @@ void BattleGround::Update(uint32 diff)
m_events |= BG_STARTING_EVENT_4;

StartingEventOpenDoors();

#ifdef BUILD_ELUNA
if (Eluna* e = GetBgMap()->GetEluna())
e->OnBGStart(this, GetTypeId(), GetInstanceId());
#endif

if (m_startMessageIds[BG_STARTING_EVENT_FOURTH])
SendMessageToAll(m_startMessageIds[BG_STARTING_EVENT_FOURTH], CHAT_MSG_BG_SYSTEM_NEUTRAL);
Expand Down Expand Up @@ -1482,7 +1487,7 @@ void BattleGround::StartBattleGround()

#ifdef BUILD_ELUNA
if (Eluna* e = GetBgMap()->GetEluna())
e->OnBGStart(this, GetTypeId(), GetInstanceId());
e->OnBGCreate(this, GetTypeId(), GetInstanceId());
#endif
}

Expand Down
5 changes: 0 additions & 5 deletions src/game/BattleGround/BattleGroundMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1887,11 +1887,6 @@ uint32 BattleGroundMgr::CreateBattleGround(BattleGroundTypeId bgTypeId, bool IsA
// add bg to update list
AddBattleGround(bg->GetInstanceId(), bg->GetTypeId(), bg);

#ifdef BUILD_ELUNA
if (Eluna* e = bg->GetBgMap()->GetEluna())
e->OnBGCreate(bg, bgTypeId, bg->GetInstanceId());
#endif

// return some not-null value, bgTypeId is good enough for me
return bgTypeId;
}
Expand Down
37 changes: 22 additions & 15 deletions src/game/World/World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -927,8 +927,11 @@ void World::LoadConfigSettings(bool reload)

setConfig(CONFIG_UINT32_SUNSREACH_COUNTER, "Sunsreach.CounterMax", 10000);
#ifdef BUILD_ELUNA
if (Eluna* e = GetEluna())
e->OnConfigLoad(reload);
if (reload)
{
if (Eluna* e = GetEluna())
e->OnConfigLoad(reload);
}
#endif

#ifdef BUILD_SOLOCRAFT
Expand Down Expand Up @@ -1660,6 +1663,20 @@ void World::SetInitialWorldSettings()
sLog.outString("Loading GM tickets...");
sTicketMgr.LoadGMTickets();

#ifdef BUILD_ELUNA
// lua state begins uninitialized
eluna = nullptr;

if (sElunaConfig->IsElunaEnabled())
{
///- Run eluna scripts.
sLog.outString("Starting Eluna world state...");
// use map id -1 for the global Eluna state
eluna = new Eluna(nullptr, sElunaConfig->IsElunaCompatibilityMode());
sLog.outString();
}
#endif

///- Load and initialize EventAI Scripts
sLog.outString("Loading CreatureEventAI Summons...");
sEventAIMgr.LoadCreatureEventAI_Summons(false); // false, will checked in LoadCreatureEventAI_Scripts
Expand Down Expand Up @@ -1795,19 +1812,9 @@ void World::SetInitialWorldSettings()
PlayerbotMgr::SetInitialWorldSettings();
#endif
#ifdef BUILD_ELUNA
// lua state begins uninitialized
eluna = nullptr;

if (sElunaConfig->IsElunaEnabled())
{
///- Run eluna scripts.
sLog.outString("Starting Eluna world state...");
// use map id -1 for the global Eluna state
eluna = new Eluna(nullptr, sElunaConfig->IsElunaCompatibilityMode());

eluna->OnConfigLoad(false); // Must be done after Eluna is initialized and scripts have run
sLog.outString();
}
if (GetEluna())
GetEluna()->OnConfigLoad(false); // Must be done after Eluna is initialized and scripts have run
sLog.outString();
#endif
sLog.outString("---------------------------------------");
sLog.outString(" CMANGOS: World initialized ");
Expand Down

0 comments on commit f37c02f

Please sign in to comment.