Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions fast64_internal/z64/exporter/scene/actors.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,26 @@ def getEntryC(self):
)


def split_c_on_commas(s: str):
parts: list[str] = []
part = ""
parens_depth = 0
for c in s:
if c == "(":
parens_depth += 1
if c == ")":
parens_depth -= 1
if parens_depth < 0:
parens_depth = 0
if c == "," and parens_depth == 0:
parts.append(part)
part = ""
else:
part += c
parts.append(part)
return parts


@dataclass
class SceneTransitionActors:
name: str
Expand Down Expand Up @@ -116,14 +136,14 @@ def from_data(raw_data: str, not_zapd_assets: bool):
if entry == "":
continue

params = entry.replace("{", "").replace("}", "").split(",")
params = split_c_on_commas(entry.replace("{", "").replace("}", ""))

# trailing commas
for p in params:
if p == "":
params.remove(p)

assert len(params) == 10
assert len(params) == 10, entry
trans_actor = TransitionActor()
trans_actor.name = "(unset)"
trans_actor.id = params[4]
Expand Down
31 changes: 19 additions & 12 deletions fast64_internal/z64/importer/actor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import re
import traceback
import bpy

from ...utility import parentObject, hexOrDecInt
Expand All @@ -19,6 +20,21 @@
)


def set_actor_params(actorProp, actor_id, actor_params):
if actorProp.actor_id != "Custom":
try:
actorProp.set_param_value(actor_params, "Params")
except:
print("Failed to parse params " + actor_params + " for actor " + actor_id + ":")
traceback.print_exc()
print("Defaulting to custom")
actorProp.actor_id = "Custom"
actorProp.actor_id_custom = actor_id
actorProp.params_custom = actor_params
else:
actorProp.params_custom = actor_params


def parseTransActorList(
roomObjs: list[bpy.types.Object],
sceneData: str,
Expand Down Expand Up @@ -66,10 +82,7 @@ def parseTransActorList(

actorProp = transActorProp.actor
setCustomProperty(actorProp, "actor_id", actor.id, game_data.z64.actors.ootEnumActorID)
if actorProp.actor_id != "Custom":
actorProp.params = actor.params
else:
actorProp.params_custom = actor.params
set_actor_params(actorProp, actor.id, actor.params)
handleActorWithRotAsParam(actorProp, actor.id, rotation)
unsetAllHeadersExceptSpecified(actorProp.headerSettings, headerIndex)

Expand Down Expand Up @@ -147,10 +160,7 @@ def parseSpawnList(
spawnProp.customActor = actorID != "ACTOR_PLAYER"
actorProp = spawnProp.actor
setCustomProperty(actorProp, "actor_id", actorID, game_data.z64.actors.ootEnumActorID)
if actorProp.actor_id != "Custom":
actorProp.params = actorParam
else:
actorProp.params_custom = actorParam
set_actor_params(actorProp, actorID, actorParam)
handleActorWithRotAsParam(actorProp, actorID, rotation)
unsetAllHeadersExceptSpecified(actorProp.headerSettings, headerIndex)

Expand Down Expand Up @@ -188,10 +198,7 @@ def parseActorList(
actorProp = actorObj.ootActorProperty

setCustomProperty(actorProp, "actor_id", actorID, game_data.z64.actors.ootEnumActorID)
if actorProp.actor_id != "Custom":
actorProp.params = actorParam
else:
actorProp.params_custom = actorParam
set_actor_params(actorProp, actorID, actorParam)
handleActorWithRotAsParam(actorProp, actorID, rotation)
unsetAllHeadersExceptSpecified(actorProp.headerSettings, headerIndex)

Expand Down
4 changes: 3 additions & 1 deletion fast64_internal/z64/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,9 @@ def _eval(node) -> int:
try:
return _eval(node.body)
except:
print("WARNING: something wrong happened:", traceback.print_exc())
print("WARNING: something wrong happened:")
print("input:", input)
traceback.print_exc()
return None


Expand Down
Loading