mirror of
https://github.com/ArchipelagoMW/Archipelago.git
synced 2026-03-22 07:35:37 -07:00
Core: Prevent people from using LogicMixin incorrectly
There's a world that ran into some issues because it defined its custom LogicMixin variables at the class level. This caused "instance bleed" when new CollectionState objects were created. I don't think there is ever a reason to have a non-function class variable on LogicMixin without also having `init_mixin`, so this asserts that this is the case. Tested: Doesn't fail any current worlds Correctly fails the world in question Also, not gonna call out that world because it was literally my fault for explaining it to them wrong :D
This commit is contained in:
@@ -107,6 +107,11 @@ class AutoLogicRegister(type):
|
||||
elif not item_name.startswith("__"):
|
||||
if hasattr(CollectionState, item_name):
|
||||
raise Exception(f"Name conflict on Logic Mixin {name} trying to overwrite {item_name}")
|
||||
|
||||
assert callable(function) or "init_mixin" in dct, (
|
||||
f"{name} defined class variable {item_name} without also having init_mixin."
|
||||
)
|
||||
|
||||
setattr(CollectionState, item_name, function)
|
||||
return new_class
|
||||
|
||||
|
||||
Reference in New Issue
Block a user