I'm pretty much ditching all of the caching I was doing for the sake of simplicity and probably not being necessary. I've attempted to commit something that is more or less identical to the previous revision in functionality, but completely different under the hood. Going to need a lot of testing to verify everything is working.

This commit is contained in:
Greg Taylor 2006-12-21 09:12:38 +00:00
parent 1b03c8cf31
commit 81d9eb313a
8 changed files with 285 additions and 158 deletions

1
evennia/trunk/TODO Normal file
View file

@ -0,0 +1 @@
* Since we now have support for GARBAGE, we need to handle creating over a garbage object gracefully.

View file

@ -40,26 +40,8 @@ class Object(models.Model):
description = models.TextField(blank=True)
location = models.ForeignKey('self', related_name="obj_location", blank=True, null=True)
flags = models.TextField(blank=True)
nosave_flags = models.TextField(blank=True)
date_created = models.DateField(editable=False, auto_now_add=True)
# Rather than keeping another relation for this, we're just going to use
# foreign keys and populate each object's contents and attribute lists at
# server startup. It'll keep some of the tables more simple, but at the
# cost of a little bit more memory usage. There may be a better way to do
# this, I'm all ears.
# A list of objects located inside the object.
# TODO: Re-activate this once we get the contents loader working.
# contents_list = []
# A dictionary of attributes assocated with the object. The keys are the
# attribute's names. This lets us look up and manipulate attributes really
# easily.
attrib_list = {}
# We keep a separate list of active flags in memory so we can store some of
# the non-saved flags such as CONNECTED.
flags_active = []
def __cmp__(self, other):
"""
@ -78,12 +60,18 @@ class Object(models.Model):
"""
BEGIN COMMON METHODS
"""
def load_flags(self):
def set_name(self, new_name):
"""
Toss the flags from self.flags into our flags_active list, where we
pull from.
Rename an object.
"""
self.flags_active = self.flags.split()
self.name = new_name
self.save()
# If it's a player, we need to update their user object as well.
if self.is_player():
pobject = User.objects.get(id=self.id)
pobject.name = new_name
pobject.save()
def get_name(self):
"""
@ -95,7 +83,7 @@ class Object(models.Model):
"""
Returns an object's flag list.
"""
return ' '.join(self.flags_active)
return '%s %s' % (self.flags, self.nosave_flags)
def clear_attribute(self, attribute):
"""
@ -106,10 +94,35 @@ class Object(models.Model):
if self.has_attribute(attribute):
attrib_obj = self.get_attribute_obj(attribute)
attrib_obj.delete()
del self.attrib_list[attribute]
return True
else:
return False
def clear_all_attributes(self):
"""
Clears all of an object's attributes.
"""
attribs = Attribute.objects.filter(object=self)
for attrib in attribs:
self.delete()
def get_all_attributes(self):
"""
Returns a QuerySet of an object's attributes.
"""
attribs = Attribute.objects.filter(object=self)
return attribs
def delete(self, server):
"""
Deletes an object.
server: (Server) Reference to the server object.
"""
# Set the object to type GARBAGE.
self.type = 6
self.save()
self.clear_all_attributes()
def set_attribute(self, attribute, new_value):
"""
@ -121,7 +134,7 @@ class Object(models.Model):
"""
if self.has_attribute(attribute):
# Attribute already exists, update it.
attrib_obj = self.attrib_list[attribute]
attrib_obj = Attribute.objects.filter(object=self).filter(name=attribute)
attrib_obj.value = new_value
attrib_obj.save()
else:
@ -131,7 +144,6 @@ class Object(models.Model):
new_attrib.value = new_value
new_attrib.object = self
new_attrib.save()
self.attrib_list[attribute] = new_attrib
def has_attribute(self, attribute):
"""
@ -139,7 +151,11 @@ class Object(models.Model):
attribute: (str) The attribute's name.
"""
return self.attrib_list.has_key(attribute)
attr = Attribute.objects.filter(object=self).filter(name=attribute)
if attr.count() == 0:
return False
else:
return True
def has_flag(self, flag):
"""
@ -147,7 +163,7 @@ class Object(models.Model):
flag: (str) Flag name
"""
return flag in self.flags_active
return flag in self.flags or flag in self.nosave_flags
def set_flag(self, flag, value):
"""
@ -160,17 +176,19 @@ class Object(models.Model):
has_flag = self.has_flag(flag)
if value == False and has_flag:
# The flag is there and we want to un-set it.
self.flags_active.remove(flag)
# Clear the flag.
if functions_db.not_saved_flag(flag):
# Not a savable flag.
flags = self.nosave_flags.split()
flags.remove(flag)
self.nosave_flags = ' '.join(flags)
else:
# Is a savable flag.
flags = self.flags.split()
flags.remove(flag)
self.flags = ' '.join(flags)
self.save()
# Not all flags are saved, such as CONNECTED.
# Don't waste queries on these things.
if flag not in global_defines.NOSAVE_FLAGS:
flag_templist = self.flags.split()
flag_templist.remove(flag)
self.flags = ' '.join(flag_templist)
self.save()
elif value == False and not has_flag:
# Object doesn't have the flag to begin with.
pass
@ -178,14 +196,18 @@ class Object(models.Model):
# We've already go it.
pass
else:
# Add the flag to our active, memory-resident list no matter what.
self.flags_active.append(flag)
if flag not in global_defines.NOSAVE_FLAGS:
flag_templist = self.flags.split()
flag_templist.append(flag)
self.flags = ' '.join(flag_templist)
self.save()
# Setting a flag.
if functions_db.not_saved_flag(flag):
# Not a savable flag.
flags = self.nosave_flags.split()
flags.append(flag)
self.nosave_flags = ' '.join(flags)
else:
# Is a savable flag.
flags = self.flags.split()
flags.append(flag)
self.flags = ' '.join(flags)
self.save()
def get_owner(self):
"""
@ -216,7 +238,8 @@ class Object(models.Model):
attrib: (str) The attribute's name.
"""
if self.has_attribute(attrib):
attrib_value = self.attrib_list[attrib]
attrib = Attribute.objects.filter(object=self).filter(name=attrib)
attrib_value = attrib[0].value
return attrib_value.value
else:
return False
@ -228,26 +251,16 @@ class Object(models.Model):
attrib: (str) The attribute's name.
"""
if self.has_attribute(attrib):
attrib_obj = self.attrib_list[attrib]
attrib_obj = Attribute.objects.filter(object=self).filter(name=attrib)
return attrib_obj
else:
return False
def load_to_location(self):
"""
Adds an object to its location.
"""
print 'Adding %s to %s.' % (self.id, self.location.id,)
self.location.contents_list.append(self)
def get_contents(self):
"""
Returns the contents of an object.
TODO: Make this use the object's contents_list field. There's
something horribly long with the load routine right now.
"""
return list(Object.objects.filter(location__id=self.id))
return list(Object.objects.filter(location__id=self.id).exclude(type__gt=4))
def get_zone(self):
"""
@ -255,23 +268,14 @@ class Object(models.Model):
"""
return self.zone
def move_to(self, server, target):
def move_to(self, target):
"""
Moves the object to a new location. We're going to modify the server's
cached version of the object rather than the one we're given due
to the way references are passed. We can firm this up by other means
but this is more or less fool-proof for now.
Moves the object to a new location.
server: (Server) Reference to the main game server.
target: (Object) Reference to the object to move to.
"""
#if self in self.location.contents_list:
# self.location.contents_list.remove(self)
#target.contents_list.append(self)
cached_object = functions_db.get_object_from_dbref(server, self.id)
cached_object.location = target
cached_object.save()
self.location = target
self.save()
def dbref_match(self, oname):
"""
@ -311,7 +315,8 @@ class Object(models.Model):
oname: (str) The string to filter from.
"""
return [prospect for prospect in self.contents_list if prospect.name_match(oname)]
contents = self.get_contents()
return [prospect for prospect in contents if prospect.name_match(oname)]
# Type comparison methods.
def is_player(self):
@ -322,8 +327,10 @@ class Object(models.Model):
return self.type == 3
def is_exit(self):
return self.type == 4
def is_garbage(self):
def is_going(self):
return self.type == 5
def is_garbage(self):
return self.type == 6
def get_type(self, return_number=False):
"""

View file

@ -14,11 +14,11 @@ def cmd_look(cdat):
Handle looking at objects.
"""
session = cdat['session']
pobject = session.pobject
pobject = session.get_pobject()
args = cdat['uinput']['splitted'][1:]
if len(args) == 0:
target_obj = session.pobject.location
target_obj = pobject.get_location()
else:
results = functions_db.local_and_global_search(pobject, ' '.join(args), searcher=pobject)
@ -50,7 +50,7 @@ def cmd_look(cdat):
for obj in target_obj.get_contents():
if obj.is_player:
if obj != session.pobject:
if obj != pobject:
con_players.append(obj)
elif obj.is_exit:
con_exits.append(obj)
@ -75,11 +75,11 @@ def cmd_examine(cdat):
Detailed object examine command
"""
session = cdat['session']
pobject = session.pobject
pobject = session.get_pobject()
args = cdat['uinput']['splitted'][1:]
if len(args) == 0:
target_obj = session.pobject.location
target_obj = pobject.get_location()
else:
results = functions_db.local_and_global_search(pobject, ' '.join(args), searcher=pobject)
@ -106,8 +106,8 @@ def cmd_examine(cdat):
session.msg("Owner: %s " % (target_obj.get_owner(),))
session.msg("Zone: %s" % (target_obj.get_zone(),))
for attribute in target_obj.attrib_list:
session.msg("%s%s%s: %s" % (ansi["hilite"], attribute, ansi["normal"], target_obj.get_attribute_value(attribute)))
for attribute in target_obj.get_all_attributes():
session.msg("%s%s%s: %s" % (ansi["hilite"], attribute.name, ansi["normal"], attribute.value))
con_players = []
con_things = []
@ -151,14 +151,16 @@ def cmd_who(cdat):
"""
session_list = cdat['server'].get_session_list()
session = cdat['session']
pobject = session.get_pobject()
retval = "Player Name On For Idle Room Cmds Host\n\r"
for player in session_list:
delta_cmd = time.time() - player.cmd_last
delta_conn = time.time() - player.conn_time
plr_pobject = player.get_pobject()
retval += '%-16s%9s %4s%-3s#%-6d%5d%3s%-25s\r\n' % \
(player.name, \
(plr_pobject.get_name(), \
# On-time
functions_general.time_format(delta_conn,0), \
# Idle time
@ -166,7 +168,7 @@ def cmd_who(cdat):
# Flags
'', \
# Location
player.pobject.location.id, \
plr_pobject.get_location().id, \
player.cmd_total, \
# More flags?
'', \
@ -181,12 +183,14 @@ def cmd_say(cdat):
"""
session_list = cdat['server'].get_session_list()
session = cdat['session']
pobject = session.get_pobject()
speech = ' '.join(cdat['uinput']['splitted'][1:])
players_present = [player for player in session_list if player.pobject.location == session.pobject.location and player != session]
players_present = [player for player in session_list if player.get_pobject().get_location() == session.get_pobject().get_location() and player != session]
retval = "You say, '%s'" % (speech,)
for player in players_present:
player.msg("%s says, '%s'" % (session.name, speech,))
player.msg("%s says, '%s'" % (pobject.get_name(), speech,))
session.msg(retval)

