fixed crash caused by startup reload event
[NeonServV5.git] / src / main.c
index 1292a82c7c627c68e6241e80e3dab80fcaf18774..17b8258c5110fd17760cce6313f4d5a2154d11d8 100644 (file)
@@ -1,4 +1,4 @@
-/* main.c - NeonServ v5.4
+/* main.c - NeonServ v5.5
  * Copyright (C) 2011-2012  Philipp Kreil (pk910)
  * 
  * This program is free software: you can redistribute it and/or modify
@@ -40,6 +40,7 @@
 #include "version.h"
 #include "modules.h"
 #include "module_commands.h"
+#include "ModuleFunctions.h"
 
 time_t start_time;
 static int running, hard_restart;
@@ -208,6 +209,8 @@ int main(int argc, char *argv[]) {
         fprintf(stderr, "Unable to load " CONF_FILE "\n");
         exit(0);
     }
+    init_bind();
+    event_reload(1);
     #if HAVE_THREADS
     THREAD_MUTEX_INIT(log_sync);
     #endif
@@ -295,6 +298,7 @@ main:
     register_module_commands();
     init_handleinfohandler();
     init_tools();
+    init_modulefunctions();
     loadModules();
     init_bots();
     init_DBHelper();
@@ -410,6 +414,7 @@ void stop_bot() {
 
 void reload_config() {
     loadConfig(CONF_FILE);
+    event_reload(0);
 }
 
 static int getCurrentSecondsOfDay() {
@@ -437,10 +442,16 @@ static AUTHLOOKUP_CALLBACK(main_checkauths_callback) {
             deleteUser(atoi(row[0]));
             char *alertchan = get_string_field("General.CheckAuths.alertchan");
             if(alertchan) {
+                char reason[MAXLEN];
+                if(!exists) {
+                    strcpy(reason, "USER_NOT_EXISTS");
+                } else {
+                    sprintf(reason, "USER_REGISTERED_MISSMATCH: %lu, expected %d (diff: %d)", (unsigned long) registered, atoi(row[1]), diff);
+                }
                 struct ChanNode *alertchan_chan = getChanByName(alertchan);
                 struct ClientSocket *alertclient;
                 if(alertchan_chan && (alertclient = getChannelBot(alertchan_chan, 0)) != NULL) {
-                    putsock(alertclient, "PRIVMSG %s :Deleted User %s", alertchan_chan->name, auth);
+                    putsock(alertclient, "PRIVMSG %s :Deleted User %s (%s)", alertchan_chan->name, auth, reason);
                 }
             }
         } else if(exists && !strcmp(row[1], "0")) {