Skip to content
Snippets Groups Projects
Commit ce6ee76b authored by dg's avatar dg
Browse files

switch

git-svn-id: http://svn.net-core.org/repos/t-engine4@2881 51575b47-30f0-44d4-a5cc-537603b46e54
parent 5fc5769b
No related branches found
No related tags found
No related merge requests found
...@@ -272,6 +272,7 @@ function _M:instanciate(mod, name, new_game, no_reboot) ...@@ -272,6 +272,7 @@ function _M:instanciate(mod, name, new_game, no_reboot)
-- Add user chat if needed -- Add user chat if needed
if mod.allow_userchat and _G.game.key then if mod.allow_userchat and _G.game.key then
profile.chat:setupOnGame() profile.chat:setupOnGame()
profile.chat:join("global")
profile.chat:join(mod.short_name) profile.chat:join(mod.short_name)
end end
......
...@@ -54,9 +54,9 @@ function _M:setupOnGame() ...@@ -54,9 +54,9 @@ function _M:setupOnGame()
} }
end end
function _M:addMessage(channel, user, msg) function _M:addMessage(channel, login, name, msg)
local log = self.channels[channel].log local log = self.channels[channel].log
table.insert(log, 1, {user=user, msg=msg}) table.insert(log, 1, {login=login, name=name, msg=msg})
while #log > self.max do table.remove(log) end while #log > self.max do table.remove(log) end
self.changed = true self.changed = true
end end
...@@ -66,18 +66,18 @@ function _M:event(e) ...@@ -66,18 +66,18 @@ function _M:event(e)
e.msg = e.msg:removeColorCodes() e.msg = e.msg:removeColorCodes()
self.channels[e.channel] = self.channels[e.channel] or {users={}, log={}} self.channels[e.channel] = self.channels[e.channel] or {users={}, log={}}
self:addMessage(e.channel, e.user, e.msg) self:addMessage(e.channel, e.login, e.name, e.msg)
if type(game) == "table" and game.log then game.log("#YELLOW#<%s> %s", e.user, e.msg) end if type(game) == "table" and game.log then game.log("#YELLOW#<%s> %s", e.name, e.msg) end
elseif e.se == "Join" then elseif e.se == "Join" then
self.channels[e.channel] = self.channels[e.channel] or {users={}, log={}} self.channels[e.channel] = self.channels[e.channel] or {users={}, log={}}
self.channels[e.channel].users[e.user] = {name=e.user} self.channels[e.channel].users[e.login] = {name=e.name, login=e.login}
self.channels_changed = true self.channels_changed = true
self:addMessage(e.channel, e.user, "#{italic}##FIREBRICK#has joined the channel#{normal}#") self:addMessage(e.channel, e.user, "#{italic}##FIREBRICK#has joined the channel#{normal}#")
if type(game) == "table" and game.log and e.channel == self.cur_channel then game.log("#{italic}##FIREBRICK#%s has joined channel %s (press space to talk).#{normal}#", e.user, e.channel) end if type(game) == "table" and game.log and e.channel == self.cur_channel then game.log("#{italic}##FIREBRICK#%s has joined channel %s (press space to talk).#{normal}#", e.user, e.channel) end
elseif e.se == "Part" then elseif e.se == "Part" then
self.channels[e.channel] = self.channels[e.channel] or {users={}, log={}} self.channels[e.channel] = self.channels[e.channel] or {users={}, log={}}
self.channels[e.channel].users[e.user] = nil self.channels[e.channel].users[e.login] = nil
self.channels_changed = true self.channels_changed = true
self:addMessage(e.channel, e.user, "#{italic}##FIREBRICK#has left the channel#{normal}#") self:addMessage(e.channel, e.user, "#{italic}##FIREBRICK#has left the channel#{normal}#")
if type(game) == "table" and game.log and e.channel == self.cur_channel then game.log("#{italic}##FIREBRICK#%s has left channel %s.#{normal}#", e.user, e.channel) end if type(game) == "table" and game.log and e.channel == self.cur_channel then game.log("#{italic}##FIREBRICK#%s has left channel %s.#{normal}#", e.user, e.channel) end
...@@ -89,7 +89,8 @@ function _M:event(e) ...@@ -89,7 +89,8 @@ function _M:event(e)
if not info then return end if not info then return end
self.channels[e.channel].users = {} self.channels[e.channel].users = {}
for _, user in ipairs(info.users) do for _, user in ipairs(info.users) do
self.channels[e.channel].users[user.name] = { self.channels[e.channel].users[user.login] = {
login=user.login,
name=user.name, name=user.name,
cur_char=user.cur_char and user.cur_char.title or "unknown", cur_char=user.cur_char and user.cur_char.title or "unknown",
module=user.cur_char and user.cur_char.module or "unknown", module=user.cur_char and user.cur_char.module or "unknown",
...@@ -211,8 +212,8 @@ function _M:resize(x, y, w, h, fontname, fontsize, color, bgcolor) ...@@ -211,8 +212,8 @@ function _M:resize(x, y, w, h, fontname, fontsize, color, bgcolor)
local item = self.dlist[i] local item = self.dlist[i]
if item.dh and y >= item.dh - self.mouse.delegate_offset_y then citem = item break end if item.dh and y >= item.dh - self.mouse.delegate_offset_y then citem = item break end
end end
if citem and citem.user and self.channels[self.cur_channel].users[citem.user] then if citem and citem.login and self.channels[self.cur_channel].users[citem.login] then
self.on_mouse(self.channels[self.cur_channel].users[citem.user], button, event) self.on_mouse(self.channels[self.cur_channel].users[citem.login], button, event)
end end
end end
end) end)
...@@ -265,10 +266,10 @@ function _M:display() ...@@ -265,10 +266,10 @@ function _M:display()
local old_style = self.font:getStyle() local old_style = self.font:getStyle()
for z = 1 + self.scroll, #log do for z = 1 + self.scroll, #log do
local stop = false local stop = false
local tstr = ("<%s> %s"):format(log[z].user, log[z].msg):toTString() local tstr = ("<%s> %s"):format(log[z].name, log[z].msg):toTString()
local gen = tstring.makeLineTextures(tstr, self.w, self.font_mono) local gen = tstring.makeLineTextures(tstr, self.w, self.font_mono)
for i = #gen, 1, -1 do for i = #gen, 1, -1 do
gen[i].user = log[z].user gen[i].login = log[z].login
self.dlist[#self.dlist+1] = gen[i] self.dlist[#self.dlist+1] = gen[i]
h = h + self.fh h = h + self.fh
if h > self.h - self.fh - ls_h then stop=true break end if h > self.h - self.fh - ls_h then stop=true break end
......
...@@ -325,7 +325,7 @@ function _M:checkFirstTime() ...@@ -325,7 +325,7 @@ function _M:checkFirstTime()
end end
function _M:createProfile(loginItem) function _M:createProfile(loginItem)
if loginItem.justlogin then if not loginItem.create then
self.auth_tried = nil self.auth_tried = nil
profile:performlogin(loginItem.login, loginItem.pass) profile:performlogin(loginItem.login, loginItem.pass)
profile:waitFirstAuth() profile:waitFirstAuth()
......
...@@ -104,7 +104,7 @@ function _M:okclick() ...@@ -104,7 +104,7 @@ function _M:okclick()
end end
game:unregisterDialog(self) game:unregisterDialog(self)
game:createProfile({justlogin=self.c_email and false or true, login=self.c_login.text, pass=self.c_pass.text, email=self.c_email and self.c_email.text}) 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})
end end
function _M:cancelclick() function _M:cancelclick()
......
...@@ -865,7 +865,8 @@ function _M:setupCommands() ...@@ -865,7 +865,8 @@ function _M:setupCommands()
end end, end end,
[{"_g","ctrl"}] = function() if config.settings.cheat then [{"_g","ctrl"}] = function() if config.settings.cheat then
-- self.nicer_tiles:postProcessLevelTiles(self.level) -- self.nicer_tiles:postProcessLevelTiles(self.level)
game:registerDialog(require("mod.dialogs.Donation").new()) -- game:registerDialog(require("mod.dialogs.Donation").new())
error("plop")
end end, end end,
} }
......
...@@ -29,7 +29,7 @@ end ...@@ -29,7 +29,7 @@ end
function _M:connected() function _M:connected()
if self.sock then return true end if self.sock then return true end
self.sock = socket.connect("te4.org", 2259) self.sock = socket.connect("te4.org", 2257)
if not self.sock then return false end if not self.sock then return false end
-- self.sock:settimeout(10) -- self.sock:settimeout(10)
print("[PROFILE] Thread connected to te4.org") print("[PROFILE] Thread connected to te4.org")
...@@ -40,7 +40,7 @@ end ...@@ -40,7 +40,7 @@ end
--- Connects the second tcp channel to receive data --- Connects the second tcp channel to receive data
function _M:connectedPull() function _M:connectedPull()
if self.psock then return true end if self.psock then return true end
self.psock = socket.connect("te4.org", 2260) self.psock = socket.connect("te4.org", 2258)
if not self.psock then return false end if not self.psock then return false end
-- self.psock:settimeout(10) -- self.psock:settimeout(10)
print("[PROFILE] Pull socket connected to te4.org") print("[PROFILE] Pull socket connected to te4.org")
......
...@@ -29,17 +29,17 @@ end ...@@ -29,17 +29,17 @@ end
function _M:event(e) function _M:event(e)
if e.e == "ChatTalk" then if e.e == "ChatTalk" then
cprofile.pushEvent(string.format("e='Chat' se='Talk' channel=%q user=%q msg=%q", e.channel, e.user, e.msg)) cprofile.pushEvent(string.format("e='Chat' se='Talk' channel=%q login=%q name=%q msg=%q", e.channel, e.login, e.name, e.msg))
print("[USERCHAT] channel talk", e.user, e.channel, e.msg) print("[USERCHAT] channel talk", e.user, e.channel, e.msg)
elseif e.e == "ChatJoin" then elseif e.e == "ChatJoin" then
self.channels[e.channel] = self.channels[e.channel] or {} self.channels[e.channel] = self.channels[e.channel] or {}
self.channels[e.channel][e.user] = true self.channels[e.channel][e.user] = true
cprofile.pushEvent(string.format("e='Chat' se='Join' channel=%q user=%q", e.channel, e.user)) cprofile.pushEvent(string.format("e='Chat' se='Join' channel=%q login=%q name=%q ", e.channel, e.login, e.name))
print("[USERCHAT] channel join", e.user, e.channel) print("[USERCHAT] channel join", e.user, e.channel)
elseif e.e == "ChatPart" then elseif e.e == "ChatPart" then
self.channels[e.channel] = self.channels[e.channel] or {} self.channels[e.channel] = self.channels[e.channel] or {}
self.channels[e.channel][e.user] = nil self.channels[e.channel][e.user] = nil
cprofile.pushEvent(string.format("e='Chat' se='Part' channel=%q user=%q", e.channel, e.user)) cprofile.pushEvent(string.format("e='Chat' se='Part' channel=%q login=%q name=%q ", e.channel, e.login, e.name))
print("[USERCHAT] channel part", e.user, e.channel) print("[USERCHAT] channel part", e.user, e.channel)
end end
end end
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