Browse Source

Prevented pc_skill with a value of 2 for 'flag' from granting a skill level that surpasses MAX_SKILL_LEVEL. (bugreport:4022)

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@14225 54d463be-8e91-2dee-dedb-b68131a5f0ec
Paradox924X 15 years ago
parent
commit
edc07c36d0
2 changed files with 16 additions and 10 deletions
  1. 2 0
      Changelog-Trunk.txt
  2. 14 10
      src/map/pc.c

+ 2 - 0
Changelog-Trunk.txt

@@ -3,6 +3,8 @@ Date	Added
 AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
 AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 
 
+2010/01/23
+	* Prevented pc_skill with a value of 2 for 'flag' from granting a skill level that surpasses MAX_SKILL_LEVEL. (bugreport:4022) [Paradox924X]
 2010/01/19
 2010/01/19
 	* Snatch should warp you anyway even if the target died. [Inkfish]
 	* Snatch should warp you anyway even if the target died. [Inkfish]
 	* Snatch now checks the distance between source and target in case it kills the target and then warps the respawned one. [Inkfish]
 	* Snatch now checks the distance between source and target in case it kills the target and then warps the respawned one. [Inkfish]

+ 14 - 10
src/map/pc.c

@@ -2954,6 +2954,10 @@ int pc_skill(TBL_PC* sd, int id, int level, int flag)
 		ShowError("pc_skill: Skill level %d too high. Max lv supported is %d\n", level, MAX_SKILL_LEVEL);
 		ShowError("pc_skill: Skill level %d too high. Max lv supported is %d\n", level, MAX_SKILL_LEVEL);
 		return 0;
 		return 0;
 	}
 	}
+	if( flag == 2 && sd->status.skill[id].lv + level > MAX_SKILL_LEVEL ) {
+		ShowError("pc_skill: Skill level bonus %d too high. Max lv supported is %d. Curr lv is %d\n", level, MAX_SKILL_LEVEL, sd->status.skill[id].lv);
+		return 0;
+	}
 
 
 	switch( flag ){
 	switch( flag ){
 	case 0: //Set skill data overwriting whatever was there before.
 	case 0: //Set skill data overwriting whatever was there before.
@@ -2970,16 +2974,6 @@ int pc_skill(TBL_PC* sd, int id, int level, int flag)
 		if( !skill_get_inf(id) ) //Only recalculate for passive skills.
 		if( !skill_get_inf(id) ) //Only recalculate for passive skills.
 			status_calc_pc(sd, 0);
 			status_calc_pc(sd, 0);
 	break;
 	break;
-	case 2: //Add skill bonus on top of what you had.
-		if( sd->status.skill[id].id == id ){
-			if( !sd->status.skill[id].flag ) // Store previous level.
-				sd->status.skill[id].flag = sd->status.skill[id].lv + 2;
-		} else {
-			sd->status.skill[id].id   = id;
-			sd->status.skill[id].flag = 1; //Set that this is a bonus skill.
-		}
-		sd->status.skill[id].lv += level;
-	break;
 	case 1: //Item bonus skill.
 	case 1: //Item bonus skill.
 		if( sd->status.skill[id].id == id ){
 		if( sd->status.skill[id].id == id ){
 			if( sd->status.skill[id].lv >= level )
 			if( sd->status.skill[id].lv >= level )
@@ -2992,6 +2986,16 @@ int pc_skill(TBL_PC* sd, int id, int level, int flag)
 		}
 		}
 		sd->status.skill[id].lv = level;
 		sd->status.skill[id].lv = level;
 	break;
 	break;
+	case 2: //Add skill bonus on top of what you had.
+		if( sd->status.skill[id].id == id ){
+			if( !sd->status.skill[id].flag ) // Store previous level.
+				sd->status.skill[id].flag = sd->status.skill[id].lv + 2;
+		} else {
+			sd->status.skill[id].id   = id;
+			sd->status.skill[id].flag = 1; //Set that this is a bonus skill.
+		}
+		sd->status.skill[id].lv += level;
+	break;
 	default: //Unknown flag?
 	default: //Unknown flag?
 		return 0;
 		return 0;
 	}
 	}