// Static parsing function idList<Setting> Setting::ParseSettingsFromDict(const idDict& dict, int level) { idList<Setting> list; // Cycle through all difficulty settings (looking for "diff_0_change_*") idStr prefix = idStr(va(PATTERN_DIFF, level)) + PREFIX_CHANGE; for (const idKeyValue* keyVal = dict.MatchPrefix(prefix); keyVal != NULL; keyVal = dict.MatchPrefix(prefix, keyVal)) { DM_LOG(LC_DIFFICULTY, LT_INFO)LOGSTRING("Parsing keyvalue: %s = %s.\r", keyVal->GetKey().c_str(), keyVal->GetValue().c_str()); // Get the index from this keyvalue (remove the prefix and convert to int) idStr key = keyVal->GetKey(); key.StripLeadingOnce(prefix); if (key.IsNumeric()) { // Extract the index int index = atoi(key); // Parse the settings with the given index Setting s; s.ParseFromDict(dict, level, index); // Check for validity and insert into map if (s.isValid) { list.Append(s); } } else { gameLocal.Warning("Found invalid difficulty settings index: %s.", keyVal->GetKey().c_str()); DM_LOG(LC_DIFFICULTY, LT_ERROR)LOGSTRING("Found invalid difficulty settings index: %s.\r", keyVal->GetKey().c_str()); } } return list; }