summaryrefslogtreecommitdiff
path: root/src/map/pc.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-02-09 14:21:41 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-02-09 14:21:41 +0000
commit173c3195ade5a6cdfe20c49e7f184a6b1336ca19 (patch)
treef85048abbba257b7418b8f379ed2b858088945d7 /src/map/pc.c
parent71ae3526c038b1aceb0400c6c798f2a69234087b (diff)
downloadhercules-173c3195ade5a6cdfe20c49e7f184a6b1336ca19.tar.gz
hercules-173c3195ade5a6cdfe20c49e7f184a6b1336ca19.tar.bz2
hercules-173c3195ade5a6cdfe20c49e7f184a6b1336ca19.tar.xz
hercules-173c3195ade5a6cdfe20c49e7f184a6b1336ca19.zip
- Code rewrites in mob_damage and party_exp_even_share for correctly handling overflow issues. Now uses UINT_MAX for range comparisons, as it should be.
- Also modified the mob_db reading to use UINT_MAX for exp limits, changed their exp/job exp fields to unsigned int as well. - Modified multi_level_up behaviour to work as specified by Kyoki. - removed functions pc_next[base/job]after as they are no longer needed. - Modified the skill attack display of Meteor Assault and the Warm Skills (I think the caster should no longer do fancy animations now on each hit) - Added back water elemental targets being inmune to SC_FREEZE - Fixed the status_change_start line in charsave.c (I knew I was forgetting something) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@5235 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/pc.c')
-rw-r--r--src/map/pc.c85
1 files changed, 36 insertions, 49 deletions
diff --git a/src/map/pc.c b/src/map/pc.c
index 09ed0d7f7..46fe462d8 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -6,6 +6,7 @@
#include <string.h>
#include <ctype.h>
#include <time.h>
+#include <limits.h>
#include "socket.h" // [Valaris]
#include "timer.h"
@@ -4597,11 +4598,13 @@ int pc_checkbaselevelup(struct map_session_data *sd)
nullpo_retr(0, sd);
if(sd->status.base_exp >= next && next > 0){
-
- // base側レベルアップ?理
sd->status.base_exp -= next;
+ //Kyoki pointed out that the max overcarry exp is the exp needed for the previous level -1. [Skotlex]
+ if(!battle_config.multi_level_up && sd->status.base_exp > next-1)
+ sd->status.base_exp = next-1;
sd->status.base_level ++;
+
if (battle_config.pet_lv_rate && sd->pd) //<Skotlex> update pet's level
status_calc_pet(sd,0);
if (battle_config.use_statpoint_table)
@@ -4653,9 +4656,13 @@ int pc_checkjoblevelup(struct map_session_data *sd)
nullpo_retr(0, sd);
if(sd->status.job_exp >= next && next > 0){
- // job側レベルアップ?理
sd->status.job_exp -= next;
+ //Kyoki pointed out that the max overcarry exp is the exp needed for the previous level -1. [Skotlex]
+ if(!battle_config.multi_level_up && sd->status.job_exp > next-1)
+ sd->status.job_exp = next-1;
+
sd->status.job_level ++;
+
clif_updatestatus(sd,SP_JOBLEVEL);
clif_updatestatus(sd,SP_NEXTJOBEXP);
sd->status.skill_point ++;
@@ -4663,7 +4670,7 @@ int pc_checkjoblevelup(struct map_session_data *sd)
status_calc_pc(sd,0);
clif_misceffect(&sd->bl,1);
- if (pc_checkskill(sd, SG_DEVIL) && !pc_nextjobafter(sd))
+ if (pc_checkskill(sd, SG_DEVIL) && !pc_nextjobexp(sd))
clif_status_change(&sd->bl,SI_DEVIL, 1); //Permanent blind effect from SG_DEVIL.
if (script_config.event_script_type == 0) {
@@ -4697,34 +4704,41 @@ int pc_gainexp(struct map_session_data *sd,unsigned int base_exp,unsigned int jo
if(sd->bl.prev == NULL || pc_isdead(sd))
return 0;
- if((battle_config.pvp_exp == 0) && map[sd->bl.m].flag.pvp) // [MouseJstr]
+ if(!battle_config.pvp_exp && map[sd->bl.m].flag.pvp) // [MouseJstr]
return 0; // no exp on pvp maps
if(sd->status.guild_id>0){ // ギルドに上納
base_exp-=guild_payexp(sd,base_exp);
}
- if(!battle_config.multi_level_up && pc_nextbaseafter(sd) && sd->status.base_exp+base_exp >= pc_nextbaseafter(sd)) {
- base_exp = pc_nextbaseafter(sd) - sd->status.base_exp;
+ if(sd->state.showexp){
+ nextb = pc_nextbaseexp(sd);
+ nextj = pc_nextjobexp(sd);
+ if (nextb > 0)
+ nextbp = (float) base_exp / (float) nextb;
+ if (nextj > 0)
+ nextjp = (float) job_exp / (float) nextj;
}
- nextb = pc_nextbaseexp(sd);
- nextj = pc_nextjobexp(sd);
- if (nextb > 0)
- nextbp = (float) base_exp / (float) nextb;
- if (nextj > 0)
- nextjp = (float) job_exp / (float) nextj;
-
- sd->status.base_exp += base_exp;
-
+
+ //Overflow checks... think we'll ever really need'em? [Skotlex]
+ if (base_exp > 0 && sd->status.base_exp > UINT_MAX - base_exp)
+ sd->status.base_exp = UINT_MAX;
+ else if (base_exp < 0 && sd->status.base_exp > base_exp)
+ sd->status.base_exp = 0;
+ else
+ sd->status.base_exp += base_exp;
+
while(pc_checkbaselevelup(sd)) ;
clif_updatestatus(sd,SP_BASEEXP);
- if(!battle_config.multi_level_up && pc_nextjobafter(sd) && sd->status.job_exp+job_exp >= pc_nextjobafter(sd)) {
- job_exp = pc_nextjobafter(sd) - sd->status.job_exp;
- }
-
- sd->status.job_exp += job_exp;
+ //Overflow checks... think we'll ever really need'em? [Skotlex]
+ if (job_exp > 0 && sd->status.job_exp > UINT_MAX - job_exp)
+ sd->status.job_exp = UINT_MAX;
+ else if (job_exp < 0 && sd->status.job_exp > job_exp)
+ sd->status.job_exp = 0;
+ else
+ sd->status.job_exp += job_exp;
while(pc_checkjoblevelup(sd)) ;
@@ -4780,33 +4794,6 @@ unsigned int pc_nextjobexp(struct map_session_data *sd)
}
/*==========================================
- * base level after next [Valaris]
- *------------------------------------------
- */
-unsigned int pc_nextbaseafter(struct map_session_data *sd)
-{
- nullpo_retr(0, sd);
-
- if(sd->status.base_level>=pc_maxbaselv(sd) || sd->status.base_level<=0)
- return 0;
-
- return exp_table[sd->status.class_][0][sd->status.base_level];
-}
-
-/*==========================================
- * job level after next [Valaris]
- *------------------------------------------
- */
-unsigned int pc_nextjobafter(struct map_session_data *sd)
-{
- nullpo_retr(0, sd);
-
- if(sd->status.job_level>=pc_maxjoblv(sd) || sd->status.job_level<=0)
- return 0;
-
- return exp_table[sd->status.class_][1][sd->status.job_level];
-}
-/*==========================================
* 必要ステ?タスポイント計算
*------------------------------------------
@@ -5208,7 +5195,7 @@ int pc_resetskill(struct map_session_data* sd)
int i, skill, inf2;
nullpo_retr(0, sd);
- if (pc_checkskill(sd, SG_DEVIL) && !pc_nextjobafter(sd))
+ if (pc_checkskill(sd, SG_DEVIL) && !pc_nextjobexp(sd))
clif_status_load(&sd->bl, SI_DEVIL, 0); //Remove perma blindness due to skill-reset. [Skotlex]
for (i = 1; i < MAX_SKILL; i++) {