diff --git a/bemani/backend/popn/fantasia.py b/bemani/backend/popn/fantasia.py index 1a1fb34..6113dd2 100644 --- a/bemani/backend/popn/fantasia.py +++ b/bemani/backend/popn/fantasia.py @@ -479,7 +479,12 @@ class PopnMusicFantasia(PopnMusicBase): self.GAME_CHART_TYPE_NORMAL: self.CHART_TYPE_NORMAL, self.GAME_CHART_TYPE_HYPER: self.CHART_TYPE_HYPER, self.GAME_CHART_TYPE_EX: self.CHART_TYPE_EX, - }[node.child_value("sheet")] + }.get(node.child_value("sheet")) + if chart is None: + # Some old versions of Fantasia still send empty chart data for Tune Street + # charts that don't exist in the game. Ignore these or we end up crashing on + # profile save. + continue medal = (node.child_value("n_data") >> (chart * 4)) & 0x000F medal = { self.GAME_PLAY_MEDAL_CIRCLE_FAILED: self.PLAY_MEDAL_CIRCLE_FAILED, diff --git a/bemani/format/afp/container.py b/bemani/format/afp/container.py index d61e538..3cf32c6 100644 --- a/bemani/format/afp/container.py +++ b/bemani/format/afp/container.py @@ -1134,7 +1134,9 @@ class TXP2File(TrackedCoverage, VerboseOutput): if feature_mask & 0xFFF00000: # We don't know these bits at all! - raise Exception(f"Invalid bits set in feature mask {hex(feature_mask & 0xFFF80000)}!") + raise Exception( + f"Invalid bits set in feature mask {hex(feature_mask & 0xFFF80000)}!" + ) if header_offset != header_length: raise Exception("Failed to parse bitfield of header correctly!")