Commit Graph

376 Commits

Author SHA1 Message Date
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
Tyler Trahan 2b1f78d2ca
Fix: Use alternate timekeeping units in savegame title (#11912) 2024-01-29 22:11:00 +00:00
Kuhnovic f1e999ec59
Feature: Region-based pathfinder for ships (#10543) 2024-01-08 20:29:05 +01:00
Peter Nelson 10f94fb0dd Codechange: Remove runtime variable size assertion. 2023-12-09 08:13:03 +00:00
frosch a7707302e6 Codechange: silence false warning. 2023-09-19 22:49:59 +02:00
frosch b6c8f301be Codechange: Silence warnings about intentionally unused parameters. 2023-09-19 22:49:59 +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 97dd84d1e0 Codechange: move saveload string fixing code to saveload 2023-06-08 20:36:27 +02:00
Rubidium 9408ab4799 Codechange: only one '\0' is required 2023-06-08 18:51:02 +02:00
Rubidium 55dfca1936 Codechange: replace seprintf with C++ style formatting 2023-06-05 23:25:59 +02:00
Rubidium 993f90b6a0 Codechange: let GenerateDefaultSaveName return std::string 2023-06-04 14:11:13 +02:00
Rubidium d9f8a4c380 Codechange: use std::string GetString variant 2023-05-31 19:31:09 +02:00
axet 60540f7df6 Change: Allow dedicated server to use threaded saves. (#10787)
Co-authored-by: Jonathan G Rennison <j.g.rennison@gmail.com>
2023-05-21 19:55:12 +02:00
Peter Nelson 56085be9bd Codechange: Move includes for common STL headers to stdafx. 2023-05-17 10:14:41 +01:00
Rubidium e9c03f0dad Cleanup: remnants of C-style strings in saveload 2023-05-16 18:32:52 +02:00
Rubidium 68ff3fd062 Change: include fmt.h C++ headers in stdafx.h
This to prevent compilation issues between runs with and without precompiled
headers. Also remove the headers from the rest of the code base as they are
not needed there anymore, although they do relatively little harm.
2023-05-08 16:49:23 +02:00
Tyler Trahan 6501f84b4a
Codechange: Move calendar date functions inside TimerGameCalendar (#10753) 2023-05-04 13:14:12 +00:00
Patric Stout 018a26d9b6
Fix: crash in emscripten when saving games (#10758)
Don't allocate 128KB on stack, but rather on the heap.
2023-05-02 21:22:09 +00:00
Peter Nelson 00bf42353a Codechange: Place gamelog into its own class, along with internal data.
Data is now stored in vectors to avoid manual memory management and
passing lengths around.
2023-05-02 19:47:55 +01:00
Rubidium 1f3b7e2efd Codechange: use std::string instead of stredup for saveload error messages 2023-05-01 16:23:24 +02:00
Rubidium ee723f26ba Codechange: Make FileToSaveLoad's title std::string and simplify assignments 2023-04-29 13:23:34 +02:00
Patric Stout 7aa2b9ab0a
Codechange: move all date-related variables inside the timer (#10706) 2023-04-24 15:56:01 +00:00
Charles Pigott b282664242 Codechange: Replace all usages of alloca/AllocaM with more modern/less discouraged alternatives 2023-04-15 16:57:00 +01:00
Charles Pigott ce24709576 Add: Some additional debugging information when chunk sizes are incorrect 2023-04-10 18:58:48 +01:00
Charles Pigott 8aea13a85b Codechange: Use fmt for SlErrorCorruptFmt 2023-04-10 18:58:48 +01:00
Rubidium 4e65ec1dc4 Codechange: do not declare functions in blocks 2023-01-29 20:28:45 +01:00
rubidium42 1951af07c0 Codechange: do not hide parameters with local variables 2023-01-29 07:21:34 +01:00
PeterN 961e66df30
Fix #10224: Don't fiddle with fast-forward when saving. (#10230)
The original comment about saving with fast-forward on was written 18 years
ago, and predates lots of changes to how saveload work.
2022-12-26 00:05:14 +01:00
Loïc Guilloux 4f9893cc98
Fix 55a1171: Restore skipping of "colour" character (#10244) 2022-12-16 01:56:25 +01:00
dP 5e14a20b3b
Feature: [GS] Scriptable league tables (#10001) 2022-11-26 18:03:03 +01:00
Loïc Guilloux 460991ecf4
Feature: Persistant rotation of numbered auto/netsave after restart (#9397)
It was always starting from 0 on openttd restart.
Now the most recent auto/netsave number will be used as a base to generate the next filename.
2021-07-17 12:48:35 +02:00
Stephan a70aa5df49
Add #9188: netsave now keeps multiple version around, similar to autosave (#9395) 2021-07-09 21:44:02 +02:00
Patric Stout c1f13e0372
Fix: reduce the amount of debug messages on -dsl=2 (#9420)
LoadCheck makes it sound like something is really broken while
loading savegames, while it really is perfectly normal, as most
chunks do not implement LoadCheck.
2021-07-08 19:31:00 +02:00
glx22 6e627f35ac Cleanup: Remove now unneeded ChunkHandler members 2021-07-06 22:29:08 +02:00
glx22 c1a9fe6fbd Codechange: Use static array of references to ChunkHandler 2021-07-06 22:29:08 +02:00
glx22 f371a5ad70 Codechange: Preparation for ChunkHandler subclassing 2021-07-06 22:29:08 +02:00
Patric Stout 7dd5fd6ed4 Feature: framework to make savegames self-descriptive
We won't be able to make it fully self-descriptive (looking at you
MAP-chunks), but anything else can. With this framework, we can
add headers for each chunk explaining how each chunk looks like
in detail.

They also will all be tables, making it a lot easier to read in
external tooling, and opening the way to consider a database
(like SQLite) to use as savegame format.

Lastly, with the headers in the savegame, you can freely add
fields without needing a savegame version bump; older versions
of OpenTTD will simply ignore the new field. This also means
we can remove all the SLE_CONDNULL, as they are irrelevant.

The next few commits will start using this framework.
2021-07-02 22:21:58 +02:00
Patric Stout 8e91527251 Codechange: mark chunks that are not stored as CH_READONLY
This makes it easier to spot chunks that have a save_proc that
is a nullptr, but also prevents confusion, where it looks like
the CH_ type of a chunk has influence on how it is being read.
It is not, it is only used for saving.
2021-06-15 19:36:15 +02:00
Patric Stout b9ab9e4d05 Codechange: add the ability to save/load a std::vector
std::vector<bool> is not possible, as .. that is a nice special
case in C++.

This new type will be used in next commit.
2021-06-15 19:36:15 +02:00
Patric Stout 97b94bdc9a Change: prefix SL_ARR with the length of the array
This means that during loading we can validate that what is saved
is also that what is expected. Additionally, this makes all list
types similar to how they are stored on disk:
First a gamma to indicate length, followed by the data.
The size still depends on the type.
2021-06-15 16:45:04 +02:00