Commit Graph

276 Commits

Author SHA1 Message Date
SamuXarick f845b4bbc3
Fix: Changing NPF max search nodes while in-game had no effect (#12194) 2024-03-25 17:28:16 +01:00
Jonathan G Rennison 2189607c34 Codechange: Reduce size of class WaterRegion
The tile patch array is 256 bytes and is not needed for the majority
of water regions, change it to be optional via std::unique_ptr
2024-03-21 21:14:30 +01:00
Patric Stout a3cfd23cf9
Codechange: rename byte to uint8_t (#12308) 2024-03-16 23:59:32 +01:00
SamuXarick d7c5e9e8ab Codechange: Where the ship comes from is already known
This simplifies the handling of variables.

`ChooseShipTrack` is called upon entering `tile`, and looking further back to the caller, it can be deduced that `v->tile` matches `src_tile`. With that said, `enterdir` can also be removed, as it's not used anywhere else.

`CreateRandomPath` and `GetRandomFollowUpTrackdir` is being fed `src_tile` as it's 2nd parameter. This could be eliminated, as `v` is also being passed to it. Just use `v->tile` in those functions.
2024-03-16 17:02:19 +01:00
Patric Stout 5f4f9334ce
Codefix f1e999ec: use RandomRange(l) instead of _random.Next(l) (#12274) 2024-03-16 14:39:57 +00:00
SamuXarick a7625b8ae0 Fix #12280: Allow ships 90 degree turns if only choice
If there is no path found, a random path is created which forbids 90 degrees.
Allow 90 degrees if they're the only choice.
2024-03-15 08:04:08 +01:00
SamuXarick 14d95ef1c9
Fix #12279: Update random path each step (#12286) 2024-03-13 11:22:52 -04:00
Koen Bussemaker 984202b101 Codechange: Remove outdated YAPF example code 2024-03-11 20:25:48 +01:00
Rubidium 27eadc13ec Codechange: rename TILE_ADD(XY) to TileAdd(XY) 2024-03-10 15:50:24 +01:00
Kuhnovic 005892bfdb
Fix #12250: YAPF Trivial rail pathfinding crashes due to #12217 (#12258) 2024-03-10 14:37:56 +00:00
Kuhnovic 08ff1ab93e
Fix #12236: Ship pathfinder causes crash when ship is already at destination (#12238) 2024-03-08 23:46:13 +01:00
Kuhnovic 30e1a61c04
Fix: YAPF doesn't check destination for start nodes (#12217) 2024-03-08 14:23:33 +01:00
Peter Nelson b2ca6e1ac8
Codefix: Remove no-longer used ship special-case. (#12192)
This special-case has not been triggered since multi-tile docks were introduced.
2024-03-03 09:31:04 +00:00
Kuhnovic c5afc9173c
Fix #12176: Ships are circling in one place (#12181) 2024-03-02 21:45:54 +01:00
Kuhnovic 2fb1593550
Fix e38c3c5: Added missing return statement (#12185) 2024-02-27 12:55:42 +01:00
Koen Bussemaker 8a1cea2ab6 Codechange: Skip non-water water region patches in neigbor search 2024-02-18 11:46:34 +01:00
Kuhnovic e38c3c59f3
Fix #11840: Ship pathfinder always returns a valid trackdir if one is available (#12031) 2024-02-09 12:31:38 -05:00
Tyler Trahan 16e6da020d
Cleanup: Remove unnecessary Trackdir casts (#12038) 2024-02-08 09:46:55 -05:00
Koen Bussemaker 35c89d57f8 Codechange: Added debug printing for Water Regions 2024-02-04 22:50:04 +01:00
Koen Bussemaker 4b94457bf1 Fix #11802: Made determining water region edge traversability more robust 2024-02-04 22:50:04 +01:00
frosch b1718478c8 Codechange: Replace old non-standard attributes with C++17/20 standard attributes. 2024-02-02 22:29:28 +01:00
Kuhnovic 8a4a99b7e8
Fix #5713: FindClosestShipDepot only considers depots that are actually reachable (#11768) 2024-01-27 15:06:14 +01:00
Kuhnovic b38d3c2208
Change: simplified water region evaluation, removed savegame data (#11750) 2024-01-21 20:56:50 +00:00
Rubidium 6b21368bc2 Codechange: replace FIND_FIRST_BIT/FindFirstBit2x64 with FindFirstBit 2024-01-19 21:10:39 +01:00
Tyler Trahan 68814bd912
Codechange: Rename SIGTYPE_NORMAL to SIGTYPE_BLOCK (#11788) 2024-01-15 15:27:48 -05:00
Jonathan G Rennison 86b046cd26
Fix: Incorrect assertion in GetTileIndexFromLocalCoordinate (#11747) 2024-01-10 00:20:34 +00:00
Jonathan G Rennison 09eefd6e95 Cleanup: Remove unused constant YAPF_SHIP_PATH_CACHE_LENGTH 2024-01-09 20:58:51 +01:00
Kuhnovic f1e999ec59
Feature: Region-based pathfinder for ships (#10543) 2024-01-08 20:29:05 +01:00
Rubidium 3a676a5af0 Codechange: replace static inline with static for non-class functions 2024-01-06 13:37:33 +01:00
Rubidium e3f49ee7a0 Codechange: coding style fixes 2024-01-04 16:23:54 +01:00
SamuXarick c05ffb22bd
Fix #10452: Don't let AyStar max_search_nodes unattended when initializing (#11544)
Add a constant with the default value of 10000 and have the pathfinding settings refer to it.

Add a preventative method to AyStar when it's initializing, to limit the number of max_search_nodes if left unattended.
2023-12-17 22:50:53 +01: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
Peter Nelson 7d4a91ef9e
Cleanup: Remove some unused functions. (#11429)
These were picked up with cppcheck.
2023-11-03 21:21:00 +00:00
Peter Nelson ac9db3f5aa
Codechange: Don't use bit-field in Yapf rail node. (#11362)
Compacting 3 booleans into 3 bits could save memory allocation, however this data is inside a union which also contains a 4-byte integer. As such this gives the cost penalty of a bit-field without any benefit.
2023-10-09 12:11:55 +00:00
frosch b6c8f301be Codechange: Silence warnings about intentionally unused parameters. 2023-09-19 22:49:59 +02: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 9624017fc2
Codechange: be more type-specific about types in NPFs queue (#11192) 2023-08-12 18:18:22 +00:00
Patric Stout 299570b2c1
Codechange: make TimerGameCalendar Date and Year types strongly typed (#10761) 2023-08-12 18:14:21 +00: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 c518293135 Codechange: replace printf with fmt::print 2023-05-21 15:12:02 +02:00
Rubidium 68ff3fd062 Change: include fmt.h C++ headers in stdafx.h
This to prevent compilation issues between runs with and without precompiled
headers. Also remove the headers from the rest of the code base as they are
not needed there anymore, although they do relatively little harm.
2023-05-08 16:49:23 +02:00
Tyler Trahan 6501f84b4a
Codechange: Move calendar date functions inside TimerGameCalendar (#10753) 2023-05-04 13:14:12 +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
Rubidium 580d0a6343 Codechange: make use of Tile in for all direct map accesses 2023-02-28 07:11:48 +01:00
Rubidium b7a5d8e296 Codechange: add annotation to selectively force inlining in debug build 2023-01-28 20:32:45 +01:00
Rubidium 71b46db8d0 Cleanup: remove commented out code 2023-01-26 23:47:55 +01:00
Rubidium ae422be979 Cleanup: remove/replace trailing ; with . in comments 2023-01-26 23:47:55 +01: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 227626b0b7 Change: [YAPF] All compatible depots are targets for 'any depot' orders 2022-10-22 14:19:08 +02:00