Skip to content
Snippets Groups Projects
Commit 4343fbbf authored by DarkGod's avatar DarkGod
Browse files

Fixed joining chat channels on star in some rare cases, one of the reason for...

Fixed joining chat channels on star in some rare cases, one of the reason for "server doesnt work: it did work you just didnt saw it
parent 314ab990
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -1069,28 +1069,30 @@ function _M:instanciate(mod, name, new_game, no_reboot, extra_module_info)
-- Add user chat if needed
if mod.allow_userchat and _G.game.key then
profile.chat:setupOnGame()
if not config.settings.chat or not config.settings.chat.channels or not config.settings.chat.channels[mod.short_name] then
if type(mod.allow_userchat) == "table" then
for _, chan in ipairs(mod.allow_userchat) do
profile.chat:join(chan)
profile:onAuth(function()
if not config.settings.chat or not config.settings.chat.channels or not config.settings.chat.channels[mod.short_name] then
if type(mod.allow_userchat) == "table" then
for _, chan in ipairs(mod.allow_userchat) do
profile.chat:join(chan)
end
if mod.allow_userchat[1] then profile.chat:selectChannel(mod.allow_userchat[1]) end
else
profile.chat:join(mod.short_name)
profile.chat:join(mod.short_name.."-spoiler")
profile.chat:join("global")
profile.chat:selectChannel(mod.short_name)
end
if mod.allow_userchat[1] then profile.chat:selectChannel(mod.allow_userchat[1]) end
print("Joining default channels")
else
profile.chat:join(mod.short_name)
profile.chat:join(mod.short_name.."-spoiler")
profile.chat:join("global")
profile.chat:selectChannel(mod.short_name)
end
print("Joining default channels")
else
local def = false
for c, _ in pairs(config.settings.chat.channels[mod.short_name]) do
profile.chat:join(c)
if c == mod.short_name then def = true end
local def = false
for c, _ in pairs(config.settings.chat.channels[mod.short_name]) do
profile.chat:join(c)
if c == mod.short_name then def = true end
end
if def then profile.chat:selectChannel(mod.short_name) else profile.chat:selectChannel( (next(config.settings.chat.channels[mod.short_name])) ) end
print("Joining selected channels")
end
if def then profile.chat:selectChannel(mod.short_name) else profile.chat:selectChannel( (next(config.settings.chat.channels[mod.short_name])) ) end
print("Joining selected channels")
end
end)
end
-- Disable the profile if ungood
......
......@@ -535,6 +535,12 @@ function _M:waitFirstAuth(timeout)
end
end
function _M:onAuth(fct)
if self.auth then fct() return end
self.on_auth_cb = self.on_auth_cb or {}
self.on_auth_cb[#self.on_auth_cb+1] = fct
end
function _M:eventAuth(e)
self.waiting_auth = false
self.connected = true
......@@ -543,6 +549,8 @@ function _M:eventAuth(e)
self.auth = e.ok:unserialize()
print("[PROFILE] Main thread got authed", self.auth.name)
self:getConfigs("generic", function(e) self:syncOnline(e.module) end)
for _, fct in ipairs(self.on_auth_cb or {}) do fct() end
self.on_auth_cb = nil
else
self.auth_last_error = e.reason or "unknown"
end
......@@ -604,11 +612,13 @@ end
function _M:eventConnected(e)
if game and type(game) == "table" and game.log then game.log("#YELLOW#Connection to online server established.") end
print("[PlayerProfile] eventConnected")
self.connected = true
end
function _M:eventDisconnected(e)
if game and type(game) == "table" and game.log and self.connected then game.log("#YELLOW#Connection to online server lost, trying to reconnect.") end
print("[PlayerProfile] eventDisconnected")
self.connected = false
end
......
......@@ -110,7 +110,7 @@ function _M:okclick()
end
game:unregisterDialog(self)
game:createProfile({create=self.c_email and true or false, login=self.c_login.text, pass=self.c_pass.text, email=self.c_email and self.c_email.text, news=self.c_news.checked})
game:createProfile({create=self.c_email and true or false, login=self.c_login.text, pass=self.c_pass.text, email=self.c_email and self.c_email.text, news=self.c_news and self.c_news.checked})
end
function _M:cancelclick()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment