void DifficultyManager::LoadDefaultDifficultySettings() { DM_LOG( LC_DIFFICULTY, LT_INFO )LOGSTRING( "Trying to load default difficulty settings from entityDefs.\r" ); // Construct the entityDef name (e.g. atdm:difficulty_settings_default) idStr defName( DEFAULT_DIFFICULTY_ENTITYDEF ); const idDict *difficultyDict = gameLocal.FindEntityDefDict( defName, true ); // grayman #3391 - don't create a default 'difficultyDict' // We want 'false' here, but FindEntityDefDict() // will print its own warning, so let's not // clutter the console with a redundant message if( difficultyDict != NULL ) { DM_LOG( LC_DIFFICULTY, LT_DEBUG )LOGSTRING( "Found difficulty settings: %s.\r", defName.c_str() ); // greebo: Try to lookup the entityDef for each difficulty level and load the settings for( int i = 0; i < DIFFICULTY_COUNT; i++ ) { // Let the setting structure know which level it is referring to _globalSettings[i].SetLevel( i ); // And load the settings _globalSettings[i].LoadFromEntityDef( *difficultyDict ); // Load the CVAR settings too _cvarSettings[i].SetLevel( i ); _cvarSettings[i].LoadFromEntityDef( *difficultyDict ); } } else { for( int i = 0; i < DIFFICULTY_COUNT; i++ ) { _globalSettings[i].Clear(); _cvarSettings[i].Clear(); } gameLocal.Warning( "DifficultyManager: Could not find default difficulty entityDef!" ); } }
static void EnumeratePrinters() { str::Str<WCHAR> output; PRINTER_INFO_5 *info5Arr = nullptr; DWORD bufSize = 0, printersCount; bool fOk = EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, nullptr, 5, nullptr, bufSize, &bufSize, &printersCount); if (fOk || GetLastError() == ERROR_INSUFFICIENT_BUFFER) { info5Arr = (PRINTER_INFO_5 *)malloc(bufSize); fOk = EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, nullptr, 5, (LPBYTE)info5Arr, bufSize, &bufSize, &printersCount); } if (!fOk || !info5Arr) { output.AppendFmt(L"Call to EnumPrinters failed with error %#x", GetLastError()); MessageBox(nullptr, output.Get(), L"SumatraPDF - EnumeratePrinters", MB_OK | MB_ICONERROR); free(info5Arr); return; } ScopedMem<WCHAR> defName(GetDefaultPrinterName()); for (DWORD i = 0; i < printersCount; i++) { const WCHAR *printerName = info5Arr[i].pPrinterName; const WCHAR *printerPort = info5Arr[i].pPortName; bool fDefault = str::Eq(defName, printerName); output.AppendFmt(L"%s (Port: %s, attributes: %#x%s)\n", printerName, printerPort, info5Arr[i].Attributes, fDefault ? L", default" : L""); DWORD bins = DeviceCapabilities(printerName, printerPort, DC_BINS, nullptr, nullptr); DWORD binNames = DeviceCapabilities(printerName, printerPort, DC_BINNAMES, nullptr, nullptr); CrashIf(bins != binNames); if (0 == bins) { output.Append(L" - no paper bins available\n"); } else if (bins == (DWORD)-1) { output.AppendFmt(L" - Call to DeviceCapabilities failed with error %#x\n", GetLastError()); } else { ScopedMem<WORD> binValues(AllocArray<WORD>(bins)); DeviceCapabilities(printerName, printerPort, DC_BINS, (WCHAR *)binValues.Get(), nullptr); ScopedMem<WCHAR> binNameValues(AllocArray<WCHAR>(24 * binNames)); DeviceCapabilities(printerName, printerPort, DC_BINNAMES, binNameValues.Get(), nullptr); for (DWORD j = 0; j < bins; j++) { output.AppendFmt(L" - '%s' (%d)\n", binNameValues.Get() + 24 * j, binValues.Get()[j]); } } } free(info5Arr); MessageBox(nullptr, output.Get(), L"SumatraPDF - EnumeratePrinters", MB_OK | MB_ICONINFORMATION); }
/* ================ idProgram::SetEntity ================ */ void idProgram::SetEntity( const char *name, idEntity *ent ) { idVarDef *def; idStr defName( "$" ); defName += name; def = GetDef( &type_entity, defName, &def_namespace ); if ( def && ( def->initialized != idVarDef::stackVariable ) ) { // 0 is reserved for NULL entity if ( !ent ) { *def->value.entityNumberPtr = 0; } else { *def->value.entityNumberPtr = ent->entityNumber + 1; } } }
/** * @brief Retrieves the specified access profile * * This method retrieves the named profile. If no name is provided, the default * profile is returned. * * There are two ways to specify the default. The first source of a named * default comes from within the configuration file. A keyword specified in the * Database object section named \b DefaultProfile can specify a named profile, * the value of the Name keyword in a \b Profile group. The second source comes * from the application programmer. In the constructor call to this object, the * application programmer can provide a named profile as the default, which * could ultimately come from the user (interface). * * If no default is specified, then only the keywords contained in the Database * object section of the configuration file is returned when requesting an * unnamed profile. * * @param name Optional name of the profile to return * * @return const DbProfile The specified profile. One should test the * validatity of the profile returned as this is the only indication of * success. */ const DbProfile DbAccess::getProfile(const std::string &name) const throw (iException &) { string defName(name); if (defName.empty()) { defName = getDefaultProfileName(); } else { if (!_profiles.exists(defName)) { return (DbProfile(defName)); } } // We have identified the proper profile if (_profiles.exists(defName)) { // Return the composite of this access scheme return(DbProfile(*this, _profiles.get(defName),defName)); } else { // Return only the high level database access keys and hope it is enough return (DbProfile(*this, DbProfile(),defName)); } }