mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 01:37:00 +00:00
[8548] implement db supported battleground eventindexes
those eventindexes will then be used by the battleground-code to decide which creature belongs to which objective for example all creatures in alteracvalley which are standing around a tower will belong to one eventindex then.. the eventindex will be defined through the code and must be proper documented for db-devs
This commit is contained in:
parent
3cf92b8507
commit
538c5c257e
11 changed files with 132 additions and 2 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_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';
|
||||
|
||||
--
|
||||
|
|
|
|||
10
sql/updates/8548_01_mangos_creature_battleground.sql
Normal file
10
sql/updates/8548_01_mangos_creature_battleground.sql
Normal file
|
|
@ -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';
|
||||
|
||||
10
sql/updates/8548_02_mangos_gameobject_battleground.sql
Normal file
10
sql/updates/8548_02_mangos_gameobject_battleground.sql
Normal file
|
|
@ -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';
|
||||
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ typedef std::map<uint32, BattleGround*> BattleGroundSet;
|
|||
typedef std::list<BattleGround*> BGFreeSlotQueueType;
|
||||
|
||||
typedef UNORDERED_MAP<uint32, BattleGroundTypeId> BattleMastersMap;
|
||||
typedef UNORDERED_MAP<uint32, BattleGroundEventIdx> CreatureBattleEventIndexesMap;
|
||||
typedef UNORDERED_MAP<uint32, BattleGroundEventIdx> 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];
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "8547"
|
||||
#define REVISION_NR "8548"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue