diff options
author | Haru <haru@dotalux.com> | 2018-06-24 20:33:59 +0200 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2018-06-30 01:51:10 +0200 |
commit | 882b22d8dfaaabd8781bdad139aaa2e6777eea52 (patch) | |
tree | f9531a74c42729247cda13b5111353bef8440851 /src | |
parent | 735e2e8340c9522ee5a9afdcad29d191da29c8d4 (diff) | |
download | hercules-882b22d8dfaaabd8781bdad139aaa2e6777eea52.tar.gz hercules-882b22d8dfaaabd8781bdad139aaa2e6777eea52.tar.bz2 hercules-882b22d8dfaaabd8781bdad139aaa2e6777eea52.tar.xz hercules-882b22d8dfaaabd8781bdad139aaa2e6777eea52.zip |
Move mapif functions from int_homunculus.c to mapif.c
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/char/int_homun.c | 97 | ||||
-rw-r--r-- | src/char/mapif.c | 103 |
2 files changed, 93 insertions, 107 deletions
diff --git a/src/char/int_homun.c b/src/char/int_homun.c index b692ac971..28ec848be 100644 --- a/src/char/int_homun.c +++ b/src/char/int_homun.c @@ -49,66 +49,6 @@ void inter_homunculus_sql_final(void) return; } -void mapif_homunculus_created(int fd, int account_id, const struct s_homunculus *sh, unsigned char flag) -{ - nullpo_retv(sh); - WFIFOHEAD(fd, sizeof(struct s_homunculus)+9); - WFIFOW(fd,0) = 0x3890; - WFIFOW(fd,2) = sizeof(struct s_homunculus)+9; - WFIFOL(fd,4) = account_id; - WFIFOB(fd,8)= flag; - memcpy(WFIFOP(fd,9),sh,sizeof(struct s_homunculus)); - WFIFOSET(fd, WFIFOW(fd,2)); -} - -void mapif_homunculus_deleted(int fd, int flag) -{ - WFIFOHEAD(fd, 3); - WFIFOW(fd, 0) = 0x3893; - WFIFOB(fd,2) = flag; //Flag 1 = success - WFIFOSET(fd, 3); -} - -void mapif_homunculus_loaded(int fd, int account_id, struct s_homunculus *hd) -{ - WFIFOHEAD(fd, sizeof(struct s_homunculus)+9); - WFIFOW(fd,0) = 0x3891; - WFIFOW(fd,2) = sizeof(struct s_homunculus)+9; - WFIFOL(fd,4) = account_id; - if( hd != NULL ) - { - WFIFOB(fd,8) = 1; // success - memcpy(WFIFOP(fd,9), hd, sizeof(struct s_homunculus)); - } - else - { - WFIFOB(fd,8) = 0; // not found. - memset(WFIFOP(fd,9), 0, sizeof(struct s_homunculus)); - } - WFIFOSET(fd, sizeof(struct s_homunculus)+9); -} - -void mapif_homunculus_saved(int fd, int account_id, bool flag) -{ - WFIFOHEAD(fd, 7); - WFIFOW(fd,0) = 0x3892; - WFIFOL(fd,2) = account_id; - WFIFOB(fd,6) = flag; // 1:success, 0:failure - WFIFOSET(fd, 7); -} - -void mapif_homunculus_renamed(int fd, int account_id, int char_id, unsigned char flag, const char *name) -{ - nullpo_retv(name); - WFIFOHEAD(fd, NAME_LENGTH+12); - WFIFOW(fd, 0) = 0x3894; - WFIFOL(fd, 2) = account_id; - WFIFOL(fd, 6) = char_id; - WFIFOB(fd,10) = flag; - safestrncpy(WFIFOP(fd,11), name, NAME_LENGTH); - WFIFOSET(fd, NAME_LENGTH+12); -} - /** * Creates a new homunculus with the given data. * @@ -302,43 +242,6 @@ bool inter_homunculus_rename(const char *name) return true; } - -void mapif_parse_homunculus_create(int fd, int len, int account_id, const struct s_homunculus *phd) -{ - struct s_homunculus shd; - bool result; - - memcpy(&shd, phd, sizeof(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 = 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 = 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 = 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 = inter_homunculus->rename(name); - mapif->homunculus_renamed(fd, account_id, char_id, result, name); -} - /*========================================== * Inter Packets *------------------------------------------*/ diff --git a/src/char/mapif.c b/src/char/mapif.c index 90386362d..cd5bfdb74 100644 --- a/src/char/mapif.c +++ b/src/char/mapif.c @@ -880,16 +880,99 @@ int mapif_parse_GuildMasterChange(int fd, int guild_id, const char* name, int le return 0; } -void mapif_homunculus_created(int fd, int account_id, const 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, 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); -void mapif_parse_homunculus_save(int fd, int len, int account_id, const struct s_homunculus *phd); -void mapif_parse_homunculus_rename(int fd, int account_id, int char_id, const char *name); +void mapif_homunculus_created(int fd, int account_id, const struct s_homunculus *sh, unsigned char flag) +{ + nullpo_retv(sh); + WFIFOHEAD(fd, sizeof(struct s_homunculus) + 9); + WFIFOW(fd, 0) = 0x3890; + WFIFOW(fd, 2) = sizeof(struct s_homunculus) + 9; + WFIFOL(fd, 4) = account_id; + WFIFOB(fd, 8) = flag; + memcpy(WFIFOP(fd, 9), sh, sizeof(struct s_homunculus)); + WFIFOSET(fd, WFIFOW(fd, 2)); +} + +void mapif_homunculus_deleted(int fd, int flag) +{ + WFIFOHEAD(fd, 3); + WFIFOW(fd, 0) = 0x3893; + WFIFOB(fd,2) = flag; //Flag 1 = success + WFIFOSET(fd, 3); +} + +void mapif_homunculus_loaded(int fd, int account_id, struct s_homunculus *hd) +{ + WFIFOHEAD(fd, sizeof(struct s_homunculus) + 9); + WFIFOW(fd, 0) = 0x3891; + WFIFOW(fd, 2) = sizeof(struct s_homunculus) + 9; + WFIFOL(fd, 4) = account_id; + if (hd != NULL) { + WFIFOB(fd, 8) = 1; // success + memcpy(WFIFOP(fd, 9), hd, sizeof(struct s_homunculus)); + } else { + WFIFOB(fd, 8) = 0; // not found. + memset(WFIFOP(fd, 9), 0, sizeof(struct s_homunculus)); + } + WFIFOSET(fd, sizeof(struct s_homunculus) + 9); +} + +void mapif_homunculus_saved(int fd, int account_id, bool flag) +{ + WFIFOHEAD(fd, 7); + WFIFOW(fd, 0) = 0x3892; + WFIFOL(fd, 2) = account_id; + WFIFOB(fd, 6) = flag; // 1:success, 0:failure + WFIFOSET(fd, 7); +} + +void mapif_homunculus_renamed(int fd, int account_id, int char_id, unsigned char flag, const char *name) +{ + nullpo_retv(name); + WFIFOHEAD(fd, NAME_LENGTH + 12); + WFIFOW(fd, 0) = 0x3894; + WFIFOL(fd, 2) = account_id; + WFIFOL(fd, 6) = char_id; + WFIFOB(fd, 10) = flag; + safestrncpy(WFIFOP(fd, 11), name, NAME_LENGTH); + WFIFOSET(fd, NAME_LENGTH + 12); +} + +void mapif_parse_homunculus_create(int fd, int len, int account_id, const struct s_homunculus *phd) +{ + struct s_homunculus shd; + bool result; + + memcpy(&shd, phd, sizeof(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 = 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 = 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 = 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 = inter_homunculus->rename(name); + mapif->homunculus_renamed(fd, account_id, char_id, result, name); +} + void mapif_mail_sendinbox(int fd, int char_id, unsigned char flag, struct mail_data *md); void mapif_parse_mail_requestinbox(int fd); void mapif_parse_mail_read(int fd); |