2023-06-28 02:49:11 +00:00
|
|
|
package shard
|
|
|
|
|
2023-11-28 03:23:28 +00:00
|
|
|
import (
|
|
|
|
"fmt"
|
2023-06-28 02:49:11 +00:00
|
|
|
|
2023-12-01 23:11:41 +00:00
|
|
|
"github.com/CPunch/gopenfusion/cnet"
|
2023-12-02 01:56:23 +00:00
|
|
|
"github.com/CPunch/gopenfusion/cnet/protocol"
|
2023-12-01 22:56:55 +00:00
|
|
|
"github.com/CPunch/gopenfusion/shard/entity"
|
2023-11-28 03:23:28 +00:00
|
|
|
)
|
|
|
|
|
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)
|
|
|
|
|
2023-12-01 06:56:34 +00:00
|
|
|
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)
|
|
|
|
|
2023-12-01 06:56:34 +00:00
|
|
|
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)
|
|
|
|
|
2023-12-01 06:56:34 +00:00
|
|
|
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,
|
|
|
|
})
|
|
|
|
}
|