Codechange: use EnumIndexArray for ContentInfo::State-indexed arrays

This commit is contained in:
Peter Nelson
2026-05-22 06:37:30 +01:00
committed by Peter Nelson
parent 6c39def287
commit 06b0b59c92
2 changed files with 8 additions and 3 deletions
+7 -3
View File
@@ -2303,10 +2303,14 @@ static void OutputContentState(const ContentInfo &ci)
static constexpr EnumIndexArray<std::string_view, ContentType, ContentType::End> types{
"", "Base graphics", "NewGRF", "AI", "AI library", "Scenario", "Heightmap", "Base sound", "Base music", "Game script", "GS library"
};
static const std::string_view states[] = { "Not selected", "Selected", "Dep Selected", "Installed", "Unknown" };
static const TextColour state_to_colour[] = { CC_COMMAND, CC_INFO, CC_INFO, CC_WHITE, CC_ERROR };
static constexpr EnumIndexArray<std::string_view, ContentInfo::State, ContentInfo::State::End> states{
"Not selected", "Selected", "Dep Selected", "Installed", "Unknown"
};
static constexpr EnumIndexArray<TextColour, ContentInfo::State, ContentInfo::State::End> state_to_colour{
CC_COMMAND, CC_INFO, CC_INFO, CC_WHITE, CC_ERROR
};
IConsolePrint(state_to_colour[to_underlying(ci.state)], "{}, {}, {}, {}, {:08X}, {}", ci.id, types[ci.type], states[to_underlying(ci.state)], ci.name, ci.unique_id, FormatArrayAsHex(ci.md5sum));
IConsolePrint(state_to_colour[ci.state], "{}, {}, {}, {}, {:08X}, {}", ci.id, types[ci.type], states[ci.state], ci.name, ci.unique_id, FormatArrayAsHex(ci.md5sum));
}
/** Downloading of content from the server. @copydoc IConsoleCmdProc */
+1
View File
@@ -53,6 +53,7 @@ struct ContentInfo {
AlreadyHere, ///< The content is already at the client side
DoesNotExist, ///< The content does not exist in the content system
Invalid, ///< The content's invalid
End, ///< End marker.
};
ContentType type = ContentType::Invalid; ///< Type of content