From 76142b1970d6fd68d001e9972833046c79483a49 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 3 Dec 2017 14:40:01 -0500 Subject: serialize: set and cache new value before calling OnSet and pass old value to OnSet --- modules/chanserv/main/channeltype.cpp | 3 +-- modules/chanserv/main/channeltype.h | 2 +- modules/nickserv/main/accounttype.cpp | 3 +-- modules/nickserv/main/accounttype.h | 2 +- modules/nickserv/main/nicktype.cpp | 4 ++-- modules/nickserv/main/nicktype.h | 2 +- 6 files changed, 7 insertions(+), 9 deletions(-) (limited to 'modules') 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(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 { using Serialize::Field::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 desc; Serialize::Field 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(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 { using Serialize::Field::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 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(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 { using Serialize::Field::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 last_quit; Serialize::Field last_realname; -- cgit