mirror of
https://github.com/evennia/evennia.git
synced 2026-03-23 08:16:30 +01:00
Various speed optimizations in various places, following further profiling.
This commit is contained in:
parent
83fa9397d5
commit
4c83d3e7a1
7 changed files with 75 additions and 59 deletions
|
|
@ -44,7 +44,6 @@ _ME = _("me")
|
|||
_SELF = _("self")
|
||||
_HERE = _("here")
|
||||
|
||||
|
||||
def clean_content_cache(obj):
|
||||
"Clean obj's content cache"
|
||||
_SA(obj, "_contents_cache", None)
|
||||
|
|
@ -428,8 +427,8 @@ class ObjectDB(TypedObject):
|
|||
Retrieve sessions connected to this object.
|
||||
"""
|
||||
# if the player is not connected, this will simply be an empty list.
|
||||
if self.player:
|
||||
return self.player.sessions
|
||||
if _GA(self, "player"):
|
||||
return _GA(_GA(self, "player"), "sessions")
|
||||
return []
|
||||
sessions = property(__sessions_get)
|
||||
|
||||
|
|
@ -439,14 +438,15 @@ class ObjectDB(TypedObject):
|
|||
Convenience function for checking if an active player is
|
||||
currently connected to this object
|
||||
"""
|
||||
return any(self.sessions)
|
||||
return any(_GA(self, "sessions"))
|
||||
has_player = property(__has_player_get)
|
||||
is_player = property(__has_player_get)
|
||||
|
||||
#@property
|
||||
def __is_superuser_get(self):
|
||||
"Check if user has a player, and if so, if it is a superuser."
|
||||
return any(self.sessions) and self.player.is_superuser
|
||||
#return any(self.sessions) and self.player.is_superuser
|
||||
return any(_GA(self, "sessions")) and _GA(_GA(self, "player"), "is_superuser")
|
||||
is_superuser = property(__is_superuser_get)
|
||||
|
||||
# contents
|
||||
|
|
|
|||
|
|
@ -637,31 +637,26 @@ class Object(TypeClass):
|
|||
"""
|
||||
if not pobject:
|
||||
return
|
||||
string = "{c%s{n" % self.name
|
||||
desc = self.attr("desc")
|
||||
# get and identify all objects
|
||||
visible = (con for con in self.contents if con != pobject and con.access(pobject, "view"))
|
||||
exits, users, things = [], [], []
|
||||
for con in visible:
|
||||
key = con.key
|
||||
if con.destination:
|
||||
exits.append(key)
|
||||
elif con.has_player:
|
||||
users.append("{c%s{n" % key)
|
||||
else:
|
||||
things.append(key)
|
||||
# get description, build string
|
||||
string = "{c%s{n" % self.key
|
||||
desc = self.db.desc
|
||||
if desc:
|
||||
string += "\n %s" % desc
|
||||
exits = []
|
||||
users = []
|
||||
things = []
|
||||
for content in [con for con in self.contents if con.access(pobject, 'view')]:
|
||||
if content == pobject:
|
||||
continue
|
||||
name = content.name
|
||||
if content.destination:
|
||||
exits.append(name)
|
||||
elif content.has_player:
|
||||
users.append(name)
|
||||
else:
|
||||
things.append(name)
|
||||
if exits:
|
||||
string += "\n{wExits:{n " + ", ".join(exits)
|
||||
if users or things:
|
||||
string += "\n{wYou see: {n"
|
||||
if users:
|
||||
string += "{c" + ", ".join(users) + "{n "
|
||||
if things:
|
||||
string += ", ".join(things)
|
||||
string += "\n{wYou see:{n " + ", ".join(users + things)
|
||||
return string
|
||||
|
||||
def at_desc(self, looker=None):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue