mirror of
https://github.com/mangosfour/server.git
synced 2025-12-16 04:37:00 +00:00
[8549] Eventloading check
Through the eventsystem can be quite complex and errormessages should be quite meaningful for finding mistakes in sql I decided to create another table in database This table will just contain the map,event1,event2 and a human readable description of every event the primary key is over map,event1,event2 this table will be outer joined with bg_creatures,bg_gameobject so every inner-join part will just match those events and create no error but every outer join part will mean there was something wrong (either a spawn which has no existant event, or an event where no spawn is inside) also this table is very useful for db-developers, to see which events exist without looking into code and understanding the logic behind the code also please note: those error-checks don't (and can't) report every mistake.. for example if you have an arathibasin node - and add just one creature in this event - this system won't look, if you've spawned all needed gameobjects and so on.. an idea would be to add to this table how much gameobjects and creatures have to be there at minimum - but i doubt that this will be much helpful also i won't stop battlegrounds from loading if not all events do exist (just cause i see no need in it)
This commit is contained in:
parent
0ce6395857
commit
db7c9f4fc1
5 changed files with 166 additions and 10 deletions
|
|
@ -2101,7 +2101,6 @@ bool BattleGroundMgr::IsBGWeekend(BattleGroundTypeId bgTypeId)
|
|||
|
||||
void BattleGroundMgr::LoadBattleEventIndexes()
|
||||
{
|
||||
|
||||
BattleGroundEventIdx events;
|
||||
events.event1 = BG_EVENT_NONE;
|
||||
events.event2 = BG_EVENT_NONE;
|
||||
|
|
@ -2110,10 +2109,40 @@ void BattleGroundMgr::LoadBattleEventIndexes()
|
|||
m_CreatureBattleEventIndexMap.clear(); // need for reload case
|
||||
m_CreatureBattleEventIndexMap[-1] = events;
|
||||
|
||||
QueryResult *result = WorldDatabase.PQuery( "SELECT 1, guid, event1, event2 FROM gameobject_battleground "
|
||||
"UNION "
|
||||
"SELECT 2, guid, event1, event2 FROM creature_battleground");
|
||||
uint32 count = 0;
|
||||
|
||||
QueryResult *result =
|
||||
// 0 1 2 3 4 5 6
|
||||
WorldDatabase.PQuery( "SELECT data.typ, data.guid1, data.ev1 ev1, data.ev2 ev2, data.map m, data.guid2, description.map, "
|
||||
// 7 8 9
|
||||
"description.event1, description.event2, description.description "
|
||||
"FROM "
|
||||
"(SELECT 1 typ, a.guid guid1, a.event1 ev1, a.event2 ev2, b.map map, b.guid guid2 "
|
||||
"FROM gameobject_battleground a "
|
||||
"LEFT OUTER JOIN gameobject b ON a.guid = b.guid "
|
||||
"UNION "
|
||||
"SELECT 2 typ, a.guid guid1, a.event1 ev1, a.event2 ev2, b.map map, b.guid guid2 "
|
||||
"FROM creature_battleground a "
|
||||
"LEFT OUTER JOIN creature b ON a.guid = b.guid "
|
||||
") data "
|
||||
"RIGHT OUTER JOIN battleground_events description ON data.map = description.map "
|
||||
"AND data.ev1 = description.event1 AND data.ev2 = description.event2 "
|
||||
// full outer join doesn't work in mysql :-/ so just UNION-select the same again and add a left outer join
|
||||
"UNION "
|
||||
"SELECT data.typ, data.guid1, data.ev1, data.ev2, data.map, data.guid2, description.map, "
|
||||
"description.event1, description.event2, description.description "
|
||||
"FROM "
|
||||
"(SELECT 1 typ, a.guid guid1, a.event1 ev1, a.event2 ev2, b.map map, b.guid guid2 "
|
||||
"FROM gameobject_battleground a "
|
||||
"LEFT OUTER JOIN gameobject b ON a.guid = b.guid "
|
||||
"UNION "
|
||||
"SELECT 2 typ, a.guid guid1, a.event1 ev1, a.event2 ev2, b.map map, b.guid guid2 "
|
||||
"FROM creature_battleground a "
|
||||
"LEFT OUTER JOIN creature b ON a.guid = b.guid "
|
||||
") data "
|
||||
"LEFT OUTER JOIN battleground_events description ON data.map = description.map "
|
||||
"AND data.ev1 = description.event1 AND data.ev2 = description.event2 "
|
||||
"ORDER BY m, ev1, ev2" );
|
||||
if( !result )
|
||||
{
|
||||
barGoLink bar( 1 );
|
||||
|
|
@ -2125,12 +2154,44 @@ void BattleGroundMgr::LoadBattleEventIndexes()
|
|||
bar.step();
|
||||
Field *fields = result->Fetch();
|
||||
if (fields[2].GetUInt8() == BG_EVENT_NONE || fields[3].GetUInt8() == BG_EVENT_NONE)
|
||||
continue; // we don't need to add those to the map
|
||||
continue; // we don't need to add those to the eventmap
|
||||
|
||||
bool gameobject = (fields[0].GetUInt8() == 1);
|
||||
bool gameobject = (fields[0].GetUInt8() == 1);
|
||||
uint32 dbTableGuidLow = fields[1].GetUInt32();
|
||||
events.event1 = fields[2].GetUInt8();
|
||||
events.event2 = fields[3].GetUInt8();
|
||||
events.event1 = fields[2].GetUInt8();
|
||||
events.event2 = fields[3].GetUInt8();
|
||||
uint32 map = fields[4].GetUInt32();
|
||||
|
||||
uint32 desc_map = fields[6].GetUInt32();
|
||||
uint8 desc_event1 = fields[7].GetUInt8();
|
||||
uint8 desc_event2 = fields[8].GetUInt8();
|
||||
const char *description = fields[9].GetString();
|
||||
|
||||
// checking for NULL - through right outer join this will mean following:
|
||||
if (fields[5].GetUInt32() != dbTableGuidLow)
|
||||
{
|
||||
sLog.outErrorDb("BattleGroundEvent: %s with nonexistant guid %u for event: map:%u, event1:%u, event2:%u (\"%s\")",
|
||||
(gameobject) ? "gameobject" : "creature", dbTableGuidLow, map, events.event1, events.event2, description);
|
||||
continue;
|
||||
}
|
||||
|
||||
// checking for NULL - through full outer join this can mean 2 things:
|
||||
if (desc_map != map)
|
||||
{
|
||||
// there is an event missing
|
||||
if (dbTableGuidLow == 0)
|
||||
{
|
||||
sLog.outErrorDb("BattleGroundEvent: missing db-data for map:%u, event1:%u, event2:%u (\"%s\")", desc_map, desc_event1, desc_event2, description);
|
||||
continue;
|
||||
}
|
||||
// we have an event which shouldn't exist
|
||||
else
|
||||
{
|
||||
sLog.outErrorDb("BattleGroundEvent: %s with guid %u is registered, for a nonexistant event: map:%u, event1:%u, event2:%u",
|
||||
(gameobject) ? "gameobject" : "creature", dbTableGuidLow, map, events.event1, events.event2);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (gameobject)
|
||||
m_GameObjectBattleEventIndexMap[dbTableGuidLow] = events;
|
||||
|
|
@ -2138,6 +2199,7 @@ void BattleGroundMgr::LoadBattleEventIndexes()
|
|||
m_CreatureBattleEventIndexMap[dbTableGuidLow] = events;
|
||||
|
||||
++count;
|
||||
|
||||
} while( result->NextRow() );
|
||||
sLog.outString();
|
||||
sLog.outString( ">> Loaded %u battleground eventindexes", count);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue