mirror of
https://github.com/evennia/evennia.git
synced 2026-03-28 02:36:32 +01:00
MULTISESSION_MODE 0-2 works as they should. Remains some fixes to migrations.
This commit is contained in:
parent
efc078b78c
commit
c967cc7914
4 changed files with 21 additions and 14 deletions
|
|
@ -824,13 +824,17 @@ class CmdOOCLook(MuxCommandOOC, CmdLook):
|
|||
sessions = player.get_all_sessions()
|
||||
|
||||
sessidstr = sessid and " (session id %i)" % sessid or ""
|
||||
string = "%sYou are logged in as {g%s{n%s." % (" "*10,player.key, sessidstr)
|
||||
string = "You are logged in as {g%s{n%s." % (player.key, sessidstr)
|
||||
|
||||
string += "\n\nSession(s) connected:"
|
||||
for sess in sessions:
|
||||
csessid = sess.sessid
|
||||
string += "\n %s %s" % (sessid == csessid and "{w%i{n" % csessid or csessid, sess.address)
|
||||
string += "\n\nUse {w@ic <character>{n to enter the game, {w@occ{n to get back here."
|
||||
if not characters:
|
||||
string += "\nYou don't have any character yet. Use {w@charcreate <name> [=description]{n to create one."
|
||||
elif len(characters) < MAX_NR_CHARACTERS:
|
||||
string += "\nUse {w@charcreate <name> [=description]{n to create a new character (max %i)" % MAX_NR_CHARACTERS
|
||||
if characters:
|
||||
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 "")
|
||||
|
|
|
|||
|
|
@ -126,8 +126,6 @@ class PlayerDB(TypedObject):
|
|||
|
||||
The PlayerDB adds the following properties:
|
||||
user - Connected User object. django field, needs to be save():d.
|
||||
obj - game object controlled by player
|
||||
character - alias for obj
|
||||
name - alias for user.username
|
||||
sessions - sessions connected to this player
|
||||
is_superuser - bool if this player is a superuser
|
||||
|
|
@ -144,11 +142,6 @@ class PlayerDB(TypedObject):
|
|||
# this profile model. It is required by django.
|
||||
user = models.ForeignKey(User, unique=True, db_index=True,
|
||||
help_text="The <I>User</I> object holds django-specific authentication for each Player. A unique User should be created and tied to each Player, the two should never be switched or changed around. The User will be deleted automatically when the Player is.")
|
||||
# the in-game object connected to this player (if any).
|
||||
# Use the property 'obj' to access.
|
||||
db_objs = models.ManyToManyField("objects.ObjectDB", null=True,
|
||||
verbose_name="characters", related_name="objs_set",
|
||||
help_text="In-game objects.")
|
||||
# store a connected flag here too, not just in sessionhandler.
|
||||
# This makes it easier to track from various out-of-process locations
|
||||
db_is_connected = models.BooleanField(default=False, verbose_name="is_connected", help_text="If player is connected to game or not")
|
||||
|
|
@ -327,7 +320,7 @@ class PlayerDB(TypedObject):
|
|||
session = _MULTISESSION_MODE == 2 and sessid and _GA(self, "get_session")(sessid) or None
|
||||
if session:
|
||||
obj = session.puppet
|
||||
if char and not char.at_msg_receive(outgoing_string, from_obj=from_obj, data=data):
|
||||
if obj and not obj.at_msg_receive(outgoing_string, from_obj=from_obj, data=data):
|
||||
# if hook returns false, cancel send
|
||||
return
|
||||
session.msg(outgoing_string, data)
|
||||
|
|
@ -347,6 +340,11 @@ class PlayerDB(TypedObject):
|
|||
data - dictionary of optional data
|
||||
session - session sending this data (no need to look it up again)
|
||||
"""
|
||||
if _MULTISESSION_MODE == 1:
|
||||
# many sessions - one puppet
|
||||
sessions = [session for session in self.get_all_sessions() if session.puppet]
|
||||
session = sessions and sessions[0] or session
|
||||
|
||||
puppet = session.puppet
|
||||
if puppet:
|
||||
# execute command on the puppeted object (this will include
|
||||
|
|
|
|||
|
|
@ -256,7 +256,7 @@ class Player(TypeClass):
|
|||
to store attributes all players should have,
|
||||
like configuration values etc.
|
||||
"""
|
||||
# set an attribute holding the characters this player has
|
||||
# set an (empty) attribute holding the characters this player has
|
||||
lockstring = "attrread:perm(Admins);attredit:perm(Admins);attrcreate:perm(Admins)"
|
||||
self.set_attribute("_playable_characters", [], lockstring=lockstring)
|
||||
|
||||
|
|
@ -323,11 +323,17 @@ class Player(TypeClass):
|
|||
at_post_login hook.
|
||||
"""
|
||||
self._send_to_connect_channel("{G%s connected{n" % self.key)
|
||||
if _MULTISESSION_MODE in (0, 1):
|
||||
# in these modes we should have only one character available. We
|
||||
if _MULTISESSION_MODE == 0:
|
||||
# in this mode we should have only one character available. We
|
||||
# try to auto-connect to it by calling the @ic command
|
||||
# (this relies on player.db._last_puppet being set)
|
||||
self.execute_cmd("@ic")
|
||||
elif _MULTISESSION_MODE == 1:
|
||||
# in this mode the first session to connect acts like mode 0,
|
||||
# the following sessions "share" the same view and should
|
||||
# not perform any actions
|
||||
if not self.get_all_puppets():
|
||||
self.execute_cmd("@ic")
|
||||
elif _MULTISESSION_MODE == 2:
|
||||
# In this mode we by default end up at a character selection
|
||||
# screen. We execute look on the player.
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ def create_objects():
|
|||
god_character.set_attribute("_superuser_character", True)
|
||||
god_player.set_attribute("_first_login", True)
|
||||
god_player.set_attribute("_last_puppet", god_character)
|
||||
god_player.db._playable_characters.append(god_character)
|
||||
|
||||
# Limbo is the default "nowhere" starting room
|
||||
|
||||
|
|
@ -84,8 +85,6 @@ def create_objects():
|
|||
god_character.location = limbo_obj
|
||||
if not god_character.home:
|
||||
god_character.home = limbo_obj
|
||||
# store in list as playable character
|
||||
god_player.db._playable_characters.append(god_character)
|
||||
|
||||
def create_channels():
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue