mirror of
https://github.com/evennia/evennia.git
synced 2026-03-22 15:56:30 +01:00
- implemented @destroy as per the MUX help specifications. As part of this, fixed the object recycling routines to actually properly replace GARBAGE-flagged objects (it crashed before).
- Set up a global cleaner event to clean all @destroyed objects every 30 minutes (makes their dbrefs available). - Added the @recover command for recovering @destroyed objects up until the point that the cleaner runs and actually destroys them. This can recover @destroyed objects, rooms and exits to the same state as before @destroy. It could easily be made to recover player objects too, but I'm thinking this would be a security issue. - Added to @dig in order to allow for creating rooms with a particular parent. Also auto-creates exits in each room if desired. The only things that is not implemented is the aliases of the exits, I don't really know how to do that. - Changed the @create command format to match the @dig (it uses : to mark the parent instead of = now, since MUX' @dig reserve = to the exit list.) - Added extra security in the example event to guard against the bug that causes the whole scheduler to freak out if the event_function() gives a traceback. - Changed many instances of type to point to the defines_global.OTYPE instead of giving the integer explicitly. /Starkiel
This commit is contained in:
parent
8799a0fd55
commit
3eb4cddf42
8 changed files with 274 additions and 77 deletions
|
|
@ -60,7 +60,7 @@ class ObjectManager(models.Manager):
|
|||
nextfree = self.filter(type__exact=defines_global.OTYPE_GARBAGE)
|
||||
if nextfree:
|
||||
# We've got at least one garbage object to recycle.
|
||||
return nextfree.id
|
||||
return nextfree[0]
|
||||
else:
|
||||
# No garbage to recycle, find the highest dbnum and increment it
|
||||
# for our next free.
|
||||
|
|
@ -74,15 +74,16 @@ class ObjectManager(models.Manager):
|
|||
o_query = self.filter(name__iexact=ostring)
|
||||
else:
|
||||
o_query = self.filter(name__icontains=ostring)
|
||||
|
||||
|
||||
return o_query.exclude(type__in=[defines_global.OTYPE_GARBAGE,
|
||||
defines_global.OTYPE_GOING])
|
||||
|
||||
|
||||
def global_object_script_parent_search(self, script_parent):
|
||||
"""
|
||||
Searches through all objects returning those which has a certain script parent.
|
||||
"""
|
||||
o_query = self.filter(script_parent__exact=script_parent)
|
||||
|
||||
return o_query.exclude(type__in=[defines_global.OTYPE_GARBAGE,
|
||||
defines_global.OTYPE_GOING])
|
||||
|
||||
|
|
@ -107,6 +108,7 @@ class ObjectManager(models.Manager):
|
|||
else:
|
||||
return [prospect for prospect in searchlist if prospect.name_match(ostring, match_type=match_type)]
|
||||
|
||||
|
||||
def object_totals(self):
|
||||
"""
|
||||
Returns a dictionary with database object totals.
|
||||
|
|
@ -121,6 +123,8 @@ class ObjectManager(models.Manager):
|
|||
}
|
||||
return dbtotals
|
||||
|
||||
|
||||
|
||||
def player_alias_search(self, searcher, ostring):
|
||||
"""
|
||||
Search players by alias. Returns a list of objects whose "ALIAS"
|
||||
|
|
@ -136,7 +140,7 @@ class ObjectManager(models.Manager):
|
|||
model="attribute").model_class()
|
||||
results = Attribute.objects.select_related().filter(attr_name__exact="ALIAS").filter(attr_value__iexact=ostring)
|
||||
return [prospect.get_object() for prospect in results if prospect.get_object().is_player()]
|
||||
|
||||
|
||||
def player_name_search(self, search_string):
|
||||
"""
|
||||
Combines an alias and global search for a player's name. If there are
|
||||
|
|
@ -263,19 +267,26 @@ class ObjectManager(models.Manager):
|
|||
* home: Reference to another object to home to. If not specified, use
|
||||
location key for home.
|
||||
"""
|
||||
#get_nextfree_dbnum() returns either an integer or an object to recycle.
|
||||
next_dbref = self.get_nextfree_dbnum()
|
||||
Object = ContentType.objects.get(app_label="objects",
|
||||
model="object").model_class()
|
||||
new_object = Object()
|
||||
|
||||
new_object.id = next_dbref
|
||||
new_object.type = odat["type"]
|
||||
if type(next_dbref) == type(int()):
|
||||
#create object with new dbref
|
||||
Object = ContentType.objects.get(app_label="objects",
|
||||
model="object").model_class()
|
||||
new_object = Object()
|
||||
new_object.id = next_dbref
|
||||
else:
|
||||
#recycle an old object's dbref
|
||||
new_object = next_dbref
|
||||
|
||||
new_object.type = odat["type"]
|
||||
new_object.set_name(odat["name"])
|
||||
|
||||
# If this is a player, we don't want him owned by anyone.
|
||||
# The get_owner() function will return that the player owns
|
||||
# himself.
|
||||
if odat["type"] == 1:
|
||||
if odat["type"] == defines_global.OTYPE_PLAYER:
|
||||
new_object.owner = None
|
||||
new_object.zone = None
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -502,7 +502,7 @@ class Object(models.Model):
|
|||
% (self,))
|
||||
|
||||
# Set the object type to GOING
|
||||
self.type = 5
|
||||
self.type = defines_global.OTYPE_GOING
|
||||
# Destroy any exits to and from this room, do this first
|
||||
self.clear_exits()
|
||||
# Clear out any objects located within the object
|
||||
|
|
@ -519,7 +519,7 @@ class Object(models.Model):
|
|||
uobj[0].delete()
|
||||
|
||||
# Set the object to type GARBAGE.
|
||||
self.type = 6
|
||||
self.type = defines_global.OTYPE_GARBAGE
|
||||
self.save()
|
||||
|
||||
# Clear all attributes
|
||||
|
|
@ -530,8 +530,8 @@ class Object(models.Model):
|
|||
Destroys all of the exits and any exits pointing to this
|
||||
object as a destination.
|
||||
"""
|
||||
exits = self.get_contents(filter_type=4)
|
||||
exits += self.obj_home.all().filter(type__exact=4)
|
||||
exits = self.get_contents(filter_type=defines_global.OTYPE_EXIT)
|
||||
exits += self.obj_home.all().filter(type__exact=defines_global.OTYPE_EXIT)
|
||||
|
||||
for exit in exits:
|
||||
exit.destroy()
|
||||
|
|
@ -781,6 +781,7 @@ class Object(models.Model):
|
|||
parent_str: (string) String pythonic import path of the script parent
|
||||
assuming the python path is game/gamesrc/parents.
|
||||
"""
|
||||
|
||||
if parent_str == None:
|
||||
if self.is_player():
|
||||
self.script_parent = settings.SCRIPT_DEFAULT_PLAYER
|
||||
|
|
@ -789,9 +790,10 @@ class Object(models.Model):
|
|||
elif parent_str:
|
||||
#check if this is actually a reasonable script parent
|
||||
#(storing with a non-valid parent path causes havoc!)
|
||||
parent_str = str(parent_str).strip()
|
||||
if not scripthandler.scriptlink(self, parent_str):
|
||||
return False
|
||||
self.script_parent = parent_str.strip()
|
||||
self.script_parent = parent_str
|
||||
self.save()
|
||||
return True
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue