From 9fc2989a043babca9c2fde0a480dcdbc4f6315b1 Mon Sep 17 00:00:00 2001 From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54> Date: Sun, 20 Feb 2011 22:42:52 +0000 Subject: [PATCH] fix git-svn-id: http://svn.net-core.org/repos/t-engine4@2773 51575b47-30f0-44d4-a5cc-537603b46e54 --- game/engines/default/engine/PlayerProfile.lua | 7 +++--- game/profile-thread/Client.lua | 23 ++++++++++++++++--- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/game/engines/default/engine/PlayerProfile.lua b/game/engines/default/engine/PlayerProfile.lua index 29d7bf17bf..c2a10fe46d 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 d7d807b0ed..f691bb6326 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 -- GitLab