| 112 | } |
| 113 | |
| 114 | SpawnTypeDatabase::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 | |
| 140 | SpawnType SpawnTypeDatabase::spawnType(String const& typeName) const { |
| 141 | if (auto spawnType = m_spawnTypes.maybe(typeName)) |
nothing calls this directly
no test coverage detected