diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-11-08 00:33:01 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-11-15 11:47:29 +0300 |
commit | f324b507a9c0792abee2d31f6f3607077376619d (patch) | |
tree | 9a956650647f34b0842f076d5dc33760f5a17d2e | |
parent | 8e3ff5af507352d8c0c3f50469917f2b5ba231f9 (diff) | |
download | hercules-f324b507a9c0792abee2d31f6f3607077376619d.tar.gz hercules-f324b507a9c0792abee2d31f6f3607077376619d.tar.bz2 hercules-f324b507a9c0792abee2d31f6f3607077376619d.tar.xz hercules-f324b507a9c0792abee2d31f6f3607077376619d.zip |
Add most functions from int_homun.c to interfaces.
-rw-r--r-- | src/char/char.c | 3 | ||||
-rw-r--r-- | src/char/int_homun.c | 64 | ||||
-rw-r--r-- | src/char/int_homun.h | 15 | ||||
-rw-r--r-- | src/char/inter.c | 6 | ||||
-rw-r--r-- | src/char/mapif.c | 29 | ||||
-rw-r--r-- | src/char/mapif.h | 15 |
6 files changed, 94 insertions, 38 deletions
diff --git a/src/char/char.c b/src/char/char.c index ad224010a..02504c786 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -1813,7 +1813,7 @@ int char_delete_char_sql(int char_id) /* remove homunculus */ if( hom_id ) - mapif_homunculus_delete(hom_id); + mapif->homunculus_delete(hom_id); /* remove elemental */ if (elemental_id) @@ -6008,6 +6008,7 @@ void char_load_defaults(void) inter_auction_defaults(); inter_elemental_defaults(); inter_guild_defaults(); + inter_homunculus_defaults(); } void char_defaults(void) diff --git a/src/char/int_homun.c b/src/char/int_homun.c index acde9eb38..191789c06 100644 --- a/src/char/int_homun.c +++ b/src/char/int_homun.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_homunculus_interface inter_homunculus_s; + int inter_homunculus_sql_init(void) { return 0; @@ -29,7 +32,7 @@ void inter_homunculus_sql_final(void) return; } -static void mapif_homunculus_created(int fd, int account_id, struct s_homunculus *sh, unsigned char flag) +void mapif_homunculus_created(int fd, int account_id, struct s_homunculus *sh, unsigned char flag) { WFIFOHEAD(fd, sizeof(struct s_homunculus)+9); WFIFOW(fd,0) = 0x3890; @@ -40,7 +43,7 @@ static void mapif_homunculus_created(int fd, int account_id, struct s_homunculus WFIFOSET(fd, WFIFOW(fd,2)); } -static void mapif_homunculus_deleted(int fd, int flag) +void mapif_homunculus_deleted(int fd, int flag) { WFIFOHEAD(fd, 3); WFIFOW(fd, 0) = 0x3893; @@ -48,7 +51,7 @@ static void mapif_homunculus_deleted(int fd, int flag) WFIFOSET(fd, 3); } -static void mapif_homunculus_loaded(int fd, int account_id, struct s_homunculus *hd) +void mapif_homunculus_loaded(int fd, int account_id, struct s_homunculus *hd) { WFIFOHEAD(fd, sizeof(struct s_homunculus)+9); WFIFOW(fd,0) = 0x3891; @@ -67,7 +70,7 @@ static void mapif_homunculus_loaded(int fd, int account_id, struct s_homunculus WFIFOSET(fd, sizeof(struct s_homunculus)+9); } -static void mapif_homunculus_saved(int fd, int account_id, bool flag) +void mapif_homunculus_saved(int fd, int account_id, bool flag) { WFIFOHEAD(fd, 7); WFIFOW(fd,0) = 0x3892; @@ -76,7 +79,7 @@ static void mapif_homunculus_saved(int fd, int account_id, bool flag) WFIFOSET(fd, 7); } -static void mapif_homunculus_renamed(int fd, int account_id, int char_id, unsigned char flag, char* name) +void mapif_homunculus_renamed(int fd, int account_id, int char_id, unsigned char flag, char* name) { WFIFOHEAD(fd, NAME_LENGTH+12); WFIFOW(fd, 0) = 0x3894; @@ -149,8 +152,6 @@ bool mapif_homunculus_save(struct s_homunculus* hd) return flag; } - - // Load an homunculus bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd) { @@ -266,35 +267,35 @@ bool mapif_homunculus_rename(char *name) } -static void mapif_parse_homunculus_create(int fd, int len, int account_id, struct s_homunculus* phd) +void mapif_parse_homunculus_create(int fd, int len, int account_id, struct s_homunculus* phd) { - bool result = mapif_homunculus_save(phd); - mapif_homunculus_created(fd, account_id, phd, result); + bool result = mapif->homunculus_save(phd); + mapif->homunculus_created(fd, account_id, phd, result); } -static void mapif_parse_homunculus_delete(int fd, int homun_id) +void mapif_parse_homunculus_delete(int fd, int homun_id) { - bool result = mapif_homunculus_delete(homun_id); - mapif_homunculus_deleted(fd, result); + bool result = mapif->homunculus_delete(homun_id); + mapif->homunculus_deleted(fd, result); } -static void mapif_parse_homunculus_load(int fd, int account_id, int homun_id) +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); - mapif_homunculus_loaded(fd, account_id, ( result ? &hd : NULL )); + bool result = mapif->homunculus_load(homun_id, &hd); + mapif->homunculus_loaded(fd, account_id, ( result ? &hd : NULL )); } -static void mapif_parse_homunculus_save(int fd, int len, int account_id, struct s_homunculus* phd) +void mapif_parse_homunculus_save(int fd, int len, int account_id, struct s_homunculus* phd) { - bool result = mapif_homunculus_save(phd); - mapif_homunculus_saved(fd, account_id, result); + bool result = mapif->homunculus_save(phd); + mapif->homunculus_saved(fd, account_id, result); } -static void mapif_parse_homunculus_rename(int fd, int account_id, int char_id, char* name) +void mapif_parse_homunculus_rename(int fd, int account_id, int char_id, char* name) { - bool result = mapif_homunculus_rename(name); - mapif_homunculus_renamed(fd, account_id, char_id, result, name); + bool result = mapif->homunculus_rename(name); + mapif->homunculus_renamed(fd, account_id, char_id, result, name); } /*========================================== @@ -306,13 +307,22 @@ int inter_homunculus_parse_frommap(int fd) switch( cmd ) { - case 0x3090: mapif_parse_homunculus_create(fd, (int)RFIFOW(fd,2), (int)RFIFOL(fd,4), (struct s_homunculus*)RFIFOP(fd,8)); break; - case 0x3091: mapif_parse_homunculus_load (fd, (int)RFIFOL(fd,2), (int)RFIFOL(fd,6)); break; - case 0x3092: mapif_parse_homunculus_save (fd, (int)RFIFOW(fd,2), (int)RFIFOL(fd,4), (struct s_homunculus*)RFIFOP(fd,8)); break; - case 0x3093: mapif_parse_homunculus_delete(fd, (int)RFIFOL(fd,2)); break; - case 0x3094: mapif_parse_homunculus_rename(fd, (int)RFIFOL(fd,2), (int)RFIFOL(fd,6), (char*)RFIFOP(fd,10)); break; + case 0x3090: mapif->parse_homunculus_create(fd, (int)RFIFOW(fd,2), (int)RFIFOL(fd,4), (struct s_homunculus*)RFIFOP(fd,8)); break; + case 0x3091: mapif->parse_homunculus_load (fd, (int)RFIFOL(fd,2), (int)RFIFOL(fd,6)); break; + case 0x3092: mapif->parse_homunculus_save (fd, (int)RFIFOW(fd,2), (int)RFIFOL(fd,4), (struct s_homunculus*)RFIFOP(fd,8)); break; + case 0x3093: mapif->parse_homunculus_delete(fd, (int)RFIFOL(fd,2)); break; + case 0x3094: mapif->parse_homunculus_rename(fd, (int)RFIFOL(fd,2), (int)RFIFOL(fd,6), (char*)RFIFOP(fd,10)); break; default: return 0; } return 1; } + +void inter_homunculus_defaults(void) +{ + inter_homunculus = &inter_homunculus_s; + + inter_homunculus->sql_init = inter_homunculus_sql_init; + inter_homunculus->sql_final = inter_homunculus_sql_final; + inter_homunculus->parse_frommap = inter_homunculus_parse_frommap; +} diff --git a/src/char/int_homun.h b/src/char/int_homun.h index 6fa4f9dc7..13debcebc 100644 --- a/src/char/int_homun.h +++ b/src/char/int_homun.h @@ -8,13 +8,14 @@ struct s_homunculus; -int inter_homunculus_sql_init(void); -void inter_homunculus_sql_final(void); -int inter_homunculus_parse_frommap(int fd); +void inter_homunculus_defaults(void); -bool mapif_homunculus_save(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(char *name); +struct inter_homunculus_interface { + int (*sql_init) (void); + void (*sql_final) (void); + int (*parse_frommap) (int fd); +}; + +struct inter_homunculus_interface *inter_homunculus; #endif /* CHAR_INT_HOMUN_H */ diff --git a/src/char/inter.c b/src/char/inter.c index 97b7e3760..8ee4da6fe 100644 --- a/src/char/inter.c +++ b/src/char/inter.c @@ -1030,7 +1030,7 @@ int inter_init_sql(const char *file) inter_storage_sql_init(); inter_party_sql_init(); inter_pet_sql_init(); - inter_homunculus_sql_init(); + inter_homunculus->sql_init(); inter_mercenary_sql_init(); inter_elemental->sql_init(); inter_mail_sql_init(); @@ -1050,7 +1050,7 @@ void inter_final(void) inter_storage_sql_final(); inter_party_sql_final(); inter_pet_sql_final(); - inter_homunculus_sql_final(); + inter_homunculus->sql_final(); inter_mercenary_sql_final(); inter_elemental->sql_final(); inter_mail_sql_final(); @@ -1457,7 +1457,7 @@ int inter_parse_frommap(int fd) || inter_guild->parse_frommap(fd) || inter_storage_parse_frommap(fd) || inter_pet_parse_frommap(fd) - || inter_homunculus_parse_frommap(fd) + || inter_homunculus->parse_frommap(fd) || inter_mercenary_parse_frommap(fd) || inter_elemental->parse_frommap(fd) || inter_mail_parse_frommap(fd) diff --git a/src/char/mapif.c b/src/char/mapif.c index 73d33f2e1..6017b3d34 100644 --- a/src/char/mapif.c +++ b/src/char/mapif.c @@ -10,6 +10,7 @@ #include "char.h" #include "int_auction.h" +#include "int_homun.h" #include "int_guild.h" #include "../common/cbasetypes.h" #include "../common/mmo.h" @@ -85,6 +86,20 @@ int mapif_parse_GuildEmblem(int fd, int len, int guild_id, int dummy, const char int mapif_parse_GuildCastleDataLoad(int fd, int len, int *castle_ids); int mapif_parse_GuildCastleDataSave(int fd, int castle_id, int index, int value); int mapif_parse_GuildMasterChange(int fd, int guild_id, const char* name, int len); +void mapif_homunculus_created(int fd, int account_id, struct s_homunculus *sh, unsigned char flag); +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, char* name); +bool mapif_homunculus_save(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(char *name); +void mapif_parse_homunculus_create(int fd, int len, int account_id, 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); +void mapif_parse_homunculus_save(int fd, int len, int account_id, struct s_homunculus* phd); +void mapif_parse_homunculus_rename(int fd, int account_id, int char_id, char* name); void mapif_defaults(void) { mapif = &mapif_s; @@ -156,4 +171,18 @@ void mapif_defaults(void) { mapif->parse_GuildCastleDataLoad = mapif_parse_GuildCastleDataLoad; mapif->parse_GuildCastleDataSave = mapif_parse_GuildCastleDataSave; mapif->parse_GuildMasterChange = mapif_parse_GuildMasterChange; + mapif->homunculus_created = mapif_homunculus_created; + mapif->homunculus_deleted = mapif_homunculus_deleted; + mapif->homunculus_loaded = mapif_homunculus_loaded; + mapif->homunculus_saved = mapif_homunculus_saved; + mapif->homunculus_renamed = mapif_homunculus_renamed; + 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; + mapif->parse_homunculus_save = mapif_parse_homunculus_save; + mapif->parse_homunculus_rename = mapif_parse_homunculus_rename; } diff --git a/src/char/mapif.h b/src/char/mapif.h index 60fd7e392..4a61db3fd 100644 --- a/src/char/mapif.h +++ b/src/char/mapif.h @@ -8,6 +8,7 @@ #include "char.h" struct s_elemental; +struct s_homunculus; /* mapif interface */ struct mapif_interface { @@ -78,6 +79,20 @@ struct mapif_interface { int (*parse_GuildCastleDataLoad) (int fd, int len, int *castle_ids); int (*parse_GuildCastleDataSave) (int fd, int castle_id, int index, int value); int (*parse_GuildMasterChange) (int fd, int guild_id, const char* name, int len); + void (*homunculus_created) (int fd, int account_id, struct s_homunculus *sh, unsigned char flag); + void (*homunculus_deleted) (int fd, int flag); + 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, char* name); + bool (*homunculus_save) (struct s_homunculus* hd); + bool (*homunculus_load) (int homun_id, struct s_homunculus* hd); + bool (*homunculus_delete) (int homun_id); + bool (*homunculus_rename) (char *name); + void (*parse_homunculus_create) (int fd, int len, int account_id, 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); + void (*parse_homunculus_save) (int fd, int len, int account_id, struct s_homunculus* phd); + void (*parse_homunculus_rename) (int fd, int account_id, int char_id, char* name); } mapif_s; struct mapif_interface *mapif; |