diff options
Diffstat (limited to 'modules/core')
| -rw-r--r-- | modules/core/cs_akick.cpp | 4 | ||||
| -rw-r--r-- | modules/core/cs_drop.cpp | 2 | ||||
| -rw-r--r-- | modules/core/cs_info.cpp | 3 | ||||
| -rw-r--r-- | modules/core/cs_main.cpp | 7 | ||||
| -rw-r--r-- | modules/core/cs_register.cpp | 3 | ||||
| -rw-r--r-- | modules/core/cs_set_founder.cpp | 11 | ||||
| -rw-r--r-- | modules/core/cs_set_successor.cpp | 4 | ||||
| -rw-r--r-- | modules/core/db_mysql.cpp | 12 | ||||
| -rw-r--r-- | modules/core/db_mysql_live.cpp | 2 | ||||
| -rw-r--r-- | modules/core/db_plain.cpp | 18 |
10 files changed, 22 insertions, 44 deletions
diff --git a/modules/core/cs_akick.cpp b/modules/core/cs_akick.cpp index 149e782a9..1b629a83b 100644 --- a/modules/core/cs_akick.cpp +++ b/modules/core/cs_akick.cpp @@ -203,7 +203,7 @@ class CommandCSAKick : public Command { ChanAccess *nc_access = ci->GetAccess(nc), *u_access = ci->GetAccess(u); int16 nc_level = nc_access ? nc_access->level : 0, u_level = u_access ? u_access->level : 0; - if (nc == ci->founder || nc_level >= u_level) + if (nc == ci->GetFounder() || nc_level >= u_level) { source.Reply(_(ACCESS_DENIED)); return; @@ -236,7 +236,7 @@ class CommandCSAKick : public Command ChanAccess *na_access = ci->GetAccess(na->nc), *u_access = ci->GetAccess(u); int16 na_level = na_access ? na_access->level : 0, u_level = u_access ? u_access->level : 0; - if (na->nc && (na->nc == ci->founder || na_level >= u_level)) + if (na->nc && (na->nc == ci->GetFounder() || na_level >= u_level)) { Anope::string buf = na->nick + "!" + na->last_usermask; if (Anope::Match(buf, mask)) diff --git a/modules/core/cs_drop.cpp b/modules/core/cs_drop.cpp index a13006196..fc6949597 100644 --- a/modules/core/cs_drop.cpp +++ b/modules/core/cs_drop.cpp @@ -54,7 +54,7 @@ class CommandCSDrop : public Command ci->c->RemoveMode(NULL, CMODE_REGISTERED, "", false); bool override = (ci->HasFlag(CI_SECUREFOUNDER) ? !IsFounder(u, ci) : !check_access(u, ci, CA_FOUNDER)); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "founder: " << (ci->founder ? ci->founder->display : "none"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "founder: " << (ci->GetFounder() ? ci->GetFounder()->display : "none"); delete ci; diff --git a/modules/core/cs_info.cpp b/modules/core/cs_info.cpp index ba26a8c77..4b5ade172 100644 --- a/modules/core/cs_info.cpp +++ b/modules/core/cs_info.cpp @@ -50,7 +50,8 @@ class CommandCSInfo : public Command show_all = true; source.Reply(_(CHAN_INFO_HEADER), chan.c_str()); - source.Reply(_(" Founder: %s"), ci->founder->display.c_str()); + if (ci->GetFounder()) + source.Reply(_(" Founder: %s"), ci->GetFounder()->display.c_str()); if (show_all && ci->successor) source.Reply(_(" Successor: %s"), ci->successor->display.c_str()); diff --git a/modules/core/cs_main.cpp b/modules/core/cs_main.cpp index 766f696a8..9d1664afb 100644 --- a/modules/core/cs_main.cpp +++ b/modules/core/cs_main.cpp @@ -123,7 +123,7 @@ class ExpireCallback : public CallBack if (ci->HasFlag(CI_SUSPENDED)) extra = "suspended "; - Log(LOG_NORMAL, "chanserv/expire", ChanServ) << "Expiring " << extra << "channel " << ci->name << " (founder: " << (ci->founder ? ci->founder->display : "(none)") << ")"; + Log(LOG_NORMAL, "chanserv/expire", ChanServ) << "Expiring " << extra << "channel " << ci->name << " (founder: " << (ci->GetFounder() ? ci->GetFounder()->display : "(none)") << ")"; FOREACH_MOD(I_OnChanExpire, OnChanExpire(ci)); delete ci; } @@ -177,7 +177,7 @@ class ChanServCore : public Module ChannelInfo *ci = it->second; ++it; - if (ci->founder == nc) + if (ci->GetFounder() == nc) { NickCore *newowner = NULL; if (ci->successor && (ci->successor->IsServicesOper() || !Config->CSMaxReg || ci->successor->channelcount < Config->CSMaxReg)) @@ -201,9 +201,8 @@ class ChanServCore : public Module if (newowner) { Log(LOG_NORMAL, "chanserv/expire") << "Transferring foundership of " << ci->name << " from deleted nick " << nc->display << " to " << newowner->display; - ci->founder = newowner; + ci->SetFounder(newowner); ci->successor = NULL; - ++newowner->channelcount; } else { diff --git a/modules/core/cs_register.cpp b/modules/core/cs_register.cpp index 9674ff126..8e150540b 100644 --- a/modules/core/cs_register.cpp +++ b/modules/core/cs_register.cpp @@ -51,7 +51,7 @@ class CommandCSRegister : public Command else { ci = new ChannelInfo(chan); - ci->founder = u->Account(); + ci->SetFounder(u->Account()); ci->desc = chdesc; if (c && !c->topic.empty()) @@ -64,7 +64,6 @@ class CommandCSRegister : public Command ci->last_topic_setter = Config->s_ChanServ; ci->bi = NULL; - ++ci->founder->channelcount; Log(LOG_COMMAND, u, this, ci); source.Reply(_("Channel \002%s\002 registered under your nickname: %s"), chan.c_str(), u->nick.c_str()); diff --git a/modules/core/cs_set_founder.cpp b/modules/core/cs_set_founder.cpp index 88ddabd86..a71794756 100644 --- a/modules/core/cs_set_founder.cpp +++ b/modules/core/cs_set_founder.cpp @@ -36,7 +36,6 @@ class CommandCSSetFounder : public Command } NickAlias *na = findnick(params[1]); - NickCore *nc, *nc0 = ci->founder; if (!na) { @@ -44,7 +43,7 @@ class CommandCSSetFounder : public Command return MOD_CONT; } - nc = na->nc; + NickCore *nc = na->nc; if (Config->CSMaxReg && nc->channelcount >= Config->CSMaxReg && !u->HasPriv("chanserv/no-register-limit")) { source.Reply(_("\002%s\002 has too many channels registered."), na->nick.c_str()); @@ -53,13 +52,7 @@ class CommandCSSetFounder : public Command Log(!this->permission.empty() ? LOG_ADMIN : LOG_COMMAND, u, this, ci) << "to change the founder to " << nc->display; - /* Founder and successor must not be the same group */ - if (nc == ci->successor) - ci->successor = NULL; - - --nc0->channelcount; - ci->founder = nc; - ++nc->channelcount; + ci->SetFounder(nc); source.Reply(_("Founder of %s changed to \002%s\002."), ci->name.c_str(), na->nick.c_str()); diff --git a/modules/core/cs_set_successor.cpp b/modules/core/cs_set_successor.cpp index 25ee2b098..f141398a3 100644 --- a/modules/core/cs_set_successor.cpp +++ b/modules/core/cs_set_successor.cpp @@ -46,9 +46,9 @@ class CommandCSSetSuccessor : public Command source.Reply(_(NICK_X_NOT_REGISTERED), params[1].c_str()); return MOD_CONT; } - if (na->nc == ci->founder) + if (na->nc == ci->GetFounder()) { - source.Reply(_("%s cannot be the successor on channel %s because he is its founder."), na->nick.c_str(), ci->name.c_str()); + source.Reply(_("%s cannot be the successor on channel %s they are the founder."), na->nick.c_str(), ci->name.c_str()); return MOD_CONT; } nc = na->nc; diff --git a/modules/core/db_mysql.cpp b/modules/core/db_mysql.cpp index 746dd8f25..03a4f9cd9 100644 --- a/modules/core/db_mysql.cpp +++ b/modules/core/db_mysql.cpp @@ -196,7 +196,6 @@ class DBMySQL : public Module nc->FromString(flags); nc->language = r.Get(i, "language"); - nc->channelcount = r.Get(i, "channelcount").is_number_only() ? convertTo<int>(r.Get(i, "channelcount")) : 0; nc->memos.memomax = r.Get(i, "memomax").is_number_only() ? convertTo<int16>(r.Get(i, "memomax")) : 20; } @@ -339,7 +338,7 @@ class DBMySQL : public Module } ChannelInfo *ci = new ChannelInfo(r.Get(i, "name")); - ci->founder = nc; + ci->SetFounder(nc); if (!r.Get(i, "successor").empty()) ci->successor = findcore(r.Get(i, "successor")); ci->desc = r.Get(i, "descr"); @@ -760,10 +759,10 @@ class DBMySQL : public Module return; if (!u->HasPriv("chanserv/set") && check_access(u, ci, CA_SET)) return; - if (params[1].equals_ci("FOUNDER") && ci->founder) + if (params[1].equals_ci("FOUNDER")) { SQLQuery query("UPDATE `anope_cs_info` SET `founder` = @founder WHERE `name` = @name"); - query.setValue("founder", ci->founder->display); + query.setValue("founder", ci->GetFounder() ? ci->GetFounder()->display : ""); query.setValue("name", ci->name); this->RunQuery(query); } @@ -976,14 +975,13 @@ class DBMySQL : public Module void InsertCore(NickCore *nc) { - SQLQuery query("INSERT INTO `anope_ns_core` (display, pass, email, greet, flags, language, channelcount, memomax) VALUES(@display, @pass, @email, @greet, @flags, @language, @channelcount, @memomax) ON DUPLICATE KEY UPDATE pass=VALUES(pass), email=VALUES(email), greet=VALUES(greet), flags=VALUES(flags), language=VALUES(language), channelcount=VALUES(channelcount), memomax=VALUES(memomax)"); + SQLQuery query("INSERT INTO `anope_ns_core` (display, pass, email, greet, flags, language, memomax) VALUES(@display, @pass, @email, @greet, @flags, @language, @memomax) ON DUPLICATE KEY UPDATE pass=VALUES(pass), email=VALUES(email), greet=VALUES(greet), flags=VALUES(flags), language=VALUES(language), memomax=VALUES(memomax)"); query.setValue("display", nc->display); query.setValue("pass", nc->pass); query.setValue("email", nc->email); query.setValue("greet", nc->greet); query.setValue("flags", ToString(nc->ToString())); query.setValue("language", nc->language); - query.setValue("channelcount", nc->channelcount); query.setValue("memomax", nc->memos.memomax); this->RunQuery(query); } @@ -1097,7 +1095,7 @@ class DBMySQL : public Module { SQLQuery query("INSERT INTO `anope_cs_info` (name, founder, successor, descr, time_registered, last_used, last_topic, last_topic_setter, last_topic_time, flags, bantype, memomax, botnick, botflags, capsmin, capspercent, floodlines, floodsecs, repeattimes) VALUES(@name, @founder, @successor, @descr, @time_registered, @last_used, @last_topic_text, @last_topic_setter, @last_topic_time, @flags, @bantype, @memomax, @botnick, @botflags, @capsmin, @capspercent, @floodlines, @floodsecs, @repeattimes) ON DUPLICATE KEY UPDATE founder=VALUES(founder), successor=VALUES(successor), descr=VALUES(descr), time_registered=VALUES(time_registered), last_used=VALUES(last_used), last_topic=VALUES(last_topic), last_topic_setter=VALUES(last_topic_setter), last_topic_time=VALUES(last_topic_time), flags=VALUES(flags), bantype=VALUES(bantype), memomax=VALUES(memomax), botnick=VALUES(botnick), botflags=VALUES(botflags), capsmin=VALUES(capsmin), capspercent=VALUES(capspercent), floodlines=VALUES(floodlines), floodsecs=VALUES(floodsecs), repeattimes=VALUES(repeattimes)"); query.setValue("name", ci->name); - query.setValue("founder", ci->founder ? ci->founder->display : ""); + query.setValue("founder", ci->GetFounder() ? ci->GetFounder()->display : ""); query.setValue("successor", ci->successor ? ci->successor->display : ""); query.setValue("descr", ci->desc); query.setValue("time_registered", ci->time_registered); diff --git a/modules/core/db_mysql_live.cpp b/modules/core/db_mysql_live.cpp index 4c7bd4f0b..1073f1b99 100644 --- a/modules/core/db_mysql_live.cpp +++ b/modules/core/db_mysql_live.cpp @@ -40,7 +40,7 @@ static void ChanInfoUpdate(const SQLResult &res) ChannelInfo *ci = cs_findchan(res.Get(0, "name")); if (!ci) ci = new ChannelInfo(res.Get(0, "name")); - ci->founder = findcore(res.Get(0, "founder")); + ci->SetFounder(findcore(res.Get(0, "founder"))); ci->successor = findcore(res.Get(0, "successor")); ci->desc = res.Get(0, "descr"); ci->time_registered = convertTo<time_t>(res.Get(0, "time_registered")); diff --git a/modules/core/db_plain.cpp b/modules/core/db_plain.cpp index f194f3ae9..2396567a0 100644 --- a/modules/core/db_plain.cpp +++ b/modules/core/db_plain.cpp @@ -171,11 +171,6 @@ static void ReadDatabase(Module *m = NULL) catch (const DatabaseException &ex) { Log() << "[db_plain]: " << ex.GetReason(); - if (!ci->founder) - { - delete ci; - ci = NULL; - } } } } @@ -474,8 +469,6 @@ class DBPlain : public Module nc->language = params[0]; else if (key.equals_ci("MEMOMAX")) nc->memos.memomax = params[0].is_pos_number_only() ? convertTo<int16>(params[0]) : -1; - else if (key.equals_ci("CHANCOUNT")) - nc->channelcount = params[0].is_pos_number_only() ? convertTo<uint16>(params[0]) : 0; else if (key.equals_ci("EMAIL")) nc->email = params[0]; else if (key.equals_ci("GREET")) @@ -553,11 +546,7 @@ class DBPlain : public Module else if (key.equals_ci("MEMOMAX")) ci->memos.memomax = params[0].is_pos_number_only() ? convertTo<int16>(params[0]) : -1; else if (key.equals_ci("FOUNDER")) - { - ci->founder = findcore(params[0]); - if (!ci->founder) - throw DatabaseException("Deleting founderless channel " + ci->name + " (founder: " + params[0] + ")"); - } + ci->SetFounder(findcore(params[0])); else if (key.equals_ci("SUCCESSOR")) ci->successor = findcore(params[0]); else if (key.equals_ci("LEVELS")) @@ -716,7 +705,6 @@ class DBPlain : public Module db_buffer << "NC " << nc->display << " " << nc->pass << endl; db_buffer << "MD MEMOMAX " << nc->memos.memomax << endl; - db_buffer << "MD CHANCOUNT " << nc->channelcount << endl; if (!nc->language.empty()) db_buffer << "MD LANGUAGE " << nc->language << endl; @@ -787,8 +775,8 @@ class DBPlain : public Module db_buffer << "CH " << ci->name << " " << ci->time_registered << " " << ci->last_used << endl; db_buffer << "MD BANTYPE " << ci->bantype << endl; db_buffer << "MD MEMOMAX " << ci->memos.memomax << endl; - if (ci->founder) - db_buffer << "MD FOUNDER " << ci->founder->display << endl; + if (ci->GetFounder()) + db_buffer << "MD FOUNDER " << ci->GetFounder()->display << endl; if (ci->successor) db_buffer << "MD SUCCESSOR " << ci->successor->display << endl; if (!ci->desc.empty()) |