View file

@ -11,11 +11,76 @@ or otherwise manipulative command that doesn't fall within the scope of
normal gameplay.
"""
def cmd_destroy(cdat):
"""
Destroy an object.
"""
session = cdat['session']
pobject = session.get_pobject()
args = cdat['uinput']['splitted'][1:]
if len(args) == 0:
session.msg("Destroy what?")
return
else:
results = functions_db.local_and_global_search(pobject, ' '.join(args), searcher=pobject)
if len(results) > 1:
session.msg("More than one match found (please narrow target):")
for result in results:
session.msg(" %s" % (result,))
return
elif len(results) == 0:
session.msg("I don't see that here.")
return
elif results[0].is_player():
session.msg("You must @nuke players, not @destroy them.")
return
else:
target_obj = results[0]
session.msg("You destroy %s." % (target_obj,))
target_obj.delete(session.server)
def cmd_name(cdat):
"""
Handle naming an object.
"""
session = cdat['session']
pobject = session.get_pobject()
args = cdat['uinput']['splitted'][1:]
eq_args = ' '.join(args).split('=')
searchstring = ''.join(eq_args[0])
if len(args) == 0:
session.msg("What do you want to name?")
elif len(eq_args) < 2:
session.msg("What would you like to name that object?")
else:
results = functions_db.local_and_global_search(pobject, searchstring, searcher=pobject)
if len(results) > 1:
session.msg("More than one match found (please narrow target):")
for result in results:
session.msg(" %s" % (result,))
return
elif len(results) == 0:
session.msg("I don't see that here.")
return
elif len(eq_args[1]) == 0:
session.msg("What would you like to name that object?")
else:
newname = '='.join(eq_args[1:])
target_obj = results[0]
session.msg("You have renamed %s to %s." % (target_obj,newname))
target_obj.set_name(newname)
def cmd_dig(cdat):
"""
Creates a new object of type 'ROOM'.
"""
session = cdat['session']
pobject = session.get_pobject()
server = session.server
uinput= cdat['uinput']['splitted']
roomname = ' '.join(uinput[1:])
@ -24,7 +89,7 @@ def cmd_dig(cdat):
session.msg("You must supply a name!")
else:
# Create and set the object up.
odat = {"name": roomname, "type": 2, "location": None, "owner": session.pobject}
odat = {"name": roomname, "type": 2, "location": None, "owner": pobject}
new_object = functions_db.create_object(server, odat)
session.msg("You create a new room: %s" % (new_object,))
@ -35,6 +100,7 @@ def cmd_create(cdat):
"""
session = cdat['session']
server = session.server
pobject = session.get_pobject()
uinput= cdat['uinput']['splitted']
thingname = ' '.join(uinput[1:])
@ -42,7 +108,7 @@ def cmd_create(cdat):
session.msg("You must supply a name!")
else:
# Create and set the object up.
odat = {"name": thingname, "type": 3, "location": session.pobject, "owner": session.pobject}
odat = {"name": thingname, "type": 3, "location": pobject, "owner": pobject}
new_object = functions_db.create_object(server, odat)
session.msg("You create a new thing: %s" % (new_object,))
@ -59,12 +125,65 @@ def cmd_nextfree(cdat):
session.msg(retval)
def cmd_open(cdat):
"""
Handle the opening of exits.
Forms:
@open <Name>
@open <Name>=<Dbref>
@open <Name>=<Dbref>,<Name>
"""
session = cdat['session']
pobject = session.get_pobject()
server = cdat['server']
args = cdat['uinput']['splitted'][1:]
if len(args) == 0:
session.msg("Open an exit to where?")
return
eq_args = args[0].split('=')
exit_name = eq_args[0]
if len(exit_name) == 0:
session.msg("You must supply an exit name.")
return
# If we have more than one entry in our '=' delimited argument list,
# then we're doing a @open <Name>=<Dbref>[,<Name>]. If not, we're doing
# an un-linked exit, @open <Name>.
if len(eq_args) > 1:
# Opening an exit to another location via @open <Name>=<Dbref>[,<Name>].
destination = functions_db.local_and_global_search(pobject, eq_args[1], searcher=pobject)
if len(destination) == 0:
session.msg("I can't find the location to link to.")
return
elif len(destination) > 1:
session.msg("Multiple results returned for exit destination!")
else:
if destination.is_exit():
session.msg("You can't open an exit to an exit!")
return
session.msg("You open the exit.")
#victim[0].move_to(server, destination[0])
# Create the object and stuff.
else:
# Create an un-linked exit.
odat = {"name": thingname, "type": 3, "location": pobject, "owner": pobject}
new_object = functions_db.create_object(server, odat)
session.msg("You create a new thing: %s" % (new_object,))
def cmd_teleport(cdat):
"""
Teleports an object somewhere.
"""
session = cdat['session']
pobject = session.pobject
pobject = session.get_pobject()
server = cdat['server']
args = cdat['uinput']['splitted'][1:]
@ -99,7 +218,7 @@ def cmd_teleport(cdat):
session.msg("You can't teleport an object inside of itself!")
return
session.msg("Teleported.")
victim[0].move_to(server, destination[0])
victim[0].move_to(destination[0])
# This is somewhat kludgy right now, we'll have to find a better way
# to do it sometime else. If we can find a session in the server's
@ -128,7 +247,7 @@ def cmd_teleport(cdat):
session.msg("You can't teleport inside yourself!")
return
session.msg("Teleported.")
pobject.move_to(server, results[0])
pobject.move_to(results[0])
commands_general.cmd_look(cdat)
def cmd_set(cdat):
@ -136,7 +255,7 @@ def cmd_set(cdat):
Sets flags or attributes on objects.
"""
session = cdat['session']
pobject = session.pobject
pobject = session.get_pobject()
server = cdat['server']
args = cdat['uinput']['splitted'][1:]
@ -241,7 +360,7 @@ def cmd_wall(cdat):
session.msg("Announce what?")
return
message = "%s shouts \"%s\"" % (session.pobject.name, wallstring)
message = "%s shouts \"%s\"" % (session.get_pobject().get_name(), wallstring)
functions_general.announce_all(server, message)
def cmd_shutdown(cdat):
@ -252,5 +371,5 @@ def cmd_shutdown(cdat):
server = cdat['server']
session.msg('Shutting down...')
print 'Server shutdown by %s(#%d)' % (session.name, session.pobject.id,)
print 'Server shutdown by %s(#%d)' % (session.get_pobject().get_name(), session.get_pobject().id,)
server.shutdown()

View file

@ -1,8 +1,15 @@
import sets
from django.db import connection
from django.contrib.auth.models import User
from apps.objects.models import Object
import global_defines
def not_saved_flag(flagname):
"""
Returns TRUE if the flag is not a savable flag.
"""
return flagname in global_defines.NOSAVE_FLAGS
def modifiable_flag(flagname):
"""
Check to see if a particular flag is modifiable.
@ -25,9 +32,9 @@ def get_nextfree_dbnum():
"""
Figure out what our next free database reference number is.
"""
# First we'll see if there's an object of type 5 (GARBAGE) that we
# First we'll see if there's an object of type 6 (GARBAGE) that we
# can recycle.
nextfree = Object.objects.filter(type__exact=5)
nextfree = Object.objects.filter(type__exact=6)
if nextfree:
# We've got at least one garbage object to recycle.
#return nextfree.id
@ -56,7 +63,7 @@ def local_and_global_search(object, ostring, local_only=False, searcher=None):
if is_dbref(ostring) and not local_only:
search_num = search_query[1:]
dbref_match = list(Object.objects.filter(id=search_num))
dbref_match = list(Object.objects.filter(id=search_num).exclude(type=6))
if len(dbref_match) > 0:
return dbref_match
@ -90,7 +97,7 @@ def session_from_object(session_list, targobject):
"""
Return the session object given a object (if there is one open).
"""
results = [prospect for prospect in session_list if prospect.pobject == targobject]
results = [prospect for prospect in session_list if prospect.get_pobject() == targobject]
if results:
return results[0]
else:
@ -101,17 +108,17 @@ def session_from_dbref(session_list, dbstring):
Return the session object given a dbref (if there is one open).
"""
if is_dbref(dbstring):
results = [prospect for prospect in session_list if prospect.pobject.dbref_match(dbstring)]
results = [prospect for prospect in session_list if prospect.get_pobject().dbref_match(dbstring)]
if results:
return results[0]
else:
return False
def get_object_from_dbref(server, dbref):
def get_object_from_dbref(dbref):
"""
Returns an object when given a dbref.
"""
return server.object_list.get(dbref, False)
return Object.objects.get(id=dbref)
def create_object(server, odat):
"""
@ -149,8 +156,7 @@ def create_object(server, odat):
new_object.save()
# Add the object to our server's dictionary of objects.
server.add_object_to_cache(new_object)
new_object.move_to(server, odat['location'])
new_object.move_to(odat['location'])
return new_object
@ -161,7 +167,7 @@ def create_user(cdat, uname, email, password):
session = cdat['session']
server = cdat['server']
start_room = int(server.get_configvalue('player_dbnum_start'))
start_room_obj = get_object_from_dbref(server, start_room)
start_room_obj = get_object_from_dbref(start_room)
# The user's entry in the User table must match up to an object
# on the object table. The id's are the same, we need to figure out
@ -170,14 +176,22 @@ def create_user(cdat, uname, email, password):
uid = get_nextfree_dbnum()
user = User.objects.create_user(uname, email, password)
# It stinks to have to do this but it's the only trivial way now.
user.id = uid
user.save
user.save()
# We can't use the user model to change the id because of the way keys
# are handled, so we actually need to fall back to raw SQL. Boo hiss.
cursor = connection.cursor()
cursor.execute("UPDATE auth_user SET id=%d WHERE id=%d" % (uid, user.id))
# Grab the user object again since we've changed it and the old reference
# is no longer valid.
user = User.objects.get(id=uid)
# Create a player object of the same ID in the Objects table.
odat = {"id": uid, "name": uname, "type": 1, "location": start_room_obj, "owner": None}
user_object = functions_db.create_object(server, odat)
user_object = create_object(server, odat)
# Activate the player's session and set them loose.
session.login(user)
print 'Registration: %s' % (session,)
session.push("Welcome to %s, %s.\n\r" % (server.get_configvalue('site_name'), session.name,))
session.push("Welcome to %s, %s.\n\r" % (server.get_configvalue('site_name'), session.get_pobject().get_name(),))

