* Implemented a non-persistent cache in src/cache.py. The cache is lost when restarting the server but it has the advantage of not hitting the database, and so is useful for implementing things that should be remembered over time but does not need to be persistently saved in the database at every point, like fast-updating combat systems, timers etc. Using the cache can substantially cut down on database access at the cost of memory comsumption. It is easiest accessed through the object model using normal dot notation. So to store a variable in volatile memory e.g. from your script parent, you can do things like self.scripted_obj.cache.myvariable = variable and be sure that later (unless there was a reboot) doing self.scripted_obj.cache.myvariable will return the value you stored there.

* OBS - doing e.g. self.scripted_obj.myvariable = variable was always iffy and since a few revisions back this will NOT work - this is because the objects are now consistently synced with the database (in the past this was not done consistently which caused strange behaviour).
* Fixed some bugs in the multi-word command handler. It can handle multi-word exits as well now.
This commit is contained in:
Griatch 2009-11-01 15:12:38 +00:00
parent af19724bb2
commit 642932a403
9 changed files with 177 additions and 58 deletions

View file

@ -136,7 +136,7 @@ def parse_batchbuild_file(filename):
else: #comment
if curr_cmd:
commands.append(curr_cmd.strip())
curr_cmd = ""
curr_cmd = ""
if curr_cmd: commands.append(curr_cmd.strip())
#second round to clean up now merged line edges etc.
@ -145,7 +145,6 @@ def parse_batchbuild_file(filename):
#remove eventual newline at the end of commands
commands = [c.strip('\r\n') for c in commands]
return commands
def batch_process(source_object, commands):
@ -202,7 +201,6 @@ def cmd_batchprocess(command):
if not source_object.set_state(STATENAME):
source_object.emit_to("You cannot use the interactive mode while you have the flag ADMIN_NOSTATE set.")
return
CMDSTACKS[source_object] = commands
STACKPTRS[source_object] = 0
FILENAMES[source_object] = filename
@ -263,10 +261,10 @@ def process_commands(source_object, steps=0):
for cmd in cmds:
#this so it is kept in case of traceback
STACKPTRS[source_object] = ptr + 1
show_curr(source_object)
#show_curr(source_object)
source_object.execute_cmd(cmd)
else:
show_curr(source_object)
#show_curr(source_object)
source_object.execute_cmd(commands[ptr])
def reload_stack(source_object):
@ -298,7 +296,7 @@ def exit_state(source_object):
# (to avoid accidental drop-outs by rooms clearing a player's state),
# we have to clear the state directly here.
source_object.state = None
def cmd_state_ll(command):
"""
ll