网关客户端协议代理功能加入二级pb数据解析

This commit is contained in:
flswld
2023-03-14 18:30:07 +08:00
parent 2c35fc0df4
commit cd922d1a38
11 changed files with 331 additions and 77 deletions

View File

@@ -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 {