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 | |
parent | 19b646cdff0fb7541e0e46ac1ee7626d1e8a6b5c (diff) |
Move vehicle accesories to DB.
Credit to Malcrom and Manuel for the idea and original patch
--HG--
branch : trunk
-rw-r--r-- | sql/updates/7547_world_vehicle_accessory.sql | 39 | ||||
-rw-r--r-- | sql/world.sql | 62 | ||||
-rw-r--r-- | src/game/ObjectMgr.cpp | 56 | ||||
-rw-r--r-- | src/game/ObjectMgr.h | 13 | ||||
-rw-r--r-- | src/game/Vehicle.cpp | 23 | ||||
-rw-r--r-- | src/game/Vehicle.h | 11 | ||||
-rw-r--r-- | src/game/World.cpp | 3 |
7 files changed, 189 insertions, 18 deletions
diff --git a/sql/updates/7547_world_vehicle_accessory.sql b/sql/updates/7547_world_vehicle_accessory.sql new file mode 100644 index 00000000000..a7e3dc4f42f --- /dev/null +++ b/sql/updates/7547_world_vehicle_accessory.sql @@ -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');
\ No newline at end of file diff --git a/sql/world.sql b/sql/world.sql index 0ee8ed1362c..805e76841fb 100644 --- a/sql/world.sql +++ b/sql/world.sql @@ -14805,14 +14805,14 @@ INSERT INTO `trinity_string` (`entry`,`content_default`,`content_loc1`,`content_ (5025, 'Type: %u', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), (5026, 'DisplayID: %u', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), (5027, 'Name: %s', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), -(6604, 'You cannot say, yell or emote until you become level %d.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
-(6605, 'You cannot whisper until you become level %d.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
-(6606, 'You cannot write to channels until you become level %d.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
-(6607, 'You cannot use auction until you become level %d.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
-(6608, 'You cannot write tickets until you become level %d.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
-(6609, 'You cannot trade until you become level %d.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
-(6610, 'You cannot trade with characters lower than level %d.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
-(6611, 'You cannot send mail until you become level %d.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+(6604, 'You cannot say, yell or emote until you become level %d.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), +(6605, 'You cannot whisper until you become level %d.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), +(6606, 'You cannot write to channels until you become level %d.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), +(6607, 'You cannot use auction until you become level %d.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), +(6608, 'You cannot write tickets until you become level %d.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), +(6609, 'You cannot trade until you become level %d.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), +(6610, 'You cannot trade with characters lower than level %d.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), +(6611, 'You cannot send mail until you become level %d.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), (6612, 'You cannot send mail to characters lower than level %d.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), (6613, '|cfff00000[GM Announcement]: %s|r', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), (6614, 'Notification to GM''s - ', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), @@ -14887,6 +14887,52 @@ INSERT INTO `trinity_string` (`entry`,`content_default`,`content_loc1`,`content_ 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` -- 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 diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h index 3bb83e4a980..6193eaa2257 100644 --- a/src/game/ObjectMgr.h +++ b/src/game/ObjectMgr.h @@ -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; diff --git a/src/game/Vehicle.cpp b/src/game/Vehicle.cpp index 0773a3dda37..07c0f32a6e8 100644 --- a/src/game/Vehicle.cpp +++ b/src/game/Vehicle.cpp @@ -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,17 +166,16 @@ void Vehicle::Die() void Vehicle::Reset() { sLog.outDebug("Vehicle::Reset"); - if(m_usableSeatNum) + if (me->GetTypeId() == TYPEID_PLAYER) { - if (me->GetTypeId() == TYPEID_PLAYER) - { + if (m_usableSeatNum) me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_PLAYER_VEHICLE); - } - else - { - InstallAllAccessories(); + } + else + { + InstallAllAccessories(); + if (m_usableSeatNum) me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK); - } } } diff --git a/src/game/Vehicle.h b/src/game/Vehicle.h index c8b12f9f6cb..1770a60798d 100644 --- a/src/game/Vehicle.h +++ b/src/game/Vehicle.h @@ -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 diff --git a/src/game/World.cpp b/src/game/World.cpp index 689f35f4177..b936162b367 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -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(); |