Added functionality for MULTISESSION_MODE of types 0 and 1.
This commit is contained in:
parent
11d612a72a
commit
b5ccad21c5
3 changed files with 10 additions and 25 deletions
|
|
@ -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
|
Player manager's methods to create users, since that automatically
|
||||||
adds the profile extension.
|
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
|
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
|
persistently store attributes of its own. This is ideal for extra
|
||||||
account info and OOC account configuration variables etc.
|
account info and OOC account configuration variables etc.
|
||||||
|
|
@ -59,6 +42,7 @@ __all__ = ("PlayerAttribute", "PlayerNick", "PlayerDB")
|
||||||
|
|
||||||
_SESSIONS = None
|
_SESSIONS = None
|
||||||
_AT_SEARCH_RESULT = utils.variable_from_module(*settings.SEARCH_AT_RESULT.rsplit('.', 1))
|
_AT_SEARCH_RESULT = utils.variable_from_module(*settings.SEARCH_AT_RESULT.rsplit('.', 1))
|
||||||
|
_MULTISESSION_MODE = settings.MULTISESSION_MODE
|
||||||
|
|
||||||
_GA = object.__getattribute__
|
_GA = object.__getattribute__
|
||||||
_SA = object.__setattr__
|
_SA = object.__setattr__
|
||||||
|
|
@ -390,7 +374,7 @@ class PlayerDB(TypedObject):
|
||||||
pass
|
pass
|
||||||
outgoing_string = utils.to_str(outgoing_string, force_string=True)
|
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:
|
if session:
|
||||||
char = _GA(self, "get_character")(sessid=sessid)
|
char = _GA(self, "get_character")(sessid=sessid)
|
||||||
if char and not char.at_msg_receive(outgoing_string, from_obj=from_obj, data=data):
|
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)
|
ingoing_string - text string (i.e. command string)
|
||||||
data - dictionary of optional data
|
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)
|
character = _GA(self, "get_character")(sessid=sessid)
|
||||||
if character:
|
if character:
|
||||||
# execute command on 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
|
return char and (return_dbobj and char[0] or char[0].typeclass) or None
|
||||||
else:
|
else:
|
||||||
# no sessid given - return all available characters
|
# 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):
|
def get_all_characters(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,6 @@ SSYNC = chr(8) # server session sync
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
|
|
||||||
SERVERNAME = settings.SERVERNAME
|
SERVERNAME = settings.SERVERNAME
|
||||||
#ALLOW_MULTISESSION = settings.ALLOW_MULTISESSION
|
|
||||||
MULTISESSION_MODE = settings.MULTISESSION_MODE
|
MULTISESSION_MODE = settings.MULTISESSION_MODE
|
||||||
IDLE_TIMEOUT = settings.IDLE_TIMEOUT
|
IDLE_TIMEOUT = settings.IDLE_TIMEOUT
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -285,17 +285,17 @@ TIME_MONTH_PER_YEAR = 12
|
||||||
# Default Player setup and access
|
# 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:
|
# 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
|
# 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, each session controlling different characters
|
||||||
MULTISESSION_MODE = 0
|
MULTISESSION_MODE = 0
|
||||||
# The maximum number of characters allowed for MULTISESSION_MODE 1 or 2. This is checked
|
# 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
|
MAX_NR_CHARACTERS = 2
|
||||||
# The access hiearchy, in climbing order. A higher permission in the
|
# 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")
|
PERMISSION_HIERARCHY = ("Players","PlayerHelpers","Builders", "Wizards", "Immortals")
|
||||||
# The default permission given to all new players
|
# The default permission given to all new players
|
||||||
PERMISSION_PLAYER_DEFAULT = "Players"
|
PERMISSION_PLAYER_DEFAULT = "Players"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue