Commit Graph

815 Commits

Author SHA1 Message Date
merni-ns 55a7c59d13 Remove: NPF and pathfinder change settings 2024-05-10 10:38:44 +02:00
Jonathan G Rennison 433484cda3
Fix #12388: Vehicle::CopyVehicleConfigAndStatistics not releasing unit number (#12389) 2024-03-27 21:20:27 +01:00
Peter Nelson 3fc7b3b9a0 Codechange: Cache train curve speed limit can be stored in 16 bits.
Cache curve speed modifier and max curve speed are both 16 bit values so can be stored in 16 bit types instead of 32 bit types.
2024-03-17 16:22:38 +00:00
Patric Stout a3cfd23cf9
Codechange: rename byte to uint8_t (#12308) 2024-03-16 23:59:32 +01:00
Tyler Trahan 32b0fb9f6e
Fix #12010: Use economy timer for vehicle stats minimum age, not calendar (#12142) 2024-03-09 09:38:52 -05:00
Peter Nelson 56cf89d189
Change: Use bitmap for free unit ID generation. (#12165)
This improves performance of finding the next free unit number for a vehicle.

Based loosely on pool's used slot bitmap.
2024-02-25 12:36:13 +00: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
Tyler Trahan f6dd5053a3
Feature: Order flag to unbunch vehicles at depot (#11945) 2024-02-03 08:04:24 -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 6b21368bc2 Codechange: replace FIND_FIRST_BIT/FindFirstBit2x64 with FindFirstBit 2024-01-19 21:10:39 +01: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 e6d132d24b
Fix #10926: New free wagons no longer split by type. (#11507)
NormalizeTrainVehInDepot() should only be called if an engine was built, not for wagons.
2023-11-28 13:48:09 +00:00
Peter Nelson 43aa91a7f5
Fix #11437: Flipped shorter rail vehicles disappear in windows. (#11446)
Mixed signed/unsigned strikes again, causing an incorrect sprite offset for shortened vehicles.
2023-11-05 20:09:11 +00:00
Rubidium c9276c2959 Codechange: replace x.size() == 0 with x.empty() 2023-10-20 23:05:43 +02:00
Jonathan G Rennison 3afb732c37 Fix #11307: Incorrect GroupStatistics after selling leading wagon
When this results in a countable consist
2023-09-17 18:42:37 +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
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
merni-ns 1be668c2e4
Fix #10975: Clear a non-head engine's name (#10976) 2023-06-09 16:09:36 +01:00
PeterN ee2d0745e9
Fix #10502: Refit engine before attaching free wagons. (#10926)
Caused by incorrect order of operations when buying a train engine with refit and attaching free wagons.
2023-06-04 15:57:36 +01:00
Jonathan G Rennison a2c0e6aa18
Fix #10831: Level crossing parts left barred after crossing tile removal (#10874) 2023-06-03 23:04:24 +02:00
Michael Lutz 7e906c7c59 Change: Preserve orders and related settings where possible when moving engines around in a train. 2023-05-10 00:35:02 +02:00
Michael Lutz 07449be876 Codechange: A vehicle that is not a front engine can't be removed from a vehicle group, so just remove a pointless function call. 2023-05-10 00:35:02 +02:00
Jonathan G Rennison 8d501f2db1
Fix #10741: Rail platforms left partially reserved after train crash (#10751) 2023-05-04 21:45:13 +01:00
Peter Nelson 4a5e413a6c Cleanup: Remove unnecessary VehicleRandomBits()
Simple Random() assignment to byte does the same.
2023-05-04 21:42:28 +01:00
Rubidium f74e26ca7e Codechange: replace error/usererror printf variant with fmt variant and rename 2023-04-25 17:55:09 +02:00
Patric Stout 7aa2b9ab0a
Codechange: move all date-related variables inside the timer (#10706) 2023-04-24 15:56:01 +00:00
Rubidium e8af8daa68 Codechange: pass "ground vehicle" to GetTileSlopeZ since for tunnel/bridges there are two states
Previously it checked the position in non-driving direction to "guess" whether
a ground vehicle was using the function, so on tunnels/bridges it could either
return the Z of the (virtual) ground compared to the Z of the path the vehicle
would take.
2023-04-09 19:00:26 +02:00
SamuXarick b52b29b1a4 Change: Avoid crashing to the side of a train
When a road vehicle is already running on a multi level crossing, and a train shows up ahead, don't make the road vehicle crash on the side of the train.
2023-02-22 20:09:02 +01:00
rubidium42 6ba55e663e Codechange: do not hide variables with other variables 2023-01-29 07:21:34 +01:00
Rubidium fe2bcd2a58 Codechange: migrate size related functions to Map structure 2023-01-21 17:11:40 +01:00
Rubidium 375a5b8e3f Codechange: refactor FindClosestDepot to not use pointers, but return a struct 2023-01-04 22:30:48 +01:00
PeterN 7b5edba76c
Change: Support flipping shorter engines without NewGRF support. (#10262)
* Change: Support flipping shorter engines without NewGRF support.
* Cleanup: Remove write-only prop27_set temporary flag.
2022-12-23 21:02:14 +00:00
Peter Nelson ed60c88b0a Change: Use power-of-2 scaling for some dimensions in GUI.
These are related to drawing sprites that are normally drawn on the
landscape, and should therefore still follow power-of-2 scaling to fit
correctly.
2022-11-12 18:28:39 +00:00
Peter Nelson f5f035a22b Codechange: Make use of Rect Width/Height helpers. 2022-11-12 18:28:39 +00:00
Artin Alavi fd4f148c62
Feature: Hotkey to honk a vehicle's horn (#10110) 2022-11-10 21:36:18 +01:00
Henry Wilson 59dbcdb5ba Feature: Display power-to-weight ratio in ground vehicle details GUI 2022-11-08 21:02:08 +01:00
Tyler Trahan c19abebf8d
Feature: Multi-track level crossings (#9931) 2022-11-01 16:51:23 -04:00
Nicolas Chappe 721d98a7d0 Feature: Constantly update destination of 'any depot' orders 2022-10-22 14:19:08 +02:00
Nicolas Chappe a4052ca348 Codechange: Add VehicleOrderSaver::Restore() 2022-10-22 14:19:08 +02:00
Nicolas Chappe 7e7d943526 Codechange: [YAPF] Allow to retrieve the final tile of the calculated path 2022-10-22 14:19:08 +02:00
Nicolas Chappe a9a21e784d Codechange: Always set the ODATFB_NEAREST_DEPOT flag for 'any depot' orders 2022-10-22 14:19:08 +02:00
Bouke Haarsma bda602f4b0 Fix: reduce framerate overhead on train ticks
Tick() is a noop for all but front-engine / crashed vehicles. Starting a framerate is rather cheap, but not free, and introduces a lot of overhead for such close loops.
2022-10-16 15:13:29 +02:00
Patric Stout 979704271b
Fix: reverse train direction command did not validate the given vehicle properly (#9947)
You could give a wagon in the chain to reverse (which makes no
functional sense ofc). In result, only parts of the vehicle were
reversing, leading to weird crashes.
2022-07-09 12:28:20 +02:00
Niels Martin Hansen e68bf58989 Codechange: Use anonymous union for vehicle orders/old orders list 2022-02-15 20:01:10 +01:00
Michael Lutz 41fa16f325 Codechange: Don't use globals for return values from vehicle command procs. 2021-12-16 22:28:32 +01:00
Michael Lutz 13528bfcd0 Codechange: Un-bitstuff all remaining commands. 2021-12-16 22:28:32 +01:00