From 759065f794b8ef7ee3e9276da1b47c1f86478cdc Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 19 Aug 2018 00:42:12 +0300 Subject: Add packet ZC_GUILD_POSITION. --- src/map/clif.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ src/map/clif.h | 3 +++ src/map/guild.c | 4 ++-- src/map/packets_struct.h | 7 +++++++ 4 files changed, 57 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/map/clif.c b/src/map/clif.c index 4e55f7d0c..e04132386 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -8310,6 +8310,49 @@ static void clif_guild_broken(struct map_session_data *sd, int flag) WFIFOSET(fd,packet_len(0x15e)); } +static void clif_guild_position_selected(struct map_session_data *sd) +{ +#if PACKETVER >= 20180801 + clif->guild_set_position(sd); +#else + clif->charnameupdate(sd); +#endif +} + +static void clif_guild_set_position(struct map_session_data *sd) +{ + nullpo_retv(sd); + + int len = sizeof(struct PACKET_ZC_GUILD_POSITION); + const char *name = NULL; + if (sd->status.guild_id > 0) { + struct guild *g = sd->guild; + + nullpo_retv(g); + + int i = 0; + int ps = -1; + ARR_FIND(0, g->max_member, i, g->member[i].account_id == sd->status.account_id && g->member[i].char_id == sd->status.char_id); + if (i < g->max_member) + ps = g->member[i].position; + + if (ps >= 0 && ps < MAX_GUILDPOSITION) { + len += 24; + name = g->position[ps].name; + } + } + + unsigned char buf[sizeof(struct PACKET_ZC_GUILD_POSITION) + NAME_LENGTH]; + struct PACKET_ZC_GUILD_POSITION *p = WBUFP(buf, 0); + p->packetType = 0xafd; + p->packetLength = len; + p->AID = sd->bl.id; + if (name != NULL) + memcpy(&p->position, name, 24); + + clif->send(buf, len, &sd->bl, AREA); +} + /// Displays emotion on an object (ZC_EMOTION). /// 00c0 .L .B /// type: @@ -22319,6 +22362,8 @@ void clif_defaults(void) clif->guild_positionnamelist = clif_guild_positionnamelist; clif->guild_positioninfolist = clif_guild_positioninfolist; clif->guild_expulsionlist = clif_guild_expulsionlist; + clif->guild_set_position = clif_guild_set_position; + clif->guild_position_selected = clif_guild_position_selected; clif->validate_emblem = clif_validate_emblem; /* battleground-specific */ clif->bg_hp = clif_bg_hp; diff --git a/src/map/clif.h b/src/map/clif.h index 406c6ca6a..b74eb8625 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -1041,6 +1041,9 @@ struct clif_interface { void (*guild_positionnamelist) (struct map_session_data *sd); void (*guild_positioninfolist) (struct map_session_data *sd); void (*guild_expulsionlist) (struct map_session_data* sd); + void (*guild_set_position) (struct map_session_data *sd); + void (*guild_position_selected) (struct map_session_data *sd); + bool (*validate_emblem) (const uint8* emblem, unsigned long emblem_len); /* battleground-specific */ void (*bg_hp) (struct map_session_data *sd); diff --git a/src/map/guild.c b/src/map/guild.c index 28954edf1..f82928c4d 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -1129,7 +1129,7 @@ static int guild_memberposition_changed(struct guild *g, int idx, int pos) // Update char position in client [LuzZza] if(g->member[idx].sd != NULL) - clif->charnameupdate(g->member[idx].sd); + clif->guild_position_selected(g->member[idx].sd); return 0; } @@ -1165,7 +1165,7 @@ static int guild_position_changed(int guild_id, int idx, const struct guild_posi // Update char name in client [LuzZza] for(i=0;imax_member;i++) if(g->member[i].position == idx && g->member[i].sd != NULL) - clif->charnameupdate(g->member[i].sd); + clif->guild_position_selected(g->member[i].sd); return 0; } diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h index e3aea5ed1..d6885a696 100644 --- a/src/map/packets_struct.h +++ b/src/map/packets_struct.h @@ -2706,6 +2706,13 @@ struct PACKET_ZC_GROUP_ISALIVE { uint8 isDead; } __attribute__((packed)); +struct PACKET_ZC_GUILD_POSITION { + int16 packetType; + int16 packetLength; + uint32 AID; + char position[]; +} __attribute__((packed)); + #if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute #pragma pack(pop) #endif // not NetBSD < 6 / Solaris -- cgit v1.2.3-60-g2f50