Peter Nelson
ca75a8ce19
Codechange: Use enum class for NewsType.
2025-02-07 19:36:52 +00:00
Peter Nelson
4fd1929bf7
Codechange: Use EnumBitSet for NewsFlags.
2025-02-07 19:36:52 +00:00
Peter Nelson
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 Nelson
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 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 Nelson
1916454776
Codechange: Use EnumBitSet for IndustryLifeTypes.
2025-02-07 12:30:06 +00:00
Peter Nelson
c31494a413
Codechange: Use EnumBitSet for RoadStopDrawModes.
2025-02-04 18:52:08 +00:00
Peter Nelson
17f6da413d
Codechange: Use EnumBitSet for RoadStopSpecFlags.
2025-02-04 18:52:08 +00:00
Peter Nelson
1a6e7f2162
Codechange: Use EnumBitSet for StationSpecFlags.
2025-02-04 18:52:08 +00:00
Peter Nelson
59354576d4
Codechange: Use EnumBitSet for LandscapeTypes and remove LandscapeID. ( #13436 )
2025-02-01 23:09:18 +00:00
Peter Nelson
40aeedeade
Codechange: Use EnumBitSet for callback masks.
2025-01-31 17:08:24 +00:00
Peter Nelson
05ac1dd888
Codechange: Use EnumBitSet for TileFlags.
2025-01-29 21:46:39 +00:00
Peter Nelson
afc0745aa2
Codechange: Specify underlying type for all enums excluding those exposed to scripts. ( #13383 )
2025-01-28 22:17:34 +00:00
Jonathan G Rennison
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 Bussemaker
3dc12e3d65
Change: Don't distinguish between bus and truck stops when removing them
2025-01-27 19:00:39 +01:00
Rubidium
e894a5880c
Codechange: rename CargoID to CargoType and amend related variables/comments
2025-01-26 18:07:10 +01:00
Peter Nelson
5f0e4cd646
Codechange: Make RoadStopType an enum class. ( #13340 )
2025-01-19 21:43:17 +00:00
Peter Nelson
4397aa3909
Codechange: Make StationType an enum class. ( #13339 )
2025-01-19 20:53:08 +00:00
Peter Nelson
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 Nelson
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
Rubidium
fd5f6caed4
Codechange: use explicit TileIndex constructor for tile 0
2025-01-01 08:26:54 +01:00
Peter Nelson
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 Nelson
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 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 Nelson
6c09dcdd66
Codechange: Use reference for non-optional StationList parameter. ( #13092 )
2024-11-19 20:33:32 +00:00
Tyler Trahan
4cd46e54aa
Fix #12940 : Use specific error when overbuilding station on signals ( #12943 )
2024-11-06 14:13:04 -05:00
Tyler Trahan
c3bb512bd9
Remove: Hidden setting for adjacent stations ( #12862 )
2024-11-06 14:11:07 -05:00
Jonathan G Rennison
07e8547eb5
Fix: Terraform of road waypoint tiles ( #13040 )
2024-10-29 14:08:15 +01:00
SamuXarick
d5a13fb9f4
Codechange: Use TileOffsByAxis(...) in more places ( #13026 )
2024-10-24 15:58:15 -04:00
Rubidium
c9819f8957
Codechange: split GetRoadDir as bays have DiagDir and drive throughs have Axis
2024-10-24 20:40:32 +02:00
Rubidium
ce641af6a9
Codechange: use StationGfx over RoadStopDir + optional offset for drive through stop
2024-10-23 18:19:32 +02:00
Rubidium
18e8a34081
Codechange: replace "magic" trick with simpler straight forward code
2024-10-20 15:49:32 +02:00
Peter Nelson
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 Nelson
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 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 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 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 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 Rennison
a43dacd988
Add: NewGRF custom road waypoint support
2024-06-24 22:12:08 +02:00
Jonathan G Rennison
c35a5e5cb1
Change: Add variable ground types for road waypoints
2024-06-24 22:12:08 +02:00
Jonathan G Rennison
9c84e5df3f
Add: Road waypoint functionality
2024-06-24 22:12:08 +02:00
Tyler Trahan
8f6e21617f
Fix #12591 : Give descriptive error when station construction fails due to wrong layout ( #12678 )
2024-05-22 17:56:03 -04:00
Peter Nelson
d2c8b476b5
Codechange: Add functions to test if a station/roadstop class is a waypoint.
...
This is now checked by class label instead of by index.
2024-05-11 02:12:41 +01:00
Peter Nelson
d5671030b1
Codechange: Add NewGRFSpecsBase class to hold class/index information.
...
Standardises how the class index is stored in the spec, instead of relying ot the Spec structs having the same members.
This allows retrieving class_index and index without searching or using pointer arithmetic.
'cls_id' is renamed to 'class_index' to make it clearer that it is an index rather than the multichar label of the class.
2024-05-11 02:12:41 +01:00
Peter Nelson
cf96d49ced
Codechange: Use vector for airport tile layouts. ( #12607 )
...
Simplify AirportSpec data by storing layout information together in a vector, instead of separate arrays.
This removes manual memory management and separate count members.
The default layouts will be copied instead of always referring to the originals.
2024-05-02 11:37:54 +00:00
Peter Nelson
3b01d31280
Fix 8746be8: Reinstate current order test when removing road stop. ( #12552 )
...
#12144 replaced pool iteration with FindVehiclesWithOrder, however the test for current_order being OT_GOTO_STATION was erroneously removed.
2024-04-21 19:41:25 +01:00
Peter Nelson
40fa45a76a
Codechange: Emplace std::pair into vectors.
...
This creates the pair in the vector, instead of creating it then copying it in.
2024-04-20 10:25:20 +01:00
Peter Nelson
ed2db80990
Codechange: Use map.emplace() instead of map.insert(std::pair).
...
This avoids a copy of the pair into the map.
2024-04-20 10:25:20 +01:00
Peter Nelson
45886e50b2
Codechange: Unify where rail station tile flags are set. ( #12531 )
...
This avoids repeating the logic in three places.
2024-04-18 18:54:10 +01:00
Jonathan G Rennison
83d99ec11d
Fix #12506 : Update station/industry nearby lists in BuildOilRig ( #12511 )
2024-04-17 22:38:11 +02:00
Rubidium
b2218e75d4
Codefix: missing space between close parenthesis and open curly brace
2024-04-16 19:28:09 +02:00
Peter Nelson
9854553e10
Codechange: ZOOM_LVL_SHIFT/BASE are not actually ZOOM_LVLs.
...
Rename to ZOOM_BASE_SHIFT and ZOOM_BASE respectively, and derive from ZOOM_LVL instead of numeric value.
2024-04-04 22:27:03 +01:00
Peter Nelson
d683ec0183
Codechange: Move dropdown and slider out of widgets directory. ( #12403 )
...
Also shuffle headers to place widget includes near end.
This leaves the widgets directory solely for defining Widget IDs.
2024-03-31 19:37:16 +01:00
Peter Nelson
8746be8bf2
Codechange: Use FindVehiclesWithOrder when removing a road stop. ( #12144 )
2024-03-28 23:22:37 +01:00
Michael Lutz
8fb7d74dfe
Fix eabb9db: Drag building of road stops should not allow mixing z levels.
2024-03-28 22:28:48 +01:00
Michael Lutz
69acc132ca
Fix #12387 , eabb9db: [NewGRF] Wrong tile offset passed to rail station CB 149 (slope check)
2024-03-28 22:28:48 +01:00
Peter Nelson
ab94c8b511
Codechange: Iterate order lists instead of vehicles to find if any vehicle visits a station. ( #12315 )
...
This reduces the search time as shared orders are only searched once and non-front vehicles are skipped.
2024-03-17 09:34:28 +00:00
Patric Stout
a3cfd23cf9
Codechange: rename byte to uint8_t ( #12308 )
2024-03-16 23:59:32 +01:00
Michael Lutz
8b9f59d320
Codechange: Use references for non-optional in/out values of slope functions
2024-03-08 18:08:55 +01:00
Michael Lutz
8dda387f82
Codechange: Use std::tuple for slope functions with two return values
2024-03-08 18:08:55 +01:00
merni-ns
b8b80cb42e
Fix #12134 : Use correct error messages if clearing drive-through road stops fails ( #12139 )
2024-03-08 14:29:04 +01:00
Joan Josep
1b33b4058e
Fix: Redraw orders when a station feature is added/removed. ( #12061 )
2024-02-11 12:47:49 -05:00
frosch
b1718478c8
Codechange: Replace old non-standard attributes with C++17/20 standard attributes.
2024-02-02 22:29:28 +01:00
Tyler Trahan
735abfe111
Codechange: Split dates and timers into Economy and Calendar time ( #10700 )
2024-01-22 09:04:34 -05:00
Rubidium
e3f49ee7a0
Codechange: coding style fixes
2024-01-04 16:23:54 +01:00
Jonathan G Rennison
3e2060f155
Fix #11337 : Station blocked/pylon/wire bits with CBID_STATION_TILE_LAYOUT ( #11656 )
2023-12-31 18:31:01 -05:00
Jonathan G Rennison
3b18877b87
Fix #11629 : AirportGetNearestTown for rotated airports ( #11631 )
...
Add rotation parameter to AirportGetNearestTown
Add wrapper for existing stations
Remove unnecessary iterator cloning
2023-12-28 21:43:05 +00:00
Peter Nelson
c0ea0589b4
Fix: AirportGetNearestTown incorrectly assumed first TileIterator result was origin. ( #11565 )
...
Not all TileIterators are equal, and some do not start at the top-corner, so the perimeter check was wrong. As the caller already has thie origin tile, use that instead.
2023-12-09 09:47:41 +00:00
Peter Nelson
a258833aee
Fix 67d071d: WC_STATION_LIST should be invalidated by owner, not station index. ( #11530 )
2023-12-02 21:46:43 +00:00
Tyler Trahan
1f41e773d6
Codechange: Use consistent name for bay road stops
...
As of #10494 , this is how we describe original dead-end road stops.
2023-11-28 14:24:33 -05:00
Peter Nelson
ab535c0a86
Codechange: Add base() method to StrongType to allow access to the base type without casting. ( #11445 )
...
This removes the ability to explicitly cast to the base type, but the requirement
to use .base() means the conversion is still explicit.
2023-11-06 20:29:35 +00:00
Tyler Trahan
49d53c41ab
Doc: Don't use other names for road vehicle bay stops ( #11418 )
2023-11-01 21:19:31 +00:00
Tyler Trahan
2dd2910ab3
Feature: Cheat to fix station ratings at 100% ( #11346 )
2023-10-21 08:35:52 -04:00
Peter Nelson
f06b3e9846
Change: Use CARGO_LIST to show station cargo acceptance changes. ( #11379 )
...
This simplifies construction of the news message and allows for more than
two changes to be show in one line.
2023-10-20 20:14:46 +01:00
Peter Nelson
9602de474d
Codechange: Use iterators and/or range-for on cargo related loops.
2023-10-19 17:03:25 +01:00
Peter Nelson
b5dc9328f2
Change: Store station blocked/wires/pylons flags in map. ( #11337 )
...
This stores three flags in unused map bits, and avoids having to look up
station graphics and custom station specs to determine blocked/wires/pylons
status.
This potentially affects rail pathfinding performance.
Savegame version is not bumped, as the flags can just be updated every
time.
2023-09-30 12:30:25 +01:00
Peter Nelson
398c7e5f9d
Codechange: Use new function to get a bitmask of empty cargo types.
2023-09-21 18:29:02 +01:00
Peter Nelson
69ee38bd43
Codechange: Use GetAcceptanceMask() instead of duplicating it.
2023-09-21 18:29:02 +01:00
Peter Nelson
122bfa2afd
Codechange: Use less locals for station free names bitmask.
2023-09-20 21:57:51 +01:00
Peter Nelson
aeaa552385
Codechange: Use std::bitset instead of bool array.
...
This avoids use of C-style pointers and memset.
2023-09-20 21:57:51 +01:00
Peter Nelson
2eacf36d0a
Codechange: List fallback station names by ID instead of magic number.
...
This improves readability and intention of the station name generator.
2023-09-20 21:57:51 +01:00
frosch
baf7cc858b
Codechange: Rename ship docking tile related functions.
2023-09-19 22:49:59 +02:00
frosch
5733145c59
Cleanup: Remove unneeded parameters.
2023-09-19 22:49:59 +02:00
frosch
b6c8f301be
Codechange: Silence warnings about intentionally unused parameters.
2023-09-19 22:49:59 +02:00
Patric Stout
9c49a61249
Fix: base cargo payment on load/unload tile, instead of station sign location ( #11281 )
2023-09-13 14:41:09 +00:00
PeterN
acd7d3c913
Codechange: Rename *Railtype* to *RailType* for consistency. ( #11287 )
2023-09-11 08:55:12 +00:00
Tyler Trahan
77173a6a10
Codechange: Move date consts and functions to CalendarTime and TimerGameCalendar classes
2023-09-10 08:40:25 -04:00
Tyler Trahan
fca2b37726
Codechange: Move Ticks into their own class
2023-09-10 08:40:25 -04:00
Jonathan G Rennison
8df4aa7979
Fix: Road stops should not draw a ground sprite of 0 ( #11214 )
2023-08-20 15:46:19 -04:00
Patric Stout
07730584d7
Codechange: make explicit when a TileIndex is cast to its basetype ( #11190 )
...
This prevents people accidentially assigning a TileIndex to a Date
or any other type they shouldn't.
2023-08-15 18:12:05 +02:00
Patric Stout
a9ed590ca7
Codechange: use TimerGameCalendar::Date for variables in linkgraph that are dates ( #11187 )
2023-08-12 16:02:38 +02:00
Rubidium
eaae0bb5e7
Codechange: automatic adding of _t to (u)int types, and WChar to char32_t
...
for i in `find src -type f|grep -v 3rdparty/fmt|grep -v 3rdparty/catch2|grep -v 3rdparty/opengl|grep -v stdafx.h`; do sed 's/uint16& /uint16 \&/g;s/int8\([ >*),;[]\)/int8_t\1/g;s/int16\([ >*),;[]\)/int16_t\1/g;s/int32\([ >*),;[]\)/int32_t\1/g;s/int64\([ >*),;[]\)/int64_t\1/g;s/ uint32(/ uint32_t(/g;s/_uint8_t/_uint8/;s/Uint8_t/Uint8/;s/ft_int64_t/ft_int64/g;s/uint64$/uint64_t/;s/WChar/char32_t/g;s/char32_t char32_t/char32_t WChar/' -i $i; done
2023-07-19 19:30:14 +02:00
Rubidium
3e8f8c55c2
Codechange: make creating temporary StringParameters easier
2023-06-20 17:37:24 +02:00
Rubidium
1d902a97ce
Codechange: move StringParameters to strings_internal.h
2023-06-17 12:14:11 +02:00
Rubidium
0a5e58451b
Codechange: pass string parameters by reference
2023-06-14 06:14:08 +02:00
Rubidium
36aaa9d683
Codechange: let GetStringWithArgs use StringBuilder
2023-06-04 18:00:23 +02:00
PeterN
584faaf064
Change: Reorganise industry accept/produce arrays. ( #10853 )
...
Use a array of struct for each cargo instead of an array for each statistic.
This makes iterating for acceptance and production much simpler.
pct_transported is now calculated when needed.
2023-05-25 21:25:46 +01:00
Peter Nelson
f177ce7c9a
Codechange: Base CargoArray off std::array.
...
This avoids needing to define array accessors and allows use of
default value initialization.
2023-05-23 19:07:36 +01:00
Peter Nelson
76516d7f70
Codechange: Use IsValidCargoID/IsValidCargoType.
...
IsValidCargoType() is used only for unmapped IDs.
2023-05-22 20:43:40 +01:00
Rubidium
3323402aaa
Codechange: rename smallvec_type to container_func and use only when needed
2023-05-20 16:53:10 +02:00