diff options
author | Spp <none@none> | 2010-03-12 18:19:50 +0100 |
---|---|---|
committer | Spp <none@none> | 2010-03-12 18:19:50 +0100 |
commit | d2a3f9670f303ad3e27d2860762091db37ab2d2e (patch) | |
tree | 55847046025f3ba831f6d29348a1731be4d85d4b /src/game/ObjectMgr.cpp | |
parent | 19b646cdff0fb7541e0e46ac1ee7626d1e8a6b5c (diff) |
Move vehicle accesories to DB.
Credit to Malcrom and Manuel for the idea and original patch
--HG--
branch : trunk
Diffstat (limited to 'src/game/ObjectMgr.cpp')
-rw-r--r-- | src/game/ObjectMgr.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 2ba3942ed4a..c6cccc7f45e 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -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 |