MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / mergeFinalParameters

Method mergeFinalParameters

source/game/StarMonsterDatabase.cpp:312–334  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

310}
311
312Json MonsterDatabase::mergeFinalParameters(JsonArray const& parameters) {
313 JsonObject mergedParameters;
314
315 for (auto const& applyParams : parameters) {
316 for (auto const& pair : applyParams.iterateObject()) {
317 Json value = mergedParameters.value(pair.first);
318
319 // Hard-coded merge for scripts and skills parameters, otherwise merge.
320 if (pair.first == "scripts" || pair.first == "skills" || pair.first == "specialSkills"
321 || pair.first == "baseSkills") {
322 auto array = value.optArray().value();
323 array.appendAll(pair.second.optArray().value());
324 value = std::move(array);
325 } else {
326 value = jsonMerge(value, pair.second);
327 }
328
329 mergedParameters[pair.first] = value;
330 }
331 }
332
333 return mergedParameters;
334}
335
336void MonsterDatabase::readCommonParameters(MonsterVariant& variant) {
337 variant.shortDescription = variant.parameters.optString("shortdescription").orMaybe(variant.shortDescription);

Callers

nothing calls this directly

Calls 5

iterateObjectMethod · 0.80
optArrayMethod · 0.80
appendAllMethod · 0.80
jsonMergeFunction · 0.50
valueMethod · 0.45

Tested by

no test coverage detected