From 562ba56aab153a7432d0a0171d5fbd6998a1f2c8 Mon Sep 17 00:00:00 2001 From: Allanis Date: Sat, 10 Aug 2013 12:42:23 +0100 Subject: [PATCH] [Change] ai.exists() should return false if pilot is dead. --- src/ai.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ai.c b/src/ai.c index 829249f..90772d1 100644 --- a/src/ai.c +++ b/src/ai.c @@ -613,13 +613,19 @@ static int ai_cargofree(lua_State* L) { } static int ai_exists(lua_State* L) { + Pilot* p; + int i; LLUA_MIN_ARGS(1); if(lua_isnumber(L,1)) { - lua_pushboolean(L, (pilot_get((unsigned int)lua_tonumber(L,1)) != NULL)?1:0); + i = 1; + p = pilot_get((unsigned int)lua_tonumber(L,1)); + if(p == NULL) i = 0; + else if(pilot_isFlag(p, PILOT_DEAD)) i = 0; + lua_pushboolean(L, i); return 1; } - return 0; + LLUA_INVALID_PARAMETER(); } /* Are we at max velocity? */