Bazaar developer reference

CvMinorCivAI::DoTileImprovementGiftFromMajor(PlayerTypes, int, int)

Defined in
CvMinorCivAI.cpp, line 10156
Class
CvMinorCivAI
Hook name
CivHooks::CvMinorCivAI_DoTileImprovementGiftFromMajor
Lua events
GameEvents.PlayerGifted

Hooks

static bool BeforeCvMinorCivAI_DoTileImprovementGiftFromMajor(CvMinorCivAI* self, PlayerTypes eMajor, int iPlotX, int iPlotY);static void AfterCvMinorCivAI_DoTileImprovementGiftFromMajor(CvMinorCivAI* self, PlayerTypes eMajor, int iPlotX, int iPlotY);static void ReplaceCvMinorCivAI_DoTileImprovementGiftFromMajor(void (*original)(CvMinorCivAI*, PlayerTypes, int, int), CvMinorCivAI* self, PlayerTypes eMajor, int iPlotX, int iPlotY);CivRegisterBefore<CivHooks::CvMinorCivAI_DoTileImprovementGiftFromMajor>(host, &BeforeCvMinorCivAI_DoTileImprovementGiftFromMajor);CivRegisterAfter<CivHooks::CvMinorCivAI_DoTileImprovementGiftFromMajor>(host, &AfterCvMinorCivAI_DoTileImprovementGiftFromMajor);CivRegisterReplace<CivHooks::CvMinorCivAI_DoTileImprovementGiftFromMajor>(host, &ReplaceCvMinorCivAI_DoTileImprovementGiftFromMajor);

Code

10156void CvMinorCivAI::DoTileImprovementGiftFromMajor(PlayerTypes eMajor, int iPlotX, int iPlotY)10157{10158	if(!CanMajorGiftTileImprovementAtPlot(eMajor, iPlotX, iPlotY))10159	{10160		return;10161	}10162	CvPlot* pPlot = GC.getMap().plot(iPlotX, iPlotY);10163	if(pPlot == NULL)10164	{10165		CvAssertMsg(false, "pPlot not expected to be NULL, invalid coordinates. Please send Anton your save file and version.");10166		return;10167	}10168	CvPlayer* pPlayer = &GET_PLAYER(eMajor);10169	if(pPlayer == NULL)10170	{10171		CvAssertMsg(false, "pPlayer not expected to be NULL. Please send Anton your save file and version.");10172		return;10173	}1017410175	ImprovementTypes eImprovement = pPlot->getImprovementTypeNeededToImproveResource(eMajor, /*bTestOwner*/false);10176	if(eImprovement == NO_IMPROVEMENT)10177	{10178		return;10179	}1018010181	pPlot->setImprovementType(eImprovement, eMajor);10182#if defined(MOD_BUGFIX_MINOR)10183	// Clear the pillage state on this plot (eg Minor builds a farm, barbs pillage it,10184	// minor discovers iron on the plot, player pays to build a mine, but the plot is still pillaged!)10185#if defined(MOD_EVENTS_TILE_IMPROVEMENTS)10186	pPlot->SetImprovementPillaged(false, false);10187#else10188	pPlot->SetImprovementPillaged(false);10189#endif10190#endif1019110192	// VFX10193	auto_ptr<ICvPlot1> pDllPlot(new CvDllPlot(pPlot));10194	gDLL->GameplayDoFX(pDllPlot.get());1019510196	const int iCost = GetGiftTileImprovementCost(eMajor);10197	GET_PLAYER(eMajor).GetTreasury()->LogExpenditure(GetPlayer()->GetMinorCivAI()->GetNamesListAsString(0), iCost,5);10198	pPlayer->GetTreasury()->ChangeGold(-iCost);1019910200#if defined(MOD_EVENTS_MINORS_INTERACTION)10201	if (MOD_EVENTS_MINORS_INTERACTION) {10202		GAMEEVENTINVOKE_HOOK(GAMEEVENT_PlayerGifted, eMajor, GetPlayer()->GetID(), -1, -1, iPlotX, iPlotY);10203	}10204#endif10205}

Calls

Called by