| | |
| | | import DataRecordPack
|
| | | import GameWorld
|
| | | import CtrlDB
|
| | | import base64
|
| | |
|
| | |
|
| | | #-------------------------------------------------------------------------------
|
| | |
|
| | |
| | | port = DBConfig.IDDispatchServerPort
|
| | | addr = (host, port)
|
| | | BUF_SIZE = 1024
|
| | | curVersion = ""
|
| | | centerVersion = ""
|
| | | try:
|
| | | cfGameVer = ConfigParser.ConfigParser()
|
| | | cfGameVer.read("GameVersion.ini")
|
| | | cfGameVer.read(os.path.join(GlobalFunctions.getAppPath(), 'GameVersion.ini'))
|
| | |
|
| | | gameID = cfGameVer.get("config", "GameID")
|
| | | curVersion = cfGameVer.get("config", "Version")
|
| | |
| | | except:
|
| | | mylog.error("IDDispatch CheckGameVersion Connect unknown Exception")
|
| | |
|
| | | return
|
| | | return curVersion, centerVersion
|
| | |
|
| | | import thread
|
| | | lockPlayerID = thread.allocate_lock()
|
| | |
| | | if not PyGameData.g_UserCtrlDBFirstInit:
|
| | | PyGameData.g_UserCtrlDBFirstInit = True
|
| | | self.__PlayerBackupSave()
|
| | | CheckGameVersion()
|
| | |
|
| | | #后续也要增加公共数据保存如家族等,考虑保存失败可以直接关闭地图
|
| | |
|
| | |
| | | oFuncGrade.End()
|
| | |
|
| | | if requestType == CommonDefine.gstGeneralDBOper:
|
| | | oFuncGrade = self.GetFuncGrade('gstMergeGeneralReturn')
|
| | | oFuncGrade = self.GetFuncGrade('gstGeneralDBOper')
|
| | | oFuncGrade.Start()
|
| | | self.OnGeneralDBOper(db, pack)
|
| | | oFuncGrade.End()
|
| | | return True
|
| | | |
| | | if requestType == CommonDefine.gstDBLogic:
|
| | | oFuncGrade = self.GetFuncGrade('gstDBLogic')
|
| | | oFuncGrade.Start()
|
| | | self.OnGameServerToDBLogic(db, pack)
|
| | | oFuncGrade.End()
|
| | | return True
|
| | |
|
| | |
| | | self.sendGameServerDBOperResult(pack.getSessionID(), result, resultSet, errorMsg)
|
| | | return
|
| | | mylog.warning('oper %s not support!'%oper)
|
| | |
|
| | |
|
| | | def OnGameServerToDBLogic(self, db, pack):
|
| | | buf = pack.getBuffer()
|
| | | recvPack = RecvPackProtocol.tagGDGameServerToDBLogic()
|
| | | pos = 0
|
| | | recvPack.ReadData(buf, pos)
|
| | | queryType = recvPack.QueryType
|
| | | mylog.debug('pack = %s'%(recvPack.OutputString()))
|
| | |
|
| | | if queryType == CommonDefine.gstDBLogic_PlayerPackDataReq:
|
| | | #请求玩家打包数据
|
| | | playerID = recvPack.ID
|
| | | packData = self.getPlayerPackData(playerID) # 有直接取,没有的话再从db整合数据
|
| | | if packData:
|
| | | result = 1
|
| | | mylog.debug("packData get from cache. playerID=%s" % playerID)
|
| | | else:
|
| | | result, playerData = self.GetPlayerDataByPlayerID(db, playerID)
|
| | | mylog.debug("packData get from db. playerID=%s,result=%s" % (playerID, result))
|
| | | if result:
|
| | | packData = base64.b64encode(playerData)
|
| | | self.updPlayerPackData(playerID, packData)
|
| | | self.SendGameServerToDBLogicResult(pack.getSessionID(), result, recvPack, packData)
|
| | | return
|
| | | |
| | | if queryType == CommonDefine.gstDBLogic_PlayerPackDataUpd:
|
| | | #更新玩家打包数据,仅子服用,不需要回复GameServer
|
| | | playerID = recvPack.ID
|
| | | packData = recvPack.Data
|
| | | self.updPlayerPackData(playerID, packData)
|
| | | return
|
| | | |
| | | if queryType == CommonDefine.gstDBLogic_GMCmd:
|
| | | dbAnswerList = GMShell.DBGMCommand(recvPack.Data)
|
| | | self.SendGameServerToDBLogicResult(pack.getSessionID(), 1, recvPack, str(dbAnswerList))
|
| | | return
|
| | | |
| | | return
|
| | | |
| | | def SendGameServerToDBLogicResult(self, sessionID, result, recvPack, resultSet):
|
| | | '''回复GameServer发送的SendDBLogic,可以不回复,由具体类型决定
|
| | | @param result: 结果:1成功,0失败
|
| | | @param recvPack: GameServer发来的数据包,Data可原值返回,也可修改后返回,由具体类型决定
|
| | | @param resultSet: 回复数据
|
| | | '''
|
| | | sendPack = SendPackProtocol.tagDGGameServerToDBLogicResult()
|
| | | sendPack.Type = CommonDefine.dgDBGameServerToDBLogicResult
|
| | | sendPack.Result = result
|
| | | sendPack.ID = recvPack.ID
|
| | | sendPack.QueryType = recvPack.QueryType
|
| | | sendPack.Data = recvPack.Data
|
| | | sendPack.DataLen = len(sendPack.Data)
|
| | | sendPack.ResultSet = resultSet
|
| | | sendPack.ResultSetLen = len(sendPack.ResultSet)
|
| | | self.packSend(sessionID, 0, 0, CommonDefine.atInner, MMORPGPack.stGame,
|
| | | MMORPGPack.stData, sendPack.GetBuffer())
|
| | | |
| | | mylog.debug("回复 SendGameServerToDBLogicResult")
|
| | | return
|
| | | |
| | | def GetPlayerDataByPlayerID(self, db, playerID):
|
| | | dbPlayer = DataServerPlayerData.tagDBPlayer()
|
| | | dbPlayer.PlayerID = playerID
|
| | | collection = db[UCN_DBPlayer]
|
| | | loadOK = dbPlayer.adoLoadCEx(collection, {'PlayerID':playerID})
|
| | | if not loadOK:
|
| | | mylog.warning('GetPlayerDataByPlayerID Exception playerID = %s'%(dbPlayer.PlayerID))
|
| | | return 0, ''
|
| | | |
| | | #测试
|
| | | mylog.info("accid = %s"%(dbPlayer.AccID))
|
| | | |
| | | #读取物品等其他数据
|
| | | queryDict = {'PlayerID':dbPlayer.PlayerID}
|
| | | collection = db[UCN_RoleItem]
|
| | | itemData = self.readPlayerPackSaveData(collection, queryDict, DataServerPlayerData.tagRoleItem, True)
|
| | | |
| | | collection = db[UCN_RoleMission]
|
| | | missionData = self.readPlayerPackSaveData(collection, queryDict, DataServerPlayerData.tagRoleMission)
|
| | |
|
| | | collection = db[UCN_RoleMissionDict]
|
| | | roleMissionDictData = self.readPlayerPackSaveData(collection, queryDict, DataServerPlayerData.tagRoleMissionDict)
|
| | |
|
| | | collection = db[UCN_RoleSkill]
|
| | | roleSkillData = self.readPlayerPackSaveData(collection, queryDict, DataServerPlayerData.tagRoleSkill)
|
| | | |
| | | collection = db[UCN_RoleBuff]
|
| | | roleBuffData = self.readPlayerPackSaveData(collection, queryDict, DataServerPlayerData.tagRoleBuff)
|
| | | |
| | | collection = db[UCN_RoleRepeatTime]
|
| | | roleRepeatTimeData = self.readPlayerPackSaveData(collection, queryDict, DataServerPlayerData.tagRoleRepeatTime)
|
| | | |
| | | collection = db[UCN_PlayerHorseTable]
|
| | | roleHorseData = self.readPlayerPackSaveData(collection, queryDict, DataServerPlayerData.tagPlayerHorseTable)
|
| | | |
| | | collection = db[UCN_GMOper]
|
| | | gmOperData = self.readPlayerPackSaveData(collection, queryDict, DataServerPlayerData.tagGMOper)
|
| | | |
| | | collection = db[UCN_RolePet]
|
| | | rolePetData = self.readPlayerPackSaveData(collection, queryDict, DataServerPlayerData.tagRolePet)
|
| | | |
| | | collection = db[UCN_PetSkill]
|
| | | petSkillData = self.readPlayerPackSaveData(collection, queryDict, DataServerPlayerData.tagPetSkill)
|
| | | |
| | | collection = db[UCN_RoleNomalDict]
|
| | | roleNormalDictData = self.readPlayerPackSaveData(collection, queryDict, DataServerPlayerData.tagRoleNomalDict)
|
| | | |
| | | collection = db[UCN_PlayerDienstgrad]
|
| | | roleDienstgradData = self.readPlayerPackSaveData(collection, queryDict, DataServerPlayerData.tagPlayerDienstgrad)
|
| | | |
| | | collection = db[UCN_BattleFormation]
|
| | | battleFormationData = self.readPlayerPackSaveData(collection, queryDict, DataServerPlayerData.tagBattleFormation)
|
| | | |
| | | #读取禁止IP数据
|
| | | gmIP = DataServerPlayerData.tagDBGMIP()
|
| | | gmIP.AccID = dbPlayer.AccID.lower()
|
| | | collection = db[UCN_DBGMIP]
|
| | | gmIPData = gmIP.adoQueryIndex(collection)
|
| | | |
| | | return 1, dbPlayer.getBuffer() + itemData + missionData + roleMissionDictData + roleSkillData + roleBuffData + roleRepeatTimeData + roleHorseData + gmOperData\
|
| | | + gmIPData + rolePetData + petSkillData + roleNormalDictData + roleDienstgradData+battleFormationData
|
| | | |
| | |
|
| | |
|
| | | # 查询返回0/1 代表是否成功
|
| | | def OnMergeQueryRegisterResult(self, db, pack):
|
| | | g_mergeRegisterPlayerDict = PyGameData.g_mergeRegisterPlayerDict
|
| | |
| | | return (False, playerRec.PlayerID, '')
|
| | | oFuncGrade.End()
|
| | | #记录下线日志流向
|
| | | if playerRec.FacePic == 0: # 约定为下线标识
|
| | | if playerRec.CountryLastWeekHornor == 0: # 约定为下线标识
|
| | | self.recPlayerLogoff(playerRec)
|
| | | #保存物品等其他数据
|
| | | #不再支持单表模式
|
| | |
| | | if len(infoList) > 3:
|
| | | accountRec.DeviceFlag = md5.md5(infoList[1]).hexdigest()
|
| | | # 倒数第二个元素为客户端版本号 仙宝奇缘新定义
|
| | | accountRec.ClientVersion = infoList[-2]
|
| | | accountRec.SetClientVersion(infoList[-2])
|
| | |
|
| | | PegasusCollectorProxy.EventReport(9001, "OperatorID=%s&Step=%s&AccountID=%s&Flag=1000&DeviceFlag=%s"%(
|
| | | accountRec.AppID, 1, CommFunc.GetPlatformAccID(authAccID), accountRec.DeviceFlag))
|
| | |
| | | def onGetGameServerPlayerData(self, db, pack):
|
| | | data = ''
|
| | |
|
| | | #玩家打包数据表较大,不同步GameServer,由db自己管理
|
| | | #collection = db[UCN_DBPlayerPackData]
|
| | | #DBPlayerPackData = DataServerPlayerData.tagDBPlayerPackData()
|
| | | #data += DBPlayerPackData.adoQueryAll(collection)
|
| | | #mylog.debug("tagDBPlayerPackData ok")
|
| | | |
| | | collection = db[UCN_DBGameRec]
|
| | | DBGameRec = DataServerPlayerData.tagDBGameRec()
|
| | | data += DBGameRec.adoQueryAll(collection)
|
| | | mylog.debug("tagDBGameRec ok")
|
| | | |
| | | collection = db[UCN_DBPyFuncTeam]
|
| | | DBPyFuncTeam = DataServerPlayerData.tagDBPyFuncTeam()
|
| | | data += DBPyFuncTeam.adoQueryAll(collection)
|
| | | mylog.debug("tagDBPyFuncTeam ok")
|
| | | |
| | | collection = db[UCN_DBPyFuncTeamMem]
|
| | | DBPyFuncTeamMem = DataServerPlayerData.tagDBPyFuncTeamMem()
|
| | | data += DBPyFuncTeamMem.adoQueryAll(collection)
|
| | | mylog.debug("tagDBPyFuncTeamMem ok")
|
| | | |
| | | collection = db[UCN_DBPlayerRecData]
|
| | | DBPlayerRecData = DataServerPlayerData.tagDBPlayerRecData()
|
| | | data += DBPlayerRecData.adoQueryAll(collection)
|
| | | mylog.debug("tagDBPlayerRecData ok")
|
| | |
|
| | | collection = db[UCN_DBPyMineAreaAward]
|
| | | DBPyMineAreaAward = DataServerPlayerData.tagDBPyMineAreaAward()
|
| | | data += DBPyMineAreaAward.adoQueryAll(collection)
|
| | |
| | | #mylog.debug("GameData = %s"%b2a_hex(decompressGameData))
|
| | | gameDataReadPos = 0
|
| | | try:
|
| | | #gameDataReadPos = self.savegameServerWorldData(decompressGameData, gameDataReadPos, UCN_DBPlayerPackData, DataServerPlayerData.tagDBPlayerPackData, db)
|
| | | gameDataReadPos = self.savegameServerWorldData(decompressGameData, gameDataReadPos, UCN_DBGameRec, DataServerPlayerData.tagDBGameRec, db)
|
| | | gameDataReadPos = self.savegameServerWorldData(decompressGameData, gameDataReadPos, UCN_DBPyFuncTeam, DataServerPlayerData.tagDBPyFuncTeam, db)
|
| | | gameDataReadPos = self.savegameServerWorldData(decompressGameData, gameDataReadPos, UCN_DBPyFuncTeamMem, DataServerPlayerData.tagDBPyFuncTeamMem, db)
|
| | | gameDataReadPos = self.savegameServerWorldData(decompressGameData, gameDataReadPos, UCN_DBPlayerRecData, DataServerPlayerData.tagDBPlayerRecData, db)
|
| | | gameDataReadPos = self.savegameServerWorldData(decompressGameData, gameDataReadPos, UCN_DBPyMineAreaAward, DataServerPlayerData.tagDBPyMineAreaAward, db)
|
| | | gameDataReadPos = self.savegameServerWorldData(decompressGameData, gameDataReadPos, UCN_DBPyMineAreaRecord, DataServerPlayerData.tagDBPyMineAreaRecord, db)
|
| | | gameDataReadPos = self.savegameServerWorldData(decompressGameData, gameDataReadPos, UCN_DBPyMineAreaItem, DataServerPlayerData.tagDBPyMineAreaItem, db)
|
| | |
| | | #mylog.debug("GameData = %s"%b2a_hex(decompressGameData))
|
| | | gameDataReadPos = 0
|
| | | try:
|
| | | #gameDataReadPos = self.savegameServerWorldData(decompressGameData, gameDataReadPos, UCN_DBPlayerPackData, DataServerPlayerData.tagDBPlayerPackData, db)
|
| | | gameDataReadPos = self.savegameServerWorldData(decompressGameData, gameDataReadPos, UCN_DBGameRec, DataServerPlayerData.tagDBGameRec, db)
|
| | | gameDataReadPos = self.savegameServerWorldData(decompressGameData, gameDataReadPos, UCN_DBPyFuncTeam, DataServerPlayerData.tagDBPyFuncTeam, db)
|
| | | gameDataReadPos = self.savegameServerWorldData(decompressGameData, gameDataReadPos, UCN_DBPyFuncTeamMem, DataServerPlayerData.tagDBPyFuncTeamMem, db)
|
| | | gameDataReadPos = self.savegameServerWorldData(decompressGameData, gameDataReadPos, UCN_DBPlayerRecData, DataServerPlayerData.tagDBPlayerRecData, db)
|
| | | gameDataReadPos = self.savegameServerWorldData(decompressGameData, gameDataReadPos, UCN_DBPyMineAreaAward, DataServerPlayerData.tagDBPyMineAreaAward, db)
|
| | | gameDataReadPos = self.savegameServerWorldData(decompressGameData, gameDataReadPos, UCN_DBPyMineAreaRecord, DataServerPlayerData.tagDBPyMineAreaRecord, db)
|
| | | gameDataReadPos = self.savegameServerWorldData(decompressGameData, gameDataReadPos, UCN_DBPyMineAreaItem, DataServerPlayerData.tagDBPyMineAreaItem, db)
|