From cdcf0e2f9a8fb0e1c363fc65f71f3131fc6c5ea5 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 12 Mar 2025 10:29:11 +0000 Subject: Move serialization from Serializable to a Serialize::Type child. --- modules/nickserv/ns_ajoin.cpp | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'modules/nickserv/ns_ajoin.cpp') diff --git a/modules/nickserv/ns_ajoin.cpp b/modules/nickserv/ns_ajoin.cpp index a169022b1..d60e30f07 100644 --- a/modules/nickserv/ns_ajoin.cpp +++ b/modules/nickserv/ns_ajoin.cpp @@ -39,18 +39,28 @@ struct AJoinEntry final (*channels)->erase(it); } } +}; - void Serialize(Serialize::Data &data) const override +struct AJoinEntryType final + : public Serialize::Type +{ + AJoinEntryType() + : Serialize::Type("AJoinEntry") { - if (!this->owner) + } + + void Serialize(const Serializable *obj, Serialize::Data &data) const override + { + const auto *aj = static_cast(obj); + if (!aj->owner) return; - data.Store("owner", this->owner->display); - data.Store("channel", this->channel); - data.Store("key", this->key); + data.Store("owner", aj->owner->display); + data.Store("channel", aj->channel); + data.Store("key", aj->key); } - static Serializable *Unserialize(Serializable *obj, Serialize::Data &sd) + Serializable *Unserialize(Serializable *obj, Serialize::Data &sd) const override { Anope::string sowner; @@ -305,17 +315,16 @@ class NSAJoin final { CommandNSAJoin commandnsajoin; ExtensibleItem ajoinlist; - Serialize::Type ajoinentry_type; + AJoinEntryType ajoinentry_type; public: - NSAJoin(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandnsajoin(this), ajoinlist(this, "ajoinlist"), - ajoinentry_type("AJoinEntry", AJoinEntry::Unserialize) + NSAJoin(const Anope::string &modname, const Anope::string &creator) + : Module(modname, creator, VENDOR) + , commandnsajoin(this) + , ajoinlist(this, "ajoinlist") { - if (!IRCD || !IRCD->CanSVSJoin) throw ModuleException("Your IRCd does not support SVSJOIN"); - } void OnUserLogin(User *u) override -- cgit