Hooks
static bool BeforeCvLuaPlayer_lInitUnit(lua_State* L, int& result);static void AfterCvLuaPlayer_lInitUnit(lua_State* L, int& result);static int ReplaceCvLuaPlayer_lInitUnit(int (*original)(lua_State*), lua_State* L);CivRegisterBefore<CivHooks::CvLuaPlayer_lInitUnit>(host, &BeforeCvLuaPlayer_lInitUnit);CivRegisterAfter<CivHooks::CvLuaPlayer_lInitUnit>(host, &AfterCvLuaPlayer_lInitUnit);CivRegisterReplace<CivHooks::CvLuaPlayer_lInitUnit>(host, &ReplaceCvLuaPlayer_lInitUnit);
Code
1265//CvUnit* initUnit(UnitTypes eUnit, int iX, int iY, UnitAITypes eUnitAI = NO_UNITAI, DirectionTypes eFacingDirection = NO_DIRECTION);1266int CvLuaPlayer::lInitUnit(lua_State* L)1267{1268 CvPlayerAI* pkPlayer = GetInstance(L);1269 const UnitTypes eUnit = (UnitTypes)lua_tointeger(L, 2);1270 const int x = lua_tointeger(L, 3);1271 const int y = lua_tointeger(L, 4);1272 const UnitAITypes eUnitAI = (UnitAITypes)luaL_optint(L, 5, NO_UNITAI);1273 const DirectionTypes eFacingDirection = (DirectionTypes)luaL_optint(L, 6, NO_DIRECTION);12741275 CvUnit* pkUnit = pkPlayer->initUnit(eUnit, x, y, eUnitAI, eFacingDirection);1276 CvLuaUnit::Push(L, pkUnit);1277 return 1;1278}