def _onResponseFailure(self, ids, args): actionID = super(VOIPChatProvider, self)._onResponseFailure(ids, args) if actionID is None: return else: error, logOnly = errors.createVOIPError(args, actionID) if error: if logOnly: LOG_NOTE(error) else: g_messengerEvents.onErrorReceived(error) else: LOG_WARNING('Error is not resolved on the client to display in GUI', actionID, ids, args) return
def checkAccount(*fargs, **fkwargs): if not isPlayerAccount(): LOG_NOTE( 'Server call "StatsRequester.%s" canceled: player is not account.' % fn.func_name) returnFurnc = dkwargs.get('func', None) if returnFurnc: returnArgs = dkwargs.get('args', None) if returnArgs: return fkwargs['callback'](returnFurnc(returnArgs)) return fkwargs['callback'](returnFurnc()) return fkwargs['callback'](*dargs, **dkwargs) fargs[0].setCallback(fkwargs['callback']) return fn(*fargs, **fkwargs)
def __tryToGetRequiredData(self): successful = True self.__playerTeam = avatar_getter.getPlayerTeam() if not self.__playerTeam: successful = False LOG_NOTE("Player's team not found.") self.__playerVehicleID = avatar_getter.getPlayerVehicleID() if not self.__playerVehicleID: successful = False LOG_NOTE("Player's vehicle ID not found.") if not successful: playerName = avatar_getter.getPlayerName() LOG_NOTE('Uses slow player search by name') for vo in self.__vInfoVOs.itervalues(): if vo.player.name == playerName: self.__playerTeam = vo.team self.__playerVehicleID = vo.vehicleID successful = True break if successful: self.__setPersonalDataOnce() return successful
def __checkRequiredData(self): result = self.__playerTeam > 0 and self.__playerVehicleID > 0 if not result: requestToFind = False self.__playerTeam = avatar_getter.getPlayerTeam() if not self.__playerTeam: requestToFind = True LOG_NOTE("Player's team not found.") self.__playerVehicleID = avatar_getter.getPlayerVehicleID() if not self.__playerVehicleID: requestToFind = True LOG_NOTE("Player's vehicle ID not found.") if not requestToFind: return playerName = avatar_getter.getPlayerName() LOG_NOTE('Uses slow player search by name') for vo in self.__vInfoVOs.itervalues(): if vo.player.name == playerName: self.__playerTeam = vo.team self.__playerVehicleID = vo.vehicleID result = True break return result
def __readAliasSection(self, section, aliases): embedded = section.readString('embedded') runtime = section.readString('runtime') fontStyle = FONT_STYLE_DEFAULT if section.has_key('flags'): flagNames = section.readString('flags').split(' ') for name in flagNames: try: fontStyle |= FONT_STYLE_NAMES[name] except KeyError: LOG_NOTE('Available font style flags are:', FONT_STYLE_NAMES.keys()) raise Exception("Flag isn't correct: {0:>s}.".format(name)) scaleFactor = section.readFloat('scaleFactor', 1.0) aliases[embedded] = (runtime, fontStyle, scaleFactor)
def isPeripheryAvailable(self, peripheryID): result = True if _isSkipPeripheryChecking(): LOG_NOTE('Skip periphery checking in standalone mode') return result else: if g_preDefinedHosts.periphery(peripheryID) is None: LOG_ERROR('Periphery not found', peripheryID) result = False elif self.__credentials is None: LOG_ERROR('Login info not found', peripheryID) result = False elif g_preDefinedHosts.isRoamingPeriphery(peripheryID) and not isRoamingEnabled(g_itemsCache.items.stats.attributes): LOG_ERROR('Roaming is not supported', peripheryID) result = False return result
def restore(self): toRestore = [] if self.__originTexQuality != -1: toRestore.append(('TEXTURE_QUALITY', self.__originTexQuality)) commit = False for label, originalIndex in toRestore: if self.__setGraphicsSetting(label, self.__originTexQuality): commit = True LOG_NOTE('The setting was restored to the original value.', label, self.__getLoweredOptionLabel(label, originalIndex)) LOG_ERROR('The setting was not restored to the original value.', label, self.__getLoweredOptionLabel(label, originalIndex), BigWorld.getGraphicsSetting(label), self.__getLoweredOption(label)) if commit: BigWorld.commitPendingGraphicsSettings() self.__originTexQuality = -1 self.__needReboot = False self.__messages = []
def __voiceChatEnable(self, isEnable): if isEnable is None: return else: preveVoIP = Settings.g_instance.userPrefs.readBool( Settings.KEY_ENABLE_VOIP) import VOIP if preveVoIP != isEnable: VOIP.getVOIPManager().enable(isEnable) Settings.g_instance.userPrefs.writeBool( Settings.KEY_ENABLE_VOIP, bool(isEnable)) from gui.WindowsManager import g_windowsManager if g_windowsManager.battleWindow is not None and not isEnable: g_windowsManager.battleWindow.speakingPlayersReset() LOG_NOTE('Change state of voip: %s' % str(isEnable)) return
def resync(self, firstInit = False, forceResync = False): if not isClubsEnabled(): LOG_DEBUG('Clubs is not enabled on this server. Skip profile resync.') return clubsMgr = getClientClubsMgr() if not forceResync and clubsMgr and not clubsMgr.isRelatedToClubs(): LOG_DEBUG('Account does not related to clubs. Skip profile resync.') if firstInit and self.__state.getStateID() != CLIENT_CLUB_STATE.NO_CLUB: self._changeState(states.NoClubState([], [])) return serverSettings = g_lobbyContext.getServerSettings() if serverSettings is not None and serverSettings.roaming.isInRoaming(): LOG_NOTE('There is no clubs in the roaming') return if self._waitForSync & _SYNC_TYPE.ALL: LOG_DEBUG('Club profile resync already in progress') return self._waitForSync |= _SYNC_TYPE.ALL self.__sendRequest(club_ctx.GetPrivateProfileCtx(), callback=partial(self.__onAccountProfileReceived, _SYNC_TYPE.ALL))
def restore(self): toRestore = [] commit = False for label, originalIndex in toRestore: if self.__setGraphicsSetting(label, originalIndex): commit = True LOG_NOTE('The setting was restored to the original value.', label, self.__getLoweredOptionLabel(label, originalIndex)) LOG_ERROR('The setting was not restored to the original value.', label, self.__getLoweredOptionLabel(label, originalIndex), BigWorld.getGraphicsSetting(label), self.__getLoweredOption(label)) if commit: BigWorld.commitPendingGraphicsSettings() self.__needReboot = False self.__messages = []
def __changeCaptureDevice(self, captureDeviceIdx): if captureDeviceIdx is None or captureDeviceIdx == -1: return else: import VOIP rh = VOIP.getVOIPManager() devices = [ device.decode(sys.getfilesystemencoding()).encode('utf-8') for device in rh.captureDevices ] if captureDeviceIdx < len(devices): newCaptureDevice = devices[captureDeviceIdx] previousDevice = Settings.g_instance.userPrefs.readString( Settings.KEY_VOIP_DEVICE) if previousDevice != newCaptureDevice: Settings.g_instance.userPrefs.writeString( Settings.KEY_VOIP_DEVICE, newCaptureDevice) LOG_NOTE('Change device of voip: %s' % str(newCaptureDevice)) return
def __init__(self): self.__settings = _DEFAULT_SETTINGS.copy() settings = {} for item in resource_helper.root_iterator( GUI_SETTINGS_FILE_PATH, customReaders={'macros': _readMacros}): if item.name in _SETTING_CONVERTERS: setting = _DEFAULT_SETTINGS[item.name] converter = _SETTING_CONVERTERS[item.name] value = converter(setting, item) else: value = item.value settings[item.name] = value if constants.IS_DEVELOPMENT: diff = set(self.__settings.keys()) - set(settings.keys()) if diff: LOG_NOTE( 'Settings are not in {0}:'.format(GUI_SETTINGS_FILE_PATH), diff) self.__settings.update(settings)
def retrievePrimary(self): LOG_NOTE('Attempting to retrieve primary messages') try: urllib.urlretrieve('%s' % (self.rtrURL), self.pMsgXML) except: self.PrimaryToggle = 'OFF' LOG_ERROR('Unable to retrieve primary message from %s' % (self.rtrURL)) LOG_NOTE('Completed') ##################################################################### # Parse primary message file LOG_NOTE('Attempting to parse primary messages') #try: # if self.primaryMsgXML is not None: # ResMgr.purge('scripts/client/mods/msg-ctr/primary.xml') # LOG_NOTE('Re-checking primary.xml') #except: # LOG_NOTE('') self.primaryMsgXML = ResMgr.openSection( 'scripts/client/mods/msg-ctr/primary.xml') try: if self.primaryMsgXML is not None: self.Author = self.primaryMsgXML.readString('Author') self.authorColor = self.primaryMsgXML.readString( 'Author_Color').strip() self.AuthorEnabled = self.primaryMsgXML.readString( 'Show_Author').strip().lower() self.CheckTimer = int( self.primaryMsgXML.readString( 'Check_Message_Time').strip()) # MOTD self.msgMOTDEnabled = self.primaryMsgXML.readString( 'Show_MOTD_Message').strip().lower() self.msgMOTDmsg = self.primaryMsgXML.readString('MOTDmsg') self.MOTDcolor = self.primaryMsgXML.readString( 'MOTD_Color').strip() # Meetings self.msgMEnabled = self.primaryMsgXML.readString( 'Show_Meeting_Message').strip().lower() self.msgMeetingmsg = self.primaryMsgXML.readString( 'Clan_Meeting') self.MeetingColor = self.primaryMsgXML.readString( 'Meeting_Color').strip() # Tournaments self.msgEnabledTourney = self.primaryMsgXML.readString( 'Show_Tourney_Message').strip().lower() self.msgTourney = self.primaryMsgXML.readString( 'Tournament_Battles_Message') self.tourneyColor = self.primaryMsgXML.readString( 'Tournament_Color').strip() self.secondaryTourney = self.primaryMsgXML.readString( 'Enable_Secondary_Tourney').strip().lower() self.combineTourney = self.primaryMsgXML.readString( 'Show_Both_TMessages').strip().lower() # Clan Wars self.msgEnabledCW = self.primaryMsgXML.readString( 'Show_Clanwars_Message').strip().lower() self.msgCWmsg = self.primaryMsgXML.readString( 'Clan_Wars_Message') self.cwColor = self.primaryMsgXML.readString( 'CW_Color').strip() self.secondaryCW = self.primaryMsgXML.readString( 'Show_Secondary_CW').strip().lower() self.combineCW = self.primaryMsgXML.readString( 'Show_Both_CWMessages').strip().lower() # msg-ctr.xml status self.UpdateCFG = self.primaryMsgXML.readString( 'Update_Mod_Config') self.UpdateCFGurl = self.primaryMsgXML.readString( 'Config_Update_Address') # is update tag present? try: self.UpdateMODUrl = self.primaryMsgXML.readString( 'Update_Mod_URL') if 'http' in self.UpdateMODUrl: try: urllib.urlretrieve('%s' % (self.UpdateMODUrl), self.uMODsave) except: LOG_CURRENT_EXCEPTION() self.modUpdated = 'YES' LOG_NOTE('Updated Mod!') except: pass LOG_NOTE( '----------------------------------------------------------------------------------------------\nSuccessfully read primary.xml, values are: \nAuthor: %s \nShow Author: %s \nCheck Time: %s \nMOTD: %s \nMOTD Enabled: %s \nMeeting Message: %s \nMeeting Message Enabled: %s \n- - -\nTourney Message: %s \nTourney Message Enabled: %s \nSecondary Tourney Message Status: %s \nCombine Both Tourney Messages: %s \n- - -\nClan Wars Message: %s \nClan Wars Message Enabled: %s \nSecondary Clan Wars Message Status: %s \nCombine Both Clan Wars Messages: %s \n- - -\nShould msg-ctr.xml be updated: %s \nLocation to get updated msg-ctr.xml: %s' % (self.Author, self.AuthorEnabled, self.CheckTimer, self.msgMOTDmsg, self.msgMOTDEnabled, self.msgMeetingmsg, self.msgMEnabled, self.msgTourney, self.msgEnabledTourney, self.secondaryTourney, self.combineTourney, self.msgCWmsg, self.msgEnabledCW, self.secondaryCW, self.combineCW, self.UpdateCFG, self.UpdateCFGurl)) LOG_NOTE( '----------------------------------------------------------------------------------------------\nCOLOR SETTINGS\nAuthor color: %s \nMOTDcolor: %s \nTourney_Color: %s \nCW Color: %s' % (self.authorColor, self.MOTDcolor, self.tourneyColor, self.cwColor)) else: LOG_ERROR('Unable to read primary.xml') #LOG_NOTE('Author color: %s \nMOTDcolor: %s \nTourney_Color: %s \nCW Color: %s' % (self.authorColor, self.MOTDcolor, self.tourneyColor, self.cwColor)) except: LOG_CURRENT_EXCEPTION() #LOG_NOTE('Completed parsing primary messages') LOG_NOTE( '----------------------------------------------------------------------------------------------' ) if self.UpdateCFG == 'yes': self.UpdateMSGConfig() ############# make sure doesn't create circular loop else: self.checkMsgGraphics()
import ResMgr import traceback from debug_utils import LOG_ERROR, LOG_NOTE keysToFind = [] textsToFind = [] debuggerCfg = ResMgr.openSection( '../mods/configs/PYmods/i18nDebugger/i18nDebugger.xml') if debuggerCfg is not None: if debuggerCfg['enable'] is not None and debuggerCfg['enable'].asBool: if debuggerCfg['key'] is not None: keysString = debuggerCfg['key'].asWideString.strip() if keysString: keysToFind = keysString.split(';') else: LOG_NOTE('Key section empty.') else: LOG_NOTE('Key section missing.') if debuggerCfg['text'] is not None: textsString = debuggerCfg['text'].asWideString.strip() if textsString: textsToFind = textsString.split(';') else: LOG_NOTE('Text section empty.') else: LOG_NOTE('Text section missing.') else: LOG_NOTE('i18nDebugger disabled.') else: LOG_ERROR('scripts/client/helpers/i18n/i18nDebugger.xml not found')
def onGeometryMapped(spaceID, path): SoundGroups.g_instance.unloadAll() LOG_NOTE('[SPACE] Loading space: ' + path) arenaName = path.split('/')[-1] BigWorld.notifySpaceChange(path) SoundGroups.g_instance.preloadSoundGroups(arenaName)
def isAnotherPeriphery(self, peripheryID): if not self._isSkipPeripheryChecking(): return self.connectionMgr.peripheryID != peripheryID LOG_NOTE('Skip periphery checking in standalone mode') return False
def readCurrentSettings(self, quiet=True): self.configsDict.clear() self.modes = { 'constant': [], 'stop': [], 'turn_left': [], 'turn_right': [], 'back': [], 'target': [], 'spot': [] } super(ConfigInterface, self).readCurrentSettings(quiet) if self.data['DebugModel']: if self.data['DebugPath']: try: _ = BigWorld.Model(self.data['DebugPath']) except StandardError: LOG_ERROR('Debug model path incorrect: %s' % self.data['DebugPath']) self.data['DebugModel'] = False else: LOG_NOTE('Debug disabled due to absence of DebugPath.') self.data['DebugModel'] = False if self.data['enabled']: configPath = self.configPath + 'configs/' if not os.path.exists(configPath): LOG_ERROR('%s config folder not found: %s' % (self.ID, configPath)) os.makedirs(configPath) for confPath in glob.iglob(configPath + '*.json'): confName = os.path.basename(confPath) try: confdict = loadJson( self.ID, confName.split('.')[0], self.configsDict.get(confName.split('.')[0], {}), os.path.dirname(confPath) + '/') except StandardError: print self.ID + ': config', confName, 'is invalid.' traceback.print_exc() continue if not confdict['enable'] or not any( x for x in (confdict.get(y, True) for y in ('attachToPlayer', 'attachToAlly', 'attachToEnemy'))): if not quiet: print self.ID + ': config', confName, 'is disabled.' continue if self.data['Debug']: print self.ID + ': loading', confName + ':' self.configsDict[confName.split('.')[0]] = configsDict = {} configsDict['meta'] = metaDict = { 'name': '<b>%s</b>' % confName, 'desc': self.i18n['UI_setting_meta_NDA'] } metaDict['name'] = confdict.get('meta', {}).get(self.lang, {}).get( 'name', metaDict['name']) metaDict['desc'] = confdict.get('meta', {}).get(self.lang, {}).get( 'desc', metaDict['desc']) for key in ['attachToPlayer', 'attachToAlly', 'attachToEnemy']: configsDict[key] = confdict.get(key, True) self.readConfDict(quiet, confdict, confPath) if not self.configsDict: print 'LampLights has not loaded any configs. Are you sure you need this .pyc?' if self.data['DebugModel'] and self.configsDict: if self.data['Debug'] and not quiet: print 'LampLights: loading configs for Debug:' for fileName, configsDict in self.configsDict.items(): for confKey in configsDict.keys(): if confKey in ('enable', 'meta', 'attachToPlayer', 'attachToAlly', 'attachToEnemy'): continue if configsDict.get(confKey + 'Debug') is None: if 'model' not in configsDict[confKey]['type']: self.configsDict[fileName][ confKey + 'Debug'] = confDict = {} confDict['type'] = 'model' for key in ('place', 'preRotate', 'postRotate', 'vect', 'mode', 'attachToPlayer', 'attachToAlly', 'attachToEnemy'): confDict[key] = listToTuple( configsDict[confKey][key]) if confDict['mode'] not in self.modes: print 'LampLights: unknown mode at %sDebug detected: %s. This light will be off.' \ % (confKey, confDict['mode']) else: self.modes[confDict['mode']].append( confKey + 'Debug') confDict['path'] = self.data['DebugPath'] if self.data['Debug'] and not quiet: print 'LampLights: config for %sDebug loaded.' % confKey elif self.data['Debug'] and not quiet: print 'LampLights: debug assignment failure: %sDebug' % confKey else: LOG_NOTE('LampLights mod fully disabled via main config.') self.isLampsVisible = False self.isTickRequired = any(self.modes[key] for key in ('stop', 'turn_left', 'turn_right', 'back')) self.updateMod()
def __call__(self): if self.__needReboot: return self.__needReboot = True self.__loweredSettings = [ t for t in BigWorld.graphicsSettings() if t[0] == 'TEXTURE_QUALITY' or t[0] == 'FLORA_QUALITY' or t[0] == 'TERRAIN_QUALITY' ] texQuality = BigWorld.getGraphicsSetting('TEXTURE_QUALITY') floraQuality = BigWorld.getGraphicsSetting('FLORA_QUALITY') terrainQuality = BigWorld.getGraphicsSetting('TERRAIN_QUALITY') pipelineType = BigWorld.getGraphicsSetting('RENDER_PIPELINE') textureSettings = [ t for t in self.__loweredSettings if t[0] == 'TEXTURE_QUALITY' ][0][2] floraSettings = [ t for t in self.__loweredSettings if t[0] == 'FLORA_QUALITY' ][0][2] terrainSettings = [ t for t in self.__loweredSettings if t[0] == 'TERRAIN_QUALITY' ][0][2] textureMinQuality = len(textureSettings) - 1 floraMinQuality = len(floraSettings) - 1 terrainMinQuality = len(terrainSettings) - 1 if textureSettings[textureMinQuality][0] == 'OFF': textureMinQuality -= 1 while textureSettings[textureMinQuality][ 1] is False or pipelineType == 1 and textureSettings[ textureMinQuality][2] is True: textureMinQuality -= 1 if textureMinQuality < texQuality: textureMinQuality = texQuality while floraSettings[floraMinQuality][ 1] is False or pipelineType == 1 and floraSettings[ floraMinQuality][2] is True: floraMinQuality -= 1 if floraMinQuality < floraQuality: floraMinQuality = floraQuality while terrainSettings[terrainMinQuality][ 1] is False or pipelineType == 1 and terrainSettings[ terrainMinQuality][2] is True: terrainMinQuality -= 1 if terrainMinQuality < terrainQuality: terrainMinQuality = terrainQuality if texQuality < textureMinQuality or floraQuality < floraMinQuality or terrainQuality < terrainMinQuality: if self.__originTexQuality == -1 and texQuality < textureMinQuality: self.__originTexQuality = texQuality if self.__originFloraQuality == -1 and floraQuality < floraMinQuality: self.__originFloraQuality = floraQuality if self.__originTerrainQuality == -1 and terrainQuality < terrainMinQuality: self.__originTerrainQuality = terrainQuality else: message = (1, 'insufficient_memory_please_reboot') self.__messages.append(message) self.__event(message) LOG_NOTE( "The free memory is too low, We can't do anything. Please, reboot the game." ) return message = (0, 'tex_was_lowered_to_min') self.__event(message) message = (1, 'insufficient_memory_please_reboot') self.__messages.append(message) if texQuality < textureMinQuality: BigWorld.setGraphicsSetting('TEXTURE_QUALITY', textureMinQuality) LOG_NOTE( 'To save the memory the texture quality setting was force lowered to <%s>.' % textureSettings[textureMinQuality][0]) if floraQuality < floraMinQuality: BigWorld.setGraphicsSetting('FLORA_QUALITY', floraMinQuality) LOG_NOTE( 'To save the memory the flora quality setting was force lowered to <%s>.' % floraSettings[floraMinQuality][0]) if terrainQuality < terrainMinQuality: BigWorld.setGraphicsSetting('TERRAIN_QUALITY', terrainMinQuality) LOG_NOTE( 'To save the memory the terrain quality setting was force lowered to <%s>.' % terrainSettings[terrainMinQuality][0]) BigWorld.commitPendingGraphicsSettings()
def merge_audio_mods(self, mediaPath, bankFiles): audio_mods = ResMgr.openSection(mediaPath + '/audio_mods.xml') audio_mods_new = ResMgr.openSection( mediaPath + '/audio_mods_edited.xml', True) if audio_mods is None: LOG_NOTE('audio_mods.xml not found, will be created if needed') data_structure = [{ 'name': 'events', 'key': 'event', 'keys': ('name', 'mod'), 'data': () }, { 'name': 'switches', 'key': 'switch', 'keys': ('name', 'mod'), 'data': { 'name': 'states', 'key': 'state', 'keys': ('name', 'mod'), 'data': () } }, { 'name': 'RTPCs', 'key': 'RTPC', 'keys': ('name', 'mod'), 'data': () }, { 'name': 'states', 'key': 'stateGroup', 'keys': ('name', 'mod'), 'data': { 'name': 'stateNames', 'key': 'state', 'keys': ('name', 'mod'), 'data': () } }] data_old, data_new = {}, {} for struct in data_structure: key = struct['name'] data_old[key] = self.check_and_collect_data( key, audio_mods[key], struct, True) banksData = {} for path in ResMgr.openSection(mediaPath).keys(): if not path.endswith('.xml') or path.replace( '.xml', '.bnk') not in bankFiles['all']: continue sect = ResMgr.openSection(mediaPath + '/' + path) bankName = path.replace('.xml', '.bnk') if sect is None: bankFiles['ignore'].add(bankName) print self.ID + ': error while reading', path continue bankData = banksData[bankName] = {} for struct in data_structure: key = struct['name'] if sect.has_key(key): bankData[key] = self.check_and_collect_data( key, sect[key], struct, False) data_new.setdefault(key, []).extend(bankData.get(key, [])) for bankSect in audio_mods['loadBanks'].values(): bankName = bankSect.asString print self.ID + ': clearing audio_mods section for bank', bankName self.editedBanks['delete'].append(bankName) self.editedBanks['delete'] = remDups(self.editedBanks['delete']) for key in ['loadBanks' ] + [struct['name'] for struct in data_structure]: audio_mods_new.createSection(key) for struct in data_structure: key = struct['name'] if data_old[key] != data_new.setdefault(key, []): self.editedBanks['remap'].add(key) if key in self.editedBanks['remap']: print self.ID + ': creating section for setting', key self.create_sect_from_data(audio_mods_new[key], data_new[key], struct) return audio_mods_new
def onSelectQualityOption(self, key, quality): LOG_NOTE('The quality = %s was selected.' % quality) self.__curQuality[key] = quality BigWorld.callback(0.1, partial(self.__onQualityChanged, key, quality))
def stop(): LOG_NOTE('End of mod')
def __init__(self): self.player = '' self.sys_msg = '' self.initialMSG = True self.type = SystemMessages.SM_TYPE.GameGreeting self.msgTime = int(time.strftime("%H")) * 60 + int(time.strftime("%M")) self.PrimaryToggle = 'ON' self.SecondaryTToggle = 'ON' self.SecondaryCWToggle = 'ON' self.hheight = '34' self.hwidth = '220' self.dheight = '10' self.dwidth = '220' self.msgMOTDEnabled = 'yes' self.msgMOTDmsg = 'Unable to retrieve primary messages' self.MOTDcolor = 'FFB300' self.AuthorEnabled = 'no' self.msgMEnabled = 'no' self.CheckTimer = 5 self.msgEnabledTourney = 'no' self.secondaryTourney = 'yes' self.msgEnabledCW = 'no' self.secondaryCW = 'yes' self.msgSTourneymsg = '' self.msgEnabledSTourney = 'no' self.combineTourney = 'yes' self.tourneyColor = 'FFCC00' self.msgEnabledSCW = 'no' self.msgSCWmsg = '' self.combineCW = 'yes' self.cwColor = 'FFCC00' self.PlaceHolder = 'Nothing to report at this time' self.UpdateCFG = 'no' self.modUpdated = 'NO' self.UpdateMODUrl = '' # self.MsgCTRupdated = 'Mod has updated!' # Create folder if necessary wotVersionCheck = ResMgr.openSection('../version.xml') try: self.wotVersion = wotVersionCheck.readString('version') self.wotVersion = self.wotVersion.split('#', 1)[0] self.wotVersion = self.wotVersion.split('v.', 1)[-1] self.wotVersion = self.wotVersion.strip() self.scriptFolder = 'res_mods/' + self.wotVersion + '/scripts/client/mods/' self.modFolder = self.scriptFolder + 'msg-ctr/' self.msgCTRxml = self.scriptFolder + 'msg-ctr.xml' self.pMsgXML = self.modFolder + 'primary.xml' self.stMsgXML = self.modFolder + 'secondary-tourney.xml' self.scwMsgXML = self.modFolder + 'secondary-clan-wars.xml' self.uMODsave = self.scriptFolder + 'msgctr.pyc' self.hpath = self.modFolder + 'msg-ctr-header.png' self.dpath = self.modFolder + 'msg-ctr-divider.png' #LOG_ERROR('%s' % (self.modFolder)) except: pass if not os.path.exists(self.modFolder): LOG_NOTE('Creating directory to store messages') os.makedirs(self.modFolder) # Parse config self.msgCFGmsg = ResMgr.openSection('scripts/client/mods/msg-ctr.xml') if self.msgCFGmsg is None: LOG_ERROR( 'Unable to open msg-ctr.xml, attempting to download default configuration' ) try: # LOG_ERROR('%s' % (self.msgCTRxml)) BigWorld.flushPythonLog() urllib.urlretrieve("http://pastebin.com/raw.php?i=HT5NU2D5", self.msgCTRxml) except: LOG_ERROR('Unable to download replacement msg-ctr.xml') self.msgCFGmsg = ResMgr.openSection( 'scripts/client/mods/msg-ctr.xml') self.rtrURL = self.msgCFGmsg.readString( 'Primary_Message_Address').strip() self.rtrTournURL = self.msgCFGmsg.readString( 'Secondary_Tourney_Address').strip() self.rtrCWarsURL = self.msgCFGmsg.readString( 'Secondary_CW_Address').strip() self.imgHUrl = self.msgCFGmsg.readString('Header_Graphic').strip() self.hheight = self.msgCFGmsg.readString('Header_Height').strip() self.hwidth = self.msgCFGmsg.readString('Header_Width').strip() self.imgDUrl = self.msgCFGmsg.readString('Divider_Graphic').strip() self.dheight = self.msgCFGmsg.readString('Divider_Height').strip() self.dwidth = self.msgCFGmsg.readString('Divider_Width').strip() LOG_NOTE('Downloaded default configuration file') else: self.rtrURL = self.msgCFGmsg.readString( 'Primary_Message_Address').strip() self.rtrTournURL = self.msgCFGmsg.readString( 'Secondary_Tourney_Address').strip() self.rtrCWarsURL = self.msgCFGmsg.readString( 'Secondary_CW_Address').strip() self.imgHUrl = self.msgCFGmsg.readString('Header_Graphic').strip() self.hheight = self.msgCFGmsg.readString('Header_Height').strip() self.hwidth = self.msgCFGmsg.readString('Header_Width').strip() self.imgDUrl = self.msgCFGmsg.readString('Divider_Graphic').strip() self.dheight = self.msgCFGmsg.readString('Divider_Height').strip() self.dwidth = self.msgCFGmsg.readString('Divider_Width').strip() LOG_NOTE( '----------------------------------------------------------------------------------------------\nOpened msg-ctr.xml: \nPrimary Message URL: %s \nSecondary Tournament URL: %s \nSecondary CW URL: %s \nHeader Graphic: %s \nDivider Graphic: %s' % (self.rtrURL, self.rtrTournURL, self.rtrCWarsURL, self.imgHUrl, self.imgDUrl)) LOG_NOTE( '----------------------------------------------------------------------------------------------' ) self.retrievePrimary() self.retrieveSecondaryT() self.retrieveSecondaryCW() LOG_NOTE('Initialized') # LOG_NOTE('self.LoggedIn %s \nplayer %s \nsys_msg %s \nself.msgTime %s' % (self.LoggedIn, self.player, self.sys_msg, self.msgTime)) BigWorld.flushPythonLog()
def checkConfigs(self): orig_engine = ResMgr.openSection('engine_config.xml') if orig_engine is None: LOG_ERROR('engine_config.xml not found') return new_engine = ResMgr.openSection('engine_config_edited.xml', True) new_engine.copy(orig_engine) ResMgr.purge('engine_config.xml') soundMgr = new_engine['soundMgr'] mediaPath = soundMgr['wwmediaPath'].asString self.check_wotmods(mediaPath) if self.editedBanks['wotmod']: return bankFiles = { 'mods': set(), 'pkg': set(), 'res': { os.path.basename(path) for path in glob.iglob('./res/' + mediaPath + '/*') if (path.endswith('.bnk') or path.endswith('.pck')) } } for pkgPath in glob.iglob('./res/packages/audioww*.pkg'): with zipfile.ZipFile(pkgPath) as pkg: bankFiles['pkg'].update( {os.path.basename(name) for name in pkg.namelist()}) bankFiles['orig'] = bankFiles['res'] | bankFiles['pkg'] bankFiles['mods'] = set(x for x in ResMgr.openSection(mediaPath).keys() if (x.endswith('.bnk') or x.endswith('.pck')) and x not in bankFiles['orig']) bankFiles['all'] = bankFiles['orig'] | bankFiles['mods'] active_profile_name = soundMgr['WWISE_active_profile'].asString active_profile = soundMgr[active_profile_name] poolKeys = { 'memoryManager': ('defaultPool', 'lowEnginePool', 'preparedPool', 'streamingPool', 'IOPoolSize'), 'soundRender': ('max_voices', ) } for poolKey, poolValuesList in poolKeys.iteritems(): for poolValue in poolValuesList: if active_profile[poolKey][poolValue].asInt != int( self.data[poolValue]): self.editedBanks['memory'].append(poolValue) active_profile[poolKey].writeInt(poolValue, self.data[poolValue]) print self.ID + ': changing value for memory setting:', poolValue moddedExist = [] for name, section in active_profile.items(): if 'soundbanks' not in name: continue for sectName, project in section.items(): if sectName != 'project': continue bankName = project['name'].asString if bankName not in bankFiles['all']: print '%s: clearing engine_config section for bank' % self.ID, bankName self.editedBanks['delete'].append(bankName) section.deleteSection(project) elif bankName not in moddedExist: moddedExist.append(bankName) audio_mods = ResMgr.openSection(mediaPath + '/audio_mods.xml') audio_mods_new = ResMgr.openSection( mediaPath + '/audio_mods_edited.xml', True) if audio_mods is None: LOG_NOTE('audio_mods.xml not found, will be created if needed') else: audio_mods_new.copy(audio_mods) ResMgr.purge(mediaPath + '/audio_mods.xml') bankFiles['ignore'] = set() modsKeys = ('events', 'switches', 'RTPCs', 'states') confList = [ x for x in ResMgr.openSection(mediaPath).keys() if x.endswith('.xml') and x.replace('.xml', '.bnk') in bankFiles['mods'] | bankFiles['orig'] ] for key in ('loadBanks', ) + modsKeys: if not audio_mods_new.has_key(key): audio_mods_new.createSection(key) confData_old = {key: [] for key in modsKeys} key_to_sub = { 'events': 'event', 'RTPCs': 'RTPC', 'switches': 'switch', 'states': 'stateGroup' } subList = {'switches': 'states', 'states': 'stateNames'} for key in modsKeys: conf = audio_mods_new[key] for sectName, confSect in conf.items(): if sectName != key_to_sub[key] or not confSect.has_key( 'name') or not confSect.has_key('mod'): conf.deleteSection(confSect) self.editedBanks['remap'].add(key) print '%s: cleaned wrong section for setting' % self.ID, key continue result = { 'name': confSect['name'].asString, 'mod': confSect['mod'].asString } if key in subList: stateList = [] for confSubName, confSubSect in confSect[ subList[key]].items(): if confSubName != 'state' or not confSubSect.has_key( 'name') or not confSubSect.has_key('mod'): confSect.deleteSection(confSubSect) self.editedBanks['remap'].add(key) print '%s: cleaned wrong section for setting' % self.ID, key continue stateList.append({ 'name': confSubSect['name'].asString, 'mod': confSubSect['mod'].asString }) result[subList[key]] = stateList confData_old[key].append(result) confData = {key: [] for key in modsKeys} bankConfData = {} for confPath in confList: confSect = ResMgr.openSection(mediaPath + '/' + confPath) bankName = confPath.replace('.xml', '.bnk') bankData = bankConfData[bankName] = {} if confSect is None: bankFiles['ignore'].add(bankName) print '%s: error while reading' % self.ID, confPath continue for key in modsKeys: if confSect.has_key(key): existingNames = [x['name'] for x in confData[key]] existingMods = [x['mod'] for x in confData[key]] bankEvents = bankData[key] = [] for sectName, subSect in confSect[key].items(): if sectName != key_to_sub[key] or not subSect.has_key( 'name') or not subSect.has_key('mod'): continue name = subSect['name'].asString mod = subSect['mod'].asString if name in existingNames or mod in existingMods: bankFiles['ignore'].add(bankName) print self.ID + ': duplicate events in', confPath + ': name:', name + ', mod:', mod break result = {'name': name, 'mod': mod} if key in subList: stateList = [] for subSectName, stateSect in subSect[ subList[key]].items(): if subSectName != 'state' or not stateSect.has_key( 'name') or not stateSect.has_key( 'mod'): continue stateList.append({ 'name': stateSect['name'].asString, 'mod': stateSect['mod'].asString }) result[subList[key]] = stateList bankEvents.append(result) if bankName in bankFiles['ignore']: del bankConfData[bankName] break for key in confData: if bankName not in bankFiles['ignore'] and key in bankData: confData[key].extend(bankData[key]) for bankSect in audio_mods_new['loadBanks'].values(): bankName = bankSect.asString print self.ID + ': clearing audio_mods section for bank', bankName self.editedBanks['delete'].append(bankName) audio_mods_new['loadBanks'].deleteSection(bankSect) self.editedBanks['delete'] = PYmodsCore.remDups( self.editedBanks['delete']) bankFiles['orig'] = set(map(str.lower, bankFiles['orig'])) for bankName in sorted(bankFiles['mods']): if bankName not in bankFiles[ 'orig'] and bankName not in moddedExist and bankName not in bankFiles[ 'ignore']: print self.ID + ': creating sections for bank', bankName if bankName in self.editedBanks['delete']: self.editedBanks['delete'].remove(bankName) self.editedBanks['move'].append(bankName) else: self.editedBanks['create'].append(bankName) active_profile.createSection( 'SFX_soundbanks_loadonce/project').writeString( 'name', bankName) for key in modsKeys: if confData_old[key] != confData[key]: self.editedBanks['remap'].add(key) if key in self.editedBanks['remap']: print self.ID + ': creating section for setting', key audio_mods_new.deleteSection(audio_mods_new[key]) newSect = audio_mods_new.createSection(key) for data in confData[key]: newSubSect = newSect.createSection(key_to_sub[key]) for subKey in ('name', 'mod'): newSubSect.createSection( subKey).asString = data[subKey] if key in subList: newSubLSect = newSubSect.createSection(subList[key]) for subData in data[subList[key]]: newSubSSect = newSubLSect.createSection('state') for subKey in subData: newSubSSect.createSection( subKey).asString = subData[subKey] if any(self.editedBanks[key] for key in ('delete', 'move', 'create', 'memory')): new_engine.save() xmlOrig = BigWorld.curCV + '/engine_config.xml' if os.path.isfile(xmlOrig): try: os.remove(xmlOrig) except StandardError: traceback.print_exc() newXml = './engine_config_edited.xml' if os.path.isfile(newXml): os.rename(newXml, xmlOrig) else: newXml = BigWorld.curCV + '/engine_config_edited.xml' if os.path.isfile(newXml): os.rename(newXml, xmlOrig) else: ResMgr.purge('engine_config_edited.xml') if any(self.editedBanks[key] for key in ('delete', 'move', 'remap')): dirName = BigWorld.curCV + '/' + mediaPath if not os.path.exists(dirName): os.makedirs(dirName) audio_mods_new.save() origXml = dirName + '/audio_mods.xml' if os.path.isfile(origXml): try: os.remove(origXml) except StandardError: traceback.print_exc() newXml = dirName + '/audio_mods_edited.xml' if os.path.isfile(newXml): os.rename(newXml, origXml) else: ResMgr.purge('audio_mods_edited.xml')
def PlayerLoggingIn(self): LOG_NOTE('Player logging in') BigWorld.flushPythonLog() msgCTRLoad.calculate() waitForConnection(self)
def start(): LOG_NOTE('Started mod')
def onPlayerSpeaking(self, dbid, state): LOG_NOTE("TEST_SUITE: onPlayerSpeaking() called")
def startSelfcheck(self): if self.__selfCheckInProgress or self.__needReboot: LOG_NOTE('Cannot start selfcheck.') return self.__selfCheckInProgress = True self.__checkStep(30, 1.0)
def log(self, name): LOG_NOTE( 'Routine {0} is blocked. Client can not send request on changing contacts by {1} protocol' .format(name, PROTO_TYPE_NAMES[self._protoType]))
def onGeometryMapped(spaceID, path): SoundGroups.g_instance.unloadAll() LOG_NOTE('[SPACE] Loading space: ' + path) SoundGroups.g_instance.preloadSoundGroups(path.split('/')[-1])
def MYLOG(message=""): try: print(message) except: pass LOG_NOTE(message)