View file

@ -5,7 +5,8 @@ OBJECT_TYPES = (
(2, 'ROOM'),
(3, 'THING'),
(4, 'EXIT'),
(5, 'GARBAGE'),
(5, 'GOING'),
(6, 'GARBAGE'),
)
# This is a list of flags that the server actually uses. Anything not in this

View file

@ -3,9 +3,10 @@ from asynchat import async_chat
import socket, asyncore, time, sys
from sessions import PlayerSession
from django.db import models
from django.db import connection
from django.contrib.auth.models import User
from apps.config.models import ConfigValue, CommandAlias
from apps.objects.models import Object, Attribute
from django.contrib.auth.models import User
from scheduler import Scheduler
import functions_db
import functions_general
@ -21,12 +22,13 @@ class Server(dispatcher):
self.configvalue = {}
self.game_running = True
# Wipe our temporary flags on all of the objects.
cursor = connection.cursor()
cursor.execute("UPDATE objects_object SET nosave_flags=''")
print '-'*50
# Load stuff up into memory for easy/quick access.
self.load_configvalues()
self.load_objects()
self.load_objects_contents()
self.load_attributes()
self.load_cmd_aliases()
# Start accepting connections.
@ -54,44 +56,6 @@ class Server(dispatcher):
print ' Configuration Loaded.'
def load_objects(self):
"""
Load all of our objects into memory.
"""
object_list = Object.objects.all()
for object in object_list:
object.load_flags()
dbnum = object.id
self.object_list[dbnum] = object
print ' Objects Loaded: %d' % (len(self.object_list),)
def load_objects_contents(self):
"""
Populate the 'contents_list' list for each object.
TODO: This thing is just completely shot. No idea what's going on but
it's bad mojo.
"""
"""
object_list = Object.objects.all()
for object in object_list:
if object.location and not object.is_room():
object.load_to_location()
#print 'Adding %s to %s' % (object.id, object.location.id,)
for object in object_list:
print 'OBJ: %s CON: %s' % (object.id, object.location,)
print ' * Object Inventories Populated'
"""
def load_attributes(self):
"""
Load all of our attributes into memory.
"""
attribute_list = Attribute.objects.all()
for attrib in attribute_list:
attrib.object.attrib_list[attrib.name] = attrib
print ' Attributes Loaded: %d' % (len(attribute_list),)
def load_cmd_aliases(self):
"""
Load up our command aliases.
@ -120,6 +84,15 @@ class Server(dispatcher):
Adds an object to the cached object list.
"""
self.object_list[object.id] = object
def remove_object_from_cache(self, object):
"""
Removes an object from the cache.
"""
if self.object_list.has_key(object.id):
del self.object_list[object.id]
else:
print 'ERROR: Trying to remove non-cached object: %s' % (object,)
def get_configvalue(self, configname):
"""

View file

@ -19,9 +19,9 @@ class PlayerSession(async_chat):
self.set_terminator("\n")
self.name = None
self.data = []
self.uid = None
self.sock = sock
self.logged_in = False
self.pobject = None
# The time the user last issued a command.
self.cmd_last = time.time()
# Total number of commands issued.
@ -57,12 +57,20 @@ class PlayerSession(async_chat):
"""
Break the connection and do some accounting.
"""
self.pobject.set_flag("CONNECTED", False)
self.get_pobject().set_flag("CONNECTED", False)
async_chat.handle_close(self)
self.logged_in = False
self.server.remove_session(self)
print 'Sessions active:', len(self.server.session_list)
def get_pobject(self):
"""
Returns the object associated with a session.
"""
result = Object.objects.get(id=self.uid)
#print 'RES', result
return result
def game_connect_screen(self, session):
"""
Show our banner screen.
@ -80,11 +88,11 @@ class PlayerSession(async_chat):
"""
After the user has authenticated, handle logging him in.
"""
self.pobject = functions_db.get_object_from_dbref(self.server, user.id)
self.uid = user.id
self.name = user.username
self.logged_in = True
self.conn_time = time.time()
self.pobject.set_flag("CONNECTED", True)
self.get_pobject().set_flag("CONNECTED", True)
self.msg("You are now logged in as %s." % (self.name,))
cdat = {"session": self, "uinput":'look', "server": self.server}
@ -116,5 +124,5 @@ class PlayerSession(async_chat):
symbol = '?'
return "<%s> %s@%s" % (symbol, self.name, self.address,)
# def handle_error(self):
# self.handle_close()
# def handle_error(self):
# self.handle_close()