summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2012-06-11 20:26:42 +0200
committerBardur Arantsson <bardur@scientician.net>2012-06-19 18:36:20 +0200
commitf9df262f44fe8b971813d9f136d8a6c6f44a0251 (patch)
treee3bca3f9bb898f1798674b3b79739df916851def
parentfe752bb67a2a43c49c3f1b6d25eb646b1f7d9847 (diff)
Lua: Remove dead load/save code
-rw-r--r--lib/core/init.lua11
-rw-r--r--lib/core/load.lua37
-rw-r--r--lib/core/load2.lua56
-rw-r--r--lib/mods/theme/core/init.lua11
-rw-r--r--lib/mods/theme/core/load.lua37
-rw-r--r--lib/mods/theme/core/load2.lua56
-rw-r--r--src/externs.h3
-rw-r--r--src/loadsave.c62
-rw-r--r--src/util.pkg21
9 files changed, 0 insertions, 294 deletions
diff --git a/lib/core/init.lua b/lib/core/init.lua
index 74486ba2..be3d40a3 100644
--- a/lib/core/init.lua
+++ b/lib/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/core/load.lua b/lib/core/load.lua
deleted file mode 100644
index 9522ec91..00000000
--- a/lib/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/core/load2.lua b/lib/core/load2.lua
deleted file mode 100644
index 7e151d91..00000000
--- a/lib/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
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
diff --git a/src/externs.h b/src/externs.h
index dc449cb1..2c996223 100644
--- a/src/externs.h
+++ b/src/externs.h
@@ -994,7 +994,6 @@ extern u32b fake_text_size;
extern bool_ gen_joke_monsters(void *data, void *in, void *out);
/* loadsave.c */
-extern void register_savefile(int num);
extern bool_ file_exist(char *buf);
extern s16b rd_variable(void);
extern void wr_variable(s16b *var);
@@ -1004,8 +1003,6 @@ extern void save_dungeon(void);
extern bool_ save_player(void);
extern bool_ load_player(void);
extern errr rd_savefile_new(void);
-extern void load_number_key(char *key, u32b *val);
-extern void save_number_key(char *key, u32b val);
/* melee1.c */
/* melee2.c */
diff --git a/src/loadsave.c b/src/loadsave.c
index 65d72d9c..dcdcaae9 100644
--- a/src/loadsave.c
+++ b/src/loadsave.c
@@ -2954,31 +2954,6 @@ static bool_ do_savefile_aux(int flag)
C_FREE(reals, max_towns, bool_);
- if (flag == LS_SAVE) tmp32u = extra_savefile_parts;
- do_u32b(&tmp32u, flag);
- if (flag == LS_SAVE)
- {
- /* Save the stuff */
- process_hooks(HOOK_SAVE_GAME, "()");
- }
-
- if (flag == LS_LOAD)
- {
- u32b len = tmp32u;
-
- while (len)
- {
- char key_buf[100];
-
- /* Load a key */
- load_number_key(key_buf, &tmp32u);
-
- /* Process it -- the hooks can use it or ignore it */
- process_hooks(HOOK_LOAD_GAME, "(s,l)", key_buf, tmp32u);
- len--;
- }
- }
-
/* I'm not dead yet... */
if (!death)
{
@@ -3294,40 +3269,3 @@ static void my_sentinel(char *place, u16b value, int flag)
note(format("Impossible has occurred")); /* Programmer error */
exit(0);
}
-
-/********** Variable savefile stuff **************/
-
-/*
- * Add num slots to the savefile
- */
-void register_savefile(int num)
-{
- extra_savefile_parts += (num > 0) ? num : 0;
-}
-
-void save_number_key(char *key, u32b val)
-{
- byte len = strlen(key);
-
- do_byte(&len, LS_SAVE);
- while (*key)
- {
- do_byte((byte*)key, LS_SAVE);
- key++;
- }
- do_u32b(&val, LS_SAVE);
-}
-
-void load_number_key(char *key, u32b *val)
-{
- byte len, i = 0;
-
- do_byte(&len, LS_LOAD);
- while (i < len)
- {
- do_byte((byte*)&key[i], LS_LOAD);
- i++;
- }
- key[i] = '\0';
- do_u32b(val, LS_LOAD);
-}
diff --git a/src/util.pkg b/src/util.pkg
index 33f60a59..1412e66b 100644
--- a/src/util.pkg
+++ b/src/util.pkg
@@ -1369,27 +1369,6 @@ extern cptr string_exec_lua(char *file);
*/
extern void lua_print_hook@print_hook(cptr str);
-/* Savefile stuff */
-/** @fn register_savefile(int num)
- * @brief Add "num" slots to the savefile.\n
- * @param num Number \n the number of slots to add.
- * @brief Slots
- * @note (see file loadsave.c)
- */
-extern void register_savefile(int num);
-
-/** @fn save_number_key(char *key, s32b val)
- * @brief Save a key-value combination in the save file.\n
- * @param *key String \n the key to save.
- * @brief Key
- * @param val Number \n the value of the key.
- * @brief Value
- * @note
- * The length of the key is stored first, then the key, then the value.
- * @note (see file loadsave.c)
- */
-extern void save_number_key(char *key, s32b val);
-
/* Tables */
/** @var adj_mag_study[100]