OpenTTD Source 20260721-master-g25ec12c62d
saveload_func.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
9
10#ifndef SAVELOAD_FUNC_H
11#define SAVELOAD_FUNC_H
12
13#include "saveload_type.h"
14#include "../fileio_type.h"
15#include "../fios.h"
16
27
29
30std::string GenerateDefaultSaveName();
33SaveLoadResult SaveOrLoad(std::string_view filename, SaveLoadOperation fop, DetailedFileType dft, Subdirectory sb, bool threaded = true);
34void WaitTillSaved();
36void DoExitSave();
37
39
40SaveLoadResult SaveWithFilter(std::shared_ptr<struct SaveFilter> writer, bool threaded);
41SaveLoadResult LoadWithFilter(std::shared_ptr<struct LoadFilter> reader);
42
44
45extern std::string _savegame_format;
46extern bool _do_autosave;
47
48#endif /* SAVELOAD_FUNC_H */
Container for an encoded string, created by GetEncodedString.
Types for standard in/out file operations.
SaveLoadOperation
Operation performed on the file.
Definition fileio_type.h:52
@ Load
File is being loaded.
Definition fileio_type.h:54
DetailedFileType
Kinds of files in each AbstractFileType.
Definition fileio_type.h:28
Subdirectory
The different kinds of subdirectories OpenTTD uses.
Definition fileio_type.h:88
Declarations for savegames operations.
std::string _savegame_format
how to compress savegames
Definition saveload.cpp:83
bool _do_autosave
are we doing an autosave at the moment?
Definition saveload.cpp:84
SaveLoadResult SaveWithFilter(std::shared_ptr< SaveFilter > writer, bool threaded)
Save the game using a (writer) filter.
FileToSaveLoad _file_to_saveload
File to save or load in the openttd loop.
Definition saveload.cpp:78
SaveLoadResult LoadWithFilter(std::shared_ptr< LoadFilter > reader)
Load the game using a (reader) filter.
void ProcessAsyncSaveFinish()
Handle async save finishes.
Definition saveload.cpp:394
void DoAutoOrNetsave(FiosNumberedSaveName &counter)
Create an autosave or netsave.
EncodedString GetSaveLoadErrorType()
Return the appropriate initial string for an error depending on whether we are saving or loading.
SaveLoadResult SaveOrLoad(std::string_view filename, SaveLoadOperation fop, DetailedFileType dft, Subdirectory sb, bool threaded=true)
Main Save or Load function where the high-level saveload functions are handled.
bool SaveloadCrashWithMissingNewGRFs()
Did loading the savegame cause a crash?
void DoExitSave()
Do a save when exiting the game (_settings_client.gui.autosave_on_exit).
EncodedString GetSaveLoadErrorMessage()
Return the description of the error.
std::string GenerateDefaultSaveName()
Get the default name for a savegame or screenshot.
Types often used outside the saveload code related to saving and loading games.
SaveLoadResult
Save or load result codes.
Deals with the type of the savegame, independent of extension.
void SetMode(const FiosType &ft, SaveLoadOperation fop=SaveLoadOperation::Load)
Set the mode and file type of the file to save or load.
FiosType ftype
File type.
SaveLoadOperation file_op
File operation to perform.
std::string name
Name of the file.
EncodedString title
Internal name of the game.
void Set(const FiosItem &item)
Set the mode, title and name of the file.
Deals with finding savegames.
Definition fios.h:78
A savegame name automatically numbered.
Definition fios.h:119
Elements of a file system that are recognized.
Definition fileio_type.h:63