Converted ZC_GUILD_CHAT to struct (#8634)
Co-authored-by: Lemongrass3110 <lemongrass@kstp.at>
This commit is contained in:
parent
9761fdf4da
commit
5c7c874f72
@ -9133,29 +9133,32 @@ void clif_guild_expulsionlist(map_session_data* sd)
|
||||
}
|
||||
|
||||
|
||||
/// Guild chat message (ZC_GUILD_CHAT).
|
||||
/// 017f <packet len>.W <message>.?B
|
||||
void clif_guild_message( const struct mmo_guild& g, uint32 account_id, const char* mes, size_t len ){
|
||||
// TODO: account_id is not used, candidate for deletion? [Ai4rei]
|
||||
map_session_data *sd;
|
||||
uint8 buf[256];
|
||||
/// Guild chat message
|
||||
/// 017f <packet len>.W <message>.?B (ZC_GUILD_CHAT)
|
||||
void clif_guild_message( const struct mmo_guild& g, const char* mes, size_t len ){
|
||||
PACKET_ZC_GUILD_CHAT *p = reinterpret_cast<PACKET_ZC_GUILD_CHAT*>( packet_buffer );
|
||||
// -1 for null terminator
|
||||
static const size_t max_len = CHAT_SIZE_MAX - sizeof( *p ) - 1;
|
||||
|
||||
if( len == 0 )
|
||||
{
|
||||
map_session_data* sd = guild_getavailablesd(g);
|
||||
|
||||
// Ignore this message, if no guildmember is available
|
||||
if (sd == nullptr)
|
||||
return;
|
||||
}
|
||||
else if( len > sizeof(buf)-5 )
|
||||
{
|
||||
ShowWarning("clif_guild_message: Truncated message '%s' (len=%d, max=%" PRIuPTR ", guild_id=%d).\n", mes, len, sizeof(buf)-5, g.guild_id);
|
||||
len = sizeof(buf)-5;
|
||||
}
|
||||
|
||||
WBUFW(buf, 0) = 0x17f;
|
||||
WBUFW( buf, 2 ) = static_cast<int16>( len + 5 );
|
||||
safestrncpy(WBUFCP(buf,4), mes, len+1);
|
||||
if( len == 0 ){
|
||||
return;
|
||||
} else if( len > max_len ){
|
||||
ShowWarning("clif_guild_message: Truncated message '%s' (len=%" PRIuPTR ", max=%" PRIuPTR ", guild_id=%u).\n", mes, len, max_len, g.guild_id);
|
||||
len = max_len;
|
||||
}
|
||||
p->packetType = HEADER_ZC_GUILD_CHAT;
|
||||
p->packetLength = sizeof(*p);
|
||||
|
||||
if ((sd = guild_getavailablesd(g)) != nullptr)
|
||||
clif_send(buf, WBUFW(buf,2), &sd->bl, GUILD_NOBG);
|
||||
safestrncpy(p->message, mes, len+1);
|
||||
p->packetLength += static_cast<decltype(p->packetLength)>( len + 1 );
|
||||
|
||||
clif_send(p, p->packetLength, &sd->bl, GUILD_NOBG);
|
||||
}
|
||||
|
||||
/// Request for guild alliance
|
||||
|
||||
@ -1057,7 +1057,7 @@ void clif_guild_memberpositionchanged(const struct mmo_guild &g,int idx);
|
||||
void clif_guild_emblem(const map_session_data &sd, const struct mmo_guild &g);
|
||||
void clif_guild_emblem_area(struct block_list* bl);
|
||||
void clif_guild_notice( map_session_data& sd );
|
||||
void clif_guild_message( const struct mmo_guild& g, uint32 account_id, const char* mes, size_t len );
|
||||
void clif_guild_message( const struct mmo_guild& g, const char* mes, size_t len );
|
||||
void clif_guild_reqalliance(map_session_data& sd,uint32 account_id,const char *name);
|
||||
void clif_guild_allianceack(map_session_data& sd, uint8 flag);
|
||||
void clif_guild_delalliance(map_session_data& sd,uint32 guild_id,uint32 flag);
|
||||
|
||||
@ -201,7 +201,6 @@
|
||||
packet(0x017b,-1);
|
||||
parseable_packet(0x017c,6,clif_parse_InsertCard,2,4);
|
||||
parseable_packet(0x017e,-1,clif_parse_GuildMessage,2,4);
|
||||
packet(0x017f,-1);
|
||||
parseable_packet(0x0180,6,clif_parse_GuildOpposition,2);
|
||||
packet(0x0182,106);
|
||||
parseable_packet(0x0183,10,clif_parse_GuildDelAlliance,2,6);
|
||||
|
||||
@ -1476,7 +1476,7 @@ int guild_recv_message( int guild_id, uint32 account_id, const char *mes, size_t
|
||||
auto g = guild_search(guild_id);
|
||||
if (!g)
|
||||
return 0;
|
||||
clif_guild_message(g->guild,account_id,mes,len);
|
||||
clif_guild_message(g->guild,mes,len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -825,6 +825,13 @@ struct PACKET_ZC_NOTIFY_POSITION_TO_GUILDM {
|
||||
} __attribute__((packed));
|
||||
DEFINE_PACKET_HEADER(ZC_NOTIFY_POSITION_TO_GUILDM, 0x1eb)
|
||||
|
||||
struct PACKET_ZC_GUILD_CHAT {
|
||||
int16 packetType;
|
||||
int16 packetLength;
|
||||
char message[];
|
||||
} __attribute__((packed));
|
||||
DEFINE_PACKET_HEADER(ZC_GUILD_CHAT, 0x17f)
|
||||
|
||||
struct PACKET_ZC_STATUS {
|
||||
int16 packetType;
|
||||
uint16 point;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user