diff options
author | Chuck Miller <shadowmil@gmail.com> | 2009-10-09 01:22:29 -0400 |
---|---|---|
committer | Chuck Miller <shadowmil@gmail.com> | 2009-10-09 01:23:58 -0400 |
commit | b555dd7bcc5046e9809ef37d2173955d042594da (patch) | |
tree | 9488db7825dcc7cfc0fe455bb1fc59bd1ffb4827 /src | |
parent | 97886ba72ba8bf09d9d397b8a53d43cbf6764d61 (diff) | |
download | manaserv-b555dd7bcc5046e9809ef37d2173955d042594da.tar.gz manaserv-b555dd7bcc5046e9809ef37d2173955d042594da.tar.bz2 manaserv-b555dd7bcc5046e9809ef37d2173955d042594da.tar.xz manaserv-b555dd7bcc5046e9809ef37d2173955d042594da.zip |
Adds the option for a configuable hard cap on skill levels
To use, use the option "maxSkillCap", and set it to desired exp
Diffstat (limited to 'src')
-rw-r--r-- | src/game-server/character.cpp | 18 |
1 files 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)) |