From 4a4f9e7a00aa6b8e4e5966dacd46b987a49bd532 Mon Sep 17 00:00:00 2001 From: pk910 Date: Mon, 31 Oct 2011 00:33:09 +0100 Subject: [PATCH] fixed small unbind problem with these temporarily added commands --- src/cmd_neonserv_unbind.c | 6 ++++-- src/modcmd.c | 5 +++-- src/modcmd.h | 1 + 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/cmd_neonserv_unbind.c b/src/cmd_neonserv_unbind.c index 67153d0..43f6c72 100644 --- a/src/cmd_neonserv_unbind.c +++ b/src/cmd_neonserv_unbind.c @@ -24,9 +24,10 @@ 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); } diff --git a/src/modcmd.c b/src/modcmd.c index 90e46e0..3f480cd 100644 --- a/src/modcmd.c +++ b/src/modcmd.c @@ -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; } } } diff --git a/src/modcmd.h b/src/modcmd.h index 4c8da64..a2d8447 100644 --- a/src/modcmd.h +++ b/src/modcmd.h @@ -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; -- 2.20.1