MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / StringToContentType

Function StringToContentType

src/console_cmds.cpp:2185–2199  ·  view source on GitHub ↗

Resolve a string to a content type. */

Source from the content-addressed store, hash-verified

2183
2184/** Resolve a string to a content type. */
2185static ContentType StringToContentType(std::string_view str)
2186{
2187 static const std::initializer_list<std::pair<std::string_view, ContentType>> content_types = {
2188 {"base", CONTENT_TYPE_BASE_GRAPHICS},
2189 {"newgrf", CONTENT_TYPE_NEWGRF},
2190 {"ai", CONTENT_TYPE_AI},
2191 {"ailib", CONTENT_TYPE_AI_LIBRARY},
2192 {"scenario", CONTENT_TYPE_SCENARIO},
2193 {"heightmap", CONTENT_TYPE_HEIGHTMAP},
2194 };
2195 for (const auto &ct : content_types) {
2196 if (StrEqualsIgnoreCase(str, ct.first)) return ct.second;
2197 }
2198 return CONTENT_TYPE_END;
2199}
2200
2201/** Asynchronous callback */
2202struct ConsoleContentCallback : public ContentCallback {

Callers 1

ConContentFunction · 0.85

Calls 1

StrEqualsIgnoreCaseFunction · 0.85

Tested by

no test coverage detected