Hooks
static bool BeforeCvLuaPlayer_lUnitsAux(lua_State* L, int& result);static void AfterCvLuaPlayer_lUnitsAux(lua_State* L, int& result);static int ReplaceCvLuaPlayer_lUnitsAux(int (*original)(lua_State*), lua_State* L);CivRegisterBefore<CivHooks::CvLuaPlayer_lUnitsAux>(host, &BeforeCvLuaPlayer_lUnitsAux);CivRegisterAfter<CivHooks::CvLuaPlayer_lUnitsAux>(host, &AfterCvLuaPlayer_lUnitsAux);CivRegisterReplace<CivHooks::CvLuaPlayer_lUnitsAux>(host, &ReplaceCvLuaPlayer_lUnitsAux);
Code
7860// Aux Method used by lUnits.7861int CvLuaPlayer::lUnitsAux(lua_State* L)7862{7863 CvPlayerAI* pkPlayer = GetInstance(L);7864 CvUnit* pkUnit = NULL;78657866 lua_pushvalue(L, lua_upvalueindex(1));7867 int t = lua_gettop(L);78687869 lua_rawgeti(L, t, 1);7870 int i = -1;7871 if(!lua_isnil(L, -1))7872 {7873 i = lua_tointeger(L, -1);7874 }7875 lua_pop(L, 1);78767877 pkUnit = (i == -1)? pkPlayer->firstUnit(&i) : pkPlayer->nextUnit(&i);78787879 lua_pushinteger(L, i);7880 lua_rawseti(L, t, 1);78817882 if(pkUnit)7883 {7884 CvLuaUnit::Push(L, pkUnit);7885 return 1;7886 }78877888 return 0;7889}