Imported from archive.
[mudpy.git] / lib / muff / muffmisc.py
index 749af91..f7218e6 100644 (file)
@@ -8,9 +8,6 @@ import ConfigParser
 # used by several functions for random calls
 import random
 
-# used to match the 'L' at the end of a long int in repr_long
-import re
-
 # random_name uses string.strip
 import string
 
@@ -143,25 +140,8 @@ def random_name():
        # strip any leading quotemark, capitalize and return the name
        return string.strip(name, "'").capitalize()
 
-def repr_long(value):
-       string_value = repr(value)
-       if re.match('\d*L$', string_value): return string_value.strip("L")
-       else: return string_value
-
-def getlong(config, section, option):
-       try:
-               return int(config.get(section, option).strip("L"))
-       except ConfigParser.NoSectionError:
-               config.add_section(section)
-               return getlong(config, section, option)
-       except ConfigParser.NoOptionError:
-               setlong(config, section, option, 0)
-               return getlong(config, section, option)
-
-def setlong(config, section, option, value):
-       return config.set(section, option, repr_long(value))
-
 def replace_macros(user, text, is_input=False):
+       """Replaces macros in text output."""
        while True:
                macro_start = string.find(text, "$(")
                if macro_start == -1: break
@@ -216,7 +196,7 @@ def check_time(frequency):
        """Check for a factor of the current increment count."""
        if type(frequency) is str:
                frequency = muffconf.getint("time", frequency)
-       return not getlong(muffvars.variable_data, "time", "elapsed") % frequency
+       return not muffuniv.universe.internals["counters"].getint("elapsed") % frequency
 
 def on_pulse():
        """The things which should happen on each pulse, aside from reloads."""
@@ -237,7 +217,6 @@ def on_pulse():
 
        # periodically save everything
        if check_time("frequency_save"):
-               muffvars.save()
                for user in muffvars.userlist: user.save()
                muffuniv.universe.save()
 
@@ -245,8 +224,7 @@ def on_pulse():
        time.sleep(muffconf.getfloat("time", "increment"))
 
        # increment the elapsed increment counter
-       setlong(muffvars.variable_data, "time", "elapsed",
-               getlong(muffvars.variable_data, "time", "elapsed") + 1)
+       muffuniv.universe.internals["counters"].set("elapsed", muffuniv.universe.internals["counters"].getint("elapsed") + 1)
 
 def reload_data():
        """Reload data into new persistent objects."""