Fix reference error in get_input. Resolves #1219.

This commit is contained in:
Griatch 2017-02-18 19:21:43 +01:00
parent a651490565
commit 865ab131bb

View file

@ -888,13 +888,12 @@ class CmdGetInput(Command):
def func(self): def func(self):
"This is called when user enters anything." "This is called when user enters anything."
caller = self.caller caller = self.caller
callback = caller.ndb._getinput._callback try:
if not callback: getinput = caller.ndb._getinput
# this can be happen if called from a player-command when IC if not getinput and hasattr(caller, "player"):
caller = self.player getinput = caller.player.ndb._getinput
callback = caller.ndb._getinput._callback caller = caller.player
if not callback: callback = getinput._callback
raise RuntimeError("No input callback found.")
caller.ndb._getinput._session = self.session caller.ndb._getinput._session = self.session
prompt = caller.ndb._getinput._prompt prompt = caller.ndb._getinput._prompt
@ -906,6 +905,11 @@ class CmdGetInput(Command):
# anything # anything
del caller.ndb._getinput del caller.ndb._getinput
caller.cmdset.remove(InputCmdSet) caller.cmdset.remove(InputCmdSet)
except Exception:
# make sure to clean up cmdset if something goes wrong
caller.msg("|rError in get_input. Choice not confirmed (report to admin)|n")
logger.log_trace("Error in get_input")
caller.cdmset.remove(InputCmdSet)
class InputCmdSet(CmdSet): class InputCmdSet(CmdSet):