Patric Stout
f67af5cbe5
Codechange: make it more obvious SlArray supports SLE_VAR_NULL
...
In the end, the code was already doing the right thing, but a few
functions deep, and not really obvious. When validating what objects
can handle SLE_VAR_NULL, it is nicer to just have this obvious.
2021-06-15 16:45:04 +02:00
Patric Stout
d5cda58158
Codechange: use SL_NULL if you want to store null-bytes or load to nothing
...
Using SL_ARR for this gives us a bit of trouble later on, where we
add a length-field to SL_ARR. This of course is not the intention
of SLE_CONDNULL. So better seperate it.
2021-06-15 16:45:04 +02:00
Patric Stout
0d2e3437e3
Change: switch SL_DEQUE and SL_REFLIST length field to a gamma
...
The current SaveLoad is a bit inconsistent how long a length field
is. Sometimes it is a 32bit, sometimes a gamma. Make it consistent
across the board by making them all gammas.
2021-06-15 16:45:04 +02:00
Patric Stout
75e7451151
Change: indicate in the savegame if a SL_STRUCT contains any data
...
This helps external tooling to understand if a SL_STRUCT should
be skipped when reading. Basically, this transforms an SL_STRUCT
into a SL_STRUCTLIST with either 0 or 1 length.
2021-06-15 16:45:04 +02:00
Patric Stout
a146bcfe93
Change: store length of SL_STRUCTLIST in the savegame
...
This wasn't consistently done, and often variables were used that
were read by an earlier blob. By moving it next to the struct
itself, the code becomes a bit more self-contained and easier to
read.
Additionally, this allows for external tooling to know how many
structs to expect, instead of having to know where to find the
length-field or a hard-coded value that can change at any moment.
2021-06-15 16:45:04 +02:00
Patric Stout
4e4720f217
Codechange: remove the special station/vehicle code from SaveLoad
...
With the new SLEG_STRUCT it is much easier to embed a struct
in a struct, where the sub-struct has limitations on when it is
being used.
This makes both the code easier to read (less magic) and avoids
the SaveLoad needing to know all these things about Stations
and Vehicles.
2021-06-14 21:58:05 +02:00
Patric Stout
4600d289b5
Codechange: ability to store structs and list of structs in savegames
...
The commits following this will use this new functionality.
Currently, a few places do this manually. This has as drawback that
the Save() and Load() code need to be in sync, and that any change
can result in (old) savegames no longer loading. In general, it is
annoying code to maintain.
By putting everything in a description table, and use that for
both Save() and Load(), it becomes easier to see what is going on,
and hopefully less likely for people to make mistakes.
2021-06-14 21:58:05 +02:00
rubidium42
55a11710a6
Codechange: convert printf DEBUG statements to fmt Debug statements
2021-06-13 12:45:45 +02:00
Patric Stout
8f323855b1
Codechange: rename SL_LST to SL_REFLIST to highlight the "reference" part
...
You can easily mistake SlList / SL_LST to be a list of SL_VAR, but
it is a list of SL_REF. With this rename, it hopefully saves a few
people from "wtf?" moments.
2021-06-10 19:18:24 +02:00
Patric Stout
aa6443d57a
Codechange: refactor SlList to use SlStorageHelper
2021-06-10 19:18:24 +02:00
Patric Stout
23857af693
Codechange: refactor SlDequeueHelper to work with unsigned and be more generic
...
Future additions will start using it for std::list too.
2021-06-10 19:18:24 +02:00
Patric Stout
a2147d437e
Codechange: use wrappers to get Var[Mem|File]Type, instead of GB()
2021-06-10 19:18:24 +02:00
Patric Stout
fba86f711f
Codechange: move GetVariableAddress inside SlObjectMember
...
Also move it to static, as nobody else is using it.
2021-06-10 19:18:24 +02:00
Patric Stout
1e564b333f
Codechange: make [Save|Load]Settings() behave more like other Save/Load code ( #9335 )
...
Prepare the full description and send it to SlObject. This does
require some code to be able to read to a SLE_VAR_NULL, like strings
etc, as there is no way to know their length beforehand.
2021-06-07 23:03:12 +02:00
Patric Stout
264991dfa5
Codechange: move SLF_NO_NETWORK_SYNC into settings
...
It is a settings-only flag, so don't pollute SaveLoad code with it.
2021-06-06 21:45:01 +02:00
Patric Stout
414e12d26b
Codechange: move SLF_NOT_IN_SAVE into settings
...
It is a settings-only flag, so don't pollute SaveLoad code with it.
2021-06-06 21:45:01 +02:00
glx22
c27afdf3f6
Codechange: Remove FOR_ALL_CHUNK_HANDLERS
...
Co-Authored-By: Patric Stout <truebrain@openttd.org>
2021-06-06 19:35:06 +02:00
Patric Stout
28e90769f7
Codechange: use "[[maybe_unused]]" instead of a wide variety of other ways we had
...
While at it, replace OTTD_ASSERT with WITH_ASSERT, as this
is always set if assert() is valid. No matter if NDEBUG is set
or not.
2021-06-03 17:30:00 +02:00
Patric Stout
9fff00ba20
Codechange: C++-ify lists for SaveLoad ( #9323 )
...
Basically, this changes "SaveLoad *" to either:
1) "SaveLoadTable" if a list of SaveLoads was meant
2) "SaveLoad &" if a single entry was meant
As added bonus, this removes SL_END / SLE_END / SLEG_END. This
also adds core/span.hpp, a "std::span"-lite.
2021-05-31 22:26:44 +02:00
Patric Stout
ca9a7df752
Codechange: rename str_validate to StrMakeValid(InPlace) ( #9304 )
...
This to be more explicit the function changes the value, and not
returns yes/no.
2021-05-29 11:21:38 +02:00
rubidium42
44ca7d9377
Change: Use gender-neutral pronouns
2021-05-15 10:16:48 +02:00
rubidium42
0f062b3882
Codechange: clean up C-string support from settings
2021-05-13 23:13:17 +02:00
rubidium42
95386dc2b8
Codechange: move misc settings to std::string
2021-05-13 23:13:17 +02:00
Loïc Guilloux
356bbbb90a
Fix: [MinGW] Set minimum OS version to Windows XP ( #9135 )
2021-04-29 14:26:08 +02:00
Patric Stout
c3dc27e37e
Add: settings to limit your fast-forward game speed
...
By default this setting is set to 2500% normal game speed.
2021-02-28 18:04:51 +00:00
Charles Pigott
9b800a96ed
Codechange: Remove min/max functions in favour of STL variants ( #8502 )
2021-01-08 11:16:18 +01:00
Patric Stout
8596b43b2b
Codechange: move some DEBUG-levels and remove some others in saveload routine ( #8474 )
...
When running with -dsl=2 it is very easy to miss important information
as there was a lot of noise in between too. This tunes the debug
levels a bit to be less noisy while keeping the important bits.
2021-01-01 14:41:14 +01:00
Michael Lutz
5cbb2da794
Codechange: Even more std::string usage in file IO.
2020-12-27 13:19:25 +01:00
Michael Lutz
65f65ad2ad
Codechange: Convert some more FIO functions to take std::string.
2020-12-27 13:19:25 +01:00
Charles Pigott
860c270c73
Codechange: Replace assert_compile macro with static_assert
2020-12-27 10:55:42 +00:00
cirdan
395a5d9991
Cleanup: Remove unused ChunkType flag CH_AUTO_LENGTH
...
CH_AUTO_LENGTH is no longer used anywhere, so remove all code
that depends on it.
2020-12-27 10:30:55 +00:00
Patric Stout
d8c8f4e72d
Fix: next 67 savegame versions are used in PatchPacks; skip them ( #8411 )
...
Various of PatchPacks (Spring 2013, Joker, ChillPP) used versions
slightly higher than ours. Of course, as time went by, this
caught up with us, and we are now almost pushing a new version
that would conflict with them. To avoid users creating unneeded
issues about "why can I not load my savegame", lets be ahead of
the curve and flat-out refuse to load them.
Version-wise, this is totally fine. We have ~32k versions to go
before we run out (0x8000 is masked by JGRPP; we should avoid
using that). At the rate we bump savegames, this is not going to
happen in any sane reality.
2020-12-22 10:44:07 +01:00
Patric Stout
d15dc9f40f
Add: support for emscripten (play-OpenTTD-in-the-browser)
...
Emscripten compiles to WASM, which can be loaded via
HTML / JavaScript. This allows you to play OpenTTD inside a
browser.
Co-authored-by: milek7 <me@milek7.pl>
2020-12-15 15:46:39 +01:00
Patric Stout
731af1f1f3
Codechange: don't do work GetVariableAddress() is already doing
2020-12-06 16:10:58 +01:00
Jonathan G Rennison
54237b0e98
Codechange: Move SlSkipBytes to saveload.h
2020-06-28 15:32:53 +02:00
Michael Lutz
63ccb36ef3
Codechange: Use std::string for most of the user-settable custom names.
2020-05-21 20:02:34 +02:00
Michael Lutz
9b6f5e3bb8
Codechange: Store GS lang texts in std::strings.
2020-05-21 20:02:34 +02:00
glx
0ed00ae111
Fix: Stop any gamelog action when recovering from SlError()
2020-05-10 20:02:55 +01:00
frosch
a4be4514c9
Fix #7925 : Reset temporary saveload data at the start of loading a savegame instead of at the end.
...
Otherwise temporary data may be passed from an aborted load action to the next load action.
2020-01-12 19:08:38 +01:00
glx
3a14cea068
Codechange: Replace FOR_ALL_COMPANIES with range-based for loops
2019-12-21 20:13:03 +01:00
S. D. Cloudt
13cc8a0cee
Cleanup: Removed SVN headers
2019-11-10 17:59:20 +00:00
JMcKiern
04f659e768
Fix: Some typos found using codespell
2019-09-29 21:27:32 +01:00
Charles Pigott
3299d6540b
Cleanup: Delete GetSavegameType function since it's been commented out since 2005
2019-04-29 17:46:28 +01:00
peter1138
4f052fc2a4
Cleanup: Fix alignment after NULL -> nullptr change.
2019-04-13 20:35:10 +01:00
Henry Wilson
7c8e7c6b6e
Codechange: Use null pointer literal instead of the NULL macro
2019-04-10 23:22:20 +02:00
Michael Lutz
8b1880187a
Remove: AutoFreeSmallVector.
...
The last use was for storing a list of memory blocks. As the way these lists are accessed is very
specific, it is easier to just write an explicit destructor instead of trying to exactly match the behaviour.
2019-04-09 22:45:15 +02:00
Michael Lutz
94c5269fa7
Codechange: Use atomic variables for thread synchronization where useful.
2019-04-06 11:27:39 +02:00
Michael Lutz
05bc2ed7cb
Codechange: Replace custom thread code with C++11 thread objects.
...
We assume a conforming C++11 compiler environment that has a valid <thread>-header.
Failure to run a real thread is handled gracefully.
2019-04-06 11:27:39 +02:00
Henry Wilson
cc62f4163f
Cleanup: Remove unused size template parameters from SmallMap and Auto[Free|Delete]SmallVector
2019-03-26 20:15:57 +00:00
Henry Wilson
a0f36a50e6
Codechange: Replaced SmallVector::Append() with std::vector::[push|emplace]_back()
2019-03-26 20:15:57 +00:00
Henry Wilson
a690936ed7
Codechange: Replace SmallVector::Length() with std::vector::size()
2019-03-26 20:15:57 +00:00
Henry Wilson
af7d9020a1
Codechange: Use override specifer for overriding member declarations
...
This is a C++11 feature that allows the compiler to check that a virtual
member declaration overrides a base-class member with the same signature.
Also src/blitter/32bpp_anim_sse4.hpp +38 is no longer erroneously marked
as virtual despite being a template.
2019-03-24 16:10:04 +01:00
Patric Stout
7adae09897
Codechange: liblzma is called liblzma, how ever strange that might be
...
It is the only library we use that calls itself with 'lib' in the
name. This might be confusing, but with the arrival of cmake a lot
of these things are automated. And detection will find 'liblzma',
not 'lzma', like with 'lzo', 'zlib', ..
2019-03-11 10:16:00 +01:00
PeterN
c0c8fb25fb
Change: Use SlErrorCorrupt() on pool index error when loading a savegame, instead of terminating. ( #7219 )
2019-02-13 09:01:49 +00:00
Peter Nelson
0f37a683a2
Codechange: Additional type safety for saveload version variables.
2019-02-02 21:39:06 +00:00
Peter Nelson
9de12521ec
Codechange: Convert saveload numbers to enum values.
...
(This was mostly achieved with a few in-place regexes)
2019-02-02 21:39:06 +00:00
Peter Nelson
ea4ea62816
Codechange: Make saveload version upper bound exclusive, i.e. version object was removed instead of version object last appeared.
2019-02-02 21:39:06 +00:00
PeterN
23960d0f2c
Feature: Group liveries, and livery window usability enhancements. ( #7108 )
...
* Change: Replace checkbox in livery selection window with Default option in drop down selection.
This reduces clutter in the UI and allows for primary/secondary colours to independently follow the default scheme if desired.
* Feature: Add vehicle group liveries.
2019-01-31 14:57:44 +01:00
Peter Nelson
67633606b0
Codechange: Remove value mangling and field misuse in SLE_WRITEBYTE.
...
The original translation functionality hasn't been used since 2007.
2019-01-30 17:11:40 +00:00
Peter Nelson
225790892d
Change: Make ships stop and change direction slowly instead of instantly turning.
2019-01-24 20:47:40 +00:00
Peter Nelson
81330b8d6e
Change: Add path cache for ships.
2019-01-19 23:11:17 +00:00
Peter Nelson
1c725fce47
Change: Add ability to save/load std::deque<> containers.
2019-01-19 23:11:17 +00:00
Niels Martin Hansen
8859381d30
Add: Industries can produce and accept up to 16 different cargoes
2018-11-03 21:43:54 +01:00
Charles Pigott
f5b1115039
Doc: Lots and lots of doxymentation fixes
2018-10-31 12:35:54 +01:00
Michael Lutz
4b0b4e0643
Feature: [NewGRF] Increase size of persistent storage to 256.
2018-09-02 21:31:15 +02:00
Peter Nelson
bf8d7df736
Change: Extend rail types to 64 (6 bit storage)
2018-07-26 13:27:40 +01:00
Peter Nelson
5db883fbe9
Change: Move rail type bits from m3 to m8.
2018-07-26 13:27:40 +01:00
PeterN
11ab3c4ea2
Change: Increase cargo type limit to 64.
2018-06-26 13:32:58 +01:00
Pavel Stupnikov
fef8b831a9
Change: Switch town growth rate and counter to actual game ticks ( #6763 )
2018-05-02 21:01:30 +02:00
frosch
8c458c153d
(svn r27990) -Update: Docs
2018-03-14 18:05:06 +00:00
frosch
59dd7be686
(svn r27978) -Fix [FS#6673] (r18541): Store the map variety setting in the samegame like the other mapgen settings, so restarting maps considers it. (Samu)
2018-03-11 12:11:09 +00:00
peter1138
ff26c6393e
(svn r27793) -Fix [FS#6450]: Use of uninitialised variable cause lzo to fail. Add check for error status.
2017-03-13 22:16:44 +00:00
frosch
ca3aaf8f6d
(svn r27778) -Change [FS#6442-ish]: Convenience savegame bump to distinguish 1.7 savegames from 1.6 savegames.
2017-03-11 20:37:32 +00:00
frosch
4342798ff5
(svn r27709) -Fix-ish: Silence some warnings. (adf88)
2016-12-25 13:26:15 +00:00
frosch
31f046bd9b
(svn r27670) -Add: [FS#6471] Assign descriptive names to (GNU pthread) threads. (JGR)
2016-10-30 17:29:33 +00:00
alberth
0adfb1ac6f
(svn r27653) -Fix(r27647): Rename FileOperation enum and values to SaveLoadOperation to avoid nameclash with windows compiler toolkit.
2016-09-04 16:06:50 +00:00
alberth
4001f6215e
(svn r27652) -Fix(r27650): Use the file operation being performed to set the _sl.action variable.
2016-09-04 15:10:41 +00:00
alberth
6f201ce4a8
(svn r27651) -Codechange: Introduce methods for setting the name and title of _file_to_saveload.
2016-09-04 12:58:04 +00:00
alberth
597380e099
(svn r27650) -Codechange: Replace SaveOrLoadMode by FileOperation and DetailedFileType.
2016-09-04 12:57:43 +00:00
alberth
df9a9f074a
(svn r27649) -Codechange: Introduce detailed file type enum, rebuild FiosType with it.
2016-09-04 12:57:20 +00:00
alberth
c6ac071619
(svn r27639) -Codechange: Also always set the abstract FileToSaveLoad::filetype when setting a mode.
2016-09-04 12:47:39 +00:00
alberth
2fa0fdb176
(svn r27638) -Codechange: Move FiosType enum, move and rename SetFiosType function.
2016-09-04 12:47:07 +00:00
alberth
9135f7130e
(svn r27635) -Codechange: Move FileType and FileToSaveLoad structure definitions.
2016-09-04 12:45:40 +00:00
frosch
4d1843a95e
(svn r27627) -Codechange: Deduplicate some cursor magic into SetMouseCursorBusy.
2016-08-15 18:32:48 +00:00
frosch
13a86497ea
(svn r27572) -Fix [FS#6442]: Convenience savegame bump to distinguish 1.6 savegames from 1.5 savegames.
2016-05-22 10:10:17 +00:00
frosch
0c7c0ada78
(svn r27518) -Update: Numbers
2016-03-01 20:00:22 +00:00
frosch
3f55e5364e
(svn r27278) -Fix: Handle savegames with an unexpected amount of industry-builder or NewGRF entity-mapping more gracefully.
2015-05-09 10:04:50 +00:00
frosch
6477356dd2
(svn r27192) -Change: heading for 1.6 now
2015-03-17 20:33:44 +00:00
rubidium
771dcf3b7b
(svn r27003) -Cleanup: fix the use of spaces and asterices "around" some comments
2014-10-12 18:41:53 +00:00
rubidium
fedc1acd62
(svn r26881) -Codechange: bump the savegame version
2014-09-21 11:28:29 +00:00
alberth
f72ad87540
(svn r26802) -Add: Command to set visibility of an engine for a company (based on patch by Juanjo).
2014-09-07 16:12:58 +00:00
rubidium
48d446ffeb
(svn r26700) -Fix [FS#6066]: incorrect saving of order backups
2014-07-21 18:03:32 +00:00
fonsinchen
37b1d36fb8
(svn r26650) -Fix [FS#6041]: Support save/load chunk lengths of up to (1 << 32) - 1
2014-06-17 06:13:38 +00:00
fonsinchen
957f5ca117
(svn r26646) -Fix [FS#6041]: Save locations instead of distances in link graphs to reduce size.
2014-06-14 13:35:39 +00:00
rubidium
46792e58dd
(svn r26591) -Add: some instrumentation to catch most cases where the wrong number of bytes would be written into variables during loading (or read during saving)
2014-05-16 17:41:55 +00:00
fonsinchen
2c11eeb39e
(svn r26551) -Fix: document revision number for latest savegame version change
2014-05-01 14:56:33 +00:00
fonsinchen
3ee31a8f89
(svn r26547) -Codechange: Collect order travel and wait times independent of timetables
2014-05-01 14:49:16 +00:00
rubidium
9ed12b0f07
(svn r26509) -Codechange: replace strdup with stredup (the latter ensures the return is not NULL)
2014-04-25 15:40:32 +00:00
rubidium
5b82822c12
(svn r26486) -Codechange: replace a number of snprintfs with seprintf
2014-04-23 21:12:09 +00:00
rubidium
0463dbdc9e
(svn r26482) -Codechange: add an include that allows us to undefine/redefine "unsafe" functions to prevent them from being used, and thus having to care about certain aspects of their return values
2014-04-23 20:13:33 +00:00