Bad logic for object recycling. Boo me. Adjusted create_object() and @nextfree.

This commit is contained in:
Greg Taylor 2007-09-14 16:32:38 +00:00
parent 74a3a01429
commit 3ae3bd6884
2 changed files with 5 additions and 13 deletions

View file

@ -292,12 +292,7 @@ def cmd_nextfree(cdat):
session = cdat['session']
nextfree = functions_db.get_nextfree_dbnum()
if str(nextfree).isdigit():
retval = "Next free object number: #%s" % (nextfree,)
else:
retval = "Next free object number: #%s (GARBAGE)" % (nextfree.id,)
session.msg(retval)
session.msg("Next free object number: #%s" % (nextfree,))
def cmd_open(cdat):
"""

View file

@ -80,7 +80,7 @@ def get_nextfree_dbnum():
nextfree = Object.objects.filter(type__exact=defines_global.OTYPE_GARBAGE)
if nextfree:
# We've got at least one garbage object to recycle.
return nextfree[0]
return nextfree.id
else:
# No garbage to recycle, find the highest dbnum and increment it
# for our next free.
@ -263,12 +263,9 @@ def create_object(odat):
location key for home.
"""
next_dbref = get_nextfree_dbnum()
if not str(next_dbref).isdigit():
# Recycle a garbage object.
new_object = next_dbref
else:
new_object = Object()
new_object = Object()
new_object.id = next_dbref
new_object.type = odat["type"]
new_object.set_name(odat["name"])