summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/channels.h49
-rw-r--r--include/extern.h2
-rw-r--r--include/services.h23
-rw-r--r--include/users.h14
4 files changed, 55 insertions, 33 deletions
diff --git a/include/channels.h b/include/channels.h
index 0cd1829e2..3baae9f1b 100644
--- a/include/channels.h
+++ b/include/channels.h
@@ -9,6 +9,39 @@
*
*/
+struct UserData
+{
+ UserData()
+ {
+ lastline = NULL;
+ last_use = time(NULL);
+ }
+
+ virtual ~UserData() { delete [] lastline; }
+
+ /* Data validity */
+ time_t last_use;
+
+ /* for flood kicker */
+ int16 lines;
+ time_t last_start;
+
+ /* for repeat kicker */
+ char *lastline;
+ int16 times;
+};
+
+struct UserContainer
+{
+ User *user;
+ UserData *ud;
+
+ UserContainer(User *u) : user(u) { ud = new UserData; }
+ virtual ~UserContainer() { delete ud; }
+};
+
+typedef std::list<UserContainer *> CUserList;
+
enum ChannelFlags
{
/* Channel still exists when emptied */
@@ -24,6 +57,9 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlags>
*/
std::map<ChannelModeName, std::string> Params;
+ /* Modes set on the channel */
+ std::bitset<128> modes;
+
public:
/** Default constructor
* @param name The channel name
@@ -42,14 +78,13 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlags>
char *topic;
std::string topic_setter;
time_t topic_time; /* When topic was set */
- std::bitset<128> modes;
EList *bans;
EList *excepts;
EList *invites;
- struct c_userlist *users;
- uint16 usercount;
+ /* List of users in the channel */
+ CUserList users;
BanData *bd;
@@ -74,8 +109,12 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlags>
*/
void DeleteUser(User *u);
- /**
- * See if a channel has a mode
+ /** See if the channel has any modes at all
+ * @return true or false
+ */
+ inline const bool HasModes() const { return modes.count(); }
+
+ /** See if a channel has a mode
* @param Name The mode name
* @return true or false
*/
diff --git a/include/extern.h b/include/extern.h
index a46894fa2..37fc40144 100644
--- a/include/extern.h
+++ b/include/extern.h
@@ -111,7 +111,7 @@ E Entry *elist_find_mask(EList *list, const char *mask);
E long get_memuse(EList *list);
-#define whosends(ci) ((!(ci) || !((ci)->botflags.HasFlag(BS_SYMBIOSIS)) || !(ci)->bi || !(ci)->c || (ci)->c->usercount < Config.BSMinUsers) ? findbot(Config.s_ChanServ) : (ci)->bi)
+#define whosends(ci) ((!(ci) || !((ci)->botflags.HasFlag(BS_SYMBIOSIS)) || !(ci)->bi || !(ci)->c || (ci)->c->users.size() < Config.BSMinUsers) ? findbot(Config.s_ChanServ) : (ci)->bi)
/**** chanserv.c ****/
diff --git a/include/services.h b/include/services.h
index 7483e591e..6a2c748c4 100644
--- a/include/services.h
+++ b/include/services.h
@@ -360,7 +360,6 @@ class Channel;
struct EList;
typedef struct bandata_ BanData;
-typedef struct userdata_ UserData;
typedef struct mailinfo_ MailInfo;
typedef struct akill_ Akill;
typedef struct sxline_ SXLine;
@@ -804,28 +803,6 @@ struct bandata_ {
int16 ttb[TTB_SIZE];
};
-/* This structure stocks information on every user that will be used by
- * BotServ. */
-
-struct userdata_ {
- /* Data validity */
- time_t last_use;
-
- /* for flood kicker */
- int16 lines;
- time_t last_start;
-
- /* for repeat kicker */
- char *lastline;
- int16 times;
-};
-
-struct c_userlist {
- struct c_userlist *next, *prev;
- User *user;
- UserData *ud;
-};
-
#include "channels.h"
/** Channelban type flags
diff --git a/include/users.h b/include/users.h
index 80bf33114..03dad2e55 100644
--- a/include/users.h
+++ b/include/users.h
@@ -9,12 +9,17 @@
*
*/
-struct u_chanlist {
- struct u_chanlist *next, *prev;
+struct ChannelContainer
+{
Channel *chan;
- int16 status; /* Associated flags; see CSTATUS_* below. */
+ int16 status;
+
+ ChannelContainer(Channel *c) : chan(c) { status = 0; }
+ virtual ~ChannelContainer() { }
};
+typedef std::list<ChannelContainer *> UChannelList;
+
/* Online user and channel data. */
class CoreExport User : public Extensible
{
@@ -44,7 +49,8 @@ class CoreExport User : public Extensible
int isSuperAdmin; /* is SuperAdmin on or off? */
- struct u_chanlist *chans; /* Channels user has joined */
+ /* Channels the user is in */
+ UChannelList chans;
unsigned short invalid_pw_count; /* # of invalid password attempts */
time_t invalid_pw_time; /* Time of last invalid password */