frosch
d8333fe3d7
Codechange: Czech town names unconditionally removed the last codepoint in _name_czech_adj; already do this in the source table.
2025-04-03 13:58:07 +02:00
frosch
ca801d55d5
Fix: [NewGRF] Display an error, if NewGRF reference out-of-bounds string parameters in gender/plural choices. ( #13881 )
2025-03-23 20:43:12 +01:00
Peter Nelson
27761ae431
Cleanup: Remove global string parameters.
...
Global parameters, and functions for dealing with them, are now gone.
2025-03-04 08:48:35 +00:00
Peter Nelson
b28dca2222
Codechange: Preprocess text ref stack parameters. ( #13642 )
...
NewGRF text ref stack is now processed in advance, creating parameters as necessary, and then encoding this into an EncodedString.
2025-02-22 22:03:38 +00:00
Peter Nelson
4010313180
Codechange: String parameters can now be explicitly not initialised.
...
As the visitor is now more complex this requires an unspecialised GetNextParameter() to avoid it being repeated for each return type.
2025-02-10 22:49:14 +00:00
Peter Nelson
52094c1fc1
Codechange: Detemplatise uint64_t version of GetNextParameters(). ( #13488 )
...
This ensures the visitor is not duplicated for the different types pass to GetNextParamters<T>(), which now is only concerned with casting the result.
2025-02-07 18:54:40 +00:00
Peter Nelson
be00fd4447
Codechange: Use std::array as simple string parameter container.
...
ArrayStringParameters contains extra state that is used when formatting strings which isn't needed when creating parameter lists.
MakeParameters() now returns a std::array which contains only the parameter data. This simpler container is more widely available than before.
2025-02-07 12:30:34 +00: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
c4424aa894
Codechange: Use correct char type in RemapNewGRFStringControlCode. ( #13173 )
2024-12-18 12:58:23 +00:00
Peter Nelson
25c5a64d39
Codechange: Use std::visit instead of std::get_if for string parameters. ( #13100 )
...
It's tidier and ensures all cases are handled, and doesn't use pointers.
2024-11-19 18:17:41 +00:00
Jonathan G Rennison
ffcc594ea3
Codefix: Incorrect documentation comments in StringBuilder
2024-10-18 22:29:28 +02:00
Peter Nelson
719d063bd4
Fix d1463f415f: Wrong type of exception thrown by invalid string parameters.
...
`FormatString()` only catches `std::out_of_range`, but `GetNextParameter()` threw `std::runtime_error`.
2024-09-19 18:44:23 +01:00
Peter Nelson
d1463f415f
Codechange: Treat reading incorrect parameter type as a string error.
...
Previously reading a string as a number would return 0 instead.
2024-09-14 15:31:05 +01:00
Peter Nelson
3d8d0e0d26
Codechange: Use std::variant to store string parameter data.
...
This avoids storing two separate values and makes the test for which type is held clearer.
This replaces use of unique_ptr for conditionally storing a string, and is also used in place of StringParameterBackup.
2024-09-14 15:31:05 +01:00
Peter Nelson
9eb28def57
Codechange: Return reference from GetNextParameterPointer.
...
GetNextParameterPointer can no longer return nullptr, and the callers do not check for nullptr, so return a reference instead.
2024-09-14 15:31:05 +01:00
Patric Stout
59a046de9c
Fix: don't use non-owning string pointer in StringParameter ( #11952 )
...
The string pointer can become invalid before the reference is
dropped, causing out-of-bound access in windows like ErrorWindow,
or News that copy 10 or 20 parameters for their internals.
Co-authored-by: Jonathan G Rennison <j.g.rennison@gmail.com>
2024-02-02 23:01:54 +01:00
Patric Stout
fd073a2810
Remove: replace custom span with std::span
2024-01-17 00:25:08 +01:00
Peter Nelson
7482f71692
Change: Don't handle 'missing' string parameters as 0. ( #11673 )
...
If not enough parameters are supplied for a string, then a value of 0 was used, which could result in incorrect information being displayed.
Instead, throw an exception and include an error in the string.
2024-01-04 20:50:58 +00:00
Jonathan G Rennison
e2a79f0f32
Codechange: No longer advance parent offset in StringParameters parent mode
...
Add method to manually advance offset
2024-01-04 17:45:33 +00:00
Rubidium
e3f49ee7a0
Codechange: coding style fixes
2024-01-04 16:23:54 +01:00
rubidium42
33ba609290
Fix #11521 , e404ba0: size for remaining span determined incorrectly
2023-11-30 08:20:58 -04:00
Jonathan G Rennison
1de1af08b9
Codechange: Replace AllocatedStringParameters with ArrayStringParameters ( #11452 )
...
All uses of AllocatedStringParameters are with a compile-time fixed
constant.
Use of a dynamically allocated buffer on the heap is unnecessary and
increases overhead, particularly due to frequent use as a temporary.
2023-11-09 19:43:47 +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
frosch
c6f5b57f13
Fix #11297 , 4e9a871: SCC_GENDER_LIST tried to determine the gender from the wrong sub-string. ( #11299 )
2023-09-15 15:25:25 -04: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
Rubidium
3e488465f8
Codechange: allow string temporaries in a StringParameter
2023-07-03 18:08:03 +02:00
Rubidium
4654b2b0aa
Codechange: separate integer and string usage in StringParameters
2023-07-03 06:56:08 +02:00
Rubidium
7ad487eeee
Cleanup: remove now unused GetInt32/64 functions
2023-06-27 12:34:40 +02:00
Rubidium
e7937efb01
Codechange: add clearer named function to get the next (string) parameter
2023-06-27 12:34:40 +02:00
Rubidium
4e9a871718
Codechange: merge multiple string parameter arrays to single array of structs
2023-06-21 05:46:11 +02:00
Rubidium
fa8c50758b
Codechange: replace memcpy when copying DParams
2023-06-21 05:46:11 +02:00
Rubidium
7a785a4224
Codechange: simplify StringParameters now type cannot be nullptr
2023-06-20 22:25:25 +02:00
Rubidium
428333aeba
Codechange: let AllocatedStringParameters allocated types too
2023-06-20 22:25:25 +02:00
Rubidium
88138c55f8
Codechange: make offset protected and guard against invalid offsets
2023-06-20 17:37:49 +02:00
Rubidium
9c3c90effa
Codechange: rename ClearTypeInformation so it can be used for preparing for the next run
2023-06-20 17:37:49 +02:00
Rubidium
01abcdfcac
Codechange: make StringParameters#next_type only writable from outside the class
2023-06-20 17:37:49 +02:00
Rubidium
3e8f8c55c2
Codechange: make creating temporary StringParameters easier
2023-06-20 17:37:24 +02:00
Rubidium
381e8b69d2
Codechange: make size and offset size_t
2023-06-18 09:50:11 +02:00
Rubidium
e404ba0631
Codechange: generify GetRemainingParameters to allow custom offsets
2023-06-18 07:09:59 +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
aba0d27a28
Codechange: use StringParameters for remapping the NewGRF string control codes
2023-06-13 22:11:21 +02:00
Rubidium
edb21620ea
Cleanup: remove unneeded checks on remaining buffer size
2023-06-05 23:26:12 +02:00
Rubidium
affceea0ae
Codechange: switch StringBuilder to use std::string as backend
2023-06-05 23:26:12 +02:00
Rubidium
4e39a58c59
Codechange: let town name generation use StringBuilder
2023-06-04 21:42:59 +02:00
rubidium42
bfcb027cb9
Fix 2dffa7d: fmt::format_to copies the iterator, so some text does not remain during formatting ( #10940 )
2023-06-04 19:55:47 +02:00
Rubidium
6a519f5d89
Cleanup: strecat has no uses anymore
2023-06-04 19:45:42 +02:00
Rubidium
36aaa9d683
Codechange: let GetStringWithArgs use StringBuilder
2023-06-04 18:00:23 +02:00
Rubidium
2dffa7d0c6
Codechange: let FormatString use StringBuilder
2023-06-04 15:06:52 +02:00