CvGame::getPlotUnit(CvPlot *, int)
- Defined in
- CvGame.cpp, line 2177
- Class
- CvGame
- Hook name
CivHooks::CvGame_getPlotUnit
Hooks
static bool BeforeCvGame_getPlotUnit(CvGame* self, CvPlot* pPlot, int iIndex, CvUnit*& result);static void AfterCvGame_getPlotUnit(CvGame* self, CvPlot* pPlot, int iIndex, CvUnit*& result);static CvUnit* ReplaceCvGame_getPlotUnit(CvUnit* (*original)(CvGame*, CvPlot*, int), CvGame* self, CvPlot* pPlot, int iIndex);CivRegisterBefore<CivHooks::CvGame_getPlotUnit>(host, &BeforeCvGame_getPlotUnit);CivRegisterAfter<CivHooks::CvGame_getPlotUnit>(host, &AfterCvGame_getPlotUnit);CivRegisterReplace<CivHooks::CvGame_getPlotUnit>(host, &ReplaceCvGame_getPlotUnit);
Code
2177CvUnit* CvGame::getPlotUnit(CvPlot* pPlot, int iIndex)2178{2179 IDInfo* pUnitNode1;2180 IDInfo* pUnitNode2;2181 CvUnit* pLoopUnit1;2182 CvUnit* pLoopUnit2;2183 int iCount;2184 int iPass;2185 PlayerTypes activePlayer = getActivePlayer();2186 TeamTypes activeTeam = getActiveTeam();21872188 if(pPlot != NULL)2189 {2190 iCount = 0;21912192 for(iPass = 0; iPass < 2; iPass++)2193 {2194 pUnitNode1 = pPlot->headUnitNode();21952196 while(pUnitNode1 != NULL)2197 {2198 pLoopUnit1 = ::getUnit(*pUnitNode1);2199 pUnitNode1 = pPlot->nextUnitNode(pUnitNode1);22002201 if(!(pLoopUnit1->isInvisible(activeTeam, true)))2202 {2203 if(!(pLoopUnit1->isCargo()))2204 {2205 if((pLoopUnit1->getOwner() == activePlayer) == (iPass == 0))2206 {2207 if(iCount == iIndex)2208 {2209 return pLoopUnit1;2210 }22112212 iCount++;22132214 if(pLoopUnit1->hasCargo())2215 {2216 pUnitNode2 = pPlot->headUnitNode();22172218 while(pUnitNode2 != NULL)2219 {2220 pLoopUnit2 = ::getUnit(*pUnitNode2);2221 pUnitNode2 = pPlot->nextUnitNode(pUnitNode2);22222223 if(!(pLoopUnit2->isInvisible(activeTeam, true)))2224 {2225 if(pLoopUnit2->getTransportUnit() == pLoopUnit1)2226 {2227 if(iCount == iIndex)2228 {2229 return pLoopUnit2;2230 }22312232 iCount++;2233 }2234 }2235 }2236 }2237 }2238 }2239 }2240 }2241 }2242 }22432244 return NULL;2245}