optimize save storage
This commit is contained in:
parent
6f447c4820
commit
66d27ac884
|
@ -155,7 +155,10 @@ module CrystalGauntlet
|
|||
LOG.debug { "-> ".colorize(:green).to_s + value_displayed }
|
||||
|
||||
context.response.content_type = "text/plain"
|
||||
context.response.print value
|
||||
# to let endpoints manually write to IO
|
||||
if value != ""
|
||||
context.response.print value
|
||||
end
|
||||
end
|
||||
else
|
||||
call_next(context)
|
||||
|
|
|
@ -13,16 +13,16 @@ CrystalGauntlet.endpoints["/accounts/backupGJAccount.php"] = ->(context : HTTP::
|
|||
if result.size > 0
|
||||
account_id, hash = result[0]
|
||||
bcrypt = Crypto::Bcrypt::Password.new(hash)
|
||||
|
||||
|
||||
if bcrypt.verify(password)
|
||||
folder = DATA_FOLDER / "saves"
|
||||
params.each do |key, _|
|
||||
if key.starts_with?("H4s")
|
||||
File.write(folder / "#{account_id}_levels.sav", key)
|
||||
File.open(folder / "#{account_id}_levels.sav", "w") { |file| Base64.decode(key, file) }
|
||||
end
|
||||
end
|
||||
|
||||
File.write(folder / "#{account_id}.sav", params["saveData"])
|
||||
File.open(folder / "#{account_id}.sav", "w") { |file| Base64.decode(params["saveData"], file) }
|
||||
return "1"
|
||||
else
|
||||
return "-1"
|
||||
|
|
|
@ -13,10 +13,14 @@ CrystalGauntlet.endpoints["/accounts/syncGJAccount.php"] = ->(context : HTTP::Se
|
|||
if result.size > 0
|
||||
account_id, hash = result[0]
|
||||
bcrypt = Crypto::Bcrypt::Password.new(hash)
|
||||
|
||||
|
||||
if bcrypt.verify(password)
|
||||
folder = DATA_FOLDER / "saves"
|
||||
return "#{File.read(folder / "#{account_id}.sav")};#{File.read(folder / "#{account_id}_levels.sav")};21;30;a;a"
|
||||
Base64.urlsafe_encode(File.read(folder / "#{account_id}.sav"), context.response.output)
|
||||
context.response.output << ";"
|
||||
Base64.urlsafe_encode(File.read(folder / "#{account_id}_levels.sav"), context.response.output)
|
||||
context.response.output << ";21;30;a;a"
|
||||
return ""
|
||||
else
|
||||
return "-1"
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue