1
0
Fork 0
Commit Graph

314 Commits (4f63340f8d1cc7ebf87d713c4b04e64ef8af792b)

Author SHA1 Message Date
Rubidium 09716dba75 Codechange: do not use MallocT for the pool
Needed to make the placement new operator use Tindex over size_t because of
ambiguity for the delete operator variant that also has the size.
2025-02-28 20:15:42 +01:00
Peter Nelson 6e10584b91
Codechange: Use EncodedStrings for News messages. (#13654) 2025-02-23 20:24:02 +00:00
Rubidium fd4adc55e3 Codechange: replace INVALID_X with XID::Invalid() for PoolIDs 2025-02-16 20:23:00 +01:00
Rubidium 7e04651220 Codechange: strongly type EngineID 2025-02-16 14:50:15 +01:00
Rubidium 380e7b48ce Codechange: use std::variant instead of a custom version for news references 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 2d7d085e8e
Codechange: Use EncodedString for error messages. (#13569) 2025-02-16 10:04:32 +00:00
Rubidium c3d5e6d2a0 Codechange: Use EnumBitSet for DoCommandFlags 2025-02-14 00:28:57 +01:00
Rubidium 37c215f1fd Fix #13513, ec492cb267: std::numeric_limits<CompanyMask> not working causes no vehicles to exist
std::numeric_limits<T>::max() returns 0 instead of an error when the type is unknown.
Solve it by implementing and using Set() and All() in BaseBitSet in same way as std::bitset.
2025-02-09 22:50:55 +01:00
Rubidium ec492cb267 Codechange: make CompanyMask a BaseBitSet implementation 2025-02-09 19:24:51 +01:00
Peter Nelson d61b376998
Codechange: Use EnumBitSet for CargoClasses. (#13491) 2025-02-08 08:46:38 +00:00
Peter Nelson 9a6fc4eb76 Codechange: Use enum class for NewsReferenceType. 2025-02-07 19:36:52 +00:00
Peter Nelson ca75a8ce19 Codechange: Use enum class for NewsType. 2025-02-07 19:36:52 +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 59354576d4
Codechange: Use EnumBitSet for LandscapeTypes and remove LandscapeID. (#13436) 2025-02-01 23:09:18 +00:00
Rubidium 4ca1fe6c32 Codechange: replace MAX_UVALUE with std::numeric_limits::max 2025-02-01 01:29:02 +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 40aeedeade Codechange: Use EnumBitSet for callback masks. 2025-01-31 17:08:24 +00:00
Peter Nelson 473728f181 Codechange: Use EnumBitSet for ExtraEngineFlags. 2025-01-29 21:46:39 +00:00
Rubidium e894a5880c Codechange: rename CargoID to CargoType and amend related variables/comments 2025-01-26 18:07:10 +01:00
Rubidium e7e9a12817 Codefix: Engine constructor's base parameter isn't an actual EngineID 2025-01-26 18:02:12 +01:00
Rubidium c0df898ac5 Codechange: do not implicitly convert during assignment to StrongType 2025-01-01 21:32:51 +01:00
Rubidium 3956ed086a Codechange: use Date/Year constructor explicitly 2025-01-01 16:25:32 +01: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 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 efcafe49f7
Fix: [NewGRF] New engines did not have a default cargo type set. (#13146)
Engines defined outside the original range did not have their cargo type/cargo label fields initialised properly.
If these engines are also not assigned a cargo type, they would therefore use the cargo in slot 0 instead of falling back to first refittable.
2024-12-03 21:59:22 +00: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
Jonathan G Rennison e477706bf5
Codechange: Add AssignBit function to assign the value of a single bit (#12934)
* Codechange: Add AssignBit function to assign the value of a single bit

* Codechange: Replace various uses of SB with AssignBit

* Codechange: Replace various uses of SB with a constant with SetBit
2024-09-10 08:36:58 -04:00
Peter Nelson 2fd9096070
Change: Decouple and remove landscape-dependent cargo types. (#11719)
Cargo types of default engines, industries and houses are now specified in terms of label.
2024-02-04 10:16:08 +00:00
Koen Bussemaker 5a55c4a934 Feature: [NewGRF] Allow higher max speeds for ships 2024-01-28 14:54:51 +01:00
Tyler Trahan 735abfe111
Codechange: Split dates and timers into Economy and Calendar time (#10700) 2024-01-22 09:04:34 -05: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
Rubidium e3f49ee7a0 Codechange: coding style fixes 2024-01-04 16:23:54 +01:00
Peter Nelson 934545a674
Fix: Calculation of initial engine age was inaccurate. (#11660)
Engine age in months was calculated as the difference in days / 32, instead of the actually difference in months. This would result in engines being artificially younger if a game was started at a later date.
2023-12-31 15:47:32 +00:00
Peter Nelson 33ff64ef74
Codechange: Simplify ConvertDateToYMD by returning YearMonthDay instead of outputting to a pointer. (#11637) 2023-12-28 21:34:08 +00:00
Peter Nelson bd3b28551e Codechange: Replace reliability magic numbers with constants.
These are derived as a percentage of UINT16_MAX.
2023-12-28 21:26:24 +00:00
Peter Nelson 7b2c143df0 Fix: Prevent underflow if engine base life is less than 8 years. 2023-12-28 21:26:24 +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
Tyler Trahan f49ffaaaea
Fix e4fd99a, Fix #11270: Vehicle max age is not subject to leap years (#11372) 2023-10-15 22:34:03 +00:00
Peter Nelson 5869f790d8
Fix: Check for engine variant loops during NewGRF initialization. (#11343)
Invalid NewGRFs could set up an engine variant loop that never ends. This
was checked for in some places that evaluated variants, but not all. In
most cases this would result in the engines not appearing, but could
potentially cause an infinite loop and crash.

Instead, during NewGRF initialization detect loops and remove invalid
variants before setting display flags.
2023-10-03 12:14:32 +01: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
Patric Stout 299570b2c1
Codechange: make TimerGameCalendar Date and Year types strongly typed (#10761) 2023-08-12 18:14:21 +00:00
Tyler Trahan e4fd99a33a
Codechange: Use DateAtStartOfYear() instead of multiplying by DAYS_IN_LEAP_YEAR (#11174) 2023-08-11 08:18:59 -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
Peter Nelson 76516d7f70 Codechange: Use IsValidCargoID/IsValidCargoType.
IsValidCargoType() is used only for unmapped IDs.
2023-05-22 20:43:40 +01:00
Peter Nelson bf9caa425b Change: Units-system can convert from N to kN, don't preconvert.
This allows force to passed as is and avoid premature rounding.

The AI function "GetMaxTractiveEffort" still needs to return kN to avoid breaking the API.
2023-05-09 23:02:51 +02:00