mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-13 01:08:35 +00:00
fix(Core/ObjectMgr): Force probabilities of creature displays during runtime if total probability is 0. (#23197)
This commit is contained in:
@@ -1122,8 +1122,22 @@ void ObjectMgr::CheckCreatureTemplate(CreatureTemplate const* cInfo)
|
||||
|
||||
if (!cInfo->Models.size())
|
||||
LOG_ERROR("sql.sql", "Creature (Entry: {}) does not have any existing display id in creature_template_model.", cInfo->Entry);
|
||||
else if (std::accumulate(cInfo->Models.begin(), cInfo->Models.end(), 0.0f, [](float sum, CreatureModel const& model) { return sum + model.Probability; }) <= 0.0f)
|
||||
LOG_ERROR("sql.sql", "Creature (Entry: {}) has zero total chance for all models in creature_template_model.", cInfo->Entry);
|
||||
else
|
||||
{
|
||||
float const totalProbability = std::accumulate(cInfo->Models.begin(), cInfo->Models.end(), 0.0f, [](float sum, CreatureModel const& model) { return sum + model.Probability; });
|
||||
|
||||
if (totalProbability <= 0.0f)
|
||||
{ // There are many cases in official data of all models having a probability of 0. Believe to be treated equivalent to equal chance ONLY if all are zeroed
|
||||
if (totalProbability == 0.0f)
|
||||
LOG_DEBUG("sql.sql", "Creature (Entry: {}) has zero total chance for all models in creature_template_model. Setting all to 1.0.", cInfo->Entry);
|
||||
else // Custom, likely bad data
|
||||
LOG_ERROR("sql.sql", "Creature (Entry: {}) has less than zero total chance for all models in creature_template_model. Setting all to 1.0.", cInfo->Entry);
|
||||
|
||||
auto& models = const_cast<CreatureTemplate*>(cInfo)->Models;
|
||||
for (auto& model : models)
|
||||
model.Probability = 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
if (!cInfo->unit_class || ((1 << (cInfo->unit_class - 1)) & CLASSMASK_ALL_CREATURES) == 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user