Permalink
Browse files

Merge pull request #2124 from MishimaHaruna/guild-add-member-fix

Guild add member fix
  • Loading branch information...
MishimaHaruna committed Jul 7, 2018
2 parents eed4e9b + b03d963 commit f341c57df75c327736792c1b1e98dd68d7033ac9
View
@@ -969,21 +969,24 @@ static struct guild *inter_guild_create(const char *name, const struct guild_mem
}
// Add member to guild
static bool inter_guild_add_member(int guild_id, const struct guild_member *member)
static bool inter_guild_add_member(int guild_id, const struct guild_member *member, int map_fd)
{
struct guild * g;
int i;
nullpo_ret(member);
g = inter_guild->fromsql(guild_id);
if (g == NULL)
if (g == NULL) {
mapif->guild_memberadded(map_fd, guild_id, member->account_id, member->char_id, 1); // 1: Failed to add
return false;
}
// Find an empty slot
for (i = 0; i < g->max_member; i++) {
if (g->member[i].account_id == 0) {
g->member[i] = *member;
g->member[i].modified = (GS_MEMBER_NEW | GS_MEMBER_MODIFIED);
mapif->guild_memberadded(map_fd, guild_id, member->account_id, member->char_id, 0); // 0: success
if (!inter_guild->calcinfo(g)) //Send members if it was not invoked.
mapif->guild_info(-1, g);
@@ -993,6 +996,8 @@ static bool inter_guild_add_member(int guild_id, const struct guild_member *memb
return true;
}
}
mapif->guild_memberadded(map_fd, guild_id, member->account_id, member->char_id, 1); // 1: Failed to add
return false;
}
View
@@ -70,7 +70,7 @@ struct inter_guild_interface {
int (*parse_frommap) (int fd);
int (*broken) (int guild_id);
struct guild *(*create) (const char *name, const struct guild_member *master);
bool (*add_member) (int guild_id, const struct guild_member *member);
bool (*add_member) (int guild_id, const struct guild_member *member, int map_fd);
bool (*leave) (int guild_id, int account_id, int char_id, int flag, const char *mes, int map_fd);
bool (*update_member_info_short) (int guild_id, int account_id, int char_id, int online, int lv, int16 class);
bool (*update_member_info) (int guild_id, int account_id, int char_id, int type, const char *data, int len);
View
@@ -784,11 +784,7 @@ static int mapif_parse_GuildAddMember(int fd, int guild_id, const struct guild_m
{
nullpo_ret(m);
if (!inter_guild->add_member(guild_id, m)) {
mapif->guild_memberadded(fd, guild_id, m->account_id, m->char_id, 1); // 1: Failed to add
} else {
mapif->guild_memberadded(fd, guild_id, m->account_id, m->char_id, 0); // 0: success
}
inter_guild->add_member(guild_id, m, fd);
return 0;
}
@@ -3080,8 +3080,8 @@ typedef int (*HPMHOOK_pre_inter_guild_broken) (int *guild_id);
typedef int (*HPMHOOK_post_inter_guild_broken) (int retVal___, int guild_id);
typedef struct guild* (*HPMHOOK_pre_inter_guild_create) (const char **name, const struct guild_member **master);
typedef struct guild* (*HPMHOOK_post_inter_guild_create) (struct guild* retVal___, const char *name, const struct guild_member *master);
typedef bool (*HPMHOOK_pre_inter_guild_add_member) (int *guild_id, const struct guild_member **member);
typedef bool (*HPMHOOK_post_inter_guild_add_member) (bool retVal___, int guild_id, const struct guild_member *member);
typedef bool (*HPMHOOK_pre_inter_guild_add_member) (int *guild_id, const struct guild_member **member, int *map_fd);
typedef bool (*HPMHOOK_post_inter_guild_add_member) (bool retVal___, int guild_id, const struct guild_member *member, int map_fd);
typedef bool (*HPMHOOK_pre_inter_guild_leave) (int *guild_id, int *account_id, int *char_id, int *flag, const char **mes, int *map_fd);
typedef bool (*HPMHOOK_post_inter_guild_leave) (bool retVal___, int guild_id, int account_id, int char_id, int flag, const char *mes, int map_fd);
typedef bool (*HPMHOOK_pre_inter_guild_update_member_info_short) (int *guild_id, int *account_id, int *char_id, int *online, int *lv, int16 *class);
@@ -6750,29 +6750,29 @@ struct guild* HP_inter_guild_create(const char *name, const struct guild_member
}
return retVal___;
}
bool HP_inter_guild_add_member(int guild_id, const struct guild_member *member) {
bool HP_inter_guild_add_member(int guild_id, const struct guild_member *member, int map_fd) {
int hIndex = 0;
bool retVal___ = false;
if (HPMHooks.count.HP_inter_guild_add_member_pre > 0) {
bool (*preHookFunc) (int *guild_id, const struct guild_member **member);
bool (*preHookFunc) (int *guild_id, const struct guild_member **member, int *map_fd);
*HPMforce_return = false;
for (hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_add_member_pre; hIndex++) {
preHookFunc = HPMHooks.list.HP_inter_guild_add_member_pre[hIndex].func;
retVal___ = preHookFunc(&guild_id, &member);
retVal___ = preHookFunc(&guild_id, &member, &map_fd);
}
if (*HPMforce_return) {
*HPMforce_return = false;
return retVal___;
}
}
{
retVal___ = HPMHooks.source.inter_guild.add_member(guild_id, member);
retVal___ = HPMHooks.source.inter_guild.add_member(guild_id, member, map_fd);
}
if (HPMHooks.count.HP_inter_guild_add_member_post > 0) {
bool (*postHookFunc) (bool retVal___, int guild_id, const struct guild_member *member);
bool (*postHookFunc) (bool retVal___, int guild_id, const struct guild_member *member, int map_fd);
for (hIndex = 0; hIndex < HPMHooks.count.HP_inter_guild_add_member_post; hIndex++) {
postHookFunc = HPMHooks.list.HP_inter_guild_add_member_post[hIndex].func;
retVal___ = postHookFunc(retVal___, guild_id, member);
retVal___ = postHookFunc(retVal___, guild_id, member, map_fd);
}
}
return retVal___;

0 comments on commit f341c57

Please sign in to comment.