X-Git-Url: https://mudpy.org/gitweb?p=mudpy.git;a=blobdiff_plain;f=mudpy%2Fmisc.py;h=4e32cccd5e99073b7f718bb3a7bbfc7eedb3086d;hp=f57fec3942769a1b28d81b93c35b628d8bec3bb8;hb=31bd5bdf5962b81cd22df5173775d7886405be80;hpb=947a707d32fe29eff85c7091b82be5c67056aecf diff --git a/mudpy/misc.py b/mudpy/misc.py index f57fec3..4e32ccc 100644 --- a/mudpy/misc.py +++ b/mudpy/misc.py @@ -1,6 +1,6 @@ """Miscellaneous functions for the mudpy engine.""" -# Copyright (c) 2004-2016 Jeremy Stanley . Permission +# Copyright (c) 2004-2017 Jeremy Stanley . Permission # to use, copy, modify, and distribute this software is granted under # terms provided in the LICENSE file distributed with this software. @@ -347,6 +347,7 @@ class Universe: self.contents = {} self.default_origins = {} self.directions = set() + self.loading = False self.loglines = [] self.private_files = [] self.reload_flag = False @@ -375,6 +376,9 @@ class Universe: def load(self): """Load universe data from persistent storage.""" + # while loading, it's safe to update elements from read-only files + self.loading = True + # it's possible for this to enter before logging configuration is read pending_loglines = [] @@ -425,6 +429,10 @@ class Universe: for element in self.contents.values(): element.update_location() element.clean_contents() + + # done loading, so disallow updating elements from read-only files + self.loading = False + return pending_loglines def new(self): @@ -1307,7 +1315,7 @@ def replace_macros(user, text, is_input=False): replacement = replacement[:-2] else: replacement = "" - log("Couldn't read included " + incfile + " file.", 6) + log("Couldn't read included " + incfile + " file.", 7) # if we get here, log and replace it with null else: