Skip to content

Commit

Permalink
Change: Increase object/station/roadstop class limit. (OpenTTD#12094)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
PeterN committed Apr 9, 2024
1 parent df8eeb1 commit 1773c5b
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
8 changes: 4 additions & 4 deletions src/newgrf_object.h
Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions src/newgrf_roadstop.h
Expand Up @@ -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)

Expand Down
10 changes: 5 additions & 5 deletions src/newgrf_station.h
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion src/road_cmd.h
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/station_cmd.h
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/waypoint_cmd.h
Expand Up @@ -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);
Expand Down

0 comments on commit 1773c5b

Please sign in to comment.