summaryrefslogtreecommitdiff
path: root/src/char/int_homun.c
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2015-01-20 04:36:08 +0100
committerHaru <haru@dotalux.com>2015-01-20 04:41:33 +0100
commit4ae2b9b72dd4fce3d7a7778222d1c39abbb564a4 (patch)
treedab9d12a6a4b95a37598e27e6e86d6047360d61b /src/char/int_homun.c
parent03709c136ad300be631adfd38dc36c2433bda718 (diff)
downloadhercules-4ae2b9b72dd4fce3d7a7778222d1c39abbb564a4.tar.gz
hercules-4ae2b9b72dd4fce3d7a7778222d1c39abbb564a4.tar.bz2
hercules-4ae2b9b72dd4fce3d7a7778222d1c39abbb564a4.tar.xz
hercules-4ae2b9b72dd4fce3d7a7778222d1c39abbb564a4.zip
Minor fixes and tweaks suggested by cppcheck
- Variable scopes reduced - Parenthesized ambiguous expressions - Removed or added NULL checks where (un)necessary - Corrected format strings - Fixed typos potentially leading to bugs Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/char/int_homun.c')
-rw-r--r--src/char/int_homun.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/char/int_homun.c b/src/char/int_homun.c
index 7f9323bdd..dd23261c2 100644
--- a/src/char/int_homun.c
+++ b/src/char/int_homun.c
@@ -155,7 +155,6 @@ bool mapif_homunculus_save(struct s_homunculus* hd)
// Load an homunculus
bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd)
{
- int i;
char* data;
size_t len;
@@ -207,24 +206,23 @@ bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd)
hd->hunger = cap_value(hd->hunger, 0, 100);
// Load Homunculus Skill
- if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `id`,`lv` FROM `%s` WHERE `homun_id`=%d", skill_homunculus_db, homun_id) )
- {
+ if (SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `id`,`lv` FROM `%s` WHERE `homun_id`=%d", skill_homunculus_db, homun_id)) {
Sql_ShowDebug(inter->sql_handle);
return false;
}
- while( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) )
- {
+ while (SQL_SUCCESS == SQL->NextRow(inter->sql_handle)) {
+ int idx;
// id
SQL->GetData(inter->sql_handle, 0, &data, NULL);
- i = atoi(data);
- if( i < HM_SKILLBASE || i >= HM_SKILLBASE + MAX_HOMUNSKILL )
+ idx = atoi(data);
+ if (idx < HM_SKILLBASE || idx >= HM_SKILLBASE + MAX_HOMUNSKILL)
continue;// invalid skill id
- i = i - HM_SKILLBASE;
- hd->hskill[i].id = (unsigned short)atoi(data);
+ idx -= HM_SKILLBASE;
+ hd->hskill[idx].id = (unsigned short)atoi(data);
// lv
SQL->GetData(inter->sql_handle, 1, &data, NULL);
- hd->hskill[i].lv = (unsigned char)atoi(data);
+ hd->hskill[idx].lv = (unsigned char)atoi(data);
}
SQL->FreeResult(inter->sql_handle);