1
0
Fork 0
Commit Graph

184 Commits (9bbc525e5326e83b902ab9168d26fbed0393b890)

Author SHA1 Message Date
frosch a62081d79e
Fix #14251: Out-of-bounds writes via TextRefStack. (#14255) 2025-05-12 13:59:33 +02:00
frosch eb9bbb2456 Codechange: Remove direct access to temporary storage from TextRefStack. 2025-05-06 22:24:41 +02:00
frosch 2a62eea005
Codefix: Comment style. (#14064) 2025-04-21 17:25:09 +02:00
frosch f5ffd4789b Codechange: Use StringConsumer in FormatString. 2025-04-14 16:57:41 +02:00
frosch 15a17d832f Codechange: Use StringConsumer in HandleNewGRFStringControlCodes. 2025-04-14 16:57:41 +02:00
frosch 98efd3c96e Codefix #13872: Use StringConsumer in TranslateTTDPatchCodes. 2025-04-14 16:57:41 +02:00
Peter Nelson 936d78fefc
Codefix: Avoid uppercase characters in variable names. (#13985) 2025-04-10 07:19:27 +01:00
frosch 128e0fcde2 Codechange: Use StringBuilder in TranslateTTDPatchCodes. 2025-04-08 23:10:58 +02:00
frosch 04246c530f
Codechange: Use fmt::format instead of stringstream with iomanip flags. (#13964) 2025-04-08 20:57:50 +00:00
frosch c105adcd96
Codechange: Encode case/gender/plural choice lists without null termination, only length prefix. (#13876) 2025-03-25 20:32:40 +01:00
frosch 5aa4ad5135
Codechange: Pass unformatted strings from GetStringPtr as std::string_view. (#13871) 2025-03-23 19:23:31 +01:00
frosch af49320637
Fix: [NewGRF] Plurals and genders did not work in strings with cases. (#13853) 2025-03-22 21:41:27 +01:00
frosch a4f3ddae5f
Fix: [NewGRF] String parameter stack and case selection were not processed for control code 0x81. (#13851) 2025-03-21 18:13:08 +01:00
frosch 3b178bf58d Fix: NewGRF string interpolation did not process all string parameters, if certain string control codes were present.
String control codes with inline data may contain null characters, in particular plural/gender/case choice lists.
2025-03-21 11:03:24 +01:00
frosch 5d291317e7 Codechange: Two very different functions were named RemapNewGRFStringControlCode. 2025-03-21 11:03:24 +01:00
Peter Nelson 89948b941b
Codechange: Use emplace_back instead of push_back. (#13855) 2025-03-20 17:39:10 +00:00
Rubidium 24f79d2ab7 Codefix: wrong type for choice list mapping 2025-03-15 21:43:18 +01:00
frosch 4f63340f8d
Codechange: Replace a raw pointer with std::optional. (#13809) 2025-03-15 16:52:12 +01:00
Peter Nelson 572f2801ac
Codechange: Use emplace_back instead of back_inserter. (#13781)
This silences a warning produced by gcc.
2025-03-09 17:42:00 +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
Rubidium 2929411130 Codechange: introduce ReferenceThroughBaseContainer
This provides support for ConvertibleThroughBase positions passed to the
functions of a container that return a reference, specifically 'at(pos)'
and 'operator[](pos)'.
2025-02-09 15:28:03 +01:00
Peter Nelson afc0745aa2
Codechange: Specify underlying type for all enums excluding those exposed to scripts. (#13383) 2025-01-28 22:17:34 +00:00
Rubidium e894a5880c Codechange: rename CargoID to CargoType and amend related variables/comments 2025-01-26 18:07:10 +01:00
Rubidium fd7a883cbd Codechange: make the StringIndex (within a StringTab) a strong type 2025-01-02 21:19:00 +01:00
Peter Nelson 2d372fa516 Codechange: NewGRF strings are not StringIDs.
Add GRFStringID type and use it when dealing with GRF-local string IDs.
2025-01-02 20:03:40 +00:00
Rubidium 9b3f4dff4c Codechange: swap `int + year` to `year + int`
This way the operator+ without implicit constructor call is used
2025-01-01 00:10:35 +01:00
Peter Nelson c4424aa894
Codechange: Use correct char type in RemapNewGRFStringControlCode. (#13173) 2024-12-18 12:58:23 +00:00
Peter Nelson e28617fda6
Codefix: Avoiding passing new raw pointer into a smart pointer. (#13138)
Use `std::make_shared` or `std::make_unique` instead of `reset(new ...)`.
2024-12-01 14:22:41 +00:00
Peter Nelson fa1849b855 Codechange: Use std::range::find_if where possible. 2024-11-24 10:36:03 +00:00
Peter Nelson 54be756aae
Codechange: Pass NewGRF strings as std::string_view instead of char *. (#12461) 2024-04-09 08:40:27 +01:00
Rubidium e904122441 Codefix: follow coding style 2024-03-22 22:24:17 +01:00
Patric Stout a3cfd23cf9
Codechange: rename byte to uint8_t (#12308) 2024-03-16 23:59:32 +01:00
Peter Nelson 7d4a91ef9e
Cleanup: Remove some unused functions. (#11429)
These were picked up with cppcheck.
2023-11-03 21:21:00 +00:00
Tyler Trahan 701a61c9af Codechange: Delete date_type.h 2023-09-10 08:40:25 -04:00
Tyler Trahan 77173a6a10 Codechange: Move date consts and functions to CalendarTime and TimerGameCalendar classes 2023-09-10 08:40:25 -04:00
Peter Nelson e4613fc04c Codechange: Allow using more than 65536 NewGRF string IDs.
NewGRF string allocation allowed up to 524288 strings, however stringid was passed as uint16_t which limits to 2^16.
2023-09-04 09:49:09 +01:00
Peter Nelson 3e762af2d1 Change: Replace fixed length _grf_text array with vector.
Additionally reshuffle GRFTextEntry for better alignment.

This removes a mostly-unused static 20MB allocation.
2023-09-04 09:49:09 +01: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 1d902a97ce Codechange: move StringParameters to strings_internal.h 2023-06-17 12:14:11 +02:00
Rubidium d4c2043294 Codechange: remove a number of unneeded c_str() calls 2023-06-15 22:14:45 +02:00
Rubidium aba0d27a28 Codechange: use StringParameters for remapping the NewGRF string control codes 2023-06-13 22:11:21 +02:00
PeterN ac1d042550
Remove: obsolete NewGRF text unprinting. (#10884)
Co-authored-by: Rubidium <rubidium@openttd.org>
2023-06-04 13:14:56 +02:00
Peter Nelson c38df2d589 Codechange: Use std::map instead of custom SmallMap. 2023-05-18 12:18:30 +01:00
Peter Nelson 56085be9bd Codechange: Move includes for common STL headers to stdafx. 2023-05-17 10:14:41 +01:00
PeterN 61516627ad
Add: NewGRF string code "9A 21" to display force from textstack. (#10782) 2023-05-11 08:06:46 +01:00
Rubidium 7b539fa7c9 Fix: fmt's {:#04X} yields '0X00', not '0x0000'
Technically the 0X vs 0x is not a big problem, just not pretty. However, the
length also including the 0x results in unexpected behaviour, so it probably
better to not use it.
2023-04-20 21:39:57 +02:00
Rubidium 7088f5b7c7 Codechange: use string/fmt instead of printf for grfmsg 2023-04-18 23:21:08 +02:00
Rubidium a409e4b026 Add: documention to large functions that have too little documentation according to CodeQL 2023-02-25 23:57:36 +01:00
Rubidium 1c0c4637d2 Fix 11ab3c4: [NewGRF] Overflow when determining cargo mask for string code 9A 1E
9A 1E: Print unsigned word as name of a cargo type (translated for GRF version >= 7).
2021-07-10 10:51:00 +02:00
rubidium42 55a11710a6 Codechange: convert printf DEBUG statements to fmt Debug statements 2021-06-13 12:45:45 +02:00