diff options
author | Adam <Adam@anope.org> | 2012-04-23 05:08:26 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2012-04-23 05:08:26 -0400 |
commit | 573e49a7ead331219eb6f0d3ca9cf83e793a5c9c (patch) | |
tree | e145e04fa3d041cf92ce46da4ac790b63231059c /modules/commands/cs_suspend.cpp | |
parent | 63c639e108a00d7dbb0d7ac9891684fc83a3b207 (diff) |
Reworked live SQL support yet again
Diffstat (limited to 'modules/commands/cs_suspend.cpp')
-rw-r--r-- | modules/commands/cs_suspend.cpp | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/modules/commands/cs_suspend.cpp b/modules/commands/cs_suspend.cpp index 676ffebfa..d5898083e 100644 --- a/modules/commands/cs_suspend.cpp +++ b/modules/commands/cs_suspend.cpp @@ -13,6 +13,11 @@ #include "module.h" +struct ExtensibleString : Anope::string, ExtensibleItem +{ + ExtensibleString(const Anope::string &s) : Anope::string(s) { } +}; + struct ChanSuspend : ExtensibleItem, Serializable { Anope::string chan; @@ -22,14 +27,14 @@ struct ChanSuspend : ExtensibleItem, Serializable { } - Anope::string serialize_name() const + const Anope::string serialize_name() const { return "ChanSuspend"; } - serialized_data serialize() anope_override + Serialize::Data serialize() const anope_override { - serialized_data sd; + Serialize::Data sd; sd["chan"] << this->chan; sd["when"] << this->when; @@ -37,18 +42,24 @@ struct ChanSuspend : ExtensibleItem, Serializable return sd; } - static void unserialize(serialized_data &sd) + static Serializable* unserialize(Serializable *obj, Serialize::Data &sd) { ChannelInfo *ci = cs_findchan(sd["chan"].astr()); if (ci == NULL) - return; + return NULL; - ChanSuspend *cs = new ChanSuspend(); + ChanSuspend *cs; + if (obj) + cs = debug_cast<ChanSuspend *>(obj); + else + cs = new ChanSuspend(); sd["chan"] >> cs->chan; sd["when"] >> cs->when; - ci->Extend("ci_suspend_expire", cs); + if (!obj) + ci->Extend("ci_suspend_expire", cs); + return cs; } }; @@ -220,11 +231,12 @@ class CSSuspend : public Module ~CSSuspend() { - for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(), it_end = RegisteredChannelList.end(); it != it_end; ++it) + for (registered_channel_map::const_iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; ++it) { - it->second->Shrink("cs_suspend_expire"); - it->second->Shrink("suspend_by"); - it->second->Shrink("suspend_reason"); + ChannelInfo *ci = it->second; + ci->Shrink("cs_suspend_expire"); + ci->Shrink("suspend_by"); + ci->Shrink("suspend_reason"); } } |