From 24b5ffbfcadf360dc5e95f8f66143ffcc681335d Mon Sep 17 00:00:00 2001 From: Steveice10 <1269164+Steveice10@users.noreply.github.com> Date: Fri, 8 Dec 2023 23:34:44 -0800 Subject: [PATCH] boss: Implement Spotpass service (part 1) (#7232) * boss: Implement Spotpass service (part 1) * boss: Fix save state (de)serialization. * boss: Fix casing of SpotPass in log messages. * boss: Minor logging improvements. * common: Add boost serialization support for std::variant. --------- Co-authored-by: Rokkubro Co-authored-by: FearlessTobi --- src/common/CMakeLists.txt | 1 + .../serialization/boost_std_variant.hpp | 204 +++++++++ src/core/CMakeLists.txt | 2 + src/core/hle/service/boss/boss.cpp | 321 +++++++++----- src/core/hle/service/boss/boss.h | 50 ++- src/core/hle/service/boss/online_service.cpp | 400 ++++++++++++++++++ src/core/hle/service/boss/online_service.h | 169 ++++++++ 7 files changed, 1018 insertions(+), 129 deletions(-) create mode 100644 src/common/serialization/boost_std_variant.hpp create mode 100644 src/core/hle/service/boss/online_service.cpp create mode 100644 src/core/hle/service/boss/online_service.h diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 6b97b6837..fa6b7a7af 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -127,6 +127,7 @@ add_library(citra_common STATIC serialization/boost_discrete_interval.hpp serialization/boost_flat_set.h serialization/boost_small_vector.hpp + serialization/boost_std_variant.hpp serialization/boost_vector.hpp static_lru_cache.h string_literal.h diff --git a/src/common/serialization/boost_std_variant.hpp b/src/common/serialization/boost_std_variant.hpp new file mode 100644 index 000000000..b00f827b1 --- /dev/null +++ b/src/common/serialization/boost_std_variant.hpp @@ -0,0 +1,204 @@ +#ifndef BOOST_SERIALIZATION_STD_VARIANT_HPP +#define BOOST_SERIALIZATION_STD_VARIANT_HPP + +// MS compatible compilers support #pragma once +#if defined(_MSC_VER) +# pragma once +#endif + +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// variant.hpp - non-intrusive serialization of variant types +// +// copyright (c) 2019 Samuel Debionne, ESRF +// +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org for updates, documentation, and revision history. +// +// Widely inspired form boost::variant serialization +// + +#include + +#include + +#include + +#include +#include +#include + +namespace boost { +namespace serialization { + +template +struct std_variant_save_visitor +{ + std_variant_save_visitor(Archive& ar) : + m_ar(ar) + {} + template + void operator()(T const & value) const + { + m_ar << BOOST_SERIALIZATION_NVP(value); + } +private: + Archive & m_ar; +}; + + +template +struct std_variant_load_visitor +{ + std_variant_load_visitor(Archive& ar) : + m_ar(ar) + {} + template + void operator()(T & value) const + { + m_ar >> BOOST_SERIALIZATION_NVP(value); + } +private: + Archive & m_ar; +}; + +template +void save( + Archive & ar, + std::variant const & v, + unsigned int /*version*/ +){ + const std::size_t which = v.index(); + ar << BOOST_SERIALIZATION_NVP(which); + std_variant_save_visitor visitor(ar); + std::visit(visitor, v); +} + +// Minimalist metaprogramming for handling parameter pack +namespace mp { + namespace detail { + template + struct front_impl; + + template