Fixed valid field not properly detecting removed units.

This commit is contained in:
Guillaume Melquiond 2010-11-27 09:09:09 +00:00
parent bba7c154c5
commit 460ce60bc3

View file

@ -837,21 +837,20 @@ static int impl_unit_get(lua_State *L)
{
lua_unit *lu = static_cast<lua_unit *>(lua_touserdata(L, 1));
char const *m = luaL_checkstring(L, 2);
unit const *pu = lu->get();
if (strcmp(m, "valid") == 0)
{
if (!pu) return 0;
if (lu->on_map())
lua_pushstring(L, "map");
else if (lu->on_recall_list())
lua_pushstring(L, "recall");
else if (lu->get())
lua_pushstring(L, "private");
else
return 0;
lua_pushstring(L, "private");
return 1;
}
unit const *pu = lu->get();
if (!pu) return luaL_argerror(L, 1, "unknown unit");
unit const &u = *pu;