Sfoglia il codice sorgente

* Converted over cfg_struct to hub/leaf mix

svn: 1832
Bryan Drewery 21 anni fa
parent
commit
950e09b829
4 ha cambiato i file con 69 aggiunte e 208 eliminazioni
  1. 42 167
      src/cfg.c
  2. 4 4
      src/cfg.h
  3. 13 21
      src/cmds.c
  4. 10 16
      src/mod/ctcp.mod/ctcp.c

+ 42 - 167
src/cfg.c

@@ -21,10 +21,8 @@
 #include "tandem.h"
 #include "src/mod/channels.mod/channels.h"
 #include "src/mod/ctcp.mod/ctcp.h"
-#ifdef LEAF
 #include "src/chanprog.h"
 #include "src/mod/server.mod/server.h"
-#endif /* LEAF */
 #include "botnet.h"
 #include <net/if.h>
 
@@ -36,71 +34,48 @@ struct cfg_entry 		**cfg = NULL;
 char 				cmdprefix = '+';	/* This is the prefix for msg/channel cmds */
 struct cmd_pass 		*cmdpass = NULL;
 
-#ifdef HUB
 static void chanset_describe(struct cfg_entry * entry, int idx) {
   dprintf(idx, STR("chanset is a list of default options for when a channel is added. Same format as .chanset.\n"));
 }
-#endif /* HUB */
 
-#ifdef LEAF
 static void chanset_changed(struct cfg_entry *entry, int *valid) {
   if (entry->ldata)
     strlcpy(cfg_glob_chanset, (char *) entry->ldata, 512);
   else if (entry->gdata)
     strlcpy(cfg_glob_chanset, (char *) entry->gdata, 512);
 }
-#endif /* LEAF */
 
 struct cfg_entry CFG_CHANSET = {
-	"chanset", CFGF_LOCAL | CFGF_GLOBAL, NULL, NULL, 
-#ifdef LEAF
-	chanset_changed, chanset_changed
-#else
-	NULL, NULL, chanset_describe
-#endif /* LEAF */
+	"chanset", CFGF_LOCAL | CFGF_GLOBAL | CFGF_LEAF, NULL, NULL, 
+	chanset_changed, chanset_changed, chanset_describe
 };
 
-#ifdef HUB
 static void servport_describe(struct cfg_entry * entry, int idx) {
   dprintf(idx, STR("servport is the default port to use for server connections.\n"));
 }
-#endif /* HUB */
 
-#ifdef LEAF
 static void servport_changed(struct cfg_entry *entry, int *valid) {
   if (entry->ldata)
     default_port = atoi(entry->ldata);
   else if (entry->gdata)
     default_port = atoi(entry->gdata);
 }
-#endif /* LEAF */
 
 struct cfg_entry CFG_SERVPORT = {
-	"servport", CFGF_LOCAL | CFGF_GLOBAL, NULL, NULL, 
-#ifdef LEAF
-	servport_changed, servport_changed
-#else
-	NULL, NULL, servport_describe
-#endif /* LEAF */
+	"servport", CFGF_LOCAL | CFGF_GLOBAL | CFGF_LEAF, NULL, NULL, 
+	servport_changed, servport_changed, servport_describe
 };
 
-#ifdef HUB
 static void authkey_describe(struct cfg_entry *entry, int idx) {
   dprintf(idx, 
   STR("authkey is used for authing, give to your users if they are to use DCC chat or IRC cmds. (can be bot specific)\n"));
 }
-#endif /* HUB */
 
 struct cfg_entry CFG_AUTHKEY = {
 	"authkey", CFGF_LOCAL | CFGF_GLOBAL, NULL, NULL,
-#ifdef LEAF
-	NULL, NULL
-#else
 	NULL, NULL, authkey_describe
-#endif /* LEAF */
 };
 
-#ifdef HUB
 static void msgcmds_describe(struct cfg_entry *entry, int idx) {
   if (entry == &CFG_MSGOP)
     dprintf(idx, STR("msgop defines the cmd for opping via msging the bot (leave blank to disable)\n"));
@@ -111,63 +86,41 @@ static void msgcmds_describe(struct cfg_entry *entry, int idx) {
   else if (entry == &CFG_MSGIDENT)
     dprintf(idx, STR("msgident defines the cmd for identing via msging the bot (leave blank to disable)\n"));
 }
-#endif /* HUB */
 
 struct cfg_entry CFG_MSGOP = {
 	"msgop", CFGF_LOCAL | CFGF_GLOBAL, NULL, NULL,
-	NULL, NULL
-#ifdef HUB
-	, msgcmds_describe
-#endif /* HUB */
-
+	NULL, NULL, msgcmds_describe
 };
 
 struct cfg_entry CFG_MSGPASS = {
 	"msgpass", CFGF_LOCAL | CFGF_GLOBAL, NULL, NULL,
-	NULL, NULL
-#ifdef HUB
-	, msgcmds_describe
-#endif /* HUB */
+	NULL, NULL, msgcmds_describe
 };
 
 struct cfg_entry CFG_MSGINVITE = {
 	"msginvite", CFGF_LOCAL | CFGF_GLOBAL, NULL, NULL,
-	NULL, NULL
-#ifdef HUB
-	, msgcmds_describe
-#endif /* HUB */
+	NULL, NULL, msgcmds_describe
 };
 
 struct cfg_entry CFG_MSGIDENT = {
 	"msgident", CFGF_LOCAL | CFGF_GLOBAL, NULL, NULL,
-	NULL, NULL
-#ifdef HUB
-	, msgcmds_describe
-#endif /* HUB */
+	NULL, NULL, msgcmds_describe
 };
 
-#ifdef HUB
 static void cmdprefix_describe(struct cfg_entry *entry, int idx) {
   dprintf(idx, STR("cmdprefix is the prefix character used for msg cmds, ie: !op or .op\n"));
 }
-#endif /* HUB */
 
-#ifdef LEAF
 static void cmdprefix_changed(struct cfg_entry *entry, int *valid) {
   if (entry->ldata)
     cmdprefix = entry->ldata[0];
   else if (entry->gdata)
     cmdprefix = entry->gdata[0];
 }
-#endif /* LEAF */
 
 struct cfg_entry CFG_CMDPREFIX = {
-	"cmdprefix", CFGF_LOCAL | CFGF_GLOBAL, NULL, NULL,
-#ifdef LEAF
-	cmdprefix_changed, cmdprefix_changed
-#else
-	NULL, NULL, cmdprefix_describe
-#endif /* LEAF */
+	"cmdprefix", CFGF_LOCAL | CFGF_GLOBAL | CFGF_LEAF, NULL, NULL,
+	cmdprefix_changed, cmdprefix_changed, cmdprefix_describe
 };
 
 int deflag_translate(const char *buf)
@@ -257,7 +210,6 @@ void deflag_user(struct userrec *u, int why, char *msg, struct chanset_t *chan)
   }
 }
 
-#ifdef HUB
 static void misc_describe(struct cfg_entry *cfgent, int idx)
 {
   int i = 0;
@@ -282,7 +234,6 @@ static void misc_describe(struct cfg_entry *cfgent, int idx)
   if (!i)
     dprintf(idx, "Valid settings are: ignore, warn, die, reject, suicide\n");
 }
-#endif /* HUB */
 
 static void fork_lchanged(struct cfg_entry * cfgent, int * valid) {
   if (!cfgent->ldata)
@@ -298,18 +249,13 @@ static void fork_gchanged(struct cfg_entry * cfgent, int * valid) {
     *valid = 0;
 }
 
-#ifdef HUB
 static void fork_describe(struct cfg_entry * cfgent, int idx) {
   dprintf(idx, STR("fork-interval is number of seconds in between each fork() call made by the bot, to change process ID and reset cpu usage counters.\n"));
 }
-#endif /* HUB */
 
 struct cfg_entry CFG_FORKINTERVAL = {
 	"fork-interval", CFGF_GLOBAL | CFGF_LOCAL, NULL, NULL,
-	fork_gchanged, fork_lchanged
-#ifdef HUB
-	, fork_describe
-#endif /* HUB */
+	fork_gchanged, fork_lchanged, fork_describe
 };
 
 static void detect_lchanged(struct cfg_entry * cfgent, int * valid) {
@@ -331,49 +277,30 @@ static void detect_gchanged(struct cfg_entry * cfgent, int * valid) {
 
 struct cfg_entry CFG_LOGIN = {
 	"login", CFGF_GLOBAL | CFGF_LOCAL, NULL, NULL,
-	detect_gchanged, detect_lchanged
-#ifdef HUB
-	, misc_describe
-#endif /* HUB */
+	detect_gchanged, detect_lchanged, misc_describe
 };
 struct cfg_entry CFG_HIJACK = {
 	"hijack", CFGF_GLOBAL | CFGF_LOCAL, NULL, NULL,
-	detect_gchanged, detect_lchanged
-#ifdef HUB
-	, misc_describe
-#endif /* HUB */
+	detect_gchanged, detect_lchanged, misc_describe
 };
 struct cfg_entry CFG_TRACE = {
 	"trace", CFGF_GLOBAL | CFGF_LOCAL, NULL, NULL,
-	detect_gchanged, detect_lchanged
-#ifdef HUB
-	, misc_describe
-#endif /* HUB */
+	detect_gchanged, detect_lchanged, misc_describe
 };
 struct cfg_entry CFG_PROMISC = {
 	"promisc", CFGF_GLOBAL | CFGF_LOCAL, NULL, NULL,
-	detect_gchanged, detect_lchanged
-#ifdef HUB
-	, misc_describe
-#endif /* HUB */
+	detect_gchanged, detect_lchanged, misc_describe
 };
 struct cfg_entry CFG_BADPROCESS = {
 	"bad-process", CFGF_GLOBAL | CFGF_LOCAL, NULL, NULL,
-	detect_gchanged, detect_lchanged
-#ifdef HUB
-	, misc_describe
-#endif /* HUB */
+	detect_gchanged, detect_lchanged, misc_describe
 };
 
 struct cfg_entry CFG_PROCESSLIST = {
 	"process-list", CFGF_GLOBAL | CFGF_LOCAL, NULL, NULL,
-	NULL, NULL
-#ifdef HUB
-	, misc_describe
-#endif /* HUB */
+	NULL, NULL, misc_describe
 };
 
-#ifdef LEAF
 static void servers_changed(struct cfg_entry * entry, int * valid) {
   if (!strcmp(entry->name, "servers")) {
     if (conf.bot->net.host6 || conf.bot->net.ip6) /* we want to use the servers6 entry. */
@@ -395,36 +322,24 @@ static void servers_changed(struct cfg_entry * entry, int * valid) {
   add_server(p);
   free(p);
 }
-#endif /* LEAF */
 
-#ifdef HUB
 static void servers_describe(struct cfg_entry * entry, int idx) {
   if (!strcmp(entry->name, "servers")) 
     dprintf(idx, STR("servers is a comma-separated list of servers the bot will use\n"));
   else
     dprintf(idx, STR("servers6 is a comma-separated list of servers the bot will use (FOR IPv6)\n"));
 }
-#endif /* HUB */
 
 struct cfg_entry CFG_SERVERS = {
-	"servers", CFGF_LOCAL | CFGF_GLOBAL, NULL, NULL,
-#ifdef LEAF
-	servers_changed, servers_changed
-#else
-	NULL, NULL, servers_describe
-#endif /* LEAF */
+	"servers", CFGF_LOCAL | CFGF_GLOBAL | CFGF_LEAF, NULL, NULL,
+	servers_changed, servers_changed, servers_describe
 };
 
 struct cfg_entry CFG_SERVERS6 = {
-	"servers6", CFGF_LOCAL | CFGF_GLOBAL, NULL, NULL,
-#ifdef LEAF
-	servers_changed, servers_changed
-#else
-	NULL, NULL, servers_describe
-#endif /* LEAF */
+	"servers6", CFGF_LOCAL | CFGF_GLOBAL | CFGF_LEAF, NULL, NULL,
+	servers_changed, servers_changed, servers_describe
 };
 
-#ifdef LEAF
 static void nick_changed(struct cfg_entry * entry, int * valid) {
   char *p = NULL;
 
@@ -441,63 +356,42 @@ static void nick_changed(struct cfg_entry * entry, int * valid) {
   if (server_online)
     dprintf(DP_SERVER, "NICK %s\n", origbotname);
 }
-#endif /* LEAF */
 
-#ifdef HUB
 static void nick_describe(struct cfg_entry * entry, int idx) {
   dprintf(idx, STR("nick is the bots preferred nick when connecting/using .resetnick\n"));
 }
-#endif /* HUB */
 
 struct cfg_entry CFG_NICK = {
-	"nick", CFGF_LOCAL | CFGF_GLOBAL, NULL, NULL,
-#ifdef LEAF
-	nick_changed, nick_changed
-#else
-	NULL, NULL, nick_describe
-#endif /* LEAF */
+	"nick", CFGF_LOCAL | CFGF_GLOBAL | CFGF_LEAF, NULL, NULL,
+	nick_changed, nick_changed, nick_describe
 };
 
-#ifdef HUB
 static void realname_describe(struct cfg_entry * entry, int idx) {
   dprintf(idx, STR("realname is the bots \"real name\" when connecting\n"));
 }
-#endif /* HUB */
 
-#ifdef LEAF
 static void realname_changed(struct cfg_entry * entry, int * valid) {
   if (entry->ldata)
     strlcpy(botrealname, (char *) entry->ldata, 121);
   else if (entry->gdata)
     strlcpy(botrealname, (char *) entry->gdata, 121);
 }
-#endif /* LEAF */
 
 struct cfg_entry CFG_REALNAME = {
-	"realname", CFGF_LOCAL | CFGF_GLOBAL, NULL, NULL,
-#ifdef LEAF
-	realname_changed, realname_changed
-#else
-	NULL, NULL, realname_describe
-#endif /* LEAF */
+	"realname", CFGF_LOCAL | CFGF_GLOBAL | CFGF_LEAF, NULL, NULL,
+	realname_changed, realname_changed, realname_describe
 };
 
-#ifdef HUB
 static void dccauth_describe(struct cfg_entry *cfgent, int idx)
 {
   dprintf(idx, STR("dccauth is boolean (0 or 1). Set to use auth checking on dcc/telnet login.\n"));
 }
-#endif /* HUB */
 
 struct cfg_entry CFG_DCCAUTH = {
 	"dccauth", CFGF_GLOBAL | CFGF_LOCAL, NULL, NULL,
-	NULL, NULL
-#ifdef HUB
-	, dccauth_describe
-#endif /* HUB */
+	NULL, NULL, dccauth_describe
 };
 
-#ifdef HUB
 static void getin_describe(struct cfg_entry *cfgent, int idx)
 {
   if (!strcmp(cfgent->name, "op-bots"))
@@ -521,7 +415,6 @@ static void getin_describe(struct cfg_entry *cfgent, int idx)
     putlog(LOG_ERRORS, "*", STR("getin_describe() called with unknown config entry %s"), cfgent->name);
   }
 }
-#endif /* HUB */
 
 static void getin_changed(struct cfg_entry *cfgent, int *valid)
 {
@@ -599,58 +492,37 @@ static void getin_changed(struct cfg_entry *cfgent, int *valid)
 
 struct cfg_entry CFG_OPBOTS = {
 	"op-bots", CFGF_GLOBAL, NULL, NULL,
-	getin_changed, NULL
-#ifdef HUB
-	, getin_describe
-#endif /* HUB */
+	getin_changed, NULL, getin_describe
 };
 
 struct cfg_entry CFG_FIGHTTHRESHOLD = {
 	"fight-threshold", CFGF_GLOBAL, NULL, NULL,
-	getin_changed, NULL
-#ifdef HUB
-	, getin_describe
-#endif /* HUB */
+	getin_changed, NULL, getin_describe
 };
 
 struct cfg_entry CFG_CLOSETHRESHOLD = {
 	"close-threshold", CFGF_GLOBAL, NULL, NULL,
-	getin_changed, NULL
-#ifdef HUB
-	, getin_describe
-#endif /* HUB */
+	getin_changed, NULL, getin_describe
 };
 
 struct cfg_entry CFG_KILLTHRESHOLD = {
 	"kill-threshold", CFGF_GLOBAL, NULL, NULL,
-	getin_changed, NULL
-#ifdef HUB
-	, getin_describe
-#endif /* HUB */
+	getin_changed, NULL, getin_describe
 };
 
 struct cfg_entry CFG_INBOTS = {
 	"in-bots", CFGF_GLOBAL, NULL, NULL,
-	getin_changed, NULL
-#ifdef HUB
-	, getin_describe
-#endif /* HUB */
+	getin_changed, NULL, getin_describe
 };
 
 struct cfg_entry CFG_LAGTHRESHOLD = {
 	"lag-threshold", CFGF_GLOBAL, NULL, NULL,
-	getin_changed, NULL
-#ifdef HUB
-	, getin_describe
-#endif /* HUB */
+	getin_changed, NULL, getin_describe
 };
 
 struct cfg_entry CFG_OPREQUESTS = {
 	"op-requests", CFGF_GLOBAL, NULL, NULL,
-	getin_changed, NULL
-#ifdef HUB
-	, getin_describe
-#endif /* HUB */
+	getin_changed, NULL, getin_describe
 };
 
 void add_cfg(struct cfg_entry *entry)
@@ -693,9 +565,15 @@ static struct cfg_entry *check_can_set_cfg(char *target, char *entryname)
 void set_cfg_str(char *target, char *entryname, char *data)
 {
   struct cfg_entry *entry = NULL;
+  bool dochange = 0;
 
   if (!(entry = check_can_set_cfg(target, entryname)))
     return;
+
+  if (!(entry->flags & (CFGF_HUB|CFGF_LEAF)) ||
+     (conf.bot->hub && entry->flags & CFGF_HUB) || (!conf.bot->hub && entry->flags & CFGF_LEAF))
+    dochange = 1;
+
   if (data && !strcmp(data, "-"))
     data = NULL;
   if (data && (strlen(data) >= 1024))
@@ -710,7 +588,7 @@ void set_cfg_str(char *target, char *entryname, char *data)
         entry->ldata = strdup(data);
       } else
         entry->ldata = NULL;
-      if (entry->localchanged) {
+      if (dochange && entry->localchanged) {
         int valid = 1;
 
         /* entry->localchanged(entry, olddata, &valid); */
@@ -739,7 +617,7 @@ void set_cfg_str(char *target, char *entryname, char *data)
       entry->gdata = strdup(data);
     } else
       entry->gdata = NULL;
-    if (entry->globalchanged) {
+    if (dochange && entry->globalchanged) {
       int valid = 1;
 
       /* entry->globalchanged(entry, olddata, &valid); */
@@ -760,10 +638,7 @@ void set_cfg_str(char *target, char *entryname, char *data)
 
 struct cfg_entry CFG_MOTD = { 
 	"motd", CFGF_GLOBAL, NULL, NULL, 
-	NULL, NULL
-#ifdef HUB
-	, NULL
-#endif /* HUB */
+	NULL, NULL, NULL
 };
 
 void init_cfg()

+ 4 - 4
src/cfg.h

@@ -5,8 +5,10 @@
 #  include "config.h"
 #endif
 
-#define CFGF_GLOBAL  1          /* Accessible as .config */
-#define CFGF_LOCAL   2          /* Accessible as .botconfig */
+#define CFGF_GLOBAL  BIT0          /* Accessible as .config */
+#define CFGF_LOCAL   BIT1          /* Accessible as .botconfig */
+#define CFGF_HUB     BIT2
+#define CFGF_LEAF    BIT3
 
 typedef struct cfg_entry {
   char *name;
@@ -15,9 +17,7 @@ typedef struct cfg_entry {
   char *ldata;
   void (*globalchanged) (struct cfg_entry *, int *valid);
   void (*localchanged) (struct cfg_entry *, int *valid);
-#ifdef HUB
   void (*describe) (struct cfg_entry *, int idx);
-#endif /* HUB */
 } cfg_entry_T;
 
 extern struct cfg_entry CFG_MOTD, CFG_CMDPREFIX, CFG_FORKINTERVAL, CFG_CHANSET, CFG_SERVERS, CFG_SERVERS6, 

+ 13 - 21
src/cmds.c

@@ -219,6 +219,7 @@ static void cmd_config(int idx, char *par)
   char *name = NULL;
   struct cfg_entry *cfgent = NULL;
   int cnt, i;
+  bool describe = conf.bot->hub;
 
   putlog(LOG_CMDS, "*", "#%s# config %s", dcc[idx].nick, par);
   if (!par[0]) {
@@ -230,8 +231,7 @@ static void cmd_config(int idx, char *par)
     dprintf(idx, "Defined config entry names:\n");
     cnt = 0;
     for (i = 0; i < cfg_count; i++) {
-#ifdef HUB
-      if ((cfg[i]->flags & CFGF_GLOBAL) && (cfg[i]->describe)) {
+      if (conf.bot->hub && (cfg[i]->flags & CFGF_GLOBAL) && (cfg[i]->describe)) {
 	if (!cnt) {
           outbuf = (char *) my_realloc(outbuf, 2 + 1);
 	  sprintf(outbuf, "  ");
@@ -244,7 +244,6 @@ static void cmd_config(int idx, char *par)
 	  cnt = 0;
 	}
       }
-#endif /* HUB */
     }
     if (cnt)
       dprintf(idx, "%s\n", outbuf);
@@ -256,12 +255,10 @@ static void cmd_config(int idx, char *par)
   for (i = 0; !cfgent && (i < cfg_count); i++)
     if (!strcmp(cfg[i]->name, name))
       cfgent = cfg[i];
-#ifdef HUB
-  if (!cfgent || !cfgent->describe) {
+  if (describe && (!cfgent || !cfgent->describe)) {
     dprintf(idx, "No such config entry\n");
     return;
   }
-#endif /* HUB */
   if (!isowner(dcc[idx].nick)) {
     int no = 0;
     if (!egg_strcasecmp(name, "authkey"))
@@ -281,9 +278,8 @@ static void cmd_config(int idx, char *par)
     }
   }
   if (!par[0]) {
-#ifdef HUB
-    cfgent->describe(cfgent, idx);
-#endif /* HUB */
+    if (describe)
+      cfgent->describe(cfgent, idx);
     if (!cfgent->gdata)
       dprintf(idx, "No current value\n");
     else {
@@ -312,7 +308,7 @@ static void cmd_botconfig(int idx, char *par)
   struct cfg_entry *cfgent = NULL;
   int i, cnt;
   tand_t *tbot = NULL;
-  bool found = 0, described = 0;
+  bool found = 0, described = 0, describe = conf.bot->hub;
 
   /* botconfig bot [name [value]]  */
   putlog(LOG_CMDS, "*", "#%s# botconfig %s", dcc[idx].nick, par);
@@ -349,8 +345,7 @@ static void cmd_botconfig(int idx, char *par)
 
       if (!entry || !entry[0]) {
         for (i = 0; i < cfg_count; i++) {
-#ifdef HUB
-          if ((cfg[i]->flags & CFGF_LOCAL) && (cfg[i]->describe)) {
+          if (describe && (cfg[i]->flags & CFGF_LOCAL) && (cfg[i]->describe)) {
 	    k = (struct xtra_key *) get_user(&USERENTRY_CONFIG, u2);
             while (k && strcmp(k->key, cfg[i]->name))
               k = k->next;
@@ -359,17 +354,16 @@ static void cmd_botconfig(int idx, char *par)
             else
               dprintf(idx, "  %s: (not set)\n", cfg[i]->name);
           }
-#endif /* HUB */
         }
         continue;
       }
 
       cfgent = NULL;
-#ifdef HUB
-      for (i = 0; !cfgent && (i < cfg_count); i++)
-        if (!strcmp(cfg[i]->name, entry) && (cfg[i]->flags & CFGF_LOCAL) && (cfg[i]->describe))
-          cfgent = cfg[i];
-#endif /* HUB */
+      if (describe) {
+        for (i = 0; !cfgent && (i < cfg_count); i++)
+          if (!strcmp(cfg[i]->name, entry) && (cfg[i]->flags & CFGF_LOCAL) && (cfg[i]->describe))
+            cfgent = cfg[i];
+      }
       if (!cfgent) {
         dprintf(idx, "No such configuration value\n");
         return;
@@ -383,12 +377,10 @@ static void cmd_botconfig(int idx, char *par)
         dprintf(idx, "Now: ");
         write_userfile(idx);
       } else {
-#ifdef HUB
-        if (cfgent->describe && !described) {
+        if (describe && cfgent->describe && !described) {
           described++;
           cfgent->describe(cfgent, idx);
         }
-#endif /* HUB */
       }
       k = (struct xtra_key *) get_user(&USERENTRY_CONFIG, u2);
       while (k && strcmp(k->key, cfgent->name))

+ 10 - 16
src/mod/ctcp.mod/ctcp.c

@@ -619,13 +619,11 @@ static cmd_t myctcp[] =
 };
 #endif /* LEAF */
 
-#ifdef HUB
 static void cloak_describe(struct cfg_entry *cfgent, int idx)
 {
   dprintf(idx, STR("cloak-script decides which BitchX script the bot cloaks. If set to 0, a random script will be cloaked.\n"));
   dprintf(idx, STR("Available: 1=plain bitchx, 2=crackrock, 3=neonapple, 4=tunnelvision, 5=argon, 6=evolver, 7=prevail 8=cypress 9=mIRC\n"));
 }
-#endif /* HUB */
 
 static void cloak_changed(struct cfg_entry *cfgent, int *valid)
 {
@@ -634,25 +632,21 @@ static void cloak_changed(struct cfg_entry *cfgent, int *valid)
   if (!(p = cfgent->ldata ? cfgent->ldata : cfgent->gdata))
     return;
 
-  int i = atoi(p);
+  if (!conf.bot->hub) {
+    int i = atoi(p);
 
-#ifdef LEAF
-  if (i == 0)
-    i = randint(CLOAK_COUNT) + 1;
-#endif /* LEAF */
-  if ((*valid = ((i >= 0) && (i <= CLOAK_COUNT))))
-    cloak_script = i;
-#ifdef LEAF
-  scriptchanged();
-#endif /* LEAF */
+    if (i == 0)
+      i = randint(CLOAK_COUNT) + 1;
+    if ((*valid = ((i >= 0) && (i <= CLOAK_COUNT))))
+      cloak_script = i;
+
+    scriptchanged();
+  }
 }
 
 struct cfg_entry CFG_CLOAK_SCRIPT = {
 	"cloak-script", CFGF_GLOBAL | CFGF_LOCAL, NULL, NULL,
-	cloak_changed, cloak_changed
-#ifdef HUB
-	, cloak_describe
-#endif /* HUB */
+	cloak_changed, cloak_changed, cloak_describe
 };