From 75049d3bbc37c6226e8dc10baab0c6138ffd31d3 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 27 Mar 2017 22:07:18 +0200 Subject: [PATCH] unit.has_attrib should not require the attribute to be registered. --- src/CMakeLists.txt | 4 +--- src/bind_unit.c | 8 +++++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fe4613e7d..ebe914dfe 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -187,12 +187,10 @@ target_link_libraries(eressea ${INIPARSER_LIBRARIES} ) -find_library(C_MATH_LIBRARY m) - add_executable(convert convert.c) target_link_libraries(convert game - ${C_MATH_LIBRARY} + ${LUA_MATH_LIBRARY} ${STORAGE_LIBRARIES} ${CLIBS_LIBRARIES} ${INIPARSER_LIBRARIES} diff --git a/src/bind_unit.c b/src/bind_unit.c index 8247e13d5..b95f43d4a 100644 --- a/src/bind_unit.c +++ b/src/bind_unit.c @@ -787,7 +787,13 @@ static int tolua_unit_get_curse(lua_State *L) { static int tolua_unit_has_attrib(lua_State *L) { unit *self = (unit *)tolua_tousertype(L, 1, 0); const char *name = tolua_tostring(L, 2, 0); - attrib * a = self->attribs ? a_find(self->attribs, at_find(name)) : NULL; + attrib * a = self->attribs; + while (a) { + if (strcmp(a->type->name, name) == 0) { + break; + } + a = a->nexttype; + } lua_pushboolean(L, a != NULL); return 1; }