diff --git a/include/common.h b/include/common.h index a666bb932..4a1bbb4be 100644 --- a/include/common.h +++ b/include/common.h @@ -183,10 +183,6 @@ extern MODVAR unsigned char char_atribs[]; #define CHPAR1 "beIqa" #endif /* PREFIX_AQ */ -#define CHPAR2 "k" -#define CHPAR3 "l" -#define CHPAR4 "psmntir" - #ifdef _WIN32 /* * Used to display a string to the GUI interface. diff --git a/src/api-channelmode.c b/src/api-channelmode.c index d741c6020..c4627b6a1 100644 --- a/src/api-channelmode.c +++ b/src/api-channelmode.c @@ -104,22 +104,52 @@ static void make_cmodestr(void) *p = '\0'; } +int sort_cmodes_cmp(char x, char y) +{ + if (x < y) + return 1; + return 0; +} + +void sort_cmodes(void) +{ + int i, j; + Cmode swap; + + /* This sorts the Channelmode_Table alphabetically, + * that is: lower characters first (a-z) and then upper (A-Z) + */ + for (i = 0; i < EXTCMODETABLESZ; i++) + { + for (j = i+1; j < EXTCMODETABLESZ; j++) + { + if (sort_cmodes_cmp(Channelmode_Table[i].mode, Channelmode_Table[j].mode)) + { + memcpy(&swap, &Channelmode_Table[j], sizeof(Cmode)); + memcpy(&Channelmode_Table[j], &Channelmode_Table[i], sizeof(Cmode)); + memcpy(&Channelmode_Table[i], &swap, sizeof(Cmode)); + } + } + } +} + /** Check for changes - if any are detected, we broadcast the change */ void extcmodes_check_for_changes(void) { char chanmodes[256]; ISupport *isup; + //sort_cmodes(); make_cmodestr(); make_extcmodestr(); snprintf(chanmodes, sizeof(chanmodes), "%s%s", CHPAR1, EXPAR1); safe_strdup(me.server->features.chanmodes[0], chanmodes); - snprintf(chanmodes, sizeof(chanmodes), "%s%s", CHPAR2, EXPAR2); + snprintf(chanmodes, sizeof(chanmodes), "%s", EXPAR2); safe_strdup(me.server->features.chanmodes[1], chanmodes); - snprintf(chanmodes, sizeof(chanmodes), "%s%s", CHPAR3, EXPAR3); + snprintf(chanmodes, sizeof(chanmodes), "%s", EXPAR3); safe_strdup(me.server->features.chanmodes[2], chanmodes); - snprintf(chanmodes, sizeof(chanmodes), "%s%s", CHPAR4, EXPAR4); + snprintf(chanmodes, sizeof(chanmodes), "%s", EXPAR4); safe_strdup(me.server->features.chanmodes[3], chanmodes); ircsnprintf(chanmodes, sizeof(chanmodes), "%s,%s,%s,%s", diff --git a/src/api-isupport.c b/src/api-isupport.c index c8bd5ee5c..8267ce8df 100644 --- a/src/api-isupport.c +++ b/src/api-isupport.c @@ -95,7 +95,7 @@ void isupport_init(void) ISupportSet(NULL, "CASEMAPPING", "ascii"); ISupportSet(NULL, "NETWORK", NETWORK_NAME_005); ISupportSetFmt(NULL, "CHANMODES", - CHPAR1 "%s," CHPAR2 "%s," CHPAR3 "%s," CHPAR4 "%s", + CHPAR1 "%s,%s,%s,%s", EXPAR1, EXPAR2, EXPAR3, EXPAR4); ISupportSet(NULL, "PREFIX", CHPFIX); ISupportSet(NULL, "CHANTYPES", "#"); diff --git a/src/conf.c b/src/conf.c index 6acb7a735..ca8eb5e37 100644 --- a/src/conf.c +++ b/src/conf.c @@ -9476,6 +9476,7 @@ void start_listeners(void) /* Actually use configuration */ void config_run(void) { + extcmodes_check_for_changes(); start_listeners(); free_all_config_resources(); } @@ -10766,7 +10767,6 @@ int rehash_internal(Client *client) unload_all_unused_caps(); unload_all_unused_history_backends(); // unload_all_unused_moddata(); -- this will crash - extcmodes_check_for_changes(); umodes_check_for_changes(); charsys_check_for_changes(); loop.rehashing = 0; diff --git a/src/ircd.c b/src/ircd.c index b0799c584..b3cdc2252 100644 --- a/src/ircd.c +++ b/src/ircd.c @@ -1089,7 +1089,6 @@ int InitUnrealIRCd(int argc, char *argv[]) me.local->fd = -1; SetMe(&me); make_server(&me); - extcmodes_check_for_changes(); umodes_check_for_changes(); charsys_check_for_changes(); clicap_init(); diff --git a/src/serv.c b/src/serv.c index c27247243..1d51aa099 100644 --- a/src/serv.c +++ b/src/serv.c @@ -214,8 +214,8 @@ void send_proto(Client *client, ConfigItem_link *aconf) ClientCapabilityFindReal("message-tags") ? "MTAGS" : ""); /* Second line */ - sendto_one(client, NULL, "PROTOCTL CHANMODES=%s%s,%s%s,%s%s,%s%s USERMODES=%s BOOTED=%lld PREFIX=%s SID=%s MLOCK TS=%lld EXTSWHOIS", - CHPAR1, EXPAR1, CHPAR2, EXPAR2, CHPAR3, EXPAR3, CHPAR4, EXPAR4, + sendto_one(client, NULL, "PROTOCTL CHANMODES=%s%s,%s,%s,%s USERMODES=%s BOOTED=%lld PREFIX=%s SID=%s MLOCK TS=%lld EXTSWHOIS", + CHPAR1, EXPAR1, EXPAR2, EXPAR3, EXPAR4, umodestring, (long long)me.local->fake_lag, prefix->value, me.id, (long long)TStime());