Commit Graph

893 Commits

Author SHA1 Message Date
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
Peter Nelson e6740046ee Codechange: Use range-for iteration. 2023-05-11 07:58:55 +01:00
PeterN 882f06bf14
Fix: Support more than 256 stations/waypoints/roadstops per class. (#10793)
It was already possible to define more than 256 per class, but not possible
to use them as the index used in GUI and passed through commands was limited
to a byte.
2023-05-08 18:09:33 +00:00
Rubidium fb856e16c1 Codechange: replace some min/clamp constructs to ClampTo 2023-05-06 21:26:13 +02:00
Tyler Trahan 6501f84b4a
Codechange: Move calendar date functions inside TimerGameCalendar (#10753) 2023-05-04 13:14:12 +00:00
Patric Stout 31ad990831
Codechange: move tick-counter into TimerGameTick (#10712) 2023-04-24 16:55:40 +00:00
Patric Stout 7aa2b9ab0a
Codechange: move all date-related variables inside the timer (#10706) 2023-04-24 15:56:01 +00:00
Tyler Trahan bc44158f9a
Change: Allow overbuilding station and waypoint tiles (#10618) 2023-04-16 09:05:04 +02:00
Charles Pigott b282664242 Codechange: Replace all usages of alloca/AllocaM with more modern/less discouraged alternatives 2023-04-15 16:57:00 +01:00
Patric Stout 3ebc7ad16e Codechange: migrate all game-time-related timers to the new framework 2023-04-15 13:58:55 +02: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
Jonathan G Rennison c74dfe393f
Fix #10556: Duplication of road infrastructure count updates (#10557)
When building a road stop
2023-03-08 18:38:19 +00:00
Rubidium 580d0a6343 Codechange: make use of Tile in for all direct map accesses 2023-02-28 07:11:48 +01:00
Chenshu Yu eabb9db0bb
Fix #9810: 'Rebuilding' a through road stop costs money (#9852) 2023-02-27 08:59:42 +00:00
Michael Lutz aab580e0ac Codechange: [Linkgraph] Drop node/edge wrappers from LinkGraph. 2023-02-26 21:41:24 +01:00
Michael Lutz 7352f812e6 Codechange: [Linkgraph] Only store present link graph edges and not all possible edges. 2023-02-26 21:41:24 +01:00
Jonathan G Rennison 4c1406a4b5 Add: NewGRF road stops 2023-02-26 21:28:30 +01:00
Rubidium 8cbf1be9d6 Codechange: split large function into smaller functions with self-explanatory names 2023-02-25 23:57:36 +01:00
Jonathan G Rennison 9c915f05ec Fix: Water infrastructure accounting when building docks 2023-01-29 23:15:53 +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
Patric Stout 1fb101eabb
Codechange: address CodeQL issue "Multiplication result converted to larger type" (#10306)
Most are very unlikely to ever be triggered in our codebase; two
stand out: linkgraph and money cheat. Those, potentially, could
wrap earlier than expected.
2023-01-02 20:30:02 +00:00
Peter Nelson 138198e971 Change: Separate ground sprite from foundation sprite offsets. 2022-12-23 15:43:11 +00:00
SamuXarick a8a7f95665
Change: Allow to build dock on clearable watered object tiles (#8514) 2022-11-08 21:04:14 +01:00
Jonathan G Rennison 4dc741a8a0
Fix #10011: Incorrect infrastructure totals when overbuilding bay road stop (#10143)
Fix https://github.com/OpenTTD/OpenTTD/issues/10011
2022-11-06 16:46:11 +01:00
PeterN f59f0195e3
Fix: Wrong string used to determine size of zoomed out station sign. (#10036) 2022-09-20 20:54:42 +01:00
Patric Stout 100aca1848
Fix: CmdRemoveRoadStop didn't validate the height property properly (#9945)
Height was a unsigned 32bit integer, where TileAddWrap uses a
signed 32bit integer for the height. In result, there was an
implicit cast from unsigned to signed, messing things up.

But looking at it from a functional perspective, allowing such
large values is not sensible. In fact, width is restricted to
just a 8bit integer. By changing height to a 8bit integer too,
the implicit cast will never make a positive value negative anymore.
2022-07-09 12:27:58 +02:00
Jonathan G Rennison 19af139631 Fix #9937: Station industries_near incorrect after removing part moved sign
RecomputeCatchment was being called before moving the sign tile
instead of afterwards
2022-06-29 12:49:55 +02:00
Tyler Trahan f92cf38ab5 Feature: Allow disabling local authority control of company actions 2022-04-02 22:50:28 +02:00
Tyler Trahan fbbc80f79e Fix #9020: Update station coverage highlight when adding/removing tiles 2022-03-10 20:54:45 +01:00
J0anJosep d9a37c915f Cleanup #9725: Replace cmd_helper related functions and remove cmd_helper.h. 2022-02-02 21:30:15 +01:00
Jonathan G Rennison 4844268d1c Fix #9774: CmdBuildRoadStop updated station acceptance in estimate mode 2021-12-30 20:39:10 +01:00
Michael Lutz c6d7b98808 Codechange: Un-bitstuff landscape commands. 2021-12-16 22:28:32 +01:00
Michael Lutz 55170ae703 Codechange: Un-bitstuff rail commands. 2021-12-16 22:28:32 +01:00
Michael Lutz 6fe445e6c0 Codechange: Un-bitstuff station/depot/waypoint commands. 2021-12-16 22:28:32 +01:00
Michael Lutz e740c24eb7 Codechange: Template DoCommand to automagically reflect the parameters of the command proc.
When finished, this will allow each command handler to take individually
different parameters, obliviating the need for bit-packing.
2021-12-16 22:28:32 +01:00
Michael Lutz 7048e1522f Codechange: Move flags in CommandProc in front of the command arguments. 2021-12-16 22:28:32 +01:00
Michael Lutz 33ca4f2b99 Codechange: Let the compile generate the master command table out of templated command traits.
This is using a non-intrusive type-traits like templated system, which
allows compile-time validation that the command table and the command
enum match up.
2021-12-16 22:28:32 +01:00
Michael Lutz b6933a2ebd Codechange: Move command arguments to the back of the DoCommand function call. 2021-12-16 22:28:32 +01:00
Loïc Guilloux 38a64eb2aa
Change: Allow all tiles around docks to be docking tiles (#9578) 2021-09-26 19:31:55 +02:00
SamuXarick 18247bb3b8
Fix #9521: Don't load at just removed docks that were part of a multi-dock station (#9524) 2021-09-18 13:25:07 +02:00
Nicolas Chappe b83820e723 Change: [Linkgraph] Delete links only served by vehicles stopped in depot
A stale link is not deleted if the link refresher finds a vehicle that still serves it.
This commit excludes vehicles stopped in depot for a very long time from the link refresher,
so that their stale links can be deleted.
2021-08-20 22:37:03 +02:00
Joan Josep cc38a42b07
Fix 659989af45: Set appropriate town window dirty when building/removing airports. (#9497) 2021-08-18 14:33:32 +02:00
Nicolas Chappe 977604ef08 Feature: [Linkgraph] Prioritize faster routes for passengers, mail and express cargo
Passengers usually prefer fast paths to short paths.
Average travel times of links are updated in real-time for use in Dijkstra's algorithm,
and newer travel times weigh more, just like capacities.
2021-08-17 14:57:59 +02:00
dP c1d79398d5 Fix: Use of unstable sort when distributing cargo production can cause desyncs 2021-08-01 07:43:49 +02:00
glx22 89ab8b79a5 Codechange: Remove FOR_EACH_SET_BIT 2021-07-09 21:36:09 +02:00
rubidium42 55a11710a6 Codechange: convert printf DEBUG statements to fmt Debug statements 2021-06-13 12:45:45 +02:00
glx22 5799402f7a Codechange: Rename window related DeleteXXX to match new behaviour 2021-05-29 21:08:25 +02:00
rubidium42 2e136285e1 Codechange: move from C-string to std::string for DoCommand 2021-05-29 19:02:18 +02:00
rubidium42 661728558e Codechange: let IsUnique.* functions accept std::string 2021-05-29 19:02:18 +02:00
rubidium42 b791ffc6de Fix: do not hide parameter by local variable with the same name 2021-05-27 18:30:56 +02:00
rubidium42 44ca7d9377 Change: Use gender-neutral pronouns 2021-05-15 10:16:48 +02:00
glx22 38c97e1492 Codechange: Replace TILE_AREA_LOOP with range-based for loops 2021-05-13 00:13:54 +02:00
glx22 2feb801e56 Codechange: Replace FOR_ALL_ROADTRAMTYPES with range-based for loops 2021-05-03 19:46:57 +02:00
Jonathan G Rennison ece9a356dc
Fix #9113: Assertion failure when removing airport with order backup (#9182) 2021-05-03 15:03:25 +01:00
Peter Nelson a3e49178d1 Codechange: Use std::vector for NewGRF station tile sprite layouts. 2021-05-02 17:15:27 +01:00
Peter Nelson bd1a20f6ee Codechange: Use std::vector for NewGRF station platform layouts.
This avoids the need to custom memory management and additional members.

This also resolves use-after-free if modifying copied layouts, so presumably nobody has ever done that.
2021-05-02 17:15:27 +01:00
glx22 9a8756d7ed Codechange: Replace FOR_ALL_CARGOSPECS with range-based for loops 2021-04-29 21:08:24 +02:00
Jonathan G Rennison 25909b06d2 Fix #8809: Crash when removing airport when hangar window open 2021-03-07 17:59:38 +00:00
SamuXarick a4035af337
Codechange: Apply coding style (#8640)
* Fix: Missing or needed spaces

* Codechange: Remove space

* Codechange: Remove space

* Codechange: More missing spaces

* Codechange: Missing spaces

* Codechange: Remove space

* Codechange: Remove space
2021-02-05 11:00:36 +01:00
Charles Pigott 9b800a96ed
Codechange: Remove min/max functions in favour of STL variants (#8502) 2021-01-08 11:16:18 +01:00
SamuXarick 79d938b957 Fix 0125892: Warning about unsigned unary minus 2021-01-07 21:42:10 +00:00
SamuXarick f84a466ca5
Fix #7945: Add cost of clearing the sloped tile when placing a dock (#7947) 2021-01-07 10:35:09 +01:00
gooball 0125892f04
Fix #8297: Infrastructure counters for road tunnels, bridges, depots … (#8454)
The previous fix 887e9481ff0e70df6bf93ce15a3899a03f124c50 only worked for roads and failed to consider a multiplier used for the infrastructure totals for tunnels/bridges.
Also, depots and bus/truck stops are counted as 2 road pieces on creation but were only counted as 1 road piece on conversion because the function DiagDirToRoadBits() was used, which only ever returns single-piece road segments.

Co-authored-by: A. S <admin-git@sotai.tk>
2020-12-28 22:54:28 +01:00
glx22 d8605ad18d Codechange: Replace FOR_VEHICLE_ORDERS with range-based for loops 2020-12-27 10:28:46 +00:00
Pavel Stupnikov 9a45a0f535
Feature: Set exclusive access to industry from GS (#8115) 2020-12-22 14:29:48 +01:00
Michael Lutz 63ccb36ef3 Codechange: Use std::string for most of the user-settable custom names. 2020-05-21 20:02:34 +02:00
dP f2a9a1e2a5 Fix #8137: New clients can't join (desync) after funding an industry 2020-05-13 08:43:01 +01:00
dP 7bd52970a1 Codechange: Refactor FindStationsAroundTiles to avoid code duplication 2020-05-13 08:43:01 +01:00
glx 9339e4dcad Fix #8081: Check for waypoints when removing docking tiles 2020-04-12 08:46:55 +02:00
SamuXarick ea7044a74b
Fix f5381798: Station::GetTileArea reduced docks to a single tile (#8014) 2020-02-22 15:51:58 +01:00
Niels Martin Hansen 3fcb240f8e Fix d84b67e5: Station rating effects affecting too large area 2020-02-06 16:39:25 +01:00
Jonathan G Rennison c3223903ed Codechange: Cache resolved town, station and industry name strings 2020-01-12 19:37:43 +00:00
dP 1225693b9c Feature: Improved logic of sharing industry production between 3 or more stations 2020-01-12 14:01:12 +00:00
SamuXarick 40605efd1c Codechange: Use KDTree for AirportGetNearestTown (#7424) 2019-12-24 17:37:30 +00:00
glx ee7a8eebca Codechange: Replace FOR_ALL_TOWNS with range-based for loops 2019-12-21 20:13:03 +01:00
glx d8a1be48cd Codechange: Replace vehicle related FOR_ALL with range-based for loops 2019-12-21 20:13:03 +01:00
glx 9892d90b26 Codechange: Replace order related FOR_ALL with range-based for loops 2019-12-21 20:13:03 +01:00
glx ddabfed1cd Codechange: Replace station related FOR_ALL with range-based for loops 2019-12-21 20:13:03 +01:00
Jonathan G Rennison 35dc377a58 Fix: Infrastructure total update when removing tram road stop
The wrong road owner was used when updating the tram infrastructure total.
This could result in desyncs, negative infrastructure totals, etc.
2019-12-08 15:12:56 +01:00
Niels Martin Hansen 9900af38f5
Fix #7847: Use ViewportSign coordinates for sign Kdtree coordinates (#7849)
Ensure the same coordinates are used for station/town/player signs regardless of how the landscape changes below it after the coordinates were first determined.

By keeping track of whether each ViewportSign is valid for Kdtree use (and only ever registering the viewport sign when the object is valid) a lot of code can be simplified and become more robust at the same time.
2019-12-01 23:17:33 +01:00
S. D. Cloudt 13cc8a0cee Cleanup: Removed SVN headers 2019-11-10 17:59:20 +00:00
Jonathan G Rennison 2be619ea88 Fix #7820: Heap use after free when removing oil rig 2019-11-03 00:39:38 +01:00
Charles Pigott 2f4de0a0fe Fix #7733: Crash when removing a dock next to an industry without a station 2019-10-26 00:35:01 +01:00
JMcKiern 04f659e768 Fix: Some typos found using codespell 2019-09-29 21:27:32 +01:00
Daniel Lee 2d9eb1c417 Fix #7626: Allow building drive-through stops over one-way/blocked roads owned by towns (instead of crashing). 2019-09-06 23:21:40 +02:00
Juriy Petrochenkov f0aea2d246 Fix: RemoveAirport function now returns with 'Aircraft in the way' error message as it should be. 2019-08-13 16:42:22 +01:00
peter1138 ec2656ab7e Codechange: Restrict docking points of docks. 2019-06-30 16:46:32 +02:00
peter1138 f538179878 Feature: Multi-tile docks and docking points. 2019-06-30 16:46:32 +02:00
peter1138 402e18b460 Change: Allow building road stops over self-owned one-way/blocked road. 2019-05-04 22:39:29 +01:00
Niels Martin Hansen d1ef13fc04 Fix #7481: Just remove oil rig stations right away, don't clean them first 2019-05-03 09:50:01 +02:00
peter1138 c02ef3e456 Feature: Add NotRoadTypes (NRT) 2019-05-01 21:36:27 +02:00
PeterN abe8cf4985
Codechange: Replace duplicated code with TileArea::Expand() (#7467) 2019-04-13 14:12:34 +01:00