mirror of https://github.com/OpenTTD/OpenTTD
Codechange: make GroupID an enum
parent
0b83b5a191
commit
19f3e74c2f
|
@ -1017,7 +1017,7 @@ public:
|
|||
}
|
||||
} else {
|
||||
/* Setting group livery */
|
||||
Command<CMD_SET_GROUP_LIVERY>::Post(this->sel, widget == WID_SCL_PRI_COL_DROPDOWN, colour);
|
||||
Command<CMD_SET_GROUP_LIVERY>::Post(static_cast<GroupID>(this->sel), widget == WID_SCL_PRI_COL_DROPDOWN, colour);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "engine_type.h"
|
||||
#include "livery.h"
|
||||
|
||||
typedef Pool<Group, GroupID, 16, 64000> GroupPool;
|
||||
typedef Pool<Group, GroupID, 16, GROUP_END> GroupPool;
|
||||
extern GroupPool _group_pool; ///< Pool of groups.
|
||||
|
||||
/** Statistics and caches on the vehicles in a group. */
|
||||
|
|
|
@ -986,7 +986,7 @@ public:
|
|||
|
||||
void OnQueryTextFinished(std::optional<std::string> str) override
|
||||
{
|
||||
if (str.has_value()) Command<CMD_ALTER_GROUP>::Post(STR_ERROR_GROUP_CAN_T_RENAME, AlterGroupMode::Rename, this->group_rename, 0, *str);
|
||||
if (str.has_value()) Command<CMD_ALTER_GROUP>::Post(STR_ERROR_GROUP_CAN_T_RENAME, AlterGroupMode::Rename, this->group_rename, INVALID_GROUP, *str);
|
||||
this->group_rename = INVALID_GROUP;
|
||||
}
|
||||
|
||||
|
|
|
@ -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'
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
if (!ScriptObject::Command<CMD_CREATE_GROUP>::Do(&ScriptInstance::DoCommandReturnGroupID, (::VehicleType)vehicle_type, parent_group_id)) return GROUP_INVALID;
|
||||
|
||||
/* In case of test-mode, we return GroupID 0 */
|
||||
return static_cast<GroupID>(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<CMD_ALTER_GROUP>::Do(AlterGroupMode::Rename, group_id, 0, text);
|
||||
return ScriptObject::Command<CMD_ALTER_GROUP>::Do(AlterGroupMode::Rename, group_id, ::INVALID_GROUP, text);
|
||||
}
|
||||
|
||||
/* static */ std::optional<std::string> ScriptGroup::GetName(GroupID group_id)
|
||||
|
|
Loading…
Reference in New Issue