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
Rubidium
ed51cf117a
Add: helper output iterator for formatting strings
2023-06-04 12:24:37 +02:00