Why sometimes when a guy die in my server freeze after i added it on my sources to increase skills losses ondeath?
I'm using 0.4 sources
I just added a * 5 in player.cpp
I'm using 0.4 sources
I just added a * 5 in player.cpp
Code:
lostMana = (uint64_t)std::ceil(sumMana * ((double)(percent * 5 * lossPercent[LOSS_MANA]) / 100.));
lostSkillTries = (uint32_t)std::ceil(sumSkillTries * ((double)(percent * 5 * lossPercent[LOSS_SKILLS]) / 100.));
Code:
if(skillLoss)
{
uint64_t lossExperience = getLostExperience();
removeExperience(lossExperience, false);
double percent = 1. - ((double)(experience - lossExperience) / experience);
//Magic level loss
uint32_t sumMana = 0;
uint64_t lostMana = 0;
for(uint32_t i = 1; i <= magLevel; ++i)
sumMana += vocation->getReqMana(i);
sumMana += manaSpent;
lostMana = (uint64_t)std::ceil(sumMana * ((double)(percent * 5 * lossPercent[LOSS_MANA]) / 100.));
while(lostMana > manaSpent && magLevel > 0)
{
lostMana -= manaSpent;
manaSpent = vocation->getReqMana(magLevel);
magLevel--;
}
manaSpent -= std::max((int32_t)0, (int32_t)lostMana);
uint64_t nextReqMana = vocation->getReqMana(magLevel + 1);
if(nextReqMana > vocation->getReqMana(magLevel))
magLevelPercent = Player::getPercentLevel(manaSpent, nextReqMana);
else
magLevelPercent = 0;
//Skill loss
uint32_t lostSkillTries, sumSkillTries;
for(int16_t i = 0; i < 7; ++i) //for each skill
{
lostSkillTries = sumSkillTries = 0;
for(uint32_t c = 11; c <= skills[i][SKILL_LEVEL]; ++c) //sum up all required tries for all skill levels
sumSkillTries += vocation->getReqSkillTries(i, c);
sumSkillTries += skills[i][SKILL_TRIES];
lostSkillTries = (uint32_t)std::ceil(sumSkillTries * ((double)(percent * 5 * lossPercent[LOSS_SKILLS]) / 100.));
while(lostSkillTries > skills[i][SKILL_TRIES])
{
lostSkillTries -= skills[i][SKILL_TRIES];
skills[i][SKILL_TRIES] = vocation->getReqSkillTries(i, skills[i][SKILL_LEVEL]);
if(skills[i][SKILL_LEVEL] < 11)
{
skills[i][SKILL_LEVEL] = 10;
skills[i][SKILL_TRIES] = lostSkillTries = 0;
break;
}
else
skills[i][SKILL_LEVEL]--;
}
skills[i][SKILL_TRIES] = std::max((int32_t)0, (int32_t)(skills[i][SKILL_TRIES] - lostSkillTries));
}
blessings = 0;
loginPosition = masterPosition;
if(!inventory[SLOT_BACKPACK])
__internalAddThing(SLOT_BACKPACK, Item::CreateItem(g_config.getNumber(ConfigManager::DEATH_CONTAINER)));
sendIcons();
sendStats();
sendSkills();
g_creatureEvents->playerLogout(this, true);
g_game.removeCreature(this, false);
sendReLoginWindow();
}
else
{
setLossSkill(true);
if(preventLoss)
{
loginPosition = masterPosition;
g_creatureEvents->playerLogout(this, true);
g_game.removeCreature(this, false);
sendReLoginWindow();
}
}