re-enable unit spells binding to Lua, remove some TODOs from the code.

This commit is contained in:
Enno Rehling 2015-05-05 08:07:20 -07:00
parent 031826902d
commit 0db74d1c09
2 changed files with 9 additions and 20 deletions

View File

@ -507,14 +507,6 @@ static int tolua_faction_tostring(lua_State * L)
return 1; return 1;
} }
#ifdef TODO /* these usertypes are undefined */
static int tolua_faction_get_spells(lua_State * L)
{
faction *self = (faction *) tolua_tousertype(L, 1, 0);
return tolua_quicklist_push(L, "spellbook", "spellbook_entry", self->spellbook->spells);
}
#endif
void tolua_faction_open(lua_State * L) void tolua_faction_open(lua_State * L)
{ {
/* register user types */ /* register user types */
@ -544,9 +536,6 @@ void tolua_faction_open(lua_State * L)
&tolua_faction_set_info); &tolua_faction_set_info);
tolua_variable(L, TOLUA_CAST "units", tolua_faction_get_units, NULL); tolua_variable(L, TOLUA_CAST "units", tolua_faction_get_units, NULL);
tolua_variable(L, TOLUA_CAST "heroes", tolua_faction_get_heroes, NULL); tolua_variable(L, TOLUA_CAST "heroes", tolua_faction_get_heroes, NULL);
#ifdef TODO
tolua_variable(L, TOLUA_CAST "spells", tolua_faction_get_spells, 0);
#endif
tolua_variable(L, TOLUA_CAST "maxheroes", tolua_faction_get_maxheroes, tolua_variable(L, TOLUA_CAST "maxheroes", tolua_faction_get_maxheroes,
NULL); NULL);
tolua_variable(L, TOLUA_CAST "password", tolua_faction_get_password, tolua_variable(L, TOLUA_CAST "password", tolua_faction_get_password,

View File

@ -758,23 +758,23 @@ static int tolua_unit_get_items(lua_State * L)
return 1; return 1;
} }
#ifdef TODO /* spellbooks */
static int tolua_unit_get_spells(lua_State * L) static int tolua_unit_get_spells(lua_State * L)
{ {
unit *self = (unit *) tolua_tousertype(L, 1, 0); unit *self = (unit *) tolua_tousertype(L, 1, 0);
sc_mage *mage = get_mage(self); sc_mage *mage = self ? get_mage(self) : 0;
quicklist *slist = 0; spellbook *sb = mage ? mage->spellbook : 0;
if (sb) {
if (mage) { quicklist *slist = 0;
quicklist **slist_ptr = get_spelllist(mage, self->faction); quicklist **slist_ptr = &sb->spells;
if (slist_ptr) { if (slist_ptr) {
slist = *slist_ptr; slist = *slist_ptr;
} }
return tolua_quicklist_push(L, "spell_list", "spell", slist);
} }
return 0;
return tolua_quicklist_push(L, "spell_list", "spell", slist);
} }
#ifdef TODO /* spellbooks */
static void unit_removespell(unit * u, spell * sp) static void unit_removespell(unit * u, spell * sp)
{ {
quicklist **isptr; quicklist **isptr;
@ -1034,8 +1034,8 @@ void tolua_unit_open(lua_State * L)
tolua_function(L, TOLUA_CAST "add_spell", &tolua_unit_addspell); tolua_function(L, TOLUA_CAST "add_spell", &tolua_unit_addspell);
#ifdef TODO /* spellbooks */ #ifdef TODO /* spellbooks */
tolua_function(L, TOLUA_CAST "remove_spell", &tolua_unit_removespell); tolua_function(L, TOLUA_CAST "remove_spell", &tolua_unit_removespell);
tolua_variable(L, TOLUA_CAST "spells", &tolua_unit_get_spells, 0);
#endif #endif
tolua_variable(L, TOLUA_CAST "spells", &tolua_unit_get_spells, 0);
tolua_function(L, TOLUA_CAST "cast_spell", &tolua_unit_castspell); tolua_function(L, TOLUA_CAST "cast_spell", &tolua_unit_castspell);
tolua_variable(L, TOLUA_CAST "magic", &tolua_unit_get_magic, tolua_variable(L, TOLUA_CAST "magic", &tolua_unit_get_magic,