diff --git a/game/engines/default/engine/PlayerProfile.lua b/game/engines/default/engine/PlayerProfile.lua index 29d7bf17bf84fb22187df5f5467a10203a5aebef..c2a10fe46df121c63f577eb92b80c2bfd276ef9c 100644 --- a/game/engines/default/engine/PlayerProfile.lua +++ b/game/engines/default/engine/PlayerProfile.lua @@ -437,10 +437,9 @@ function _M:logOut() profile.generic.online = nil profile.auth = nil - local restore = fs.getWritePath() - fs.setWritePath(engine.homepath) - fs.delete("/profiles/"..self.name.."/generic/online.profile") - if restore then fs.setWritePath(restore) end + local pop = self:mountProfile(true) + fs.delete("/generic/online.profile") + self:umountProfile(true, pop) end function _M:getConfigs(module, cb) diff --git a/game/profile-thread/Client.lua b/game/profile-thread/Client.lua index d7d807b0ed0fed988523c8d15e10906e6e6af612..f691bb63263b6cf1da4533779717399adc69bcd6 100644 --- a/game/profile-thread/Client.lua +++ b/game/profile-thread/Client.lua @@ -75,7 +75,7 @@ function _M:pread(ncode) if not l then if err == "closed" then print("[PROFILE] push connection disrupted, trying to reconnect", err) - self:disconnect() + self.psock = nil end return nil end @@ -112,19 +112,27 @@ end function _M:step() if self:connected() then - local rready = socket.select({self.psock}, nil, 0) + if not self.psock and self.auth then self:connectedPull() end + + local socks = {} + if self.sock then socks[#socks+1] = self.sock end + if self.psock then socks[#socks+1] = self.psock end + local rready = socket.select(socks, nil, 0) if rready[self.psock] then local l = self:pread() if l then local code = l:sub(1, 3) local data = l:sub(5) - print("<<<<<<<", code, "::", data) if code == "101" then local e = data:unserialize() if e and e.e and self["push"..e.e] then self["push"..e.e](self, e) end end end end + if rready[self.sock] then + local l = self:read() + if l then print("[PROFILE] req/rep thread got unwanted data", l) end + end return true end return false @@ -261,3 +269,12 @@ function _M:pushCode(o) cprofile.pushEvent(string.format("e='PushCode' code=%q", o.code)) end end + +function _M:pushChatTalk(o) + if o.profile then + local f = loadstring(o.code) + if f then pcall(f) end + else + cprofile.pushEvent(string.format("e='PushCode' code=%q", o.code)) + end +end