Added a check to avoid creating a duplicate character name with charcreate in MULTISESSION_MODE>1. Resolves 943.

This commit is contained in:
Griatch 2016-04-11 20:05:58 +02:00
parent 8844b7bb80
commit 37a24f12e6

View file

@ -136,14 +136,22 @@ class CmdCharCreate(MuxPlayerCommand):
len(player.db._playable_characters) >= charmax):
self.msg("You may only create a maximum of %i characters." % charmax)
return
# create the character
from evennia.objects.models import ObjectDB
typeclass = settings.BASE_CHARACTER_TYPECLASS
if ObjectDB.objects.filter(db_typeclass_path=typeclass, db_key__iexact=key):
# check if this Character already exists. Note that we are only
# searching the base character typeclass here, not any child
# classes.
self.msg("{rA character named '{w%s{r' already exists.{n" % key)
return
# create the character
start_location = ObjectDB.objects.get_id(settings.START_LOCATION)
default_home = ObjectDB.objects.get_id(settings.DEFAULT_HOME)
typeclass = settings.BASE_CHARACTER_TYPECLASS
permissions = settings.PERMISSION_PLAYER_DEFAULT
new_character = create.create_object(typeclass, key=key,
location=start_location,
home=default_home,