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
+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