fixes for multi thread support
[NeonServV5.git] / src / cmd_neonserv_nicklist.c
index d0a7e852697b000d9e0e2beaf9066f11bca08958..6178198598f07d5ef4b9395fc1b70aea17034d2e 100644 (file)
@@ -1,5 +1,5 @@
-/* cmd_neonserv_nicklist.c - NeonServ v5.2
- * Copyright (C) 2011  Philipp Kreil (pk910)
+/* cmd_neonserv_nicklist.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
@@ -105,8 +105,12 @@ static void neonserv_cmd_nicklist_async1(struct ClientSocket *client, struct Cli
     int synced_user = 0;
     struct ChanUser *chanuser;
     int sort_nicklist[] = { 
+            CHANUSERFLAG_OPPED | CHANUSERFLAG_HALFOPPED | CHANUSERFLAG_VOICED,
+            CHANUSERFLAG_OPPED | CHANUSERFLAG_HALFOPPED,
             CHANUSERFLAG_OPPED | CHANUSERFLAG_VOICED,
             CHANUSERFLAG_OPPED,
+            CHANUSERFLAG_HALFOPPED | CHANUSERFLAG_VOICED,
+            CHANUSERFLAG_HALFOPPED,
             CHANUSERFLAG_VOICED,
             CHANUSERFLAG_INVISIBLE,
             0
@@ -125,6 +129,7 @@ static void neonserv_cmd_nicklist_async1(struct ClientSocket *client, struct Cli
             if(!stateset) {
                 if((chanuser->flags & CHANUSERFLAG_INVISIBLE)) statebuf[stateset++] = '<';
                 if((chanuser->flags & CHANUSERFLAG_OPPED)) statebuf[stateset++] = '@';
+                if((chanuser->flags & CHANUSERFLAG_HALFOPPED)) statebuf[stateset++] = '%';
                 if((chanuser->flags & CHANUSERFLAG_VOICED)) statebuf[stateset++] = '+';
                 statebuf[stateset++] = '\0';
             }
@@ -171,7 +176,7 @@ static void neonserv_cmd_nicklist_async1(struct ClientSocket *client, struct Cli
                         if(db_enfops >= caccess)
                             event->flags |= CMDFLAG_OPLOG;
                         uaccess = db_enfops;
-                    } else if((chanuser->flags & CHANUSERFLAG_VOICED) && db_enfvoice < caccess) {
+                    } else if((chanuser->flags & CHANUSERFLAG_VOICED) && (db_enfvoice < caccess || isGodMode(user))) {
                         if(db_enfvoice >= caccess)
                             event->flags |= CMDFLAG_OPLOG;
                         uaccess = db_enfvoice;
@@ -207,7 +212,7 @@ static void neonserv_cmd_nicklist_async1(struct ClientSocket *client, struct Cli
     table_free(table);
     if(synced_user) {
         if(!syncusers)
-            reply(textclient, user, "NS_NICKLIST_SYNC");
+            reply(textclient, user, "NS_NICKLIST_SYNC", db_enfops, db_enfvoice);
         else
             logEvent(event);
     }
@@ -224,7 +229,7 @@ static void neonserv_cmd_nicklist_synchronize_user(struct ChanNode *chan, struct
         userid = atoi(row[0]);
     } else {
         printf_mysql_query("INSERT INTO `users` (`user_user`) VALUES ('%s')", escape_string(user->auth));
-        userid = (int) mysql_insert_id(mysql_conn);
+        userid = (int) mysql_insert_id(get_mysql_conn());
     }
     //check if already added
     printf_mysql_query("SELECT `chanuser_access`, `chanuser_id`, `chanuser_seen` FROM `chanusers` WHERE `chanuser_cid` = '%d' AND `chanuser_uid` = '%d'", chan->channel_id, userid);