mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 19:37:02 +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
|
|
@ -24,7 +24,7 @@ CREATE TABLE `db_version` (
|
|||
`version` varchar(120) default NULL,
|
||||
`creature_ai_version` varchar(120) default NULL,
|
||||
`cache_id` int(10) default '0',
|
||||
`required_8548_02_mangos_gameobject_battleground` bit(1) default NULL
|
||||
`required_8549_03_mangos_battleground_events` bit(1) default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes';
|
||||
|
||||
--
|
||||
|
|
|
|||
92
sql/updates/8549_03_mangos_battleground_events.sql
Normal file
92
sql/updates/8549_03_mangos_battleground_events.sql
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
ALTER TABLE db_version CHANGE COLUMN required_8548_02_mangos_gameobject_battleground required_8549_03_mangos_battleground_events bit;
|
||||
|
||||
DROP TABLE IF EXISTS `battleground_events`;
|
||||
CREATE TABLE `battleground_events` (
|
||||
`map` smallint(5) NOT NULL,
|
||||
`event1` tinyint(3) unsigned NOT NULL,
|
||||
`event2` tinyint(3) unsigned NOT NULL,
|
||||
`description` varchar(255) NOT NULL,
|
||||
PRIMARY KEY (`map`,`event1`,`event2`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
|
||||
SET @WS_MAP = 489;
|
||||
SET @AB_MAP = 529;
|
||||
SET @EY_MAP = 566;
|
||||
SET @NA_MAP = 559;
|
||||
SET @BE_MAP = 562;
|
||||
SET @RL_MAP = 572;
|
||||
|
||||
INSERT INTO battleground_events (map, event1, event2, description) VALUES
|
||||
(@WS_MAP, 0, 0, 'Alliance Flag'),
|
||||
(@WS_MAP, 1, 0, 'Horde Flag'),
|
||||
(@WS_MAP, 2, 0, 'Spirit Guides'),
|
||||
(@WS_MAP, 254, 0, 'Doors'),
|
||||
|
||||
-- arathi
|
||||
(@AB_MAP, 0, 0, 'Stables - neutral'),
|
||||
(@AB_MAP, 0, 1, 'Stables - alliance contested'),
|
||||
(@AB_MAP, 0, 2, 'Stables - horde contested'),
|
||||
(@AB_MAP, 0, 3, 'Stables - alliance owned'),
|
||||
(@AB_MAP, 0, 4, 'Stables - horde owned'),
|
||||
|
||||
(@AB_MAP, 1, 0, 'Blacksmith - neutral'),
|
||||
(@AB_MAP, 1, 1, 'Blacksmith - alliance contested'),
|
||||
(@AB_MAP, 1, 2, 'Blacksmith - horde contested'),
|
||||
(@AB_MAP, 1, 3, 'Blacksmith - alliance owned'),
|
||||
(@AB_MAP, 1, 4, 'Blacksmith - horde owned'),
|
||||
|
||||
(@AB_MAP, 2, 0, 'Farm - neutral'),
|
||||
(@AB_MAP, 2, 1, 'Farm - alliance contested'),
|
||||
(@AB_MAP, 2, 2, 'Farm - horde contested'),
|
||||
(@AB_MAP, 2, 3, 'Farm - alliance owned'),
|
||||
(@AB_MAP, 2, 4, 'Farm - horde owned'),
|
||||
|
||||
(@AB_MAP, 3, 0, 'Lumber Mill - neutral'),
|
||||
(@AB_MAP, 3, 1, 'Lumber Mill - alliance contested'),
|
||||
(@AB_MAP, 3, 2, 'Lumber Mill - horde contested'),
|
||||
(@AB_MAP, 3, 3, 'Lumber Mill - alliance owned'),
|
||||
(@AB_MAP, 3, 4, 'Lumber Mill - horde owned'),
|
||||
|
||||
(@AB_MAP, 4, 0, 'Gold Mine - neutral'),
|
||||
(@AB_MAP, 4, 1, 'Gold Mine - alliance contested'),
|
||||
(@AB_MAP, 4, 2, 'Gold Mine - horde contested'),
|
||||
(@AB_MAP, 4, 3, 'Gold Mine - alliance owned'),
|
||||
(@AB_MAP, 4, 4, 'Gold Mine - horde owned'),
|
||||
|
||||
(@AB_MAP, 254, 0, 'doors'),
|
||||
-- eye of the storm
|
||||
(@EY_MAP, 0, 0, 'Fel Reaver - alliance'),
|
||||
(@EY_MAP, 0, 1, 'Fel Reaver - horde'),
|
||||
(@EY_MAP, 0, 2, 'Fel Reaver - neutral'),
|
||||
|
||||
(@EY_MAP, 1, 0, 'Blood Elf - alliance'),
|
||||
(@EY_MAP, 1, 1, 'Blood Elf - horde'),
|
||||
(@EY_MAP, 1, 2, 'Blood Elf - neutral'),
|
||||
|
||||
(@EY_MAP, 2, 0, 'Draenei Ruins - alliance'),
|
||||
(@EY_MAP, 2, 1, 'Draenei Ruins - horde'),
|
||||
(@EY_MAP, 2, 2, 'Draenei Ruins - neutral'),
|
||||
|
||||
(@EY_MAP, 3, 0, 'Mage Tower - alliance'),
|
||||
(@EY_MAP, 3, 1, 'Mage Tower - horde'),
|
||||
(@EY_MAP, 3, 2, 'Mage Tower - neutral'),
|
||||
|
||||
(@EY_MAP, 4, 0, 'capture flag - Fel Reaver'),
|
||||
(@EY_MAP, 4, 1, 'capture flag - Blood Elf'),
|
||||
(@EY_MAP, 4, 2, 'capture flag - Draenei Ruins'),
|
||||
(@EY_MAP, 4, 3, 'capture flag - Mage Tower'),
|
||||
(@EY_MAP, 4, 4, 'capture flag - center'),
|
||||
|
||||
(@EY_MAP, 254, 0, 'doors'),
|
||||
|
||||
-- arenas
|
||||
(@NA_MAP, 253, 0, 'buffs'),
|
||||
(@NA_MAP, 254, 0, 'doors'),
|
||||
|
||||
(@RL_MAP, 253, 0, 'buffs'),
|
||||
(@RL_MAP, 254, 0, 'doors'),
|
||||
|
||||
(@BE_MAP, 253, 0, 'buffs'),
|
||||
(@BE_MAP, 254, 0, 'doors')
|
||||
|
|
@ -115,6 +115,7 @@ pkgdata_DATA = \
|
|||
8521_01_mangos_spell_proc_event.sql \
|
||||
8548_01_mangos_creature_battleground.sql \
|
||||
8548_02_mangos_gameobject_battleground.sql \
|
||||
8549_03_mangos_battleground_events.sql \
|
||||
README
|
||||
|
||||
## Additional files to include when running 'make dist'
|
||||
|
|
@ -210,4 +211,5 @@ EXTRA_DIST = \
|
|||
8521_01_mangos_spell_proc_event.sql \
|
||||
8548_01_mangos_creature_battleground.sql \
|
||||
8548_02_mangos_gameobject_battleground.sql \
|
||||
8549_03_mangos_battleground_events.sql \
|
||||
README
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
uint32 dbTableGuidLow = fields[1].GetUInt32();
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "8548"
|
||||
#define REVISION_NR "8549"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue