I was ready to abandon the 64-bit project when I found an acceptable solution: the 64-bit version should simply ignore any bytecode contained in the savegames. The 32-bit LOG2 stores the bytecode of hooks and script functions to savegames, but this is ultimately unnecessary. Hooks can be copied from arch object definitions and script functions can be loaded from the dungeon file. I haven't yet fully worked out all the details, but I think this should work.
However, there are some (rare) cases where this could break. If scripts treat functions as first-class values, e.g. if they copy/rename/delete functions at runtime (for example to implement state machines), the savegame loader will load the state of those functions as they were when the dungeon was started. I have checked the main dungeon and I've found no cases which would fail.
But, for example, the following script would fail because the variable 'state' would always point to 'state1' after loading a savegame:
Code: Select all
state = state1
function state1()
if <some condition> then state = state2 end
end
function state2()
if <some condition> then state = state1 end
end
function tick()
state()
end
Questions:
1. Are there any mods that rely on the old behavior (serialization of functions)?
2. Can you think of any reasons why this is a bad idea? (It's possible that I've missed some detail)