From 65d8ac8bdc8153433b3736600576b02c0e0519aa Mon Sep 17 00:00:00 2001 From: Greg Taylor Date: Mon, 6 Apr 2009 22:24:49 +0000 Subject: [PATCH] Disallow re-naming and re-aliasing duplicates. --- src/commands/objmanip.py | 10 +++++++++- src/objects/models.py | 7 ++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/commands/objmanip.py b/src/commands/objmanip.py index 754fa8baf2..6ded1d3150 100644 --- a/src/commands/objmanip.py +++ b/src/commands/objmanip.py @@ -6,6 +6,7 @@ from src.objects.models import Object, Attribute import src.flags from src import ansi from src.cmdtable import GLOBAL_CMD_TABLE +from src import defines_global def cmd_teleport(command): """ @@ -95,7 +96,8 @@ def cmd_alias(command): source_object.emit_to("Aliases must be alphanumeric.") return - old_alias = target.get_attribute_value('ALIAS') + old_alias = target.get_attribute_value('ALIAS', default='') + print "ALIAS", old_alias duplicates = Object.objects.player_alias_search(source_object, new_alias) if not duplicates or old_alias.lower() == new_alias.lower(): # Either no duplicates or just changing the case of existing alias. @@ -668,6 +670,12 @@ def cmd_name(command): return ansi_name = ansi.parse_ansi(new_name, strip_formatting=True) + + if Object.objects.filter(name__iexact=new_name, + type=defines_global.OTYPE_PLAYER): + source_object.emit_to("There is already a player with that name.") + return + source_object.emit_to("You have renamed %s to %s." % (target_obj, ansi_name)) target_obj.set_name(new_name) diff --git a/src/objects/models.py b/src/objects/models.py index 0184f3ac97..13948cc5bb 100755 --- a/src/objects/models.py +++ b/src/objects/models.py @@ -793,7 +793,7 @@ class Object(models.Model): self.script_parent = parent_str.strip() self.save() - def get_attribute_value(self, attrib, default=False): + def get_attribute_value(self, attrib, default=None): """ Returns the value of an attribute on an object. You may need to type cast the returned value from this function! @@ -804,10 +804,7 @@ class Object(models.Model): attrib = Attribute.objects.filter(attr_object=self).filter(attr_name=attrib) return attrib[0].attr_value else: - if default: - return default - else: - return False + return default def get_attribute_obj(self, attrib): """