Make @typeclass/reset also purge cmdsets. Resolves #1000.
This commit is contained in:
parent
89fbc44d15
commit
2d35c71cd1
2 changed files with 7 additions and 2 deletions
|
|
@ -1641,7 +1641,7 @@ class CmdTypeclass(COMMAND_DEFAULT_CLASS):
|
||||||
old_typeclass_path = obj.typeclass_path
|
old_typeclass_path = obj.typeclass_path
|
||||||
|
|
||||||
# we let this raise exception if needed
|
# we let this raise exception if needed
|
||||||
obj.swap_typeclass(new_typeclass, clean_attributes=reset)
|
obj.swap_typeclass(new_typeclass, clean_attributes=reset, clean_cmdsets=reset)
|
||||||
|
|
||||||
if is_same:
|
if is_same:
|
||||||
string = "%s updated its existing typeclass (%s).\n" % (obj.name, obj.path)
|
string = "%s updated its existing typeclass (%s).\n" % (obj.name, obj.path)
|
||||||
|
|
|
||||||
|
|
@ -407,7 +407,7 @@ class TypedObject(SharedMemoryModel):
|
||||||
return any(hasattr(cls, "path") and cls.path in typeclass for cls in self.__class__.mro())
|
return any(hasattr(cls, "path") and cls.path in typeclass for cls in self.__class__.mro())
|
||||||
|
|
||||||
def swap_typeclass(self, new_typeclass, clean_attributes=False,
|
def swap_typeclass(self, new_typeclass, clean_attributes=False,
|
||||||
run_start_hooks=True, no_default=True):
|
run_start_hooks=True, no_default=True, clean_cmdsets=False):
|
||||||
"""
|
"""
|
||||||
This performs an in-situ swap of the typeclass. This means
|
This performs an in-situ swap of the typeclass. This means
|
||||||
that in-game, this object will suddenly be something else.
|
that in-game, this object will suddenly be something else.
|
||||||
|
|
@ -437,6 +437,7 @@ class TypedObject(SharedMemoryModel):
|
||||||
allow for swapping to a default typeclass in case the
|
allow for swapping to a default typeclass in case the
|
||||||
given one fails for some reason. Instead the old one will
|
given one fails for some reason. Instead the old one will
|
||||||
be preserved.
|
be preserved.
|
||||||
|
clean_cmdsets (bool, optional): Delete all cmdsets on the object.
|
||||||
Returns:
|
Returns:
|
||||||
result (bool): True/False depending on if the swap worked
|
result (bool): True/False depending on if the swap worked
|
||||||
or not.
|
or not.
|
||||||
|
|
@ -470,6 +471,10 @@ class TypedObject(SharedMemoryModel):
|
||||||
else:
|
else:
|
||||||
self.attributes.clear()
|
self.attributes.clear()
|
||||||
self.nattributes.clear()
|
self.nattributes.clear()
|
||||||
|
if clean_cmdsets:
|
||||||
|
# purge all cmdsets
|
||||||
|
self.cmdset.clear()
|
||||||
|
self.cmdset.remove_default()
|
||||||
|
|
||||||
if run_start_hooks:
|
if run_start_hooks:
|
||||||
# fake this call to mimic the first save
|
# fake this call to mimic the first save
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue