mirror of
https://github.com/evennia/evennia.git
synced 2026-04-03 06:27:17 +02:00
Added a check for 1st level recursion of location. So self.location=self will no longer work. I did not add a full recursive check (it would need to go through all contents of the object and their contents etc) since this is expensive for something that should usually not be a common error. Further checks could be added higher up in the build commands if location-loops are considered a big problem. Resolves Issue 296.
This commit is contained in:
parent
4830560ac5
commit
67dc11849f
1 changed files with 16 additions and 3 deletions
|
|
@ -285,18 +285,31 @@ class ObjectDB(TypedObject):
|
|||
loc = _GA(location, "dbobj")
|
||||
else:
|
||||
loc = location
|
||||
if loc == self:
|
||||
# block 1st level recursion; best to defer having to do
|
||||
# a full recursive check of location loops if possible -
|
||||
# (it's rather expensive) this could be checked higher up
|
||||
# if a problem.
|
||||
raise RuntimeError
|
||||
# set the location
|
||||
_set_cache(self, "location", loc)
|
||||
# update the contents of each location
|
||||
if old_loc:
|
||||
_GA(_GA(old_loc, "dbobj"), "contents_update")(self, remove=True)
|
||||
if loc:
|
||||
_GA(loc, "contents_update")(_GA(self, "typeclass"))
|
||||
except RuntimeError:
|
||||
string = "Cannot set location: "
|
||||
string += "%s.location = %s would create a location-loop." % (self.key, location)
|
||||
_GA(self, "msg")(_(string))
|
||||
logger.log_trace(string)
|
||||
raise RuntimeError(string)
|
||||
except Exception:
|
||||
string = "Cannot set location: "
|
||||
string += "%s is not a valid location."
|
||||
_GA(self, "msg")(_(string) % location)
|
||||
string += "%s is not a valid location." % location
|
||||
_GA(self, "msg")(_(string))
|
||||
logger.log_trace(string)
|
||||
raise
|
||||
raise Exception(string)
|
||||
#@location.deleter
|
||||
def __location_del(self):
|
||||
"Deleter. Allows for del self.location"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue