Move vehicle accesories to DB.

Credit to Malcrom and Manuel for the idea and original patch

--HG--
branch : trunk
This commit is contained in:
Spp
2010-03-12 18:19:50 +01:00
parent 19b646cdff
commit d2a3f9670f
7 changed files with 189 additions and 18 deletions
@@ -0,0 +1,39 @@
CREATE TABLE `vehicle_accessory` (
`entry` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT 0,
`accessory_entry` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT 0,
`seat_id` TINYINT(1) SIGNED NOT NULL DEFAULT 0,
`minion` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
`description` TEXT NOT NULL,
PRIMARY KEY (`entry`, `seat_id`)
)
COLLATE=utf8_general_ci
ENGINE=MyISAM
ROW_FORMAT=FIXED
AVG_ROW_LENGTH=0
INSERT INTO `vehicle_accessory` (`entry`,`accessory_entry`,`seat_id`,`minion`,`description`) VALUES
(28782,28768,0,0, 'Acherus Deathcharger'),
(28312,28319,7,1, 'Wintergrasp Siege Engine'),
(32627,32629,7,1, 'Wintergrasp Siege Engine'),
(32930,32933,0,1, 'Kologarn'),
(32930,32934,1,1, 'Kologarn'),
(33109,33167,1,1, 'Salvaged Demolisher'),
(33060,33067,7,1, 'Salvaged Siege Engine'),
(33113,33114,0,1, 'Flame Leviathan'),
(33113,33114,1,1, 'Flame Leviathan'),
(33113,33114,2,1, 'Flame Leviathan'),
(33113,33114,3,1, 'Flame Leviathan'),
(33113,33139,7,1, 'Flame Leviathan'),
(33114,33142,1,1, 'Overload Control Device'),
(33114,33143,2,1, 'Leviathan Defense Turret'),
(33214,33218,1,1, 'Mechanolift 304-A'),
(35637,34705,0,0, 'Marshal Jacob Alerius'' Mount'),
(35633,34702,0,0, 'Ambrose Boltspark''s Mount'),
(35768,34701,0,0, 'Colosos'' Mount'),
(34658,34657,0,0, 'Jaelyne Evensong''s Mount'),
(35636,34703,0,0, 'Lana Stouthammer''s Mount'),
(35638,35572,0,0, 'Mokra the Skullcrusher''s Mount'),
(35635,35569,0,0, 'Eressea Dawnsinger''s Mount'),
(35640,35571,0,0, 'Runok Wildmane''s Mount'),
(35641,35570,0,0, 'Zul''tore''s Mount'),
(35634,35617,0,0, 'Deathstalker Visceri''s Mount');
+46
View File
@@ -14886,6 +14886,52 @@ INSERT INTO `trinity_string` (`entry`,`content_default`,`content_loc1`,`content_
/*!40000 ALTER TABLE `trinity_string` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `vehicle_accessory`
--
DROP TABLE IF EXISTS `vehicle_accessory`;
CREATE TABLE `vehicle_accessory` (
`entry` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT 0,
`accessory_entry` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT 0,
`seat_id` TINYINT(1) SIGNED NOT NULL DEFAULT 0,
`minion` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
`description` TEXT NOT NULL,
PRIMARY KEY (`entry`, `seat_id`)
)
COLLATE=utf8_general_ci
ENGINE=MyISAM
ROW_FORMAT=FIXED
AVG_ROW_LENGTH=0
LOCK TABLES `vehicle_accessory` WRITE;
INSERT INTO `vehicle_accessory` (`entry`,`accessory_entry`,`seat_id`,`minion`,`description`) VALUES
(28782,28768,0,0, 'Acherus Deathcharger'),
(28312,28319,7,1, 'Wintergrasp Siege Engine'),
(32627,32629,7,1, 'Wintergrasp Siege Engine'),
(32930,32933,0,1, 'Kologarn'),
(32930,32934,1,1, 'Kologarn'),
(33109,33167,1,1, 'Salvaged Demolisher'),
(33060,33067,7,1, 'Salvaged Siege Engine'),
(33113,33114,0,1, 'Flame Leviathan'),
(33113,33114,1,1, 'Flame Leviathan'),
(33113,33114,2,1, 'Flame Leviathan'),
(33113,33114,3,1, 'Flame Leviathan'),
(33113,33139,7,1, 'Flame Leviathan'),
(33114,33142,1,1, 'Overload Control Device'),
(33114,33143,2,1, 'Leviathan Defense Turret'),
(33214,33218,1,1, 'Mechanolift 304-A'),
(35637,34705,0,0, 'Marshal Jacob Alerius'' Mount'),
(35633,34702,0,0, 'Ambrose Boltspark''s Mount'),
(35768,34701,0,0, 'Colosos'' Mount'),
(34658,34657,0,0, 'Jaelyne Evensong''s Mount'),
(35636,34703,0,0, 'Lana Stouthammer''s Mount'),
(35638,35572,0,0, 'Mokra the Skullcrusher''s Mount'),
(35635,35569,0,0, 'Eressea Dawnsinger''s Mount'),
(35640,35571,0,0, 'Runok Wildmane''s Mount'),
(35641,35570,0,0, 'Zul''tore''s Mount'),
(35634,35617,0,0, 'Deathstalker Visceri''s Mount');
UNLOCK TABLES;
--
-- Table structure for table `version`
--
+56
View File
@@ -46,6 +46,7 @@
#include "WaypointManager.h"
#include "InstanceData.h" //for condition_instance_data
#include "GossipDef.h"
#include "Vehicle.h"
INSTANTIATE_SINGLETON_1(ObjectMgr);
@@ -2362,6 +2363,61 @@ void ObjectMgr::LoadItemPrototypes()
sLog.outErrorDb("Item (Entry: %u) not exist in `item_template` but referenced in `CharStartOutfit.dnc`", *itr);
}
void ObjectMgr::LoadVehicleAccessories()
{
m_VehicleAccessoryMap.clear(); // needed for reload case
VehicleAccessoryList mVehicleList;
uint32 count = 0;
QueryResult_AutoPtr result = WorldDatabase.Query("SELECT `entry`,`accessory_entry`,`seat_id`,`minion` FROM `vehicle_accessory`");
if (!result)
{
barGoLink bar(1);
bar.step();
sLog.outString();
sLog.outErrorDb(">> Loaded 0 LoadVehicleAccessor. DB table `vehicle_accessory` is empty.");
return;
}
barGoLink bar(result->GetRowCount());
do
{
Field *fields = result->Fetch();
bar.step();
uint32 uiEntry = fields[0].GetUInt32();
uint32 uiAccessory = fields[1].GetUInt32();
int8 uiSeat = int8(fields[2].GetInt16());
bool bMinion = fields[3].GetBool();
if (!sCreatureStorage.LookupEntry<CreatureInfo>(uiEntry))
{
sLog.outErrorDb("Table `vehicle_accessory`: creature template entry %u does not exist.", uiEntry);
continue;
}
if (!sCreatureStorage.LookupEntry<CreatureInfo>(uiAccessory))
{
sLog.outErrorDb("Table `vehicle_accessory`: Accessory %u does not exist.", uiAccessory);
continue;
}
mVehicleList = GetVehicleAccessoryList(uiEntry);
mVehicleList.push_back(VehicleAccessory(uiAccessory, uiSeat, bMinion));
m_VehicleAccessoryMap[uiEntry] = mVehicleList;
++count;
} while (result->NextRow());
sLog.outString();
sLog.outString(">> Loaded %u Vehicle Accessories", count);
}
void ObjectMgr::LoadItemRequiredTarget()
{
m_ItemRequiredTarget.clear(); // needed for reload case
+13
View File
@@ -40,6 +40,7 @@
#include "ObjectDefines.h"
#include "Policies/Singleton.h"
#include "Database/SQLStorage.h"
#include "Vehicle.h"
#include <string>
#include <map>
@@ -577,6 +578,15 @@ class ObjectMgr
return NULL;
}
VehicleAccessoryList GetVehicleAccessoryList(uint32 uiEntry)
{
VehicleAccessoryList mVehList;
VehicleAccessoryMap::const_iterator itr = m_VehicleAccessoryMap.find(uiEntry);
if (itr != m_VehicleAccessoryMap.end())
mVehList = itr->second;
return mVehList;
}
void LoadGuilds();
void LoadArenaTeams();
void LoadGroups();
@@ -639,6 +649,7 @@ class ObjectMgr
void LoadPointOfInterestLocales();
void LoadInstanceTemplate();
void LoadMailLevelRewards();
void LoadVehicleAccessories();
void LoadGossipText();
@@ -1047,6 +1058,8 @@ class ObjectMgr
ItemRequiredTargetMap m_ItemRequiredTarget;
VehicleAccessoryMap m_VehicleAccessoryMap;
typedef std::vector<LocaleConstant> LocalForIndex;
LocalForIndex m_LocalForIndex;
+8 -5
View File
@@ -91,7 +91,11 @@ void Vehicle::Install()
void Vehicle::InstallAllAccessories()
{
switch(me->GetEntry())
VehicleAccessoryList mVehicleList = objmgr.GetVehicleAccessoryList(me->GetEntry());
if (mVehicleList.size())
for (VehicleAccessoryList::iterator itr2 = mVehicleList.begin(); itr2 < mVehicleList.end(); ++itr2)
InstallAccessory(itr2->uiAccessory, itr2->uiSeat, itr2->bMinion);
/*switch(me->GetEntry())
{
//case 27850:InstallAccessory(27905,1);break;
case 28782:InstallAccessory(28768,0,false);break; // Acherus Deathcharger
@@ -136,7 +140,7 @@ void Vehicle::InstallAllAccessories()
case 33418:InstallAccessory(35326,0);break; //Silvermoon Hawkstrider
case 33299:InstallAccessory(35323,0);break; //Darkspear Raptor
case 35491:InstallAccessory(35451,0,false);break; //Black Knight
}
}*/
}
void Vehicle::Uninstall()
@@ -162,19 +166,18 @@ void Vehicle::Die()
void Vehicle::Reset()
{
sLog.outDebug("Vehicle::Reset");
if(m_usableSeatNum)
{
if (me->GetTypeId() == TYPEID_PLAYER)
{
if (m_usableSeatNum)
me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_PLAYER_VEHICLE);
}
else
{
InstallAllAccessories();
if (m_usableSeatNum)
me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
}
}
}
void Vehicle::RemoveAllPassengers()
{
+11
View File
@@ -38,6 +38,17 @@ struct VehicleSeat
Unit* passenger;
};
struct VehicleAccessory
{
explicit VehicleAccessory(uint32 _uiAccessory, int8 _uiSeat, bool _bMinion) : uiAccessory(_uiAccessory), uiSeat(_uiSeat), bMinion(_bMinion) {}
uint32 uiAccessory;
int8 uiSeat;
uint32 bMinion;
};
typedef std::vector<VehicleAccessory> VehicleAccessoryList;
typedef std::map<uint32, VehicleAccessoryList> VehicleAccessoryMap;
typedef std::map<int8, VehicleSeat> SeatMap;
class Vehicle
+3
View File
@@ -1393,6 +1393,9 @@ void World::SetInitialWorldSettings()
sLog.outString("Loading Creature Template Addon Data...");
objmgr.LoadCreatureAddons(); // must be after LoadCreatureTemplates() and LoadCreatures()
sLog.outString("Loading Vehicle Accessories...");
objmgr.LoadVehicleAccessories(); // must be after LoadCreatureTemplates()
sLog.outString("Loading Creature Respawn Data..."); // must be after PackInstances()
objmgr.LoadCreatureRespawnTimes();