Skip to content

Commit

Permalink
Verify quote packs don't reuse line IDs
Browse files Browse the repository at this point in the history
This breaks turning them on/off. See BEEmod/BEE2-items#3087.
  • Loading branch information
TeamSpen210 committed Aug 29, 2019
1 parent 0798ada commit 36e2179
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/packageLoader.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
Match,
TypeVar,
Callable,
Set,
)


Expand Down Expand Up @@ -2140,6 +2141,38 @@ def strip_quote_data(prop: Property, _depth=0) -> Property:
children.append(Property(sub_prop.real_name, sub_prop.value))
return Property(prop.real_name, children)

@classmethod
def post_parse(cls) -> None:
"""Verify no quote packs have duplicate IDs."""

def iter_lines(conf: Property) -> Iterator[Property]:
"""Iterate over the varios line blocks."""
yield from conf.find_all("Quotes", "Group", "Quote", "Line")

yield from conf.find_all("Quotes", "Midchamber", "Quote", "Line")

for group in conf.find_children("Quotes", "CoopResponses"):
if group.has_children():
yield from group

for voice in cls.all():
used: Set[str] = set()
for quote in iter_lines(voice.config):
try:
quote_id = quote['id']
except LookupError:
quote_id = quote['name', '']
LOGGER.warning(
'Quote Pack "{}" has no specific ID for "{}"!',
voice.id, quote_id,
)
if quote_id in used:
LOGGER.warning(
'Quote Pack "{}" has duplicate '
'voice ID "{}"!', voice.id, quote_id,
)
used.add(quote_id)


class Skybox(PakObject):
def __init__(
Expand Down

0 comments on commit 36e2179

Please sign in to comment.