mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-04 18:32:26 +08:00
网关客户端协议代理功能加入二级pb数据解析
This commit is contained in:
@@ -256,7 +256,7 @@ func (d *Dao) QueryChatMsgListByUid(uid uint32) ([]*model.ChatMsg, error) {
|
||||
context.TODO(),
|
||||
bson.D{{"$or", []bson.D{{{"ToUid", uid}}, {{"Uid", uid}}}}},
|
||||
options.Find().SetLimit(MaxQueryChatMsgLen),
|
||||
options.Find().SetSort(bson.M{"Time": -1}),
|
||||
options.Find().SetSort(bson.M{"Time": 1}),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -9,6 +9,8 @@ import (
|
||||
"hk4e/gs/model"
|
||||
)
|
||||
|
||||
// 玩家游戏内GM命令格式解析模块
|
||||
|
||||
// HelpCommand 帮助命令
|
||||
func (c *CommandManager) HelpCommand(cmd *CommandMessage) {
|
||||
c.SendMessage(cmd.Executor,
|
||||
@@ -158,13 +160,13 @@ func (c *CommandManager) TeleportCommand(cmd *CommandMessage) {
|
||||
c.SendMessage(cmd.Executor, "已将玩家 UID:%v 请求加入目标玩家 UID:%v 的世界。", player.PlayerID, targetUid)
|
||||
} else {
|
||||
// 传送玩家至目标玩家的位置
|
||||
c.GMTeleportPlayer(player.PlayerID, target.SceneId, target.Pos.X, target.Pos.Y, target.Pos.Z)
|
||||
c.gmCmd.GMTeleportPlayer(player.PlayerID, target.SceneId, target.Pos.X, target.Pos.Y, target.Pos.Z)
|
||||
// 发送消息给执行者
|
||||
c.SendMessage(cmd.Executor, "已将玩家 UID:%v 传送至 目标玩家 UID:%v。", player.PlayerID, targetUid)
|
||||
}
|
||||
} else {
|
||||
// 传送玩家至指定的位置
|
||||
c.GMTeleportPlayer(player.PlayerID, sceneId, pos.X, pos.Y, pos.Z)
|
||||
c.gmCmd.GMTeleportPlayer(player.PlayerID, sceneId, pos.X, pos.Y, pos.Z)
|
||||
// 发送消息给执行者
|
||||
c.SendMessage(cmd.Executor, "已将玩家 UID:%v 传送至 场景:%v, X:%.2f, Y:%.2f, Z:%.2f。", player.PlayerID, sceneId, pos.X, pos.Y, pos.Z)
|
||||
}
|
||||
@@ -247,7 +249,7 @@ func (c *CommandManager) GiveCommand(cmd *CommandMessage) {
|
||||
_, ok := GAME_MANAGER.GetAllItemDataConfig()[int32(id)]
|
||||
if ok {
|
||||
// 给予玩家物品
|
||||
c.GMAddUserItem(player.PlayerID, id, count)
|
||||
c.gmCmd.GMAddUserItem(player.PlayerID, id, count)
|
||||
c.SendMessage(cmd.Executor, "已给予玩家 UID:%v, 物品ID:%v 数量:%v。", player.PlayerID, id, count)
|
||||
return
|
||||
}
|
||||
@@ -255,7 +257,7 @@ func (c *CommandManager) GiveCommand(cmd *CommandMessage) {
|
||||
_, ok = GAME_MANAGER.GetAllWeaponDataConfig()[int32(id)]
|
||||
if ok {
|
||||
// 给予玩家武器
|
||||
c.GMAddUserWeapon(player.PlayerID, id, count)
|
||||
c.gmCmd.GMAddUserWeapon(player.PlayerID, id, count)
|
||||
c.SendMessage(cmd.Executor, "已给予玩家 UID:%v, 武器 物品ID:%v 数量:%v。", player.PlayerID, id, count)
|
||||
return
|
||||
|
||||
@@ -264,7 +266,7 @@ func (c *CommandManager) GiveCommand(cmd *CommandMessage) {
|
||||
_, ok = GAME_MANAGER.GetAllReliquaryDataConfig()[int32(id)]
|
||||
if ok {
|
||||
// 给予玩家圣遗物
|
||||
c.GMAddUserReliquary(player.PlayerID, id, count)
|
||||
c.gmCmd.GMAddUserReliquary(player.PlayerID, id, count)
|
||||
c.SendMessage(cmd.Executor, "已给予玩家 UID:%v, 圣遗物 物品ID:%v 数量:%v。", player.PlayerID, id, count)
|
||||
return
|
||||
|
||||
@@ -273,21 +275,21 @@ func (c *CommandManager) GiveCommand(cmd *CommandMessage) {
|
||||
_, ok = GAME_MANAGER.GetAllAvatarDataConfig()[int32(id)]
|
||||
if ok {
|
||||
// 给予玩家角色
|
||||
c.GMAddUserAvatar(player.PlayerID, id)
|
||||
c.gmCmd.GMAddUserAvatar(player.PlayerID, id)
|
||||
c.SendMessage(cmd.Executor, "已给予玩家 UID:%v, 角色ID:%v 数量:%v。", player.PlayerID, id, count)
|
||||
return
|
||||
}
|
||||
// 判断是否为时装
|
||||
if gdconf.GetAvatarCostumeDataById(int32(id)) != nil {
|
||||
// 给予玩家角色
|
||||
c.GMAddUserCostume(player.PlayerID, id)
|
||||
// 给予玩家时装
|
||||
c.gmCmd.GMAddUserCostume(player.PlayerID, id)
|
||||
c.SendMessage(cmd.Executor, "已给予玩家 UID:%v, 时装ID:%v 数量:%v。", player.PlayerID, id, count)
|
||||
return
|
||||
}
|
||||
// 判断是否为风之翼
|
||||
if gdconf.GetAvatarFlycloakDataById(int32(id)) != nil {
|
||||
// 给予玩家角色
|
||||
c.GMAddUserFlycloak(player.PlayerID, id)
|
||||
// 给予玩家风之翼
|
||||
c.gmCmd.GMAddUserFlycloak(player.PlayerID, id)
|
||||
c.SendMessage(cmd.Executor, "已给予玩家 UID:%v, 风之翼ID:%v 数量:%v。", player.PlayerID, id, count)
|
||||
return
|
||||
}
|
||||
@@ -295,31 +297,31 @@ func (c *CommandManager) GiveCommand(cmd *CommandMessage) {
|
||||
c.SendMessage(cmd.Executor, "ID:%v 不存在。", id)
|
||||
case "item", "物品":
|
||||
// 给予玩家所有物品
|
||||
c.GMAddUserAllItem(player.PlayerID, count)
|
||||
c.gmCmd.GMAddUserAllItem(player.PlayerID, count)
|
||||
c.SendMessage(cmd.Executor, "已给予玩家 UID:%v, 所有物品 数量:%v。", player.PlayerID, count)
|
||||
case "weapon", "武器":
|
||||
// 给予玩家所有武器
|
||||
c.GMAddUserAllWeapon(player.PlayerID, count)
|
||||
c.gmCmd.GMAddUserAllWeapon(player.PlayerID, count)
|
||||
c.SendMessage(cmd.Executor, "已给予玩家 UID:%v, 所有武器 数量:%v。", player.PlayerID, count)
|
||||
case "reliquary", "圣遗物":
|
||||
// 给予玩家所有圣遗物
|
||||
c.GMAddUserAllReliquary(player.PlayerID, count)
|
||||
c.gmCmd.GMAddUserAllReliquary(player.PlayerID, count)
|
||||
c.SendMessage(cmd.Executor, "已给予玩家 UID:%v, 所有圣遗物 数量:%v。", player.PlayerID, count)
|
||||
case "avatar", "角色":
|
||||
// 给予玩家所有角色
|
||||
c.GMAddUserAllAvatar(player.PlayerID)
|
||||
c.gmCmd.GMAddUserAllAvatar(player.PlayerID)
|
||||
c.SendMessage(cmd.Executor, "已给予玩家 UID:%v, 所有角色。", player.PlayerID)
|
||||
case "costume", "时装":
|
||||
// 给予玩家所有角色
|
||||
c.GMAddUserAllCostume(player.PlayerID)
|
||||
// 给予玩家所有时装
|
||||
c.gmCmd.GMAddUserAllCostume(player.PlayerID)
|
||||
c.SendMessage(cmd.Executor, "已给予玩家 UID:%v, 所有时装。", player.PlayerID)
|
||||
case "flycloak", "风之翼":
|
||||
// 给予玩家所有角色
|
||||
c.GMAddUserAllFlycloak(player.PlayerID)
|
||||
// 给予玩家所有风之翼
|
||||
c.gmCmd.GMAddUserAllFlycloak(player.PlayerID)
|
||||
c.SendMessage(cmd.Executor, "已给予玩家 UID:%v, 所有风之翼。", player.PlayerID)
|
||||
case "all", "全部":
|
||||
// 给予玩家所有内容
|
||||
c.GMAddUserAllEvery(player.PlayerID, count, count) // TODO 武器额外获取数量
|
||||
c.gmCmd.GMAddUserAllEvery(player.PlayerID, count) // TODO 武器额外获取数量
|
||||
c.SendMessage(cmd.Executor, "已给予玩家 UID:%v, 所有内容。", player.PlayerID)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,16 @@ import (
|
||||
"hk4e/protocol/proto"
|
||||
)
|
||||
|
||||
// GM函数模块
|
||||
// GM函数只支持基本类型的简单参数传入
|
||||
|
||||
type GMCmd struct {
|
||||
}
|
||||
|
||||
// 玩家通用GM指令
|
||||
|
||||
// GMTeleportPlayer 传送玩家
|
||||
func (c *CommandManager) GMTeleportPlayer(userId, sceneId uint32, posX, posY, posZ float64) {
|
||||
func (g *GMCmd) GMTeleportPlayer(userId, sceneId uint32, posX, posY, posZ float64) {
|
||||
player := USER_MANAGER.GetOnlineUser(userId)
|
||||
if player == nil {
|
||||
logger.Error("player is nil, uid: %v", userId)
|
||||
@@ -25,7 +33,7 @@ func (c *CommandManager) GMTeleportPlayer(userId, sceneId uint32, posX, posY, po
|
||||
}
|
||||
|
||||
// GMAddUserItem 给予玩家物品
|
||||
func (c *CommandManager) GMAddUserItem(userId, itemId, itemCount uint32) {
|
||||
func (g *GMCmd) GMAddUserItem(userId, itemId, itemCount uint32) {
|
||||
GAME_MANAGER.AddUserItem(userId, []*ChangeItem{
|
||||
{
|
||||
ItemId: itemId,
|
||||
@@ -35,7 +43,7 @@ func (c *CommandManager) GMAddUserItem(userId, itemId, itemCount uint32) {
|
||||
}
|
||||
|
||||
// GMAddUserWeapon 给予玩家武器
|
||||
func (c *CommandManager) GMAddUserWeapon(userId, itemId, itemCount uint32) {
|
||||
func (g *GMCmd) GMAddUserWeapon(userId, itemId, itemCount uint32) {
|
||||
// 武器数量
|
||||
for i := uint32(0); i < itemCount; i++ {
|
||||
// 给予武器
|
||||
@@ -44,7 +52,7 @@ func (c *CommandManager) GMAddUserWeapon(userId, itemId, itemCount uint32) {
|
||||
}
|
||||
|
||||
// GMAddUserReliquary 给予玩家圣遗物
|
||||
func (c *CommandManager) GMAddUserReliquary(userId, itemId, itemCount uint32) {
|
||||
func (g *GMCmd) GMAddUserReliquary(userId, itemId, itemCount uint32) {
|
||||
// 圣遗物数量
|
||||
for i := uint32(0); i < itemCount; i++ {
|
||||
// 给予圣遗物
|
||||
@@ -53,7 +61,7 @@ func (c *CommandManager) GMAddUserReliquary(userId, itemId, itemCount uint32) {
|
||||
}
|
||||
|
||||
// GMAddUserAvatar 给予玩家角色
|
||||
func (c *CommandManager) GMAddUserAvatar(userId, avatarId uint32) {
|
||||
func (g *GMCmd) GMAddUserAvatar(userId, avatarId uint32) {
|
||||
// 添加角色
|
||||
GAME_MANAGER.AddUserAvatar(userId, avatarId)
|
||||
// TODO 设置角色 等以后做到角色升级之类的再说
|
||||
@@ -61,23 +69,19 @@ func (c *CommandManager) GMAddUserAvatar(userId, avatarId uint32) {
|
||||
}
|
||||
|
||||
// GMAddUserCostume 给予玩家时装
|
||||
func (c *CommandManager) GMAddUserCostume(userId, costumeId uint32) {
|
||||
func (g *GMCmd) GMAddUserCostume(userId, costumeId uint32) {
|
||||
// 添加时装
|
||||
GAME_MANAGER.AddUserCostume(userId, costumeId)
|
||||
}
|
||||
|
||||
// GMAddUserFlycloak 给予玩家风之翼
|
||||
func (c *CommandManager) GMAddUserFlycloak(userId, flycloakId uint32) {
|
||||
func (g *GMCmd) GMAddUserFlycloak(userId, flycloakId uint32) {
|
||||
// 添加风之翼
|
||||
GAME_MANAGER.AddUserFlycloak(userId, flycloakId)
|
||||
}
|
||||
|
||||
// GMAddUserAllItem 给予玩家所有物品
|
||||
func (c *CommandManager) GMAddUserAllItem(userId, itemCount uint32) {
|
||||
// 猜猜这样做为啥不行?
|
||||
// for itemId := range GAME_MANAGER.GetAllItemDataConfig() {
|
||||
// c.GMAddUserItem(userId, uint32(itemId), itemCount)
|
||||
// }
|
||||
func (g *GMCmd) GMAddUserAllItem(userId, itemCount uint32) {
|
||||
itemList := make([]*ChangeItem, 0)
|
||||
for itemId := range GAME_MANAGER.GetAllItemDataConfig() {
|
||||
itemList = append(itemList, &ChangeItem{
|
||||
@@ -89,57 +93,59 @@ func (c *CommandManager) GMAddUserAllItem(userId, itemCount uint32) {
|
||||
}
|
||||
|
||||
// GMAddUserAllWeapon 给予玩家所有武器
|
||||
func (c *CommandManager) GMAddUserAllWeapon(userId, itemCount uint32) {
|
||||
func (g *GMCmd) GMAddUserAllWeapon(userId, itemCount uint32) {
|
||||
for itemId := range GAME_MANAGER.GetAllWeaponDataConfig() {
|
||||
c.GMAddUserWeapon(userId, uint32(itemId), itemCount)
|
||||
g.GMAddUserWeapon(userId, uint32(itemId), itemCount)
|
||||
}
|
||||
}
|
||||
|
||||
// GMAddUserAllReliquary 给予玩家所有圣遗物
|
||||
func (c *CommandManager) GMAddUserAllReliquary(userId, itemCount uint32) {
|
||||
func (g *GMCmd) GMAddUserAllReliquary(userId, itemCount uint32) {
|
||||
for itemId := range GAME_MANAGER.GetAllReliquaryDataConfig() {
|
||||
c.GMAddUserReliquary(userId, uint32(itemId), itemCount)
|
||||
g.GMAddUserReliquary(userId, uint32(itemId), itemCount)
|
||||
}
|
||||
}
|
||||
|
||||
// GMAddUserAllAvatar 给予玩家所有角色
|
||||
func (c *CommandManager) GMAddUserAllAvatar(userId uint32) {
|
||||
func (g *GMCmd) GMAddUserAllAvatar(userId uint32) {
|
||||
for avatarId := range GAME_MANAGER.GetAllAvatarDataConfig() {
|
||||
c.GMAddUserAvatar(userId, uint32(avatarId))
|
||||
g.GMAddUserAvatar(userId, uint32(avatarId))
|
||||
}
|
||||
}
|
||||
|
||||
// GMAddUserAllCostume 给予玩家所有时装
|
||||
func (c *CommandManager) GMAddUserAllCostume(userId uint32) {
|
||||
func (g *GMCmd) GMAddUserAllCostume(userId uint32) {
|
||||
for costumeId := range gdconf.GetAvatarCostumeDataMap() {
|
||||
c.GMAddUserCostume(userId, uint32(costumeId))
|
||||
g.GMAddUserCostume(userId, uint32(costumeId))
|
||||
}
|
||||
}
|
||||
|
||||
// GMAddUserAllFlycloak 给予玩家所有风之翼
|
||||
func (c *CommandManager) GMAddUserAllFlycloak(userId uint32) {
|
||||
func (g *GMCmd) GMAddUserAllFlycloak(userId uint32) {
|
||||
for flycloakId := range gdconf.GetAvatarFlycloakDataMap() {
|
||||
c.GMAddUserFlycloak(userId, uint32(flycloakId))
|
||||
g.GMAddUserFlycloak(userId, uint32(flycloakId))
|
||||
}
|
||||
}
|
||||
|
||||
// GMAddUserAllEvery 给予玩家所有内容
|
||||
func (c *CommandManager) GMAddUserAllEvery(userId uint32, itemCount uint32, weaponCount uint32) {
|
||||
func (g *GMCmd) GMAddUserAllEvery(userId, itemCount uint32) {
|
||||
// 给予玩家所有物品
|
||||
c.GMAddUserAllItem(userId, itemCount)
|
||||
g.GMAddUserAllItem(userId, itemCount)
|
||||
// 给予玩家所有武器
|
||||
c.GMAddUserAllWeapon(userId, itemCount)
|
||||
g.GMAddUserAllWeapon(userId, itemCount)
|
||||
// 给予玩家所有圣遗物
|
||||
c.GMAddUserAllReliquary(userId, itemCount)
|
||||
g.GMAddUserAllReliquary(userId, itemCount)
|
||||
// 给予玩家所有角色
|
||||
c.GMAddUserAllAvatar(userId)
|
||||
g.GMAddUserAllAvatar(userId)
|
||||
// 给予玩家所有时装
|
||||
c.GMAddUserAllCostume(userId)
|
||||
g.GMAddUserAllCostume(userId)
|
||||
// 给予玩家所有风之翼
|
||||
c.GMAddUserAllFlycloak(userId)
|
||||
g.GMAddUserAllFlycloak(userId)
|
||||
}
|
||||
|
||||
func (c *CommandManager) ChangePlayerCmdPerm(userId uint32, cmdPerm uint8) {
|
||||
// 系统级GM指令
|
||||
|
||||
func (g *GMCmd) ChangePlayerCmdPerm(userId uint32, cmdPerm uint8) {
|
||||
player := USER_MANAGER.GetOnlineUser(userId)
|
||||
if player == nil {
|
||||
logger.Error("player is nil, uid: %v", userId)
|
||||
@@ -148,13 +154,13 @@ func (c *CommandManager) ChangePlayerCmdPerm(userId uint32, cmdPerm uint8) {
|
||||
player.CmdPerm = cmdPerm
|
||||
}
|
||||
|
||||
func (c *CommandManager) ReloadGameDataConfig() {
|
||||
func (g *GMCmd) ReloadGameDataConfig() {
|
||||
LOCAL_EVENT_MANAGER.GetLocalEventChan() <- &LocalEvent{
|
||||
EventId: ReloadGameDataConfig,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *CommandManager) XLuaDebug(userId uint32, luacBase64 string) {
|
||||
func (g *GMCmd) XLuaDebug(userId uint32, luacBase64 string) {
|
||||
logger.Debug("xlua debug, uid: %v, luac: %v", userId, luacBase64)
|
||||
player := USER_MANAGER.GetOnlineUser(userId)
|
||||
if player == nil {
|
||||
|
||||
@@ -2,6 +2,7 @@ package game
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -9,7 +10,7 @@ import (
|
||||
"hk4e/pkg/logger"
|
||||
)
|
||||
|
||||
// 命令管理器
|
||||
// GM命令管理器模块
|
||||
|
||||
// CommandPerm 命令权限等级
|
||||
// 0 为普通玩家 数越大权限越大
|
||||
@@ -42,6 +43,8 @@ type CommandManager struct {
|
||||
commandFuncRouter map[string]CommandFunc // 记录命令处理函数
|
||||
commandPermMap map[string]CommandPerm // 记录命令对应的权限
|
||||
commandTextInput chan *CommandMessage // 传输要处理的命令文本
|
||||
gmCmd *GMCmd
|
||||
gmCmdRefValue reflect.Value
|
||||
}
|
||||
|
||||
// NewCommandManager 新建命令管理器
|
||||
@@ -50,6 +53,8 @@ func NewCommandManager() *CommandManager {
|
||||
// 初始化
|
||||
r.commandTextInput = make(chan *CommandMessage, 1000)
|
||||
r.InitRouter() // 初始化路由
|
||||
r.gmCmd = new(GMCmd)
|
||||
r.gmCmdRefValue = reflect.ValueOf(r.gmCmd)
|
||||
return r
|
||||
}
|
||||
|
||||
@@ -128,21 +133,117 @@ func (c *CommandManager) InputCommand(executor any, text string) {
|
||||
c.commandTextInput <- &CommandMessage{Executor: executor, Text: text}
|
||||
}
|
||||
|
||||
func (c *CommandManager) CallGMCmd(funcName string, paramList []string) bool {
|
||||
fn := c.gmCmdRefValue.MethodByName(funcName)
|
||||
if !fn.IsValid() {
|
||||
return false
|
||||
}
|
||||
if fn.Type().NumIn() != len(paramList) {
|
||||
return false
|
||||
}
|
||||
in := make([]reflect.Value, fn.Type().NumIn())
|
||||
for i := 0; i < fn.Type().NumIn(); i++ {
|
||||
kind := fn.Type().In(i).Kind()
|
||||
param := paramList[i]
|
||||
var value reflect.Value
|
||||
switch kind {
|
||||
case reflect.Int:
|
||||
val, err := strconv.ParseInt(param, 10, 64)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
value = reflect.ValueOf(int(val))
|
||||
case reflect.Uint:
|
||||
val, err := strconv.ParseUint(param, 10, 64)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
value = reflect.ValueOf(uint(val))
|
||||
case reflect.Int8:
|
||||
val, err := strconv.ParseInt(param, 10, 8)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
value = reflect.ValueOf(int8(val))
|
||||
case reflect.Uint8:
|
||||
val, err := strconv.ParseUint(param, 10, 8)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
value = reflect.ValueOf(uint8(val))
|
||||
case reflect.Int16:
|
||||
val, err := strconv.ParseInt(param, 10, 16)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
value = reflect.ValueOf(int16(val))
|
||||
case reflect.Uint16:
|
||||
val, err := strconv.ParseUint(param, 10, 16)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
value = reflect.ValueOf(uint16(val))
|
||||
case reflect.Int32:
|
||||
val, err := strconv.ParseInt(param, 10, 32)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
value = reflect.ValueOf(int32(val))
|
||||
case reflect.Uint32:
|
||||
val, err := strconv.ParseUint(param, 10, 32)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
value = reflect.ValueOf(uint32(val))
|
||||
case reflect.Int64:
|
||||
val, err := strconv.ParseInt(param, 10, 64)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
value = reflect.ValueOf(val)
|
||||
case reflect.Uint64:
|
||||
val, err := strconv.ParseUint(param, 10, 64)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
value = reflect.ValueOf(val)
|
||||
case reflect.Float32:
|
||||
val, err := strconv.ParseFloat(param, 32)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
value = reflect.ValueOf(float32(val))
|
||||
case reflect.Float64:
|
||||
val, err := strconv.ParseFloat(param, 64)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
value = reflect.ValueOf(val)
|
||||
case reflect.Bool:
|
||||
val, err := strconv.ParseBool(param)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
value = reflect.ValueOf(val)
|
||||
case reflect.String:
|
||||
value = reflect.ValueOf(param)
|
||||
default:
|
||||
return false
|
||||
}
|
||||
in[i] = value
|
||||
}
|
||||
fn.Call(in)
|
||||
return true
|
||||
}
|
||||
|
||||
// HandleCommand 处理命令
|
||||
// 主协程接收到命令消息后执行
|
||||
func (c *CommandManager) HandleCommand(cmd *CommandMessage) {
|
||||
// 直接执行GM函数
|
||||
if cmd.FuncName != "" {
|
||||
logger.Info("run gm cmd, FuncName: %v, Param: %v", cmd.FuncName, cmd.Param)
|
||||
// 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])
|
||||
}
|
||||
// 反射调用command_gm.go中的函数并反射解析传入参数类型
|
||||
c.CallGMCmd(cmd.FuncName, cmd.Param)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,6 @@ import (
|
||||
pb "google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
// TODO 暂时只做3.2协议的兼容了 在GS这边处理不同版本的协议太烦人了 有机会全部改到GATE那边处理 GS所有接收和发送的都应该是3.2版本的协议
|
||||
|
||||
var cmdProtoMap *cmd.CmdProtoMap = nil
|
||||
|
||||
func DoForward[IET model.InvokeEntryType](player *model.Player, invokeHandler *model.InvokeHandler[IET],
|
||||
|
||||
@@ -65,6 +65,10 @@ func (g *GameManager) AddUserReliquary(userId uint32, itemId uint32) uint64 {
|
||||
mainPropId := uint32(reliquaryMainConfig.MainPropId)
|
||||
// 玩家添加圣遗物
|
||||
dbReliquary := player.GetDbReliquary()
|
||||
// 校验背包圣遗物容量
|
||||
if dbReliquary.GetReliquaryMapLen() > constant.STORE_PACK_LIMIT_RELIQUARY {
|
||||
return 0
|
||||
}
|
||||
dbReliquary.AddReliquary(player, itemId, reliquaryId, mainPropId)
|
||||
reliquary := dbReliquary.GetReliquary(reliquaryId)
|
||||
if reliquary == nil {
|
||||
|
||||
@@ -33,6 +33,10 @@ func (g *GameManager) AddUserWeapon(userId uint32, itemId uint32) uint64 {
|
||||
}
|
||||
weaponId := uint64(g.snowflake.GenId())
|
||||
dbWeapon := player.GetDbWeapon()
|
||||
// 校验背包武器容量
|
||||
if dbWeapon.GetWeaponMapLen() > constant.STORE_PACK_LIMIT_WEAPON {
|
||||
return 0
|
||||
}
|
||||
dbWeapon.AddWeapon(player, itemId, weaponId)
|
||||
weapon := dbWeapon.GetWeapon(weaponId)
|
||||
if weapon == nil {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"hk4e/common/constant"
|
||||
"hk4e/gdconf"
|
||||
"hk4e/pkg/logger"
|
||||
)
|
||||
@@ -32,6 +31,10 @@ type Reliquary struct {
|
||||
Guid uint64 `bson:"-" msgpack:"-"`
|
||||
}
|
||||
|
||||
func (r *DbReliquary) GetReliquaryMapLen() int {
|
||||
return len(r.ReliquaryMap)
|
||||
}
|
||||
|
||||
func (r *DbReliquary) InitAllReliquary(player *Player) {
|
||||
for _, reliquary := range r.ReliquaryMap {
|
||||
r.InitReliquary(player, reliquary)
|
||||
@@ -69,10 +72,6 @@ func (r *DbReliquary) GetReliquary(reliquaryId uint64) *Reliquary {
|
||||
}
|
||||
|
||||
func (r *DbReliquary) AddReliquary(player *Player, itemId uint32, reliquaryId uint64, mainPropId uint32) {
|
||||
// 校验背包圣遗物容量
|
||||
if len(r.ReliquaryMap) > constant.STORE_PACK_LIMIT_RELIQUARY {
|
||||
return
|
||||
}
|
||||
itemDataConfig := gdconf.GetItemDataById(int32(itemId))
|
||||
if itemDataConfig == nil {
|
||||
logger.Error("reliquary config is nil, itemId: %v", itemId)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"hk4e/common/constant"
|
||||
"hk4e/gdconf"
|
||||
"hk4e/pkg/logger"
|
||||
)
|
||||
@@ -32,6 +31,10 @@ type Weapon struct {
|
||||
Guid uint64 `bson:"-" msgpack:"-"`
|
||||
}
|
||||
|
||||
func (w *DbWeapon) GetWeaponMapLen() int {
|
||||
return len(w.WeaponMap)
|
||||
}
|
||||
|
||||
func (w *DbWeapon) InitAllWeapon(player *Player) {
|
||||
for _, weapon := range w.WeaponMap {
|
||||
w.InitWeapon(player, weapon)
|
||||
@@ -63,10 +66,6 @@ func (w *DbWeapon) GetWeapon(weaponId uint64) *Weapon {
|
||||
}
|
||||
|
||||
func (w *DbWeapon) AddWeapon(player *Player, itemId uint32, weaponId uint64) {
|
||||
// 校验背包武器容量
|
||||
if len(w.WeaponMap) > constant.STORE_PACK_LIMIT_WEAPON {
|
||||
return
|
||||
}
|
||||
itemDataConfig := gdconf.GetItemDataById(int32(itemId))
|
||||
if itemDataConfig == nil {
|
||||
logger.Error("weapon config is nil, itemId: %v", itemId)
|
||||
|
||||
Reference in New Issue
Block a user