1
0
Fork 0
Commit Graph

306 Commits (a908c7bed01570377c11d60d66fcf774e3c93930)

Author SHA1 Message Date
Rubidium a908c7bed0 Codechange: remove uses of MemCmpT (and MemMoveT) 2025-03-18 21:18:37 +01:00
enveeed b0cc56a8b5
Fix: NewGRF vehicles display loading sprites when not actually loading or unloading (#13554) 2025-03-15 16:58:47 -04:00
Peter Nelson 8b39b23d2b
Codechange: Use EnumBitSet for VehicleFlags. (#13793) 2025-03-13 08:38:54 +00:00
Peter Nelson 91d22f7617
Codechange: Use EnumBitSet for VehStates. (#13755)
Renamed from VehStatus because pluralising that is weird.
2025-03-08 18:24:21 +00:00
Peter Nelson 3fde611012
Codechange: Use EnumBitSet for AirportMovingDataFlags. (#13754) 2025-03-06 19:03:41 +00:00
Peter Nelson a8f56fe7b3
Add: Variable to test how many vehicles in a chain contain a specific badge. (#13594) 2025-02-25 20:55:11 +00:00
Peter Nelson 9de913dd21
Codechange: Use helper to set grf_prop's grffile and grfid together. (#13612) 2025-02-18 22:33:13 +00:00
Peter Nelson 8f14894024 Add: NewGRF Badges. 2025-02-16 22:24:25 +00:00
Rubidium fd4adc55e3 Codechange: replace INVALID_X with XID::Invalid() for PoolIDs 2025-02-16 20:23:00 +01:00
Rubidium 59df0ff496 Codechange: strongly type StationID 2025-02-16 18:25:51 +01:00
Rubidium 70c9f3963c Codechange: strongly type VehicleID 2025-02-16 14:50:15 +01:00
Rubidium 7e04651220 Codechange: strongly type EngineID 2025-02-16 14:50:15 +01:00
Rubidium 9015c3651f Codechange: make EngineID an enum 2025-02-16 14:50:15 +01:00
Peter Nelson 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
Jonathan G Rennison d06b371254 Cleanup: Fix various spelling errors 2025-02-12 22:44:51 +01:00
Peter Nelson d61b376998
Codechange: Use EnumBitSet for CargoClasses. (#13491) 2025-02-08 08:46:38 +00:00
Rubidium e937c4dcfd Codechange: change DestinationID into class with conversion helpers
A DestinationID is either a DepotID or StationID, where the aircraft hangar
being conceptually a depot is actually a StationID. When making those types
stronger, a lot of casts would need to be added, but this shows the intent
much better.
2025-02-06 21:03:24 +01:00
Peter Nelson f8b1e3033f Codechange: Use EnumBitSet for EngineFlags. 2025-01-31 18:55:31 +00:00
Peter Nelson 6c4ddb242a Codechange: Use EnumBitSet for EngineMiscFlags. 2025-01-31 18:55:31 +00:00
Peter Nelson 917d5cc75d
Codechange: Use EnumBitSet for RoadTypeFlags and RailTypeFlags. (#13415) 2025-01-30 22:08:51 +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
Rubidium e894a5880c Codechange: rename CargoID to CargoType and amend related variables/comments 2025-01-26 18:07:10 +01:00
Peter Nelson 41c9f2d82c
Codefix: Pass cargo as CargoID. (#13311) 2025-01-13 19:23:26 +00:00
Peter Nelson cfb995b6e9
Codechange: Reimplement engine sort order with std::rotate. (#13124) 2024-12-05 22:17:40 +00:00
Peter Nelson f56b6756f1 Codechange: Sort EngineOverrideManager for fast lookups.
Allows quickly finding the EngineID given the type, grfid and local id of an engine, instead a linear scan.

This can reduce loading time when lots of engines are present and also affects performance in-game.
Lookup can be on the order of 10000 times faster.
2024-12-05 18:17:58 +00:00
Peter Nelson bc2513975f Codechange: Don't inherit EngineOverrideManager from std::vector.
Inheriting from std::vector means some operations are needlessly complex, and shouldn't really be done anyway.
2024-12-05 18:17:58 +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 3be0166801 Codechange: Use std::ranges::find where possible.
Replace `std::find(range.begin(), range.end(), ...)` with `std::ranges::find(range, ...)`.
2024-11-24 10:36:03 +00:00
Peter Nelson 0340e19e04
Codechange: Add to_underlying() to convert enum to underlying type. (#12958)
This simplifies and replaces static_cast and C-style casts doing the same.

`std::to_underlying()` exists in C++23 but not C++20.
2024-09-22 18:07:42 +01:00
Loïc Guilloux 29ce013eda
Codechange: Pass avail(able) as reference instead of pointer since they are never nullptr (#12696) 2024-05-18 17:04:16 +02:00
Peter Nelson 1424a184d8
Codechange: Use vector/span when loading wagon overrides. (#12604)
Replaces manual memory allocation and passing pointer with size.
2024-05-01 18:23:27 +01:00
Peter Nelson bf8de188ec
Codechange: Use member initialization of GRFFilePropsBase. (#12581)
Don't blame compilers for our sloppy initialisation.

Removes memset, and lengthof.
2024-04-26 22:58:54 +01:00
Rubidium 4f2412a272 Codechange: range based for loops instead of C-style for loops 2024-04-11 07:05:04 +02:00
Patric Stout a3cfd23cf9
Codechange: rename byte to uint8_t (#12308) 2024-03-16 23:59:32 +01:00
Peter Nelson 97e2bc612c Codechange: Rename and move SpriteGroup-specific cargo types into a namespace.
These 'cargo types' have special defined uses and must not be used elsewhere. This makes it clearer that they are special.
2024-01-09 18:56:05 +00:00
Peter Nelson 952d111b94 Codechange: Split CT_INVALID into CT_INVALID and INVALID_CARGO.
INVALID_CARGO is a CargoID and should be used for most purposes in game.
CT_INVALID is a CargoType used for defining default properties.
2024-01-09 18:56:05 +00:00
Peter Nelson ddd609ce9b
Feature: Randomize direction of rail vehicle on build based on probability callback. (#11489)
This allows NewGRF authors to indicate that the game should randomly flip rail vehicles on build, without needing to use random bits nor duplicate sprites to handle it themselves.

To use this functionality, test for callback 162 (CBID_VEHICLE_BUILD_PROBABILITY)  and var10 = 0 (values other than 0 are reserved for future use), and return a value between 0 and 100 inclusive.

The return value is a percentage chance of reversing the vehicle. A value of 0 will always build a forward facing vehicle, and 100 will always build a reverse facing vehicle.
2023-11-29 22:40:09 +00: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
Peter Nelson 429a6f58e7
Codechange: Use max_element to find best cargo (sub-)type in NewGRF var 42. (#11370)
This replaces two manual loops to find the best cargo (sub-)type.
2023-10-20 18:40:26 +01:00
frosch b6c8f301be Codechange: Silence warnings about intentionally unused parameters. 2023-09-19 22:49:59 +02: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
Patric Stout 30172fc037
Codechange: cleanup CargoPacket in terms of variable/function names (#11278)
Over the years, things got reused and changed, making the current
names somewhat unclear in what they actually mean and do.
2023-09-09 23:21:21 +02:00
Patric Stout 299570b2c1
Codechange: make TimerGameCalendar Date and Year types strongly typed (#10761) 2023-08-12 18:14:21 +00:00
Tyler Trahan 9a602ff304
Fix #10334: Store separate newgrf-safe version of date_of_last_service. (#11124)
This value is not changed when the date cheat is used, which caused issues with changing properties based on service date.

Co-authored-by: Peter Nelson <peter1138@openttd.org>
2023-08-06 12:57:10 -04: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
rubidium42 9f6fec01cd
Codechange: rename cargo aging days to periods, as they are not really days (#11112) 2023-07-12 13:20:02 -04: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
Rubidium fb856e16c1 Codechange: replace some min/clamp constructs to ClampTo 2023-05-06 21:26:13 +02:00