diff options
-rw-r--r-- | src/char/char.c | 7 | ||||
-rw-r--r-- | src/char/int_mercenary.c | 54 | ||||
-rw-r--r-- | src/char/int_mercenary.h | 18 | ||||
-rw-r--r-- | src/char/inter.c | 6 | ||||
-rw-r--r-- | src/char/mapif.c | 20 | ||||
-rw-r--r-- | src/char/mapif.h | 11 |
6 files changed, 83 insertions, 33 deletions
diff --git a/src/char/char.c b/src/char/char.c index 82a3fade9..8ade532f2 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -546,7 +546,7 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p) (p->spear_calls != cp->spear_calls) || (p->spear_faith != cp->spear_faith) || (p->sword_calls != cp->sword_calls) || (p->sword_faith != cp->sword_faith) ) { - if (inter_mercenary_owner_tosql(char_id, p)) + if (inter_mercenary->owner_tosql(char_id, p)) strcat(save_status, " mercenary"); else errors++; @@ -1396,7 +1396,7 @@ int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_every #endif /* Mercenary Owner DataBase */ - inter_mercenary_owner_fromsql(char_id, p); + inter_mercenary->owner_fromsql(char_id, p); strcat(t_msg, " mercenary"); /* default */ @@ -1821,7 +1821,7 @@ int char_delete_char_sql(int char_id) mapif->elemental_delete(elemental_id); /* remove mercenary data */ - inter_mercenary_owner_delete(char_id); + inter_mercenary->owner_delete(char_id); /* delete char's friends list */ if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d'", friend_db, char_id) ) @@ -6011,6 +6011,7 @@ void char_load_defaults(void) inter_guild_defaults(); inter_homunculus_defaults(); inter_mail_defaults(); + inter_mercenary_defaults(); } void char_defaults(void) diff --git a/src/char/int_mercenary.c b/src/char/int_mercenary.c index ff7f9fa1f..3fd01b3f6 100644 --- a/src/char/int_mercenary.c +++ b/src/char/int_mercenary.c @@ -12,6 +12,7 @@ #include "char.h" #include "inter.h" +#include "mapif.h" #include "../common/malloc.h" #include "../common/mmo.h" #include "../common/showmsg.h" @@ -20,6 +21,8 @@ #include "../common/strlib.h" #include "../common/utils.h" +struct inter_mercenary_interface inter_mercenary_s; + bool inter_mercenary_owner_fromsql(int char_id, struct mmo_charstatus *status) { char* data; @@ -141,7 +144,7 @@ bool mapif_mercenary_delete(int merc_id) return true; } -static void mapif_mercenary_send(int fd, struct s_mercenary *merc, unsigned char flag) +void mapif_mercenary_send(int fd, struct s_mercenary *merc, unsigned char flag) { int size = sizeof(struct s_mercenary) + 5; @@ -153,20 +156,20 @@ static void mapif_mercenary_send(int fd, struct s_mercenary *merc, unsigned char WFIFOSET(fd,size); } -static void mapif_parse_mercenary_create(int fd, struct s_mercenary* merc) +void mapif_parse_mercenary_create(int fd, struct s_mercenary* merc) { - bool result = mapif_mercenary_save(merc); - mapif_mercenary_send(fd, merc, result); + bool result = mapif->mercenary_save(merc); + mapif->mercenary_send(fd, merc, result); } -static void mapif_parse_mercenary_load(int fd, int merc_id, int char_id) +void mapif_parse_mercenary_load(int fd, int merc_id, int char_id) { struct s_mercenary merc; - bool result = mapif_mercenary_load(merc_id, char_id, &merc); - mapif_mercenary_send(fd, &merc, result); + bool result = mapif->mercenary_load(merc_id, char_id, &merc); + mapif->mercenary_send(fd, &merc, result); } -static void mapif_mercenary_deleted(int fd, unsigned char flag) +void mapif_mercenary_deleted(int fd, unsigned char flag) { WFIFOHEAD(fd,3); WFIFOW(fd,0) = 0x3871; @@ -174,13 +177,13 @@ static void mapif_mercenary_deleted(int fd, unsigned char flag) WFIFOSET(fd,3); } -static void mapif_parse_mercenary_delete(int fd, int merc_id) +void mapif_parse_mercenary_delete(int fd, int merc_id) { - bool result = mapif_mercenary_delete(merc_id); - mapif_mercenary_deleted(fd, result); + bool result = mapif->mercenary_delete(merc_id); + mapif->mercenary_deleted(fd, result); } -static void mapif_mercenary_saved(int fd, unsigned char flag) +void mapif_mercenary_saved(int fd, unsigned char flag) { WFIFOHEAD(fd,3); WFIFOW(fd,0) = 0x3872; @@ -188,10 +191,10 @@ static void mapif_mercenary_saved(int fd, unsigned char flag) WFIFOSET(fd,3); } -static void mapif_parse_mercenary_save(int fd, struct s_mercenary* merc) +void mapif_parse_mercenary_save(int fd, struct s_mercenary* merc) { - bool result = mapif_mercenary_save(merc); - mapif_mercenary_saved(fd, result); + bool result = mapif->mercenary_save(merc); + mapif->mercenary_saved(fd, result); } int inter_mercenary_sql_init(void) @@ -212,12 +215,25 @@ int inter_mercenary_parse_frommap(int fd) switch( cmd ) { - case 0x3070: mapif_parse_mercenary_create(fd, (struct s_mercenary*)RFIFOP(fd,4)); break; - case 0x3071: mapif_parse_mercenary_load(fd, (int)RFIFOL(fd,2), (int)RFIFOL(fd,6)); break; - case 0x3072: mapif_parse_mercenary_delete(fd, (int)RFIFOL(fd,2)); break; - case 0x3073: mapif_parse_mercenary_save(fd, (struct s_mercenary*)RFIFOP(fd,4)); break; + case 0x3070: mapif->parse_mercenary_create(fd, (struct s_mercenary*)RFIFOP(fd,4)); break; + case 0x3071: mapif->parse_mercenary_load(fd, (int)RFIFOL(fd,2), (int)RFIFOL(fd,6)); break; + case 0x3072: mapif->parse_mercenary_delete(fd, (int)RFIFOL(fd,2)); break; + case 0x3073: mapif->parse_mercenary_save(fd, (struct s_mercenary*)RFIFOP(fd,4)); break; default: return 0; } return 1; } + +void inter_mercenary_defaults(void) +{ + inter_mercenary = &inter_mercenary_s; + + inter_mercenary->owner_fromsql = inter_mercenary_owner_fromsql; + inter_mercenary->owner_tosql = inter_mercenary_owner_tosql; + inter_mercenary->owner_delete = inter_mercenary_owner_delete; + + inter_mercenary->sql_init = inter_mercenary_sql_init; + inter_mercenary->sql_final = inter_mercenary_sql_final; + inter_mercenary->parse_frommap = inter_mercenary_parse_frommap; +} diff --git a/src/char/int_mercenary.h b/src/char/int_mercenary.h index 504b2fca6..1d84a931a 100644 --- a/src/char/int_mercenary.h +++ b/src/char/int_mercenary.h @@ -8,15 +8,17 @@ struct mmo_charstatus; -int inter_mercenary_sql_init(void); -void inter_mercenary_sql_final(void); -int inter_mercenary_parse_frommap(int fd); +void inter_mercenary_defaults(void); -// Mercenary Owner Database -bool inter_mercenary_owner_fromsql(int char_id, struct mmo_charstatus *status); -bool inter_mercenary_owner_tosql(int char_id, struct mmo_charstatus *status); -bool inter_mercenary_owner_delete(int char_id); +struct inter_mercenary_interface { + bool (*owner_fromsql) (int char_id, struct mmo_charstatus *status); + bool (*owner_tosql) (int char_id, struct mmo_charstatus *status); + bool (*owner_delete) (int char_id); + int (*sql_init) (void); + void (*sql_final) (void); + int (*parse_frommap) (int fd); +}; -bool mapif_mercenary_delete(int merc_id); +struct inter_mercenary_interface *inter_mercenary; #endif /* CHAR_INT_MERCENARY_H */ diff --git a/src/char/inter.c b/src/char/inter.c index 3f770efa4..869d6928a 100644 --- a/src/char/inter.c +++ b/src/char/inter.c @@ -1031,7 +1031,7 @@ int inter_init_sql(const char *file) inter_party_sql_init(); inter_pet_sql_init(); inter_homunculus->sql_init(); - inter_mercenary_sql_init(); + inter_mercenary->sql_init(); inter_elemental->sql_init(); inter_mail->sql_init(); inter_auction->sql_init(); @@ -1051,7 +1051,7 @@ void inter_final(void) inter_party_sql_final(); inter_pet_sql_final(); inter_homunculus->sql_final(); - inter_mercenary_sql_final(); + inter_mercenary->sql_final(); inter_elemental->sql_final(); inter_mail->sql_final(); inter_auction->sql_final(); @@ -1458,7 +1458,7 @@ int inter_parse_frommap(int fd) || inter_storage_parse_frommap(fd) || inter_pet_parse_frommap(fd) || inter_homunculus->parse_frommap(fd) - || inter_mercenary_parse_frommap(fd) + || inter_mercenary->parse_frommap(fd) || inter_elemental->parse_frommap(fd) || inter_mail->parse_frommap(fd) || inter_auction->parse_frommap(fd) diff --git a/src/char/mapif.c b/src/char/mapif.c index 58b47a6e4..5c53564f7 100644 --- a/src/char/mapif.c +++ b/src/char/mapif.c @@ -113,6 +113,16 @@ void mapif_mail_return(int fd, int char_id, int mail_id, int new_mail); void mapif_parse_mail_return(int fd); void mapif_mail_send(int fd, struct mail_message* msg); void mapif_parse_mail_send(int fd); +bool mapif_mercenary_save(struct s_mercenary* merc); +bool mapif_mercenary_load(int merc_id, int char_id, struct s_mercenary *merc); +bool mapif_mercenary_delete(int merc_id); +void mapif_mercenary_send(int fd, struct s_mercenary *merc, unsigned char flag); +void mapif_parse_mercenary_create(int fd, struct s_mercenary* merc); +void mapif_parse_mercenary_load(int fd, int merc_id, int char_id); +void mapif_mercenary_deleted(int fd, unsigned char flag); +void mapif_parse_mercenary_delete(int fd, int merc_id); +void mapif_mercenary_saved(int fd, unsigned char flag); +void mapif_parse_mercenary_save(int fd, struct s_mercenary* merc); void mapif_defaults(void) { mapif = &mapif_s; @@ -211,4 +221,14 @@ void mapif_defaults(void) { mapif->parse_mail_return = mapif_parse_mail_return; mapif->mail_send = mapif_mail_send; mapif->parse_mail_send = mapif_parse_mail_send; + mapif->mercenary_save = mapif_mercenary_save; + mapif->mercenary_load = mapif_mercenary_load; + mapif->mercenary_delete = mapif_mercenary_delete; + mapif->mercenary_send = mapif_mercenary_send; + mapif->parse_mercenary_create = mapif_parse_mercenary_create; + mapif->parse_mercenary_load = mapif_parse_mercenary_load; + mapif->mercenary_deleted = mapif_mercenary_deleted; + mapif->parse_mercenary_delete = mapif_parse_mercenary_delete; + mapif->mercenary_saved = mapif_mercenary_saved; + mapif->parse_mercenary_save = mapif_parse_mercenary_save; } diff --git a/src/char/mapif.h b/src/char/mapif.h index ec177fcd1..511a40a68 100644 --- a/src/char/mapif.h +++ b/src/char/mapif.h @@ -9,6 +9,7 @@ struct s_elemental; struct s_homunculus; +struct s_mercenary; struct mail_message; /* mapif interface */ @@ -107,6 +108,16 @@ struct mapif_interface { void (*parse_mail_return) (int fd); void (*mail_send) (int fd, struct mail_message* msg); void (*parse_mail_send) (int fd); + bool (*mercenary_save) (struct s_mercenary* merc); + bool (*mercenary_load) (int merc_id, int char_id, struct s_mercenary *merc); + bool (*mercenary_delete) (int merc_id); + void (*mercenary_send) (int fd, struct s_mercenary *merc, unsigned char flag); + void (*parse_mercenary_create) (int fd, struct s_mercenary* merc); + void (*parse_mercenary_load) (int fd, int merc_id, int char_id); + void (*mercenary_deleted) (int fd, unsigned char flag); + void (*parse_mercenary_delete) (int fd, int merc_id); + void (*mercenary_saved) (int fd, unsigned char flag); + void (*parse_mercenary_save) (int fd, struct s_mercenary* merc); } mapif_s; struct mapif_interface *mapif; |