diff --git a/sql/mangos.sql b/sql/mangos.sql index f6bf658d6..cda0ead45 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_8521_01_mangos_spell_proc_event` bit(1) default NULL + `required_8548_02_mangos_gameobject_battleground` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes'; -- diff --git a/sql/updates/8548_01_mangos_creature_battleground.sql b/sql/updates/8548_01_mangos_creature_battleground.sql new file mode 100644 index 000000000..8f9e880e6 --- /dev/null +++ b/sql/updates/8548_01_mangos_creature_battleground.sql @@ -0,0 +1,10 @@ +ALTER TABLE db_version CHANGE COLUMN required_8521_01_mangos_spell_proc_event required_8548_01_mangos_creature_battleground bit; + +DROP TABLE IF EXISTS `creature_battleground`; +CREATE TABLE `creature_battleground` ( + `guid` int(10) unsigned NOT NULL COMMENT 'Creature\'s GUID', + `event1` tinyint(3) unsigned NOT NULL COMMENT 'main event', + `event2` tinyint(3) unsigned NOT NULL COMMENT 'sub event', + PRIMARY KEY (`guid`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Creature battleground indexing system'; + diff --git a/sql/updates/8548_02_mangos_gameobject_battleground.sql b/sql/updates/8548_02_mangos_gameobject_battleground.sql new file mode 100644 index 000000000..a8dbd8e40 --- /dev/null +++ b/sql/updates/8548_02_mangos_gameobject_battleground.sql @@ -0,0 +1,10 @@ +ALTER TABLE db_version CHANGE COLUMN required_8548_01_mangos_creature_battleground required_8548_02_mangos_gameobject_battleground bit; + +DROP TABLE IF EXISTS `gameobject_battleground`; +CREATE TABLE `gameobject_battleground` ( + `guid` int(10) unsigned NOT NULL COMMENT 'GameObject\'s GUID', + `event1` tinyint(3) unsigned NOT NULL COMMENT 'main event', + `event2` tinyint(3) unsigned NOT NULL COMMENT 'sub event', + PRIMARY KEY (`guid`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='GameObject battleground indexing system'; + diff --git a/sql/updates/Makefile.am b/sql/updates/Makefile.am index cd09ce4a8..7873045e8 100644 --- a/sql/updates/Makefile.am +++ b/sql/updates/Makefile.am @@ -113,6 +113,8 @@ pkgdata_DATA = \ 8511_01_mangos_spell_proc_event.sql \ 8514_01_mangos_spell_bonus_data.sql \ 8521_01_mangos_spell_proc_event.sql \ + 8548_01_mangos_creature_battleground.sql \ + 8548_02_mangos_gameobject_battleground.sql \ README ## Additional files to include when running 'make dist' @@ -206,4 +208,6 @@ EXTRA_DIST = \ 8511_01_mangos_spell_proc_event.sql \ 8514_01_mangos_spell_bonus_data.sql \ 8521_01_mangos_spell_proc_event.sql \ + 8548_01_mangos_creature_battleground.sql \ + 8548_02_mangos_gameobject_battleground.sql \ README diff --git a/src/game/BattleGround.h b/src/game/BattleGround.h index 893e692b0..688c8fbc6 100644 --- a/src/game/BattleGround.h +++ b/src/game/BattleGround.h @@ -22,6 +22,7 @@ #include "Common.h" #include "SharedDefines.h" +#define BG_EVENT_NONE 255 class Creature; class GameObject; class Group; @@ -30,6 +31,12 @@ class WorldPacket; struct WorldSafeLocsEntry; +struct BattleGroundEventIdx +{ + uint8 event1; + uint8 event2; +}; + enum BattleGroundSounds { SOUND_HORDE_WINS = 8454, diff --git a/src/game/BattleGroundMgr.cpp b/src/game/BattleGroundMgr.cpp index 599108606..8bfb50982 100644 --- a/src/game/BattleGroundMgr.cpp +++ b/src/game/BattleGroundMgr.cpp @@ -2098,3 +2098,67 @@ bool BattleGroundMgr::IsBGWeekend(BattleGroundTypeId bgTypeId) return false; } } + +void BattleGroundMgr::LoadCreatureBattleEventIndexes() +{ + mCreatureBattleEventIndexMap.clear(); // need for reload case + QueryResult *result = WorldDatabase.Query( "SELECT guid, event1, event2 FROM creature_battleground" ); + uint32 count = 0; + if( !result ) + { + barGoLink bar( 1 ); + bar.step(); + + sLog.outString(); + sLog.outString( ">> Loaded 0 battleground eventindexes for creatures - table is empty!" ); + return; + } + barGoLink bar( result->GetRowCount() ); + do + { + ++count; + bar.step(); + Field *fields = result->Fetch(); + uint32 dbTableGuidLow = fields[0].GetUInt32(); + BattleGroundEventIdx events; + events.event1 = fields[1].GetUInt8(); + events.event2 = fields[2].GetUInt8(); + mCreatureBattleEventIndexMap[dbTableGuidLow] = events; + + } while( result->NextRow() ); + delete result; + sLog.outString(); + sLog.outString( ">> Loaded %u battleground eventindexes for creatures", count ); +} + +void BattleGroundMgr::LoadGameObjectBattleEventIndexes() +{ + mGameObjectBattleEventIndexMap.clear(); // need for reload case + QueryResult *result = WorldDatabase.Query( "SELECT guid, event1, event2 FROM gameobject_battleground" ); + uint32 count = 0; + if( !result ) + { + barGoLink bar( 1 ); + bar.step(); + + sLog.outString(); + sLog.outString( ">> Loaded 0 battleground eventindexes for gameobjects - table is empty!" ); + return; + } + barGoLink bar( result->GetRowCount() ); + do + { + ++count; + bar.step(); + Field *fields = result->Fetch(); + uint32 dbTableGuidLow = fields[0].GetUInt32(); + BattleGroundEventIdx events; + events.event1 = fields[1].GetUInt8(); + events.event2 = fields[2].GetUInt8(); + mGameObjectBattleEventIndexMap[dbTableGuidLow] = events; + + } while( result->NextRow() ); + delete result; + sLog.outString(); + sLog.outString( ">> Loaded %u battleground eventindexes for gameobjects", count ); +} diff --git a/src/game/BattleGroundMgr.h b/src/game/BattleGroundMgr.h index cad25abae..270724817 100644 --- a/src/game/BattleGroundMgr.h +++ b/src/game/BattleGroundMgr.h @@ -29,6 +29,8 @@ typedef std::map BattleGroundSet; typedef std::list BGFreeSlotQueueType; typedef UNORDERED_MAP BattleMastersMap; +typedef UNORDERED_MAP CreatureBattleEventIndexesMap; +typedef UNORDERED_MAP GameObjectBattleEventIndexesMap; #define BATTLEGROUND_ARENA_POINT_DISTRIBUTION_DAY 86400 // seconds in a day #define COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME 10 @@ -236,6 +238,29 @@ class BattleGroundMgr return BATTLEGROUND_WS; } + void LoadCreatureBattleEventIndexes(); + BattleGroundEventIdx GetCreatureEventIndex(uint32 dbTableGuidLow) const + { + CreatureBattleEventIndexesMap::const_iterator itr = mCreatureBattleEventIndexMap.find(dbTableGuidLow); + if(itr != mCreatureBattleEventIndexMap.end()) + return itr->second; + BattleGroundEventIdx none; + none.event1 = BG_EVENT_NONE; + none.event2 = BG_EVENT_NONE; + return none; // needed to check for error + } + void LoadGameObjectBattleEventIndexes(); + BattleGroundEventIdx GetGameObjectEventIndex(uint32 dbTableGuidLow) const + { + GameObjectBattleEventIndexesMap::const_iterator itr = mGameObjectBattleEventIndexMap.find(dbTableGuidLow); + if(itr != mGameObjectBattleEventIndexMap.end()) + return itr->second; + BattleGroundEventIdx none; + none.event1 = BG_EVENT_NONE; + none.event2 = BG_EVENT_NONE; + return none; // needed to check for error + } + bool isArenaTesting() const { return m_ArenaTesting; } bool isTesting() const { return m_Testing; } @@ -248,6 +273,8 @@ class BattleGroundMgr static bool IsBGWeekend(BattleGroundTypeId bgTypeId); private: BattleMastersMap mBattleMastersMap; + CreatureBattleEventIndexesMap mCreatureBattleEventIndexMap; + GameObjectBattleEventIndexesMap mGameObjectBattleEventIndexMap; /* Battlegrounds */ BattleGroundSet m_BattleGrounds[MAX_BATTLEGROUND_TYPE_ID]; diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index d6c25141d..ad2308ab8 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -1454,6 +1454,7 @@ void Creature::DeleteFromDB() WorldDatabase.PExecuteLog("DELETE FROM creature_movement WHERE id = '%u'", m_DBTableGuid); WorldDatabase.PExecuteLog("DELETE FROM game_event_creature WHERE guid = '%u'", m_DBTableGuid); WorldDatabase.PExecuteLog("DELETE FROM game_event_model_equip WHERE guid = '%u'", m_DBTableGuid); + WorldDatabase.PExecuteLog("DELETE FROM creature_battleground WHERE guid = '%u'", m_DBTableGuid); WorldDatabase.CommitTransaction(); } diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp index d88193726..995940ebf 100644 --- a/src/game/GameObject.cpp +++ b/src/game/GameObject.cpp @@ -641,6 +641,7 @@ void GameObject::DeleteFromDB() objmgr.DeleteGOData(m_DBTableGuid); WorldDatabase.PExecuteLog("DELETE FROM gameobject WHERE guid = '%u'", m_DBTableGuid); WorldDatabase.PExecuteLog("DELETE FROM game_event_gameobject WHERE guid = '%u'", m_DBTableGuid); + WorldDatabase.PExecuteLog("DELETE FROM gameobject_battleground WHERE guid = '%u'", m_DBTableGuid); } GameObjectInfo const *GameObject::GetGOInfo() const diff --git a/src/game/World.cpp b/src/game/World.cpp index ed09a68c4..e3f4f88b9 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -1371,6 +1371,12 @@ void World::SetInitialWorldSettings() sLog.outString( "Loading BattleMasters..." ); sBattleGroundMgr.LoadBattleMastersEntry(); + sLog.outString( "Loading Creature BattleGround event indexes..." ); + sBattleGroundMgr.LoadCreatureBattleEventIndexes(); + + sLog.outString( "Loading GameObject BattleGround event indexes..." ); + sBattleGroundMgr.LoadGameObjectBattleEventIndexes(); + sLog.outString( "Loading GameTeleports..." ); objmgr.LoadGameTele(); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 1bd7e517b..3342e2c61 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 "8547" + #define REVISION_NR "8548" #endif // __REVISION_NR_H__