Skip to content

Commit

Permalink
add check for DN mod dependencies outside of nightmode=dark variants
Browse files Browse the repository at this point in the history
  • Loading branch information
memo33 committed Dec 16, 2024
1 parent b393698 commit 9d6e444
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
22 changes: 20 additions & 2 deletions .github/sc4pac-yaml-schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@
"bsc:mega-props-newmaninc-rivers-and-ponds",
])

# Add packages as necessary. These packages should only be used as dependencies
# from packages with a matching variant. For example, a package without a DN
# variant should never depend on simfox:day-and-nite-mod.
variant_specific_dependencies = {
"simfox:day-and-nite-mod": ("nightmode", "dark"),
"toroca:industry-quadrupler": ("toroca:industry-quadrupler:capacity", "quadrupled"),
"cam:colossus-addon-mod": ("CAM", "yes"),
}

unique_strings = {
"type": "array",
"items": {"type": "string"},
Expand Down Expand Up @@ -206,6 +215,7 @@ def __init__(self):
self.packages_using_asset = {} # asset -> set of packages
self.dlls_without_checksum = set()
self.http_without_checksum = set()
self.unexpected_variant_specific_dependencies = [] # (pkg, dependency)

def aggregate_identifiers(self, doc):
if 'assetId' in doc:
Expand Down Expand Up @@ -243,8 +253,14 @@ def iterate_doc_and_variants():
for obj in iterate_doc_and_variants():
local_deps = obj.get('dependencies', [])
self.referenced_packages.update(local_deps)
if pkg in local_deps:
self.self_dependencies.add(pkg)
for dep in local_deps:
if dep == pkg:
self.self_dependencies.add(pkg)
if dep in variant_specific_dependencies:
expected_variant, expected_value = variant_specific_dependencies[dep]
if obj.get('variant', {}).get(expected_variant) != expected_value:
self.unexpected_variant_specific_dependencies.append((pkg, dep))

local_assets = list(asset_ids(obj))
self.referenced_assets.update(local_assets)
for a in local_assets:
Expand Down Expand Up @@ -480,6 +496,8 @@ def basic_report(identifiers, msg: str, stringify=None):
for label, dupes in dependency_checker.duplicates().items():
basic_report(dupes, f"The following {label} are defined multiple times:")
basic_report(dependency_checker.self_dependencies, "The following packages unnecessarily depend on themselves:")
basic_report(dependency_checker.unexpected_variant_specific_dependencies, "The following packages have dependencies that should only be used with specific variants:",
lambda tup: "{0} depends on {1}, but this dependency should only be used with variant \"{2}={3}\"".format(*(tup + variant_specific_dependencies[tup[1]])))
basic_report(dependency_checker.assets_with_same_url(),
"The following assets have the same URL (The same asset was defined twice with different asset IDs):",
lambda assets: ', '.join(assets))
Expand Down
4 changes: 1 addition & 3 deletions src/yaml/andisart/tower-verre-53w53.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
group: andisart
name: tower-verre
version: "1.0"
version: "1.0-1"
subfolder: 360-landmark
info:
summary: Tower Verre - 53W53 (MoMA Expansion Tower)
Expand All @@ -27,8 +27,6 @@ info:
- https://www.simtropolis.com/objects/screens/monthly_2018_02/closeup.thumb.jpg.a77e5252f67dd1dd2eadcf9adbe0dc30.jpg
- https://www.simtropolis.com/objects/screens/monthly_2018_02/logo.thumb.jpg.c5926809b29dd839553292b9dd8c7625.jpg

dependencies:
- simfox:day-and-nite-mod
variants:
- variant: { nightmode: standard }
assets:
Expand Down

0 comments on commit 9d6e444

Please sign in to comment.