aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSpp <none@none>2010-05-04 17:51:11 +0200
committerSpp <none@none>2010-05-04 17:51:11 +0200
commit390f11078f46f05a9b0cd28b09b85d508e6940ec (patch)
tree3f492d758189e330b12bfeefe2bfed234d50949f
parent5b4647dcf40d91571d4f1c06d0c9d987724797d6 (diff)
Add support to set RandomProperty / RandomSuffix to -1 in item_template
--HG-- branch : trunk
-rw-r--r--src/game/Item.cpp2
-rw-r--r--src/game/ItemEnchantmentMgr.cpp17
-rw-r--r--src/game/ItemEnchantmentMgr.h2
-rw-r--r--src/game/ItemPrototype.h2
4 files changed, 17 insertions, 6 deletions
diff --git a/src/game/Item.cpp b/src/game/Item.cpp
index 30023f511ab..9927a936bc1 100644
--- a/src/game/Item.cpp
+++ b/src/game/Item.cpp
@@ -554,7 +554,7 @@ int32 Item::GenerateItemRandomPropertyId(uint32 item_id)
// RandomProperty case
if (itemProto->RandomProperty)
{
- int32 randomPropId = GetItemEnchantMod(itemProto->RandomProperty);
+ uint32 randomPropId = GetItemEnchantMod(itemProto->RandomProperty);
ItemRandomPropertiesEntry const *random_id = sItemRandomPropertiesStore.LookupEntry(randomPropId);
if (!random_id)
{
diff --git a/src/game/ItemEnchantmentMgr.cpp b/src/game/ItemEnchantmentMgr.cpp
index f86ecf1ba67..d452f9f6429 100644
--- a/src/game/ItemEnchantmentMgr.cpp
+++ b/src/game/ItemEnchantmentMgr.cpp
@@ -86,11 +86,22 @@ void LoadRandomEnchantmentsTable()
}
}
-uint32 GetItemEnchantMod(uint32 entry)
+uint32 GetItemEnchantMod(int32 entry)
{
- if (!entry) return 0;
+ if (!entry)
+ return 0;
+
+ EnchantmentStore::const_iterator tab;
- EnchantmentStore::const_iterator tab = RandomItemEnch.find(entry);
+ if (entry == -1)
+ {
+ tab = RandomItemEnch.begin();
+ entry = urand(1, RandomItemEnch.size()) - 1;
+ for (uint32 i = 0; i < entry; ++i)
+ ++tab;
+ }
+ else
+ tab = RandomItemEnch.find(entry);
if (tab == RandomItemEnch.end())
{
diff --git a/src/game/ItemEnchantmentMgr.h b/src/game/ItemEnchantmentMgr.h
index 8233c5e94c2..625dd651595 100644
--- a/src/game/ItemEnchantmentMgr.h
+++ b/src/game/ItemEnchantmentMgr.h
@@ -24,7 +24,7 @@
#include "Common.h"
void LoadRandomEnchantmentsTable();
-uint32 GetItemEnchantMod(uint32 entry);
+uint32 GetItemEnchantMod(int32 entry);
uint32 GenerateEnchSuffixFactor(uint32 item_id);
#endif
diff --git a/src/game/ItemPrototype.h b/src/game/ItemPrototype.h
index 7cec4551a5a..e547f56db84 100644
--- a/src/game/ItemPrototype.h
+++ b/src/game/ItemPrototype.h
@@ -570,7 +570,7 @@ struct ItemPrototype
int32 Material; // id from Material.dbc
uint32 Sheath;
int32 RandomProperty; // id from ItemRandomProperties.dbc
- uint32 RandomSuffix; // id from ItemRandomSuffix.dbc
+ int32 RandomSuffix; // id from ItemRandomSuffix.dbc
uint32 Block;
uint32 ItemSet; // id from ItemSet.dbc
uint32 MaxDurability;