From 458be36a321615c0f3004a6abde7e14d40f5da32 Mon Sep 17 00:00:00 2001 From: Adam- Date: Sun, 8 Nov 2009 20:06:21 +0000 Subject: Rewrote all of the old C style flag systems into a new Flag class which everything inherits from. This breaks reading and writing flags to the old databases (and probably many other things aswell) - Don't use it git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2636 5417fbe8-f217-4b02-8779-1006273d7864 --- include/account.h | 69 ++++++- include/bots.h | 26 ++- include/extern.h | 15 +- include/modules.h | 21 +-- include/regchannel.h | 49 ++++- include/services.h | 412 ++++++++++++++++++++++-------------------- src/bots.cpp | 30 ++- src/botserv.c | 62 +++---- src/channels.c | 47 ++--- src/chanserv.c | 97 +++++----- src/command.cpp | 16 -- src/commands.c | 4 +- src/config.c | 83 +++++---- src/core/bs_assign.c | 4 +- src/core/bs_badwords.c | 2 +- src/core/bs_botlist.c | 4 +- src/core/bs_info.c | 34 ++-- src/core/bs_kick.c | 32 ++-- src/core/bs_set.c | 28 +-- src/core/cs_access.c | 10 +- src/core/cs_akick.c | 61 +++---- src/core/cs_ban.c | 6 +- src/core/cs_drop.c | 10 +- src/core/cs_forbid.c | 2 +- src/core/cs_info.c | 37 ++-- src/core/cs_kick.c | 6 +- src/core/cs_list.c | 26 ++- src/core/cs_modes.c | 25 ++- src/core/cs_set.c | 88 ++++----- src/core/cs_suspend.c | 8 +- src/core/cs_xop.c | 4 +- src/core/hs_del.c | 2 +- src/core/hs_delall.c | 2 +- src/core/hs_set.c | 2 +- src/core/hs_setall.c | 2 +- src/core/ms_cancel.c | 2 +- src/core/ms_check.c | 4 +- src/core/ms_info.c | 28 +-- src/core/ms_list.c | 6 +- src/core/ms_read.c | 6 +- src/core/ms_set.c | 31 ++-- src/core/ns_access.c | 8 +- src/core/ns_alist.c | 8 +- src/core/ns_drop.c | 2 +- src/core/ns_forbid.c | 2 +- src/core/ns_getpass.c | 2 +- src/core/ns_ghost.c | 6 +- src/core/ns_group.c | 11 +- src/core/ns_identify.c | 6 +- src/core/ns_info.c | 20 +- src/core/ns_list.c | 38 ++-- src/core/ns_logout.c | 2 +- src/core/ns_recover.c | 6 +- src/core/ns_register.c | 5 +- src/core/ns_release.c | 8 +- src/core/ns_saset.c | 50 ++--- src/core/ns_sendpass.c | 2 +- src/core/ns_set.c | 46 +++-- src/core/ns_suspend.c | 14 +- src/core/os_jupe.c | 2 +- src/core/os_svsnick.c | 2 +- src/language.c | 2 +- src/memoserv.c | 28 +-- src/messages.c | 5 +- src/modules/cs_appendtopic.c | 2 - src/modules/cs_enforce.c | 21 ++- src/modules/ns_noop_convert.c | 2 +- src/nickalias.cpp | 1 - src/nickcore.cpp | 7 +- src/nickserv.c | 64 ++++--- src/operserv.c | 2 +- src/protocol.cpp | 2 +- src/regchannel.cpp | 19 +- src/send.c | 2 +- src/servers.c | 35 ++-- src/users.c | 18 +- 76 files changed, 994 insertions(+), 859 deletions(-) diff --git a/include/account.h b/include/account.h index 09db33955..075b15e9e 100644 --- a/include/account.h +++ b/include/account.h @@ -1,6 +1,69 @@ /* NickServ nickname structures. */ +/** Flags set on NickAliases + */ +enum NickNameFlag +{ + NS_BEGIN, + + /* Nick may not be registered or used */ + NS_FORBIDDEN, + /* Nick never expires */ + NS_NO_EXPIRE, + /* Nick is being held after a kill */ + NS_KILL_HELD, + /* SVSNICK has been sent but nick has not yet changed. + * An enforcer will be introduced when it does change. */ + NS_GUESTED, + + NS_END +}; + +/** Flags set on NickCores + */ +enum NickCoreFlag +{ + NI_BEGIN, + + /* Kill others who take this nick */ + NI_KILLPROTECT, + /* Dont recognize unless IDENTIFIED */ + NI_SECURE, + /* Use PRIVMSG instead of NOTICE */ + NI_MSG, + /* Don't allow user to change memo limit */ + NI_MEMO_HARDMAX, + /* Notify of memos at signon and un-away */ + NI_MEMO_SIGNON, + /* Notify of new memos when sent */ + NI_MEMO_RECEIVE, + /* Don't show in LIST to non-servadmins */ + NI_PRIVATE, + /* Don't show email in INFO */ + NI_HIDE_EMAIL, + /* Don't show last seen address in INFO */ + NI_HIDE_MASK, + /* Don't show last quit message in INFO */ + NI_HIDE_QUIT, + /* Kill in 20 seconds instead of in 60 */ + NI_KILL_QUICK, + /* Kill immediatly */ + NI_KILL_IMMED, + /* User gets email on memo */ + NI_MEMO_MAIL, + /* Don't show services access status */ + NI_HIDE_STATUS, + /* Nickname is suspended */ + NI_SUSPENDED, + /* Autoop nickname in channels */ + NI_AUTOOP, + /* Nick won't expire */ + NI_NOEXPIRE, + + NI_END +}; + /** XXX: this really needs to die with fire and be merged with metadata into NickCore or something. */ class NickRequest @@ -24,7 +87,7 @@ class NickRequest class NickCore; -class CoreExport NickAlias : public Extensible +class CoreExport NickAlias : public Extensible, public Flags { public: NickAlias(); @@ -36,11 +99,10 @@ class CoreExport NickAlias : public Extensible char *last_usermask; /* Last usermask */ time_t time_registered; /* When the nick was registered */ 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 */ }; -class CoreExport NickCore : public Extensible +class CoreExport NickCore : public Extensible, public Flags { public: NickCore(); @@ -53,7 +115,6 @@ class CoreExport NickCore : public Extensible char *greet; /* Greet associated to the nick */ uint32 icq; /* ICQ # associated to the nick */ char *url; /* URL associated to the nick */ - uint32 flags; /* See NI_* below */ uint16 language; /* Language selected by nickname owner (LANG_*) */ std::vector access; /* Access list, vector of strings */ MemoInfo memos; diff --git a/include/bots.h b/include/bots.h index 38ad5534d..80ac08c1f 100644 --- a/include/bots.h +++ b/include/bots.h @@ -9,10 +9,33 @@ * */ +/** Flags settable on a bot + */ +enum BotFlag +{ + BI_BEGIN, + + /* This bot can only be assigned by IRCops */ + BI_PRIVATE, + /* The following flags are used to determin what bot really is what. + * Since you *could* have ChanServ really named BotServ or something stupid, + * this keeps track of them and allows them to be renamed in the config + * at any time, even if they already exist in the database + */ + BI_CHANSERV, + BI_BOTSERV, + BI_HOSTSERV, + BI_OPERSERV, + BI_MEMOSERV, + BI_NICKSERV, + BI_GLOBAL, + + BI_END +}; struct CommandHash; -class CoreExport BotInfo +class CoreExport BotInfo : public Extensible, public Flags { public: BotInfo *next, *prev; @@ -22,7 +45,6 @@ class CoreExport BotInfo char *user; /* Its user name */ char *host; /* Its hostname */ char *real; /* Its real name */ - int16 flags; /* Bot flags -- see BI_* below */ time_t created; /* Birth date ;) */ int16 chancount; /* Number of channels that use the bot. */ /* Dynamic data */ diff --git a/include/extern.h b/include/extern.h index 821bc2190..21a4987ff 100644 --- a/include/extern.h +++ b/include/extern.h @@ -123,7 +123,7 @@ E Entry *elist_find_mask(EList *list, const char *mask); E long get_memuse(EList *list); -#define whosends(ci) ((!(ci) || !((ci)->botflags & BS_SYMBIOSIS) || !(ci)->bi || !(ci)->c || (ci)->c->usercount < BSMinUsers) ? findbot(s_ChanServ) : (ci)->bi) +#define whosends(ci) ((!(ci) || !((ci)->botflags.HasFlag(BS_SYMBIOSIS)) || !(ci)->bi || !(ci)->c || (ci)->c->usercount < BSMinUsers) ? findbot(s_ChanServ) : (ci)->bi) /**** chanserv.c ****/ @@ -257,7 +257,7 @@ E bool RestrictMail; E time_t MailDelay; E bool DontQuoteAddresses; -E int NSDefFlags; +E Flags NSDefFlags; E unsigned NSDefLanguage; E time_t NSRegDelay; E time_t NSResendDelay; @@ -280,7 +280,7 @@ E bool NSEmailReg; E bool NSModeOnID; E bool NSAddAccessOnReg; -E int CSDefFlags; +E Flags CSDefFlags; E unsigned CSMaxReg; E time_t CSExpire; E int CSDefBantype; @@ -298,7 +298,7 @@ E time_t MSSendDelay; E bool MSNotifyAll; E unsigned MSMemoReceipt; -E int BSDefFlags; +E Flags BSDefFlags; E time_t BSKeepData; E unsigned BSMinUsers; E unsigned BSBadWordsMax; @@ -720,14 +720,13 @@ E Server *serv_uplink; E uint32 uplink_capab; E CapabInfo capab_info[]; -E Server *first_server(int flags); -E Server *next_server(int flags); +E Server *first_server(ServerFlag flag); +E Server *next_server(ServerFlag flag); E int is_ulined(const char *server); E int is_sync(Server *server); -E Server *new_server(Server * uplink, const char *name, const char *desc, - uint16 flags, const char *suid); +E Server *new_server(Server * uplink, const char *name, const char *desc, ServerFlag flag, const char *suid); E Server *findserver(Server *s, const char *name); diff --git a/include/modules.h b/include/modules.h index bd128a3bc..d5fddcc44 100644 --- a/include/modules.h +++ b/include/modules.h @@ -217,7 +217,7 @@ struct ModuleLang_ { char **argv; }; -enum CommandFlags +enum CommandFlag { CFLAG_ALLOW_UNREGISTERED = 1, CFLAG_ALLOW_FORBIDDEN = 2, @@ -229,9 +229,8 @@ enum CommandFlags /** Every services command is a class, inheriting from Command. */ -class CoreExport Command +class CoreExport Command : public Flags { - int flags; public: size_t MaxParams; size_t MinParams; @@ -264,22 +263,6 @@ class CoreExport Command */ virtual void OnSyntaxError(User *u); - /** Set a certain flag on this command. - * @param flag The CommandFlag to set on this command. - */ - void SetFlag(CommandFlags flag); - - /** Remove a certain flag from this command. - * @param flag The CommandFlag to unset. - */ - void UnsetFlag(CommandFlags flag); - - /** Check whether a certain flag is set on this command. - * @param flag The CommandFlag to check. - * @return bool True if the flag is set, false else. - */ - bool HasFlag(CommandFlags flag) const; - /** Set which command permission (e.g. chanserv/forbid) is required for this command. * @param reststr The permission required to successfully execute this command */ diff --git a/include/regchannel.h b/include/regchannel.h index 73a0666ab..710437374 100644 --- a/include/regchannel.h +++ b/include/regchannel.h @@ -9,7 +9,51 @@ * */ -class CoreExport ChannelInfo : public Extensible +/** Flags used for the ChannelInfo class + */ +enum ChannelInfoFlag +{ + CI_BEGIN, + + /* ChanServ is currently holding the channel */ + CI_INHABIT, + /* Retain the topic even after the channel is emptied */ + CI_KEEPTOPIC, + /* Don't allow non-authorized users to be opped */ + CI_SECUREOPS, + /* Hide channel from ChanServ LIST command */ + CI_PRIVATE, + /* Topic can only be changed by SET TOPIC */ + CI_TOPICLOCK, + /* Only users on the access list may join */ + CI_RESTRICTED, + /* Don't allow ChanServ and BotServ commands to do bad things to users with higher access levels */ + CI_PEACE, + /* Don't allow any privileges unless a user is IDENTIFIED with NickServ */ + CI_SECURE, + /* Don't allow the channel to be registered or used */ + CI_FORBIDDEN, + /* Channel does not expire */ + CI_NO_EXPIRE, + /* Channel memo limit may not be changed */ + CI_MEMO_HARDMAX, + /* Send notice to channel on use of OP/DEOP */ + CI_OPNOTICE, + /* Stricter control of channel founder status */ + CI_SECUREFOUNDER, + /* Sign kicks with the user who did the kick */ + CI_SIGNKICK, + /* Sign kicks if level is < than the one defined by the SIGNKIGK level */ + CI_SIGNKICK_LEVEL, + /* Uses XOP */ + CI_XOP, + /* Channel is suspended */ + CI_SUSPENDED, + + CI_END +}; + +class CoreExport ChannelInfo : public Extensible, public Flags { private: std::map Params; /* Map of parameters by mode name */ @@ -36,7 +80,6 @@ class CoreExport ChannelInfo : public Extensible char last_topic_setter[NICKMAX]; /* Who set the last topic */ time_t last_topic_time; /* When the last topic was set */ - uint32 flags; /* See below */ char *forbidby; char *forbidreason; @@ -53,7 +96,7 @@ class CoreExport ChannelInfo : public Extensible /* For BotServ */ BotInfo *bi; /* Bot used on this channel */ - uint32 botflags; /* BS_* below */ + Flags botflags; int16 *ttb; /* Times to ban for each kicker */ uint16 bwcount; diff --git a/include/services.h b/include/services.h index 738c4b283..1680d4d1a 100644 --- a/include/services.h +++ b/include/services.h @@ -418,18 +418,65 @@ class CoreExport Extensible }; +/** Class with the ability to keep flags on items, they should extend from this + * where T is an enum. + */ +template +class CoreExport Flags +{ + protected: + std::bitset<128> Flag_Values; + + public: + /** Add a flag to this item + * @param Value The flag + */ + void SetFlag(T Value) + { + Flag_Values[(size_t)Value] = true; + } + + /** Remove a flag from this item + * @param Value The flag + */ + void UnsetFlag(T Value) + { + Flag_Values[(size_t)Value] = false; + } + + /** Check if this item has a flag + * @param Value The flag + * @return true or false + */ + const bool HasFlag(T Value) const + { + return Flag_Values[(size_t)Value]; + } + + /** Check how many flags are set + * @return The number of flags set + */ + const size_t FlagCount() const + { + return Flag_Values.count(); + } + + /** Unset all of the flags + */ + void ClearFlags() + { + Flag_Values.reset(); + } +}; + /*************************************************************************/ /* forward declarations, mostly used by older code */ class User; class ChannelInfo; class Channel; +class EList; -typedef struct server_ Server; -typedef struct c_elist EList; -typedef struct c_elist_entry Entry; -typedef struct memo_ Memo; -typedef struct badword_ BadWord; typedef struct bandata_ BanData; typedef struct userdata_ UserData; typedef struct mailinfo_ MailInfo; @@ -584,12 +631,24 @@ struct ircdcapab_ { /*************************************************************************/ +/** Memo Flags + */ +enum MemoFlag +{ + /* Memo is unread */ + MF_UNREAD, + /* SEnder requests a receipt */ + MF_RECEIPT, + /* Memo is a notification of receipt */ + MF_NOTIFYS +}; + /* Memo info structures. Since both nicknames and channels can have memos, * we encapsulate memo data in a MemoList to make it easier to handle. */ - -struct memo_ { +class CoreExport Memo : public Flags +{ + public: uint32 number; /* Index number -- not necessarily array position! */ - uint16 flags; time_t time; /* When it was sent */ char sender[NICKMAX]; char *text; @@ -636,7 +695,8 @@ enum AccessLevel * wouldn't get very far. ;) ) */ /* Access levels for users. */ -struct ChanAccess { +struct ChanAccess +{ uint16 in_use; /* 1 if this entry is in use, else 0 */ int16 level; NickCore *nc; /* Guaranteed to be non-NULL if in use, NULL if not */ @@ -644,11 +704,22 @@ struct ChanAccess { std::string creator; }; -/* AutoKick data. */ -struct AutoKick +/** Flags for auto kick + */ +enum AutoKickFlag { - uint16 flags; + /* This auto kick entry is in use */ + AK_USED, + /* Is by nick core, not mask */ + AK_ISNICK, + /* This entry is stuck */ + AK_STUCK +}; +/* AutoKick data. */ +class CoreExport AutoKick : public Flags +{ + public: /* Only one of these can be in use */ std::string mask; NickCore *nc; @@ -658,63 +729,28 @@ struct AutoKick time_t addtime; }; -#define AK_USED 0x0001 -#define AK_ISNICK 0x0002 -#define AK_STUCK 0x0004 +/** Flags for badwords + */ +enum BadWordType +{ + /* Always kicks if the word is said */ + BW_ANY, + /* User must way the entire word */ + BW_SINGLE, + /* The word has to start with the badword */ + BW_START, + /* The word has to end with the badword */ + BW_END +}; /* Structure used to contain bad words. */ - -struct badword_ { +struct BadWord +{ uint16 in_use; char *word; - uint16 type; /* BW_* below */ + BadWordType type; }; -#define BW_ANY 0 -#define BW_SINGLE 1 -#define BW_START 2 -#define BW_END 3 - -#include "regchannel.h" - -/* Retain topic even after last person leaves channel */ -#define CI_KEEPTOPIC 0x00000001 -/* Don't allow non-authorized users to be opped */ -#define CI_SECUREOPS 0x00000002 -/* Hide channel from ChanServ LIST command */ -#define CI_PRIVATE 0x00000004 -/* Topic can only be changed by SET TOPIC */ -#define CI_TOPICLOCK 0x00000008 -/* Those not allowed ops are kickbanned */ -#define CI_RESTRICTED 0x00000010 -/* Don't allow ChanServ and BotServ commands to do bad things to bigger levels */ -#define CI_PEACE 0x00000020 -/* Don't allow any privileges unless a user is IDENTIFY'd with NickServ */ -#define CI_SECURE 0x00000040 -/* Don't allow the channel to be registered or used */ -#define CI_FORBIDDEN 0x00000080 -/* Channel password is encrypted */ -#define CI_ENCRYPTEDPW 0x00000100 -/* Channel does not expire */ -#define CI_NO_EXPIRE 0x00000200 -/* Channel memo limit may not be changed */ -#define CI_MEMO_HARDMAX 0x00000400 -/* Send notice to channel on use of OP/DEOP */ -#define CI_OPNOTICE 0x00000800 -/* Stricter control of channel founder status */ -#define CI_SECUREFOUNDER 0x00001000 -/* Always sign kicks */ -#define CI_SIGNKICK 0x00002000 -/* Sign kicks if level is < than the one defined by the SIGNKICK level */ -#define CI_SIGNKICK_LEVEL 0x00004000 -/* Use the xOP lists */ -#define CI_XOP 0x00008000 -/* Channel is suspended */ -#define CI_SUSPENDED 0x00010000 - -/* TEMPORARY - ChanServ is on the channel. */ -#define CI_INHABIT 0x80000000 - /* Indices for cmd_access[]: */ #define CA_INVITE 0 #define CA_AKICK 1 @@ -759,22 +795,37 @@ struct badword_ { #define CA_SIZE 39 /* BotServ SET flags */ -#define BS_DONTKICKOPS 0x00000001 -#define BS_DONTKICKVOICES 0x00000002 -#define BS_FANTASY 0x00000004 -#define BS_SYMBIOSIS 0x00000008 -#define BS_GREET 0x00000010 -#define BS_NOBOT 0x00000020 - -/* BotServ Kickers flags */ -#define BS_KICK_BOLDS 0x80000000 -#define BS_KICK_COLORS 0x40000000 -#define BS_KICK_REVERSES 0x20000000 -#define BS_KICK_UNDERLINES 0x10000000 -#define BS_KICK_BADWORDS 0x08000000 -#define BS_KICK_CAPS 0x04000000 -#define BS_KICK_FLOOD 0x02000000 -#define BS_KICK_REPEAT 0x01000000 +enum BotServFlag +{ + /* BotServ won't kick ops */ + BS_DONTKICKOPS, + /* BotServ won't kick voices */ + BS_DONTKICKVOICES, + /* BotServ bot accepts fantasy commands */ + BS_FANTASY, + /* BotServ bot sets modes etc instead of ChanServ */ + BS_SYMBIOSIS, + /* BotServ should show greets */ + BS_GREET, + /* BotServ bots are not allowed to be in this channel */ + BS_NOBOT, + /* BotServ kicks for bolds */ + BS_KICK_BOLDS, + /* BotServ kicks for colors */ + BS_KICK_COLORS, + /* BOtServ kicks for reverses */ + BS_KICK_REVERSES, + /* BotServ kicks for underlines */ + BS_KICK_UNDERLINES, + /* BotServ kicks for badwords */ + BS_KICK_BADWORDS, + /* BotServ kicks for caps */ + BS_KICK_CAPS, + /* BotServ kicks for flood */ + BS_KICK_FLOOD, + /* BotServ kicks for repeating */ + BS_KICK_REPEAT +}; /* Indices for TTB (Times To Ban) */ #define TTB_BOLDS 0 @@ -787,6 +838,8 @@ struct badword_ { #define TTB_REPEAT 7 #define TTB_SIZE 8 +#include "regchannel.h" + /*************************************************************************/ typedef struct { @@ -805,13 +858,30 @@ typedef enum { SSYNC_DONE = 1 /* We're in sync */ } SyncState; -struct server_ { +/** Flags set on servers + */ +enum ServerFlag +{ + SERVER_START, + + /* This server is me */ + SERVER_ISME, + /* This server was juped */ + SERVER_JUPED, + /* This server is the current uplink */ + SERVER_ISUPLINK, + + SERVER_END +}; + +class CoreExport Server : public Flags +{ + public: Server *next, *prev; char *name; /* Server name */ uint16 hops; /* Hops between services and server */ char *desc; /* Server description */ - uint16 flags; /* Some info flags, as defined below */ char *suid; /* Server Univeral ID */ SyncState sync; /* Server sync state (see above) */ @@ -819,10 +889,6 @@ struct server_ { Server *uplink; /* Server which pretends to be the uplink */ }; -#define SERVER_ISME 0x0001 -#define SERVER_JUPED 0x0002 -#define SERVER_ISUPLINK 0x0004 - /*************************************************************************/ #define CUS_OP 0x0001 @@ -866,16 +932,6 @@ struct userdata_ { int16 times; }; -/* Channelban type flags */ -#define ENTRYTYPE_NONE 0x00000000 -#define ENTRYTYPE_CIDR4 0x00000001 -#define ENTRYTYPE_NICK_WILD 0x00000004 -#define ENTRYTYPE_NICK 0x00000008 -#define ENTRYTYPE_USER_WILD 0x00000010 -#define ENTRYTYPE_USER 0x00000020 -#define ENTRYTYPE_HOST_WILD 0x00000040 -#define ENTRYTYPE_HOST 0x00000080 - struct c_userlist { struct c_userlist *next, *prev; User *user; @@ -998,19 +1054,35 @@ class CoreExport Channel : public Extensible const bool HasParam(ChannelModeName Name); }; -struct c_elist { - Entry *entries; - int32 count; +/** Channelban type flags + */ +enum EntryType +{ + ENTRYTYPE_NONE, + ENTRYTYPE_CIDR4, + ENTRYTYPE_NICK_WILD, + ENTRYTYPE_NICK, + ENTRYTYPE_USER_WILD, + ENTRYTYPE_USER, + ENTRYTYPE_HOST_WILD, + ENTRYTYPE_HOST }; -struct c_elist_entry { +class CoreExport Entry : public Flags +{ + public: Entry *next, *prev; - uint32 type; uint32 cidr_ip; /* IP mask for CIDR matching */ uint32 cidr_mask; /* Netmask for CIDR matching */ char *nick, *user, *host, *mask; }; +struct EList +{ + Entry *entries; + int32 count; +}; + /*************************************************************************/ /* Ignorance list data. */ @@ -1469,62 +1541,10 @@ enum DefconLevel DEFCON_SILENT_OPER_ONLY, DEFCON_AKILL_NEW_CLIENTS, DEFCON_NO_NEW_MEMOS - }; /*************************************************************************/ -/* Memo Flags */ -#define MF_UNREAD 0x0001 /* Memo has not yet been read */ -#define MF_RECEIPT 0x0002 /* Sender requested receipt */ -#define MF_NOTIFYS 0x0004 /* Memo is a notification of receitp */ - -/* Nickname status flags: */ -#define NS_FORBIDDEN 0x0002 /* Nick may not be registered or used */ -#define NS_NO_EXPIRE 0x0004 /* Nick never expires */ -//#define NS_IDENTIFIED 0x8000 /* User has IDENTIFY'd */ -//#define NS_RECOGNIZED 0x4000 /* ON_ACCESS true && SECURE flag not set */ -//#define NS_ON_ACCESS 0x2000 /* User comes from a known address */ -#define NS_KILL_HELD 0x1000 /* Nick is being held after a kill */ -#define NS_GUESTED 0x0100 /* SVSNICK has been sent but nick has not - * yet changed. An enforcer will be - * introduced when it does change. */ -#define NS_MASTER 0x0200 /* Was a master nick; used to import old databases */ -#define NS_TRANSGROUP 0xC000 /* Status flags that can be passed to a nick of the - same group during nick change */ -#define NS_TEMPORARY 0xFF00 /* All temporary status flags */ -/* These two are not used anymore */ -#define NS_OLD_ENCRYPTEDPW 0x0001 /* Nickname password is encrypted */ - - - - -/* Nickname setting flags: */ -#define NI_KILLPROTECT 0x00000001 /* Kill others who take this nick */ -#define NI_SECURE 0x00000002 /* Don't recognize unless IDENTIFY'd */ -#define NI_MSG 0x00000004 /* Use PRIVMSGs instead of NOTICEs */ -#define NI_MEMO_HARDMAX 0x00000008 /* Don't allow user to change memo limit */ -#define NI_MEMO_SIGNON 0x00000010 /* Notify of memos at signon and un-away */ -#define NI_MEMO_RECEIVE 0x00000020 /* Notify of new memos when sent */ -#define NI_PRIVATE 0x00000040 /* Don't show in LIST to non-servadmins */ -#define NI_HIDE_EMAIL 0x00000080 /* Don't show E-mail in INFO */ -#define NI_HIDE_MASK 0x00000100 /* Don't show last seen address in INFO */ -#define NI_HIDE_QUIT 0x00000200 /* Don't show last quit message in INFO */ -#define NI_KILL_QUICK 0x00000400 /* Kill in 20 seconds instead of 60 */ -#define NI_KILL_IMMED 0x00000800 /* Kill immediately instead of in 60 sec */ -//#define NI_SERVICES_OPER 0x00001000 /* No longer used */ -//#define NI_SERVICES_ADMIN 0x00002000 /* No longer used */ -#define NI_ENCRYPTEDPW 0x00004000 /* Nickname password is encrypted */ -//#define NI_SERVICES_ROOT 0x00008000 /* No longer used */ -#define NI_MEMO_MAIL 0x00010000 /* User gets email on memo */ -#define NI_HIDE_STATUS 0x00020000 /* Don't show services access status */ -#define NI_SUSPENDED 0x00040000 /* Nickname is suspended */ -#define NI_AUTOOP 0x00080000 /* Autoop nickname in channels */ -#define NI_NOEXPIRE 0x00100000 /* nicks in this group won't expire */ - -// Old NS_FORBIDDEN, very fucking temporary. -#define NI_FORBIDDEN 0x80000000 - /* Languages. Never insert anything in the middle of this list, or * everybody will start getting the wrong language! If you want to change * the order the languages are displayed in for NickServ HELP SET LANGUAGE, @@ -1553,54 +1573,54 @@ enum DefconLevel #define DEF_LANGUAGE LANG_EN_US -#define BI_PRIVATE 0x0001 -#define BI_CHANSERV 0x0002 -#define BI_BOTSERV 0x0004 -#define BI_HOSTSERV 0x0008 -#define BI_OPERSERV 0x0010 -#define BI_MEMOSERV 0x0020 -#define BI_NICKSERV 0x0040 -#define BI_GLOBAL 0x0080 - /*************************************************************************/ -/* CAPAB stuffs */ -typedef struct capabinfo_ CapabInfo; -struct capabinfo_ { - const char *token; - uint32 flag; +/* Types of capab + */ +enum CapabType +{ + CAPAB_BEGIN, + + CAPAB_NOQUIT, + CAPAB_TSMODE, + CAPAB_UNCONNECT, + CAPAB_NICKIP, + CAPAB_NSJOIN, + CAPAB_ZIP, + CAPAB_BURST, + CAPAB_TS3, + CAPAB_TS5, + CAPAB_DKEY, + CAPAB_DOZIP, + CAPAB_DODKEY, + CAPAB_QS, + CAPAB_SCS, + CAPAB_PT4, + CAPAB_UID, + CAPAB_KNOCK, + CAPAB_CLIENT, + CAPAB_IPV6, + CAPAB_SSJ5, + CAPAB_SN2, + CAPAB_VHOST, + CAPAB_TOKEN, + CAPAB_SSJ3, + CAPAB_NICK2, + CAPAB_VL, + CAPAB_TLKEXT, + CAPAB_CHANMODE, + CAPAB_SJB64, + CAPAB_NICKCHARS, + + CAPAB_END }; -#define CAPAB_NOQUIT 0x00000001 -#define CAPAB_TSMODE 0x00000002 -#define CAPAB_UNCONNECT 0x00000004 -#define CAPAB_NICKIP 0x00000008 -#define CAPAB_NSJOIN 0x00000010 -#define CAPAB_ZIP 0x00000020 -#define CAPAB_BURST 0x00000040 -#define CAPAB_TS3 0x00000080 -#define CAPAB_TS5 0x00000100 -#define CAPAB_DKEY 0x00000200 -#define CAPAB_DOZIP 0x00000400 -#define CAPAB_DODKEY 0x00000800 -#define CAPAB_QS 0x00001000 -#define CAPAB_SCS 0x00002000 -#define CAPAB_PT4 0x00004000 -#define CAPAB_UID 0x00008000 -#define CAPAB_KNOCK 0x00010000 -#define CAPAB_CLIENT 0x00020000 -#define CAPAB_IPV6 0x00040000 -#define CAPAB_SSJ5 0x00080000 -#define CAPAB_SN2 0x00100000 -#define CAPAB_VHOST 0x00200000 -#define CAPAB_TOKEN 0x00400000 -#define CAPAB_SSJ3 0x00800000 -#define CAPAB_NICK2 0x01000000 -#define CAPAB_VL 0x02000000 -#define CAPAB_TLKEXT 0x04000000 -#define CAPAB_CHANMODE 0x08000000 -#define CAPAB_SJB64 0x10000000 -#define CAPAB_NICKCHARS 0x20000000 +/* CAPAB stuffs */ +struct CapabInfo +{ + const char *token; + CapabType flag; +}; /*************************************************************************/ diff --git a/src/bots.cpp b/src/bots.cpp index 4cb4556f2..8a4198b74 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -19,23 +19,22 @@ BotInfo::BotInfo(const char *nnick) this->uid = ts6_uid_retrieve(); // XXX is this safe? has ts6 been setup yet? nbots++; this->cmdTable = NULL; - this->flags = 0; this->chancount = 0; if (s_ChanServ && !stricmp(s_ChanServ, nnick)) - this->flags |= BI_CHANSERV; + this->SetFlag(BI_CHANSERV); else if (s_BotServ && !stricmp(s_BotServ, nnick)) - this->flags |= BI_BOTSERV; + this->SetFlag(BI_BOTSERV); else if (s_HostServ && !stricmp(s_HostServ, nnick)) - this->flags |= BI_HOSTSERV; + this->SetFlag(BI_HOSTSERV); else if (s_OperServ && !stricmp(s_OperServ, nnick)) - this->flags |= BI_OPERSERV; + this->SetFlag(BI_OPERSERV); else if (s_MemoServ && !stricmp(s_MemoServ, nnick)) - this->flags |= BI_MEMOSERV; + this->SetFlag(BI_MEMOSERV); else if (s_NickServ && !stricmp(s_NickServ, nnick)) - this->flags |= BI_NICKSERV; + this->SetFlag(BI_NICKSERV); else if (s_GlobalNoticer && !stricmp(s_GlobalNoticer, nnick)) - this->flags |= BI_GLOBAL; + this->SetFlag(BI_GLOBAL); FOREACH_MOD(I_OnBotPreLoad, OnBotPreLoad(this)); @@ -57,23 +56,22 @@ BotInfo::BotInfo(const char *nnick, const char *nuser, const char *nhost, const this->uid = ts6_uid_retrieve(); // XXX is this safe? has ts6 been setup yet? nbots++; this->cmdTable = NULL; - this->flags = 0; this->chancount = 0; if (s_ChanServ && !stricmp(s_ChanServ, nnick)) - this->flags |= BI_CHANSERV; + this->SetFlag(BI_CHANSERV); else if (s_BotServ && !stricmp(s_BotServ, nnick)) - this->flags |= BI_BOTSERV; + this->SetFlag(BI_BOTSERV); else if (s_HostServ && !stricmp(s_HostServ, nnick)) - this->flags |= BI_HOSTSERV; + this->SetFlag(BI_HOSTSERV); else if (s_OperServ && !stricmp(s_OperServ, nnick)) - this->flags |= BI_OPERSERV; + this->SetFlag(BI_OPERSERV); else if (s_MemoServ && !stricmp(s_MemoServ, nnick)) - this->flags |= BI_MEMOSERV; + this->SetFlag(BI_MEMOSERV); else if (s_NickServ && !stricmp(s_NickServ, nnick)) - this->flags |= BI_NICKSERV; + this->SetFlag(BI_NICKSERV); else if (s_GlobalNoticer && !stricmp(s_GlobalNoticer, nnick)) - this->flags |= BI_GLOBAL; + this->SetFlag(BI_GLOBAL); FOREACH_MOD(I_OnBotPreLoad, OnBotPreLoad(this)); diff --git a/src/botserv.c b/src/botserv.c index c160c496b..c9e1f3ed7 100644 --- a/src/botserv.c +++ b/src/botserv.c @@ -168,44 +168,44 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf) */ /* We first retrieve the user status on the channel if needed */ - if (ci->botflags & (BS_DONTKICKOPS | BS_DONTKICKVOICES)) + if (ci->botflags.HasFlag(BS_DONTKICKOPS) || ci->botflags.HasFlag(BS_DONTKICKVOICES)) cstatus = chan_get_user_status(ci->c, u); if (buf && !check_access(u, ci, CA_NOKICK) && - (!(ci->botflags & BS_DONTKICKOPS) + (!ci->botflags.HasFlag(BS_DONTKICKOPS) || !(cstatus & (CUS_HALFOP | CUS_OP | CUS_OWNER | CUS_PROTECT))) + && (!ci->botflags.HasFlag(BS_DONTKICKVOICES) || !(cstatus & CUS_VOICE))) { - && (!(ci->botflags & BS_DONTKICKVOICES) || !(cstatus & CUS_VOICE))) { /* Bolds kicker */ - if ((ci->botflags & BS_KICK_BOLDS) && strchr(buf, 2)) { + if (ci->botflags.HasFlag(BS_KICK_BOLDS) && strchr(buf, 2)) { check_ban(ci, u, TTB_BOLDS); bot_kick(ci, u, BOT_REASON_BOLD); return; } /* Color kicker */ - if ((ci->botflags & BS_KICK_COLORS) && strchr(buf, 3)) { + if (ci->botflags.HasFlag(BS_KICK_COLORS) && strchr(buf, 3)) { check_ban(ci, u, TTB_COLORS); bot_kick(ci, u, BOT_REASON_COLOR); return; } /* Reverses kicker */ - if ((ci->botflags & BS_KICK_REVERSES) && strchr(buf, 22)) { + if (ci->botflags.HasFlag(BS_KICK_REVERSES) && strchr(buf, 22)) { check_ban(ci, u, TTB_REVERSES); bot_kick(ci, u, BOT_REASON_REVERSE); return; } /* Underlines kicker */ - if ((ci->botflags & BS_KICK_UNDERLINES) && strchr(buf, 31)) { + if (ci->botflags.HasFlag(BS_KICK_UNDERLINES) && strchr(buf, 31)) { check_ban(ci, u, TTB_UNDERLINES); bot_kick(ci, u, BOT_REASON_UNDERLINE); return; } /* Caps kicker */ - if ((ci->botflags & BS_KICK_CAPS) + if (ci->botflags.HasFlag(BS_KICK_CAPS) && ((c = strlen(buf)) >= ci->capsmin)) { int i = 0; int l = 0; @@ -231,7 +231,7 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf) } /* Bad words kicker */ - if (ci->botflags & BS_KICK_BADWORDS) { + if (ci->botflags.HasFlag(BS_KICK_BADWORDS)) { int i; int mustkick = 0; char *nbuf; @@ -364,7 +364,7 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf) } /* Flood kicker */ - if (ci->botflags & BS_KICK_FLOOD) { + if (ci->botflags.HasFlag(BS_KICK_FLOOD)) { time_t now = time(NULL); ud = get_user_data(ci->c, u); @@ -386,7 +386,7 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf) } /* Repeat kicker */ - if (ci->botflags & BS_KICK_REPEAT) { + if (ci->botflags.HasFlag(BS_KICK_REPEAT)) { ud = get_user_data(ci->c, u); if (!ud) { return; @@ -417,7 +417,7 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf) /* Fantaisist commands */ - if (buf && (ci->botflags & BS_FANTASY) && *buf == *BSFantasyCharacter && !was_action) { + if (buf && ci->botflags.HasFlag(BS_FANTASY) && *buf == *BSFantasyCharacter && !was_action) { cmd = strtok(buf, " "); if (cmd && (cmd[0] == *BSFantasyCharacter)) { @@ -454,8 +454,9 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf) FOREACH_MOD(I_OnBotFantasy, OnBotFantasy(cmd, u, ci, params)); } else + { FOREACH_MOD(I_OnBotNoFantasyAccess, OnBotNoFantasyAccess(cmd, u, ci, params)); - + } } } } @@ -502,7 +503,7 @@ void load_bs_dbase() SAFE(read_string(&bi->real, f)); if (ver >= 10) { SAFE(read_int16(&tmp16, f)); - bi->flags |= tmp16; + //bi->flags |= tmp16; } SAFE(read_int32(&tmp32, f)); bi->created = tmp32; @@ -513,19 +514,19 @@ void load_bs_dbase() * changed in the config and different from database * names */ - if (s_ChanServ && bi->flags & BI_CHANSERV && strcmp(bi->nick, s_ChanServ)) + if (s_ChanServ && bi->HasFlag(BI_CHANSERV) && strcmp(bi->nick, s_ChanServ)) bi->ChangeNick(s_ChanServ); - else if (s_BotServ && bi->flags & BI_BOTSERV && strcmp(bi->nick, s_BotServ)) + else if (s_BotServ && bi->HasFlag(BI_BOTSERV) && strcmp(bi->nick, s_BotServ)) bi->ChangeNick(s_BotServ); - else if (s_HostServ && bi->flags & BI_HOSTSERV && strcmp(bi->nick, s_HostServ)) + else if (s_HostServ && bi->HasFlag(BI_HOSTSERV) && strcmp(bi->nick, s_HostServ)) bi->ChangeNick(s_HostServ); - else if (s_OperServ && bi->flags & BI_OPERSERV && strcmp(bi->nick, s_OperServ)) + else if (s_OperServ && bi->HasFlag(BI_OPERSERV) && strcmp(bi->nick, s_OperServ)) bi->ChangeNick(s_OperServ); - else if (s_MemoServ && bi->flags & BI_MEMOSERV && strcmp(bi->nick, s_MemoServ)) + else if (s_MemoServ && bi->HasFlag(BI_MEMOSERV) && strcmp(bi->nick, s_MemoServ)) bi->ChangeNick(s_MemoServ); - else if (s_NickServ && bi->flags & BI_NICKSERV && strcmp(bi->nick, s_NickServ)) + else if (s_NickServ && bi->HasFlag(BI_NICKSERV) && strcmp(bi->nick, s_NickServ)) bi->ChangeNick(s_NickServ); - else if (s_GlobalNoticer && bi->flags & BI_GLOBAL && strcmp(bi->nick, s_GlobalNoticer)) + else if (s_GlobalNoticer && bi->HasFlag(BI_GLOBAL) && strcmp(bi->nick, s_GlobalNoticer)) bi->ChangeNick(s_GlobalNoticer); } @@ -566,7 +567,8 @@ void save_bs_dbase() SAFE(write_string(bi->user, f)); SAFE(write_string(bi->host, f)); SAFE(write_string(bi->real, f)); - SAFE(write_int16(bi->flags, f)); + //SAFE(write_int16(bi->flags, f)); + SAFE(write_int16(0, f)); SAFE(write_int32(bi->created, f)); SAFE(write_int16(bi->chancount, f)); } @@ -893,8 +895,7 @@ void bot_raw_ban(User * requester, ChannelInfo * ci, char *nick, } } - if ((ci->flags & CI_PEACE) && stricmp(requester->nick, nick) - && (get_access(u, ci) >= get_access(requester, ci))) + if (ci->HasFlag(CI_PEACE) && stricmp(requester->nick, nick) && (get_access(u, ci) >= get_access(requester, ci))) return; if (ModeManager::FindChannelModeByName(CMODE_EXCEPT)) @@ -937,9 +938,7 @@ void bot_raw_ban(User * requester, ChannelInfo * ci, char *nick, } /* Check if we need to do a signkick or not -GD */ - if ((ci->flags & CI_SIGNKICK) - || ((ci->flags & CI_SIGNKICK_LEVEL) - && !check_access(requester, ci, CA_SIGNKICK))) + if ((ci->HasFlag(CI_SIGNKICK) || ci->HasFlag(CI_SIGNKICK_LEVEL)) && !check_access(requester, ci, CA_SIGNKICK)) ircdproto->SendKick(ci->bi, kav[0], kav[1], "%s (%s)", kav[2], requester->nick); else @@ -971,8 +970,7 @@ void bot_raw_kick(User * requester, ChannelInfo * ci, char *nick, } } - if ((ci->flags & CI_PEACE) && stricmp(requester->nick, nick) - && (get_access(u, ci) >= get_access(requester, ci))) + if (ci->HasFlag(CI_PEACE) && stricmp(requester->nick, nick) && (get_access(u, ci) >= get_access(requester, ci))) return; av[0] = ci->name; @@ -986,9 +984,7 @@ void bot_raw_kick(User * requester, ChannelInfo * ci, char *nick, av[2] = reason; } - if ((ci->flags & CI_SIGNKICK) - || ((ci->flags & CI_SIGNKICK_LEVEL) - && !check_access(requester, ci, CA_SIGNKICK))) + if (ci->HasFlag(CI_SIGNKICK) || ((ci->HasFlag(CI_SIGNKICK_LEVEL)) && !check_access(requester, ci, CA_SIGNKICK))) ircdproto->SendKick(ci->bi, av[0], av[1], "%s (%s)", av[2], requester->nick); else @@ -1025,7 +1021,7 @@ void bot_raw_mode(User * requester, ChannelInfo * ci, const char *mode, } } - if (*mode == '-' && (ci->flags & CI_PEACE) + if (*mode == '-' && ci->HasFlag(CI_PEACE) && stricmp(requester->nick, nick) && (get_access(u, ci) >= get_access(requester, ci))) return; diff --git a/src/channels.c b/src/channels.c index 8556179ea..9bd3abdc3 100644 --- a/src/channels.c +++ b/src/channels.c @@ -625,7 +625,7 @@ void chan_set_modes(const char *source, Channel *chan, int ac, const char **av, { if (check < 2) chan_set_correct_modes(user, chan, 0); - else if ((chan->ci->flags) && (chan->ci->flags & CI_SECUREOPS)) + else if (chan->ci->HasFlag(CI_SECUREOPS)) { /* Fixing bug #1006 oringinally caused by fixing #922 * we must check for secureops here, not in chan_set_correct_modes @@ -1509,7 +1509,7 @@ void do_cmode(const char *source, int ac, const char **av) if (!chan) { if (debug) { ci = cs_findchan(av[0]); - if (!(ci && (ci->flags & CI_FORBIDDEN))) + if (!(ci && (ci->HasFlag(CI_FORBIDDEN)))) alog("debug: MODE %s for nonexistent channel %s", merge_args(ac - 1, av + 1), av[0]); } @@ -1635,7 +1635,7 @@ void chan_set_correct_modes(User * user, Channel * c, int give_modes) if (!c || !(ci = c->ci)) return; - if ((ci->flags & CI_FORBIDDEN) || (*(c->name) == '+')) + if ((ci->HasFlag(CI_FORBIDDEN)) || (*(c->name) == '+')) return; status = chan_get_user_status(c, user); @@ -1649,7 +1649,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->nc || !(user->nc->flags & NI_AUTOOP))) { + && (!user->nc || !user->nc->HasFlag(NI_AUTOOP))) { if (owner && (IsFounder(user, ci) || check_access(user, ci, CA_AUTOOWNER))) add_modes |= CUS_OWNER; else if (admin && check_access(user, ci, CA_AUTOPROTECT)) @@ -1668,7 +1668,7 @@ void chan_set_correct_modes(User * user, Channel * c, int give_modes) * Unless the channel has just been created. -heinz * Or the user matches CA_AUTODEOP... -GD */ - if (((ci->flags & CI_SECUREOPS) || (c->usercount == 1) + if (((ci->HasFlag(CI_SECUREOPS)) || (c->usercount == 1) || check_access(user, ci, CA_AUTODEOP)) && !is_ulined(user->server->name)) { if (owner && (status & CUS_OWNER) && !IsFounder(user, ci)) @@ -1823,7 +1823,7 @@ void chan_adduser2(User * user, Channel * c) if (s_BotServ && c->ci && c->ci->bi) { if (c->usercount == BSMinUsers) bot_join(c->ci); - if (c->usercount >= BSMinUsers && (c->ci->botflags & BS_GREET) + if (c->usercount >= BSMinUsers && (c->ci->botflags.HasFlag(BS_GREET)) && user->nc && user->nc->greet && check_access(user, c->ci, CA_GREET)) { /* Only display the greet if the main uplink we're connected @@ -2071,7 +2071,7 @@ Entry *entry_create(char *mask) uint32 ip, cidr; entry = new Entry; - entry->type = ENTRYTYPE_NONE; + entry->SetFlag(ENTRYTYPE_NONE); entry->prev = NULL; entry->next = NULL; entry->nick = NULL; @@ -2113,18 +2113,18 @@ Entry *entry_create(char *mask) entry->nick = sstrdup(nick); /* Check if we have a wildcard user */ if (str_is_wildcard(nick)) - entry->type |= ENTRYTYPE_NICK_WILD; + entry->SetFlag(ENTRYTYPE_NICK_WILD); else - entry->type |= ENTRYTYPE_NICK; + entry->SetFlag(ENTRYTYPE_NICK); } if (user) { entry->user = sstrdup(user); /* Check if we have a wildcard user */ if (str_is_wildcard(user)) - entry->type |= ENTRYTYPE_USER_WILD; + entry->SetFlag(ENTRYTYPE_USER_WILD); else - entry->type |= ENTRYTYPE_USER; + entry->SetFlag(ENTRYTYPE_USER); } /* Only check the host if it's not a pure wildcard */ @@ -2132,7 +2132,7 @@ Entry *entry_create(char *mask) if (ircd->cidrchanbei && str_is_cidr(host, &ip, &cidr, &cidrhost)) { entry->cidr_ip = ip; entry->cidr_mask = cidr; - entry->type |= ENTRYTYPE_CIDR4; + entry->SetFlag(ENTRYTYPE_CIDR4); host = cidrhost; } else if (ircd->cidrchanbei && strchr(host, '/')) { /* Most IRCd's don't enforce sane bans therefore it is not @@ -2143,13 +2143,14 @@ Entry *entry_create(char *mask) * str_is_cidr() as this expects a standard cidr. * Add it to the internal list (so it is included in for example clear) * but do not use if during matching.. ~ Viper */ - entry->type = ENTRYTYPE_NONE; + entry->ClearFlags(); + entry->SetFlag(ENTRYTYPE_NONE); } else { entry->host = sstrdup(host); if (str_is_wildcard(host)) - entry->type |= ENTRYTYPE_HOST_WILD; + entry->SetFlag(ENTRYTYPE_HOST_WILD); else - entry->type |= ENTRYTYPE_HOST; + entry->SetFlag(ENTRYTYPE_HOST); } } delete [] mask; @@ -2246,28 +2247,28 @@ EList *list_create() int entry_match(Entry * e, const char *nick, const char *user, const char *host, uint32 ip) { /* If we don't get an entry, or it s an invalid one, no match ~ Viper */ - if (!e || e->type == ENTRYTYPE_NONE) + if (!e || !e->FlagCount()) return 0; - if (ircd->cidrchanbei && (e->type & ENTRYTYPE_CIDR4) && + if (ircd->cidrchanbei && (e->HasFlag(ENTRYTYPE_CIDR4)) && (!ip || (ip && ((ip & e->cidr_mask) != e->cidr_ip)))) return 0; - if ((e->type & ENTRYTYPE_NICK) + if ((e->HasFlag(ENTRYTYPE_NICK)) && (!nick || stricmp(e->nick, nick) != 0)) return 0; - if ((e->type & ENTRYTYPE_USER) + if ((e->HasFlag(ENTRYTYPE_USER)) && (!user || stricmp(e->user, user) != 0)) return 0; - if ((e->type & ENTRYTYPE_HOST) + if ((e->HasFlag(ENTRYTYPE_HOST)) && (!user || stricmp(e->host, host) != 0)) return 0; - if ((e->type & ENTRYTYPE_NICK_WILD) + if ((e->HasFlag(ENTRYTYPE_NICK_WILD)) && !Anope::Match(nick, e->nick, false)) return 0; - if ((e->type & ENTRYTYPE_USER_WILD) + if ((e->HasFlag(ENTRYTYPE_USER_WILD)) && !Anope::Match(user, e->user, false)) return 0; - if ((e->type & ENTRYTYPE_HOST_WILD) + if ((e->HasFlag(ENTRYTYPE_HOST_WILD)) && !Anope::Match(host, e->host, false)) return 0; diff --git a/src/chanserv.c b/src/chanserv.c index 340ab045c..c52cd9d07 100644 --- a/src/chanserv.c +++ b/src/chanserv.c @@ -134,7 +134,7 @@ class ChanServTimer : public Timer ChannelInfo *ci = cs_findchan(channel.c_str()); if (ci) - ci->flags &= ~CI_INHABIT; + ci->UnsetFlag(CI_INHABIT); ircdproto->SendPart(findbot(s_ChanServ), channel.c_str(), NULL); } @@ -394,13 +394,14 @@ void load_cs_dbase() SAFE(read = read_buffer(ci->last_topic_setter, f)); SAFE(read_int32(&tmp32, f)); ci->last_topic_time = tmp32; - SAFE(read_int32(&ci->flags, f)); + //SAFE(read_int32(&ci->flags, f)); + SAFE(read_int32(&tmp32, f)); /* Leaveops cleanup */ - if (ver <= 13 && (ci->flags & 0x00000020)) - ci->flags &= ~0x00000020; +// if (ver <= 13 && (ci->HasFlag()0x00000020)) +// ci->UnsetFlag()0x00000020; /* Temporary flags cleanup */ - ci->flags &= ~CI_INHABIT; + ci->UnsetFlag(CI_INHABIT); SAFE(read_string(&ci->forbidby, f)); SAFE(read_string(&ci->forbidreason, f)); @@ -517,7 +518,8 @@ void load_cs_dbase() ci->memos.memos[j] = new Memo; Memo *memo = ci->memos.memos[j]; SAFE(read_int32(&memo->number, f)); - SAFE(read_int16(&memo->flags, f)); + //SAFE(read_int16(&memo->flags, f)); + SAFE(read_int16(&tmp16, f)); SAFE(read_int32(&tmp32, f)); memo->time = tmp32; SAFE(read = read_buffer(memo->sender, f)); @@ -540,7 +542,7 @@ void load_cs_dbase() ci->bi = NULL; SAFE(read_int32(&tmp32, f)); - ci->botflags = tmp32; + //ci->botflags = tmp32; SAFE(read_int16(&tmp16, f)); n_ttb = tmp16; ci->ttb = new int16[2 * TTB_SIZE]; @@ -569,7 +571,9 @@ void load_cs_dbase() SAFE(read_int16(&ci->badwords[j].in_use, f)); if (ci->badwords[j].in_use) { SAFE(read_string(&ci->badwords[j].word, f)); - SAFE(read_int16(&ci->badwords[j].type, f)); + //SAFE(read_int16(&ci->badwords[j].type, f)); + SAFE(read_int16(&tmp16, f)); + ci->badwords[j].type = BW_ANY; // for now } } } else { @@ -589,7 +593,7 @@ void load_cs_dbase() ChannelInfo *next; for (ci = chanlists[i]; ci; ci = next) { next = ci->next; - if (!(ci->flags & CI_FORBIDDEN) && !ci->founder) { + if (!(ci->HasFlag(CI_FORBIDDEN)) && !ci->founder) { alog("%s: database load: Deleting founderless channel %s", s_ChanServ, ci->name); delchan(ci); @@ -655,7 +659,8 @@ void save_cs_dbase() SAFE(write_string(ci->last_topic, f)); SAFE(written = write_buffer(ci->last_topic_setter, f)); SAFE(write_int32(ci->last_topic_time, f)); - SAFE(write_int32(ci->flags, f)); + //SAFE(write_int32(ci->flags, f)); + SAFE(write_int32(0, f)); SAFE(write_string(ci->forbidby, f)); SAFE(write_string(ci->forbidreason, f)); SAFE(write_int16(ci->bantype, f)); @@ -681,8 +686,9 @@ void save_cs_dbase() for (j = 0; j < ci->GetAkickCount(); ++j) { AutoKick *akick = ci->GetAkick(j); - SAFE(write_int16(akick->flags, f)); - if (akick->flags & AK_ISNICK) + //SAFE(write_int16(akick->flags, f)); + SAFE(write_int16(0, f)); + if (akick->HasFlag(AK_ISNICK)) SAFE(write_string(akick->nc->display, f)); else SAFE(write_string(akick->mask.c_str(), f)); @@ -714,7 +720,8 @@ void save_cs_dbase() for (j = 0; j < ci->memos.memos.size(); j++) { Memo *memo = ci->memos.memos[j]; SAFE(write_int32(memo->number, f)); - SAFE(write_int16(memo->flags, f)); + SAFE(write_int16(0, f)); + //SAFE(write_int16(memo->flags, f)); SAFE(write_int32(memo->time, f)); SAFE(written = write_buffer(memo->sender, f)); SAFE(write_string(memo->text, f)); @@ -727,7 +734,8 @@ void save_cs_dbase() else SAFE(write_string(NULL, f)); - SAFE(write_int32(ci->botflags, f)); + //SAFE(write_int32(ci->botflags, f)); + SAFE(write_int32(0, f)); tmp16 = TTB_SIZE; SAFE(write_int16(tmp16, f)); @@ -914,7 +922,7 @@ int check_valid_admin(User * user, Channel * chan, int servermode) return 0; /* They will be kicked; no need to deop, no need to update our internal struct too */ - if (chan->ci->flags & CI_FORBIDDEN) + if (chan->ci->HasFlag(CI_FORBIDDEN)) return 0; if (servermode && !check_access(user, chan->ci, CA_AUTOPROTECT)) { @@ -946,7 +954,7 @@ int check_valid_op(User * user, Channel * chan, int servermode) return 1; /* They will be kicked; no need to deop, no need to update our internal struct too */ - if (chan->ci->flags & CI_FORBIDDEN) + if (chan->ci->HasFlag(CI_FORBIDDEN)) return 0; owner = ModeManager::FindChannelModeByName(CMODE_OWNER); @@ -1029,10 +1037,10 @@ int check_should_op(User * user, char *chan) { ChannelInfo *ci = cs_findchan(chan); - if (!ci || (ci->flags & CI_FORBIDDEN) || *chan == '+') + if (!ci || (ci->HasFlag(CI_FORBIDDEN)) || *chan == '+') return 0; - if ((ci->flags & CI_SECURE) && !nick_identified(user)) + if ((ci->HasFlag(CI_SECURE)) && !nick_identified(user)) return 0; if (check_access(user, ci, CA_AUTOOP)) { @@ -1052,10 +1060,10 @@ int check_should_voice(User * user, char *chan) { ChannelInfo *ci = cs_findchan(chan); - if (!ci || (ci->flags & CI_FORBIDDEN) || *chan == '+') + if (!ci || (ci->HasFlag(CI_FORBIDDEN)) || *chan == '+') return 0; - if ((ci->flags & CI_SECURE) && !nick_identified(user)) + if ((ci->HasFlag(CI_SECURE)) && !nick_identified(user)) return 0; if (check_access(user, ci, CA_AUTOVOICE)) { @@ -1072,7 +1080,7 @@ int check_should_halfop(User * user, char *chan) { ChannelInfo *ci = cs_findchan(chan); - if (!ci || (ci->flags & CI_FORBIDDEN) || *chan == '+') + if (!ci || (ci->HasFlag(CI_FORBIDDEN)) || *chan == '+') return 0; if (check_access(user, ci, CA_AUTOHALFOP)) { @@ -1090,11 +1098,11 @@ int check_should_owner(User * user, char *chan) ChannelInfo *ci = cs_findchan(chan); ChannelMode *cm = ModeManager::FindChannelModeByName(CMODE_OWNER); - if (!ci || (ci->flags & CI_FORBIDDEN) || *chan == '+') + if (!ci || (ci->HasFlag(CI_FORBIDDEN)) || *chan == '+') return 0; - if (((ci->flags & CI_SECUREFOUNDER) && IsRealFounder(user, ci)) - || (!(ci->flags & CI_SECUREFOUNDER) && IsFounder(user, ci))) { + if (((ci->HasFlag(CI_SECUREFOUNDER)) && IsRealFounder(user, ci)) + || (!(ci->HasFlag(CI_SECUREFOUNDER)) && IsFounder(user, ci))) { ircdproto->SendMode(whosends(ci), chan, "+o%s %s %s", cm->ModeChar, user->nick, user->nick); return 1; @@ -1110,7 +1118,7 @@ int check_should_protect(User * user, char *chan) ChannelInfo *ci = cs_findchan(chan); ChannelMode *cm = ModeManager::FindChannelModeByName(CMODE_PROTECT); - if (!ci || (ci->flags & CI_FORBIDDEN) || *chan == '+') + if (!ci || (ci->HasFlag(CI_FORBIDDEN)) || *chan == '+') return 0; if (check_access(user, ci, CA_AUTOPROTECT)) { @@ -1157,7 +1165,7 @@ int check_kick(User * user, const char *chan, time_t chants) return 0; } - if (ci->flags & CI_SUSPENDED || ci->flags & CI_FORBIDDEN) + if (ci->HasFlag(CI_SUSPENDED) || ci->HasFlag(CI_FORBIDDEN)) { if (is_oper(user)) return 0; @@ -1188,16 +1196,16 @@ int check_kick(User * user, const char *chan, time_t chants) { akick = ci->GetAkick(j); - if (!(akick->flags & AK_USED)) + if (!akick->HasFlag(AK_USED)) continue; - if ((akick->flags & AK_ISNICK && akick->nc == nc) - || (!(akick->flags & AK_ISNICK) + if ((akick->HasFlag(AK_ISNICK) && akick->nc == nc) + || (!akick->HasFlag(AK_ISNICK) && match_usermask(akick->mask.c_str(), user))) { if (debug >= 2) - alog("debug: %s matched akick %s", user->nick, (akick->flags & AK_ISNICK) ? akick->nc->display : akick->mask.c_str()); - if (akick->flags & AK_ISNICK) + alog("debug: %s matched akick %s", user->nick, akick->HasFlag(AK_ISNICK) ? akick->nc->display : akick->mask.c_str()); + if (akick->HasFlag(AK_ISNICK)) get_idealban(ci, user, mask, sizeof(mask)); else strlcpy(mask, akick->mask.c_str(), sizeof(mask)); @@ -1226,7 +1234,7 @@ int check_kick(User * user, const char *chan, time_t chants) * JOIN would not). */ /* Don't check for CI_INHABIT before for the Channel record cos else * c may be NULL even if it exists */ - if ((!(c = findchan(chan)) || c->usercount == 0) && !(ci->flags & CI_INHABIT)) + if ((!(c = findchan(chan)) || c->usercount == 0) && !ci->HasFlag(CI_INHABIT)) { ircdproto->SendJoin(findbot(s_ChanServ), chan, (c ? c->creation_time : chants)); /* @@ -1238,7 +1246,7 @@ int check_kick(User * user, const char *chan, time_t chants) } t = new ChanServTimer(CSInhabit, chan); - ci->flags |= CI_INHABIT; + ci->SetFlag(CI_INHABIT); } if (c) { @@ -1306,7 +1314,7 @@ void restore_topic(const char *chan) return; /* We can be sure that the topic will be in sync when we return -GD */ c->topic_sync = 1; - if (!(ci->flags & CI_KEEPTOPIC)) { + if (!(ci->HasFlag(CI_KEEPTOPIC))) { /* We need to reset the topic here, since it's currently empty and * should be updated with a TOPIC from the IRCd soon. -GD */ @@ -1356,7 +1364,7 @@ int check_topiclock(Channel * c, time_t topic_time) return 0; } - if (!(ci = c->ci) || !(ci->flags & CI_TOPICLOCK)) + if (!(ci = c->ci) || !(ci->HasFlag(CI_TOPICLOCK))) return 0; if (c->topic) @@ -1421,9 +1429,7 @@ void expire_chans() for (i = 0; i < 256; i++) { for (ci = chanlists[i]; ci; ci = next) { next = ci->next; - if (!ci->c && now - ci->last_used >= CSExpire - && !(ci-> - flags & (CI_FORBIDDEN | CI_NO_EXPIRE | CI_SUSPENDED))) + if (!ci->c && now - ci->last_used >= CSExpire && !ci->HasFlag(CI_FORBIDDEN) && !ci->HasFlag(CI_NO_EXPIRE) && !ci->HasFlag(CI_SUSPENDED)) { EventReturn MOD_RESULT; FOREACH_RESULT(I_OnPreChanExpire, OnPreChanExpire(ci)); @@ -1500,7 +1506,7 @@ void cs_remove_nick(const NickCore * nc) for (j = ci->GetAkickCount(); j > 0; --j) { akick = ci->GetAkick(j - 1); - if ((akick->flags & AK_USED) && (akick->flags & AK_ISNICK) && akick->nc == nc) + if (akick->HasFlag(AK_USED) && akick->HasFlag(AK_ISNICK) && akick->nc == nc) ci->EraseAkick(akick); } } @@ -1560,7 +1566,7 @@ int check_access(User * user, ChannelInfo * ci, int what) if (level >= ACCESS_FOUNDER) return (what == CA_AUTODEOP || what == CA_NOJOIN) ? 0 : 1; /* Hacks to make flags work */ - if (what == CA_AUTODEOP && (ci->flags & CI_SECUREOPS) && level == 0) + if (what == CA_AUTODEOP && (ci->HasFlag(CI_SECUREOPS)) && level == 0) return 1; if (limit == ACCESS_INVALID) return 0; @@ -1785,7 +1791,7 @@ bool IsFounder(User *user, ChannelInfo *ci) } /* If they're QOP+ and theyre identified or theyre recognized and the channel isn't secure */ - if (access && access->level >= ACCESS_QOP && (user->nc || (user->IsRecognized() && !(ci->flags & CI_SECURE)))) + if (access && access->level >= ACCESS_QOP && (user->nc || (user->IsRecognized() && !(ci->HasFlag(CI_SECURE))))) return true; return false; @@ -1843,7 +1849,7 @@ int get_access(User *user, ChannelInfo *ci) NickAlias *na = findnick(user->nick); if (na) access = ci->GetAccess(na->nc); - if (access && user->IsRecognized() && !(ci->flags & CI_SECURE)) + if (access && user->IsRecognized() && !(ci->HasFlag(CI_SECURE))) return access->level; } @@ -1860,7 +1866,7 @@ void update_cs_lastseen(User * user, ChannelInfo * ci) return; if (IsFounder(user, ci) || nick_identified(user) - || (user->IsRecognized() && !(ci->flags & CI_SECURE))) + || (user->IsRecognized() && !ci->HasFlag(CI_SECURE))) if ((access = ci->GetAccess(user->nc))) access->last_seen = time(NULL); } @@ -1977,7 +1983,7 @@ AutoKick *is_stuck(ChannelInfo * ci, const char *mask) { AutoKick *akick = ci->GetAkick(i); - if (!(akick->flags & AK_USED) || (akick->flags & AK_ISNICK) || !(akick->flags & AK_STUCK)) + if (!akick->HasFlag(AK_USED) || akick->HasFlag(AK_ISNICK) || !akick->HasFlag(AK_STUCK)) continue; if (Anope::Match(akick->mask, mask, false)) @@ -2038,8 +2044,7 @@ void stick_all(ChannelInfo * ci) { AutoKick *akick = ci->GetAkick(i); - if (!(akick->flags & AK_USED) || (akick->flags & AK_ISNICK) - || !(akick->flags & AK_STUCK)) + if (!akick->HasFlag(AK_USED) || (akick->HasFlag(AK_ISNICK) || !akick->HasFlag(AK_STUCK))) continue; av[0] = "+b"; diff --git a/src/command.cpp b/src/command.cpp index fa5b21a2a..41e9045e5 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -13,7 +13,6 @@ Command::Command(const std::string &sname, size_t min_params, size_t max_params, const std::string &spermission) : MaxParams(max_params), MinParams(min_params), name(sname), permission(spermission) { - this->flags = 0; this->core = 0; this->mod_name = NULL; this->service = NULL; @@ -36,21 +35,6 @@ bool Command::OnHelp(User *u, const ci::string &subcommand) { return false; } void Command::OnSyntaxError(User *u) { } -void Command::SetFlag(CommandFlags flag) -{ - this->flags |= flag; -} - -void Command::UnsetFlag(CommandFlags flag) -{ - this->flags &= ~flag; -} - -bool Command::HasFlag(CommandFlags flag) const -{ - return this->flags & flag; -} - void Command::SetPermission(const std::string &reststr) { this->permission = reststr; diff --git a/src/commands.c b/src/commands.c index 9247307a3..d8fcf5589 100644 --- a/src/commands.c +++ b/src/commands.c @@ -123,14 +123,14 @@ void mod_run_cmd(char *service, User * u, CommandHash * cmdTable[], const char * { if ((ci = cs_findchan(params[0].c_str()))) { - if ((ci->flags & CI_FORBIDDEN) && (!c->HasFlag(CFLAG_ALLOW_FORBIDDEN))) + if ((ci->HasFlag(CI_FORBIDDEN)) && (!c->HasFlag(CFLAG_ALLOW_FORBIDDEN))) { notice_lang(service, u, CHAN_X_FORBIDDEN, ci->name); alog("Access denied for user %s with service %s and command %s because of FORBIDDEN channel %s", u->nick, service, cmd, ci->name); return; } - else if ((ci->flags & CI_SUSPENDED) && (!c->HasFlag(CFLAG_ALLOW_SUSPENDED))) + else if ((ci->HasFlag(CI_SUSPENDED)) && (!c->HasFlag(CFLAG_ALLOW_SUSPENDED))) { notice_lang(service, u, CHAN_X_FORBIDDEN, ci->name); alog("Access denied for user %s with service %s and command %s because of SUSPENDED channel %s", diff --git a/src/config.c b/src/config.c index 070fcfb6d..03f1fde24 100644 --- a/src/config.c +++ b/src/config.c @@ -95,7 +95,7 @@ static std::string NSDefaults; char *NSGuestNickPrefix; bool NSAllowKillImmed; bool NSNoGroupChange; -int NSDefFlags; +Flags NSDefFlags; unsigned NSDefLanguage; time_t NSRegDelay; time_t NSResendDelay; @@ -117,7 +117,7 @@ bool NSModeOnID; bool NSAddAccessOnReg; static std::string CSDefaults; -int CSDefFlags; +Flags CSDefFlags; unsigned CSMaxReg; time_t CSExpire; int CSDefBantype; @@ -135,7 +135,7 @@ bool MSNotifyAll; unsigned MSMemoReceipt; static std::string BSDefaults; -int BSDefFlags; +Flags BSDefFlags; time_t BSKeepData; unsigned BSMinUsers; unsigned BSBadWordsMax; @@ -1785,29 +1785,34 @@ int read_config(int reload) } } - NSDefFlags = 0; - if (NSDefaults.empty()) NSDefFlags = NI_SECURE | NI_MEMO_SIGNON | NI_MEMO_RECEIVE; + if (NSDefaults.empty()) + { + NSDefFlags.SetFlag(NI_SECURE); + NSDefFlags.SetFlag(NI_MEMO_SIGNON); + NSDefFlags.SetFlag(NI_MEMO_RECEIVE); + } else if (NSDefaults != "none") { bool hadAutoop = false; spacesepstream options(NSDefaults); std::string option; - while (options.GetToken(option)) { - if (option == "kill") NSDefFlags |= NI_KILLPROTECT; - else if (option == "killquick") NSDefFlags |= NI_KILL_QUICK; - else if (option == "secure") NSDefFlags |= NI_SECURE; - else if (option == "private") NSDefFlags |= NI_PRIVATE; + while (options.GetToken(option)) + { + if (option == "kill") NSDefFlags.SetFlag(NI_KILLPROTECT); + else if (option == "killquick") NSDefFlags.SetFlag(NI_KILL_QUICK); + else if (option == "secure") NSDefFlags.SetFlag(NI_SECURE); + else if (option == "private") NSDefFlags.SetFlag(NI_PRIVATE); else if (option == "msg") { if (!UsePrivmsg) alog("msg in can only be used when UsePrivmsg is set"); - else NSDefFlags |= NI_MSG; + else NSDefFlags.SetFlag(NI_MSG); } - else if (option == "hideemail") NSDefFlags |= NI_HIDE_EMAIL; - else if (option == "hideusermask") NSDefFlags |= NI_HIDE_MASK; - else if (option == "hidequit") NSDefFlags |= NI_HIDE_QUIT; - else if (option == "memosignon") NSDefFlags |= NI_MEMO_SIGNON; - else if (option == "memoreceive") NSDefFlags |= NI_MEMO_RECEIVE; + else if (option == "hideemail") NSDefFlags.SetFlag(NI_HIDE_EMAIL); + else if (option == "hideusermask") NSDefFlags.SetFlag(NI_HIDE_MASK); + else if (option == "hidequit") NSDefFlags.SetFlag(NI_HIDE_QUIT); + else if (option == "memosignon") NSDefFlags.SetFlag(NI_MEMO_SIGNON); + else if (option == "memoreceive") NSDefFlags.SetFlag(NI_MEMO_RECEIVE); else if (option == "autoop") hadAutoop = true; } - if (!hadAutoop) NSDefFlags |= NI_AUTOOP; + if (!hadAutoop) NSDefFlags.SetFlag(NI_AUTOOP); } if (reload) { @@ -1820,37 +1825,41 @@ int read_config(int reload) retval = 0; } - CSDefFlags = 0; - if (CSDefaults.empty()) CSDefFlags = CI_KEEPTOPIC | CI_SECURE | CI_SECUREFOUNDER | CI_SIGNKICK; + if (CSDefaults.empty()) + { + CSDefFlags.SetFlag(CI_KEEPTOPIC); + CSDefFlags.SetFlag(CI_SECURE); + CSDefFlags.SetFlag(CI_SECUREFOUNDER); + CSDefFlags.SetFlag(CI_SIGNKICK); + } else if (CSDefaults != "none") { spacesepstream options(CSDefaults); std::string option; while (options.GetToken(option)) { - if (option == "keeptopic") CSDefFlags |= CI_KEEPTOPIC; - else if (option == "topiclock") CSDefFlags |= CI_TOPICLOCK; - else if (option == "private") CSDefFlags |= CI_PRIVATE; - else if (option == "restricted") CSDefFlags |= CI_RESTRICTED; - else if (option == "secure") CSDefFlags |= CI_SECURE; - else if (option == "secureops") CSDefFlags |= CI_SECUREOPS; - else if (option == "securefounder") CSDefFlags |= CI_SECUREFOUNDER; - else if (option == "signkick") CSDefFlags |= CI_SIGNKICK; - else if (option == "signkicklevel") CSDefFlags |= CI_SIGNKICK_LEVEL; - else if (option == "opnotice") CSDefFlags |= CI_OPNOTICE; - else if (option == "xop") CSDefFlags |= CI_XOP; - else if (option == "peace") CSDefFlags |= CI_PEACE; + if (option == "keeptopic") CSDefFlags.SetFlag(CI_KEEPTOPIC); + else if (option == "topiclock") CSDefFlags.SetFlag(CI_TOPICLOCK); + else if (option == "private") CSDefFlags.SetFlag(CI_PRIVATE); + else if (option == "restricted") CSDefFlags.SetFlag(CI_RESTRICTED); + else if (option == "secure") CSDefFlags.SetFlag(CI_SECURE); + else if (option == "secureops") CSDefFlags.SetFlag(CI_SECUREOPS); + else if (option == "securefounder") CSDefFlags.SetFlag(CI_SECUREFOUNDER); + else if (option == "signkick") CSDefFlags.SetFlag(CI_SIGNKICK); + else if (option == "signkicklevel") CSDefFlags.SetFlag(CI_SIGNKICK_LEVEL); + else if (option == "opnotice") CSDefFlags.SetFlag(CI_OPNOTICE); + else if (option == "xop") CSDefFlags.SetFlag(CI_XOP); + else if (option == "peace") CSDefFlags.SetFlag(CI_PEACE); } } - BSDefFlags = 0; if (!BSDefaults.empty()) { spacesepstream options(BSDefaults); std::string option; while (options.GetToken(option)) { - if (option == "dontkickops") BSDefFlags |= BS_DONTKICKOPS; - else if (option == "dontkickvoices") BSDefFlags |= BS_DONTKICKVOICES; - else if (option == "greet") BSDefFlags |= BS_GREET; - else if (option == "fantasy") BSDefFlags |= BS_FANTASY; - else if (option == "symbiosis") BSDefFlags |= BS_SYMBIOSIS; + if (option == "dontkickops") BSDefFlags.SetFlag(BS_DONTKICKOPS); + else if (option == "dontkickvoices") BSDefFlags.SetFlag(BS_DONTKICKVOICES); + else if (option == "greet") BSDefFlags.SetFlag(BS_GREET); + else if (option == "fantasy") BSDefFlags.SetFlag(BS_FANTASY); + else if (option == "symbiosis") BSDefFlags.SetFlag(BS_SYMBIOSIS); } } diff --git a/src/core/bs_assign.c b/src/core/bs_assign.c index 1ca280c4c..e6d619095 100644 --- a/src/core/bs_assign.c +++ b/src/core/bs_assign.c @@ -43,13 +43,13 @@ class CommandBSAssign : public Command ci = cs_findchan(chan); - if ((ci->botflags & BS_NOBOT) || (!check_access(u, ci, CA_ASSIGN) && !u->nc->HasPriv("botserv/administration"))) + if (ci->botflags.HasFlag(BS_NOBOT) || (!check_access(u, ci, CA_ASSIGN) && !u->nc->HasPriv("botserv/administration"))) { notice_lang(s_BotServ, u, ACCESS_DENIED); return MOD_CONT; } - if (bi->flags & BI_PRIVATE && !u->nc->HasCommand("botserv/assign/private")) + if (bi->HasFlag(BI_PRIVATE) && !u->nc->HasCommand("botserv/assign/private")) { notice_lang(s_BotServ, u, ACCESS_DENIED); return MOD_CONT; diff --git a/src/core/bs_badwords.c b/src/core/bs_badwords.c index 8c07fb36a..405dbf2a6 100644 --- a/src/core/bs_badwords.c +++ b/src/core/bs_badwords.c @@ -57,7 +57,7 @@ class CommandBSBadwords : public Command CommandReturn DoAdd(User *u, ChannelInfo *ci, const char *word) { char *opt, *pos; - int type = BW_ANY; + BadWordType type = BW_ANY; unsigned i = 0; BadWord *bw; diff --git a/src/core/bs_botlist.c b/src/core/bs_botlist.c index 79902a752..c29ce19ee 100644 --- a/src/core/bs_botlist.c +++ b/src/core/bs_botlist.c @@ -34,7 +34,7 @@ class CommandBSBotList : public Command for (i = 0; i < 256; i++) { for (bi = botlists[i]; bi; bi = bi->next) { - if (!(bi->flags & BI_PRIVATE)) { + if (!(bi->HasFlag(BI_PRIVATE))) { if (!count) notice_lang(s_BotServ, u, BOT_BOTLIST_HEADER); count++; @@ -48,7 +48,7 @@ class CommandBSBotList : public Command for (i = 0; i < 256; i++) { for (bi = botlists[i]; bi; bi = bi->next) { - if (bi->flags & BI_PRIVATE) { + if (bi->HasFlag(BI_PRIVATE)) { u->SendMes