1
0
mirror of https://github.com/anope/anope.git synced 2026-07-10 10:43:13 +02:00

Move serialization from Serializable to a Serialize::Type child.

This commit is contained in:
Sadie Powell
2025-03-12 10:29:11 +00:00
parent 718f2e922a
commit cdcf0e2f9a
40 changed files with 778 additions and 452 deletions
+16 -7
View File
@@ -21,18 +21,27 @@ struct Stats final
{
me = this;
}
};
void Serialize(Serialize::Data &data) const override
struct StatsType final
: Serialize::Type
{
StatsType()
: Serialize::Type("Stats")
{
}
void Serialize(const Serializable *obj, Serialize::Data &data) const override
{
data.Store("maxusercnt", MaxUserCount);
data.Store("maxusertime", MaxUserTime);
}
static Serializable *Unserialize(Serializable *obj, Serialize::Data &data)
Serializable *Unserialize(Serializable *obj, Serialize::Data &data) const override
{
data["maxusercnt"] >> MaxUserCount;
data["maxusertime"] >> MaxUserTime;
return me;
return obj;
}
};
@@ -316,14 +325,14 @@ class OSStats final
: public Module
{
CommandOSStats commandosstats;
Serialize::Type stats_type;
StatsType stats_type;
Stats stats_saver;
public:
OSStats(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
commandosstats(this), stats_type("Stats", Stats::Unserialize)
OSStats(const Anope::string &modname, const Anope::string &creator)
: Module(modname, creator, VENDOR)
, commandosstats(this)
{
}
void OnUserConnect(User *u, bool &exempt) override