mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 13:37:05 +00:00
[c12552] Differ random property and random suffix entries in item_enchantment_template table. Use negative values for random suffixes. This will fix overlapping entries.
Fixes cmangos/issues#138 Signed-off-by: Dramacydal <PulLumBerMal@gmail.com>
This commit is contained in:
parent
ab636ea537
commit
456de16b5e
8 changed files with 2634 additions and 6294 deletions
8845
sql/mangos.sql
8845
sql/mangos.sql
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,3 @@
|
|||
ALTER TABLE db_version CHANGE COLUMN required_c12484_01_mangos_string required_c12552_01_mangos_item_enchantment_template bit;
|
||||
|
||||
ALTER TABLE item_enchantment_template MODIFY COLUMN entry mediumint(8) NOT NULL DEFAULT '0';
|
||||
|
|
@ -771,7 +771,7 @@ int32 Item::GenerateItemRandomPropertyId(uint32 item_id)
|
|||
// Random Property case
|
||||
if (itemProto->RandomProperty)
|
||||
{
|
||||
uint32 randomPropId = GetItemEnchantMod(itemProto->RandomProperty);
|
||||
uint32 randomPropId = GetItemRandomPropertyMod(itemProto->RandomProperty);
|
||||
ItemRandomPropertiesEntry const* random_id = sItemRandomPropertiesStore.LookupEntry(randomPropId);
|
||||
if (!random_id)
|
||||
{
|
||||
|
|
@ -784,7 +784,7 @@ int32 Item::GenerateItemRandomPropertyId(uint32 item_id)
|
|||
// Random Suffix case
|
||||
else
|
||||
{
|
||||
uint32 randomPropId = GetItemEnchantMod(itemProto->RandomSuffix);
|
||||
uint32 randomPropId = GetItemRandomSuffixMod(itemProto->RandomSuffix);
|
||||
ItemRandomSuffixEntry const* random_id = sItemRandomSuffixStore.LookupEntry(randomPropId);
|
||||
if (!random_id)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -42,17 +42,15 @@ struct EnchStoreItem
|
|||
typedef std::vector<EnchStoreItem> EnchStoreList;
|
||||
typedef UNORDERED_MAP<uint32, EnchStoreList> EnchantmentStore;
|
||||
|
||||
static EnchantmentStore RandomItemEnch;
|
||||
static EnchantmentStore RandomItemPropEnch;
|
||||
static EnchantmentStore RandomItemSuffixEnch;
|
||||
|
||||
void LoadRandomEnchantmentsTable()
|
||||
{
|
||||
RandomItemEnch.clear(); // for reload case
|
||||
RandomItemPropEnch.clear(); // for reload case
|
||||
RandomItemSuffixEnch.clear(); // for reload case
|
||||
|
||||
EnchantmentStore::const_iterator tab;
|
||||
uint32 entry, ench;
|
||||
float chance;
|
||||
uint32 count = 0;
|
||||
|
||||
QueryResult* result = WorldDatabase.Query("SELECT entry, ench, chance FROM item_enchantment_template");
|
||||
|
||||
if (result)
|
||||
|
|
@ -64,12 +62,23 @@ void LoadRandomEnchantmentsTable()
|
|||
Field* fields = result->Fetch();
|
||||
bar.step();
|
||||
|
||||
entry = fields[0].GetUInt32();
|
||||
ench = fields[1].GetUInt32();
|
||||
chance = fields[2].GetFloat();
|
||||
int32 entry = fields[0].GetInt32();
|
||||
uint32 ench = fields[1].GetUInt32();
|
||||
float chance = fields[2].GetFloat();
|
||||
|
||||
if (chance > 0.000001f && chance <= 100.0f)
|
||||
RandomItemEnch[entry].push_back(EnchStoreItem(ench, chance));
|
||||
{
|
||||
if (entry > 0)
|
||||
RandomItemPropEnch[entry].push_back(EnchStoreItem(ench, chance));
|
||||
else
|
||||
RandomItemSuffixEnch[-entry].push_back(EnchStoreItem(ench, chance));
|
||||
}
|
||||
else
|
||||
{
|
||||
sLog.outErrorDb("Item Enchantment %u for entry %u has too high or too low chance %f, skipped.", ench, entry, chance);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
++count;
|
||||
}
|
||||
|
|
@ -87,16 +96,29 @@ void LoadRandomEnchantmentsTable()
|
|||
}
|
||||
}
|
||||
|
||||
uint32 GetItemEnchantMod(uint32 entry)
|
||||
uint32 GetItemEnchantMod(int32 entry)
|
||||
{
|
||||
if (!entry) return 0;
|
||||
|
||||
EnchantmentStore::const_iterator tab = RandomItemEnch.find(entry);
|
||||
|
||||
if (tab == RandomItemEnch.end())
|
||||
{
|
||||
sLog.outErrorDb("Item RandomProperty / RandomSuffix id #%u used in `item_template` but it doesn't have records in `item_enchantment_template` table.", entry);
|
||||
if (!entry)
|
||||
return 0;
|
||||
|
||||
EnchantmentStore::const_iterator tab;
|
||||
if (entry > 0)
|
||||
{
|
||||
tab = RandomItemPropEnch.find(entry);
|
||||
if (tab == RandomItemPropEnch.end())
|
||||
{
|
||||
sLog.outErrorDb("Item RandomProperty id #%u used in `item_template` but it doesn't have records in `item_enchantment_template` table.", entry);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tab = RandomItemSuffixEnch.find(-entry);
|
||||
if (tab == RandomItemSuffixEnch.end())
|
||||
{
|
||||
sLog.outErrorDb("Item RandomSuffix id #%u used in `item_template` but it doesn't have records in `item_enchantment_template` table.", -entry);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
double dRoll = rand_chance();
|
||||
|
|
@ -123,6 +145,9 @@ uint32 GetItemEnchantMod(uint32 entry)
|
|||
return 0;
|
||||
}
|
||||
|
||||
uint32 GetItemRandomPropertyMod(uint32 entry) { return GetItemEnchantMod(entry); }
|
||||
uint32 GetItemRandomSuffixMod(uint32 entry) { return GetItemEnchantMod(-int32(entry)); }
|
||||
|
||||
uint32 GenerateEnchSuffixFactor(uint32 item_id)
|
||||
{
|
||||
ItemPrototype const* itemProto = ObjectMgr::GetItemPrototype(item_id);
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
#include "Common.h"
|
||||
|
||||
void LoadRandomEnchantmentsTable();
|
||||
uint32 GetItemEnchantMod(uint32 entry);
|
||||
uint32 GetItemRandomPropertyMod(uint32 entry);
|
||||
uint32 GetItemRandomSuffixMod(uint32 entry);
|
||||
uint32 GenerateEnchSuffixFactor(uint32 item_id);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -2183,13 +2183,13 @@ void ObjectMgr::LoadItemPrototypes()
|
|||
const_cast<ItemPrototype*>(proto)->Sheath = SHEATHETYPE_NONE;
|
||||
}
|
||||
|
||||
if (proto->RandomProperty && !sItemRandomPropertiesStore.LookupEntry(GetItemEnchantMod(proto->RandomProperty)))
|
||||
if (proto->RandomProperty && !sItemRandomPropertiesStore.LookupEntry(GetItemRandomPropertyMod(proto->RandomProperty)))
|
||||
{
|
||||
sLog.outErrorDb("Item (Entry: %u) has unknown (wrong or not listed in `item_enchantment_template`) RandomProperty (%u)", i, proto->RandomProperty);
|
||||
const_cast<ItemPrototype*>(proto)->RandomProperty = 0;
|
||||
}
|
||||
|
||||
if (proto->RandomSuffix && !sItemRandomSuffixStore.LookupEntry(GetItemEnchantMod(proto->RandomSuffix)))
|
||||
if (proto->RandomSuffix && !sItemRandomSuffixStore.LookupEntry(GetItemRandomSuffixMod(proto->RandomSuffix)))
|
||||
{
|
||||
sLog.outErrorDb("Item (Entry: %u) has wrong RandomSuffix (%u)", i, proto->RandomSuffix);
|
||||
const_cast<ItemPrototype*>(proto)->RandomSuffix = 0;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "12551"
|
||||
#define REVISION_NR "12552"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#ifndef __REVISION_SQL_H__
|
||||
#define __REVISION_SQL_H__
|
||||
#define REVISION_DB_CHARACTERS "required_12161_01_characters_characters"
|
||||
#define REVISION_DB_MANGOS "required_12216_12_mangos_spell_loot_template"
|
||||
#define REVISION_DB_REALMD "required_12112_01_realmd_account_access"
|
||||
#define REVISION_DB_CHARACTERS "required_12447_02_characters_calendar_invites"
|
||||
#define REVISION_DB_MANGOS "required_c12552_01_mangos_item_enchantment_template"
|
||||
#define REVISION_DB_REALMD "required_c12484_02_realmd_account_access"
|
||||
#endif // __REVISION_SQL_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue