CvLuaPlayer::lGetPlayerVisiblePlot(lua_State *)
- Defined in
- Lua/CvLuaPlayer.cpp, line 9629
- Class
- CvLuaPlayer
- Hook name
CivHooks::CvLuaPlayer_lGetPlayerVisiblePlot
Hooks
static bool BeforeCvLuaPlayer_lGetPlayerVisiblePlot(lua_State* L, int& result);static void AfterCvLuaPlayer_lGetPlayerVisiblePlot(lua_State* L, int& result);static int ReplaceCvLuaPlayer_lGetPlayerVisiblePlot(int (*original)(lua_State*), lua_State* L);CivRegisterBefore<CivHooks::CvLuaPlayer_lGetPlayerVisiblePlot>(host, &BeforeCvLuaPlayer_lGetPlayerVisiblePlot);CivRegisterAfter<CivHooks::CvLuaPlayer_lGetPlayerVisiblePlot>(host, &AfterCvLuaPlayer_lGetPlayerVisiblePlot);CivRegisterReplace<CivHooks::CvLuaPlayer_lGetPlayerVisiblePlot>(host, &ReplaceCvLuaPlayer_lGetPlayerVisiblePlot);
Code
9629int CvLuaPlayer::lGetPlayerVisiblePlot(lua_State* L)9630{9631 CvPlayerAI* pkPlayer = GetInstance(L);9632 CvPlayerAI* pkPlayer2 = CvLuaPlayer::GetInstance(L, 2);96339634 const CvPlotsVector& aiPlots = pkPlayer->GetPlots();96359636 // go through all the plots the player has under their control9637 for(uint uiPlotIndex = 0; uiPlotIndex < aiPlots.size(); uiPlotIndex++)9638 {9639 // when we encounter the first plot that is invalid, the rest of the list will be invalid9640 if(aiPlots[uiPlotIndex] == -1)9641 {9642 break;9643 }96449645 CvPlot* pPlot = GC.getMap().plotByIndex(aiPlots[uiPlotIndex]);9646 if(!pPlot)9647 {9648 continue;9649 }96509651 if(pPlot->isRevealed(pkPlayer2->getTeam()))9652 {9653 CvLuaPlot::Push(L, pPlot);9654 return 1;9655 }9656 }96579658 lua_pushnil(L);9659 return 1;9660}
Calls
BaseVector::operator[]BaseVector::size- CvGlobals::getMap()
CvLuaScopedInstance::GetInstanceCvLuaScopedInstance::Push- CvMap::plotByIndex(int) const
- CvPlayer::GetPlots()
- CvPlayer::getTeam() const
- CvPlot::isRevealed(TeamTypes) const
lua_pushnil