diff options
author | Neil Moore <neil@s-z.org> | 2012-06-19 22:51:14 -0400 |
---|---|---|
committer | Raphael Langella <raphael.langella@gmail.com> | 2012-07-04 18:04:09 +0200 |
commit | 87c40161cad6ace4f6c2abbc0a8e9696df75ac30 (patch) | |
tree | f8bdc11bb06fb9b88ad8a1e81face0a83fb12748 /crawl-ref/source/l_moninf.cc | |
parent | 62cb7de5ac324c4438784bf0454c41373cdc1f69 (diff) | |
download | crawl-ref-87c40161cad6ace4f6c2abbc0a8e9696df75ac30.tar.gz crawl-ref-87c40161cad6ace4f6c2abbc0a8e9696df75ac30.zip |
Use mid rather than mindex for constriction.
actor::constricting is now a pointer to a map from mids to durations;
if the actor is not constricting anything, we use a NULL pointer rather
than an empty map to save memory.
Save compatibility: Because constrictees might be loaded after
constrictors (and vice versa), we cannot convert the old constriction
arrays (which use mindex) until all the monsters have been loaded.
Instead, save the constriction data temporarily, and create the maps
at the end of tag_read_level_monsters().
Diffstat (limited to 'crawl-ref/source/l_moninf.cc')
-rw-r--r-- | crawl-ref/source/l_moninf.cc | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/crawl-ref/source/l_moninf.cc b/crawl-ref/source/l_moninf.cc index 1b3d0e79c1..584b7211e1 100644 --- a/crawl-ref/source/l_moninf.cc +++ b/crawl-ref/source/l_moninf.cc @@ -15,6 +15,8 @@ #include "player.h" #include "transform.h" +#include <algorithm> + #define MONINF_METATABLE "monster.info" void lua_push_moninf(lua_State *ls, monster_info *mi) @@ -136,14 +138,7 @@ LUAFN(moninf_get_is_constricted) LUAFN(moninf_get_is_constricting) { MONINF(ls, 1, mi); - bool any = false; - for (int i = 0; i < MAX_CONSTRICT; i++) - if (!mi->constricting_name[i].empty()) - { - any = true; - break; - } - lua_pushboolean(ls, any); + lua_pushboolean(ls, !mi->constricting_name.empty()); return (1); } @@ -155,13 +150,11 @@ LUAFN(moninf_get_is_constricting_you) lua_pushboolean(ls, false); return (1); } - for (int i = 0; i < MAX_CONSTRICT; i++) - if (mi->constricting_name[i] == "you") // yay the interface - { - lua_pushboolean(ls, true); - return (1); - } - lua_pushboolean(ls, false); + + // yay the interface + lua_pushboolean(ls, (std::find(mi->constricting_name.begin(), + mi->constricting_name.end(), "you") + != mi->constricting_name.end())); return (1); } |