From 88391bc54043c4345cafb2d7b92ab6a2fbe59b68 Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Sun, 26 Feb 2012 17:25:35 +0000
Subject: [PATCH] get charballs t oo

git-svn-id: http://svn.net-core.org/repos/t-engine4@4932 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/engines/default/engine/PlayerProfile.lua | 14 ++++++++++++++
 game/profile-thread/Client.lua                | 13 +++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/game/engines/default/engine/PlayerProfile.lua b/game/engines/default/engine/PlayerProfile.lua
index c61a46c6d9..3103fcd5c3 100644
--- a/game/engines/default/engine/PlayerProfile.lua
+++ b/game/engines/default/engine/PlayerProfile.lua
@@ -627,6 +627,20 @@ function _M:registerNewCharacter(module)
 	return uuid
 end
 
+function _M:getCharball(id_profile, uuid)
+	if not self.auth then return end
+	local dialog = Dialog:simpleWaiter("Retrieving data from the server", "Retrieving...")
+	core.display.forceRedraw()
+
+	local data = nil
+	core.profile.pushOrder(table.serialize{o="GetCharball", module=game.__mod_info.short_name, uuid=uuid, id_profile=id_profile})
+	self:waitEvent("GetCharball", function(e) data = e.data end, 30000)
+
+	dialog:done()
+	if not data then return end
+	return data
+end
+
 function _M:registerSaveCharball(module, uuid, data)
 	if not self.auth or not self.hash_valid then return end
 	core.profile.pushOrder(table.serialize{o="SaveCharball",
diff --git a/game/profile-thread/Client.lua b/game/profile-thread/Client.lua
index f1d9517369..6b2de89e5a 100644
--- a/game/profile-thread/Client.lua
+++ b/game/profile-thread/Client.lua
@@ -352,6 +352,19 @@ function _M:orderSaveCharball(o)
 	cprofile.pushEvent("e='SaveCharball' ok=true")
 end
 
+function _M:orderGetCharball(o)
+	self:command("CHAR", "GETCHARBALL", o.id_profile, o.uuid, o.module)
+	if self:read("200") then
+		local _, _, size = self.last_line:find("^([0-9]+)")
+		size = tonumber(size)
+		if not size or size < 1 then return end
+		local body = self:receive(size)
+		cprofile.pushEvent(string.format("e='GetCharball' id_profile=%q uuid=%q data=%q", o.id_profile, o.uuid, body))
+	else
+		cprofile.pushEvent(string.format("e='GetCharball' id_profile=%q uuid=%q unknown=true", o.id_profile, o.uuid))
+	end
+end
+
 function _M:orderCurrentCharacter(o)
 	self:command("CHAR", "CUR", table.serialize(o))
 	self.cur_char = o
-- 
GitLab