diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nickalias.cpp | 19 | ||||
-rw-r--r-- | src/nickcore.cpp | 7 | ||||
-rw-r--r-- | src/regchannel.cpp | 22 |
3 files changed, 45 insertions, 3 deletions
diff --git a/src/nickalias.cpp b/src/nickalias.cpp index 24d3d6e2b..43a35d448 100644 --- a/src/nickalias.cpp +++ b/src/nickalias.cpp @@ -139,7 +139,24 @@ void NickAlias::unserialize(serialized_data &data) if (core == NULL) return; - NickAlias *na = new NickAlias(data["nick"].astr(), core); + NickAlias *na = findnick(data["nick"].astr()); + if (na == NULL) + na = new NickAlias(data["nick"].astr(), core); + else if (na->nc != core) + { + std::list<NickAlias *>::iterator it = std::find(na->nc->aliases.begin(), na->nc->aliases.end(), na); + if (it != na->nc->aliases.end()) + na->nc->aliases.erase(it); + + if (na->nc->aliases.empty()) + delete na->nc; + else if (na->nick.equals_ci(na->nc->display)) + change_core_display(na->nc); + + na->nc = core; + na->nc->aliases.push_back(na); + } + data["last_quit"] >> na->last_quit; data["last_realname"] >> na->last_realname; data["last_usermask"] >> na->last_usermask; diff --git a/src/nickcore.cpp b/src/nickcore.cpp index 836ffdda4..370d6b705 100644 --- a/src/nickcore.cpp +++ b/src/nickcore.cpp @@ -73,7 +73,9 @@ Serializable::serialized_data NickCore::serialize() void NickCore::unserialize(serialized_data &data) { - NickCore *nc = new NickCore(data["display"].astr()); + NickCore *nc = findcore(data["display"].astr()); + if (nc == NULL) + nc = new NickCore(data["display"].astr()); data["pass"] >> nc->pass; data["email"] >> nc->email; data["greet"] >> nc->greet; @@ -83,6 +85,7 @@ void NickCore::unserialize(serialized_data &data) Anope::string buf; data["access"] >> buf; spacesepstream sep(buf); + nc->access.clear(); while (sep.GetToken(buf)) nc->access.push_back(buf); } @@ -90,6 +93,7 @@ void NickCore::unserialize(serialized_data &data) Anope::string buf; data["cert"] >> buf; spacesepstream sep(buf); + nc->cert.clear(); while (sep.GetToken(buf)) nc->cert.push_back(buf); } @@ -98,6 +102,7 @@ void NickCore::unserialize(serialized_data &data) Anope::string buf; data["memoignores"] >> buf; spacesepstream sep(buf); + nc->memos.ignores.clear(); while (sep.GetToken(buf)) nc->memos.ignores.push_back(buf); } diff --git a/src/regchannel.cpp b/src/regchannel.cpp index 33131f059..b8cfbd4ba 100644 --- a/src/regchannel.cpp +++ b/src/regchannel.cpp @@ -355,11 +355,24 @@ Serializable::serialized_data ChannelInfo::serialize() void ChannelInfo::unserialize(serialized_data &data) { - ChannelInfo *ci = new ChannelInfo(data["name"].astr()); + ChannelInfo *ci = cs_findchan(data["name"].astr()); + if (ci == NULL) + new ChannelInfo(data["name"].astr()); + if (data.count("founder") > 0) + { + if (ci->founder) + ci->founder->channelcount--; ci->founder = findcore(data["founder"].astr()); + if (ci->founder) + ci->founder->channelcount++; + } if (data.count("successor") > 0) + { ci->successor = findcore(data["successor"].astr()); + if (ci->founder && ci->founder == ci->successor) + ci->successor = NULL; + } data["description"] >> ci->desc; data["time_registered"] >> ci->time_registered; data["last_used"] >> ci->last_used; @@ -375,7 +388,13 @@ void ChannelInfo::unserialize(serialized_data &data) ci->levels[v[i]] = convertTo<int16_t>(v[i + 1]); } if (data.count("bi") > 0) + { + if (ci->bi) + ci->bi->chancount--; ci->bi = findbot(data["bi"].astr()); + if (ci->bi) + ci->bi->chancount++; + } data["capsmin"] >> ci->capsmin; data["capspercent"] >> ci->capspercent; data["floodlines"] >> ci->floodlines; @@ -386,6 +405,7 @@ void ChannelInfo::unserialize(serialized_data &data) Anope::string buf; data["memoignores"] >> buf; spacesepstream sep(buf); + ci->memos.ignores.clear(); while (sep.GetToken(buf)) ci->memos.ignores.push_back(buf); } |