mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-04 14:22:26 +08:00
GM客户端XLUA调试
This commit is contained in:
@@ -18,18 +18,6 @@ func (c *CommandManager) HelpCommand(cmd *CommandMessage) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// OpCommand 给予权限命令
|
|
||||||
func (c *CommandManager) OpCommand(cmd *CommandMessage) {
|
|
||||||
player, ok := cmd.Executor.(*model.Player)
|
|
||||||
if !ok {
|
|
||||||
c.SendMessage(cmd.Executor, "只有玩家才能执行此命令。")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
player.IsGM = 1
|
|
||||||
c.SendMessage(cmd.Executor, "权限修改完毕,现在你是GM啦~")
|
|
||||||
}
|
|
||||||
|
|
||||||
// TeleportCommand 传送玩家命令
|
// TeleportCommand 传送玩家命令
|
||||||
// tp [--u <uid>] [--s <sceneId>] {--t <targetUid> --x <posX> | --y <posY> | --z <posZ>}
|
// tp [--u <uid>] [--s <sceneId>] {--t <targetUid> --x <posX> | --y <posY> | --z <posZ>}
|
||||||
func (c *CommandManager) TeleportCommand(cmd *CommandMessage) {
|
func (c *CommandManager) TeleportCommand(cmd *CommandMessage) {
|
||||||
@@ -336,20 +324,16 @@ func (c *CommandManager) GiveCommand(cmd *CommandMessage) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReloadConfigCommand 帮助命令
|
|
||||||
func (c *CommandManager) ReloadConfigCommand(cmd *CommandMessage) {
|
|
||||||
LOCAL_EVENT_MANAGER.GetLocalEventChan() <- &LocalEvent{
|
|
||||||
EventId: ReloadGameDataConfig,
|
|
||||||
}
|
|
||||||
|
|
||||||
c.SendMessage(cmd.Executor, "成功发送重载配置请求。")
|
|
||||||
}
|
|
||||||
|
|
||||||
// GcgCommand Gcg测试命令
|
// GcgCommand Gcg测试命令
|
||||||
func (c *CommandManager) GcgCommand(cmd *CommandMessage) {
|
func (c *CommandManager) GcgCommand(cmd *CommandMessage) {
|
||||||
player := cmd.Executor.(*model.Player)
|
player := cmd.Executor.(*model.Player)
|
||||||
|
|
||||||
GAME_MANAGER.GCGStartChallenge(player)
|
GAME_MANAGER.GCGStartChallenge(player)
|
||||||
|
|
||||||
c.SendMessage(cmd.Executor, "收到命令")
|
c.SendMessage(cmd.Executor, "收到命令")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// XLuaDebugCommand 主动开启客户端XLUA调试命令
|
||||||
|
func (c *CommandManager) XLuaDebugCommand(cmd *CommandMessage) {
|
||||||
|
player := cmd.Executor.(*model.Player)
|
||||||
|
player.XLuaDebug = true
|
||||||
|
c.SendMessage(cmd.Executor, "XLua Debug Enable")
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
package game
|
package game
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/base64"
|
||||||
|
|
||||||
"hk4e/gdconf"
|
"hk4e/gdconf"
|
||||||
"hk4e/gs/model"
|
"hk4e/gs/model"
|
||||||
"hk4e/pkg/logger"
|
"hk4e/pkg/logger"
|
||||||
|
"hk4e/protocol/cmd"
|
||||||
"hk4e/protocol/proto"
|
"hk4e/protocol/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -135,3 +138,46 @@ func (c *CommandManager) GMAddUserAllEvery(userId uint32, itemCount uint32, weap
|
|||||||
// 给予玩家所有风之翼
|
// 给予玩家所有风之翼
|
||||||
c.GMAddUserAllFlycloak(userId)
|
c.GMAddUserAllFlycloak(userId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *CommandManager) ChangePlayerCmdPerm(userId uint32, cmdPerm uint8) {
|
||||||
|
player := USER_MANAGER.GetOnlineUser(userId)
|
||||||
|
if player == nil {
|
||||||
|
logger.Error("player is nil, uid: %v", userId)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
player.CmdPerm = cmdPerm
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *CommandManager) ReloadGameDataConfig() {
|
||||||
|
LOCAL_EVENT_MANAGER.GetLocalEventChan() <- &LocalEvent{
|
||||||
|
EventId: ReloadGameDataConfig,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *CommandManager) XLuaDebug(userId uint32, luacBase64 string) {
|
||||||
|
logger.Debug("xlua debug, uid: %v, luac: %v", userId, luacBase64)
|
||||||
|
player := USER_MANAGER.GetOnlineUser(userId)
|
||||||
|
if player == nil {
|
||||||
|
logger.Error("player is nil, uid: %v", userId)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 只有在线玩家主动开启之后才能发送
|
||||||
|
if !player.XLuaDebug {
|
||||||
|
logger.Error("player xlua debug not enable, uid: %v", userId)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
luac, err := base64.StdEncoding.DecodeString(luacBase64)
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("decode luac error: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
GAME_MANAGER.SendMsg(cmd.WindSeedClientNotify, player.PlayerID, 0, &proto.WindSeedClientNotify{
|
||||||
|
Notify: &proto.WindSeedClientNotify_AreaNotify_{
|
||||||
|
AreaNotify: &proto.WindSeedClientNotify_AreaNotify{
|
||||||
|
AreaCode: luac,
|
||||||
|
AreaId: 1,
|
||||||
|
AreaType: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package game
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"hk4e/gs/model"
|
"hk4e/gs/model"
|
||||||
@@ -68,15 +69,14 @@ func (c *CommandManager) InitRouter() {
|
|||||||
{
|
{
|
||||||
// 权限等级 0: 普通玩家
|
// 权限等级 0: 普通玩家
|
||||||
c.RegisterRouter(CommandPermNormal, c.HelpCommand, "help")
|
c.RegisterRouter(CommandPermNormal, c.HelpCommand, "help")
|
||||||
c.RegisterRouter(CommandPermNormal, c.OpCommand, "op")
|
|
||||||
c.RegisterRouter(CommandPermNormal, c.TeleportCommand, "teleport", "tp")
|
c.RegisterRouter(CommandPermNormal, c.TeleportCommand, "teleport", "tp")
|
||||||
c.RegisterRouter(CommandPermNormal, c.GiveCommand, "give", "item")
|
c.RegisterRouter(CommandPermNormal, c.GiveCommand, "give", "item")
|
||||||
// c.RegisterRouter(CommandPermNormal, c.GcgCommand, "gcg")
|
// c.RegisterRouter(CommandPermNormal, c.GcgCommand, "gcg")
|
||||||
|
c.RegisterRouter(CommandPermNormal, c.XLuaDebugCommand, "xluadebug")
|
||||||
}
|
}
|
||||||
// GM命令
|
// GM命令
|
||||||
{
|
{
|
||||||
// 权限等级 1: GM 1级
|
// 权限等级 1: GM 1级
|
||||||
c.RegisterRouter(CommandPermGM, c.ReloadConfigCommand, "reloadconfig")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,6 +134,15 @@ func (c *CommandManager) HandleCommand(cmd *CommandMessage) {
|
|||||||
if cmd.FuncName != "" {
|
if cmd.FuncName != "" {
|
||||||
logger.Info("run gm cmd, FuncName: %v, Param: %v", cmd.FuncName, cmd.Param)
|
logger.Info("run gm cmd, FuncName: %v, Param: %v", cmd.FuncName, cmd.Param)
|
||||||
// TODO 反射调用command_gm.go中的函数并反射解析传入参数类型
|
// TODO 反射调用command_gm.go中的函数并反射解析传入参数类型
|
||||||
|
if cmd.FuncName == "ReloadGameDataConfig" && len(cmd.Param) == 0 {
|
||||||
|
c.ReloadGameDataConfig()
|
||||||
|
} else if cmd.FuncName == "XLuaDebug" && len(cmd.Param) == 2 {
|
||||||
|
uid, err := strconv.Atoi(cmd.Param[0])
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.XLuaDebug(uint32(uid), cmd.Param[1])
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,9 +226,9 @@ func (c *CommandManager) ExecCommand(cmd *CommandMessage) {
|
|||||||
|
|
||||||
// 判断玩家的权限是否符合要求
|
// 判断玩家的权限是否符合要求
|
||||||
player, ok := executor.(*model.Player)
|
player, ok := executor.(*model.Player)
|
||||||
if ok && player.IsGM < uint8(cmdPerm) {
|
if ok && player.CmdPerm < uint8(cmdPerm) {
|
||||||
logger.Debug("exec command permission denied, uid: %v, isGM: %v", player.PlayerID, player.IsGM)
|
logger.Debug("exec command permission denied, uid: %v, CmdPerm: %v", player.PlayerID, player.CmdPerm)
|
||||||
c.SendMessage(player, "权限不足,该命令需要%v级权限。\n你目前的权限等级:%v", cmdPerm, player.IsGM)
|
c.SendMessage(player, "权限不足,该命令需要%v级权限。\n你目前的权限等级:%v", cmdPerm, player.CmdPerm)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ func (u *UserManager) OnlineUser(userId uint32, clientSeq uint32, gateAppId stri
|
|||||||
u.SaveUserToRedisSync(player)
|
u.SaveUserToRedisSync(player)
|
||||||
}
|
}
|
||||||
// 解离线玩家数据分布式锁
|
// 解离线玩家数据分布式锁
|
||||||
u.dao.DistUnlock(player.PlayerID)
|
u.dao.DistUnlock(userId)
|
||||||
if player != nil {
|
if player != nil {
|
||||||
u.ChangeUserDbState(player, model.DbNormal)
|
u.ChangeUserDbState(player, model.DbNormal)
|
||||||
player.ChatMsgMap = u.LoadUserChatMsgFromDbSync(userId)
|
player.ChatMsgMap = u.LoadUserChatMsgFromDbSync(userId)
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ type Player struct {
|
|||||||
FlyCloakList []uint32 // 风之翼列表
|
FlyCloakList []uint32 // 风之翼列表
|
||||||
CostumeList []uint32 // 角色衣装列表
|
CostumeList []uint32 // 角色衣装列表
|
||||||
SceneId uint32 // 场景
|
SceneId uint32 // 场景
|
||||||
IsGM uint8 // 管理员权限等级
|
CmdPerm uint8 // 玩家命令权限等级
|
||||||
SafePos *Vector // 在陆地时的坐标
|
SafePos *Vector // 在陆地时的坐标
|
||||||
Pos *Vector // 坐标
|
Pos *Vector // 坐标
|
||||||
Rot *Vector // 朝向
|
Rot *Vector // 朝向
|
||||||
@@ -78,6 +78,7 @@ type Player struct {
|
|||||||
FightAppId string `bson:"-" msgpack:"-"` // 战斗服务器的appid
|
FightAppId string `bson:"-" msgpack:"-"` // 战斗服务器的appid
|
||||||
GCGCurGameGuid uint32 `bson:"-" msgpack:"-"` // GCG玩家所在的游戏guid
|
GCGCurGameGuid uint32 `bson:"-" msgpack:"-"` // GCG玩家所在的游戏guid
|
||||||
GCGInfo *GCGInfo `bson:"-" msgpack:"-"` // 七圣召唤信息
|
GCGInfo *GCGInfo `bson:"-" msgpack:"-"` // 七圣召唤信息
|
||||||
|
XLuaDebug bool `bson:"-" msgpack:"-"` // 是否开启客户端XLUA调试
|
||||||
// 特殊数据
|
// 特殊数据
|
||||||
ChatMsgMap map[uint32][]*ChatMsg `bson:"-" msgpack:"-"` // 聊天信息 数据量偏大 只从db读写 不保存到redis
|
ChatMsgMap map[uint32][]*ChatMsg `bson:"-" msgpack:"-"` // 聊天信息 数据量偏大 只从db读写 不保存到redis
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ func (c *CmdProtoMap) registerAllMessage() {
|
|||||||
c.registerMessage(OpenStateUpdateNotify, &proto.OpenStateUpdateNotify{}) // 游戏功能模块开放状态更新通知
|
c.registerMessage(OpenStateUpdateNotify, &proto.OpenStateUpdateNotify{}) // 游戏功能模块开放状态更新通知
|
||||||
c.registerMessage(PlayerTimeNotify, &proto.PlayerTimeNotify{}) // 玩家累计在线时长通知
|
c.registerMessage(PlayerTimeNotify, &proto.PlayerTimeNotify{}) // 玩家累计在线时长通知
|
||||||
c.registerMessage(ServerTimeNotify, &proto.ServerTimeNotify{}) // 服务器时间通知
|
c.registerMessage(ServerTimeNotify, &proto.ServerTimeNotify{}) // 服务器时间通知
|
||||||
|
c.registerMessage(WindSeedClientNotify, &proto.WindSeedClientNotify{}) // 客户端XLUA调试通知
|
||||||
|
|
||||||
// 场景
|
// 场景
|
||||||
c.registerMessage(PlayerSetPauseReq, &proto.PlayerSetPauseReq{}) // 玩家暂停请求
|
c.registerMessage(PlayerSetPauseReq, &proto.PlayerSetPauseReq{}) // 玩家暂停请求
|
||||||
|
|||||||
Reference in New Issue
Block a user