added "nowho" parameter to debug userlist and fixed memory leak in DBHelper.c
[NeonServV5.git] / src / cmd_funcmds.c
index 7578f10a0a51b8736ee9f656af19386538dc6704..3f4095ad6f45c4cf0410ec371dcfb4ed23e87231 100644 (file)
@@ -1,5 +1,5 @@
-/* cmd_funcmds.c - NeonServ v5.2
- * Copyright (C) 2011  Philipp Kreil (pk910)
+/* cmd_funcmds.c - NeonServ v5.3
+ * Copyright (C) 2011-2012  Philipp Kreil (pk910)
  * 
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
 #include "ChanNode.h"
 #include "lang.h"
 #include "tools.h"
+#include "DBHelper.h"
 
 static const struct default_language_entry msgtab[] = {
     {"FUN_DICE", "$b%s$b: A $b%d$b shows on the %d-sided die."}, /* {ARGS: "TestUser", 5, 6} */
     {"FUN_DICE_NUM", "I do not understand $b%s$b. Please use a single number above 1."}, /* {ARGS: "bla"} */
     {"FUN_8BALL", "$b%s$b: %s"}, /* {ARGS: "TestUser", "Not a chance."} */
     {"FUN_8BALL_REPLIES", "Not a chance.|In your dreams.|Absolutely!|Could be, could be.|No!"},
-    {"FUN_COOKIE", "gives %1%s a very big chocolate cookie. (%1$s got %2$d cookies - %3$d in this channel)"}, /* {ARGS: "TestUser", 20, 50} */
+    {"FUN_COOKIE", "gives %1$s a very big chocolate cookie. %1$s has got %2$d cookies until now (%3$d in this channel)."}, /* {ARGS: "TestUser", 20, 50} */
     {NULL, NULL}
 };
 
@@ -90,7 +91,7 @@ static void funcmd_reply(const char *text, int type, ...) {
     char sendBuf[MAXLEN];
     int pos;
     sendBuf[0] = '\0';
-    va_start(arg_list, text);
+    va_start(arg_list, type);
     pos = vsnprintf(sendBuf, MAXLEN - 2, formatBuf, arg_list);
     va_end(arg_list);
     if (pos < 0 || pos > (MAXLEN - 2)) pos = MAXLEN - 2;
@@ -198,8 +199,10 @@ CMD_BIND(funcmd_8ball) {
 CMD_BIND(funcmd_cookie) {
     FUNCMD_HEADER;
     if(argc) {
-        if(!(user = getUserByNick(argv[0])))
+        if(!(user = getUserByNick(argv[0]))) {
             reply(current_funcmd.client, current_funcmd.user, "NS_USER_UNKNOWN", argv[0]);
+            return;
+        }
     }
     char *tmp;
     int user_count = ((tmp = getSetting(user, chan, "cookies")) ? atoi(tmp) : 0);