gopenfusion/shard/chat.go

60 lines
1.7 KiB
Go
Raw Permalink Normal View History

2023-06-28 02:49:11 +00:00
package shard
import (
"fmt"
2023-06-28 02:49:11 +00:00
2023-12-01 23:11:41 +00:00
"github.com/CPunch/gopenfusion/cnet"
"github.com/CPunch/gopenfusion/cnet/protocol"
2023-12-01 22:56:55 +00:00
"github.com/CPunch/gopenfusion/shard/entity"
)
2023-12-02 01:15:00 +00:00
func (server *ShardServer) freeChat(peer *cnet.Peer, pkt protocol.Packet) error {
2023-06-28 02:49:11 +00:00
var chat protocol.SP_CL2FE_REQ_SEND_FREECHAT_MESSAGE
pkt.Decode(&chat)
plr, ok := peer.UserData().(*entity.Player)
if !ok || plr == nil {
return fmt.Errorf("freeChat: plr is nil")
2023-06-28 02:49:11 +00:00
}
// spread message
2023-06-28 03:05:08 +00:00
return server.sendAllPacket(plr, protocol.P_FE2CL_REP_SEND_FREECHAT_MESSAGE_SUCC, protocol.SP_FE2CL_REP_SEND_FREECHAT_MESSAGE_SUCC{
2023-06-28 02:49:11 +00:00
IPC_ID: int32(plr.PlayerID),
SzFreeChat: chat.SzFreeChat,
IEmoteCode: chat.IEmoteCode,
})
}
2023-12-02 01:15:00 +00:00
func (server *ShardServer) menuChat(peer *cnet.Peer, pkt protocol.Packet) error {
2023-06-28 02:49:11 +00:00
var chat protocol.SP_CL2FE_REQ_SEND_MENUCHAT_MESSAGE
pkt.Decode(&chat)
plr, ok := peer.UserData().(*entity.Player)
if !ok || plr == nil {
return fmt.Errorf("menuChat: plr is nil")
2023-06-28 02:49:11 +00:00
}
// spread message
2023-06-28 03:05:08 +00:00
return server.sendAllPacket(plr, protocol.P_FE2CL_REP_SEND_MENUCHAT_MESSAGE_SUCC, protocol.SP_FE2CL_REP_SEND_MENUCHAT_MESSAGE_SUCC{
2023-06-28 02:49:11 +00:00
IPC_ID: int32(plr.PlayerID),
SzFreeChat: chat.SzFreeChat,
IEmoteCode: chat.IEmoteCode,
})
}
2023-12-02 01:15:00 +00:00
func (server *ShardServer) emoteChat(peer *cnet.Peer, pkt protocol.Packet) error {
2023-06-28 02:49:11 +00:00
var chat protocol.SP_CL2FE_REQ_PC_AVATAR_EMOTES_CHAT
pkt.Decode(&chat)
plr, ok := peer.UserData().(*entity.Player)
if !ok || plr == nil {
return fmt.Errorf("emoteChat: plr is nil")
2023-06-28 02:49:11 +00:00
}
// spread message
2023-06-28 03:05:08 +00:00
return server.sendAllPacket(plr, protocol.P_FE2CL_REP_PC_AVATAR_EMOTES_CHAT, protocol.SP_FE2CL_REP_PC_AVATAR_EMOTES_CHAT{
2023-06-28 02:49:11 +00:00
IID_From: int32(plr.PlayerID),
IEmoteCode: chat.IEmoteCode,
})
}