Codechange: Make ContentType::State an enum class. (#14279)

This commit is contained in:
Peter Nelson
2025-05-19 17:11:28 +01:00
committed by GitHub
parent ad3a34e9ef
commit 77d6f6c69f
6 changed files with 58 additions and 58 deletions
+5 -5
View File
@@ -32,9 +32,9 @@
bool ContentInfo::IsSelected() const
{
switch (this->state) {
case ContentInfo::SELECTED:
case ContentInfo::AUTOSELECTED:
case ContentInfo::ALREADY_HERE:
case ContentInfo::State::Selected:
case ContentInfo::State::Autoselected:
case ContentInfo::State::AlreadyHere:
return true;
default:
@@ -48,7 +48,7 @@ bool ContentInfo::IsSelected() const
*/
bool ContentInfo::IsValid() const
{
return this->state < ContentInfo::INVALID && this->type >= CONTENT_TYPE_BEGIN && this->type < CONTENT_TYPE_END;
return this->state < ContentInfo::State::Invalid && this->type >= CONTENT_TYPE_BEGIN && this->type < CONTENT_TYPE_END;
}
/**
@@ -58,7 +58,7 @@ bool ContentInfo::IsValid() const
*/
std::optional<std::string> ContentInfo::GetTextfile(TextfileType type) const
{
if (this->state == INVALID) return std::nullopt;
if (this->state == ContentInfo::State::Invalid) return std::nullopt;
std::optional<std::string_view> tmp;
switch (this->type) {
default: NOT_REACHED();
+8 -8
View File
@@ -55,13 +55,13 @@ static constexpr ContentID INVALID_CONTENT_ID = UINT32_MAX; ///< Sentinel for in
/** Container for all important information about a piece of content. */
struct ContentInfo {
/** The state the content can be in. */
enum State : uint8_t {
UNSELECTED, ///< The content has not been selected
SELECTED, ///< The content has been manually selected
AUTOSELECTED, ///< The content has been selected as dependency
ALREADY_HERE, ///< The content is already at the client side
DOES_NOT_EXIST, ///< The content does not exist in the content system
INVALID, ///< The content's invalid
enum class State : uint8_t {
Unselected, ///< The content has not been selected
Selected, ///< The content has been manually selected
Autoselected, ///< The content has been selected as dependency
AlreadyHere, ///< The content is already at the client side
DoesNotExist, ///< The content does not exist in the content system
Invalid, ///< The content's invalid
};
ContentType type = INVALID_CONTENT_TYPE; ///< Type of content
@@ -76,7 +76,7 @@ struct ContentInfo {
MD5Hash md5sum; ///< The MD5 checksum
std::vector<ContentID> dependencies; ///< The dependencies (unique server side ids)
StringList tags; ///< Tags associated with the content
State state = State::UNSELECTED; ///< Whether the content info is selected (for download)
State state = State::Unselected; ///< Whether the content info is selected (for download)
bool upgrade = false; ///< This item is an upgrade
bool IsSelected() const;