Peter Nelson
14b986609b
Add: AppendStringInPlace() to append translated string ID into an existing string. ( #12969 )
...
This allows avoiding a string copy when building strings.
2024-10-07 19:05:38 +01:00
Peter Nelson
16b4e737a3
Fix 3d8d0e0d26
: Don't assume plural parameter is valid. ( #12954 )
...
A crash can occur if the parameter used for a plural isn't a numeric value.
2024-09-21 15:04:35 +01:00
Peter Nelson
908ee7292b
Codechange: Replace all FILE * with FileHandle RAII class. ( #12718 )
...
This removes the need to manually ensure all files are closed.
2024-09-16 08:45:26 +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
b449839538
Codechange: Pass span instead of vector to HaveDParamChanged.
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
Peter Nelson
aee04e7bc6
Codechange: Pass span to StrValid instead of first and last - 1. ( #12846 )
...
`std::span` is used instead of `std::string_view` as this is only used for fixed-length buffers.
This removes some callers of `lastof()`
2024-07-08 08:36:57 +01:00
Peter Nelson
b4b2fad8e0
Fix #12648 : Ensure all uses of std::filesystem::path use native encoding. ( #12650 )
...
std::filesystem::path does not expect UTF-8 strings, so they must be converted to native format first (and back to utf-8 after.)
2024-06-09 10:23:47 +01:00
Peter Nelson
7e914a0568
Fix #12738 , de16655f
: Fallback font searcher failure since ? substitution removed.
...
Fallback font searcher looked for the substituted ? glyph, which was removed by #12736 .
Instead of comparing against a sprite, test against the font returning a missing glyph.
This should also improve performance of fallback font searching, as previously glyphs were actually rendered while searching.
2024-05-31 21:47:47 +01:00
Peter Nelson
9008d793ab
Change: Use per-company group numbers. ( #12297 )
...
This is used by the default group name, replacing the use of group index.
2024-05-07 19:01:28 +00:00
dP
f5a50a874f
Codechange: Update doxygen comment to reflect removed parameter ( #12499 )
2024-04-15 12:40:50 +02:00
Peter Nelson
839f486074
Codechange: Use directory_iterator to find language files. ( #12495 )
...
This avoids using custom ttd_opendir, along with C-style string comparisons against file names.
2024-04-14 23:57:26 +01:00
Rubidium
21b640b5ff
Codechange: simplify president name generation
2024-04-10 18:57:53 +02:00
Peter Nelson
8d312b305b
Codechange: Replace currency macros with functions. ( #12396 )
2024-03-29 14:49:48 +00:00
Patric Stout
a3cfd23cf9
Codechange: rename byte to uint8_t ( #12308 )
2024-03-16 23:59:32 +01:00
Rubidium
4c117dd2d8
Revert #11993 : new number format system does not and cannot work for CJK languages
...
There are too many intricacies that I am unaware of that are popping up after
asking whether things are right or not.
I do not want to keep playing whack-a-mole, so just revert the whole thing.
This reverts:
15be383b93
360fe8b0b6
1aa9a5c0ab
59f56941e5
7e2eefb91f
b741b2ba6f
609d0071d5
9f8fd80112
a253205b93
819c6c756e
2024-02-22 20:40:12 +01:00
Rubidium
5d2e6e4efa
Fix #12148 , fca8166
: Do not draw decimals when number of digits is 0
2024-02-21 19:32:53 +01:00
Rubidium
360fe8b0b6
Fix a253205
: division by zero when attempting to format some short currencies
2024-02-17 22:45:48 +01:00
Rubidium
7e2eefb91f
Cleanup: Remove digit group separators from strgen and languages
2024-02-17 14:33:16 +01:00
Rubidium
b741b2ba6f
Feature: Fully user configurable number format and abbreviations
2024-02-17 14:33:16 +01:00
Rubidium
609d0071d5
Change: Remove saving of digit group and decimal separator configurations from the savegame
2024-02-17 14:33:16 +01:00
Rubidium
9f8fd80112
Feature: Fully customisable number abbreviations per translation
2024-02-17 14:33:16 +01:00
Rubidium
a253205b93
Feature: Fully customisable number format per translation
2024-02-17 14:33:16 +01:00
Rubidium
819c6c756e
Codechange: Add support for number format and abbreviations pragmas/attributes to strgen
2024-02-17 14:33:16 +01:00
Rubidium
fca8166087
Codechange: Simplify FormatNumber by moving out zero fill and decimal support
2024-02-17 14:33:16 +01:00
Rubidium
a44bd81280
Codechange: Move determining the decimal separator to a separate function
2024-02-17 14:33:16 +01:00
Patric Stout
f1842f9144
Add: {CURRENCY_SHORT} only did k / m suffix. Add bn / tn and make translatable. ( #11921 )
...
64bit numbers are REALLY large, but our compact method was build
for 32bit numbers. Extend it to 64bit.
2024-01-29 20:20:35 +00:00
frosch
28c83089f6
Codechange: Remove TKM string code.
2024-01-28 14:44:24 +01:00
Peter Nelson
6d276698b6
Fix: Memory leak in ICUParagraphLayout::NextLine() ( #11895 )
...
This function calls icu::BreakIterator::createLineInstance() but does not clean up after it.
Instead use a static instance that is cloned (for thread-safety) and deleted as necessary.
2024-01-27 20:13:42 +00:00
Tyler Trahan
fd9e72a7e7
Feature: Use real-time "wallclock" timekeeping units ( #11341 )
2024-01-23 11:36:09 -05:00
Rubidium
ee00c7b159
Codechange: use TO_LE16 directly when reading language file offsets
2024-01-18 23:29:15 +01:00
Patric Stout
fd073a2810
Remove: replace custom span with std::span
2024-01-17 00:25:08 +01:00
Jonathan G Rennison
4b48d3b5fe
Fix: String gender scan with SCC_INDUSTRY_NAME ( #11697 )
2024-01-07 15:48:47 -05: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
5db9266f4b
Change: Allow STRING/STRINGN to use all remaining parameters in game script mode
2024-01-04 17:45:33 +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
Peter Nelson
33ff64ef74
Codechange: Simplify ConvertDateToYMD by returning YearMonthDay instead of outputting to a pointer. ( #11637 )
2023-12-28 21:34:08 +00:00
Jonathan G Rennison
97b86b7147
Codechange: Use MakeParameters with GetNextParameter in FormatString ( #11583 )
...
Instead of StringParameters subspan, to avoid GSs being able to
cause subspan boundary assertion failures
2023-12-14 10:41:31 -05: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
7d4a91ef9e
Cleanup: Remove some unused functions. ( #11429 )
...
These were picked up with cppcheck.
2023-11-03 21:21:00 +00:00
Rubidium
c9276c2959
Codechange: replace x.size() == 0 with x.empty()
2023-10-20 23:05:43 +02:00
frosch
b6c8f301be
Codechange: Silence warnings about intentionally unused parameters.
2023-09-19 22:49:59 +02:00
Rubidium
6635f809dd
Fix #11181 : attempting to read string as int triggers assertion
2023-08-20 23:57:42 +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
968de827d6
Fix #11108 , e2f583a
: missing argument for SCC_CARGO_SHORT formatting
2023-07-06 19:46:54 +02:00
Rubidium
2ec4ea2b99
Codechange: use the string temporaries for game script strings
2023-07-03 18:08:03 +02:00
Rubidium
3e488465f8
Codechange: allow string temporaries in a StringParameter
2023-07-03 18:08:03 +02:00
Rubidium
b2edf82b69
Cleanup: remove unneeded CopyOutDParam version with StringID
2023-07-03 06:56:08 +02:00
Rubidium
4654b2b0aa
Codechange: separate integer and string usage in StringParameters
2023-07-03 06:56:08 +02:00