diff options
author | Robert Vollmert <rvollmert@gmx.net> | 2010-02-05 12:43:13 +0100 |
---|---|---|
committer | Robert Vollmert <rvollmert@gmx.net> | 2010-02-05 13:24:50 +0100 |
commit | a85e4c549ffadc2b64dacdbba428d2af782acee3 (patch) | |
tree | ddd203235e698d13e62ee36265d6343771ca381c /crawl-ref/source/l_moninf.cc | |
parent | f881a22c2315f61f41c9d829a5cc3c6bb4975fff (diff) | |
download | crawl-ref-a85e4c549ffadc2b64dacdbba428d2af782acee3.tar.gz crawl-ref-a85e4c549ffadc2b64dacdbba428d2af782acee3.zip |
Allow lua code to access monster_info description.
This is not really safe since it accesses the underlying monsters*;
it would be preferable to generate the necessary info on construction
of the monster_info instance and not storing the monsters* pointer.
Diffstat (limited to 'crawl-ref/source/l_moninf.cc')
-rw-r--r-- | crawl-ref/source/l_moninf.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/crawl-ref/source/l_moninf.cc b/crawl-ref/source/l_moninf.cc index c2a4f36a01..45b7cf896f 100644 --- a/crawl-ref/source/l_moninf.cc +++ b/crawl-ref/source/l_moninf.cc @@ -46,10 +46,25 @@ LUAFN(moninf_get_damage_desc) return (1); } +// FIXME: This is unsafe, since monster_info::to_string +// acccesses the underlying monsters*. monster_info +// should be changed to collect all info it needs +// on instantiation. +LUAFN(moninf_get_desc) +{ + MONINF(ls, 1, mi); + std::string desc; + int col; + mi->to_string(1, desc, col); + lua_pushstring(ls, desc.c_str()); + return (1); +} + static const struct luaL_reg moninf_lib[] = { MIREG(damage_level), MIREG(damage_desc), + MIREG(desc), { NULL, NULL } }; |