From ecfb86072dae983c44dea2f2725c60e5c4574f9c Mon Sep 17 00:00:00 2001 From: Johnny Date: Wed, 24 Oct 2018 18:57:48 +0000 Subject: [PATCH] Minor fixes to handle addition of created chars to account playable characters list, and check for multisession mode compliance. --- evennia/accounts/accounts.py | 3 ++- evennia/objects/objects.py | 12 ++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/evennia/accounts/accounts.py b/evennia/accounts/accounts.py index 86573f389c..2a8915a59c 100644 --- a/evennia/accounts/accounts.py +++ b/evennia/accounts/accounts.py @@ -733,7 +733,8 @@ class DefaultAccount(with_metaclass(TypeclassBase, AccountDB)): if character: # Update playable character list - account.db._playable_characters.append(character) + if character not in account.characters: + account.db._playable_characters.append(character) # We need to set this to have @ic auto-connect to this character account.db._last_puppet = character diff --git a/evennia/objects/objects.py b/evennia/objects/objects.py index f41dd02d02..0dca98ef75 100644 --- a/evennia/objects/objects.py +++ b/evennia/objects/objects.py @@ -1944,12 +1944,20 @@ class DefaultCharacter(DefaultObject): locks = kwargs.pop('locks', '') try: + # Check to make sure account does not have too many chars + if len(account.characters) >= settings.MAX_NR_CHARACTERS: + errors.append("There are too many characters associated with this account.") + return obj, errors + # Create the Character obj = create.create_object(**kwargs) # Record creator id and creation IP if ip: obj.db.creator_ip = ip - if account: obj.db.creator_id = account.id + if account: + obj.db.creator_id = account.id + if obj not in account.characters: + account.db._playable_characters.append(obj) # Add locks if not locks and account: @@ -1963,7 +1971,7 @@ class DefaultCharacter(DefaultObject): # If no description is set, set a default description if description or not obj.db.desc: obj.db.desc = description if description else "This is a character." - + except Exception as e: errors.append("An error occurred while creating this '%s' object." % key) logger.log_err(e)