diff options
author | Bardur Arantsson <bardur@scientician.net> | 2012-06-11 20:26:42 +0200 |
---|---|---|
committer | Bardur Arantsson <bardur@scientician.net> | 2012-06-19 18:36:20 +0200 |
commit | f9df262f44fe8b971813d9f136d8a6c6f44a0251 (patch) | |
tree | e3bca3f9bb898f1798674b3b79739df916851def /lib/mods | |
parent | fe752bb67a2a43c49c3f1b6d25eb646b1f7d9847 (diff) |
Lua: Remove dead load/save code
Diffstat (limited to 'lib/mods')
-rw-r--r-- | lib/mods/theme/core/init.lua | 11 | ||||
-rw-r--r-- | lib/mods/theme/core/load.lua | 37 | ||||
-rw-r--r-- | lib/mods/theme/core/load2.lua | 56 |
3 files changed, 0 insertions, 104 deletions
diff --git a/lib/mods/theme/core/init.lua b/lib/mods/theme/core/init.lua index 74486ba2..be3d40a3 100644 --- a/lib/mods/theme/core/init.lua +++ b/lib/mods/theme/core/init.lua @@ -3,9 +3,6 @@ -- Load the system functions -- --- Name of globals to save -tome_dofile_anywhere(ANGBAND_DIR_CORE, "load.lua") - -- Very thin xml parser(49 lines ;) tome_dofile_anywhere(ANGBAND_DIR_CORE, "xml.lua") @@ -15,11 +12,3 @@ tome_dofile_anywhere(ANGBAND_DIR_CORE, "player.lua") tome_dofile_anywhere(ANGBAND_DIR_CORE, "objects.lua") tome_dofile_anywhere(ANGBAND_DIR_CORE, "monsters.lua") tome_dofile_anywhere(ANGBAND_DIR_CORE, "dungeon.lua") - --------------------------------------------------------------- --------------------------------------------------------------- --------------------------------------------------------------- --- --- Do not thouch after this line --- -tome_dofile_anywhere(ANGBAND_DIR_CORE, "load2.lua") diff --git a/lib/mods/theme/core/load.lua b/lib/mods/theme/core/load.lua deleted file mode 100644 index 9522ec91..00000000 --- a/lib/mods/theme/core/load.lua +++ /dev/null @@ -1,37 +0,0 @@ --- Savefile stuff --- Do not meddle in the affairs of savefiles for they are subtle and quick to be become incompatible - -__loadsave_name = {} -__loadsave_max = 0 -__loadsave_tmp = 0 - -function add_loadsave(name, default) - assert(name, "No variable name to save") - assert(default, "No default value") - - -- if it is a table we must create many entries - if type(default) == "table" then - for k, e in default do - add_loadsave(name.."."..k, e) - end - else - __loadsave_name[__loadsave_max] = { name = name, default = default } - __loadsave_max = __loadsave_max + 1 - end -end - --- Example of how to save a table --- NOTE: { 1, 2, 3 } will NOT work, the key MUST be a string ---[[ -add_loadsave("t", -{ - foo = 7, - tab = { - a = 1, - b = 2, - tab = { - a=1, b=2, c=3, - }, - }, -}) -]] diff --git a/lib/mods/theme/core/load2.lua b/lib/mods/theme/core/load2.lua deleted file mode 100644 index 7e151d91..00000000 --- a/lib/mods/theme/core/load2.lua +++ /dev/null @@ -1,56 +0,0 @@ --- Savefile helpers - --- function called when a key in the variable part ofthe savefile is read --- if the key matches what we need, we use it, otehrwise just ignore it -function __savefile_load(key, val) - local index, elem - - for index, elem in __loadsave_name do - if (key == elem.name) then - dostring(elem.name.." = "..val) - end - end -end - --- called when the game is saved, can only save numbers --- assosiate a key with them to allow the loading code to recognize them -function __savefile_save() - local index, elem - for index, elem in __loadsave_name do - dostring("__loadsave_tmp = "..elem.name) - save_number_key(elem.name, __loadsave_tmp); - end -end - -register_savefile(__loadsave_max) -add_hook_script(HOOK_LOAD_GAME, "__savefile_load", "__hook_load") -add_hook_script(HOOK_SAVE_GAME, "__savefile_save", "__hook_save") - --- Parse a flattened(i.e: foo.bar.zog) table path and recrate tables -function reconstruct_table(name) - for i = 1, strlen(name) - 1 do - if strsub(name, i, i) == "." then - local tbl = strsub(name, 1, i - 1) - - if dostring("return "..tbl) == nil then - dostring(tbl.."={}") - end - end - end -end - --- Automagically set unkown variables, otherwise the savefile code --- might get VERY upset -do - local k, e - -- We need to be able to check for unknown globals - unset_safe_globals() - for k, e in __loadsave_name do - reconstruct_table(e.name) - if dostring("return "..(e.name)) == nil then - dostring((e.name).." = "..(e.default)) - end - end - -- Now taht we did, we set it back, for it is usefull ;) - set_safe_globals() -end |