Fix MULTISESSION_MODE = 1
This commit is contained in:
parent
eda6cae1ef
commit
9733468098
3 changed files with 32 additions and 17 deletions
|
|
@ -203,8 +203,8 @@ class DefaultPlayer(PlayerDB):
|
||||||
txt1 = "{c%s{n{R is now acted from another of your sessions.{n"
|
txt1 = "{c%s{n{R is now acted from another of your sessions.{n"
|
||||||
txt2 = "Taking over {c%s{n from another of your sessions."
|
txt2 = "Taking over {c%s{n from another of your sessions."
|
||||||
self.unpuppet_object(obj.sessid.get())
|
self.unpuppet_object(obj.sessid.get())
|
||||||
self.msg(txt1 % obj.name, sessid=obj.sessid.get())
|
self.msg(txt1 % obj.name, sessid=obj.sessid.get(), _forced_nomulti=True)
|
||||||
self.msg(txt2 % obj.name, sessid=sessid)
|
self.msg(txt2 % obj.name, sessid=sessid, _forced_nomulti=True)
|
||||||
elif obj.player.is_connected:
|
elif obj.player.is_connected:
|
||||||
# controlled by another player
|
# controlled by another player
|
||||||
raise RuntimeError("{R{c%s{R is already puppeted by another Player.")
|
raise RuntimeError("{R{c%s{R is already puppeted by another Player.")
|
||||||
|
|
@ -244,22 +244,24 @@ class DefaultPlayer(PlayerDB):
|
||||||
"""
|
"""
|
||||||
if _MULTISESSION_MODE == 1:
|
if _MULTISESSION_MODE == 1:
|
||||||
sessions = self.get_all_sessions()
|
sessions = self.get_all_sessions()
|
||||||
|
ignore_empty = True
|
||||||
else:
|
else:
|
||||||
sessions = self.get_session(sessid)
|
sessions = self.get_session(sessid)
|
||||||
|
ignore_empty = False
|
||||||
if not sessions:
|
if not sessions:
|
||||||
raise RuntimeError("No session was found.")
|
raise RuntimeError("No session was found.")
|
||||||
for session in make_iter(sessions):
|
for session in make_iter(sessions):
|
||||||
#print "unpuppet, session:", session, session.puppet
|
|
||||||
obj = hasattr(session, "puppet") and session.puppet or None
|
obj = hasattr(session, "puppet") and session.puppet or None
|
||||||
#print "unpuppet, obj:", obj
|
if not obj and not ignore_empty:
|
||||||
if not obj:
|
|
||||||
raise RuntimeError("No puppet was found to disconnect from.")
|
raise RuntimeError("No puppet was found to disconnect from.")
|
||||||
# do the disconnect, but only if we are the last session to puppet
|
elif obj:
|
||||||
obj.at_pre_unpuppet()
|
# do the disconnect, but only if we are the last session to puppet
|
||||||
obj.sessid.remove(sessid)
|
obj.at_pre_unpuppet()
|
||||||
if not obj.sessid.count():
|
obj.sessid.remove(session.sessid)
|
||||||
del obj.player
|
if not obj.sessid.count():
|
||||||
obj.at_post_unpuppet(self, sessid=sessid)
|
del obj.player
|
||||||
|
obj.at_post_unpuppet(self, sessid=sessid)
|
||||||
|
# Just to be sure we're always clear.
|
||||||
session.puppet = None
|
session.puppet = None
|
||||||
session.puid = None
|
session.puid = None
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ are stored on the Portal side)
|
||||||
import time
|
import time
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
#from evennia.scripts.models import ScriptDB
|
|
||||||
from evennia.comms.models import ChannelDB
|
from evennia.comms.models import ChannelDB
|
||||||
from evennia.utils import logger
|
from evennia.utils import logger
|
||||||
from evennia.utils.inlinefunc import parse_inlinefunc
|
from evennia.utils.inlinefunc import parse_inlinefunc
|
||||||
|
|
|
||||||
|
|
@ -446,15 +446,29 @@ class ServerSessionHandler(SessionHandler):
|
||||||
session will receive the rest of the data,
|
session will receive the rest of the data,
|
||||||
regardless of MULTISESSION_MODE. This is an
|
regardless of MULTISESSION_MODE. This is an
|
||||||
internal variable that will not be passed on.
|
internal variable that will not be passed on.
|
||||||
|
This is ignored for MULTISESSION_MODE = 1,
|
||||||
|
since all messages are mirrored everywhere for
|
||||||
|
that.
|
||||||
|
_forced_nomulti (bool, optional): Like _nomulti,
|
||||||
|
but works even when MULTISESSION_MODE = 1.
|
||||||
|
Useful for connection handling messages.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
text = text and to_str(to_unicode(text), encoding=session.encoding)
|
text = text and to_str(to_unicode(text), encoding=session.encoding)
|
||||||
multi = not kwargs.pop("_nomulti", None)
|
multi = not kwargs.pop("_nomulti", None)
|
||||||
|
forced_nomulti = kwargs.pop("_forced_nomulti", None)
|
||||||
sessions = [session]
|
sessions = [session]
|
||||||
|
# Mode 1 mirrors to all.
|
||||||
if _MULTISESSION_MODE == 1:
|
if _MULTISESSION_MODE == 1:
|
||||||
if session.player:
|
multi = True
|
||||||
sessions = self.sessions_from_player(session.player)
|
# ...Unless we're absolutely sure.
|
||||||
elif multi:
|
if forced_nomulti:
|
||||||
|
multi = False
|
||||||
|
|
||||||
|
if multi:
|
||||||
|
if _MULTISESSION_MODE == 1:
|
||||||
|
if session.player:
|
||||||
|
sessions = self.sessions_from_player(session.player)
|
||||||
if _MULTISESSION_MODE == 2:
|
if _MULTISESSION_MODE == 2:
|
||||||
if session.player:
|
if session.player:
|
||||||
sessions = self.sessions_from_player(session.player)
|
sessions = self.sessions_from_player(session.player)
|
||||||
|
|
@ -467,8 +481,8 @@ class ServerSessionHandler(SessionHandler):
|
||||||
# send to all found sessions
|
# send to all found sessions
|
||||||
for session in sessions:
|
for session in sessions:
|
||||||
self.server.amp_protocol.call_remote_MsgServer2Portal(sessid=session.sessid,
|
self.server.amp_protocol.call_remote_MsgServer2Portal(sessid=session.sessid,
|
||||||
msg=text,
|
msg=text,
|
||||||
data=kwargs)
|
data=kwargs)
|
||||||
|
|
||||||
def data_in(self, sessid, text="", **kwargs):
|
def data_in(self, sessid, text="", **kwargs):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue