Zillion: webhost config fix (#2145)

This commit is contained in:
Doug Hoskisson 2023-09-10 14:03:22 -07:00 committed by GitHub
parent 72b44be41c
commit e01eb4e00c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View File

@ -10,6 +10,7 @@ import logging
from BaseClasses import ItemClassification, LocationProgressType, \ from BaseClasses import ItemClassification, LocationProgressType, \
MultiWorld, Item, CollectionState, Entrance, Tutorial MultiWorld, Item, CollectionState, Entrance, Tutorial
from .config import detect_test
from .logic import cs_to_zz_locs from .logic import cs_to_zz_locs
from .region import ZillionLocation, ZillionRegion from .region import ZillionLocation, ZillionRegion
from .options import ZillionStartChar, zillion_options, validate from .options import ZillionStartChar, zillion_options, validate
@ -145,8 +146,7 @@ class ZillionWorld(World):
self._item_counts = item_counts self._item_counts = item_counts
import __main__ rom_dir_name = "" if detect_test() else os.path.dirname(get_base_rom_path())
rom_dir_name = "" if "test" in __main__.__file__ else os.path.dirname(get_base_rom_path())
with redirect_stdout(self.lsi): # type: ignore with redirect_stdout(self.lsi): # type: ignore
self.zz_system.make_patcher(rom_dir_name) self.zz_system.make_patcher(rom_dir_name)
self.zz_system.make_randomizer(zz_op) self.zz_system.make_randomizer(zz_op)

View File

@ -2,3 +2,20 @@ import os
base_id = 8675309 base_id = 8675309
zillion_map = os.path.join(os.path.dirname(__file__), "empty-zillion-map-row-col-labels-281.png") zillion_map = os.path.join(os.path.dirname(__file__), "empty-zillion-map-row-col-labels-281.png")
def detect_test() -> bool:
"""
Parts of generation that are in unit tests need the rom.
This is to detect whether we are running unit tests
so we can work around the need for the rom.
"""
import __main__
try:
if "test" in __main__.__file__:
return True
except AttributeError:
# In some environments, __main__ doesn't have __file__
# We'll assume that's not unit tests.
pass
return False