mirror of
https://github.com/CPunch/gopenfusion.git
synced 2024-11-12 19:20:06 +00:00
added chat :D
This commit is contained in:
parent
3559d9ba9b
commit
215e313c43
56
shard/chat.go
Normal file
56
shard/chat.go
Normal file
@ -0,0 +1,56 @@
|
||||
package shard
|
||||
|
||||
import "github.com/CPunch/gopenfusion/core/protocol"
|
||||
|
||||
func (server *ShardServer) freeChat(peer *protocol.CNPeer, pkt protocol.Packet) error {
|
||||
var chat protocol.SP_CL2FE_REQ_SEND_FREECHAT_MESSAGE
|
||||
pkt.Decode(&chat)
|
||||
|
||||
// sanity check
|
||||
plr, err := server.getPlayer(peer)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// spread message
|
||||
return server.sendOthersPacket(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,
|
||||
})
|
||||
}
|
||||
|
||||
func (server *ShardServer) menuChat(peer *protocol.CNPeer, pkt protocol.Packet) error {
|
||||
var chat protocol.SP_CL2FE_REQ_SEND_MENUCHAT_MESSAGE
|
||||
pkt.Decode(&chat)
|
||||
|
||||
// sanity check
|
||||
plr, err := server.getPlayer(peer)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// spread message
|
||||
return server.sendOthersPacket(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,
|
||||
})
|
||||
}
|
||||
|
||||
func (server *ShardServer) emoteChat(peer *protocol.CNPeer, pkt protocol.Packet) error {
|
||||
var chat protocol.SP_CL2FE_REQ_PC_AVATAR_EMOTES_CHAT
|
||||
pkt.Decode(&chat)
|
||||
|
||||
// sanity check
|
||||
plr, err := server.getPlayer(peer)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// spread message
|
||||
return server.sendOthersPacket(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,
|
||||
})
|
||||
}
|
@ -11,6 +11,7 @@ func (server *ShardServer) addEntity(e entity.Entity) {
|
||||
}
|
||||
|
||||
func (server *ShardServer) removeEntity(e entity.Entity) {
|
||||
// TODO: chunk cleanup
|
||||
pos := e.GetChunk()
|
||||
server.removeEntityFromChunks(server.getViewableChunks(pos), e)
|
||||
server.getChunk(pos).RemoveEntity(e)
|
||||
|
@ -48,11 +48,14 @@ func NewShardServer(dbHndlr *db.DBHandler, redisHndlr *redis.RedisHandler, port
|
||||
}
|
||||
|
||||
server.packetHandlers = map[uint32]PacketHandler{
|
||||
protocol.P_CL2FE_REQ_PC_ENTER: server.RequestEnter,
|
||||
protocol.P_CL2FE_REQ_PC_LOADING_COMPLETE: server.LoadingComplete,
|
||||
protocol.P_CL2FE_REQ_PC_MOVE: server.playerMove,
|
||||
protocol.P_CL2FE_REQ_PC_STOP: server.playerStop,
|
||||
protocol.P_CL2FE_REQ_PC_JUMP: server.playerJump,
|
||||
protocol.P_CL2FE_REQ_PC_ENTER: server.RequestEnter,
|
||||
protocol.P_CL2FE_REQ_PC_LOADING_COMPLETE: server.LoadingComplete,
|
||||
protocol.P_CL2FE_REQ_PC_MOVE: server.playerMove,
|
||||
protocol.P_CL2FE_REQ_PC_STOP: server.playerStop,
|
||||
protocol.P_CL2FE_REQ_PC_JUMP: server.playerJump,
|
||||
protocol.P_CL2FE_REQ_SEND_FREECHAT_MESSAGE: server.freeChat,
|
||||
protocol.P_CL2FE_REQ_SEND_MENUCHAT_MESSAGE: server.menuChat,
|
||||
protocol.P_CL2FE_REQ_PC_AVATAR_EMOTES_CHAT: server.emoteChat,
|
||||
}
|
||||
|
||||
redisHndlr.RegisterShard(redis.ShardMetadata{
|
||||
|
Loading…
Reference in New Issue
Block a user