From a84b4f24fccac04376841e74b748c9cf08dec123 Mon Sep 17 00:00:00 2001 From: Griatch Date: Mon, 4 Feb 2013 22:02:04 +0100 Subject: [PATCH] Fixed bugs that now allows multiple sessions to connect through the same player to different characters. Still lots of bugs and inconsistencies, the permissions of superusers don't quite transfer sometimes, for example. --- src/commands/default/building.py | 25 +++++++++++++++++-------- src/commands/default/cmdset_ooc.py | 4 ++++ src/commands/default/general.py | 3 +-- src/players/models.py | 6 +----- 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/commands/default/building.py b/src/commands/default/building.py index 47ef5bf3a..0e6ad4c69 100644 --- a/src/commands/default/building.py +++ b/src/commands/default/building.py @@ -1555,7 +1555,7 @@ class CmdExamine(ObjManipCommand): """ key = "@examine" aliases = ["@ex","ex", "exam", "examine"] - locks = "cmd:perm(examine) or perm(Builders)" + locks = "cmd:perm(examine) or perm(Players)"#Builders)" help_category = "Building" arg_regex = r"(/\w+?(\s|$))|\s|$" @@ -1615,6 +1615,7 @@ class CmdExamine(ObjManipCommand): headers = {"name":"\n{wName/key{n: {c%s{n (%s)", "aliases":"\n{wAliases{n: %s", "player":"\n{wPlayer{n: {c%s{n", + "sessid":" {wsessid{n: {c%s{n", "playerperms":"\n{wPlayer Perms{n: %s", "typeclass":"\n{wTypeclass{n: %s (%s)", "location":"\n{wLocation{n: %s (#%s)", @@ -1630,6 +1631,7 @@ class CmdExamine(ObjManipCommand): headers_noansi = {"name":"\nName/key: %s (%s)", "aliases":"\nAliases: %s", "player":"\nPlayer: %s", + "sessid":" sessid: %s)", "playerperms":"\nPlayer Perms: %s", "typeclass":"\nTypeclass: %s%s", "location":"\nLocation: %s (#%s)", @@ -1659,6 +1661,10 @@ class CmdExamine(ObjManipCommand): elif not perms: perms = [""] string += headers["playerperms"] % (", ".join(perms)) + if hasattr(obj, "sessid"): + string += headers["sessid"] % obj.sessid + elif hasattr(obj, "sessions"): + string += headers["sessid"] % (",".join(sess.sessid for sess in obj.sessions)) string += headers["typeclass"] % (obj.typeclass.typename, obj.typeclass_path) if hasattr(obj, "location") and obj.location: @@ -1733,13 +1739,16 @@ class CmdExamine(ObjManipCommand): if not self.args: # If no arguments are provided, examine the invoker's location. - obj = caller.location - if not obj.access(caller, 'examine'): - #If we don't have special info access, just look at the object instead. - caller.execute_cmd('look %s' % obj.name) - return - # using callback for printing result whenever function returns. - get_and_merge_cmdsets(obj).addCallback(get_cmdset_callback) + if hasattr(caller, "location"): + obj = caller.location + if not obj.access(caller, 'examine'): + #If we don't have special info access, just look at the object instead. + caller.execute_cmd('look %s' % obj.name) + return + # using callback for printing result whenever function returns. + get_and_merge_cmdsets(obj).addCallback(get_cmdset_callback) + else: + caller.msg("You need to supply a target to examine.") return # we have given a specific target object diff --git a/src/commands/default/cmdset_ooc.py b/src/commands/default/cmdset_ooc.py index 63e9cfcd5..649bd5c4b 100644 --- a/src/commands/default/cmdset_ooc.py +++ b/src/commands/default/cmdset_ooc.py @@ -8,6 +8,7 @@ a Player object as caller rather than a Character. from src.commands.cmdset import CmdSet from src.commands.default import help, comms, general, admin, system +from src.commands.default import building class OOCCmdSet(CmdSet): """ Implements the player command set. @@ -28,6 +29,9 @@ class OOCCmdSet(CmdSet): self.add(general.CmdQuit()) self.add(general.CmdPassword()) + # test + self.add(building.CmdExamine()) + # Help command self.add(help.CmdHelp()) diff --git a/src/commands/default/general.py b/src/commands/default/general.py index 184ccf2d4..8282125f7 100644 --- a/src/commands/default/general.py +++ b/src/commands/default/general.py @@ -934,8 +934,7 @@ class CmdOOC(MuxCommandOOC): old_char.location = None # disconnect - err = caller.disconnect_character(caller) - print "err:", err + err = caller.disconnect_character(self.character) caller.msg("\n{GYou go OOC.{n\n") caller.execute_cmd("look") diff --git a/src/players/models.py b/src/players/models.py index 40feea2d7..775565625 100644 --- a/src/players/models.py +++ b/src/players/models.py @@ -465,7 +465,6 @@ class PlayerDB(TypedObject): if not sessid: return char = _GA(self, "get_character")(sessid=sessid, return_dbobj=True) - print "disonnect session:", char if char: # call hook before disconnecting _GA(char.typeclass, "at_disconnect")() @@ -512,9 +511,7 @@ class PlayerDB(TypedObject): return char and (char == character.dbobj and (return_dbobj and char or char.typeclass)) or None return char and (return_dbobj and char or char.typeclass) or None elif character: - print character, character.dbobj, _GA(self,"db_objs").all() char = _GA(self, "db_objs").filter(id=_GA(character.dbobj, "id")) - print "character:", character, char return char and (return_dbobj and char[0] or char[0].typeclass) or None else: # no sessid given - return all available characters @@ -555,9 +552,8 @@ class PlayerDB(TypedObject): if not character: return char = _GA(self, "get_character")(character=character, return_dbobj=True) - print "disconnect_char:", char if char: - print _GA(self, "disconnect_session_from_character")(char.sessid) + err = _GA(self, "disconnect_session_from_character")(char.sessid) _GA(self, "db_objs").remove(char) del char.player self.save()