5015 【主干】【bt】【bt2】【工具】GM工具支持修改玩家数据(支持运行自定义脚本命令GMT_Execfile)
1个文件已修改
4个文件已添加
261 ■■■■■ 已修改文件
ServerPython/CoreServerGroup/GameServer/Script/GM/Commands/GMT_Execfile.py 77 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ServerPython/CoreServerGroup/GameServer/Script/GM/GMTExec/Test.py 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/GMCommon.py 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/GMTExec/Test.py 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/RemoteQuery/GY_Query_GMTExecfile.py 91 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ServerPython/CoreServerGroup/GameServer/Script/GM/Commands/GMT_Execfile.py
New file
@@ -0,0 +1,77 @@
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
##@package GM.Commands.GMT_Execfile
#
# @todo:执行命令文件
# @author hxp
# @date 2021-05-19
# @version 1.0
#
# 详细描述: 执行命令文件
#
#-------------------------------------------------------------------------------
#"""Version = 2021-05-19 11:00"""
#-------------------------------------------------------------------------------
import GMCommon
import GameWorld
import DataRecordPack
import ChConfig
import traceback
import os
#逻辑实现(这里curPlayer = None)
## 执行逻辑
#  @param curPlayer 当前玩家 None
#  @param gmList [cmdIndex,gmAccID,forbidAccIP]
#  @return None
#  @remarks 函数详细说明.
def OnExec(orderId, gmCmdDict):
    queryType = gmCmdDict.get(GMCommon.Def_GMKey_QueryType, '')
    playerFind = gmCmdDict.get(GMCommon.Def_GMKey_PlayerFind, '')
    cmdInfo = gmCmdDict.get('cmdInfo', '')
    if not cmdInfo:
        GMCommon.GMCommandResult(orderId, gmCmdDict, GMCommon.Def_ParamErr)
        return
    if playerFind:
        if queryType == GMCommon.Def_GMKey_PlayerAccID:
            queryType = ChConfig.queryType_sqtPlayerByAccID
        elif queryType == GMCommon.Def_GMKey_PlayerName:
            queryType = ChConfig.queryType_sqtPlayerByName
        GMCommon.GMTool_MapServer_Query(queryType, orderId, playerFind, gmCmdDict, "GMTExecfile", [orderId, cmdInfo], False)
        return
    backDir = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
    execfilepath = os.path.join(backDir, "GMTExec\\%s.py" % cmdInfo)
    GameWorld.Log("GMT_Execfile: %s" % execfilepath)
    if not os.path.exists(execfilepath):
        GMCommon.GMCommandResult(orderId, gmCmdDict, GMCommon.Def_ParamErr, "%s is not exists!" % cmdInfo)
        return
    resultDict = {"cmdInfo":cmdInfo}
    try:
        execfile(execfilepath, globals(), locals())
    except:
        errMsg = traceback.format_exc()
        GameWorld.ErrLog(errMsg)
        resultDict["errMsg"] = errMsg
        GMCommon.GMCommandResult(orderId, gmCmdDict, GMCommon.Def_Unknow, resultDict)
        return
    DataRecordPack.DR_ToolGMOperate(0, "", "", "GMT_Execfile", resultDict)
    GMCommon.GMCommandResult(orderId, gmCmdDict, GMCommon.Def_Success, resultDict)
    return
ServerPython/CoreServerGroup/GameServer/Script/GM/GMTExec/Test.py
New file
@@ -0,0 +1,47 @@
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
##@package Script.GM.GMTExec.Test
#
# @todo:测试命令文件运行
# @author hxp
# @date 2021-05-19
# @version 1.0
#
# 详细描述: 测试命令文件运行
#
#-------------------------------------------------------------------------------
#"""Version = 2021-05-19 11:00"""
#-------------------------------------------------------------------------------
def runMyTest(exec_locals):
    ''' 运行命令函数
    @param exec_locals: GMT_Execfile 模块中的 DoLogic 函数 locals()
    import 其他模块需要写在此函数里,不然无法引用到
    '''
    import GameWorld
    orderId = exec_locals["orderId"]
    cmdInfo = exec_locals["cmdInfo"]
    resultDict = exec_locals["resultDict"] # 建议都进行更新结果字典记录详细处理信息,GMT_Execfile 模块会统一写入流向
    # 以下为详细处理逻辑
    GameWorld.Log("This is GameServer GMT_Execfile run %s. orderId=%s" % (cmdInfo, orderId))
    activePlayerIDList = []
    playerManager = GameWorld.GetPlayerManager()
    activePlayerCount = playerManager.GetActivePlayerCount()
    for index in xrange(activePlayerCount):
        player = playerManager.GetActivePlayerAt(index)
        if player == None or not player.GetInitOK():
            continue
        activePlayerIDList.append(player.GetPlayerID())
    resultDict.update({"activePlayerIDList":activePlayerIDList})
    return
exec_locals = locals()
if exec_locals.get("cmdInfo"):
    runMyTest(exec_locals)
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/GMCommon.py
@@ -21,6 +21,7 @@
#---------------------------------------------------------------------
import IPY_GameWorld
import GameWorld
#------------------------------------------------------------------------------ 
#gm工具返回结果类型
@@ -89,3 +90,7 @@
    
    return buffTypeList
def SendGMTResult(orderId, pack_type, result=Def_Success, retMsg=None):
    resultMsg = str([orderId, retMsg, pack_type, result])
    GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(0, 0, 0, 'GMToolResult', resultMsg, len(resultMsg))
    return
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/GMTExec/Test.py
New file
@@ -0,0 +1,41 @@
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
##@package Script.Player.RemoteQuery.GMTExec.Test
#
# @todo:测试命令文件运行
# @author hxp
# @date 2021-05-19
# @version 1.0
#
# 详细描述: 测试命令文件运行
#
#-------------------------------------------------------------------------------
#"""Version = 2021-05-19 11:00"""
#-------------------------------------------------------------------------------
def runMyTest(exec_locals):
    ''' 运行命令函数
    @param exec_locals: GY_Query_GMTExecfile 模块中的 DoLogic 函数 locals()
    import 其他模块需要写在此函数里,不然无法引用到
    '''
    import GameWorld
    orderId = exec_locals["orderId"]
    cmdInfo = exec_locals["cmdInfo"]
    curPlayer = exec_locals["curPlayer"]
    resultDict = exec_locals["resultDict"] # 建议都进行更新结果字典记录详细处理信息,GY_Query_GMTExecfile 模块会统一写入流向
    # 以下为详细处理逻辑
    GameWorld.Log("This is MameServer GMT_Execfile run %s. orderId=%s" % (cmdInfo, orderId), curPlayer.GetPlayerID())
    resultDict.update({"LV":curPlayer.GetLV(), "PlayerID":curPlayer.GetPlayerID()})
    return
exec_locals = locals()
if exec_locals.get("cmdInfo"):
    runMyTest(exec_locals)
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/RemoteQuery/GY_Query_GMTExecfile.py
New file
@@ -0,0 +1,91 @@
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
##@package Player.RemoteQuery.GY_Query_GMTExecfile
#
# @todo:执行命令文件
# @author hxp
# @date 2021-05-19
# @version 1.0
#
# 详细描述: 执行命令文件
#
#-------------------------------------------------------------------------------
#"""Version = 2021-05-19 11:00"""
#-------------------------------------------------------------------------------
import DataRecordPack
import GameWorld
import GMCommon
import traceback
import os
#逻辑实现
## 请求逻辑
#  @param query_Type 请求类型
#  @param query_ID 玩家ID
#  @param packCMDList 发包命令
#  @param tick 当前时间
#  @return "True" or "False" or ""
#  @remarks 函数详细说明.
def DoLogic(query_Type, query_ID, packCMDList, tick):
    curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(query_ID)
    if not curPlayer or curPlayer.IsEmpty():
        return
    pack_type = "GMT_Execfile"
    result = GMCommon.Def_Success
    orderId, cmdInfo = packCMDList
    backDir = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
    execfilepath = os.path.join(backDir, "GMTExec\\%s.py" % cmdInfo)
    GameWorld.Log("GMT_Execfile: %s" % execfilepath)
    if not os.path.exists(execfilepath):
        GMCommon.SendGMTResult(orderId, pack_type, GMCommon.Def_ParamErr, "%s is not exists!" % cmdInfo)
        return
    mapID = GameWorld.GetMap().GetMapID()
    resultDict = {"cmdInfo":cmdInfo, "mapID":mapID}
    try:
        execfile(execfilepath, globals(), locals())
    except:
        errMsg = traceback.format_exc()
        GameWorld.ErrLog(errMsg)
        resultDict["errMsg"] = errMsg
        GMCommon.SendGMTResult(orderId, pack_type, GMCommon.Def_Unknow, resultDict)
        return
    DataRecordPack.DR_ToolGMOperate(query_ID, curPlayer.GetPlayerName(), curPlayer.GetAccID(), pack_type, resultDict)
    GMCommon.SendGMTResult(orderId, pack_type, GMCommon.Def_Success, resultDict)
    return
#执行结果
## 执行结果
#  @param curPlayer 发出请求的玩家
#  @param callFunName 功能名称
#  @param funResult 查询的结果
#  @param tick 当前时间
#  @return None
#  @remarks 函数详细说明.
def DoResult(curPlayer, callFunName, funResult, tick):
    return