forked from woofmeow/straywild
Expand gameplay systems and interface controls
This commit is contained in:
parent
09b7a78533
commit
2710544070
46 changed files with 2072 additions and 153 deletions
|
|
@ -122,6 +122,7 @@ static func migrate_active_to(
|
|||
_remove_tree(staging)
|
||||
return {"ok": false, "message": str(created.get("message", ""))}
|
||||
for relative: String in [
|
||||
"player/player_save.nfsave",
|
||||
"player/player_save.json",
|
||||
"player/network_profile.json",
|
||||
"player/player_appearance.json",
|
||||
|
|
@ -134,7 +135,11 @@ static func migrate_active_to(
|
|||
var source: String = data_root.root_path.path_join(relative)
|
||||
if not FileAccess.file_exists(source):
|
||||
continue
|
||||
if not bool(_copy_verified_json(source, staging.path_join(relative)).get("ok", false)):
|
||||
if not bool(
|
||||
_copy_verified_owned_file(
|
||||
source, staging.path_join(relative)
|
||||
).get("ok", false)
|
||||
):
|
||||
_remove_tree(staging)
|
||||
return {"ok": false, "message": "Migration validation failed for %s." % relative}
|
||||
if DirAccess.dir_exists_absolute(normalized):
|
||||
|
|
@ -248,6 +253,30 @@ static func _copy_verified_json(source: String, destination: String) -> Dictiona
|
|||
}
|
||||
|
||||
|
||||
static func _copy_verified_owned_file(
|
||||
source: String,
|
||||
destination: String,
|
||||
) -> Dictionary:
|
||||
if source.get_file() != "player_save.nfsave":
|
||||
return _copy_verified_json(source, destination)
|
||||
var decoded: Dictionary = ProgressionSaveCodec.read_local_save(source)
|
||||
if not bool(decoded.get("ok", false)):
|
||||
return {"ok": false}
|
||||
var save_data: Dictionary = decoded["data"]
|
||||
var version: int = int(save_data.get("save_version", -1))
|
||||
if version < 1 or version > PlayerSaveManager.SAVE_VERSION:
|
||||
return {"ok": false}
|
||||
var bytes: PackedByteArray = PortableFileGuard.read_bytes(source)
|
||||
if bytes.is_empty() or not _write_bytes(destination, bytes):
|
||||
return {"ok": false}
|
||||
return {
|
||||
"ok": (
|
||||
PortableFileGuard.hash_file(destination)
|
||||
== PortableFileGuard.hash_bytes(bytes)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
static func _valid_owned_data(filename: String, data: Dictionary) -> bool:
|
||||
if filename == "player_save.json":
|
||||
var version: int = int(data.get("save_version", -1))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue