From 3ae3bd68846c620a520df0e041f7637fc626f0b0 Mon Sep 17 00:00:00 2001 From: Greg Taylor Date: Fri, 14 Sep 2007 16:32:38 +0000 Subject: [PATCH] Bad logic for object recycling. Boo me. Adjusted create_object() and @nextfree. --- commands/objmanip.py | 7 +------ functions_db.py | 11 ++++------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/commands/objmanip.py b/commands/objmanip.py index 5042ebddc3..779647132d 100644 --- a/commands/objmanip.py +++ b/commands/objmanip.py @@ -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): """ diff --git a/functions_db.py b/functions_db.py index bd777fa46c..6e06e9c86e 100644 --- a/functions_db.py +++ b/functions_db.py @@ -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"])