diff --git a/sql/mangos.sql b/sql/mangos.sql index cda0ead45..9071133cc 100644 --- a/sql/mangos.sql +++ b/sql/mangos.sql @@ -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'; -- diff --git a/sql/updates/8549_03_mangos_battleground_events.sql b/sql/updates/8549_03_mangos_battleground_events.sql new file mode 100644 index 000000000..63bedd54d --- /dev/null +++ b/sql/updates/8549_03_mangos_battleground_events.sql @@ -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') diff --git a/sql/updates/Makefile.am b/sql/updates/Makefile.am index 7873045e8..5387117fa 100644 --- a/sql/updates/Makefile.am +++ b/sql/updates/Makefile.am @@ -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 diff --git a/src/game/BattleGroundMgr.cpp b/src/game/BattleGroundMgr.cpp index 4e2e9071a..fd9d677e6 100644 --- a/src/game/BattleGroundMgr.cpp +++ b/src/game/BattleGroundMgr.cpp @@ -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); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 3342e2c61..b1b98db0b 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8548" + #define REVISION_NR "8549" #endif // __REVISION_NR_H__