From 8d8a8ec5191c472905d082d7c4b793b09b592805 Mon Sep 17 00:00:00 2001 From: ShadowNinja Date: Sat, 22 Feb 2014 13:49:47 -0500 Subject: [PATCH] Delay connecting until the first server step This fixes an issue with servers on a restart loop starting up and immedietely crashing, causing a join/quit flood. --- src/init.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/init.lua b/src/init.lua index dfff384..0a66dd1 100644 --- a/src/init.lua +++ b/src/init.lua @@ -41,10 +41,18 @@ minetest.register_privilege("irc_admin", { give_to_singleplayer = true }) +local firstrun = true minetest.register_globalstep(function(dtime) return mt_irc:step(dtime) end) function mt_irc:step(dtime) + if firstrun then + firstrun = false + if self.config.auto_connect then + self:connect() + end + end + if not self.connected then return end -- Tick down the recent message count @@ -146,7 +154,3 @@ function mt_irc:send(line) end -if mt_irc.config.auto_connect then - mt_irc:connect() -end -