mirror of https://github.com/OpenTTD/OpenTTD
Codechange: strongly type GoalID
parent
7cc194e745
commit
6aada55e96
|
@ -14,7 +14,7 @@
|
|||
#include "goal_type.h"
|
||||
#include "core/pool_type.hpp"
|
||||
|
||||
typedef Pool<Goal, GoalID, 64, 64000> GoalPool;
|
||||
using GoalPool = Pool<Goal, GoalID, 64, GoalID::End().base()>;
|
||||
extern GoalPool _goal_pool;
|
||||
|
||||
/** Struct about goals, current and completed */
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#define GOAL_TYPE_H
|
||||
|
||||
#include "core/enum_type.hpp"
|
||||
#include "core/pool_type.hpp"
|
||||
|
||||
static const uint32_t GOAL_QUESTION_BUTTON_COUNT = 18; ///< Amount of buttons available.
|
||||
|
||||
|
@ -34,8 +35,10 @@ enum GoalType : uint8_t {
|
|||
|
||||
typedef uint32_t GoalTypeID; ///< Contains either tile, industry ID, town ID, company ID, or story page ID
|
||||
|
||||
typedef uint16_t GoalID; ///< ID of a goal
|
||||
/** ID of a goal */
|
||||
using GoalID = PoolID<uint16_t, struct GoalIDTag, 64000, 0xFFFF>;
|
||||
|
||||
struct Goal;
|
||||
static const GoalID INVALID_GOAL = 0xFFFF; ///< Constant representing a non-existing goal.
|
||||
static constexpr GoalID INVALID_GOAL = GoalID::Invalid(); ///< Constant representing a non-existing goal.
|
||||
|
||||
#endif /* GOAL_TYPE_H */
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
if (!ScriptObject::Command<CMD_CREATE_GOAL>::Do(&ScriptInstance::DoCommandReturnGoalID, ScriptCompany::FromScriptCompanyID(company), (::GoalType)type, destination, text)) return GOAL_INVALID;
|
||||
|
||||
/* In case of test-mode, we return GoalID 0 */
|
||||
return static_cast<GoalID>(0);
|
||||
return GoalID::Begin();
|
||||
}
|
||||
|
||||
/* static */ bool ScriptGoal::Remove(GoalID goal_id)
|
||||
|
|
|
@ -105,7 +105,7 @@ static void UpdateElement(StoryPageElement &pe, TileIndex tile, uint32_t referen
|
|||
pe.referenced_id = tile.base();
|
||||
break;
|
||||
case SPET_GOAL:
|
||||
pe.referenced_id = (GoalID)reference;
|
||||
pe.referenced_id = reference;
|
||||
break;
|
||||
case SPET_BUTTON_PUSH:
|
||||
case SPET_BUTTON_TILE:
|
||||
|
|
Loading…
Reference in New Issue