Another year is about to end... So we have to update these damn copyright information :P
[NeonServV5.git] / src / cmd_global_commands.c
index 53f90bd4d96f2bd2dcdc358f61fb4edde1cf76b7..426be8b8ddd509821b4ddbc61cbd7267c7d0116a 100644 (file)
@@ -1,5 +1,5 @@
-/* cmd_global_commands.c - NeonServ v5.2
- * Copyright (C) 2011  Philipp Kreil (pk910)
+/* cmd_global_commands.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
@@ -29,27 +29,31 @@ CMD_BIND(global_cmd_commands) {
     struct cmd_binding *cbind;
     int bindcount = 0;
     for(cbind = getAllBinds(NULL); cbind; cbind = getAllBinds(cbind)) {
-        if(cbind->botid == client->botid)
+        if(cbind->botid == client->botid && (cbind->botid || cbind->clientid == client->clientid) && !(cbind->func->flags & CMDFLAG_FUNCMD))
             bindcount++;
     }
     struct cmd_binding *binds[bindcount];
     bindcount = 0;
     for(cbind = getAllBinds(NULL); cbind; cbind = getAllBinds(cbind)) {
-        if(cbind->botid == client->botid)
+        if(cbind->botid == client->botid && (cbind->botid || cbind->clientid == client->clientid) && !(cbind->func->flags & CMDFLAG_FUNCMD))
             binds[bindcount++] = cbind;
     }
     qsort(binds, bindcount, sizeof(struct cmd_binding *), global_cmd_commands_sort);
     int i;
     struct Table *table;
-    table = table_init(4, bindcount + 1, 0);
-    char *content[4];
+    table = table_init(5, bindcount + 1, 0);
+    char *content[5];
     content[0] = get_language_string(user, "NS_COMMANDS_NAME");
     content[1] = get_language_string(user, "NS_COMMANDS_ACCESS");
     content[2] = get_language_string(user, "NS_COMMANDS_GACCESS");
-    content[3] = get_language_string(user, "NS_COMMANDS_FUNCTION");
+    content[3] = get_language_string(user, "NS_COMMANDS_TRIGGERED");
+    content[4] = get_language_string(user, "NS_COMMANDS_FUNCTION");
     table_add(table, content);
     char caccess[5];
     char gaccess[5];
+    char triggered[10];
+    char funcname[MAXLEN];
+    int funcpos;
     for(i = 0; i < bindcount; i++) {
         cbind = binds[i];
         content[0] = cbind->cmd;
@@ -57,7 +61,16 @@ CMD_BIND(global_cmd_commands) {
         content[1] = caccess;
         sprintf(gaccess, "%d", global_cmd_commands_operaccess(cbind));
         content[2] = gaccess;
-        content[3] = cbind->func->name;
+        sprintf(triggered, "%d", cbind->triggered);
+        content[3] = triggered;
+        funcpos = sprintf(funcname, "%s", cbind->func->name);
+        if(cbind->paramcount) {
+            int j;
+            for(j = 0; j < cbind->paramcount; j++) {
+                funcpos += sprintf(funcname + funcpos, " %s", cbind->parameters[j]);
+            }
+        }
+        content[4] = funcname;
         table_add(table, content);
     }
     //send the table