diff --git a/src/company_gui.cpp b/src/company_gui.cpp index 9b9bd46c30..0c5ea96194 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -1017,7 +1017,7 @@ public: } } else { /* Setting group livery */ - Command::Post(this->sel, widget == WID_SCL_PRI_COL_DROPDOWN, colour); + Command::Post(static_cast(this->sel), widget == WID_SCL_PRI_COL_DROPDOWN, colour); } } diff --git a/src/group.h b/src/group.h index 5b74b8c655..4259e074bc 100644 --- a/src/group.h +++ b/src/group.h @@ -17,7 +17,7 @@ #include "engine_type.h" #include "livery.h" -typedef Pool GroupPool; +typedef Pool GroupPool; extern GroupPool _group_pool; ///< Pool of groups. /** Statistics and caches on the vehicles in a group. */ diff --git a/src/group_gui.cpp b/src/group_gui.cpp index 14a8ae4605..3d2fc6b651 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -986,7 +986,7 @@ public: void OnQueryTextFinished(std::optional str) override { - if (str.has_value()) Command::Post(STR_ERROR_GROUP_CAN_T_RENAME, AlterGroupMode::Rename, this->group_rename, 0, *str); + if (str.has_value()) Command::Post(STR_ERROR_GROUP_CAN_T_RENAME, AlterGroupMode::Rename, this->group_rename, INVALID_GROUP, *str); this->group_rename = INVALID_GROUP; } diff --git a/src/group_type.h b/src/group_type.h index 32c4926197..e7f75af3d5 100644 --- a/src/group_type.h +++ b/src/group_type.h @@ -10,12 +10,14 @@ #ifndef GROUP_TYPE_H #define GROUP_TYPE_H -typedef uint16_t GroupID; ///< Type for all group identifiers. - -static const GroupID NEW_GROUP = 0xFFFC; ///< Sentinel for a to-be-created group. -static const GroupID ALL_GROUP = 0xFFFD; ///< All vehicles are in this group. -static const GroupID DEFAULT_GROUP = 0xFFFE; ///< Ungrouped vehicles are in this group. -static const GroupID INVALID_GROUP = 0xFFFF; ///< Sentinel for invalid groups. +enum GroupID : uint16_t { + GROUP_BEGIN = 0, + GROUP_END = 64000, + NEW_GROUP = 0xFFFC, ///< Sentinel for a to-be-created group. + ALL_GROUP = 0xFFFD, ///< All vehicles are in this group. + DEFAULT_GROUP = 0xFFFE, ///< Ungrouped vehicles are in this group. + INVALID_GROUP = 0xFFFF ///< Sentinel for invalid groups. +}; static const uint MAX_LENGTH_GROUP_NAME_CHARS = 32; ///< The maximum length of a group name in characters including '\0' diff --git a/src/script/api/script_group.cpp b/src/script/api/script_group.cpp index 5c50713d55..818f9d150c 100644 --- a/src/script/api/script_group.cpp +++ b/src/script/api/script_group.cpp @@ -36,7 +36,7 @@ if (!ScriptObject::Command::Do(&ScriptInstance::DoCommandReturnGroupID, (::VehicleType)vehicle_type, parent_group_id)) return GROUP_INVALID; /* In case of test-mode, we return GroupID 0 */ - return static_cast(0); + return ::GROUP_BEGIN; } /* static */ bool ScriptGroup::DeleteGroup(GroupID group_id) @@ -65,7 +65,7 @@ EnforcePreconditionEncodedText(false, text); EnforcePreconditionCustomError(false, ::Utf8StringLength(text) < MAX_LENGTH_GROUP_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG); - return ScriptObject::Command::Do(AlterGroupMode::Rename, group_id, 0, text); + return ScriptObject::Command::Do(AlterGroupMode::Rename, group_id, ::INVALID_GROUP, text); } /* static */ std::optional ScriptGroup::GetName(GroupID group_id)