Hooks
static bool BeforeCvGame_PopulateDigSite(CvGame* self, CvPlot& kPlot, EraTypes eEra, GreatWorkArtifactClass eArtifact);static void AfterCvGame_PopulateDigSite(CvGame* self, CvPlot& kPlot, EraTypes eEra, GreatWorkArtifactClass eArtifact);static void ReplaceCvGame_PopulateDigSite(void (*original)(CvGame*, CvPlot&, EraTypes, GreatWorkArtifactClass), CvGame* self, CvPlot& kPlot, EraTypes eEra, GreatWorkArtifactClass eArtifact);CivRegisterBefore<CivHooks::CvGame_PopulateDigSite>(host, &BeforeCvGame_PopulateDigSite);CivRegisterAfter<CivHooks::CvGame_PopulateDigSite>(host, &AfterCvGame_PopulateDigSite);CivRegisterReplace<CivHooks::CvGame_PopulateDigSite>(host, &ReplaceCvGame_PopulateDigSite);
Code
11558void CvGame::PopulateDigSite(CvPlot& kPlot, EraTypes eEra, GreatWorkArtifactClass eArtifact)11559{11560 CvMap& theMap = GC.getMap();11561 CvArchaeologyData digSite;1156211563 const int iPlotX = kPlot.getX();11564 const int iPlotY = kPlot.getY();1156511566 eEra = eEra > static_cast<EraTypes>(0) ? eEra : static_cast<EraTypes>(0);11567 digSite.m_eArtifactType = eArtifact;11568 digSite.m_eEra = eEra;1156911570 // find nearest city (preferably on same area)11571 CvCity* pNearestCity = theMap.findCity(iPlotX, iPlotY, NO_PLAYER, NO_TEAM, true /* bSameArea */);11572 pNearestCity = pNearestCity ? pNearestCity : theMap.findCity(iPlotX, iPlotY, NO_PLAYER, NO_TEAM, false /* bSameArea */); // expand search if we need to11573 if (pNearestCity)11574 {11575 digSite.m_ePlayer1 = pNearestCity->getOriginalOwner();11576 }11577 else // we can't find a nearby city (likely a late era start)11578 {11579 // look for nearby units11580 CvUnit* pUnit = theMap.findUnit(iPlotX, iPlotY);11581 if (pUnit)11582 {11583 digSite.m_ePlayer1 = pUnit->GetOriginalOwner();11584 }11585 else11586 {11587 // look for the start location if it exists11588 PlayerTypes thisPlayer;11589 if (theMap.findNearestStartPlot(iPlotX, iPlotY, thisPlayer))11590 {11591 digSite.m_ePlayer1 = thisPlayer;11592 }11593 else // just make something up11594 {11595 digSite.m_ePlayer1 = GetRandomMajorPlayer();11596 }11597 }11598 }1159911600 if (eArtifact == CvTypes::getARTIFACT_BATTLE_MELEE() || eArtifact == CvTypes::getARTIFACT_BATTLE_RANGED() || eArtifact == CvTypes::getARTIFACT_RAZED_CITY())11601 {11602 PlayerTypes ePlayer2 = NO_PLAYER;11603 do 11604 {11605 ePlayer2 = GetRandomPlayer();11606 } while (ePlayer2 == digSite.m_ePlayer1);11607 digSite.m_ePlayer2 = ePlayer2;11608 }1160911610 kPlot.AddArchaeologicalRecord(digSite.m_eArtifactType, digSite.m_eEra, digSite.m_ePlayer1, digSite.m_ePlayer2);11611}