From 735e2e8340c9522ee5a9afdcad29d191da29c8d4 Mon Sep 17 00:00:00 2001 From: Haru Date: Sun, 24 Jun 2018 20:30:19 +0200 Subject: Move some non-mapif functionality from the mapif interface to the inter_homunculus interface Signed-off-by: Haru --- src/char/char.c | 2 +- src/char/int_homun.c | 26 ++++++++++++++++---------- src/char/int_homun.h | 7 +++++++ src/char/mapif.c | 10 ---------- src/char/mapif.h | 5 ----- 5 files changed, 24 insertions(+), 26 deletions(-) diff --git a/src/char/char.c b/src/char/char.c index 2c9c73dd7..3f55bd699 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -1811,7 +1811,7 @@ int char_delete_char_sql(int char_id) /* remove homunculus */ if( hom_id ) - mapif->homunculus_delete(hom_id); + inter_homunculus->delete(hom_id); /* remove elemental */ if (elemental_id) diff --git a/src/char/int_homun.c b/src/char/int_homun.c index 1844c8182..b692ac971 100644 --- a/src/char/int_homun.c +++ b/src/char/int_homun.c @@ -119,7 +119,7 @@ void mapif_homunculus_renamed(int fd, int account_id, int char_id, unsigned char * @param[in,out] hd The new homunculus' data. * @retval false in case of errors. */ -bool mapif_homunculus_create(struct s_homunculus *hd) +bool inter_homunculus_create(struct s_homunculus *hd) { char esc_name[NAME_LENGTH*2+1]; @@ -146,7 +146,7 @@ bool mapif_homunculus_create(struct s_homunculus *hd) * @param hd The homunculus' data. * @retval false in case of errors. */ -bool mapif_homunculus_save(const struct s_homunculus *hd) +bool inter_homunculus_save(const struct s_homunculus *hd) { bool flag = true; char esc_name[NAME_LENGTH*2+1]; @@ -188,7 +188,7 @@ bool mapif_homunculus_save(const struct s_homunculus *hd) } // Load an homunculus -bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd) +bool inter_homunculus_load(int homun_id, struct s_homunculus* hd) { char* data; size_t len; @@ -269,7 +269,7 @@ bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd) return true; } -bool mapif_homunculus_delete(int homun_id) +bool inter_homunculus_delete(int homun_id) { if (SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `homun_id` = '%d'", homunculus_db, homun_id) || SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `homun_id` = '%d'", skill_homunculus_db, homun_id) @@ -280,7 +280,7 @@ bool mapif_homunculus_delete(int homun_id) return true; } -bool mapif_homunculus_rename(const char *name) +bool inter_homunculus_rename(const char *name) { int i; @@ -310,32 +310,32 @@ void mapif_parse_homunculus_create(int fd, int len, int account_id, const struct memcpy(&shd, phd, sizeof(shd)); - result = mapif->homunculus_create(&shd); + result = inter_homunculus->create(&shd); mapif->homunculus_created(fd, account_id, &shd, result); } void mapif_parse_homunculus_delete(int fd, int homun_id) { - bool result = mapif->homunculus_delete(homun_id); + bool result = inter_homunculus->delete(homun_id); mapif->homunculus_deleted(fd, result); } void mapif_parse_homunculus_load(int fd, int account_id, int homun_id) { struct s_homunculus hd; - bool result = mapif->homunculus_load(homun_id, &hd); + bool result = inter_homunculus->load(homun_id, &hd); mapif->homunculus_loaded(fd, account_id, ( result ? &hd : NULL )); } void mapif_parse_homunculus_save(int fd, int len, int account_id, const struct s_homunculus *phd) { - bool result = mapif->homunculus_save(phd); + bool result = inter_homunculus->save(phd); mapif->homunculus_saved(fd, account_id, result); } void mapif_parse_homunculus_rename(int fd, int account_id, int char_id, const char *name) { - bool result = mapif->homunculus_rename(name); + bool result = inter_homunculus->rename(name); mapif->homunculus_renamed(fd, account_id, char_id, result, name); } @@ -365,4 +365,10 @@ void inter_homunculus_defaults(void) inter_homunculus->sql_init = inter_homunculus_sql_init; inter_homunculus->sql_final = inter_homunculus_sql_final; inter_homunculus->parse_frommap = inter_homunculus_parse_frommap; + + inter_homunculus->create = inter_homunculus_create; + inter_homunculus->save = inter_homunculus_save; + inter_homunculus->load = inter_homunculus_load; + inter_homunculus->delete = inter_homunculus_delete; + inter_homunculus->rename = inter_homunculus_rename; } diff --git a/src/char/int_homun.h b/src/char/int_homun.h index fbd9d0eb9..8eba66963 100644 --- a/src/char/int_homun.h +++ b/src/char/int_homun.h @@ -22,6 +22,7 @@ #define CHAR_INT_HOMUN_H #include "common/hercules.h" +#include "common/mmo.h" /** * inter_homunculus interface @@ -30,6 +31,12 @@ struct inter_homunculus_interface { int (*sql_init) (void); void (*sql_final) (void); int (*parse_frommap) (int fd); + + bool (*create) (struct s_homunculus *hd); + bool (*save) (const struct s_homunculus *hd); + bool (*load) (int homun_id, struct s_homunculus* hd); + bool (*delete) (int homun_id); + bool (*rename) (const char *name); }; #ifdef HERCULES_CORE diff --git a/src/char/mapif.c b/src/char/mapif.c index 9e6efd4c2..90386362d 100644 --- a/src/char/mapif.c +++ b/src/char/mapif.c @@ -885,11 +885,6 @@ void mapif_homunculus_deleted(int fd, int flag); void mapif_homunculus_loaded(int fd, int account_id, struct s_homunculus *hd); void mapif_homunculus_saved(int fd, int account_id, bool flag); void mapif_homunculus_renamed(int fd, int account_id, int char_id, unsigned char flag, const char *name); -bool mapif_homunculus_create(struct s_homunculus *hd); -bool mapif_homunculus_save(const struct s_homunculus *hd); -bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd); -bool mapif_homunculus_delete(int homun_id); -bool mapif_homunculus_rename(const char *name); void mapif_parse_homunculus_create(int fd, int len, int account_id, const struct s_homunculus *phd); void mapif_parse_homunculus_delete(int fd, int homun_id); void mapif_parse_homunculus_load(int fd, int account_id, int homun_id); @@ -1098,11 +1093,6 @@ void mapif_defaults(void) { mapif->homunculus_loaded = mapif_homunculus_loaded; mapif->homunculus_saved = mapif_homunculus_saved; mapif->homunculus_renamed = mapif_homunculus_renamed; - mapif->homunculus_create = mapif_homunculus_create; - mapif->homunculus_save = mapif_homunculus_save; - mapif->homunculus_load = mapif_homunculus_load; - mapif->homunculus_delete = mapif_homunculus_delete; - mapif->homunculus_rename = mapif_homunculus_rename; mapif->parse_homunculus_create = mapif_parse_homunculus_create; mapif->parse_homunculus_delete = mapif_parse_homunculus_delete; mapif->parse_homunculus_load = mapif_parse_homunculus_load; diff --git a/src/char/mapif.h b/src/char/mapif.h index 4f32d8a62..364870567 100644 --- a/src/char/mapif.h +++ b/src/char/mapif.h @@ -97,11 +97,6 @@ struct mapif_interface { void (*homunculus_loaded) (int fd, int account_id, struct s_homunculus *hd); void (*homunculus_saved) (int fd, int account_id, bool flag); void (*homunculus_renamed) (int fd, int account_id, int char_id, unsigned char flag, const char *name); - bool (*homunculus_create) (struct s_homunculus *hd); - bool (*homunculus_save) (const struct s_homunculus *hd); - bool (*homunculus_load) (int homun_id, struct s_homunculus* hd); - bool (*homunculus_delete) (int homun_id); - bool (*homunculus_rename) (const char *name); void (*parse_homunculus_create) (int fd, int len, int account_id, const struct s_homunculus *phd); void (*parse_homunculus_delete) (int fd, int homun_id); void (*parse_homunculus_load) (int fd, int account_id, int homun_id); -- cgit v1.2.3-70-g09d2