fixed crash in module.c if no bot is available
[NeonServV5.git] / src / modules / stats.mod / module.c
index f276a0abded650f370c1585344e9d2c9f2eb595a..c08e0fba58e8225341c6d8e5a2d1cc7563474c0f 100644 (file)
@@ -1,4 +1,4 @@
-/* module.c - NeonServ v5.5
+/* module.c - NeonServ v5.6
  * Copyright (C) 2011-2012  Philipp Kreil (pk910)
  * 
  * This program is free software: you can redistribute it and/or modify
@@ -39,10 +39,6 @@ static void module_start(int type) {
         timeq_add_name("stats", 60, module_id, stats_timer_callback, NULL);
 }
 
-static void module_loop() {
-    
-}
-
 static void module_stop(int type) {
     timeq_del_name("stats");
 }
@@ -98,7 +94,7 @@ static TIMEQ_CALLBACK(stats_timer_callback) {
     if(get_int_field(tmp))
         pkgpos += sprintf(pkgbuf + pkgpos, "*\n");
     else {
-        struct ClientSocket *bot, *bot1, *bot2, *bot3;
+        struct ClientSocket *bot, *bot1 = NULL, *bot2 = NULL, *bot3 = NULL;
         for(bot = getBots(SOCKET_FLAG_READY, NULL); bot; bot = getBots(SOCKET_FLAG_READY, bot)) {
             if(bot->botid == 1 && (bot->flags & SOCKET_FLAG_PREFERRED))
                 bot1 = bot;
@@ -164,4 +160,4 @@ static TIMEQ_CALLBACK(stats_timer_callback) {
     close(sock);
 }
 
-MODULE_HEADER(module_initialize, module_start, module_loop, module_stop);
+MODULE_HEADER(module_initialize, module_start, module_stop);