aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql/base/world_database.sql6
-rw-r--r--sql/updates/world/2011_04_28_01_world_creature_equip_template.sql26
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.cpp6
-rwxr-xr-xsrc/server/game/Entities/Creature/Creature.cpp2
-rwxr-xr-xsrc/server/game/Entities/Creature/Creature.h6
-rwxr-xr-xsrc/server/game/Globals/ObjectMgr.cpp74
-rwxr-xr-xsrc/server/game/Globals/ObjectMgr.h2
-rwxr-xr-xsrc/server/shared/Database/SQLStorage.cpp2
8 files changed, 87 insertions, 37 deletions
diff --git a/sql/base/world_database.sql b/sql/base/world_database.sql
index 835642bf041..0ca95fb2ab4 100644
--- a/sql/base/world_database.sql
+++ b/sql/base/world_database.sql
@@ -1416,9 +1416,9 @@ DROP TABLE IF EXISTS `creature_equip_template`;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `creature_equip_template` (
`entry` mediumint(8) unsigned NOT NULL DEFAULT '0' COMMENT 'Unique entry',
- `equipentry1` mediumint(8) unsigned NOT NULL DEFAULT '0',
- `equipentry2` mediumint(8) unsigned NOT NULL DEFAULT '0',
- `equipentry3` mediumint(8) unsigned NOT NULL DEFAULT '0',
+ `itemEntry1` mediumint(8) unsigned NOT NULL DEFAULT '0',
+ `itemEntry2` mediumint(8) unsigned NOT NULL DEFAULT '0',
+ `itemEntry3` mediumint(8) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`entry`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Creature System (Equipment)';
/*!40101 SET character_set_client = @saved_cs_client */;
diff --git a/sql/updates/world/2011_04_28_01_world_creature_equip_template.sql b/sql/updates/world/2011_04_28_01_world_creature_equip_template.sql
new file mode 100644
index 00000000000..1cf6a95395c
--- /dev/null
+++ b/sql/updates/world/2011_04_28_01_world_creature_equip_template.sql
@@ -0,0 +1,26 @@
+ALTER TABLE `creature_equip_template`
+CHANGE `entry` `entry` SMALLINT(5) UNSIGNED DEFAULT '0' NOT NULL,
+CHANGE `equipentry1` `itemEntry1` MEDIUMINT(8) UNSIGNED DEFAULT '0' NOT NULL,
+CHANGE `equipentry2` `itemEntry2` MEDIUMINT(8) UNSIGNED DEFAULT '0' NOT NULL,
+CHANGE `equipentry3` `itemEntry3` MEDIUMINT(8) UNSIGNED DEFAULT '0' NOT NULL,
+ADD COLUMN `newEntry` INT UNSIGNED AUTO_INCREMENT,
+ADD INDEX(newEntry),
+DROP PRIMARY KEY;
+
+UPDATE `creature_template` ct, `creature_equip_template` cet
+SET ct.`equipment_id` = cet.`newEntry`
+WHERE ct.`equipment_id` = cet.`entry`;
+
+UPDATE `game_event_model_equip` geme, `creature_equip_template` cet
+SET geme.`equipment_id` = cet.`newEntry`
+WHERE geme.`equipment_id` = cet.`entry`;
+
+UPDATE `creature` c, `creature_equip_template` cet
+SET c.`equipment_id` = cet.`newEntry`
+WHERE c.`equipment_id` = cet.`entry`;
+
+UPDATE `creature_equip_template` SET `entry` = `newEntry`;
+
+ALTER TABLE `creature_equip_template`
+ADD PRIMARY KEY(`entry`),
+DROP COLUMN `newEntry`; \ No newline at end of file
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");