diff options
author | Adam <Adam@anope.org> | 2017-12-03 14:40:01 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2017-12-03 14:40:01 -0500 |
commit | 76142b1970d6fd68d001e9972833046c79483a49 (patch) | |
tree | 166328fe427a73cab304378e4c3e994b3abe4759 /modules | |
parent | 2fda0fff4655e92e388d7823e5b1c1f0c6bcfe2d (diff) |
serialize: set and cache new value before calling OnSet and pass old value to OnSet
Diffstat (limited to 'modules')
-rw-r--r-- | modules/chanserv/main/channeltype.cpp | 3 | ||||
-rw-r--r-- | modules/chanserv/main/channeltype.h | 2 | ||||
-rw-r--r-- | modules/nickserv/main/accounttype.cpp | 3 | ||||
-rw-r--r-- | modules/nickserv/main/accounttype.h | 2 | ||||
-rw-r--r-- | modules/nickserv/main/nicktype.cpp | 4 | ||||
-rw-r--r-- | modules/nickserv/main/nicktype.h | 2 |
6 files changed, 7 insertions, 9 deletions
diff --git a/modules/chanserv/main/channeltype.cpp b/modules/chanserv/main/channeltype.cpp index e3de67357..4cbda871e 100644 --- a/modules/chanserv/main/channeltype.cpp +++ b/modules/chanserv/main/channeltype.cpp @@ -53,10 +53,9 @@ ChannelType::ChannelType(Module *me) : Serialize::Type<ChannelImpl>(me) } -void ChannelType::Name::OnSet(ChannelImpl *c, const Anope::string &value) +void ChannelType::Name::OnSet(ChannelImpl *c, Anope::string *old, const Anope::string &value) { ChanServ::registered_channel_map& map = ChanServ::service->GetChannels(); - Anope::string *old = this->Get_(c); if (old != nullptr) map.erase(*old); diff --git a/modules/chanserv/main/channeltype.h b/modules/chanserv/main/channeltype.h index c8515b289..437eba133 100644 --- a/modules/chanserv/main/channeltype.h +++ b/modules/chanserv/main/channeltype.h @@ -27,7 +27,7 @@ class ChannelType : public Serialize::Type<ChannelImpl> { using Serialize::Field<ChannelImpl, Anope::string>::Field; - void OnSet(ChannelImpl *c, const Anope::string &value) override; + void OnSet(ChannelImpl *c, Anope::string *old, const Anope::string &value) override; } name; Serialize::Field<ChannelImpl, Anope::string> desc; Serialize::Field<ChannelImpl, time_t> time_registered; diff --git a/modules/nickserv/main/accounttype.cpp b/modules/nickserv/main/accounttype.cpp index 0f4ebbd16..d8d4da108 100644 --- a/modules/nickserv/main/accounttype.cpp +++ b/modules/nickserv/main/accounttype.cpp @@ -47,11 +47,10 @@ AccountType::AccountType(Module *me) : Serialize::Type<AccountImpl>(me) } -void AccountType::Display::OnSet(AccountImpl *acc, const Anope::string &disp) +void AccountType::Display::OnSet(AccountImpl *acc, Anope::string *old, const Anope::string &disp) { NickServ::nickcore_map& map = NickServ::service->GetAccountMap(); - Anope::string *old = this->Get_(acc); if (old != nullptr) map.erase(*old); diff --git a/modules/nickserv/main/accounttype.h b/modules/nickserv/main/accounttype.h index 1a6ab37cd..9ac91cd2e 100644 --- a/modules/nickserv/main/accounttype.h +++ b/modules/nickserv/main/accounttype.h @@ -27,7 +27,7 @@ class AccountType : public Serialize::Type<AccountImpl> { using Serialize::Field<AccountImpl, Anope::string>::Field; - void OnSet(AccountImpl *s, const Anope::string &) override; + void OnSet(AccountImpl *s, Anope::string *, const Anope::string &) override; } display; /* User password in form of hashm:data */ Serialize::Field<AccountImpl, Anope::string> pass; diff --git a/modules/nickserv/main/nicktype.cpp b/modules/nickserv/main/nicktype.cpp index c732fe74a..4480169a1 100644 --- a/modules/nickserv/main/nicktype.cpp +++ b/modules/nickserv/main/nicktype.cpp @@ -34,11 +34,11 @@ NickType::NickType(Module *me) : Serialize::Type<NickImpl>(me) } -void NickType::Nick::OnSet(NickImpl *na, const Anope::string &value) +void NickType::Nick::OnSet(NickImpl *na, Anope::string *old, const Anope::string &value) { /* Remove us from the aliases list */ NickServ::nickalias_map &map = NickServ::service->GetNickMap(); - Anope::string *old = this->Get_(na); + if (old != nullptr) map.erase(*old); diff --git a/modules/nickserv/main/nicktype.h b/modules/nickserv/main/nicktype.h index 187cf463e..b804c2762 100644 --- a/modules/nickserv/main/nicktype.h +++ b/modules/nickserv/main/nicktype.h @@ -26,7 +26,7 @@ class NickType : public Serialize::Type<NickImpl> { using Serialize::Field<NickImpl, Anope::string>::Field; - void OnSet(NickImpl *s, const Anope::string &value) override; + void OnSet(NickImpl *s, Anope::string *old, const Anope::string &value) override; } nick; Serialize::Field<NickImpl, Anope::string> last_quit; Serialize::Field<NickImpl, Anope::string> last_realname; |