diff options
| author | rburchell <rburchell@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-02-15 22:29:18 +0000 |
|---|---|---|
| committer | rburchell <rburchell@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-02-15 22:29:18 +0000 |
| commit | d1611b640bcd27e1a91a99ef32127bc722e50a36 (patch) | |
| tree | b18c77b07b74b70f5613b106aa2a81baa6227f35 | |
| parent | 0e5b71923b25d908167e7ef9d07c6c217827e901 (diff) | |
Remove User::na, use User::nc everywhere. Will probably break everything, but opens the door to decoupling NC from NA, and means commands can now be run without bothering about changinc nick :)
More tweaking for na/nc usage.
It compiles, but it's still a work in progress.
Again, this compiles, but I *bet* there's no chance in hell it'll work. :)
Slightly better.
Set User::nc correctly.
Fix crash with unregistered nicks in core and ns_access.
Fix glist to work when you're not on that particular nick.
Fix ns_set to not crash and burn horribly.
Fix ns_set and ns_logout to not do bad things.
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2076 5417fbe8-f217-4b02-8779-1006273d7864
66 files changed, 427 insertions, 677 deletions
diff --git a/include/account.h b/include/account.h index 40b7146c2..6c49bbd58 100644 --- a/include/account.h +++ b/include/account.h @@ -34,7 +34,6 @@ class NickAlias time_registered = last_seen = 0; status = 0; nc = NULL; - u = NULL; } NickAlias *next, *prev; @@ -46,9 +45,6 @@ class NickAlias time_t last_seen; /* When it was seen online for the last time */ uint16 status; /* See NS_* below */ NickCore *nc; /* I'm an alias of this */ - - /* Not saved */ - User *u; /* Current online user that has me */ }; class NickCore : public Extensible diff --git a/include/extern.h b/include/extern.h index 43adbf644..888d64721 100644 --- a/include/extern.h +++ b/include/extern.h @@ -317,7 +317,6 @@ E bool NSStrictPrivileges; E bool NSEmailReg; E bool NSModeOnID; E bool NSRestrictGetPass; -E bool NSNickTracking; E bool NSAddAccessOnReg; E int CSDefFlags; @@ -525,7 +524,9 @@ E void lang_init(); E int strftime_lang(char *buf, int size, User * u, int format, struct tm *tm); E void syntax_error(char *service, User * u, const char *command, int msgnum); E const char *getstring(NickAlias *na, int index); -E const char *getstring2(NickCore *nc, int index); +E const char *getstring(NickCore *nc, int index); +E const char *getstring(User *nc, int index); +E const char *getstring(int index); /**** log.c ****/ @@ -630,8 +631,8 @@ E const char *merge_args(int argc, const char **argv); E int match_wild(const char *pattern, const char *str) MARK_DEPRECATED; E int match_wild_nocase(const char *pattern, const char *str) MARK_DEPRECATED; E int dotime(const char *s); -E char *duration(NickAlias * na, char *buf, int bufsize, time_t seconds); -E char *expire_left(NickAlias * na, char *buf, int len, time_t expires); +E const char *duration(NickCore *nc, char *buf, int bufsize, time_t seconds); +E const char *expire_left(NickCore *nc, char *buf, int len, time_t expires); E int doValidHost(const char *host, int type); typedef int (*range_callback_t) (User * u, int num, va_list args); @@ -736,11 +737,6 @@ E NickAlias *findnick(const char *nick); E NickAlias *findnick(const std::string &nick); E NickCore *findcore(const char *nick); E void clean_ns_timeouts(NickAlias * na); -E void nsStartNickTracking(User * u); -E void nsStopNickTracking(User * u); -E int nsCheckNickTracking(User *u); - -E int group_identified(User * u, NickCore * nc); E int is_on_access(User * u, NickCore * nc); /**** operserv.c ****/ @@ -930,7 +926,7 @@ E char *TS6UPLINK; E void update_host(User * user); E User *do_nick(const char *source, const char *nick, const char *username, const char *host, - const char *server, const char *realname, time_t ts, uint32 svid, uint32 ip, const char *vhost, const char *uid); + const char *server, const char *realname, time_t ts, uint32 ip, const char *vhost, const char *uid); E void do_umode(const char *source, int ac, const char **av); E void do_quit(const char *source, int ac, const char **av); diff --git a/include/services.h b/include/services.h index 549d39ba1..6c00c959f 100644 --- a/include/services.h +++ b/include/services.h @@ -1312,10 +1312,7 @@ class IRCDProto virtual void SendSGLine(const char *, const char *) { } virtual void SendBanDel(const char *, const char *) { } virtual void SendSVSModeChan(const char *, const char *, const char *) { } - virtual void SendSVID(const char *, time_t) { } virtual void SendUnregisteredNick(User *) { } - virtual void SendSVID2(User *, const char *) { } - virtual void SendSVID3(User *, const char *) { } virtual void SendCTCP(BotInfo *bi, const char *dest, const char *fmt, ...); virtual void SendSVSJoin(const char *, const char *, const char *, const char *) { } virtual void SendSVSPart(const char *, const char *, const char *) { } diff --git a/include/users.h b/include/users.h index 17dfccd8d..fd05b5c17 100644 --- a/include/users.h +++ b/include/users.h @@ -37,14 +37,11 @@ public: // XXX: exposing a tiny bit too much std::string chost; /* User's cloaked hostname */ char *realname; /* Realname */ Server *server; /* Server user is connected to */ - char *nickTrack; /* Nick Tracking */ time_t timestamp; /* Timestamp of the nick */ time_t my_signon; /* When did _we_ see the user? */ - time_t svid; /* Services ID */ uint32 mode; /* See below */ NickCore *nc; - NickAlias *na; int isSuperAdmin; /* is SuperAdmin on or off? */ diff --git a/src/botserv.c b/src/botserv.c index 96b017bcd..1f0a13421 100644 --- a/src/botserv.c +++ b/src/botserv.c @@ -803,7 +803,7 @@ static void bot_kick(ChannelInfo * ci, User * u, int message, ...) return; va_start(args, message); - fmt = getstring(u->na, message); + fmt = getstring(u, message); if (!fmt) return; vsnprintf(buf, sizeof(buf), fmt, args); @@ -837,7 +837,7 @@ void bot_raw_ban(User * requester, ChannelInfo * ci, char *nick, if (ircd->protectedumode) { if (is_protected(u) && (requester != u)) { ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", - getstring2(NULL, PERMISSION_DENIED)); + getstring(PERMISSION_DENIED)); return; } } @@ -849,7 +849,7 @@ void bot_raw_ban(User * requester, ChannelInfo * ci, char *nick, if (ircd->except) { if (is_excepted(ci, u) == 1) { ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", - getstring2(NULL, BOT_EXCEPT)); + getstring(BOT_EXCEPT)); return; } } @@ -913,7 +913,7 @@ void bot_raw_kick(User * requester, ChannelInfo * ci, char *nick, if (ircd->protectedumode) { if (is_protected(u) && (requester != u)) { ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", - getstring2(NULL, PERMISSION_DENIED)); + getstring(PERMISSION_DENIED)); return; } } @@ -967,7 +967,7 @@ void bot_raw_mode(User * requester, ChannelInfo * ci, const char *mode, if (ircd->protectedumode) { if (is_protected(u) && *mode == '-' && (requester != u)) { ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", - getstring2(NULL, PERMISSION_DENIED)); + getstring(PERMISSION_DENIED)); return; } } diff --git a/src/channels.c b/src/channels.c index 85f17785e..6e52139f7 100644 --- a/src/channels.c +++ b/src/channels.c @@ -499,7 +499,7 @@ User *nc_on_chan(Channel * c, NickCore * nc) return NULL; for (u = c->users; u; u = u->next) { - if (u->user->na && u->user->na->nc == nc + if (u->user->nc == nc && nick_recognized(u->user)) return u->user; } @@ -1390,7 +1390,7 @@ void chan_set_correct_modes(User * user, Channel * c, int give_modes) * to receive modes. I wonder who added that... *looks at Rob* ;) -GD */ if (give_modes && (get_ignore(user->nick) == NULL) - && (!user->na || !(user->na->nc->flags & NI_AUTOOP))) { + && (!user->nc || !(user->nc->flags & NI_AUTOOP))) { if (ircd->owner && is_founder(user, ci)) add_modes |= CUS_OWNER; else if ((ircd->protect || ircd->admin) @@ -1569,7 +1569,7 @@ void chan_adduser2(User * user, Channel * c) if (c->usercount == BSMinUsers) bot_join(c->ci); if (c->usercount >= BSMinUsers && (c->ci->botflags & BS_GREET) - && user->na && user->na->nc->greet + && user->nc && user->nc->greet && check_access(user, c->ci, CA_GREET)) { /* Only display the greet if the main uplink we're connected * to has synced, or we'll get greet-floods when the net @@ -1577,7 +1577,7 @@ void chan_adduser2(User * user, Channel * c) */ if (is_sync(user->server)) { ircdproto->SendPrivmsg(c->ci->bi, c->name, "[%s] %s", - user->na->nick, user->na->nc->greet); + user->nc->display, user->nc->greet); c->ci->bi->lastmsg = time(NULL); } } diff --git a/src/chanserv.c b/src/chanserv.c index 79824a008..393a5831b 100644 --- a/src/chanserv.c +++ b/src/chanserv.c @@ -1142,13 +1142,13 @@ int check_kick(User * user, const char *chan, time_t chants) if (ci->flags & CI_SUSPENDED || ci->flags & CI_FORBIDDEN) { get_idealban(ci, user, mask, sizeof(mask)); - reason = ci->forbidreason ? ci->forbidreason : getstring(user->na, CHAN_MAY_NOT_BE_USED); + reason = ci->forbidreason ? ci->forbidreason : getstring(user, CHAN_MAY_NOT_BE_USED); set_modes = true; goto kick; } if (nick_recognized(user)) - nc = user->na->nc; + nc = user->nc; else nc = NULL; @@ -1188,7 +1188,7 @@ int check_kick(User * user, const char *chan, time_t chants) if (check_access(user, ci, CA_NOJOIN)) { get_idealban(ci, user, mask, sizeof(mask)); - reason = getstring(user->na, CHAN_NOT_ALLOWED_TO_JOIN); + reason = getstring(user, CHAN_NOT_ALLOWED_TO_JOIN); goto kick; } @@ -1846,7 +1846,7 @@ int is_founder(User * user, ChannelInfo * ci) return 1; } - if (user->na && user->na->nc == ci->founder) { + if (user->nc && user->nc == ci->founder) { if ((nick_identified(user) || (nick_recognized(user) && !(ci->flags & CI_SECURE)))) return 1; @@ -1864,7 +1864,7 @@ int is_real_founder(User * user, ChannelInfo * ci) return 1; } - if (user->na && user->na->nc == ci->founder) { + if (user->nc && user->nc == ci->founder) { if ((nick_identified(user) || (nick_recognized(user) && !(ci->flags & CI_SECURE)))) return 1; @@ -1927,12 +1927,12 @@ int get_access(User * user, ChannelInfo * ci) if (is_founder(user, ci)) return ACCESS_FOUNDER; - if (!user->na) + if (!user->nc) return 0; if (nick_identified(user) || (nick_recognized(user) && !(ci->flags & CI_SECURE))) - if ((access = get_access_entry(user->na->nc, ci))) + if ((access = get_access_entry(user->nc, ci))) return access->level; if (nick_identified(user)) @@ -1947,12 +1947,12 @@ void update_cs_lastseen(User * user, ChannelInfo * ci) { ChanAccess *access; - if (!ci || !user || !user->na) + if (!ci || !user || !user->nc) return; if (is_founder(user, ci) || nick_identified(user) || (nick_recognized(user) && !(ci->flags & CI_SECURE))) - if ((access = get_access_entry(user->na->nc, ci))) + if ((access = get_access_entry(user->nc, ci))) access->last_seen = time(NULL); } diff --git a/src/commands.c b/src/commands.c index 9501640c7..018ca6897 100644 --- a/src/commands.c +++ b/src/commands.c @@ -77,8 +77,7 @@ void mod_run_cmd(char *service, User * u, CommandHash * cmdTable[], const char * // Command requires registered users only if (!nick_identified(u)) { - // XXX: we should have a new string for this - notice_lang(service, u, ACCESS_DENIED); + notice_lang(service, u, NICK_IDENTIFY_REQUIRED, service); alog("Access denied for unregistered user %s with service %s and command %s", u->nick, service, cmd); return; } diff --git a/src/core/bs_info.c b/src/core/bs_info.c index 4f65d990d..ff7c2c932 100644 --- a/src/core/bs_info.c +++ b/src/core/bs_info.c @@ -61,7 +61,7 @@ class CommandBSInfo : public Command int need_comma = 0; char buf[BUFSIZE], *end; - const char *commastr = getstring(u->na, COMMA_SPACE); + const char *commastr = getstring(u, COMMA_SPACE); if ((bi = findbot(query))) { @@ -74,7 +74,7 @@ class CommandBSInfo : public Command strftime_lang(buf, sizeof(buf), u, STRFTIME_DATE_TIME_FORMAT, tm); notice_lang(s_BotServ, u, BOT_INFO_BOT_CREATED, buf); notice_lang(s_BotServ, u, BOT_INFO_BOT_OPTIONS, - getstring(u->na, + getstring(u, (bi-> flags & BI_PRIVATE) ? BOT_INFO_OPT_PRIVATE : BOT_INFO_OPT_NONE)); @@ -104,137 +104,137 @@ class CommandBSInfo : public Command if (ci->botflags & BS_KICK_BADWORDS) { if (ci->ttb[TTB_BADWORDS]) notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BADWORDS_BAN, - getstring(u->na, BOT_INFO_ACTIVE), + getstring(u, BOT_INFO_ACTIVE), ci->ttb[TTB_BADWORDS]); else notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BADWORDS, - getstring(u->na, BOT_INFO_ACTIVE)); + getstring(u, BOT_INFO_ACTIVE)); } else notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BADWORDS, - getstring(u->na, BOT_INFO_INACTIVE)); + getstring(u, BOT_INFO_INACTIVE)); if (ci->botflags & BS_KICK_BOLDS) { if (ci->ttb[TTB_BOLDS]) notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BOLDS_BAN, - getstring(u->na, BOT_INFO_ACTIVE), + getstring(u, BOT_INFO_ACTIVE), ci->ttb[TTB_BOLDS]); else notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BOLDS, - getstring(u->na, BOT_INFO_ACTIVE)); + getstring(u, BOT_INFO_ACTIVE)); } else notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BOLDS, - getstring(u->na, BOT_INFO_INACTIVE)); + getstring(u, BOT_INFO_INACTIVE)); if (ci->botflags & BS_KICK_CAPS) { if (ci->ttb[TTB_CAPS]) notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_CAPS_BAN, - getstring(u->na, BOT_INFO_ACTIVE), + getstring(u, BOT_INFO_ACTIVE), ci->ttb[TTB_CAPS], ci->capsmin, ci->capspercent); else notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_CAPS_ON, - getstring(u->na, BOT_INFO_ACTIVE), ci->capsmin, + getstring(u, BOT_INFO_ACTIVE), ci->capsmin, ci->capspercent); } else notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_CAPS_OFF, - getstring(u->na, BOT_INFO_INACTIVE)); + getstring(u, BOT_INFO_INACTIVE)); if (ci->botflags & BS_KICK_COLORS) { if (ci->ttb[TTB_COLORS]) notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_COLORS_BAN, - getstring(u->na, BOT_INFO_ACTIVE), + getstring(u, BOT_INFO_ACTIVE), ci->ttb[TTB_COLORS]); else notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_COLORS, - getstring(u->na, BOT_INFO_ACTIVE)); + getstring(u, BOT_INFO_ACTIVE)); } else notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_COLORS, - getstring(u->na, BOT_INFO_INACTIVE)); + getstring(u, BOT_INFO_INACTIVE)); if (ci->botflags & BS_KICK_FLOOD) { if (ci->ttb[TTB_FLOOD]) notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_FLOOD_BAN, - getstring(u->na, BOT_INFO_ACTIVE), + getstring(u, BOT_INFO_ACTIVE), ci->ttb[TTB_FLOOD], ci->floodlines, ci->floodsecs); else notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_FLOOD_ON, - getstring(u->na, BOT_INFO_ACTIVE), + getstring(u, BOT_INFO_ACTIVE), ci->floodlines, ci->floodsecs); } else notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_FLOOD_OFF, - getstring(u->na, BOT_INFO_INACTIVE)); + getstring(u, BOT_INFO_INACTIVE)); if (ci->botflags & BS_KICK_REPEAT) { if (ci->ttb[TTB_REPEAT]) notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REPEAT_BAN, - getstring(u->na, BOT_INFO_ACTIVE), + getstring(u, BOT_INFO_ACTIVE), ci->ttb[TTB_REPEAT], ci->repeattimes); else notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REPEAT_ON, - getstring(u->na, BOT_INFO_ACTIVE), + getstring(u, BOT_INFO_ACTIVE), ci->repeattimes); } else notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REPEAT_OFF, - getstring(u->na, BOT_INFO_INACTIVE)); + getstring(u, BOT_INFO_INACTIVE)); if (ci->botflags & BS_KICK_REVERSES) { if (ci->ttb[TTB_REVERSES]) notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REVERSES_BAN, - getstring(u->na, BOT_INFO_ACTIVE), + getstring(u, BOT_INFO_ACTIVE), ci->ttb[TTB_REVERSES]); else notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REVERSES, - getstring(u->na, BOT_INFO_ACTIVE)); + getstring(u, BOT_INFO_ACTIVE)); } else notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REVERSES, - getstring(u->na, BOT_INFO_INACTIVE)); + getstring(u, BOT_INFO_INACTIVE)); if (ci->botflags & BS_KICK_UNDERLINES) { if (ci->ttb[TTB_UNDERLINES]) notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_UNDERLINES_BAN, - getstring(u->na, BOT_INFO_ACTIVE), + getstring(u, BOT_INFO_ACTIVE), ci->ttb[TTB_UNDERLINES]); else notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_UNDERLINES, - getstring(u->na, BOT_INFO_ACTIVE)); + getstring(u, BOT_INFO_ACTIVE)); } else notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_UNDERLINES, - getstring(u->na, BOT_INFO_INACTIVE)); + getstring(u, BOT_INFO_INACTIVE)); end = buf; *end = 0; if (ci->botflags & BS_DONTKICKOPS) { end += snprintf(end, sizeof(buf) - (end - buf), "%s", - getstring(u->na, BOT_INFO_OPT_DONTKICKOPS)); + getstring(u, BOT_INFO_OPT_DONTKICKOPS)); need_comma = 1; } if (ci->botflags & BS_DONTKICKVOICES) { end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", need_comma ? commastr : "", - getstring(u->na, BOT_INFO_OPT_DONTKICKVOICES)); + getstring(u, BOT_INFO_OPT_DONTKICKVOICES)); need_comma = 1; } if (ci->botflags & BS_FANTASY) { end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", need_comma ? commastr : "", - getstring(u->na, BOT_INFO_OPT_FANTASY)); + getstring(u, BOT_INFO_OPT_FANTASY)); need_comma = 1; } if (ci->botflags & BS_GREET) { end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", need_comma ? commastr : "", - getstring(u->na, BOT_INFO_OPT_GREET)); + getstring(u, BOT_INFO_OPT_GREET)); need_comma = 1; } if (ci->botflags & BS_NOBOT) { end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", need_comma ? commastr : "", - getstring(u->na, BOT_INFO_OPT_NOBOT)); + getstring(u, BOT_INFO_OPT_NOBOT)); need_comma = 1; } if (ci->botflags & BS_SYMBIOSIS) { end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", need_comma ? commastr : "", - getstring(u->na, BOT_INFO_OPT_SYMBIOSIS)); + getstring(u, BOT_INFO_OPT_SYMBIOSIS)); need_comma = 1; } notice_lang(s_BotServ, u, BOT_INFO_CHAN_OPTIONS, - *buf ? buf : getstring(u->na, BOT_INFO_OPT_NONE)); + *buf ? buf : getstring(u, BOT_INFO_OPT_NONE)); } else notice_lang(s_BotServ, u, BOT_INFO_NOT_FOUND, query); diff --git a/src/core/bs_kick.c b/src/core/bs_kick.c index 87ef4111a..53485f011 100644 --- a/src/core/bs_kick.c +++ b/src/core/bs_kick.c @@ -44,7 +44,7 @@ class CommandBSKick : public Command notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan); else if (ci->flags & CI_FORBIDDEN) notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan); - else if (!check_access(u, ci, CA_SET) && !u->na->nc->HasCommand("botserv/administration")) + else if (!check_access(u, ci, CA_SET) && !u->nc->HasCommand("botserv/administration")) notice_lang(s_BotServ, u, ACCESS_DENIED); else if (!ci->bi) notice_help(s_BotServ, u, BOT_NOT_ASSIGNED); diff --git a/src/core/cs_akick.c b/src/core/cs_akick.c index 4bd2b10bd..a0efdc067 100644 --- a/src/core/cs_akick.c +++ b/ |
