From 270728ba388f819356f5cf1e007768786671e931 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Tue, 9 Apr 2024 22:04:54 +0100 Subject: [PATCH] Change: Increase object/station/roadstop class limit. The class limit is arbitrary and not stored in game state. This change prevents all entities in classes after the 255th class from being dumped into the first class. --- src/newgrf_object.h | 8 ++++---- src/newgrf_roadstop.h | 10 +++++----- src/newgrf_station.h | 10 +++++----- src/road_cmd.h | 2 +- src/station_cmd.h | 4 ++-- src/waypoint_cmd.h | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/newgrf_object.h b/src/newgrf_object.h index 0d224410ab..8b17a7c7a6 100644 --- a/src/newgrf_object.h +++ b/src/newgrf_object.h @@ -45,10 +45,10 @@ static const uint8_t OBJECT_SIZE_1X1 = 0x11; ///< The value of a NewGRF's size p void ResetObjects(); /** Class IDs for objects. */ -enum ObjectClassID : uint8_t { - OBJECT_CLASS_BEGIN = 0, ///< The lowest valid value - OBJECT_CLASS_MAX = 0xFF, ///< Maximum number of classes. - INVALID_OBJECT_CLASS = 0xFF, ///< Class for the less fortunate. +enum ObjectClassID : uint16_t { + OBJECT_CLASS_BEGIN = 0, ///< The lowest valid value + OBJECT_CLASS_MAX = UINT16_MAX, ///< Maximum number of classes. + INVALID_OBJECT_CLASS = UINT16_MAX, ///< Class for the less fortunate. }; /** Allow incrementing of ObjectClassID variables */ DECLARE_POSTFIX_INCREMENT(ObjectClassID) diff --git a/src/newgrf_roadstop.h b/src/newgrf_roadstop.h index 8c231dc4ca..03df70e9fa 100644 --- a/src/newgrf_roadstop.h +++ b/src/newgrf_roadstop.h @@ -22,11 +22,11 @@ /** The maximum amount of roadstops a single GRF is allowed to add */ static const int NUM_ROADSTOPS_PER_GRF = UINT16_MAX - 1; -enum RoadStopClassID : uint8_t { - ROADSTOP_CLASS_BEGIN = 0, ///< The lowest valid value - ROADSTOP_CLASS_DFLT = 0, ///< Default road stop class. - ROADSTOP_CLASS_WAYP, ///< Waypoint class (unimplemented: this is reserved for future use with road waypoints). - ROADSTOP_CLASS_MAX = 255, ///< Maximum number of classes. +enum RoadStopClassID : uint16_t { + ROADSTOP_CLASS_BEGIN = 0, ///< The lowest valid value + ROADSTOP_CLASS_DFLT = 0, ///< Default road stop class. + ROADSTOP_CLASS_WAYP, ///< Waypoint class (unimplemented: this is reserved for future use with road waypoints). + ROADSTOP_CLASS_MAX = UINT16_MAX, ///< Maximum number of classes. }; DECLARE_POSTFIX_INCREMENT(RoadStopClassID) diff --git a/src/newgrf_station.h b/src/newgrf_station.h index be9fa03dfe..2924ff4288 100644 --- a/src/newgrf_station.h +++ b/src/newgrf_station.h @@ -80,11 +80,11 @@ struct StationResolverObject : public ResolverObject { uint32_t GetDebugID() const override; }; -enum StationClassID : uint8_t { - STAT_CLASS_BEGIN = 0, ///< the lowest valid value - STAT_CLASS_DFLT = 0, ///< Default station class. - STAT_CLASS_WAYP, ///< Waypoint class. - STAT_CLASS_MAX = 255, ///< Maximum number of classes. +enum StationClassID : uint16_t { + STAT_CLASS_BEGIN = 0, ///< the lowest valid value + STAT_CLASS_DFLT = 0, ///< Default station class. + STAT_CLASS_WAYP, ///< Waypoint class. + STAT_CLASS_MAX = UINT16_MAX, ///< Maximum number of classes. }; /** Allow incrementing of StationClassID variables */ diff --git a/src/road_cmd.h b/src/road_cmd.h index 3a957f2a15..71883ddada 100644 --- a/src/road_cmd.h +++ b/src/road_cmd.h @@ -14,7 +14,7 @@ #include "road_type.h" #include "command_type.h" -enum RoadStopClassID : uint8_t; +enum RoadStopClassID : uint16_t; void DrawRoadDepotSprite(int x, int y, DiagDirection dir, RoadType rt); void UpdateNearestTownForRoadTiles(bool invalidate); diff --git a/src/station_cmd.h b/src/station_cmd.h index ef566af5fd..00f98a0d35 100644 --- a/src/station_cmd.h +++ b/src/station_cmd.h @@ -13,8 +13,8 @@ #include "command_type.h" #include "station_type.h" -enum StationClassID : uint8_t; -enum RoadStopClassID : uint8_t; +enum StationClassID : uint16_t; +enum RoadStopClassID : uint16_t; extern Town *AirportGetNearestTown(const struct AirportSpec *as, Direction rotation, TileIndex tile, TileIterator &&it, uint &mindist); extern uint8_t GetAirportNoiseLevelForDistance(const struct AirportSpec *as, uint distance); diff --git a/src/waypoint_cmd.h b/src/waypoint_cmd.h index b64ef0496c..02914124c6 100644 --- a/src/waypoint_cmd.h +++ b/src/waypoint_cmd.h @@ -13,7 +13,7 @@ #include "command_type.h" #include "station_type.h" -enum StationClassID : uint8_t; +enum StationClassID : uint16_t; CommandCost CmdBuildRailWaypoint(DoCommandFlag flags, TileIndex start_tile, Axis axis, uint8_t width, uint8_t height, StationClassID spec_class, uint16_t spec_index, StationID station_to_join, bool adjacent); CommandCost CmdRemoveFromRailWaypoint(DoCommandFlag flags, TileIndex start, TileIndex end, bool keep_rail);