diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartScript.cpp | 6 | ||||
-rwxr-xr-x | src/server/game/Entities/Creature/Creature.cpp | 2 | ||||
-rwxr-xr-x | src/server/game/Entities/Creature/Creature.h | 6 | ||||
-rwxr-xr-x | src/server/game/Globals/ObjectMgr.cpp | 74 | ||||
-rwxr-xr-x | src/server/game/Globals/ObjectMgr.h | 2 | ||||
-rwxr-xr-x | src/server/shared/Database/SQLStorage.cpp | 2 |
6 files changed, 58 insertions, 34 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 22cd2ed17cf..f08be714ea8 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -1323,9 +1323,9 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u return; } npc->SetCurrentEquipmentId(e.action.equip.entry); - slot[0] = einfo->equipentry[0]; - slot[1] = einfo->equipentry[1]; - slot[2] = einfo->equipentry[2]; + slot[0] = einfo->ItemEntry[0]; + slot[1] = einfo->ItemEntry[1]; + slot[2] = einfo->ItemEntry[2]; } else { diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 7a591d5660e..3ff02511f29 100755 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -1354,7 +1354,7 @@ void Creature::LoadEquipment(uint32 equip_entry, bool force) m_equipmentId = equip_entry; for (uint8 i = 0; i < 3; ++i) - SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + i, einfo->equipentry[i]); + SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + i, einfo->ItemEntry[i]); } bool Creature::hasQuest(uint32 quest_id) const diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index 6dac9dd9d12..d25ddd24930 100755 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -230,10 +230,12 @@ struct PointOfInterestLocale struct EquipmentInfo { - uint32 entry; - uint32 equipentry[3]; + uint32 ItemEntry[3]; }; +// Benchmarked: Faster than std::map (insert/find) +typedef UNORDERED_MAP<uint16, EquipmentInfo> EquipmentInfoContainer; + // from `creature` table struct CreatureData { diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index a39d8665486..2fc2131d7e9 100755 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -1023,53 +1023,77 @@ void ObjectMgr::LoadCreatureAddons() EquipmentInfo const* ObjectMgr::GetEquipmentInfo(uint32 entry) { - return sEquipmentStorage.LookupEntry<EquipmentInfo>(entry); + EquipmentInfoContainer::const_iterator itr = EquipmentInfoStore.find(entry); + if (itr != EquipmentInfoStore.end()) + return &(itr->second); + + return NULL; } void ObjectMgr::LoadEquipmentTemplates() { uint32 oldMSTime = getMSTime(); - sEquipmentStorage.Load(); + QueryResult result = WorldDatabase.Query("SELECT entry, itemEntry1, itemEntry2, itemEntry3 FROM creature_equip_template"); - for (uint32 i = 0; i < sEquipmentStorage.MaxEntry; ++i) + if (!result) { - EquipmentInfo const* eqInfo = sEquipmentStorage.LookupEntry<EquipmentInfo>(i); + sLog->outString(">> Loaded 0 creature equipment templates. DB table `creature_equip_template` is empty!"); + sLog->outString(); + return; + } - if (!eqInfo) - continue; + uint32 count = 0; + do + { + Field* fields = result->Fetch(); + + uint16 entry = fields[0].GetUInt16(); + + EquipmentInfo equipmentInfo; + + equipmentInfo.ItemEntry[0] = fields[1].GetUInt32(); + equipmentInfo.ItemEntry[1] = fields[2].GetUInt32(); + equipmentInfo.ItemEntry[2] = fields[3].GetUInt32(); - for (uint8 j = 0; j < 3; ++j) + for (uint8 i = 0; i < 3; ++i) { - if (!eqInfo->equipentry[j]) - continue; + if (!equipmentInfo.ItemEntry[i]) + continue; - ItemEntry const *dbcitem = sItemStore.LookupEntry(eqInfo->equipentry[j]); + ItemEntry const *dbcItem = sItemStore.LookupEntry(equipmentInfo.ItemEntry[i]); - if (!dbcitem) + if (!dbcItem) { - sLog->outErrorDb("Unknown item (entry=%u) in creature_equip_template.equipentry%u for entry = %u, forced to 0.", eqInfo->equipentry[j], j+1, i); - const_cast<EquipmentInfo*>(eqInfo)->equipentry[j] = 0; + sLog->outErrorDb("Unknown item (entry=%u) in creature_equip_template.itemEntry%u for entry = %u, forced to 0.", + equipmentInfo.ItemEntry[i], i+1, entry); + equipmentInfo.ItemEntry[i] = 0; continue; } - if (dbcitem->InventoryType != INVTYPE_WEAPON && - dbcitem->InventoryType != INVTYPE_SHIELD && - dbcitem->InventoryType != INVTYPE_RANGED && - dbcitem->InventoryType != INVTYPE_2HWEAPON && - dbcitem->InventoryType != INVTYPE_WEAPONMAINHAND && - dbcitem->InventoryType != INVTYPE_WEAPONOFFHAND && - dbcitem->InventoryType != INVTYPE_HOLDABLE && - dbcitem->InventoryType != INVTYPE_THROWN && - dbcitem->InventoryType != INVTYPE_RANGEDRIGHT) + if (dbcItem->InventoryType != INVTYPE_WEAPON && + dbcItem->InventoryType != INVTYPE_SHIELD && + dbcItem->InventoryType != INVTYPE_RANGED && + dbcItem->InventoryType != INVTYPE_2HWEAPON && + dbcItem->InventoryType != INVTYPE_WEAPONMAINHAND && + dbcItem->InventoryType != INVTYPE_WEAPONOFFHAND && + dbcItem->InventoryType != INVTYPE_HOLDABLE && + dbcItem->InventoryType != INVTYPE_THROWN && + dbcItem->InventoryType != INVTYPE_RANGEDRIGHT) { - sLog->outErrorDb("Item (entry=%u) in creature_equip_template.equipentry%u for entry = %u is not equipable in a hand, forced to 0.", eqInfo->equipentry[j], j+1, i); - const_cast<EquipmentInfo*>(eqInfo)->equipentry[j] = 0; + sLog->outErrorDb("Item (entry=%u) in creature_equip_template.itemEntry%u for entry = %u is not equipable in a hand, forced to 0.", + equipmentInfo.ItemEntry[i], i+1, entry); + equipmentInfo.ItemEntry[i] = 0; } } + + EquipmentInfoStore[entry] = equipmentInfo; + + ++count; } + while (result->NextRow()); - sLog->outString(">> Loaded %u equipment templates in %u ms", sEquipmentStorage.RecordCount, GetMSTimeDiffToNow(oldMSTime)); + sLog->outString(">> Loaded %u equipment templates in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); sLog->outString(); } diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h index 8350ae92abb..adcab35c4eb 100755 --- a/src/server/game/Globals/ObjectMgr.h +++ b/src/server/game/Globals/ObjectMgr.h @@ -46,7 +46,6 @@ extern SQLStorage sCreatureStorage; extern SQLStorage sCreatureDataAddonStorage; extern SQLStorage sCreatureInfoAddonStorage; -extern SQLStorage sEquipmentStorage; extern SQLStorage sGOStorage; extern SQLStorage sItemStorage; @@ -1408,6 +1407,7 @@ class ObjectMgr MapObjectGuids mMapObjectGuids; CreatureDataMap mCreatureDataMap; CreatureModelContainer CreatureModelStore; + EquipmentInfoContainer EquipmentInfoStore; LinkedRespawnMap mLinkedRespawnMap; CreatureLocaleMap mCreatureLocaleMap; GameObjectDataMap mGameObjectDataMap; diff --git a/src/server/shared/Database/SQLStorage.cpp b/src/server/shared/Database/SQLStorage.cpp index 5fc850e6eda..6fcb7b1af9d 100755 --- a/src/server/shared/Database/SQLStorage.cpp +++ b/src/server/shared/Database/SQLStorage.cpp @@ -23,7 +23,6 @@ const char CreatureInfosrcfmt[]="iiiiiiiiiisssiiiiiiifffiffiifiiiiiiiiiiffiiiiii const char CreatureInfodstfmt[]="iiiiiiiiiisssibbiiiifffiffiifiiiiiiiiiiffiiiiiiiiiiiiiiiiiiiiiiiisiifffliiiiiiiliiiii"; const char CreatureDataAddonInfofmt[]="iiiiiis"; const char CreatureInfoAddonInfofmt[]="iiiiiis"; -const char EquipmentInfofmt[]="iiii"; const char GameObjectInfosrcfmt[]="iiissssiifiiiiiiiiiiiiiiiiiiiiiiiiiiiiiissi"; const char GameObjectInfodstfmt[]="iiissssiifiiiiiiiiiiiiiiiiiiiiiiiiiiiiiisii"; const char ItemPrototypesrcfmt[]="iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifiiisiiiii"; @@ -32,7 +31,6 @@ const char ItemPrototypedstfmt[]="iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii SQLStorage sCreatureStorage(CreatureInfosrcfmt, CreatureInfodstfmt, "entry","creature_template"); SQLStorage sCreatureDataAddonStorage(CreatureDataAddonInfofmt,"guid","creature_addon"); SQLStorage sCreatureInfoAddonStorage(CreatureInfoAddonInfofmt,"entry","creature_template_addon"); -SQLStorage sEquipmentStorage(EquipmentInfofmt,"entry","creature_equip_template"); SQLStorage sGOStorage(GameObjectInfosrcfmt, GameObjectInfodstfmt, "entry","gameobject_template"); SQLStorage sItemStorage(ItemPrototypesrcfmt, ItemPrototypedstfmt, "entry","item_template"); |