From 89e4e49a63e53d7ed73170091037067a5c137be1 Mon Sep 17 00:00:00 2001
From: Hamish Milne <hamishmilne83@gmail.com>
Date: Tue, 24 Dec 2019 23:17:24 +0000
Subject: [PATCH] Finished AC and ACT service serialization

---
 TODO                               | 2 +-
 src/core/hle/service/ac/ac.h       | 2 --
 src/core/hle/service/ac/ac_i.h     | 1 -
 src/core/hle/service/ac/ac_u.cpp   | 3 +++
 src/core/hle/service/ac/ac_u.h     | 6 ++++++
 src/core/hle/service/act/act.h     | 6 +++++-
 src/core/hle/service/act/act_a.cpp | 3 +++
 src/core/hle/service/act/act_a.h   | 5 +++++
 src/core/hle/service/act/act_u.cpp | 3 +++
 src/core/hle/service/act/act_u.h   | 5 +++++
 src/core/hle/service/service.h     | 2 ++
 11 files changed, 33 insertions(+), 5 deletions(-)

diff --git a/TODO b/TODO
index b9f4fe46b..a7488a20f 100644
--- a/TODO
+++ b/TODO
@@ -62,7 +62,7 @@
         ✔ Wait object @done(19-08-13 16:46)
     ☐ Service @started(19-12-23 12:49)
         ✔ AC @started(19-12-23 12:48) @done(19-12-24 22:38) @lasted(1d9h50m3s)
-        ☐ ACT
+        ✔ ACT @done(19-12-24 23:17)
         ☐ AM
         ☐ APT
         ☐ BOSS
diff --git a/src/core/hle/service/ac/ac.h b/src/core/hle/service/ac/ac.h
index b7a079b33..0f31ca1b4 100644
--- a/src/core/hle/service/ac/ac.h
+++ b/src/core/hle/service/ac/ac.h
@@ -6,8 +6,6 @@
 
 #include <array>
 #include <memory>
-#include <boost/serialization/base_object.hpp>
-#include <boost/serialization/shared_ptr.hpp>
 #include "core/hle/service/service.h"
 
 namespace Core {
diff --git a/src/core/hle/service/ac/ac_i.h b/src/core/hle/service/ac/ac_i.h
index d7ab22b25..e05bac803 100644
--- a/src/core/hle/service/ac/ac_i.h
+++ b/src/core/hle/service/ac/ac_i.h
@@ -5,7 +5,6 @@
 #pragma once
 
 #include <memory>
-#include <boost/serialization/base_object.hpp>
 #include "core/hle/service/ac/ac.h"
 
 namespace Service::AC {
diff --git a/src/core/hle/service/ac/ac_u.cpp b/src/core/hle/service/ac/ac_u.cpp
index d62d7ccb6..429942f7d 100644
--- a/src/core/hle/service/ac/ac_u.cpp
+++ b/src/core/hle/service/ac/ac_u.cpp
@@ -3,6 +3,7 @@
 // Refer to the license.txt file included.
 
 #include "core/hle/service/ac/ac_u.h"
+#include "common/archives.h"
 
 namespace Service::AC {
 
@@ -33,3 +34,5 @@ AC_U::AC_U(std::shared_ptr<Module> ac) : Module::Interface(std::move(ac), "ac:u"
 }
 
 } // namespace Service::AC
+
+SERIALIZE_EXPORT_IMPL(Service::AC::AC_U)
diff --git a/src/core/hle/service/ac/ac_u.h b/src/core/hle/service/ac/ac_u.h
index 18efcd1e6..c15870b51 100644
--- a/src/core/hle/service/ac/ac_u.h
+++ b/src/core/hle/service/ac/ac_u.h
@@ -12,6 +12,12 @@ namespace Service::AC {
 class AC_U final : public Module::Interface {
 public:
     explicit AC_U(std::shared_ptr<Module> ac);
+
+private:
+    SERVICE_SERIALIZATION(AC_U, ac)
 };
 
 } // namespace Service::AC
+
+BOOST_CLASS_EXPORT_KEY(Service::AC::AC_U)
+BOOST_SERIALIZATION_CONSTRUCT(Service::AC::AC_U)
diff --git a/src/core/hle/service/act/act.h b/src/core/hle/service/act/act.h
index 884678890..c327cdaef 100644
--- a/src/core/hle/service/act/act.h
+++ b/src/core/hle/service/act/act.h
@@ -20,9 +20,13 @@ public:
         Interface(std::shared_ptr<Module> act, const char* name);
         ~Interface();
 
-    private:
+    protected:
         std::shared_ptr<Module> act;
     };
+private:
+    template <class Archive>
+    inline void serialize(Archive& ar, const unsigned int file_version) { }
+    friend class boost::serialization::access;
 };
 
 void InstallInterfaces(Core::System& system);
