Added more session info to ooclook. Working on a bug that causes superuser to not be recognized now and then - this seems to be related to character.player returning None. This revision contains some printout debug messages since that bug is not yet fixed.
This commit is contained in:
parent
406800f254
commit
29e313492f
6 changed files with 53 additions and 27 deletions
|
|
@ -188,27 +188,34 @@ class Command(object):
|
||||||
"""
|
"""
|
||||||
return self.lockhandler.check(srcobj, access_type, default=default)
|
return self.lockhandler.check(srcobj, access_type, default=default)
|
||||||
|
|
||||||
def msg(self, msg="", data=None, from_obj=None, to_obj=None, all_sessions=False):
|
def msg(self, msg="", to_obj=None, from_obj=None, data=None, sessid=None, all_sessions=False):
|
||||||
"""
|
"""
|
||||||
This is a shortcut instad of calling msg() directly on an object - it will
|
This is a shortcut instad of calling msg() directly on an object - it will
|
||||||
determine
|
|
||||||
|
|
||||||
detect if caller is an Object or a Player and also appends self.sessid
|
detect if caller is an Object or a Player and also appends self.sessid
|
||||||
automatically.
|
automatically.
|
||||||
|
|
||||||
msg - text string of message to send
|
msg - text string of message to send
|
||||||
data - optional dictionary of data
|
|
||||||
from_obj - source of message. Defaults to self.caller.
|
|
||||||
to_obj - target object of message. Defaults to self.caller
|
to_obj - target object of message. Defaults to self.caller
|
||||||
|
from_obj - source of message. Defaults to to_obj
|
||||||
|
data - optional dictionary of data
|
||||||
|
sessid - supply data only to a unique sessid (normally not used - this is only potentially useful if
|
||||||
|
to_obj is a Player object different from self.caller or self.caller.player)
|
||||||
all_sessions (bool) - default is to send only to the session connected to
|
all_sessions (bool) - default is to send only to the session connected to
|
||||||
the target object
|
the target object
|
||||||
"""
|
"""
|
||||||
from_obj = from_obj or self.caller
|
from_obj = from_obj or self.caller
|
||||||
to_obj = to_obj or from_obj
|
to_obj = to_obj or from_obj
|
||||||
if hasattr(to_obj, "sessid"):
|
if not sessid:
|
||||||
sessid = all_sessions and None or to_obj.sessid
|
if hasattr(to_obj, "sessid"):
|
||||||
else:
|
# this is the case when to_obj is e.g. a Character
|
||||||
sessid = None
|
sessid = all_sessions and None or to_obj.sessid
|
||||||
|
elif to_obj == self.caller:
|
||||||
|
# this is the case if to_obj is the calling Player
|
||||||
|
sessid = all_sessions and None or self.sessid
|
||||||
|
else:
|
||||||
|
# if to_obj is a different Player, all their sessions
|
||||||
|
# will be notified unless sessid was given specifically
|
||||||
|
sessid = None
|
||||||
to_obj.msg(msg, from_obj=from_obj, data=data, sessid=sessid)
|
to_obj.msg(msg, from_obj=from_obj, data=data, sessid=sessid)
|
||||||
|
|
||||||
# Common Command hooks
|
# Common Command hooks
|
||||||
|
|
|
||||||
|
|
@ -769,6 +769,12 @@ class CmdColorTest(MuxCommand):
|
||||||
|
|
||||||
#------------------------------------------------------------
|
#------------------------------------------------------------
|
||||||
# OOC commands
|
# OOC commands
|
||||||
|
#
|
||||||
|
# Note that in commands inheriting from MuxCommandOOC,
|
||||||
|
# self.caller is always the Player object, not the Character.
|
||||||
|
# A property self.character can be used to access the
|
||||||
|
# connecter character (this can be None if no character is
|
||||||
|
# currently controlled by the Player).
|
||||||
#------------------------------------------------------------
|
#------------------------------------------------------------
|
||||||
|
|
||||||
class CmdOOCLook(MuxCommandOOC, CmdLook):
|
class CmdOOCLook(MuxCommandOOC, CmdLook):
|
||||||
|
|
@ -809,24 +815,33 @@ class CmdOOCLook(MuxCommandOOC, CmdLook):
|
||||||
# caller is always a player at this point.
|
# caller is always a player at this point.
|
||||||
player = self.caller
|
player = self.caller
|
||||||
sessid = self.sessid
|
sessid = self.sessid
|
||||||
# get all our characters
|
# get all our characters and sessions
|
||||||
characters = player.db._playable_characters
|
characters = player.db._playable_characters
|
||||||
string = "You are logged in as {g%s{n." % player.key
|
sessions = player.get_all_sessions()
|
||||||
string += "\nUse {w@ic <character>{n to enter the game, {w@occ{n to get back here."
|
|
||||||
|
sessidstr = sessid and "(session id %i)" % sessid or ""
|
||||||
|
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 characters:
|
if characters:
|
||||||
string += "\n\nAvailable character%s:" % (len(characters) > 1 and "s" or "")
|
string += "\n\nAvailable character%s:" % (len(characters) > 1 and "s" or "")
|
||||||
for char in characters:
|
for char in characters:
|
||||||
csessid = char.sessid
|
csessid = char.sessid
|
||||||
if csessid:
|
if csessid:
|
||||||
# character is already puppeted
|
# character is already puppeted
|
||||||
if player.get_session(csessid):
|
sess = player.get_session(csessid)
|
||||||
string += "\n - {G%s{n (played by you in another session)" % char.key
|
if sess:
|
||||||
|
string += "\n - {G%s{n (played by you from session with id %i)" % (char.key, sess.sessid)
|
||||||
else:
|
else:
|
||||||
string += "\n - {R%s{n (played by someone else)" % char.key
|
string += "\n - {R%s{n (played by someone else)" % char.key
|
||||||
else:
|
else:
|
||||||
# character is "free to puppet"
|
# character is "free to puppet"
|
||||||
string += "\n - %s" % char.key
|
string += "\n - %s" % char.key
|
||||||
player.msg(string)
|
self.msg(string)
|
||||||
|
|
||||||
def func(self):
|
def func(self):
|
||||||
"implement the ooc look command"
|
"implement the ooc look command"
|
||||||
|
|
@ -957,7 +972,7 @@ class CmdIC(MuxCommandOOC):
|
||||||
|
|
||||||
class CmdOOC(MuxCommandOOC):
|
class CmdOOC(MuxCommandOOC):
|
||||||
"""
|
"""
|
||||||
@ooc - go ooc
|
go ooc
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
@ooc
|
@ooc
|
||||||
|
|
@ -977,9 +992,6 @@ class CmdOOC(MuxCommandOOC):
|
||||||
|
|
||||||
caller = self.caller
|
caller = self.caller
|
||||||
|
|
||||||
if utils.inherits_from(caller, "src.objects.objects.Object"):
|
|
||||||
caller = self.caller.player
|
|
||||||
|
|
||||||
old_char = caller.get_character(sessid=self.sessid)
|
old_char = caller.get_character(sessid=self.sessid)
|
||||||
if not old_char:
|
if not old_char:
|
||||||
string = "You are already OOC."
|
string = "You are already OOC."
|
||||||
|
|
|
||||||
|
|
@ -175,7 +175,7 @@ class MuxCommandOOC(MuxCommand):
|
||||||
|
|
||||||
This class makes sure that caller is always a Player object, while
|
This class makes sure that caller is always a Player object, while
|
||||||
creating a new property "character" that is set only if a
|
creating a new property "character" that is set only if a
|
||||||
character is actually attached to the Player.
|
character is actually attached to this Player and Session.
|
||||||
"""
|
"""
|
||||||
def parse(self):
|
def parse(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -170,12 +170,21 @@ class LockHandler(object):
|
||||||
self.log_obj = None
|
self.log_obj = None
|
||||||
self.reset_flag = False
|
self.reset_flag = False
|
||||||
self._cache_locks(self.obj.lock_storage)
|
self._cache_locks(self.obj.lock_storage)
|
||||||
# we handle bypass checks already here for efficiency. We need to grant access to superusers and
|
# we handle bypass checks already here for efficiency. We need to grant access to superusers.
|
||||||
# to protocol instances where the superuser status cannot be determined (can happen at
|
# We need to check both directly on the object (players), through obj.player and using the
|
||||||
# some rare cases during login).
|
# get_player method (this sits on serversessions, in some rare cases where a check is done
|
||||||
|
# before the login process has yet been fully finalized)
|
||||||
self.lock_bypass = ((hasattr(obj, "is_superuser") and obj.is_superuser)
|
self.lock_bypass = ((hasattr(obj, "is_superuser") and obj.is_superuser)
|
||||||
or (hasattr(obj, "player") and hasattr(obj.player, "is_superuser") and obj.player.is_superuser)
|
or (hasattr(obj, "player") and hasattr(obj.player, "is_superuser") and obj.player.is_superuser)
|
||||||
or (hasattr(obj, "get_player") and (not obj.get_player() or obj.get_player().is_superuser)))
|
or (hasattr(obj, "get_player") and (not obj.get_player() or obj.get_player().is_superuser)))
|
||||||
|
if obj.key == "Griatch":
|
||||||
|
print "SETTING lock_bypass:", obj, self.lock_bypass, "<-",
|
||||||
|
print (hasattr(obj, "is_superuser") and obj.is_superuser),
|
||||||
|
print (hasattr(obj, "player") and hasattr(obj.player, "is_superuser") and obj.player.is_superuser),
|
||||||
|
print (hasattr(obj, "get_player") and (not obj.get_player() or obj.get_player().is_superuser)),
|
||||||
|
if hasattr(obj, "player"):
|
||||||
|
print obj.player and obj.player.is_superuser
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return ";".join(self.locks[key][2] for key in sorted(self.locks))
|
return ";".join(self.locks[key][2] for key in sorted(self.locks))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -390,9 +390,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 = None
|
session = sessid and _GA(self, "get_session")(sessid) or None
|
||||||
if sessid:
|
|
||||||
session = _GA(self, "get_session")(sessid)
|
|
||||||
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):
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ SSL_PORTS = [4001]
|
||||||
# Interface addresses to listen to. If 0.0.0.0, listen to all.
|
# Interface addresses to listen to. If 0.0.0.0, listen to all.
|
||||||
SSL_INTERFACES = ['0.0.0.0']
|
SSL_INTERFACES = ['0.0.0.0']
|
||||||
# Multisession modes allow a player (=account) to connect to the game simultaneously
|
# Multisession modes allow a player (=account) to connect to the game simultaneously
|
||||||
# with multiple clients 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 - no multisession - 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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue