1
0
Fork 0
Commit Graph

415 Commits (9ac9798d7f98ec1d0f1faf7fe3028e27ca592153)

Author SHA1 Message Date
frosch 9ac9798d7f
Codechange: Remove usages of stoi and stol. (#14196) 2025-05-03 17:46:30 +02:00
Loïc Guilloux 1f212e6f2a
Fix: Handle \t when loading GS strings from savegame (#14180) 2025-05-01 16:48:02 +02:00
Rubidium c1a287ad17 Codechange: make some saveload functions work natively with std::string_view 2025-04-30 23:49:06 +02:00
frosch 9cf36dac39 Codechange: Use data() instead of c_str(), if no NUL termination is needed. 2025-04-30 19:33:56 +02:00
Rubidium 78250c3bba Codechange: remove const char* overloads when there are std::string_view and std::string& overloads 2025-04-29 10:14:53 +02:00
frosch 689f55a0ea
Fix #14044: Negative string parameters from GS were rendered as zero. (#14049)
String parameters are always stored as uint64_t. Negative values are sign-extended to int64_t and then casted to uint64_t.
The same applies to encoded strings. But ScriptText encoded them as int64_t.

Co-authored-by: rubidium42 <rubidium42@users.noreply.github.com>
2025-04-20 23:01:49 +02:00
frosch 26db4ccf09
Codechange: Turn bit-stuffed FiosType enum into a struct. (#14019) 2025-04-18 15:20:55 +02:00
frosch 131b7c7122 Codechange: Replace Utf8Decode usages with StringConsumer. 2025-04-13 21:59:10 +02:00
frosch dd073eb38d Codechange: Use StringBuilder to create encoded strings. 2025-04-08 23:10:58 +02:00
Peter Nelson 5b9d171e63
Codechange: Use EnumBitSet for StringValidationSettings. (#13974) 2025-04-08 21:19:17 +01:00
frosch 2cdf2bedfa
Codechange: Add a std::string overload for StrMakeValidInPlace() and a moving std::string&& overload for StrMakeValid(). (#13962) 2025-04-07 18:22:47 +02:00
Peter Nelson 8b4114d709
Fix #13849: Settings in old saves could be overridden by defaults. (#13874)
Resolved by resetting settings to default values before the OPTS and PATS chunks are loaded.
2025-03-23 15:55:55 +00:00
Peter Nelson 2909a14374 Codechange: Include table/strings.h in files that use StringIDs.
Be consistent with how and where the file is incldued.
2025-03-21 12:53:40 +00:00
Peter Nelson 89948b941b
Codechange: Use emplace_back instead of push_back. (#13855) 2025-03-20 17:39:10 +00:00
Rubidium 754311a779 Codechange: use std::move when appropriate 2025-03-13 13:00:24 +01:00
Rubidium 32b2de36ef Codefix: check the table header is actually being read 2025-03-12 17:55:34 +01:00
Peter Nelson 94c6221dff
Fix edf9f597ec: Screenshot with non-wallclock date saved with wrong filename. (#13721) 2025-03-03 21:44:48 +00:00
Peter Nelson edf9f597ec Codechange: Use parameterised GetString() for remaining windows. 2025-03-02 07:29:25 +00:00
Peter Nelson 2d7d085e8e
Codechange: Use EncodedString for error messages. (#13569) 2025-02-16 10:04:32 +00:00
Peter Nelson dccc6185b9
Codechange: Change internal format of encoded strings to improve robustness and allow expansion. (#13499) 2025-02-09 12:45:50 +00:00
Rubidium 83479a4e12 Codechange: add method for reading a string from a savegame given a length 2025-02-07 22:49:17 +01:00
Peter Nelson bf6293a13f
Fix: Rail/road type conversion data is not populated on new game. (#13403)
This means that the rail/road type conversion that happens if NewGRFs are changed does not work the first time for a new game, only with a savegame.
2025-01-29 21:45:16 +00: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
Peter Nelson fb6781015a Codechange: Use std::endian instead of TTD_ENDIAN defines. 2025-01-28 19:37:34 +00:00
Rubidium 4099acb946 Codechange: replace BSWAP32/BSWAP16 with std::byteswap 2025-01-28 19:22:12 +01:00
Peter Nelson f6ab2b69c6
Codechange: Define GRFConfigList alias and pass by reference. (#13358)
This adds the distinction between a single GRFConfig and a GRFConfig list, and simplifies how GRFConfig lists are passed to various functions.
2025-01-22 22:30:32 +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
Peter Nelson 177e2ebf80 Codechange: Support saveload of reference vectors.
This uses the same data format as reference lists, but for vectors, so allows data structures to be changed without affecting savegame format.
2024-11-27 12:35:27 +00:00
Peter Nelson 059a4b22f7 Codechange: Use projection-based std::range::find where possible.
This simplifies matching by class members and avoids wordy lambdas.
2024-11-24 10:36:03 +00:00
Peter Nelson d4f8453c22 Codefix: Clear and reserve storage when loading vectors from savegames. 2024-11-18 08:59:41 +00:00
Peter Nelson 74910d3d14
Fix 908ee729: Inverted condition prevented actually writing data to files. (#12941) 2024-09-16 13:45:23 +00: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
Jonathan G Rennison 2a5a0b0990 Codechange: No longer allow saving of incorrect string container table fields
See: 1250ce8f
2024-09-14 15:32:48 +01:00
Peter Nelson 7f5a3eaf83
Codefix: Avoid type-casting function pointer with incorrect type. (#12929)
Make `AutolengthProc` take `int` instead of `void *`, avoiding pointer parameters.
2024-09-12 06:49:45 +01:00
Jonathan G Rennison 65c666cb57
Codechange: Remove unused size field from struct SaveLoad (#12859) 2024-07-14 14:30:35 -04:00
Peter Nelson b4bcb330c7
Codechange: Replace GetSavegameFormat's compression output pointer with std::pair return. (#12850)
This avoids using an unchecked pointer as an out-parameter.
2024-07-09 18:57:47 +01:00
Peter Nelson 100dd7b6d1
Codechange: Use find_if to get default writeable saveload format. (#12849)
* Codechange: Use find_if to get default writeable savegame format.

This removes the last of lastof, and so the lastof macro is removed.
2024-07-09 17:07:40 +01:00
Peter Nelson 79c1492a73
Codechange: Use unique_ptr in MemoryDumper. (#12766)
This replaces C-style manual memory management.
2024-06-08 21:59:56 +01:00
Rubidium 1250ce8fdc Codechange: support storing std::string vectors/deques in the savegame 2024-05-07 00:03:15 +02:00
Peter Nelson 26bb87ebf1
Codechange: Replace SaveLoad var length arrays with switch block and sizeof. (#12570)
SlCalcConvMemLen(), SlCalcConfFileLen() and CalcOldVarLen() follow a pattern of looking up part of a value in an array.

These function returns the size of bytes of a variable type, but is not very clear. Replace with a switch block instead.

Removes lengthof, array indices, and magic numbers.
2024-04-24 21:33:29 +01:00
Rubidium df8eeb1b10 Codechange: use C++ algorithms to determine the SaveLoadFormat 2024-04-09 23:36:39 +02:00
Rubidium 4e6d4fcf32 Codechange: replace for loops with endof with range-based for loops 2024-04-08 07:00:55 +02:00
merni-ns 6f36f3d714
Fix #11055: Make saveload failure error messages consistent with others (#12247)
The save/load error messages were combined using string parameters, rather than using the built-in functionality of error dialogs.
2024-04-01 17:57:03 +01:00
Patric Stout a3cfd23cf9
Codechange: rename byte to uint8_t (#12308) 2024-03-16 23:59:32 +01:00
Patric Stout 3e625b5b1a
Add: track savegame size to report with survey (#12304) 2024-03-16 08:58:56 +01:00
Rubidium e67fc33172 Codechange: Add support for NULL strings in SaveLoadCompat 2024-02-17 14:33:16 +01:00
Loïc Guilloux 3ffa176870
Change: [Script] Store randomizers in savegame (#12063) 2024-02-12 01:22:57 +01:00
Rubidium 7a740eefa0 Codechange: use std::unique_ptr for managing SaveLoadParams 2024-02-03 21:38:33 +01:00
Rubidium 4b372b6050 Codechange: use std::shared_ptr to manage saveload filters instead of manually trying to avoid double frees 2024-02-03 21:38:33 +01:00
frosch b1718478c8 Codechange: Replace old non-standard attributes with C++17/20 standard attributes. 2024-02-02 22:29:28 +01:00