send chat packets to *all* players

This commit is contained in:
unknown 2023-06-27 22:05:08 -05:00
parent 215e313c43
commit f27e72d68d
2 changed files with 13 additions and 3 deletions

View File

@ -13,7 +13,7 @@ func (server *ShardServer) freeChat(peer *protocol.CNPeer, pkt protocol.Packet)
}
// spread message
return server.sendOthersPacket(plr, protocol.P_FE2CL_REP_SEND_FREECHAT_MESSAGE_SUCC, protocol.SP_FE2CL_REP_SEND_FREECHAT_MESSAGE_SUCC{
return server.sendAllPacket(plr, protocol.P_FE2CL_REP_SEND_FREECHAT_MESSAGE_SUCC, protocol.SP_FE2CL_REP_SEND_FREECHAT_MESSAGE_SUCC{
IPC_ID: int32(plr.PlayerID),
SzFreeChat: chat.SzFreeChat,
IEmoteCode: chat.IEmoteCode,
@ -31,7 +31,7 @@ func (server *ShardServer) menuChat(peer *protocol.CNPeer, pkt protocol.Packet)
}
// spread message
return server.sendOthersPacket(plr, protocol.P_FE2CL_REP_SEND_MENUCHAT_MESSAGE_SUCC, protocol.SP_FE2CL_REP_SEND_MENUCHAT_MESSAGE_SUCC{
return server.sendAllPacket(plr, protocol.P_FE2CL_REP_SEND_MENUCHAT_MESSAGE_SUCC, protocol.SP_FE2CL_REP_SEND_MENUCHAT_MESSAGE_SUCC{
IPC_ID: int32(plr.PlayerID),
SzFreeChat: chat.SzFreeChat,
IEmoteCode: chat.IEmoteCode,
@ -49,7 +49,7 @@ func (server *ShardServer) emoteChat(peer *protocol.CNPeer, pkt protocol.Packet)
}
// spread message
return server.sendOthersPacket(plr, protocol.P_FE2CL_REP_PC_AVATAR_EMOTES_CHAT, protocol.SP_FE2CL_REP_PC_AVATAR_EMOTES_CHAT{
return server.sendAllPacket(plr, protocol.P_FE2CL_REP_PC_AVATAR_EMOTES_CHAT, protocol.SP_FE2CL_REP_PC_AVATAR_EMOTES_CHAT{
IID_From: int32(plr.PlayerID),
IEmoteCode: chat.IEmoteCode,
})

View File

@ -46,6 +46,16 @@ func (server *ShardServer) sendOthersPacket(plr *entity.Player, typeID uint32, p
return nil
}
// sends a packet to all peers in the given chunks
func (server *ShardServer) sendAllPacket(plr *entity.Player, typeID uint32, pkt ...interface{}) error {
chunks := server.getViewableChunks(plr.Chunk)
for _, chunk := range chunks {
chunk.SendPacket(typeID, pkt...)
}
return nil
}
func (server *ShardServer) removeEntityFromChunks(chunks []*entity.Chunk, this entity.Entity) {
for _, chunk := range chunks {
for e := range chunk.Entities {