diff options
Diffstat (limited to 'src/char/int_homun.c')
-rw-r--r-- | src/char/int_homun.c | 81 |
1 files changed, 41 insertions, 40 deletions
diff --git a/src/char/int_homun.c b/src/char/int_homun.c index 933661954..6e4f63849 100644 --- a/src/char/int_homun.c +++ b/src/char/int_homun.c @@ -1,5 +1,6 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. +// See the LICENSE file +// Portions Copyright (c) Athena Dev Teams #include "../common/mmo.h" #include "../common/malloc.h" @@ -88,11 +89,11 @@ bool mapif_homunculus_save(struct s_homunculus* hd) bool flag = true; char esc_name[NAME_LENGTH*2+1]; - Sql_EscapeStringLen(sql_handle, esc_name, hd->name, strnlen(hd->name, NAME_LENGTH)); + SQL->EscapeStringLen(sql_handle, esc_name, hd->name, strnlen(hd->name, NAME_LENGTH)); if( hd->hom_id == 0 ) {// new homunculus - if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` " + 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`) " "VALUES ('%d', '%d', '%d', '%s', '%d', '%u', '%u', '%d', '%d', %d, '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')", 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, @@ -103,12 +104,12 @@ bool mapif_homunculus_save(struct s_homunculus* hd) } else { - hd->hom_id = (int)Sql_LastInsertId(sql_handle); + hd->hom_id = (int)SQL->LastInsertId(sql_handle); } } 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`='%d',`max_hp`='%d',`sp`='%d',`max_sp`='%d',`skill_point`='%d', `rename_flag`='%d', `vaporize`='%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`='%u',`intimacy`='%u',`hunger`='%d', `str`='%d', `agi`='%d', `vit`='%d', `int`='%d', `dex`='%d', `luk`='%d', `hp`='%d',`max_hp`='%d',`sp`='%d',`max_sp`='%d',`skill_point`='%d', `rename_flag`='%d', `vaporize`='%d' WHERE `homun_id`='%d'", 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->hom_id) ) { @@ -156,61 +157,61 @@ bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd) memset(hd, 0, sizeof(*hd)); - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `homun_id`,`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` FROM `%s` WHERE `homun_id`='%u'", homunculus_db, homun_id) ) + if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `homun_id`,`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` FROM `%s` WHERE `homun_id`='%u'", homunculus_db, homun_id) ) { Sql_ShowDebug(sql_handle); return false; } - if( !Sql_NumRows(sql_handle) ) + if( !SQL->NumRows(sql_handle) ) { //No homunculus found. - Sql_FreeResult(sql_handle); + SQL->FreeResult(sql_handle); return false; } - if( SQL_SUCCESS != Sql_NextRow(sql_handle) ) + if( SQL_SUCCESS != SQL->NextRow(sql_handle) ) { Sql_ShowDebug(sql_handle); - Sql_FreeResult(sql_handle); + SQL->FreeResult(sql_handle); return false; } hd->hom_id = homun_id; - Sql_GetData(sql_handle, 1, &data, NULL); hd->char_id = atoi(data); - Sql_GetData(sql_handle, 2, &data, NULL); hd->class_ = atoi(data); - 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, 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); - Sql_GetData(sql_handle, 10, &data, NULL); hd->agi = atoi(data); - Sql_GetData(sql_handle, 11, &data, NULL); hd->vit = atoi(data); - Sql_GetData(sql_handle, 12, &data, NULL); hd->int_ = atoi(data); - Sql_GetData(sql_handle, 13, &data, NULL); hd->dex = atoi(data); - Sql_GetData(sql_handle, 14, &data, NULL); hd->luk = atoi(data); - Sql_GetData(sql_handle, 15, &data, NULL); hd->hp = atoi(data); - Sql_GetData(sql_handle, 16, &data, NULL); hd->max_hp = atoi(data); - Sql_GetData(sql_handle, 17, &data, NULL); hd->sp = atoi(data); - Sql_GetData(sql_handle, 18, &data, NULL); hd->max_sp = atoi(data); - Sql_GetData(sql_handle, 19, &data, NULL); hd->skillpts = atoi(data); - Sql_GetData(sql_handle, 20, &data, NULL); hd->rename_flag = atoi(data); - Sql_GetData(sql_handle, 21, &data, NULL); hd->vaporize = atoi(data); - Sql_FreeResult(sql_handle); + SQL->GetData(sql_handle, 1, &data, NULL); hd->char_id = atoi(data); + SQL->GetData(sql_handle, 2, &data, NULL); hd->class_ = atoi(data); + 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, 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); + SQL->GetData(sql_handle, 10, &data, NULL); hd->agi = atoi(data); + SQL->GetData(sql_handle, 11, &data, NULL); hd->vit = atoi(data); + SQL->GetData(sql_handle, 12, &data, NULL); hd->int_ = atoi(data); + SQL->GetData(sql_handle, 13, &data, NULL); hd->dex = atoi(data); + SQL->GetData(sql_handle, 14, &data, NULL); hd->luk = atoi(data); + SQL->GetData(sql_handle, 15, &data, NULL); hd->hp = atoi(data); + SQL->GetData(sql_handle, 16, &data, NULL); hd->max_hp = atoi(data); + SQL->GetData(sql_handle, 17, &data, NULL); hd->sp = atoi(data); + SQL->GetData(sql_handle, 18, &data, NULL); hd->max_sp = atoi(data); + SQL->GetData(sql_handle, 19, &data, NULL); hd->skillpts = atoi(data); + SQL->GetData(sql_handle, 20, &data, NULL); hd->rename_flag = atoi(data); + SQL->GetData(sql_handle, 21, &data, NULL); hd->vaporize = atoi(data); + SQL->FreeResult(sql_handle); hd->intimacy = cap_value(hd->intimacy, 0, 100000); hd->hunger = cap_value(hd->hunger, 0, 100); // Load Homunculus Skill - if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `id`,`lv` FROM `%s` WHERE `homun_id`=%d", skill_homunculus_db, homun_id) ) + if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `id`,`lv` FROM `%s` WHERE `homun_id`=%d", skill_homunculus_db, homun_id) ) { Sql_ShowDebug(sql_handle); return false; } - while( SQL_SUCCESS == Sql_NextRow(sql_handle) ) + while( SQL_SUCCESS == SQL->NextRow(sql_handle) ) { // id - Sql_GetData(sql_handle, 0, &data, NULL); + SQL->GetData(sql_handle, 0, &data, NULL); i = atoi(data); if( i < HM_SKILLBASE || i >= HM_SKILLBASE + MAX_HOMUNSKILL ) continue;// invalid skill id @@ -218,10 +219,10 @@ bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd) hd->hskill[i].id = (unsigned short)atoi(data); // lv - Sql_GetData(sql_handle, 1, &data, NULL); + SQL->GetData(sql_handle, 1, &data, NULL); hd->hskill[i].lv = (unsigned char)atoi(data); } - Sql_FreeResult(sql_handle); + SQL->FreeResult(sql_handle); if( save_log ) ShowInfo("Homunculus loaded (%d - %s).\n", hd->hom_id, hd->name); @@ -231,8 +232,8 @@ bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd) bool mapif_homunculus_delete(int homun_id) { - if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `homun_id` = '%u'", homunculus_db, homun_id) - || SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `homun_id` = '%u'", skill_homunculus_db, homun_id) + if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `homun_id` = '%u'", homunculus_db, homun_id) + || SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `homun_id` = '%u'", skill_homunculus_db, homun_id) ) { Sql_ShowDebug(sql_handle); return false; |