Skip to content
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.

Commit

Permalink
Fix actorinfo crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Caleb Smith committed Jun 3, 2022
1 parent 5661718 commit 84ea0f1
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 60 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "bcml"
authors = ["Caleb Smith"]
version = "3.9.4"
version = "3.9.5"
edition = "2021"
readme = "docs/README.md"

Expand All @@ -22,7 +22,7 @@ msyt = { git = "https://github.com/NiceneNerd/msyt", rev = "12e4d95fb6480f445284
path-slash = "0.1.4"
pyo3 = { version = "0.15.0", features = ["extension-module"] }
rayon = "1.5.1"
roead = "0.10.0"
roead = "0.10.1"
rstb = "0.3.2"
serde = { version = "1.0.130", features = ["derive"] }
serde_json = "1.0.71"
Expand Down
2 changes: 1 addition & 1 deletion bcml/__version__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
_MAJOR=3
_MINOR=9
_PATCH="4"
_PATCH="5"

VERSION = f"{_MAJOR}.{_MINOR}.{_PATCH}"
USER_VERSION = f"""{_MAJOR}.{_MINOR}.{_PATCH[0:1]} {
Expand Down
50 changes: 2 additions & 48 deletions bcml/mergers/actors.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,54 +99,8 @@ def perform_merge(self):
actor_path.unlink()
return

rsext.mergers.actorinfo.merge_actorinfo(oead.byml.to_binary(modded_actors, False))

# print("Loading unmodded actor info...")
# actorinfo = get_stock_actorinfo()
# stock_actors = {
# crc32(actor["name"].encode("utf8")): actor for actor in actorinfo["Actors"]
# }

# print("Merging changes...")
# new_hashes = set()
# for actor_hash, actor_info in modded_actors.items():
# if isinstance(actor_hash, str):
# actor_hash = int(actor_hash)
# if actor_hash in stock_actors:
# util.dict_merge(
# stock_actors[actor_hash], actor_info, overwrite_lists=True
# )
# else:
# actorinfo["Actors"].append(actor_info)
# new_hashes.add(actor_hash)

# print("Sorting new actor info...")
# actorinfo["Hashes"] = oead.byml.Array(
# [
# oead.S32(x) if x < 2147483648 else oead.U32(x)
# for x in sorted(new_hashes | set(stock_actors.keys()))
# ]
# )
# try:
# actorinfo["Actors"] = sorted(
# actorinfo["Actors"], key=lambda x: crc32(x["name"].encode("utf-8"))
# )
# except KeyError as err:
# if str(err) == "":
# raise RuntimeError(
# "Your actor info mods could not be merged. "
# "This usually indicates a corrupt game dump."
# ) from err
# else:
# raise

# print("Saving new actor info...")
# actor_path.parent.mkdir(parents=True, exist_ok=True)
# actor_path.write_bytes(
# util.compress(
# oead.byml.to_binary(actorinfo, big_endian=util.get_settings("wiiu"))
# )
# )
bin_data = oead.byml.to_binary(modded_actors, False)
rsext.mergers.actorinfo.merge_actorinfo(bin_data)
print("Actor info merged successfully")

def get_checkbox_options(self):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "maturin"

[project]
name = "bcml"
version = "3.9.4"
version = "3.9.5"
description = "A mod manager for The Legend of Zelda: Breath of the Wild"
author = "NiceneNerd"
author_email = "[email protected]"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

setup(
name="bcml",
version="3.9.4",
version="3.9.5",
author="NiceneNerd",
author_email="[email protected]",
description="A mod manager for The Legend of Zelda: Breath of the Wild",
Expand Down
13 changes: 6 additions & 7 deletions src/mergers/actorinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,14 @@ fn diff_actorinfo(py: Python, actorinfo_path: String) -> PyResult<PyObject> {
#[pyfunction]
fn merge_actorinfo(py: Python, modded_actors: Vec<u8>) -> PyResult<()> {
let merge = || -> Result<()> {
let modded_actor_root = Byml::from_binary(&modded_actors).unwrap();
let modded_actors: ActorMap = py.allow_threads(|| {
modded_actor_root
.as_hash()
.unwrap()
let modded_actor_root = Byml::from_binary(&modded_actors)?;
let modded_actors: ActorMap = py.allow_threads(|| -> Result<ActorMap> {
Ok(modded_actor_root
.as_hash()?
.into_par_iter()
.map(|(h, a)| (h.parse::<u32>().unwrap(), a.clone()))
.collect()
});
.collect())
})?;
let mut merged_actors = stock_actorinfo()?.clone();
merge_actormap(&mut merged_actors, &modded_actors);
let (hashes, actors): (Vec<Byml>, Vec<Byml>) = merged_actors
Expand Down

0 comments on commit 84ea0f1

Please sign in to comment.