fixed small unbind problem with these temporarily added commands
authorpk910 <philipp@zoelle1.de>
Sun, 30 Oct 2011 23:33:09 +0000 (00:33 +0100)
committerpk910 <philipp@zoelle1.de>
Sun, 30 Oct 2011 23:33:09 +0000 (00:33 +0100)
src/cmd_neonserv_unbind.c
src/modcmd.c
src/modcmd.h

index 67153d036a759e1bfed9249364d184dee4de1ff2..43f6c7272bb9bbb5b59ce9326eb54e7885d17ed5 100644 (file)
 CMD_BIND(neonserv_cmd_unbind) {
     MYSQL_RES *res;
     MYSQL_ROW row;
+    struct cmd_binding *cbind = find_cmd_binding(client->botid, argv[0]);
     printf_mysql_query("SELECT `function` FROM `bot_binds` WHERE `botclass` = '%d' AND `command` = '%s'", client->botid, escape_string(argv[0]));
     res = mysql_use();
-    if ((row = mysql_fetch_row(res)) == NULL) {
+    if ((row = mysql_fetch_row(res)) == NULL && (!cbind || !(cbind->flags & CMDFLAG_TEMPONARY_BIND))) {
         reply(getTextBot(), user, "NS_UNBIND_NOT_FOUND", argv[0]);
         return;
     }
@@ -40,7 +41,8 @@ CMD_BIND(neonserv_cmd_unbind) {
         }
     }
     unbind_cmd(client->botid, argv[0]);
-    printf_mysql_query("DELETE FROM `bot_binds` WHERE `id` = '%s'", row[0]);
+    if((!cbind || !(cbind->flags & CMDFLAG_TEMPONARY_BIND)))
+        printf_mysql_query("DELETE FROM `bot_binds` WHERE `id` = '%s'", row[0]);
     reply(getTextBot(), user, "NS_UNBIND_DONE", argv[0]);
     logEvent(event);
 }
index 90e46e069354775aea37408db06757ebd1e21a29..3f480cda6b8fcac491f15397f4e84f0d632a206a 100644 (file)
@@ -718,8 +718,9 @@ void bind_unbound_required_functions(int botid) {
                 if(found)
                     break;
             }
-            if(!found) {
-                bind_cmd_to_function(botid, cmdfunc->name, cmdfunc);
+            if(!found && bind_cmd_to_function(botid, cmdfunc->name, cmdfunc)) {
+                cbind = find_cmd_binding(botid, cmdfunc->name);
+                cbind->flags |= CMDFLAG_TEMPONARY_BIND;
             }
         }
     }
index 4c8da64da1942b6304bb9ed7a8c97fba6d6bbc5b..a2d8447f82a6417e0253a0d88ac1d787fb12fbc4 100644 (file)
@@ -32,6 +32,7 @@
 #define CMDFLAG_OPLOG                   0x0200
 #define CMDFLAG_EMPTY_ARGS              0x0400
 #define CMDFLAG_REQUIRED                0x0800
+#define CMDFLAG_TEMPONARY_BIND          0x1000
 
 struct ClientSocket;
 struct UserNode;