diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index 62a8e18c6d..781a93f8cc 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -2049,9 +2049,16 @@ DEF_CONSOLE_CMD(ConNetworkAuthorizedKey) /** Resolve a string to a content type. */ static ContentType StringToContentType(const char *str) { - static const char * const inv_lookup[] = { "", "base", "newgrf", "ai", "ailib", "scenario", "heightmap" }; - for (uint i = 1 /* there is no type 0 */; i < lengthof(inv_lookup); i++) { - if (StrEqualsIgnoreCase(str, inv_lookup[i])) return (ContentType)i; + static const std::initializer_list> content_types = { + {"base", CONTENT_TYPE_BASE_GRAPHICS}, + {"newgrf", CONTENT_TYPE_NEWGRF}, + {"ai", CONTENT_TYPE_AI}, + {"ailib", CONTENT_TYPE_AI_LIBRARY}, + {"scenario", CONTENT_TYPE_SCENARIO}, + {"heightmap", CONTENT_TYPE_HEIGHTMAP}, + }; + for (const auto &ct : content_types) { + if (StrEqualsIgnoreCase(str, ct.first)) return ct.second; } return CONTENT_TYPE_END; }