Commit Graph

205 Commits

Author SHA1 Message Date
Peter Nelson 774f811217
Codechange: Use std::optional for town parent scope resolver. (#12530)
When resolving NewGRF, the parent town_scope is lazily initialised as it does not always need to be used.

Replace the manually managed pointer with std::optional to simplify. Using std::optional avoids extra memory allocation.
2024-04-18 22:14:16 +01:00
Peter Nelson 00e0021e3a Codechange: Don't assume accepted/produced slot exists. 2024-04-01 21:35:20 +01:00
Patric Stout a3cfd23cf9
Codechange: rename byte to uint8_t (#12308) 2024-03-16 23:59:32 +01: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
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
frosch b6c8f301be Codechange: Silence warnings about intentionally unused parameters. 2023-09-19 22:49:59 +02:00
PeterN 18e75dbc88
Fix: Don't produce invalid cargo. (#11314)
Production for secondary industries did not always check that the produced cargo type isn't valid.
2023-09-18 22:43:03 +01:00
Tyler Trahan 77173a6a10 Codechange: Move date consts and functions to CalendarTime and TimerGameCalendar classes 2023-09-10 08:40:25 -04: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 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
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 09408e8e46 Codechange: Add IsCargoAccepted/Produced() helpers. 2023-05-24 17:34:11 +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 fb856e16c1 Codechange: replace some min/clamp constructs to ClampTo 2023-05-06 21:26:13 +02:00
Tyler Trahan 930f0a16d8 Codechange: Define Date/Year/Month/Day within TimerGameCalendar class 2023-04-26 07:14:03 -04:00
rubidium42 55a11710a6 Codechange: convert printf DEBUG statements to fmt Debug statements 2021-06-13 12:45:45 +02:00
rubidium42 44ca7d9377 Change: Use gender-neutral pronouns 2021-05-15 10:16:48 +02:00
frosch 2cf5df2a50 Fix: [NewGRF] industry variable 66 and object variable 46 clamped the squared-euclidian distance to 16 bit, when they should not. 2021-05-02 13:45:43 +01:00
frosch 84aa17cea6 Fix: [NewGRF] industry variables 65 and 66 ignored the parameter, and always used the north tile. 2021-05-02 13:45:43 +01:00
frosch 5b08960560 Fix: [NewGRF] industry variables 69 to 71 did not check, whether the queried cargo is valid. 2021-01-10 21:24:38 +01:00
Charles Pigott 9b800a96ed
Codechange: Remove min/max functions in favour of STL variants (#8502) 2021-01-08 11:16:18 +01:00
Niels Martin Hansen b7751c483e
Feature: Influence industry production changes from GS (#7912) 2020-12-22 14:21:31 +01:00
Niels Martin Hansen c8779fb311
Feature: NewGRF callback profiling (#7868)
Adds a console command newgrf_profile to collect some profiling data about NewGRF action 2 callbacks and produce a CSV file.
2020-01-26 13:45:51 +01:00
glx 00c2a98cf3 Codechange: Replace FOR_ALL_INDUSTRIES 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
Niels Martin Hansen 53f8d0b815 Codechange: Use std::vector for industry tile layouts 2019-10-19 17:16:25 +01:00
Henry Wilson 7c8e7c6b6e Codechange: Use null pointer literal instead of the NULL macro 2019-04-10 23:22:20 +02:00
Johannes E. Krause fdaf67d924 Add: [Newgrf] Some 60+ Vars for industries that were missed in #6867 2019-03-27 10:44:21 +00:00
Johannes E. Krause 1a4c7a4e54 Cleanup: use switch for industry cargo vars 2019-03-27 10:44:21 +00:00
peter1138 fc5f67123a Fix e66cec8f86: Permit loading of industry production callback with invalid cargo type.
It is only an error if the invalid result is actually used. This will be silently ignored at the moment.
It is still an error if a duplicate cargo type is returned.
2019-03-15 17:43:10 +00: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
frosch d9d669dcf8 (svn r27984) -Codechange: Make ScopeResolver constructors/destructors inlineable. Speedup sprite resolving by about 8 percent. 2018-03-11 13:19:41 +00:00
frosch 135ad9c6c9 (svn r27929) -Cleanup: Remove unused Industry::random_triggers 2017-10-25 15:38:19 +00:00
frosch 82ae414e8d (svn r27928) -Fix: [NewGRF] While executing random triggers, var 5F should include the new triggers.
-Fix: [NewGRF] Reset used random triggers only after all A123 chains have been resolved, so that all RA2 in all chains can test the shard triggers. This also includes multiple RA2 in the same A123 chain.
-Fix: [NewGRF] Industry random triggers are stored per tile, even when randomising the shared random bits of the parent industry.
2017-10-25 15:38:14 +00:00
frosch b4b98e5165 (svn r27893) -Codechange: Use fallthrough attribute. (LordAro) 2017-08-13 18:38:42 +00:00
frosch b9f7ca2dbd (svn r27279) -Feature: [NewGRF] Increase the maximum amount of industry types to 128 per NewGRF and 240 in total. 2015-05-09 10:21:55 +00:00
frosch c2b6a9bb56 (svn r27267) -Change: [NewGRF] Translate industry variable A6. 2015-05-03 10:33:26 +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
frosch 6b61c4608f (svn r26388) -Codechange: Move resolving of Action 3 into ResolverObject constructor. 2014-03-03 20:02:31 +00:00
frosch 73c6565cf2 (svn r26240) -Codechange: Pass the GRFFile to GetErrorMessageFromLocationCallbackResult instead of the GRFID. 2014-01-12 18:00:19 +00:00
frosch 49852e3dac (svn r26175) -Add: Log in desync output when persistent storage is discarded. 2013-12-23 18:09:29 +00:00
frosch db894b0b3f (svn r26085) -Codechange: Pass ResolverObjects as reference instead of pointer since they are never NULL. 2013-11-24 14:41:19 +00:00
rubidium d18852170b (svn r26066) -Fix: possible NULL dereference when resolving industry scope 2013-11-23 18:07:11 +00:00
planetmaker 5bf105d4f2 (svn r25856) -Codechange: Use Industry::TileBelongsToIndustry in one more place (cirdan, LordAro) 2013-10-13 11:04:20 +00:00
peter1138 3b4f4fe0b6 (svn r24973) -Fix [FS#5462]: Prevent access to tile-based variables when tile is invalid. 2013-02-05 21:38:38 +00:00
planetmaker c24374f99c (svn r24900) -Fix [FS#5389]: Comments with typos (most fixes supplied by Eagle_rainbow) 2013-01-08 22:46:42 +00:00