mirror of
https://github.com/evennia/evennia.git
synced 2026-04-02 22:17:17 +02:00
Disallow re-naming and re-aliasing duplicates.
This commit is contained in:
parent
899136760e
commit
65d8ac8bdc
2 changed files with 11 additions and 6 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue