diff --git a/src/commands/default/general.py b/src/commands/default/general.py index 09624456b5..b30376f6f3 100644 --- a/src/commands/default/general.py +++ b/src/commands/default/general.py @@ -9,7 +9,9 @@ from src.utils import utils, search, create from src.objects.models import ObjectNick as Nick from src.commands.default.muxcommand import MuxCommand, MuxCommandOOC -from settings import MAX_NR_CHARACTERS +from settings import MAX_NR_CHARACTERS, MULTISESSION_MODE +# force max nr chars to 1 if mode is 0 or 1 +MAX_NR_CHARACTERS = MULTISESSION_MODE < 2 and 1 or MAX_NR_CHARACTERS # limit symbol import for API __all__ = ("CmdHome", "CmdLook", "CmdPassword", "CmdNick", @@ -822,7 +824,7 @@ class CmdOOCLook(MuxCommandOOC, CmdLook): sessions = player.get_all_sessions() sessidstr = sessid and " (session id %i)" % sessid or "" - string = "You are logged in as {g%s{n%s." % (player.key, sessidstr) + string = "%sYou are logged in as {g%s{n%s." % (" "*10,player.key, sessidstr) string += "\n\nSession(s) connected:" for sess in sessions: @@ -830,7 +832,8 @@ class CmdOOCLook(MuxCommandOOC, CmdLook): string += "\n %s %s" % (sessid == csessid and "{w%i{n" % csessid or csessid, sess.address) string += "\n\nUse {w@ic {n to enter the game, {w@occ{n to get back here." if characters: - string += "\n\nAvailable character%s:" % (len(characters) > 1 and "s" or "") + string += "\n\nAvailable character%s%s:" % (len(characters) > 1 and "s" or "", + MAX_NR_CHARACTERS > 1 and " (out of a maximum of %i)" % MAX_NR_CHARACTERS or "") for char in characters: csessid = char.sessid if csessid: @@ -854,6 +857,11 @@ class CmdOOCLook(MuxCommandOOC, CmdLook): def func(self): "implement the ooc look command" + if MULTISESSION_MODE < 2: + # only one character allowed + string = "You are out-of-character (OOC).\nUse {w@ic{n to get back into the game." + self.msg(string) + return if utils.inherits_from(self.caller, "src.objects.objects.Object"): # An object of some type is calling. Use default look instead. super(CmdOOCLook, self).func() diff --git a/src/commands/default/unloggedin.py b/src/commands/default/unloggedin.py index ac29d311e5..59c791db76 100644 --- a/src/commands/default/unloggedin.py +++ b/src/commands/default/unloggedin.py @@ -17,6 +17,7 @@ from src.commands.cmdhandler import CMD_LOGINSTART # limit symbol import for API __all__ = ("CmdUnconnectedConnect", "CmdUnconnectedCreate", "CmdUnconnectedQuit", "CmdUnconnectedLook", "CmdUnconnectedHelp") +MULTISESSION_MODE = settings.MULTISESSION_MODE CONNECTION_SCREEN_MODULE = settings.CONNECTION_SCREEN_MODULE CONNECTION_SCREEN = "" try: @@ -164,12 +165,6 @@ class CmdUnconnectedCreate(MuxCommand): new_player = create.create_player(playername, None, password, permissions=permissions) - # create character to go with player - new_character = create.create_object(typeclass, key=playername, - location=default_home, home=default_home, - permissions=permissions) - # set list - new_player.db._playable_characters.append(new_character) except Exception, e: session.msg("There was an error creating the default Player/Character:\n%s\n If this problem persists, contact an admin." % e) @@ -187,14 +182,24 @@ class CmdUnconnectedCreate(MuxCommand): string = "New player '%s' could not connect to public channel!" % new_player.key logger.log_errmsg(string) - # allow only the character itself and the player to puppet this character (and Immortals). - new_character.locks.add("puppet:id(%i) or pid(%i) or perm(Immortals) or pperm(Immortals)" % - (new_character.id, new_player.id)) + if MULTISESSION_MODE < 2: + # if we only allow one character, create one with the same name as Player + # (in mode 2, the character must be created manually once logging in) + new_character = create.create_object(typeclass, key=playername, + location=default_home, home=default_home, + permissions=permissions) + # set playable character list + new_player.db._playable_characters.append(new_character) + + # allow only the character itself and the player to puppet this character (and Immortals). + new_character.locks.add("puppet:id(%i) or pid(%i) or perm(Immortals) or pperm(Immortals)" % + (new_character.id, new_player.id)) + + # If no description is set, set a default description + if not new_character.db.desc: + new_character.db.desc = "This is a Player." - # If no description is set, set a default description - if not new_character.db.desc: - new_character.db.desc = "This is a Player." # tell the caller everything went well. string = "A new account '%s' was created. Welcome!" diff --git a/src/settings_default.py b/src/settings_default.py index 1e73b496c8..d3a833b43c 100644 --- a/src/settings_default.py +++ b/src/settings_default.py @@ -286,14 +286,16 @@ TIME_MONTH_PER_YEAR = 12 ###################################################################### # Different Multisession modes allow a player (=account) to connect to the game simultaneously -# with multiple clients (=sessions) in various ways according to the set mode: +# with multiple clients (=sessions). In modes 0,1 there is only one character created to the same +# name as the account at first login. In modes 1,2 no default character will be created and +# the MAX_NR_CHARACTERS value (below) defines how many characters are allowed. # 0 - single session, one player, one character, when a new session is connected, the old one is disconnected # 1 - multiple sessions, one player, one character, each session getting the same data -# 2 - multiple sessions, one player, each session controlling different characters +# 2 - multiple sessions, one player, many characters, each session getting data from different characters MULTISESSION_MODE = 0 -# The maximum number of characters allowed for MULTISESSION_MODE 1 or 2. This is checked -# by the default char-creation commands in this mode. Forced to 1 for MULTISESSION_MODE 0. -MAX_NR_CHARACTERS = 2 +# The maximum number of characters allowed for MULTISESSION_MODE 2. This is checked +# by the default ooc char-creation command. Forced to 1 for MULTISESSION_MODE 0 and 1. +MAX_NR_CHARACTERS = 1 # The access hiearchy, in climbing order. A higher permission in the # hierarchy includes access of all levels below it. Used by the perm()/pperm() lock functions. PERMISSION_HIERARCHY = ("Players","PlayerHelpers","Builders", "Wizards", "Immortals")