Bazaar developer reference

CvLuaPlayer::lCanGetGoody(lua_State *)

Defined in
Lua/CvLuaPlayer.cpp, line 1657
Class
CvLuaPlayer
Hook name
CivHooks::CvLuaPlayer_lCanGetGoody

Hooks

static bool BeforeCvLuaPlayer_lCanGetGoody(lua_State* L, int& result);static void AfterCvLuaPlayer_lCanGetGoody(lua_State* L, int& result);static int ReplaceCvLuaPlayer_lCanGetGoody(int (*original)(lua_State*), lua_State* L);CivRegisterBefore<CivHooks::CvLuaPlayer_lCanGetGoody>(host, &BeforeCvLuaPlayer_lCanGetGoody);CivRegisterAfter<CivHooks::CvLuaPlayer_lCanGetGoody>(host, &AfterCvLuaPlayer_lCanGetGoody);CivRegisterReplace<CivHooks::CvLuaPlayer_lCanGetGoody>(host, &ReplaceCvLuaPlayer_lCanGetGoody);

Code

1656// This function checks the handicap as well as CanReceiveGoody to test validity1657int CvLuaPlayer::lCanGetGoody(lua_State* L)1658{1659	CvPlayerAI* pkPlayer = GetInstance(L);1660	CvPlot* pPlot = CvLuaPlot::GetInstance(L, 2);1661	GoodyTypes eGoody = (GoodyTypes)lua_tointeger(L, 3);1662	CvUnit* pUnit = CvLuaUnit::GetInstance(L, 4);16631664	bool bResult = false;1665	// Need to have Goodies in the Handicap file to pick from1666	if(pkPlayer->getHandicapInfo().getNumGoodies() > 0)1667	{1668		for(int iGoodyLoop = 0; iGoodyLoop < pkPlayer->getHandicapInfo().getNumGoodies(); iGoodyLoop++)1669		{1670			GoodyTypes eThisGoody = (GoodyTypes) pkPlayer->getHandicapInfo().getGoodies(iGoodyLoop);1671			if(eGoody == eThisGoody && pkPlayer->canReceiveGoody(pPlot, eThisGoody, pUnit))1672			{1673				bResult = true;1674				break;1675			}1676		}1677	}16781679	lua_pushboolean(L, bResult);1680	return 1;1681}

Calls

Called by