Made Empty cmdsets have priority -100, also changed their key from "Empty" to _EMPTY_CMDSET to make it clearer this is a special name. See also discussion in Issue 447.
This commit is contained in:
parent
acbfa57240
commit
48bfc7e54a
3 changed files with 13 additions and 7 deletions
|
|
@ -200,7 +200,7 @@ def get_and_merge_cmdsets(caller, session, player, obj,
|
||||||
|
|
||||||
# weed out all non-found sets
|
# weed out all non-found sets
|
||||||
cmdsets = yield [cmdset for cmdset in cmdsets
|
cmdsets = yield [cmdset for cmdset in cmdsets
|
||||||
if cmdset and cmdset.key != "Empty"]
|
if cmdset and cmdset.key != "_EMPTY_CMDSET"]
|
||||||
# report cmdset errors to user (these should already have been logged)
|
# report cmdset errors to user (these should already have been logged)
|
||||||
yield [report_to.msg(cmdset.errmessage) for cmdset in cmdsets
|
yield [report_to.msg(cmdset.errmessage) for cmdset in cmdsets
|
||||||
if cmdset.key == "_CMDSET_ERROR"]
|
if cmdset.key == "_CMDSET_ERROR"]
|
||||||
|
|
@ -218,6 +218,7 @@ def get_and_merge_cmdsets(caller, session, player, obj,
|
||||||
tempmergers = {}
|
tempmergers = {}
|
||||||
for cmdset in cmdsets:
|
for cmdset in cmdsets:
|
||||||
prio = cmdset.priority
|
prio = cmdset.priority
|
||||||
|
#print cmdset.key, prio
|
||||||
if prio in tempmergers:
|
if prio in tempmergers:
|
||||||
# merge same-prio cmdset together separately
|
# merge same-prio cmdset together separately
|
||||||
tempmergers[prio] = yield cmdset + tempmergers[prio]
|
tempmergers[prio] = yield cmdset + tempmergers[prio]
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,11 @@ class _ErrorCmdSet(CmdSet):
|
||||||
key = "_CMDSET_ERROR"
|
key = "_CMDSET_ERROR"
|
||||||
errmessage = "Error when loading cmdset."
|
errmessage = "Error when loading cmdset."
|
||||||
|
|
||||||
|
class _EmptyCmdSet(CmdSet):
|
||||||
|
"This cmdset represents an empty cmdset"
|
||||||
|
key = "_EMPTY_CMDSET"
|
||||||
|
priority = -100
|
||||||
|
mergetype = "Union"
|
||||||
|
|
||||||
def import_cmdset(python_path, cmdsetobj, emit_to_obj=None, no_logging=False):
|
def import_cmdset(python_path, cmdsetobj, emit_to_obj=None, no_logging=False):
|
||||||
"""
|
"""
|
||||||
|
|
@ -166,7 +171,7 @@ class CmdSetHandler(object):
|
||||||
# this holds the "merged" current command set
|
# this holds the "merged" current command set
|
||||||
self.current = None
|
self.current = None
|
||||||
# this holds a history of CommandSets
|
# this holds a history of CommandSets
|
||||||
self.cmdset_stack = [CmdSet(cmdsetobj=self.obj, key="Empty")]
|
self.cmdset_stack = [_EmptyCmdSet(cmdsetobj=self.obj)]
|
||||||
# this tracks which mergetypes are actually in play in the stack
|
# this tracks which mergetypes are actually in play in the stack
|
||||||
self.mergetype_stack = ["Union"]
|
self.mergetype_stack = ["Union"]
|
||||||
|
|
||||||
|
|
@ -244,7 +249,7 @@ class CmdSetHandler(object):
|
||||||
self.cmdset_stack = []
|
self.cmdset_stack = []
|
||||||
for pos, path in enumerate(storage):
|
for pos, path in enumerate(storage):
|
||||||
if pos == 0 and not path:
|
if pos == 0 and not path:
|
||||||
self.cmdset_stack = [CmdSet(cmdsetobj=self.obj, key="Empty")]
|
self.cmdset_stack = [EmptyCmdSet(cmdsetobj=self.obj)]
|
||||||
elif path:
|
elif path:
|
||||||
cmdset = self._import_cmdset(path)
|
cmdset = self._import_cmdset(path)
|
||||||
if cmdset:
|
if cmdset:
|
||||||
|
|
@ -410,9 +415,9 @@ class CmdSetHandler(object):
|
||||||
else:
|
else:
|
||||||
storage = [""]
|
storage = [""]
|
||||||
self.cmdset_storage = storage
|
self.cmdset_storage = storage
|
||||||
self.cmdset_stack[0] = CmdSet(cmdsetobj=self.obj, key="Empty")
|
self.cmdset_stack[0] = EmptyCmdSet(cmdsetobj=self.obj)
|
||||||
else:
|
else:
|
||||||
self.cmdset_stack = [CmdSet(cmdsetobj=self.obj, key="Empty")]
|
self.cmdset_stack = [EmptyCmdSet(cmdsetobj=self.obj)]
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
def all(self):
|
def all(self):
|
||||||
|
|
@ -453,7 +458,7 @@ class CmdSetHandler(object):
|
||||||
new_cmdset_stack = []
|
new_cmdset_stack = []
|
||||||
new_mergetype_stack = []
|
new_mergetype_stack = []
|
||||||
for cmdset in self.cmdset_stack:
|
for cmdset in self.cmdset_stack:
|
||||||
if cmdset.key == "Empty":
|
if cmdset.key == "_EMPTY_CMDSET":
|
||||||
new_cmdset_stack.append(cmdset)
|
new_cmdset_stack.append(cmdset)
|
||||||
new_mergetype_stack.append("Union")
|
new_mergetype_stack.append("Union")
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -1685,7 +1685,7 @@ class CmdExamine(ObjManipCommand):
|
||||||
|
|
||||||
string += "\n{wLocks{n:%s" % locks_string
|
string += "\n{wLocks{n:%s" % locks_string
|
||||||
|
|
||||||
if not (len(obj.cmdset.all()) == 1 and obj.cmdset.current.key == "Empty"):
|
if not (len(obj.cmdset.all()) == 1 and obj.cmdset.current.key == "_EMPTY_CMDSET"):
|
||||||
# list the current cmdsets
|
# list the current cmdsets
|
||||||
all_cmdsets = (obj.cmdset.all() +
|
all_cmdsets = (obj.cmdset.all() +
|
||||||
(hasattr(obj, "player") and obj.player and
|
(hasattr(obj, "player") and obj.player and
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue