From ab4d62787cf6958470cecaaaf5758877e0a64c02 Mon Sep 17 00:00:00 2001 From: hxp <ale99527@vip.qq.com> Date: 星期三, 28 五月 2025 11:57:13 +0800 Subject: [PATCH] 54 【三国主界面】核心主体-服务端(仙树;增加货币41-战锤;42-结晶) --- ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorld.py | 58 ++++++++++++++++++++++++++-------------------------------- 1 files changed, 26 insertions(+), 32 deletions(-) diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorld.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorld.py index 8de3a0d..ae8e33a 100644 --- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorld.py +++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorld.py @@ -56,6 +56,7 @@ import PyGameData import urllib import md5 +import uuid #--------------------------------------------------------------------- #设置允许的最大迭代数目, 默认1000 #在NPCAI中, 可能超过1000, 所以要设定为2000 @@ -608,8 +609,6 @@ return False #if not curPlayer.GetInitOK(): # return False - #if IsTJGPlayer(curPlayer): - # return False if IsMirrorPlayer(curPlayer): return False return True @@ -864,6 +863,8 @@ # @return 返回值. 时间Data格式 # @remarks 获得服务器系统时间 def GetCurrentTime(): + return datetime.datetime.today() +def GetServerTime(): return datetime.datetime.today() # ctime = GetGameWorld().GetGameServerEventTime() # @@ -1321,7 +1322,7 @@ ## 获取服务器ID所属主服ID ServerIDMainServerDict = IpyGameDataPY.GetConfigEx("ServerIDMainServerDict") if ServerIDMainServerDict == None: - filePath = ChConfig.GetDBPath() + ("\\MixServerMap_%s.json" % GetPlatform()) + filePath = ChConfig.GetServerConfigPath() + ("\\MixServerMap_%s.json" % GetPlatform()) if not os.path.isfile(filePath): SendGameErrorEx("GetMainServerIDError", "file can not found. %s" % filePath) else: @@ -1384,8 +1385,8 @@ ##获取玩家所属区服ID # @param curPlayer # @return -def GetPlayerServerID(curPlayer): - accID = curPlayer.GetAccID() +def GetPlayerServerID(curPlayer): return GetAccIDServerID(curPlayer.GetAccID()) +def GetAccIDServerID(accID): infoList = accID.split(Def_AccID_Split_Sign) return 0 if len(infoList) < 3 else ToIntDef(infoList[-1][1:]) @@ -1403,6 +1404,9 @@ return mainServerID return 0 +def GetDBPlayerAccIDByID(playerID): + ## 获取玩家表账号ID - 根据玩家ID, 可用于判断是否本服玩家 + return PyGameData.g_dbPlayerIDMap.get(playerID, "") #=============================================================================== # 平台ID = appid @@ -1474,6 +1478,8 @@ ChannelCodeDict = ReadChConfig.GetEvalChConfig("ChannelCode") return ChannelCodeDict.get(codeNum, "") + +def GetGUID(): return str(uuid.uuid1()) #--------------------------------------------------------------------- ##大额度金钱记录 @@ -1879,18 +1885,12 @@ # @param inputText 输入的文字 # @return: 是否符合编码格式 def EncodingToUnicode(inputText): - encodingList = ReadChConfig.GetEvalChConfig("EncodingTex") - - if len(encodingList) != 2: - ErrLog("EncodingTex.txt Error len != 2") - return False - - if encodingList[0]: + if IpyGameDataPY.GetFuncCfg("EncodingTex", 1): #不檢查 return True try: - unicode(inputText, encodingList[1]) + unicode(inputText, IpyGameDataPY.GetFuncCfg("EncodingTex", 2)) except: return False @@ -1898,25 +1898,20 @@ # 获得游戏设置的字符编码 -def GetCharacterEncoding(): - encodingList = ReadChConfig.GetEvalChConfig("EncodingTex") - - if len(encodingList) != 2: - ErrLog("EncodingTex.txt Error len != 2") - return 'utf8' - return encodingList[1] - +def GetCharacterEncoding(): return IpyGameDataPY.GetFuncCfg("EncodingTex", 2) # 服务器默认GBK,转配置编码如UTF8,一般用于与显示层交互,不判断是否base64 def GbkToCode(inputText): - encodingList = ReadChConfig.GetEvalChConfig("EncodingTex") - - if len(encodingList) != 2: - ErrLog("EncodingTex.txt Error len != 2") - return inputText - try: return inputText.decode(ShareDefine.Def_Game_Character_Encoding).encode(GetCharacterEncoding()) + except: + return inputText + + return inputText + +def CodeToGbk(inputText): + try: + return inputText.decode(GetCharacterEncoding()).encode(ShareDefine.Def_Game_Character_Encoding) except: return inputText @@ -2376,7 +2371,7 @@ # return #=========================================================================== - DebugLog(text) + DebugLog(text, curPlayer.GetPlayerID()) text = text.decode(ShareDefine.Def_Game_Character_Encoding).encode(GetCharacterEncoding()) curPlayer.DebugAnswer(text) return @@ -2392,10 +2387,9 @@ def SendGameErrorEx(errType, msgInfo="", playerID=0): ErrLog("SendGameErrorEx: %s -> %s" % (errType, msgInfo), playerID) - if GetGameWorld().GetDebugLevel(): - raise Exception("%s -> %s" % (errType, msgInfo)) - else: - SendGameError(errType, msgInfo) + SendGameError(errType, msgInfo) + #if GetGameWorld().GetDebugLevel(): + # raise Exception("%s -> %s" % (errType, msgInfo)) return def SendGameError(errType, msgInfo=""): -- Gitblit v1.8.0