From b9894d348db43cacb2807c325fb48d8d46e84985 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Mon, 11 Jun 2012 20:39:06 +0200 Subject: Lua: Remove dead object & summoning code --- lib/core/objects.lua | 37 ------------------------------ lib/mods/theme/core/objects.lua | 37 ------------------------------ src/defines.h | 1 - src/externs.h | 2 -- src/lua_bind.c | 51 ----------------------------------------- src/monster.pkg | 23 ------------------- src/monster2.c | 5 ---- src/object.pkg | 2 -- 8 files changed, 158 deletions(-) diff --git a/lib/core/objects.lua b/lib/core/objects.lua index 97320b82..fa77c57b 100644 --- a/lib/core/objects.lua +++ b/lib/core/objects.lua @@ -3,43 +3,6 @@ -- Lua object funtions -- -function create_object(tval, sval) - local obj = new_object() - object_prep(obj, lookup_kind(tval, sval)) - return (obj) -end - -function set_item_tester(tester) - if tolua.type(tester) == "number" then - lua_set_item_tester(tester, "") - end - if tolua.type(tester) == "string" then - lua_set_item_tester(0, tester) - end - if tolua.type(tester) == "function" then - __get_item_hook_default = tester - lua_set_item_tester(0, "__get_item_hook_default") - end -end - -function create_artifact(a_idx) - local obj - local tval, sval - - tval = a_info[a_idx + 1].tval - sval = a_info[a_idx + 1].sval - obj = create_object(tval, sval) - obj.name1 = a_idx - apply_magic(obj, -1, TRUE, TRUE, TRUE) - - return (obj) -end - function get_kind(obj) return k_info[obj.k_idx + 1] end - -function get_item(ask, deny, flags, mask) - set_item_tester(mask) - return get_item_aux(0, ask, deny, flags) -end diff --git a/lib/mods/theme/core/objects.lua b/lib/mods/theme/core/objects.lua index 97320b82..fa77c57b 100644 --- a/lib/mods/theme/core/objects.lua +++ b/lib/mods/theme/core/objects.lua @@ -3,43 +3,6 @@ -- Lua object funtions -- -function create_object(tval, sval) - local obj = new_object() - object_prep(obj, lookup_kind(tval, sval)) - return (obj) -end - -function set_item_tester(tester) - if tolua.type(tester) == "number" then - lua_set_item_tester(tester, "") - end - if tolua.type(tester) == "string" then - lua_set_item_tester(0, tester) - end - if tolua.type(tester) == "function" then - __get_item_hook_default = tester - lua_set_item_tester(0, "__get_item_hook_default") - end -end - -function create_artifact(a_idx) - local obj - local tval, sval - - tval = a_info[a_idx + 1].tval - sval = a_info[a_idx + 1].sval - obj = create_object(tval, sval) - obj.name1 = a_idx - apply_magic(obj, -1, TRUE, TRUE, TRUE) - - return (obj) -end - function get_kind(obj) return k_info[obj.k_idx + 1] end - -function get_item(ask, deny, flags, mask) - set_item_tester(mask) - return get_item_aux(0, ask, deny, flags) -end diff --git a/src/defines.h b/src/defines.h index 7e4321a1..6fa426c7 100644 --- a/src/defines.h +++ b/src/defines.h @@ -2582,7 +2582,6 @@ #define SUMMON_SHADOWS 55 #define SUMMON_GHOST 56 #define SUMMON_QUYLTHULG 57 -#define SUMMON_LUA 58 /* diff --git a/src/externs.h b/src/externs.h index 2c996223..d4d7d140 100644 --- a/src/externs.h +++ b/src/externs.h @@ -2379,8 +2379,6 @@ extern char *lua_object_desc(object_type *o_ptr, int pref, int mode); extern s16b add_new_power(cptr name, cptr desc, cptr gain, cptr lose, byte level, byte cost, byte stat, byte diff); extern void find_position(int y, int x, int *yy, int *xx); -extern bool_ summon_lua_okay(int r_idx); -extern bool_ lua_summon_monster(int y, int x, int lev, bool_ ffriend, char *fct); extern s16b add_new_gods(char *name); extern int get_lua_int(cptr name); diff --git a/src/lua_bind.c b/src/lua_bind.c index ab1a19c8..4ae8ed80 100644 --- a/src/lua_bind.c +++ b/src/lua_bind.c @@ -82,33 +82,6 @@ void end_object(object_type *o_ptr) FREE(o_ptr, object_type); } -static char *lua_item_tester_fct; -static bool_ lua_item_tester(object_type* o_ptr) -{ - int oldtop = lua_gettop(L); - bool_ ret; - - lua_getglobal(L, lua_item_tester_fct); - tolua_pushusertype(L, o_ptr, tolua_tag(L, "object_type")); - lua_call(L, 1, 1); - ret = lua_tonumber(L, -1); - lua_settop(L, oldtop); - return (ret); -} - -void lua_set_item_tester(int tval, char *fct) -{ - if (tval) - { - item_tester_tval = tval; - } - else - { - lua_item_tester_fct = fct; - item_tester_hook = lua_item_tester; - } -} - char *lua_object_desc(object_type *o_ptr, int pref, int mode) { static char buf[150]; @@ -132,30 +105,6 @@ void find_position(int y, int x, int *yy, int *xx) while (!(in_bounds(*yy, *xx) && cave_floor_bold(*yy, *xx)) && --attempts); } -static char *summon_lua_okay_fct; -bool_ summon_lua_okay(int r_idx) -{ - int oldtop = lua_gettop(L); - bool_ ret; - - lua_getglobal(L, lua_item_tester_fct); - tolua_pushnumber(L, r_idx); - lua_call(L, 1, 1); - ret = lua_tonumber(L, -1); - lua_settop(L, oldtop); - return (ret); -} - -bool_ lua_summon_monster(int y, int x, int lev, bool_ friend_, char *fct) -{ - summon_lua_okay_fct = fct; - - if (!friend_) - return summon_specific(y, x, lev, SUMMON_LUA); - else - return summon_specific_friendly(y, x, lev, SUMMON_LUA, TRUE); -} - /* * Misc */ diff --git a/src/monster.pkg b/src/monster.pkg index a9efd089..bf0f4661 100644 --- a/src/monster.pkg +++ b/src/monster.pkg @@ -2062,25 +2062,6 @@ extern bool summon_specific(int y1, int x1, int lev, int type); */ extern bool summon_specific_friendly(int y1, int x1, int lev, int type, bool Group_ok); -/** @fn summon_monster_aux(int y, int x, int lev, bool friend, char *fct); - * @brief Place a monster near grid "y","x".\n - * @param y Number \n the y coordinate of the target grid - * @brief Y-coordinate - * @param x Number \n the x coordinate of the target grid - * @brief X-coordinate - * @param lev Number \n the monster level of the summoning monster - * @brief Summoner level - * @param friend Boolean \n TRUE if friendly monsters are to be summoned, - * otherwise FALSE - * @brief Friendly? - * @param *fct String \n the function which determines which type of monster - * will be summoned - * @brief Monster type function - * @return Boolean \n TRUE if a monster was summoned, otherwise FALSE. - * @note (see file w_mnster.c) - */ -extern bool lua_summon_monster @ summon_monster_aux(int y, int x, int lev, bool friend, char *fct); - /** @fn can_create_companion() * @brief Determine if a companion can be created. * @return Boolean \n TRUE if a companion can be created, otherwise FALSE. @@ -2300,10 +2281,6 @@ extern void monster_set_level(int m_idx, int level); */ #define SUMMON_QUYLTHULG 57 -/** @def SUMMON_LUA - * @note Summon monsters according to a Lua script. - */ -#define SUMMON_LUA 58 /** @} */ /** @fn do_control_reconnect() diff --git a/src/monster2.c b/src/monster2.c index cdef75d4..e9ae164e 100644 --- a/src/monster2.c +++ b/src/monster2.c @@ -3355,11 +3355,6 @@ bool_ summon_specific_okay(int r_idx) break; } - case SUMMON_LUA: - { - okay = summon_lua_okay(r_idx); - break; - } } /* Result */ diff --git a/src/object.pkg b/src/object.pkg index 4859e35b..05ea9c1a 100644 --- a/src/object.pkg +++ b/src/object.pkg @@ -1130,8 +1130,6 @@ extern s16b drop_near(object_type *o_ptr, int chance, int y, int x); extern object_type *get_object(int item); extern object_type *new_object(); extern void end_object(object_type *o_ptr); -extern bool get_item @ get_item_aux(int *cp, cptr pmt, cptr str, int mode); -extern void lua_set_item_tester(int tval, char *fct); extern void identify_pack_fully(void); extern s16b inven_carry(object_type *o_ptr, bool final); extern s32b calc_total_weight(void); -- cgit v1.2.3