Peter Nelson
2d372fa516
Codechange: NewGRF strings are not StringIDs.
...
Add GRFStringID type and use it when dealing with GRF-local string IDs.
2025-01-02 20:03:40 +00:00
Rubidium
c0df898ac5
Codechange: do not implicitly convert during assignment to StrongType
2025-01-01 21:32:51 +01:00
Peter Nelson
1e77fd0b61
Codechange: Remove unnecessary 'return_cmd_error` macro. ( #13160 )
...
This macro is a leftover from when errors used to be packed into a single int32_t.
`return CommandCost` is clearer, and doesn't need a macro.
2024-12-08 18:02:30 +00:00
Peter Nelson
e73d6fcaac
Codechange: Store grfid with entity grfprops.
...
This allows using the grfid without having to dereference the grffile pointer.
Uses no extra storage as it fits within otherwise wasted padding space.
2024-12-05 18:17:58 +00:00
Peter Nelson
3be0166801
Codechange: Use std::ranges::find where possible.
...
Replace `std::find(range.begin(), range.end(), ...)` with `std::ranges::find(range, ...)`.
2024-11-24 10:36:03 +00:00
Peter Nelson
16038879e4
Codechange: Speed up industry generation using industry-type checks. ( #13094 )
...
Store a list of industries per industry type. This allows industry generation checks which only consider a specific industry type to check a reduced set of industries, leading to a potential performance increase.
This also removes the need to track industry type counts as well.
2024-11-22 23:17:24 +00:00
Peter Nelson
6c09dcdd66
Codechange: Use reference for non-optional StationList parameter. ( #13092 )
2024-11-19 20:33:32 +00:00
Peter Nelson
640a270ed6
Codefix: Use correct type for IndustryType in several industry functions. ( #13096 )
2024-11-19 20:32:06 +00:00
SamuXarick
d5a13fb9f4
Codechange: Use TileOffsByAxis(...) in more places ( #13026 )
2024-10-24 15:58:15 -04:00
Peter Nelson
446db2c826
Codechange: Remove redundant NewsStringData data. ( #12983 )
...
Since SetDParamStr() always owns a copy of the string, there is no need to make another copy of it to keep it around while the news item exists.
This also fixes a leak in `CmdIndustrySetProduction` as the allocated data wasn't passed to AddIndustryNewsItem.
2024-10-08 19:48:55 +01:00
Peter Nelson
8754846901
Codechange: Allow adding to animated tile list without marking dirty.
...
This avoids redundant tile refreshes when the caller has already marked a tile dirty, or knows it does not need refreshing.
Loosely backported from JGRPP.
2024-08-13 20:04:44 +01:00
Peter Nelson
79369a886a
Codechange: Don't mark tiles dirty when deleting from animated tile list.
...
The callers of DeleteAnimatedTile already know if the tile needs refreshing, so it is redundant for DeleteAnimatedTile to do so.
Loosely backported from JGRPP.
2024-08-13 20:04:44 +01:00
Peter Nelson
93eb27d8df
Codechange: Use reference for always_accepted output parameter of AddAcceptedCargo. ( #12854 )
...
This parameter should always present (see tile_cmd.h:186), so use a reference to ensure it is.
2024-07-10 12:30:14 +01:00
dP
f98b90ac2e
Codechange: Use constants for tree growth stages and tile update frequency ( #12833 )
2024-07-01 15:39:25 -04:00
Peter Nelson
f146680121
Codechange: Use vector for industry random sounds. ( #12606 )
...
Use a vector to store the list of random sounds played for an industry.
The removes manual memory allocation, flags to control memory management, a separate count member, and a try/catch block.
2024-05-01 19:55:00 +00:00
Peter Nelson
5159aa81d4
Codechange: Use iterators when enabling industries. ( #12569 )
...
Removes lengthof and array indices.
2024-04-24 21:33:49 +01:00
Peter Nelson
959ced71bb
Codechange: Add constants for original input/output cargo counts. ( #12548 )
...
This replaces some magic 3s and 2s.
2024-04-20 20:50:48 +01:00
Rubidium
e441033d68
Codechange: use std::array instead of C-style array for produced/accepts cargo
2024-04-20 11:29:55 +02:00
Peter Nelson
a28ab8cac2
Codechange: Replace C-style casts to size_t with static_cast. ( #12455 )
...
* Codechange: Replace C-style casts to size_t with static_cast.
This touches only simple value-type casts.
* Codechange: Replace static_cast<size_t>(-1) with SIZE_MAX
Co-authored-by: Rubidium <rubidium@openttd.org>
2024-04-19 20:34:36 +01:00
Peter Nelson
12125bad82
Fix 3de8853e: Industry cargo types callback no longer functioned due to container change. ( #12489 )
...
Use defined INDUSTRY_NUM_INPUTS/INDUSTRY_NUM_OUTPUTS values instead of container size, which is now empty at this point.
2024-04-12 23:07:07 +01:00
Peter Nelson
995fca58a2
Codechange: Use begin/end instead of endof for some industry arrays. ( #12447 )
2024-04-07 22:01:46 +01:00
Peter Nelson
3de8853e29
Codechange: Store accepted and produced cargo in vector instead of array.
...
Most industries do not use the full 16 slots, so this can save a little memory and iteration time.
2024-04-01 21:35:20 +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
Rubidium
27eadc13ec
Codechange: rename TILE_ADD(XY) to TileAdd(XY)
2024-03-10 15:50:24 +01:00
Rubidium
bab5a8a787
Codechange: use std::source_location over __FILE__ and __LINE__ for Backup
2024-03-10 10:14:20 +01:00
Peter Nelson
58ed38be03
Change: Avoid adjacent fence fields.
...
This restores pre-r23168 behaviour of only a single fence between adjacent fields.
2024-02-11 22:10:46 +01: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
41f2eed425
Feature: Settings to scale cargo production of towns and industries ( #10606 )
2024-01-30 15:11:46 -05: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
c0ab436077
Codechange: Store Colours in Colours type. ( #11625 )
...
This reduces casts, some magic numbers, and introduces a bit of type-safety.
2024-01-21 13:23:04 +00:00
Peter Nelson
952d111b94
Codechange: Split CT_INVALID into CT_INVALID and INVALID_CARGO.
...
INVALID_CARGO is a CargoID and should be used for most purposes in game.
CT_INVALID is a CargoType used for defining default properties.
2024-01-09 18:56:05 +00:00
Rubidium
e3f49ee7a0
Codechange: coding style fixes
2024-01-04 16:23:54 +01:00
Peter Nelson
e5aed24395
Codechange: Use std::array for industry tile cargo acceptance. ( #11498 )
...
This avoids use of memcpy/memset to copy or fill.
2023-11-27 23:17:55 +00: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
Rubidium
c9276c2959
Codechange: replace x.size() == 0 with x.empty()
2023-10-20 23:05:43 +02:00
frosch
5733145c59
Cleanup: Remove unneeded parameters.
2023-09-19 22:49:59 +02: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
fca2b37726
Codechange: Move Ticks into their own class
2023-09-10 08:40:25 -04:00
Michael Lutz
0089323542
Add: [Script] Custom news message text for industry SetProductionLevel.
2023-09-02 16:20:59 +02:00
Michael Lutz
1c56991213
Add: [Script] Game script control of industry production level.
2023-09-02 16:20: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
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
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
f86500df92
Codechange: remove need for SetDParamX
2023-06-12 09:12:11 +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