diff --git a/src/core/hle/service/act/act_a.cpp b/src/core/hle/service/act/act_a.cpp
index 7a33f9175..b4bf750f7 100644
--- a/src/core/hle/service/act/act_a.cpp
+++ b/src/core/hle/service/act/act_a.cpp
@@ -3,6 +3,7 @@
 // Refer to the license.txt file included.
 
 #include "core/hle/service/act/act_a.h"
+#include "common/archives.h"
 
 namespace Service::ACT {
 
@@ -24,3 +25,5 @@ ACT_A::ACT_A(std::shared_ptr<Module> act) : Module::Interface(std::move(act), "a
 }
 
 } // namespace Service::ACT
+
+SERIALIZE_EXPORT_IMPL(Service::ACT::ACT_A)
diff --git a/src/core/hle/service/act/act_a.h b/src/core/hle/service/act/act_a.h
index 48a79aab7..036a96182 100644
--- a/src/core/hle/service/act/act_a.h
+++ b/src/core/hle/service/act/act_a.h
@@ -11,6 +11,11 @@ namespace Service::ACT {
 class ACT_A final : public Module::Interface {
 public:
     explicit ACT_A(std::shared_ptr<Module> act);
+private:
+    SERVICE_SERIALIZATION(ACT_A, act)
 };
 
 } // namespace Service::ACT
+
+BOOST_CLASS_EXPORT_KEY(Service::ACT::ACT_A)
+BOOST_SERIALIZATION_CONSTRUCT(Service::ACT::ACT_A)
diff --git a/src/core/hle/service/act/act_u.cpp b/src/core/hle/service/act/act_u.cpp
index 99978d9ca..599bec18a 100644
--- a/src/core/hle/service/act/act_u.cpp
+++ b/src/core/hle/service/act/act_u.cpp
@@ -3,6 +3,7 @@
 // Refer to the license.txt file included.
 
 #include "core/hle/service/act/act_u.h"
+#include "common/archives.h"
 
 namespace Service::ACT {
 
@@ -20,3 +21,5 @@ ACT_U::ACT_U(std::shared_ptr<Module> act) : Module::Interface(std::move(act), "a
 }
 
 } // namespace Service::ACT
+
+SERIALIZE_EXPORT_IMPL(Service::ACT::ACT_U)
diff --git a/src/core/hle/service/act/act_u.h b/src/core/hle/service/act/act_u.h
index 3aca428e6..14d924025 100644
--- a/src/core/hle/service/act/act_u.h
+++ b/src/core/hle/service/act/act_u.h
@@ -11,6 +11,11 @@ namespace Service::ACT {
 class ACT_U final : public Module::Interface {
 public:
     explicit ACT_U(std::shared_ptr<Module> act);
+private:
+    SERVICE_SERIALIZATION(ACT_U, act)
 };
 
 } // namespace Service::ACT
+
+BOOST_CLASS_EXPORT_KEY(Service::ACT::ACT_U)
+BOOST_SERIALIZATION_CONSTRUCT(Service::ACT::ACT_U)
diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h
index d124b0070..bdad47ea8 100644
--- a/src/core/hle/service/service.h
+++ b/src/core/hle/service/service.h
@@ -11,6 +11,8 @@
 #include <string>
 #include <boost/container/flat_map.hpp>
 #include <boost/serialization/assume_abstract.hpp>
+#include <boost/serialization/shared_ptr.hpp>
+#include <boost/serialization/base_object.hpp>
 #include "common/common_types.h"
 #include "common/construct.h"
 #include "core/hle/kernel/hle_ipc.h"