Commit Graph

571 Commits

Author SHA1 Message Date
Tyler Trahan f4ca94d3f6 Codechange: Revenue is not the same as Income
Income is revenue minus costs. Let's name things correctly (without breaking the script API).
2022-04-25 21:51:51 +02:00
Tyler Trahan d220debc6c
Change: Don't pay Property Maintenance on stations when Infrastructure Maintenance is disabled (#9828) 2022-03-10 22:34:03 +01:00
Rubidium c73f578e8c Codechange: replace magic numbers and C-style arrays with C++-style array for share owners 2022-03-09 18:05:12 +01:00
Rubidium 1c256a4be7 Fix: do not let shares in the company taking over another company disappear 2022-02-24 20:25:31 +01:00
dP 36bee83864
Change: Deliver cargo to the closest industry first (#9536) 2022-02-19 19:08:23 +01: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 2e39637db2 Codechange: Don't use a global for the 'not enough cash' message. 2021-12-16 22:28:32 +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
Michael Lutz 21675ec7e2 Codechange: Un-bitstuff vehicle/engine commands. 2021-12-16 22:28:32 +01:00
Michael Lutz 4f3ea3907e Codechange: Un-bitstuff commands taking a ClientID (i.e. CMD_CLIENT_ID). 2021-12-16 22:28:32 +01:00
Michael Lutz 0f64ee5ce1 Codechange: Template DoCommandP 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 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 a38bbefe1b Codechange: Untangle command code, flags and error string for DoCommand*. 2021-12-16 22:28:32 +01:00
Michael Lutz 549caca39c Codechange: Move command arguments to the back of the networked command function calls. 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
Rubidium d83647f9a7 Fix #9440: negative cargo payments not being handled right
Cargo payments were stored as unsigned integer, but cast to int64 during
application of inflation. However, then being multiplied with a uint64
making the result uint64. So in the end the payment that should have been
negative becomes hugely positive.
2021-08-02 20:44:53 +02:00
glx22 a543a4b7bb Codechange: Remove FOR_EACH_SET_CARGO_ID 2021-07-09 21:36:09 +02:00
rubidium42 9a7750f14e Codechange: use the constructor for CompanyNewsItem to fill the data instead of a separate function 2021-07-01 19:04:38 +02:00
rubidium42 aa9818db90 Codechange: create a type for the "free_data" of NewsItems and (de)allocate it with new and delete 2021-07-01 19:04:38 +02:00
Patric Stout ef25afd55a
Fix #9348, 4d74e51: don't try to sell shares of spectators (#9349)
"new_owner" can be INVALID_OWNER, and as INVALID_OWNER ==
COMPANY_SPECTATORS, we could end up trying to sell shares of
nobody.
2021-06-11 00:18:20 +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
Patric Stout 4d74e51907
Fix #9281: acquire a company uses special bookkeeping to make you rich (#9300)
When you buy-out a company, you got your shares back. This is
based on company-value, which includes values for the vehicles etc.
In other words, you not only got the vehicles, but you also got
paid to get them back.

Additionally, you also got the loan of the company, but not the
money for the loan (as that is subtracted from the company-value).

Solve this by changing the rules of a buy-out: don't sell your
shares, get the loan AND the balance and get the infrastructure.
2021-05-29 11:21:30 +02:00
rubidium42 44ca7d9377 Change: Use gender-neutral pronouns 2021-05-15 10:16:48 +02:00
William Davis 881e1da51d
Change: Use gender-neutral pronouns in console command messages (and comments) (#9203) 2021-05-08 11:02:30 +01:00
glx22 9a8756d7ed Codechange: Replace FOR_ALL_CARGOSPECS with range-based for loops 2021-04-29 21:08:24 +02:00
glx22 6b8ad5a9b1 Change: Apply some consistency to singleplayer related comments 2021-01-22 22:19:55 +01:00
Charles Pigott 9b800a96ed
Codechange: Remove min/max functions in favour of STL variants (#8502) 2021-01-08 11:16:18 +01:00
Charles Pigott 860c270c73 Codechange: Replace assert_compile macro with static_assert 2020-12-27 10:55:42 +00:00
Michael Lutz 79cb9efa7f
Change: Always apply inflation from 1920 to 2090, no matter the game start year. (#7589) 2020-12-25 20:36:14 +01:00
Pavel Stupnikov 9a45a0f535
Feature: Set exclusive access to industry from GS (#8115) 2020-12-22 14:29:48 +01:00
Pavel Stupnikov b2895dfcd0
Change: extend the allowed range for max loan setting (#8386) 2020-12-16 21:56:32 +01:00
Jonathan G Rennison 2fee030a26 Change: Algorithm for transfer feeder payments
The original algorithm pays intermediate legs in feeder systems based
on the start and end stations of that particular leg.
This tends to result in large negative payments on the final leg for
journeys with many feeder legs, as the overall feeder payment increases
with the number of legs, and the final leg is penalised for discrepancies
between the previous leg payments and the actual payment for delivery
from the source to the destination.
The feeder share setting is a partial mitigation, however it is difficult
to tune as a suitable value depends on the number of legs and the network
topology, which are often not the same for all vehicles.

The new incremental algorithm pays the cargo payment from the source
station to the end station of the current leg, minus any previous
transfer feeder payments for each leg.
This prevents unbounded increase of feeder payments and therefore avoids
the issue of excessive negative payments on the final leg.
Feeder payments may be negative, e.g. in the case of poorly performing
or highly indirect legs. This is better than penalising the final leg.
This mode reduces the need to tune the feeder shares setting to the
current network.

The feeder share setting applies in the existing way.
2020-01-28 23:37:16 +01:00
Mingwei Samuel 26ce4eb45d Fix #7430: when train visits station, only reset time_since_pickup if has room to load 2019-12-23 21:07:45 +01:00
glx ee7a8eebca Codechange: Replace FOR_ALL_TOWNS with range-based for loops 2019-12-21 20:13:03 +01:00
glx 0b489f9924 Codechange: Replace FOR_ALL_SUBSIDIES with range-based for loops 2019-12-21 20:13:03 +01:00
glx 847e5f33d4 Codechange: Replace story related FOR_ALL with range-based for loops 2019-12-21 20:13:03 +01:00
glx 869581eb23 Codechange: Replace FOR_ALL_SIGNS 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 4ae829cb27 Codechange: Replace FOR_ALL_GROUPS with range-based for loops 2019-12-21 20:13:03 +01:00
glx f58ce3db19 Codechange: Replace FOR_ALL_GOALS 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
glx 3a14cea068 Codechange: Replace FOR_ALL_COMPANIES with range-based for loops 2019-12-21 20:13:03 +01:00
S. D. Cloudt 13cc8a0cee Cleanup: Removed SVN headers 2019-11-10 17:59:20 +00:00
Jack Baron 7c9dedb94f Feature: Configure minimum share trading years 2019-10-19 20:31:44 +01:00
JMcKiern 04f659e768 Fix: Some typos found using codespell 2019-09-29 21:27:32 +01:00
peter1138 c02ef3e456 Feature: Add NotRoadTypes (NRT) 2019-05-01 21:36:27 +02:00
Charles Pigott 5b34c8019f Codechange: Remove Company/OwnerByte types 2019-04-29 17:40:22 +01:00
peter1138 0130f3be45 Fix #7491: Send company update admin message when bankruptcy counter changes. 2019-04-11 13:00:25 +01:00
Henry Wilson 7c8e7c6b6e Codechange: Use null pointer literal instead of the NULL macro 2019-04-10 23:22:20 +02:00
glx22 a1e492d0d8
Fix #7439: don't overwrite CompanyRemoveReason with ClientID (#7465) 2019-04-05 15:11:52 +02:00
Henry Wilson c01a2e2a81 Codechange: Removed SmallVector completely 2019-03-26 20:15:57 +00:00
Henry Wilson ab711e6942 Codechange: Replaced SmallVector::[Begin|End]() with std alternatives 2019-03-26 20:15:57 +00:00
Henry Wilson 297fd3dda3 Codechange: Replaced SmallVector::Include() with include() 2019-03-26 20:15:57 +00:00
Henry Wilson bfd79e59dc Codechange: Replace SmallVector::Clear() with std::vector::clear() 2019-03-26 20:15:57 +00:00
Patric Stout e3c639a09f Remove: ENABLE_NETWORK switch
This switch has been a pain for years. Often disabling broke
compilation, as no developer compiles OpenTTD without, neither do
any of our official binaries.

Additionaly, it has grown so hugely in our codebase, that it
clearly shows that the current solution was a poor one. 350+
instances of "#ifdef ENABLE_NETWORK" were in the code, of which
only ~30 in the networking code itself. The rest were all around
the code to do the right thing, from GUI to NewGRF.

A more proper solution would be to stub all the functions, and
make sure the rest of the code can simply assume network is
available. This was also partially done, and most variables were
correct if networking was disabled. Despite that, often the #ifdefs
were still used.

With the recent removal of DOS, there is also no platform anymore
which we support where networking isn't working out-of-the-box.

All in all, it is time to remove the ENABLE_NETWORK switch. No
replacement is planned, but if you feel we really need this option,
we welcome any Pull Request which implements this in a way that
doesn't crawl through the code like this diff shows we used to.
2019-03-20 19:24:55 +01:00
stormcone 43caef2968 Fix f58fa80e: Wrong company performance rating when money exceeds INT_MAX. (#7382)
Company performance rating calculation does not take into account the companies' money when those exceeds INT_MAX.
2019-03-17 21:28:37 +01:00
Peter Nelson 8b1b3fd0f9 Feature: Non-rectangular sparse station catchment area. 2019-03-09 16:33:47 +00:00
peter1138 94b40fd530 Codechange: Convert IndustryVector to a std::set. 2019-03-09 16:33:47 +00:00
PeterN dd20ccee88
Feature: Industries with neutral stations (e.g. Oil Rig) only supply/accept cargo to/from their neutral station. (#7234)
This change is a controlled by a game setting, located under Environment ->
Industries which allows toggling the behaviour. It defaults to enabled.

"Company stations can serve industries with attached neutral stations"

When enabled, industries with attached neutral station (such as Oil Rigs) may
also be served by company-owned stations built nearby. This is the traditional
behaviour.

When disabled, these industries may only be served by their neutral station.
Any nearby company-owned stations won't be able to serve them, nor will the
neutral station serve anything else other than the industry.
2019-03-08 18:30:44 +00:00
Samu 780593ae60 Fix #6633: Cargo monitor industry delivery now accounts for which IndustryID the cargo was delivered to 2019-03-02 18:14:45 +01:00
SamuXarick 456e67ac1c Change: Owner of vehicle with exclusive transport rights may now load cargo from neutral stations (#7256) 2019-02-21 21:23:37 +00:00
glx 8e7fe3973f Add: CompanyCtrlAction enum for CMD_COMPANY_CTRL actions 2019-02-04 21:08:36 +01:00
Peter Nelson 48fb575502 Fix 11ab3c4ea2f: Vehicles could not be refitted to cargo IDs higher than 32. 2019-01-29 17:57:28 +00:00
Niels Martin Hansen 810887af30 Fix #6498: Use int64 for all company rating calculations 2018-11-25 00:48:34 +01:00
Niels Martin Hansen e66cec8f86 Add: NewGRF support for 16-in-16-out industries 2018-11-03 21:43:54 +01:00
Niels Martin Hansen 8859381d30 Add: Industries can produce and accept up to 16 different cargoes 2018-11-03 21:43:54 +01:00
Charles Pigott f5b1115039 Doc: Lots and lots of doxymentation fixes 2018-10-31 12:35:54 +01:00
Charles Pigott 5f86e1a390 Codechange: Silence -Wclass-memaccess warnings with GCC8 2018-06-27 22:54:46 +02:00
PeterN 4cebebcf68
Change: Add CargoTypes type for cargo masks. (#6790) 2018-05-21 22:08:39 +01:00
frosch db54db00df (svn r27981) -Change [FS#6679]: Check companies for bankruptcy before subtracting reoccuring monthly costs. (Samu) 2018-03-11 12:46:05 +00:00
frosch b4b98e5165 (svn r27893) -Codechange: Use fallthrough attribute. (LordAro) 2017-08-13 18:38:42 +00:00
peter1138 d31f9a83e7 (svn r27788) -Fix [FS#6536]: Get vehicle load amount after executing new cargo trigger. 2017-03-13 07:37:05 +00:00
frosch b0c56f3432 (svn r27585) -Fix [FS#6437]: Enforce a non-zero load amount for all vehicles, so that vehicles can process their cargo reservations. 2016-05-29 13:35:17 +00:00
frosch dac94c7cbc (svn r27584) -Codechange: Add some assertions about Vehicle::cargo_payment. 2016-05-29 13:33:20 +00:00
frosch 32cb62a242 (svn r27282) -Fix [FS#6254]: Enforce the company's default service intervals when purchasing another company. (Johnnei) 2015-05-11 16:58:09 +00:00
frosch e686add63a (svn r27281) -Codechange: Do not shadow local variables with other local variables in sub-scopes. 2015-05-11 16:53:05 +00:00
fonsinchen 75cb16a7d7 (svn r26918) -Fix [FS#6110]: Reserve cargo only after unloading finished or if the vehicle has the desired cargo already 2014-09-24 20:56:52 +00:00
fonsinchen d6fc217136 (svn r26917) -Revert (r26857): It broke improved loading. 2014-09-24 20:55:47 +00:00
fonsinchen c4902c4150 (svn r26857) -Fix [FS#6110]: Reserve cargo after refitting and only if necessary. 2014-09-20 09:41:25 +00:00
fonsinchen dfbcd8869d (svn r26847) -Fix [FS#6110]: Don't assign a next hop when returning cargo 2014-09-18 17:49:19 +00:00
fonsinchen 3648e95265 (svn r26586) -Fix [FS#5995]: Consider multiheaded trains in station refits (and clean up a bit) 2014-05-13 19:16:04 +00:00
rubidium b590a64718 (svn r26581) -Fix [FS#5989]: transfering cargo to a station doesn't give that station a rating and thus the cargo does not decay... until the first pickup happens
For cargo drops from industries/houses, the station gets a rating too so why not when cargo is dropped at the station from a train?
2014-05-11 18:31:38 +00:00
rubidium 89c25b955e (svn r26580) -Codechange: s/GES_PICKUP/GES_RATING/ (it has nothing to do with actual pickup), s/acceptance_pickup/status/ (the enum isn't called GoodEntryStatus for a reason; it's not only acceptance and pickup anymore) 2014-05-11 18:02:11 +00:00
fonsinchen 11d98f043e (svn r26549) -Change: better estimation for link capacities during full load 2014-05-01 14:50:52 +00:00
fonsinchen b5566ae6ec (svn r26548) -Codechange: move updating of load_unload_ticks out of LoadUnloadVehicle 2014-05-01 14:49:44 +00:00
fonsinchen 3ee31a8f89 (svn r26547) -Codechange: Collect order travel and wait times independent of timetables 2014-05-01 14:49:16 +00:00
fonsinchen c915d9fa55 (svn r26546) -Codechange: Make order wait_time, travel_time and max_speed private 2014-05-01 14:48:44 +00:00
fonsinchen 49f27eb247 (svn r26483) -Fix: Allow single-vehicle consists to station-refit in a meaningful way. 2014-04-23 20:22:27 +00:00
rubidium 0463dbdc9e (svn r26482) -Codechange: add an include that allows us to undefine/redefine "unsafe" functions to prevent them from being used, and thus having to care about certain aspects of their return values 2014-04-23 20:13:33 +00:00
fonsinchen 88787412b6 (svn r26327) -Fix [FS#5901]: Take care of next_station when reassigning from MTA_DELIVER to MTA_TRANSFER. 2014-02-09 21:10:25 +00:00
fonsinchen 9ad173c9cc (svn r26236) -Fix: Don't overreserve after autorefit, but do reserve mail for aircraft 2014-01-12 17:44:55 +00:00
fonsinchen ecdd796a86 (svn r26188) -Codechange: Move station refitting to a separate function. 2013-12-30 14:50:45 +00:00
fonsinchen 63b43ed914 (svn r26187) -Fix: allow refitting at station if cargo has already been reserved. 2013-12-30 14:50:09 +00:00
fonsinchen 6e1cc80926 (svn r25903) -Codechange: Refactor RefreshNextHopsStats into an own class LinkRefresher. 2013-10-22 18:34:10 +00:00
fonsinchen 54db96be43 (svn r25891) -Feature: Use smallstack to allow for multiple next hops when loading and unloading. 2013-10-20 13:47:58 +00:00
fonsinchen b09c4043ec (svn r25565) -Codechange: Rewrite order prediction logic to introduce proper refit prediction 2013-07-06 17:01:31 +00:00