Core/Vehicles: Rename vehicle_accessory to vehicle_template_accessory, and implement a new table named vehicle_accessory to allow accessory definitions based on GUID that will overwrite defeinitions based on entry.
Fixes #Nay
This commit is contained in:
@@ -0,0 +1,12 @@
|
|||||||
|
RENAME TABLE `vehicle_accessory` TO `vehicle_template_accessory`;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `vehicle_accessory` (
|
||||||
|
`guid` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT 0,
|
||||||
|
`accessory_entry` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT 0,
|
||||||
|
`seat_id` TINYINT(1) NOT NULL DEFAULT 0,
|
||||||
|
`minion` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
|
||||||
|
`description` TEXT NOT NULL,
|
||||||
|
`summontype` TINYINT(3) UNSIGNED NOT NULL DEFAULT 6 COMMENT 'see enum TempSummonType',
|
||||||
|
`summontimer` INT(10) UNSIGNED NOT NULL DEFAULT 30000 COMMENT 'timer, only relevant for certain summontypes',
|
||||||
|
PRIMARY KEY (`guid`,`seat_id`)
|
||||||
|
) ENGINE=MYISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED
|
||||||
@@ -124,7 +124,7 @@ void Vehicle::InstallAllAccessories()
|
|||||||
{
|
{
|
||||||
RemoveAllPassengers(); // We might have aura's saved in the DB with now invalid casters - remove
|
RemoveAllPassengers(); // We might have aura's saved in the DB with now invalid casters - remove
|
||||||
|
|
||||||
VehicleAccessoryList const* mVehicleList = sObjectMgr->GetVehicleAccessoryList(m_creatureEntry);
|
VehicleAccessoryList const* mVehicleList = sObjectMgr->GetVehicleAccessoryList(this);
|
||||||
if (!mVehicleList)
|
if (!mVehicleList)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -124,6 +124,7 @@ class Vehicle
|
|||||||
|
|
||||||
Unit *GetBase() const { return me; }
|
Unit *GetBase() const { return me; }
|
||||||
VehicleEntry const *GetVehicleInfo() const { return m_vehicleInfo; }
|
VehicleEntry const *GetVehicleInfo() const { return m_vehicleInfo; }
|
||||||
|
uint32 const& GetCreatureEntry() const { return m_creatureEntry; }
|
||||||
|
|
||||||
bool HasEmptySeat(int8 seatId) const;
|
bool HasEmptySeat(int8 seatId) const;
|
||||||
Unit *GetPassenger(int8 seatId) const;
|
Unit *GetPassenger(int8 seatId) const;
|
||||||
|
|||||||
@@ -2741,6 +2741,62 @@ void ObjectMgr::LoadItemSetNames()
|
|||||||
sLog->outString();
|
sLog->outString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ObjectMgr::LoadVehicleTemplateAccessories()
|
||||||
|
{
|
||||||
|
uint32 oldMSTime = getMSTime();
|
||||||
|
|
||||||
|
m_VehicleTemplateAccessoryMap.clear(); // needed for reload case
|
||||||
|
|
||||||
|
uint32 count = 0;
|
||||||
|
|
||||||
|
QueryResult result = WorldDatabase.Query("SELECT `entry`,`accessory_entry`,`seat_id`,`minion`,`summontype`,`summontimer` FROM `vehicle_template_accessory`");
|
||||||
|
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
sLog->outErrorDb(">> Loaded 0 vehicle template accessories. DB table `vehicle_template_accessory` is empty.");
|
||||||
|
sLog->outString();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
Field *fields = result->Fetch();
|
||||||
|
|
||||||
|
uint32 uiEntry = fields[0].GetUInt32();
|
||||||
|
uint32 uiAccessory = fields[1].GetUInt32();
|
||||||
|
int8 uiSeat = int8(fields[2].GetInt16());
|
||||||
|
bool bMinion = fields[3].GetBool();
|
||||||
|
uint8 uiSummonType = fields[4].GetUInt8();
|
||||||
|
uint32 uiSummonTimer= fields[5].GetUInt32();
|
||||||
|
|
||||||
|
if (!sCreatureStorage.LookupEntry<CreatureInfo>(uiEntry))
|
||||||
|
{
|
||||||
|
sLog->outErrorDb("Table `vehicle_template_accessory`: creature template entry %u does not exist.", uiEntry);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sCreatureStorage.LookupEntry<CreatureInfo>(uiAccessory))
|
||||||
|
{
|
||||||
|
sLog->outErrorDb("Table `vehicle_template_accessory`: Accessory %u does not exist.", uiAccessory);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mSpellClickInfoMap.find(uiEntry) == mSpellClickInfoMap.end())
|
||||||
|
{
|
||||||
|
sLog->outErrorDb("Table `vehicle_template_accessory`: creature template entry %u has no data in npc_spellclick_spells", uiEntry);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_VehicleTemplateAccessoryMap[uiEntry].push_back(VehicleAccessory(uiAccessory, uiSeat, bMinion, uiSummonType, uiSummonTimer));
|
||||||
|
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
while (result->NextRow());
|
||||||
|
|
||||||
|
sLog->outString(">> Loaded %u Vehicle Accessories in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||||
|
sLog->outString();
|
||||||
|
}
|
||||||
|
|
||||||
void ObjectMgr::LoadVehicleAccessories()
|
void ObjectMgr::LoadVehicleAccessories()
|
||||||
{
|
{
|
||||||
uint32 oldMSTime = getMSTime();
|
uint32 oldMSTime = getMSTime();
|
||||||
@@ -2749,11 +2805,11 @@ void ObjectMgr::LoadVehicleAccessories()
|
|||||||
|
|
||||||
uint32 count = 0;
|
uint32 count = 0;
|
||||||
|
|
||||||
QueryResult result = WorldDatabase.Query("SELECT `entry`,`accessory_entry`,`seat_id`,`minion`,`summontype`,`summontimer` FROM `vehicle_accessory`");
|
QueryResult result = WorldDatabase.Query("SELECT `guid`,`accessory_entry`,`seat_id`,`minion`,`summontype`,`summontimer` FROM `vehicle_accessory`");
|
||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
sLog->outErrorDb(">> Loaded 0 LoadVehicleAccessor. DB table `vehicle_accessory` is empty.");
|
sLog->outErrorDb(">> Loaded 0 vehicle accessories. DB table `vehicle_accessory` is empty.");
|
||||||
sLog->outString();
|
sLog->outString();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -807,11 +807,20 @@ class ObjectMgr
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
VehicleAccessoryList const* GetVehicleAccessoryList(uint32 uiEntry) const
|
VehicleAccessoryList const* GetVehicleAccessoryList(Vehicle* veh) const
|
||||||
{
|
{
|
||||||
VehicleAccessoryMap::const_iterator itr = m_VehicleAccessoryMap.find(uiEntry);
|
if (veh->GetBase()->ToCreature())
|
||||||
|
{
|
||||||
|
// Give preference to GUID-based accessories
|
||||||
|
VehicleAccessoryMap::const_iterator itr = m_VehicleAccessoryMap.find(veh->GetBase()->GetGUIDLow());
|
||||||
if (itr != m_VehicleAccessoryMap.end())
|
if (itr != m_VehicleAccessoryMap.end())
|
||||||
return &itr->second;
|
return &itr->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise return entry-based
|
||||||
|
VehicleAccessoryMap::const_iterator itr = m_VehicleTemplateAccessoryMap.find(veh->GetCreatureEntry());
|
||||||
|
if (itr != m_VehicleTemplateAccessoryMap.end())
|
||||||
|
return &itr->second;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -921,6 +930,7 @@ class ObjectMgr
|
|||||||
void LoadInstanceTemplate();
|
void LoadInstanceTemplate();
|
||||||
void LoadInstanceEncounters();
|
void LoadInstanceEncounters();
|
||||||
void LoadMailLevelRewards();
|
void LoadMailLevelRewards();
|
||||||
|
void LoadVehicleTemplateAccessories();
|
||||||
void LoadVehicleAccessories();
|
void LoadVehicleAccessories();
|
||||||
void LoadVehicleScaling();
|
void LoadVehicleScaling();
|
||||||
|
|
||||||
@@ -1325,6 +1335,7 @@ class ObjectMgr
|
|||||||
|
|
||||||
ItemRequiredTargetMap m_ItemRequiredTarget;
|
ItemRequiredTargetMap m_ItemRequiredTarget;
|
||||||
|
|
||||||
|
VehicleAccessoryMap m_VehicleTemplateAccessoryMap;
|
||||||
VehicleAccessoryMap m_VehicleAccessoryMap;
|
VehicleAccessoryMap m_VehicleAccessoryMap;
|
||||||
VehicleScalingMap m_VehicleScalingMap;
|
VehicleScalingMap m_VehicleScalingMap;
|
||||||
|
|
||||||
|
|||||||
@@ -1399,9 +1399,12 @@ void World::SetInitialWorldSettings()
|
|||||||
sLog->outString("Loading Game Event Data..."); // must be after loading pools fully
|
sLog->outString("Loading Game Event Data..."); // must be after loading pools fully
|
||||||
sGameEventMgr->LoadFromDB(); // TODOLEAK: add scopes
|
sGameEventMgr->LoadFromDB(); // TODOLEAK: add scopes
|
||||||
|
|
||||||
sLog->outString("Loading UNIT_NPC_FLAG_SPELLCLICK Data...");
|
sLog->outString("Loading UNIT_NPC_FLAG_SPELLCLICK Data..."); // must be after LoadQuests
|
||||||
sObjectMgr->LoadNPCSpellClickSpells();
|
sObjectMgr->LoadNPCSpellClickSpells();
|
||||||
|
|
||||||
|
sLog->outString("Loading Vehicle Template Accessories...");
|
||||||
|
sObjectMgr->LoadVehicleTemplateAccessories(); // must be after LoadCreatureTemplates() and LoadNPCSpellClickSpells()
|
||||||
|
|
||||||
sLog->outString("Loading Vehicle Accessories...");
|
sLog->outString("Loading Vehicle Accessories...");
|
||||||
sObjectMgr->LoadVehicleAccessories(); // must be after LoadCreatureTemplates() and LoadNPCSpellClickSpells()
|
sObjectMgr->LoadVehicleAccessories(); // must be after LoadCreatureTemplates() and LoadNPCSpellClickSpells()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user