1
0

Fixed Errors

This commit is contained in:
daniel0916 2014-04-18 14:34:29 +02:00
parent 3efd232829
commit 56613d2b22
3 changed files with 23 additions and 5 deletions

View File

@ -893,7 +893,23 @@ void cEnchantments::RemoveEnchantmentWeightFromVector(cWeightedEnchantments * a_
if (EnchantmentID == a_EnchantmentID)
{
a_Enchantments->erase(std::remove(a_Enchantments->begin(), a_Enchantments->end(), *it), a_Enchantments->end());
a_Enchantments->erase(it);
break;
}
}
}
void cEnchantments::RemoveEnchantmentWeightFromVector(cWeightedEnchantments * a_Enchantments, cEnchantments a_Enchantment)
{
for (cWeightedEnchantments::iterator it = a_Enchantments->begin(); it != a_Enchantments->end(); ++it)
{
if ((*it).m_Enchantments == a_Enchantment)
{
a_Enchantments->erase(it);
break;
}
}
@ -980,6 +996,8 @@ cEnchantments cEnchantments::GetRandomEnchantmentFromVector(cWeightedEnchantment
return (*it).m_Enchantments;
}
}
return cEnchantments();
}

View File

@ -109,6 +109,7 @@ public:
static void AddEnchantmentWeightToVector(cWeightedEnchantments * a_Enchantments, int a_Weight, cEnchantments a_Enchantment);
/** Remove a enchantment weight from the vector */
static void RemoveEnchantmentWeightFromVector(cWeightedEnchantments * a_Enchantments, int a_EnchantmentID);
static void RemoveEnchantmentWeightFromVector(cWeightedEnchantments * a_Enchantments, cEnchantments a_Enchantment);
/** Check enchantment conflicts from enchantments from the vector */
static void CheckEnchantmentConflictsFromVector(cWeightedEnchantments & a_Enchantments, cEnchantments a_FirstEnchantment);

View File

@ -286,7 +286,7 @@ bool cItem::EnchantByXPLevels(int a_NumXPLevels)
cEnchantments Enchantment1 = cEnchantments::GetRandomEnchantmentFromVector(enchantments);
m_Enchantments.AddFromString(Enchantment1.ToString());
enchantments.erase(std::remove(enchantments.begin(), enchantments.end(), Enchantment1), enchantments.end());
cEnchantments::RemoveEnchantmentWeightFromVector(&enchantments, Enchantment1);
// Checking for conflicting enchantments
cEnchantments::CheckEnchantmentConflictsFromVector(enchantments, Enchantment1);
@ -302,7 +302,7 @@ bool cItem::EnchantByXPLevels(int a_NumXPLevels)
{
cEnchantments Enchantment2 = cEnchantments::GetRandomEnchantmentFromVector(enchantments);
m_Enchantments.AddFromString(Enchantment2.ToString());
enchantments.erase(std::remove(enchantments.begin(), enchantments.end(), Enchantment2), enchantments.end());
cEnchantments::RemoveEnchantmentWeightFromVector(&enchantments, Enchantment2);
// Checking for conflicting enchantments
cEnchantments::CheckEnchantmentConflictsFromVector(enchantments, Enchantment2);
@ -318,7 +318,7 @@ bool cItem::EnchantByXPLevels(int a_NumXPLevels)
{
cEnchantments Enchantment3 = cEnchantments::GetRandomEnchantmentFromVector(enchantments);
m_Enchantments.AddFromString(Enchantment3.ToString());
enchantments.erase(std::remove(enchantments.begin(), enchantments.end(), Enchantment3), enchantments.end());
cEnchantments::RemoveEnchantmentWeightFromVector(&enchantments, Enchantment3);
// Checking for conflicting enchantments
cEnchantments::CheckEnchantmentConflictsFromVector(enchantments, Enchantment3);
@ -334,7 +334,6 @@ bool cItem::EnchantByXPLevels(int a_NumXPLevels)
{
cEnchantments Enchantment4 = cEnchantments::GetRandomEnchantmentFromVector(enchantments);
m_Enchantments.AddFromString(Enchantment4.ToString());
enchantments.erase(std::remove(enchantments.begin(), enchantments.end(), Enchantment4), enchantments.end());
}
}