From b555dd7bcc5046e9809ef37d2173955d042594da Mon Sep 17 00:00:00 2001 From: Chuck Miller Date: Fri, 9 Oct 2009 01:22:29 -0400 Subject: Adds the option for a configuable hard cap on skill levels To use, use the option "maxSkillCap", and set it to desired exp --- src/game-server/character.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/game-server/character.cpp b/src/game-server/character.cpp index f7366dc3..af1ccdb4 100644 --- a/src/game-server/character.cpp +++ b/src/game-server/character.cpp @@ -468,14 +468,26 @@ void Character::receiveExperience(int skill, int experience) // add exp int oldExp = mExperience[skill]; long int newExp = mExperience[skill] + experience; - if (newExp > INT_MAX) newExp = INT_MAX; // avoid integer overflow. if (newExp < 0) newExp = 0; // avoid integer underflow/negative exp + + // Check the skill cap + long int maxSkillCap = Configuration::getValue("maxSkillCap", INT_MAX); + assert(maxSkillCap <= INT_MAX); // avoid interger overflow + if (newExp > maxSkillCap) + { + newExp = maxSkillCap; + if (oldExp != maxSkillCap) + { + LOG_INFO("Player hit the skill cap"); + // TODO: send a message to player leting them know they hit the cap + } + } mExperience[skill] = newExp; mModifiedExperience.insert(skill); // inform account server - accountHandler->updateExperience(getDatabaseID(), - skill, newExp); + if (newExp != oldExp) + accountHandler->updateExperience(getDatabaseID(), skill, newExp); // check for skill levelup if (Character::levelForExp(newExp) >= Character::levelForExp(oldExp)) -- cgit v1.2.3-70-g09d2