--- /dev/null
+"""Main loop for the MUFF Engine"""
+
+# Copyright (c) 2005 mudpy, Jeremy Stanley <fungi@yuggoth.org>, all rights reserved.
+# Licensed per terms in the LICENSE file distributed with this software.
+
+# string.strip is used to clean up leading/trailing whitespace in user input
+import string
+
+# time.sleep is used in the loop to save cpu and provide crude pulse timing
+import time
+
+# hack to load all modules in the muff package
+import muff
+for module in muff.__all__:
+ exec("import " + module)
+
+def main():
+ """The main loop."""
+
+ # loop indefinitely while the world is not flagged for termination or
+ # there are connected users
+ while not muffvars.terminate_world or muffvars.userlist:
+
+ # the world was flagged for a reload of all code/data
+ if muffvars.reload_modules:
+
+ # reload the muff package
+ reload(muff)
+
+ # reload all modules listed in the muff package
+ for module in muff.__all__:
+ exec("reload(muff." + module + ")")
+
+ # move data into new persistent objects
+ muffmisc.reload_data()
+
+ # reset the reload flag
+ muffvars.reload_modules = False
+
+ # do what needs to be done on each pulse
+ muffmisc.on_pulse()
+
+ # the loop has terminated, so save persistent data
+ muffuniv.universe.save()
+
+ # log a final message
+ muffmisc.log("Shutting down now.")
+