| | |
| | | from Common import (CommFuncEx, mylog)
|
| | |
|
| | | from Protocol import (MMORPGPack, RecvPackProtocol, SendPackProtocol, MergeServerRecvProtocol, MergeServerSendProtocol)
|
| | | import PlayerOfflineSupport
|
| | | import PyGameData
|
| | | import GameWorld
|
| | |
|
| | | ##################################################################
|
| | | ####### python逻辑入口 #######
|
| | |
| | |
|
| | | ##################################################################
|
| | |
|
| | | def GMCmdPlayerValidation(gmCmdDict, offlineSupport=True):
|
| | | '''后台GM工具玩家命令通用验证
|
| | | @param gmCmdDict: 命令参数字典
|
| | | @param offlineSupport: 离线玩家是否支持该命令,默认支持,当玩家离线时,会在上线后执行该命令
|
| | | @return: GMCommon.Def_xxx, curPlayer
|
| | | 非 Def_Success 的错误类型 - 代表错误,可直接返回给后台
|
| | | Def_Success, curPlayer - curPlayer为空时代表玩家离线状态
|
| | | '''
|
| | | |
| | | queryType = gmCmdDict.get(GMCommon.Def_GMKey_QueryType, '')
|
| | | playerFind = gmCmdDict.get(GMCommon.Def_GMKey_PlayerFind, '')
|
| | | |
| | | if len(playerFind) <= 0:
|
| | | return GMCommon.Def_ParamErr, None
|
| | | |
| | | # 玩家姓名
|
| | | if queryType == GMCommon.Def_GMKey_PlayerName:
|
| | | rec = PyGameData.g_usrCtrlDB.findDBPlayerByName(playerFind)
|
| | | elif queryType == GMCommon.Def_GMKey_PlayerAccID:
|
| | | rec = PyGameData.g_usrCtrlDB.findDBPlayerByAccID(playerFind)
|
| | | else:
|
| | | return GMCommon.Def_ParamErr, None
|
| | | |
| | | if not rec:
|
| | | # db找不到就是不存在该玩家
|
| | | return GMCommon.Def_NoTag, None
|
| | | |
| | | playerID = rec.get(u'PlayerID', 0)
|
| | | curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID)
|
| | | if not curPlayer or curPlayer.IsEmpty():
|
| | | # 离线处理
|
| | | if offlineSupport:
|
| | | PlayerOfflineSupport.AddOfflineUnprocessed(playerID, "GMToolCMD", gmCmdDict)
|
| | | return GMCommon.Def_Success, None
|
| | | return GMCommon.Def_PlayerOfLine, None
|
| | | |
| | | return GMCommon.Def_Success, curPlayer
|
| | |
|
| | | def GMCmdPlayerLogin(curPlayer):
|
| | | PlayerOfflineSupport.DoOfflineUnprocessed(curPlayer, "GMToolCMD", __doOfflineGMToolCMD)
|
| | | return
|
| | |
|
| | | def __doOfflineGMToolCMD(curPlayer, recData, eventName, eventData):
|
| | | gmCmdDict = eventData
|
| | | if not gmCmdDict or not isinstance(gmCmdDict, dict):
|
| | | return
|
| | | funcName = gmCmdDict.get(GMCommon.Def_GMKey_Type, '') |
| | | callFunc = GetExecFunc(Commands, "%s.%s" % (funcName, "OnExec"))
|
| | | if callFunc != None:
|
| | | callFunc(gmCmdDict)
|
| | | return
|
| | |
|
| | |
|
| | | ## gm命令执行
|
| | | #
|