// get an element T get(s32 x, s32 y) const { if(x < 0 || y < 0 || x >= m_sizeX || y >= m_sizeY) throw Exception("Array2D::get " + Vector2i(x,y)); else return getNoEx(x, y); }
bool Settings::getNoiseParamsFromValue(const std::string &name, NoiseParams &np) const { std::string value; if (!getNoEx(name, value)) return false; Strfnd f(value); np.offset = stof(f.next(",")); np.scale = stof(f.next(",")); f.next("("); np.spread.X = stof(f.next(",")); np.spread.Y = stof(f.next(",")); np.spread.Z = stof(f.next(")")); f.next(","); np.seed = stoi(f.next(",")); np.octaves = stoi(f.next(",")); np.persist = stof(f.next(",")); std::string optional_params = f.next(""); if (optional_params != "") np.lacunarity = stof(optional_params); return true; }
Json::Value Settings::getJson(const std::string & name, const Json::Value & def) { { std::lock_guard<std::mutex> lock(m_mutex); if (!m_json[name].empty()) return m_json.get(name, def); } //todo: remove later: Json::Value root; Settings * group = new Settings; if (getGroupNoEx(name, group)) { group->toJson(root); delete group; return root; } delete group; std::string value; getNoEx(name, value); if (value.empty()) return def; if (!json_reader.parse( value, root ) ) { errorstream << "Failed to parse json conf var [" << name << "]='" << value <<"' : " << json_reader.getFormattedErrorMessages()<<std::endl; } return root; }