mirror of
https://github.com/cave-story-randomizer/cave-story-randomizer
synced 2024-12-25 06:26:57 +00:00
makes the title screen hash into a real hash
This commit is contained in:
parent
d280a76d90
commit
d72738d474
|
@ -702,7 +702,7 @@ function worldGraph.locationsArray(locations)
|
||||||
return array
|
return array
|
||||||
end
|
end
|
||||||
|
|
||||||
function worldGraph:logLocations()
|
function worldGraph:serialize()
|
||||||
local array = {}
|
local array = {}
|
||||||
for k,v in pairs(self.regions) do
|
for k,v in pairs(self.regions) do
|
||||||
table.insert(array, v)
|
table.insert(array, v)
|
||||||
|
@ -712,17 +712,27 @@ function worldGraph:logLocations()
|
||||||
return a.order < b.order
|
return a.order < b.order
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local lines = {}
|
||||||
|
|
||||||
for k,r in ipairs(_.sort(array,sort)) do
|
for k,r in ipairs(_.sort(array,sort)) do
|
||||||
if next(r.locations) then
|
if next(r.locations) then
|
||||||
logSpoiler("")
|
lines:insert("")
|
||||||
logSpoiler("Region: " .. r.name)
|
lines:insert("Region: " .. r.name)
|
||||||
for k2,l in pairs(r.locations) do
|
for k2,l in pairs(r.locations) do
|
||||||
if l.item ~= nil and not _has({l.item}, "event") then
|
if l.item ~= nil and not _has({l.item}, "event") then
|
||||||
logSpoiler("\t " .. l.name .. ": " .. l.item.name)
|
lines:insert("\t " .. l.name .. ": " .. l.item.name)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return lines
|
||||||
|
end
|
||||||
|
|
||||||
|
function worldGraph:logLocations()
|
||||||
|
for k,v in ipairs(worldGraph:serialize()) do
|
||||||
|
logSpoiler(v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return worldGraph
|
return worldGraph
|
|
@ -286,8 +286,18 @@ function C:_copyMyChar()
|
||||||
end
|
end
|
||||||
|
|
||||||
function C:_generateHash()
|
function C:_generateHash()
|
||||||
|
local serialized = self.worldGraph:serialize():concat()
|
||||||
|
local hashed = ld.encode('string', 'hex', ld.hash('sha256', serialized))
|
||||||
|
hashed = tonumber(hashed:sub(-8, -1), 16)
|
||||||
|
hashed = hashed % (39^5)
|
||||||
|
|
||||||
|
local h = {}
|
||||||
|
for i=1,5 do
|
||||||
|
h:insert((hashed%39)+1)
|
||||||
|
hashed = math.floor(hashed / 39)
|
||||||
|
end
|
||||||
|
|
||||||
local path = self:_getWritePath() .. '/hash.txt'
|
local path = self:_getWritePath() .. '/hash.txt'
|
||||||
local h = {love.math.random(39), love.math.random(39), love.math.random(39), love.math.random(39), love.math.random(39)}
|
|
||||||
U.writeFile(path, ("%04d,%04d,%04d,%04d,%04d"):format(h[1], h[2], h[3], h[4], h[5]))
|
U.writeFile(path, ("%04d,%04d,%04d,%04d,%04d"):format(h[1], h[2], h[3], h[4], h[5]))
|
||||||
return h
|
return h
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue