Peter Nelson
cb12a59eed
Fix #14495 : Dangling references in Industry Production graph window. ( #14496 )
2025-08-05 20:14:55 +01:00
Peter Nelson
d09dfd843c
Codechange: Extend industry cargo history to 24 years.
...
Monthly data is stored for the current 24 months.
Quarterly data is stored for a further 2-6 years.
Yearly data is stored for a further 6-24 years.
2025-07-30 01:13:05 +01:00
Peter Nelson
56942a15c7
Add: Industry accepted and waiting history graphs.
...
Records amount of cargo accepted, and a rolling average of the waiting amount.
Average waiting samples the waiting amount once per day for each industry, spread out over an economy day.
2025-07-20 14:03:54 +01:00
Peter Nelson
290144c5c9
Fix #14396 : Industry production graph showed zero instead of N/A.
...
Record the number of valid history records per industry so that the graph avoids showing values which are not present as zero.
2025-07-09 23:02:58 +01:00
Peter Nelson
9b55ad5b8d
Codechange: Generic type and container for history statistics.
2025-07-09 23:02:58 +01:00
Peter Nelson
9c16603da6
Codechange: Add AutoRelease helper to use function as unique_ptr deleter. ( #14353 )
...
This allows passing the function as a template parameter instead of requiring a custom deleter functor.
2025-06-11 20:13:49 +01:00
Peter Nelson
b042e7a439
Codefix: Prefer static inline const keyword order. ( #14301 )
2025-05-25 20:32:56 +01:00
Peter Nelson
940071a5f2
Codechange: Add alternating iterator to take elements from middle of range.
2025-05-23 07:42:10 +01:00
Peter Nelson
9735fbbaa1
Codechange: Use LRUCache for layouted LineCache.
...
This avoids needing to manually manage the size of the cache.
2025-05-06 18:09:00 +01:00
Peter Nelson
8c4f8af66e
Codechange: Move std::unique_ptr out of LRUCache implementation.
...
This is an implementation detail of how OpenGLSprites are stored.
2025-05-06 18:09:00 +01:00
frosch
61cec33be2
Codechange: Add 'const' to static variables, which are only initialised once.
2025-05-06 18:29:41 +02:00
Rubidium
fbe80f31fe
Codechange: replace char* in GetOptData with std::string_view
2025-04-30 23:49:06 +02:00
frosch
afe3dfb3a4
Codechange: Use format instead of to_string.
2025-04-29 20:26:23 +02:00
Rubidium
78250c3bba
Codechange: remove const char* overloads when there are std::string_view and std::string& overloads
2025-04-29 10:14:53 +02:00
Rubidium
49ef3eee13
Codechange: replace char* with std::string_view
2025-04-27 20:08:02 +02:00
frosch
04246c530f
Codechange: Use fmt::format instead of stringstream with iomanip flags. ( #13964 )
2025-04-08 20:57:50 +00:00
Peter Nelson
b55af05626
Codechange: Pass encoded script strings as EncodedString.
...
This removes the ambiguity of having std::strings that may or may not be encoded.
2025-03-04 21:40:39 +00:00
Rubidium
b50cf8f252
Codechange: rework OpenGL backend to not need emplacement new and manual deconstructor calls
2025-02-23 14:44:11 +01:00
Rubidium
e8beb0eff3
Codechange: add support for std::variant in EndianBuffer
2025-02-16 12:44:10 +01:00
Peter Nelson
11bfd5bb9e
Codechange: Use EnumBitSet for EndSegmentReasons. ( #13490 )
2025-02-07 23:53:23 +00:00
Peter Nelson
64724b8893
Codechange: Make OverflowSafeInt ConvertibleThroughBase. ( #13449 )
2025-02-03 12:53:45 +00:00
Rubidium
b6a092f3e0
Codechange: make EnumBitSet ConvertibleThroughBase
2025-02-01 19:22:02 +01:00
Rubidium
55588b052e
Codechange: add concept of ConvertibleThroughBase for strong types
...
This makes it possible to write templated alternatives for ConvertibleThroughBase
which are then available for any (strong) type that implements a base() function
In the end making adding new ConvertibleThroughBase types less awkward.
2025-02-01 19:22:02 +01:00
Peter Nelson
6d1f56ce6b
Codechange: Allow using EnumBitSet over network commands.
2025-01-29 21:46:39 +00:00
Peter Nelson
b653f875b0
Codechange: Space between template and < ( #13278 )
...
Make it all consistent so it matches CODINGSTYLE.
2025-01-04 17:56:14 +00:00
Rubidium
c0df898ac5
Codechange: do not implicitly convert during assignment to StrongType
2025-01-01 21:32:51 +01: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
Koen Bussemaker
0200bc3720
Codechange: Renamed CHashTableT to HashTable and corrected code style
2024-10-29 08:35:47 +01:00
Peter Nelson
8360fab18a
Codechange: Remove CCountedPtr.
...
This was originally generic and used by YAPF, but now it is used only by script objects.
CCountedPtr provided much more (untested) functionality than used.
ScriptObjectRef already exists for script objects and does the same thing, so use this instead.
2024-10-16 21:52:00 +01:00
Koen Bussemaker
d8029b1d84
Fix: CHashTableT's Clear function doesn't set number of items back to zero
2024-10-16 22:36:26 +02:00
Jonathan G Rennison
d53b681cf7
Codefix f481c9fc: Incorrect references to previous items in DumpTarget
2024-10-08 20:23:08 +02:00
Peter Nelson
0340e19e04
Codechange: Add to_underlying() to convert enum to underlying type. ( #12958 )
...
This simplifies and replaces static_cast and C-style casts doing the same.
`std::to_underlying()` exists in C++23 but not C++20.
2024-09-22 18:07:42 +01:00
Rubidium
77c188e6da
Codechange: use std::vector instead of malloced array
2024-05-12 12:55:52 +02:00
Rubidium
6cea49c117
Codechange: replace uint with size_t in binary heap
2024-05-12 12:55:52 +02:00
Peter Nelson
d074ab909c
Codechange: Replace Array/FixedSizeArray with std::deque. ( #12409 )
...
Array/FixedSizeArray is actually a resizeable container that allocates space in chunks and allows resizing without invalidating pointers.
This is also a behaviour of std::deque, so use that instead.
2024-05-04 10:55:16 +01:00
Peter Nelson
40fa45a76a
Codechange: Emplace std::pair into vectors.
...
This creates the pair in the vector, instead of creating it then copying it in.
2024-04-20 10:25:20 +01: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
Rubidium
afd7878de0
Codechange: internally use a span of arguments for GetOptData
2024-04-11 12:00:36 +02:00
Rubidium
5592b4409b
Codechange: use ranged for loop and separate function instead of goto
2024-04-11 12:00:36 +02:00
Rubidium
e8a56db21d
Codechange: use designated initializers for OptionData and pass as span
2024-04-11 12:00:36 +02:00
Patric Stout
a3cfd23cf9
Codechange: rename byte to uint8_t ( #12308 )
2024-03-16 23:59:32 +01:00
Patric Stout
fd073a2810
Remove: replace custom span with std::span
2024-01-17 00:25:08 +01:00
Rubidium
e3f49ee7a0
Codechange: coding style fixes
2024-01-04 16:23:54 +01:00
Peter Nelson
d4008850e3
Codechange: Ensure function opening { is on new line.
2023-11-09 20:15:38 +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
f16399f4c9
Codechange: replace x.size() > 0 with !x.empty()
2023-10-20 23:05:43 +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
299570b2c1
Codechange: make TimerGameCalendar Date and Year types strongly typed ( #10761 )
2023-08-12 18:14:21 +00:00
Patric Stout
5fba47b0f7
Codechange: make no assumptions on how the internals of TileIndex work ( #11183 )
...
Basically, avoid ".value", and just cast it to its original type
if you want to retrieve this.
2023-08-11 14:53:51 +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