Commit Graph
945 Commits
Author SHA1 Message Date
Peter NelsonandGitHub ff7eb996e6 Codechange: Use variable storage for GrfProps with cargo-type groups. (#13557)
Slots are only allocated when used instead of being reserved.

Array-based GrfProps are still used when the number of options is more limited.
2025-02-14 18:30:17 +00:00
Rubidiumandrubidium42 069ff846e4 Codechange: use std::vector/std::span for DrawTileSprites over malloc-ed table 2025-02-14 16:01:45 +01:00
Rubidiumandrubidium42 c3d5e6d2a0 Codechange: Use EnumBitSet for DoCommandFlags 2025-02-14 00:28:57 +01:00
Peter NelsonandPeter Nelson f309b90a1d Codechange: Use EnumBitSet for Airport blocks. 2025-02-13 22:02:02 +00:00
Peter NelsonandPeter Nelson 75387b9e2b Codechange: Use EnumBitSet for StationFacility. 2025-02-13 18:03:13 +00:00
Peter NelsonandGitHub 0d5708ba86 Codechange: Use EnumBitSet for AirportFTAClass::Flags (#13535) 2025-02-11 21:49:18 +00:00
Rubidiumandrubidium42 ec492cb267 Codechange: make CompanyMask a BaseBitSet implementation 2025-02-09 19:24:51 +01:00
Peter NelsonandGitHub d61b376998 Codechange: Use EnumBitSet for CargoClasses. (#13491) 2025-02-08 08:46:38 +00:00
Rubidiumandrubidium42 5f41bc0279 Codechange: put SourceType and SourceID into Source struct 2025-02-08 06:37:23 +01:00
Peter NelsonandPeter Nelson 9a6fc4eb76 Codechange: Use enum class for NewsReferenceType. 2025-02-07 19:36:52 +00:00
Peter NelsonandPeter Nelson ca75a8ce19 Codechange: Use enum class for NewsType. 2025-02-07 19:36:52 +00:00
Peter NelsonandPeter Nelson 4fd1929bf7 Codechange: Use EnumBitSet for NewsFlags. 2025-02-07 19:36:52 +00:00
Peter NelsonandGitHub 8c48f9fc49 Codechange: Pass preformatted string when updating sign positions. (#13480)
This forces the strings to be formatted in advance and avoids using global string parameters.
2025-02-07 13:19:00 +00:00
Peter NelsonandGitHub eaa765d615 Codechange: Disentangle news window style from news flags. (#13482)
This avoids NewsFlags being used as both bitmask and bitstuffed data.
2025-02-07 13:10:39 +00:00
Peter NelsonandPeter Nelson be00fd4447 Codechange: Use std::array as simple string parameter container.
ArrayStringParameters contains extra state that is used when formatting strings which isn't needed when creating parameter lists.

MakeParameters() now returns a std::array which contains only the parameter data. This simpler container is more widely available than before.
2025-02-07 12:30:34 +00:00
Peter NelsonandPeter Nelson 1916454776 Codechange: Use EnumBitSet for IndustryLifeTypes. 2025-02-07 12:30:06 +00:00
Peter NelsonandPeter Nelson c31494a413 Codechange: Use EnumBitSet for RoadStopDrawModes. 2025-02-04 18:52:08 +00:00
Peter NelsonandPeter Nelson 17f6da413d Codechange: Use EnumBitSet for RoadStopSpecFlags. 2025-02-04 18:52:08 +00:00
Peter NelsonandPeter Nelson 1a6e7f2162 Codechange: Use EnumBitSet for StationSpecFlags. 2025-02-04 18:52:08 +00:00
Peter NelsonandGitHub 59354576d4 Codechange: Use EnumBitSet for LandscapeTypes and remove LandscapeID. (#13436) 2025-02-01 23:09:18 +00:00
Peter NelsonandPeter Nelson 40aeedeade Codechange: Use EnumBitSet for callback masks. 2025-01-31 17:08:24 +00:00
Peter NelsonandPeter Nelson 05ac1dd888 Codechange: Use EnumBitSet for TileFlags. 2025-01-29 21:46:39 +00:00
Peter NelsonandGitHub afc0745aa2 Codechange: Specify underlying type for all enums excluding those exposed to scripts. (#13383) 2025-01-28 22:17:34 +00:00
Jonathan G RennisonandKuhnovic a7deb16e81 Fix #13384: Crash when remove bus/truck stop tool used on road waypoints
Or vice versa
2025-01-27 20:21:01 +01:00
Koen BussemakerandKuhnovic 3dc12e3d65 Change: Don't distinguish between bus and truck stops when removing them 2025-01-27 19:00:39 +01:00
Rubidiumandrubidium42 e894a5880c Codechange: rename CargoID to CargoType and amend related variables/comments 2025-01-26 18:07:10 +01:00
Peter NelsonandGitHub 5f0e4cd646 Codechange: Make RoadStopType an enum class. (#13340) 2025-01-19 21:43:17 +00:00
Peter NelsonandGitHub 4397aa3909 Codechange: Make StationType an enum class. (#13339) 2025-01-19 20:53:08 +00:00
Peter NelsonandGitHub 810e442203 Codechange: Split GoodsEntry cargo and flows data to unique_ptr. (#13058)
This allows cargo packets and cargo flow data to be empty if not in use, which is the case for the majority of station goods entries, and data is allocated when needed.

This reduces the initial size of a Station from 9192 bytes to 2024 bytes (on 64 bit platforms), although an allocation of 120 bytes is made for each active cargo type at a station.

Based on similar changes in JGRPP.
2025-01-02 20:48:23 +00:00
Peter NelsonandGitHub 810dc23215 Codechange: Replace viewport StringID specialisation with flags. (#13237)
When drawing viewport strings, the StringID is used to determine how to draw the sign. Instead, allow the behaviour to be set by the caller with flags. This means that some of the viewport-specific strings are no longer necessary.

ViewportAddString() now returns a pointer to a string as it may not actually add the string, in which case preparing the string parameters in advance is a waste of time.
2025-01-02 20:47:12 +00:00
Rubidiumandrubidium42 fd5f6caed4 Codechange: use explicit TileIndex constructor for tile 0 2025-01-01 08:26:54 +01:00
Peter NelsonandGitHub 1cf3a2a726 Codechange: No need to call DeleteAnimatedTile and DoClearSquare. (#13191)
DoClearSquare calls DeleteAnimatedTile itself so this is effectively a duplicate call.
2024-12-23 19:08:03 +00:00
Peter NelsonandGitHub 1e77fd0b61 Codechange: Remove unnecessary 'return_cmd_error` macro. (#13160)
This macro is a leftover from when errors used to be packed into a single int32_t.

`return CommandCost` is clearer, and doesn't need a macro.
2024-12-08 18:02:30 +00:00
Peter NelsonandPeter Nelson e73d6fcaac Codechange: Store grfid with entity grfprops.
This allows using the grfid without having to dereference the grffile pointer.

Uses no extra storage as it fits within otherwise wasted padding space.
2024-12-05 18:17:58 +00:00
Peter NelsonandGitHub 6c09dcdd66 Codechange: Use reference for non-optional StationList parameter. (#13092) 2024-11-19 20:33:32 +00:00
Tyler TrahanandGitHub 4cd46e54aa Fix #12940: Use specific error when overbuilding station on signals (#12943) 2024-11-06 14:13:04 -05:00
Tyler TrahanandGitHub c3bb512bd9 Remove: Hidden setting for adjacent stations (#12862) 2024-11-06 14:11:07 -05:00
Jonathan G RennisonandGitHub 07e8547eb5 Fix: Terraform of road waypoint tiles (#13040) 2024-10-29 14:08:15 +01:00
SamuXarickandGitHub d5a13fb9f4 Codechange: Use TileOffsByAxis(...) in more places (#13026) 2024-10-24 15:58:15 -04:00
Rubidiumandrubidium42 c9819f8957 Codechange: split GetRoadDir as bays have DiagDir and drive throughs have Axis 2024-10-24 20:40:32 +02:00
Rubidiumandrubidium42 ce641af6a9 Codechange: use StationGfx over RoadStopDir + optional offset for drive through stop 2024-10-23 18:19:32 +02:00
Rubidiumandrubidium42 18e8a34081 Codechange: replace "magic" trick with simpler straight forward code 2024-10-20 15:49:32 +02:00
Peter NelsonandGitHub 376e882a14 Codechange: Add HasFlag() to test if a value is present in a bitset enum type. (#12959)
This simplifies tests for `(x & y) != y` with enum classes by reducing repetition, similar to HasBit(), and also makes the intent of the expression clearer.
2024-09-22 14:51:37 +01:00
Peter NelsonandGitHub ff972ec4ff Codechange: Store custom station layouts in a map instead of nested vectors. (#12898)
The map key is the platforms and length combined. This simplifies allocation and searching for layouts.
2024-08-14 19:58:56 +01:00
Peter NelsonandPeter Nelson a03ddb3ccb Add: [NewGRF] Station property 1E, extended station tile flags.
Properties 11, 14 and 15 to set pylons/nowires/blocked intrinsically only support 8 station tiles.

Add new property to define all three flags for each station tile layout.
2024-08-03 14:57:34 +01:00
Peter NelsonandPeter Nelson 6e553410d3 Feature: [NewGRF] Allow fixed layout up to 256 tiles per NewGRF rail station.
Allow using up to 256 tile layouts in property 0E or callback 24, which defines the layout to be saved into the map.

This was originally limited to 8, because station graphics above 8 referred to other station types but that was changed in 2007.

1) More efficient than using callback 14, as that needs to be checked every time a station tile is rendered.
2) The layout does not get changed when the station is changed (this may or may not be desirable!)

Using more than 256 layouts still requires callback 14.
2024-08-03 14:57:34 +01:00
Peter NelsonandPeter Nelson d08636c841 Codechange: Store station layout tiles as std::span.
Using std::span provides both the start and end of the list, which allows validating that the requested layout is in range.
2024-08-03 14:57:34 +01:00
Peter NelsonandPeter Nelson 70a2ed062d Codechange: Rename CBID_STATION_SPRITE_LAYOUT and CBID_STATION_TILE_LAYOUT.
These callbacks both select rail station tile layouts, the difference is one happens when drawing, the other happens when building. Change the names to make this clearer.
2024-08-03 14:57:34 +01:00
Jonathan G Rennisonandrubidium42 a43dacd988 Add: NewGRF custom road waypoint support 2024-06-24 22:12:08 +02:00
Jonathan G Rennisonandrubidium42 c35a5e5cb1 Change: Add variable ground types for road waypoints 2024-06-24 22:12:08 +02:00