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

Method SpawnTypeDatabase

source/game/StarSpawnTypeDatabase.cpp:114–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112}
113
114SpawnTypeDatabase::SpawnTypeDatabase() {
115 auto assets = Root::singleton().assets();
116 auto& files = assets->scanExtension("spawntypes");
117 assets->queueJsons(files);
118 uint64_t seedMix = 0;
119 for (auto const& file : files) {
120 try {
121 auto spawnTypes = assets->json(file);
122
123 for (auto const& entry : spawnTypes.iterateArray()) {
124 auto spawnType = spawnTypeFromJson(entry);
125
126 if (m_spawnTypes.contains(spawnType.typeName))
127 throw SpawnTypeDatabaseException::format("Duplicate spawnType named '{}' in config file '{}'", spawnType.typeName, file);
128
129 if (!entry.contains("seedMix"))
130 spawnType.seedMix = ++seedMix;
131
132 m_spawnTypes[spawnType.typeName] = spawnType;
133 }
134 } catch (std::exception const& e) {
135 throw SpawnTypeDatabaseException(strf("Error reading spawnType config file {}", file), e);
136 }
137 }
138}
139
140SpawnType SpawnTypeDatabase::spawnType(String const& typeName) const {
141 if (auto spawnType = m_spawnTypes.maybe(typeName))

Callers

nothing calls this directly

Calls 9

singletonClass · 0.85
spawnTypeFromJsonFunction · 0.85
strfFunction · 0.85
assetsMethod · 0.80
queueJsonsMethod · 0.80
jsonMethod · 0.80
iterateArrayMethod · 0.80
formatFunction · 0.50
containsMethod · 0.45

Tested by

no test coverage detected