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
Rubidium
84037d4a57
Codechange: use std::string for parameters in the dbg_helpers
2023-06-04 15:56:53 +02:00
Peter Nelson
56085be9bd
Codechange: Move includes for common STL headers to stdafx.
2023-05-17 10:14:41 +01:00
Rubidium
68ff3fd062
Change: include fmt.h C++ headers in stdafx.h
...
This to prevent compilation issues between runs with and without precompiled
headers. Also remove the headers from the rest of the code base as they are
not needed there anymore, although they do relatively little harm.
2023-05-08 16:49:23 +02:00
Peter Nelson
9f26e74e1e
Codechange: Rename item_t to Item.
2023-04-24 09:17:37 +01:00
Rubidium
71b46db8d0
Cleanup: remove commented out code
2023-01-26 23:47:55 +01:00
PeterN
4031894aef
Cleanup: Remove svn-style `$Id$` comments. ( #10122 )
2022-11-01 18:24:31 -06:00
Michael Lutz
13528bfcd0
Codechange: Un-bitstuff all remaining commands.
2021-12-16 22:28:32 +01:00
Michael Lutz
a05fd7aa50
Change: [Network] Transfer command data as serialized byte stream without fixed structure.
...
The data will be transmitted as the length followed by the serialized data. This allows the command
data to be different for every command type in the future.
2021-12-16 22:28:32 +01:00
Patric Stout
28e90769f7
Codechange: use "[[maybe_unused]]" instead of a wide variety of other ways we had
...
While at it, replace OTTD_ASSERT with WITH_ASSERT, as this
is always set if assert() is valid. No matter if NDEBUG is set
or not.
2021-06-03 17:30:00 +02:00
rubidium42
9197de39e4
Cleanup: remove unused copy-constructor without copy-assignment
2021-05-27 18:30:56 +02:00
Charles Pigott
e8a94dc8bb
Cleanup: Delete remaining Blob code
2021-04-04 08:01:54 +01:00
Charles Pigott
f481c9fc2c
Codechange: Replace CStrA with std::string
2021-04-04 08:01:54 +01:00
Patric Stout
fece1c57ca
Codechange: Suppress warnings when asserts are disabled ( #8917 )
2021-04-01 11:16:19 +02:00
Michael Lutz
1e1a9f3999
Add: A simple, templated cache map that uses a least recently used eviction strategy.
2021-02-22 22:16:07 +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