From 9f87653e3a137197f0efe40c97b99e618bf8bb7f Mon Sep 17 00:00:00 2001 From: Lemongrass3110 Date: Tue, 26 Jan 2021 15:25:43 +0100 Subject: [PATCH] Fixed homcunulus exp definitions (#5711) Follow up to f57b037 Thanks to @JinYuichi and @RagnaWay --- src/char/int_homun.cpp | 6 +++--- src/common/mmo.hpp | 2 +- src/map/clif.cpp | 4 ++-- src/map/homunculus.cpp | 9 ++++----- src/map/homunculus.hpp | 4 ++-- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/char/int_homun.cpp b/src/char/int_homun.cpp index 2d24e13766..a5a3b87bdb 100644 --- a/src/char/int_homun.cpp +++ b/src/char/int_homun.cpp @@ -94,7 +94,7 @@ bool mapif_homunculus_save(struct s_homunculus* hd) {// new homunculus if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` " "(`char_id`, `class`,`prev_class`,`name`,`level`,`exp`,`intimacy`,`hunger`, `str`, `agi`, `vit`, `int`, `dex`, `luk`, `hp`,`max_hp`,`sp`,`max_sp`,`skill_point`, `rename_flag`, `vaporize`, `autofeed`) " - "VALUES ('%d', '%d', '%d', '%s', '%d', '%u', '%u', '%d', '%d', %d, '%d', '%d', '%d', '%d', '%u', '%u', '%u', '%u', '%d', '%d', '%d', '%d')", + "VALUES ('%d', '%d', '%d', '%s', '%d', '%" PRIu64 "', '%u', '%d', '%d', %d, '%d', '%d', '%d', '%d', '%u', '%u', '%u', '%u', '%d', '%d', '%d', '%d')", schema_config.homunculus_db, hd->char_id, hd->class_, hd->prev_class, esc_name, hd->level, hd->exp, hd->intimacy, hd->hunger, hd->str, hd->agi, hd->vit, hd->int_, hd->dex, hd->luk, hd->hp, hd->max_hp, hd->sp, hd->max_sp, hd->skillpts, hd->rename_flag, hd->vaporize, hd->autofeed) ) { @@ -108,7 +108,7 @@ bool mapif_homunculus_save(struct s_homunculus* hd) } else { - if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `char_id`='%d', `class`='%d',`prev_class`='%d',`name`='%s',`level`='%d',`exp`='%u',`intimacy`='%u',`hunger`='%d', `str`='%d', `agi`='%d', `vit`='%d', `int`='%d', `dex`='%d', `luk`='%d', `hp`='%u',`max_hp`='%u',`sp`='%u',`max_sp`='%u',`skill_point`='%d', `rename_flag`='%d', `vaporize`='%d', `autofeed`='%d' WHERE `homun_id`='%d'", + if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `char_id`='%d', `class`='%d',`prev_class`='%d',`name`='%s',`level`='%d',`exp`='%" PRIu64 "',`intimacy`='%u',`hunger`='%d', `str`='%d', `agi`='%d', `vit`='%d', `int`='%d', `dex`='%d', `luk`='%d', `hp`='%u',`max_hp`='%u',`sp`='%u',`max_sp`='%u',`skill_point`='%d', `rename_flag`='%d', `vaporize`='%d', `autofeed`='%d' WHERE `homun_id`='%d'", schema_config.homunculus_db, hd->char_id, hd->class_, hd->prev_class, esc_name, hd->level, hd->exp, hd->intimacy, hd->hunger, hd->str, hd->agi, hd->vit, hd->int_, hd->dex, hd->luk, hd->hp, hd->max_hp, hd->sp, hd->max_sp, hd->skillpts, hd->rename_flag, hd->vaporize, hd->autofeed, hd->hom_id) ) { @@ -180,7 +180,7 @@ bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd) Sql_GetData(sql_handle, 3, &data, NULL); hd->prev_class = atoi(data); Sql_GetData(sql_handle, 4, &data, &len); safestrncpy(hd->name, data, sizeof(hd->name)); Sql_GetData(sql_handle, 5, &data, NULL); hd->level = atoi(data); - Sql_GetData(sql_handle, 6, &data, NULL); hd->exp = atoi(data); + Sql_GetData(sql_handle, 6, &data, NULL); hd->exp = strtoull( data, nullptr, 10 ); Sql_GetData(sql_handle, 7, &data, NULL); hd->intimacy = (unsigned int)strtoul(data, NULL, 10); Sql_GetData(sql_handle, 8, &data, NULL); hd->hunger = atoi(data); Sql_GetData(sql_handle, 9, &data, NULL); hd->str = atoi(data); diff --git a/src/common/mmo.hpp b/src/common/mmo.hpp index e688eafc3f..04f2d0daef 100644 --- a/src/common/mmo.hpp +++ b/src/common/mmo.hpp @@ -438,7 +438,7 @@ struct s_homunculus { //[orn] struct s_skill hskill[MAX_HOMUNSKILL]; //albator short skillpts; short level; - unsigned int exp; + t_exp exp; short rename_flag; short vaporize; //albator int str; diff --git a/src/map/clif.cpp b/src/map/clif.cpp index ce71b07328..d6d8fa8849 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -1734,8 +1734,8 @@ void clif_hominfo( struct map_session_data *sd, struct homun_data *hd, int flag p.sp = status->sp; p.maxSp = status->max_sp; } - p.exp = hd->homunculus.exp; - p.expNext = hd->exp_next; + p.exp = (uint32)hd->homunculus.exp; + p.expNext = (uint32)hd->exp_next; switch( hom_class2type( hd->homunculus.class_ ) ){ case HT_REG: case HT_EVO: diff --git a/src/map/homunculus.cpp b/src/map/homunculus.cpp index 604c2bf72a..ee43f9ba0e 100644 --- a/src/map/homunculus.cpp +++ b/src/map/homunculus.cpp @@ -30,7 +30,7 @@ struct homun_skill_tree_entry hskill_tree[MAX_HOMUNCULUS_CLASS][MAX_HOM_SKILL_TR static TIMER_FUNC(hom_hungry); static uint16 homunculus_count; -static unsigned int hexptbl[MAX_LEVEL]; +static t_exp hexptbl[MAX_LEVEL]; //For holding the view data of npc classes. [Skotlex] static struct view_data hom_viewdb[MAX_HOMUNCULUS_CLASS]; @@ -669,7 +669,7 @@ int hom_mutate(struct homun_data *hd, int homun_id) * @param hd * @param exp Added EXP */ -void hom_gainexp(struct homun_data *hd,int exp) +void hom_gainexp(struct homun_data *hd,t_exp exp) { int m_class; @@ -1311,7 +1311,6 @@ int hom_shuffle(struct homun_data *hd) { struct map_session_data *sd; int lv, i, skillpts; - unsigned int exp; struct s_skill b_skill[MAX_HOMUNSKILL]; if (!hom_is_active(hd)) @@ -1319,7 +1318,7 @@ int hom_shuffle(struct homun_data *hd) sd = hd->master; lv = hd->homunculus.level; - exp = hd->homunculus.exp; + t_exp exp = hd->homunculus.exp; memcpy(&b_skill, &hd->homunculus.hskill, sizeof(b_skill)); skillpts = hd->homunculus.skillpts; //Reset values to level 1. @@ -1619,7 +1618,7 @@ void read_homunculus_expdb(void) if (line[0] == '/' && line[1] == '/') continue; - hexptbl[j] = strtoul(line, NULL, 10); + hexptbl[j] = strtoull(line, NULL, 10); if (!hexptbl[j++]) break; } diff --git a/src/map/homunculus.hpp b/src/map/homunculus.hpp index 2a82fa429d..e9732eb80b 100644 --- a/src/map/homunculus.hpp +++ b/src/map/homunculus.hpp @@ -65,7 +65,7 @@ struct homun_data { int masterteleport_timer; struct map_session_data *master; //pointer back to its master int hungry_timer; //[orn] - unsigned int exp_next; + t_exp exp_next; std::vector blockskill; // [orn] }; @@ -153,7 +153,7 @@ void hom_skillup(struct homun_data *hd,uint16 skill_id); void hom_calc_skilltree(struct homun_data *hd, bool flag_evolve); short hom_checkskill(struct homun_data *hd,uint16 skill_id); uint8 hom_skill_get_min_level(int class_, uint16 skill_id); -void hom_gainexp(struct homun_data *hd,int exp); +void hom_gainexp(struct homun_data *hd,t_exp exp); int hom_levelup(struct homun_data *hd); int hom_evolution(struct homun_data *hd); int hom_mutate(struct homun_data *hd,int homun_id);