diff --git a/src/players/models.py b/src/players/models.py index 4239768b55..678fdf1aad 100644 --- a/src/players/models.py +++ b/src/players/models.py @@ -17,23 +17,6 @@ attributes on the Player. Within the game we should normally use the Player manager's methods to create users, since that automatically adds the profile extension. -The default Django permission system is geared towards web-use, and is -defined on a per-application basis permissions. In django terms, -'src/objects' is one application, 'src/scripts' another, indeed all -folders in /src with a model.py inside them is an application. Django -permissions thus have the form -e.g. 'applicationlabel.permissionstring' and django automatically -defines a set of these for editing each application from its automatic -admin interface. These are still available should you want them. - -For most in-game mud-use however, like commands and other things, it -does not make sense to tie permissions to the applications in src/ - -To the user these should all just be considered part of the game -engine. So instead we define our own separate permission system here, -borrowing heavily from the django original, but allowing the -permission string to look however we want, making them unrelated to -the applications. - To make the Player model more flexible for your own game, it can also persistently store attributes of its own. This is ideal for extra account info and OOC account configuration variables etc. @@ -59,6 +42,7 @@ __all__ = ("PlayerAttribute", "PlayerNick", "PlayerDB") _SESSIONS = None _AT_SEARCH_RESULT = utils.variable_from_module(*settings.SEARCH_AT_RESULT.rsplit('.', 1)) +_MULTISESSION_MODE = settings.MULTISESSION_MODE _GA = object.__getattribute__ _SA = object.__setattr__ @@ -390,7 +374,7 @@ class PlayerDB(TypedObject): pass outgoing_string = utils.to_str(outgoing_string, force_string=True) - session = sessid and _GA(self, "get_session")(sessid) or None + session = _MULTISESSION_MODE == 2 and sessid and _GA(self, "get_session")(sessid) or None if session: char = _GA(self, "get_character")(sessid=sessid) if char and not char.at_msg_receive(outgoing_string, from_obj=from_obj, data=data): @@ -411,8 +395,9 @@ class PlayerDB(TypedObject): ingoing_string - text string (i.e. command string) data - dictionary of optional data - session - session sending this data + sessid - session sending this data """ + if _MULTISESSION_MODE < 2: sessid = None character = _GA(self, "get_character")(sessid=sessid) if character: # execute command on character @@ -555,7 +540,8 @@ class PlayerDB(TypedObject): return char and (return_dbobj and char[0] or char[0].typeclass) or None else: # no sessid given - return all available characters - return list(return_dbobj and o or o.typeclass for o in self.db_objs.all()) + chars = list(return_dbobj and o or o.typeclass for o in self.db_objs.all()) + return len(chars) == 1 and chars[0] or chars def get_all_characters(self): """ diff --git a/src/server/sessionhandler.py b/src/server/sessionhandler.py index 39fef6a80c..ba9982b6ad 100644 --- a/src/server/sessionhandler.py +++ b/src/server/sessionhandler.py @@ -36,7 +36,6 @@ SSYNC = chr(8) # server session sync from django.utils.translation import ugettext as _ SERVERNAME = settings.SERVERNAME -#ALLOW_MULTISESSION = settings.ALLOW_MULTISESSION MULTISESSION_MODE = settings.MULTISESSION_MODE IDLE_TIMEOUT = settings.IDLE_TIMEOUT diff --git a/src/settings_default.py b/src/settings_default.py index 5a3ec2989a..1e73b496c8 100644 --- a/src/settings_default.py +++ b/src/settings_default.py @@ -285,17 +285,17 @@ TIME_MONTH_PER_YEAR = 12 # Default Player setup and access ###################################################################### -# Multisession modes allow a player (=account) to connect to the game simultaneously +# 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: -# 0 - no multisession - when a new session is connected, the old one is disconnected +# 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 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. +# by the default char-creation commands in this mode. Forced to 1 for MULTISESSION_MODE 0. MAX_NR_CHARACTERS = 2 # The access hiearchy, in climbing order. A higher permission in the -# hierarchy includes access of all levels below it. +# hierarchy includes access of all levels below it. Used by the perm()/pperm() lock functions. PERMISSION_HIERARCHY = ("Players","PlayerHelpers","Builders", "Wizards", "Immortals") # The default permission given to all new players PERMISSION_PLAYER_DEFAULT = "Players"