summaryrefslogtreecommitdiff
path: root/src/map/clif.c
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-05-01 12:14:06 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-05-01 12:14:06 +0000
commit5524938f8650e659b3c838df44212de56bf72584 (patch)
tree9696c2ef858b4ebd81eda804389f8ece788a994b /src/map/clif.c
parent3bba210cc5151bfc2971be296ab5c4391ea28639 (diff)
downloadhercules-5524938f8650e659b3c838df44212de56bf72584.tar.gz
hercules-5524938f8650e659b3c838df44212de56bf72584.tar.bz2
hercules-5524938f8650e659b3c838df44212de56bf72584.tar.xz
hercules-5524938f8650e659b3c838df44212de56bf72584.zip
Implemented get_percentage() for compact and safe calculation of percentual values.
Fixed integer arithmetic overflows that were occuring in several supernovice checks (bugreport:1135). git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12679 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/clif.c')
-rw-r--r--src/map/clif.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index 30cc5b8ab..6d902f14d 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -7131,7 +7131,7 @@ int clif_charnameack (int fd, struct block_list *bl)
if (battle_config.show_mob_info&1)
str_p += sprintf(str_p, "HP: %u/%u | ", md->status.hp, md->status.max_hp);
if (battle_config.show_mob_info&2)
- str_p += sprintf(str_p, "HP: %d%% | ", status_calc_life(md->status.hp, md->status.max_hp));
+ str_p += sprintf(str_p, "HP: %d%% | ", percent(md->status.hp, md->status.max_hp));
//Even thought mobhp ain't a name, we send it as one so the client
//can parse it. [Skotlex]
if (str_p != mobhp) {
@@ -8182,8 +8182,10 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd)
// check for special supernovice phrase
if( (sd->class_&MAPID_UPPERMASK) == MAPID_SUPER_NOVICE )
{
- int next = pc_nextbaseexp(sd);
- if( next > 0 && (sd->status.base_exp * 1000 / next)% 100 == 0 ) { // 0%, 10%, 20%, ...
+ unsigned int next = pc_nextbaseexp(sd);
+ if( next == 0 ) next = pc_thisbaseexp(sd);
+ if( percent(sd->status.base_exp, next)% 10 == 0 ) // 0%, 10%, 20%, ...
+ {
switch (sd->state.snovice_call_flag) {
case 0:
if( strstr(message, msg_txt(504)) ) // "Guardian Angel, can you hear my voice? ^^;"