Skip to content

Commit

Permalink
GameEvent: Add game event checks for nonexistant guids
Browse files Browse the repository at this point in the history
  • Loading branch information
killerwife committed Sep 28, 2023
1 parent f6130f9 commit d5f3f32
Showing 1 changed file with 33 additions and 15 deletions.
48 changes: 33 additions & 15 deletions src/game/GameEvents/GameEventMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,9 @@ void GameEventMgr::LoadFromDB()
m_gameEventSpawnPoolIds.resize(m_gameEvents.size());

m_gameEventCreatureGuids.resize(m_gameEvents.size() * 2 - 1);
// 1 2
result.reset(WorldDatabase.Query("SELECT creature.guid, game_event_creature.event "
"FROM creature JOIN game_event_creature ON creature.guid = game_event_creature.guid"));
// 0 1 2
result.reset(WorldDatabase.Query("SELECT creature.guid, game_event_creature.guid, game_event_creature.event "
"FROM game_event_creature LEFT OUTER JOIN creature ON creature.guid = game_event_creature.guid"));

count = 0;
if (!result)
Expand All @@ -274,8 +274,14 @@ void GameEventMgr::LoadFromDB()

bar.step();

uint32 guid = fields[0].GetUInt32();
int16 event_id = fields[1].GetInt16();
uint32 guid = fields[1].GetUInt32();
if (fields[0].IsNULL())
{
sLog.outErrorDb("`game_event_creature` guid (%u) does not exist in `creature`", guid);
continue;
}

int16 event_id = fields[2].GetInt16();

if (event_id == 0)
{
Expand Down Expand Up @@ -328,9 +334,9 @@ void GameEventMgr::LoadFromDB()
}

m_gameEventGameobjectGuids.resize(m_gameEvents.size() * 2 - 1);
// 1 2
result.reset(WorldDatabase.Query("SELECT gameobject.guid, game_event_gameobject.event "
"FROM gameobject JOIN game_event_gameobject ON gameobject.guid=game_event_gameobject.guid"));
// 0 1 2
result.reset(WorldDatabase.Query("SELECT gameobject.guid, game_event_gameobject.guid, game_event_gameobject.event "
"FROM game_event_gameobject LEFT OUTER JOIN gameobject ON gameobject.guid=game_event_gameobject.guid"));

count = 0;
if (!result)
Expand All @@ -349,9 +355,15 @@ void GameEventMgr::LoadFromDB()
Field* fields = result->Fetch();

bar.step();

uint32 guid = fields[1].GetUInt32();
if (fields[0].IsNULL())
{
sLog.outErrorDb("`game_event_gameobject` guid (%u) does not exist in `gameobject`", guid);
continue;
}

uint32 guid = fields[0].GetUInt32();
int16 event_id = fields[1].GetInt16();
int16 event_id = fields[2].GetInt16();

if (event_id == 0)
{
Expand Down Expand Up @@ -413,13 +425,13 @@ void GameEventMgr::LoadFromDB()
}

m_gameEventCreatureData.resize(m_gameEvents.size());
// 0 1 2
// 0 1 2
result.reset(WorldDatabase.Query("SELECT creature.guid, game_event_creature_data.event, game_event_creature_data.modelid,"
// 3 4
"game_event_creature_data.equipment_id, game_event_creature_data.entry_id, "
// 5 6
"game_event_creature_data.spell_start, game_event_creature_data.spell_end "
"FROM creature JOIN game_event_creature_data ON creature.guid=game_event_creature_data.guid"));
// 5 6 7
"game_event_creature_data.spell_start, game_event_creature_data.spell_end, game_event_creature_data.guid "
"FROM game_event_creature_data LEFT OUTER JOIN creature ON creature.guid=game_event_creature_data.guid"));

count = 0;
if (!result)
Expand All @@ -438,7 +450,13 @@ void GameEventMgr::LoadFromDB()
Field* fields = result->Fetch();

bar.step();
uint32 guid = fields[0].GetUInt32();
uint32 guid = fields[7].GetUInt32();
if (fields[0].IsNULL())
{
sLog.outErrorDb("`game_event_creature_data` guid (%u) does not exist in `creature`", guid);
continue;
}

uint16 event_id = fields[1].GetUInt16();

if (event_id == 0)
Expand Down

0 comments on commit d5f3f32

Please sign in to comment.