From 635200ca176caf28981a49e391beb1ef899c1979 Mon Sep 17 00:00:00 2001 From: Scyfris Talivinsky Date: Sat, 30 Sep 2017 18:18:54 -0700 Subject: [PATCH 1/2] Fix locationless spawned objects Spawned objects were not getting locations assigned to them. By default the locations should be assigned to the caller's location. --- evennia/commands/default/building.py | 2 +- evennia/utils/spawner.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/evennia/commands/default/building.py b/evennia/commands/default/building.py index 61a46bde30..9170f3c9ff 100644 --- a/evennia/commands/default/building.py +++ b/evennia/commands/default/building.py @@ -2718,7 +2718,7 @@ class CmdSpawn(COMMAND_DEFAULT_CLASS): self.caller.msg("The prototype must be a prototype key or a Python dictionary.") return - if "noloc" in self.switches and not "location" not in prototype: + if "noloc" not in self.switches and "location" not in prototype: prototype["location"] = self.caller.location for obj in spawn(prototype): diff --git a/evennia/utils/spawner.py b/evennia/utils/spawner.py index 423fc8225b..4a8ac946c8 100644 --- a/evennia/utils/spawner.py +++ b/evennia/utils/spawner.py @@ -100,7 +100,7 @@ _CREATE_OBJECT_KWARGS = ("key", "location", "home", "destination") def _handle_dbref(inp): - dbid_to_obj(inp, ObjectDB) + return dbid_to_obj(inp, ObjectDB) def _validate_prototype(key, prototype, protparents, visited): From 5871e64681e516e1681389ba73daeff2119de509 Mon Sep 17 00:00:00 2001 From: Griatch Date: Sun, 1 Oct 2017 09:43:33 +0200 Subject: [PATCH 2/2] Fix unittest for mail contrib update --- evennia/contrib/mail.py | 10 +++++----- evennia/contrib/tests.py | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/evennia/contrib/mail.py b/evennia/contrib/mail.py index 48369083d1..6e8585136d 100644 --- a/evennia/contrib/mail.py +++ b/evennia/contrib/mail.py @@ -133,7 +133,7 @@ class CmdMail(default_cmds.MuxCommand): return else: all_mail = self.get_all_mail() - mind_max = all_mail.count() - 1 + mind_max = max(0, all_mail.count() - 1) mind = max(0, min(mind_max, int(self.lhs) - 1)) if all_mail[mind]: all_mail[mind].delete() @@ -154,7 +154,7 @@ class CmdMail(default_cmds.MuxCommand): return else: all_mail = self.get_all_mail() - mind_max = all_mail.count() - 1 + mind_max = max(0, all_mail.count() - 1) if "/" in self.rhs: message_number, message = self.rhs.split("/", 1) mind = max(0, min(mind_max, int(message_number) - 1)) @@ -193,7 +193,7 @@ class CmdMail(default_cmds.MuxCommand): return else: all_mail = self.get_all_mail() - mind_max = all_mail.count() - 1 + mind_max = max(0, all_mail.count() - 1) mind = max(0, min(mind_max, int(self.lhs) - 1)) if all_mail[mind]: old_message = all_mail[mind] @@ -218,9 +218,9 @@ class CmdMail(default_cmds.MuxCommand): self.send_mail(self.search_targets(self.lhslist), subject, body, self.caller) else: all_mail = self.get_all_mail() - mind_max = all_mail.count() - 1 + mind_max = max(0, all_mail.count() - 1) try: - mind = max(0, min(mind_max, self.lhs - 1)) + mind = max(0, min(mind_max, int(self.lhs) - 1)) message = all_mail[mind] except (ValueError, IndexError): self.caller.msg("'%s' is not a valid mail id." % self.lhs) diff --git a/evennia/contrib/tests.py b/evennia/contrib/tests.py index 2342c4d17a..1678d06567 100644 --- a/evennia/contrib/tests.py +++ b/evennia/contrib/tests.py @@ -661,6 +661,7 @@ from evennia.contrib import mail class TestMail(CommandTest): def test_mail(self): self.call(mail.CmdMail(), "2", "'2' is not a valid mail id.", caller=self.account) + self.call(mail.CmdMail(), "test", "'test' is not a valid mail id.") self.call(mail.CmdMail(), "", "There are no messages in your inbox.", caller=self.account) self.call(mail.CmdMail(), "Char=Message 1", "You have received a new @mail from Char|You sent your message.", caller=self.char1) self.call(mail.CmdMail(), "Char=Message 2", "You sent your message.", caller=self.char2)