diff --git a/Changes b/Changes index 784cb8b36..e1f6eb999 100644 --- a/Changes +++ b/Changes @@ -2494,3 +2494,8 @@ seen. gmtime warning still there - Fix for +L without +l desynch on serverlinking. - Fixed a problem regarding module hooks, if a hook was called within a hook it could cause problems (like pre connect hook -> exit_client -> quit hook). +- Changed some useless stuff. +- Enabled EXTCMODE by default, I presume it's stable but can't promise anything. +- Module coders: changed 'allowed' callback function for umodes&snomasks, + from 'aClient *sptr' to 'aClient *sptr, int what'. + 'what' will be MODE_ADD if trying to add and MODE_DEL if trying to remove. diff --git a/include/config.h b/include/config.h index 56a5238e6..b0132e171 100644 --- a/include/config.h +++ b/include/config.h @@ -496,9 +496,8 @@ /* * Extended channel modes. This extends the channel modes with yet another * 32 possible modes which can also be used in modules. - * This is currently considered experimental however. */ -#undef EXTCMODE +#define EXTCMODE /* * New channelmode +f system which allows flood control for: diff --git a/include/h.h b/include/h.h index ec19fa7cc..c32d37632 100644 --- a/include/h.h +++ b/include/h.h @@ -342,13 +342,13 @@ extern int m_umode(aClient *, aClient *, int, char **); extern int m_names(aClient *, aClient *, int, char **); extern int m_server_estab(aClient *); extern void umode_init(void); -extern long umode_get(char, int, int (*)(aClient *)); +extern long umode_get(char, int, int (*)(aClient *, int)); #define UMODE_GLOBAL 1 #define UMODE_LOCAL 0 #define umode_lget(x) umode_get(x, 0, 0); #define umode_gget(x) umode_get(x, 1, 0); -extern int umode_allow_all(aClient *sptr); -extern int umode_allow_opers(aClient *sptr); +extern int umode_allow_all(aClient *sptr, int what); +extern int umode_allow_opers(aClient *sptr, int what); extern int umode_delete(char ch, long val); extern void send_umode(aClient *, aClient *, long, long, char *); extern void send_umode_out(aClient *, aClient *, long); diff --git a/include/modules.h b/include/modules.h index 25f002844..91510c2f4 100644 --- a/include/modules.h +++ b/include/modules.h @@ -101,7 +101,7 @@ typedef struct { typedef struct { long mode; char flag; - int (*allowed)(aClient *sptr); + int (*allowed)(aClient *sptr, int what); char unloaded; Module *owner; } Umode; @@ -109,7 +109,7 @@ typedef struct { typedef struct { long mode; char flag; - int (*allowed)(aClient *sptr); + int (*allowed)(aClient *sptr, int what); char unloaded; Module *owner; } Snomask; diff --git a/include/struct.h b/include/struct.h index 8adf0a4f7..ebede4a6d 100644 --- a/include/struct.h +++ b/include/struct.h @@ -759,10 +759,10 @@ extern Cmode *Channelmode_Table; extern unsigned short Channelmode_highest; #endif -extern Umode *UmodeAdd(Module *module, char ch, int options, int (*allowed)(aClient *sptr), long *mode); +extern Umode *UmodeAdd(Module *module, char ch, int options, int (*allowed)(aClient *sptr, int what), long *mode); extern void UmodeDel(Umode *umode); -extern Snomask *SnomaskAdd(Module *module, char ch, int (*allowed)(aClient *sptr), long *mode); +extern Snomask *SnomaskAdd(Module *module, char ch, int (*allowed)(aClient *sptr, int what), long *mode); extern void SnomaskDel(Snomask *sno); #ifdef EXTCMODE diff --git a/src/extcmodes.c b/src/extcmodes.c index 2218aceab..c53df0ed0 100644 --- a/src/extcmodes.c +++ b/src/extcmodes.c @@ -79,7 +79,6 @@ int i; if (!Channelmode_Table[i].paracount && Channelmode_Table[i].flag) *p++ = Channelmode_Table[i].flag; *p = '\0'; - printf("dect: %s/%s/%s/%s\n", extchmstr[0], extchmstr[1], extchmstr[2], extchmstr[3]); } diff --git a/src/s_user.c b/src/s_user.c index c5c86f6ad..c31e7872c 100644 --- a/src/s_user.c +++ b/src/s_user.c @@ -802,7 +802,9 @@ extern int register_user(aClient *cptr, aClient *sptr, char *nick, char *usernam cptr->last = TStime(); parv[0] = sptr->name; parv[1] = parv[2] = NULL; - + nick = sptr->name; /* <- The data is always the same, but the pointer is sometimes not, + * I need this for one of my modules, so do not remove! ;) -- Syzop */ + if (MyConnect(sptr)) { if ((i = check_client(sptr))) { @@ -1788,6 +1790,7 @@ CMD_FUNC(m_nick) if (register_user(cptr, sptr, nick, sptr->user->username, NULL, NULL) == FLUSH_BUFFER) return FLUSH_BUFFER; + strcpy(nick, sptr->name); /* don't ask, but I need this. do not remove! -- Syzop */ update_watch = 0; newusr = 1; } @@ -2193,7 +2196,7 @@ CMD_FUNC(m_ison) } void set_snomask(aClient *sptr, char *snomask) { - int what = MODE_ADD; + int what = MODE_ADD; /* keep this an int. -- Syzop */ char *p; int i; if (snomask == NULL) { @@ -2216,7 +2219,7 @@ void set_snomask(aClient *sptr, char *snomask) { continue; if (*p == Snomask_Table[i].flag) { - if (Snomask_Table[i].allowed && !Snomask_Table[i].allowed(sptr)) + if (Snomask_Table[i].allowed && !Snomask_Table[i].allowed(sptr,what)) continue; if (what == MODE_ADD) sptr->user->snomask |= Snomask_Table[i].mode; @@ -2229,7 +2232,7 @@ void set_snomask(aClient *sptr, char *snomask) { } void create_snomask(aClient *sptr, anUser *user, char *snomask) { - int what = MODE_ADD; + int what = MODE_ADD; /* keep this an int. -- Syzop */ char *p; int i; if (snomask == NULL) { @@ -2252,7 +2255,7 @@ void create_snomask(aClient *sptr, anUser *user, char *snomask) { continue; if (*p == Snomask_Table[i].flag) { - if (Snomask_Table[i].allowed && !Snomask_Table[i].allowed(sptr)) + if (Snomask_Table[i].allowed && !Snomask_Table[i].allowed(sptr,what)) continue; if (what == MODE_ADD) user->snomask |= Snomask_Table[i].mode; @@ -2276,6 +2279,7 @@ CMD_FUNC(m_umode) char **p, *m; aClient *acptr; int what, setflags, setsnomask = 0; + /* (small note: keep 'what' as an int. -- Syzop). */ short rpterror = 0, umode_restrict_err = 0, chk_restrict = 0, modex_err = 0; what = MODE_ADD; @@ -2416,13 +2420,11 @@ CMD_FUNC(m_umode) { if (*m == Usermode_Table[i].flag) { + if (Usermode_Table[i].allowed) + if (!Usermode_Table[i].allowed(sptr,what)) + break; if (what == MODE_ADD) - { - if (Usermode_Table[i].allowed) - if (!Usermode_Table[i].allowed(sptr)) - break; sptr->umodes |= Usermode_Table[i].mode; - } else sptr->umodes &= ~Usermode_Table[i].mode; break; diff --git a/src/umodes.c b/src/umodes.c index 7df31cb30..b35a66935 100644 --- a/src/umodes.c +++ b/src/umodes.c @@ -175,7 +175,7 @@ void make_umodestr(void) * Add a usermode with character 'ch', if global is set to 1 the usermode is global * (sent to other servers) otherwise it's a local usermode */ -Umode *UmodeAdd(Module *module, char ch, int global, int (*allowed)(aClient *sptr), long *mode) +Umode *UmodeAdd(Module *module, char ch, int global, int (*allowed)(aClient *sptr, int what), long *mode) { short i = 0; short j = 0; @@ -275,7 +275,7 @@ void UmodeDel(Umode *umode) return; } -Snomask *SnomaskAdd(Module *module, char ch, int (*allowed)(aClient *sptr), long *mode) +Snomask *SnomaskAdd(Module *module, char ch, int (*allowed)(aClient *sptr, int what), long *mode) { short i = 0; short j = 0; @@ -368,12 +368,12 @@ void SnomaskDel(Snomask *sno) return; } -int umode_allow_all(aClient *sptr) +int umode_allow_all(aClient *sptr, int what) { return 1; } -int umode_allow_opers(aClient *sptr) +int umode_allow_opers(aClient *sptr, int what) { return IsAnOper(sptr) ? 1 : 0; } @@ -444,7 +444,7 @@ void unload_all_unused_snomasks() } } -long umode_get(char ch, int options, int (*allowed)(aClient *sptr)) +long umode_get(char ch, int options, int (*allowed)(aClient *sptr, int what)) { long flag; if (UmodeAdd(NULL, ch, options, allowed, &flag))