diff options
author | Sadie Powell <sadie@witchery.services> | 2024-06-19 22:10:19 +0100 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2024-06-19 22:44:31 +0100 |
commit | 01fc3ea22e02da39a0297858dba118ea3da4e410 (patch) | |
tree | d130b0d2dd471b51821da13e44bc964a19c715c8 /include | |
parent | 3388736fabf562de9ad2c50cb45c7ccbb05ab9f0 (diff) |
Fix importing Atheme opers.
Diffstat (limited to 'include')
-rw-r--r-- | include/modules/os_oper.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/include/modules/os_oper.h b/include/modules/os_oper.h new file mode 100644 index 000000000..8a92efe45 --- /dev/null +++ b/include/modules/os_oper.h @@ -0,0 +1,46 @@ +/* + * + * (C) 2011-2024 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + */ + +#pragma once + +struct MyOper final + : Oper + , Serializable +{ + MyOper(const Anope::string &n, OperType *o) : Oper(n, o), Serializable("Oper") { } + + void Serialize(Serialize::Data &data) const override + { + data["name"] << this->name; + data["type"] << this->ot->GetName(); + } + + static Serializable *Unserialize(Serializable *obj, Serialize::Data &data) + { + Anope::string stype, sname; + + data["type"] >> stype; + data["name"] >> sname; + + OperType *ot = OperType::Find(stype); + if (ot == NULL) + return NULL; + NickCore *nc = NickCore::Find(sname); + if (nc == NULL) + return NULL; + + MyOper *myo; + if (obj) + myo = anope_dynamic_static_cast<MyOper *>(obj); + else + myo = new MyOper(nc->display, ot); + nc->o = myo; + Log(LOG_NORMAL, "operserv/oper") << "Tied oper " << nc->display << " to type " << ot->GetName(); + return myo; + } +}; |