Fix 908ee729: Inverted condition prevented actually writing data to files. (#12941)
[openttd-github.git] / src / saveload / saveload_error.hpp
blob5500d90231a1e217a45304df009a92f3ece248d1
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 <http://www.gnu.org/licenses/>.
6 */
8 /** @file saveload.h Functions/types related to errors from savegames. */
10 #ifndef SAVELOAD_ERROR_HPP
11 #define SAVELOAD_ERROR_HPP
13 #include "../3rdparty/fmt/format.h"
14 #include "../strings_type.h"
16 [[noreturn]] void SlError(StringID string, const std::string &extra_msg = {});
17 [[noreturn]] void SlErrorCorrupt(const std::string &msg);
19 /**
20 * Issue an SlErrorCorrupt with a format string.
21 * @param format_string The formatting string to tell what to do with the remaining arguments.
22 * @param fmt_args The arguments to be passed to fmt.
23 * @tparam Args The types of the fmt arguments.
24 * @note This function does never return as it throws an exception to
25 * break out of all the saveload code.
27 template <typename ... Args>
28 [[noreturn]] inline void SlErrorCorruptFmt(const fmt::format_string<Args...> format, Args&&... fmt_args)
30 SlErrorCorrupt(fmt::format(format, std::forward<Args>(fmt_args)...));
33 #endif /* SAVELOAD_ERROR_HPP */