Bazaar developer reference

CvPlayerCulture::DoSwapGreatWorks(YieldTypes)

Defined in
CvCultureClasses.cpp, line 1069
Class
CvPlayerCulture
Hook name
CivHooks::CvPlayerCulture_DoSwapGreatWorks

Hooks

static bool BeforeCvPlayerCulture_DoSwapGreatWorks(CvPlayerCulture* self, YieldTypes eFocusYield);static void AfterCvPlayerCulture_DoSwapGreatWorks(CvPlayerCulture* self, YieldTypes eFocusYield);static void ReplaceCvPlayerCulture_DoSwapGreatWorks(void (*original)(CvPlayerCulture*, YieldTypes), CvPlayerCulture* self, YieldTypes eFocusYield);CivRegisterBefore<CivHooks::CvPlayerCulture_DoSwapGreatWorks>(host, &BeforeCvPlayerCulture_DoSwapGreatWorks);CivRegisterAfter<CivHooks::CvPlayerCulture_DoSwapGreatWorks>(host, &AfterCvPlayerCulture_DoSwapGreatWorks);CivRegisterReplace<CivHooks::CvPlayerCulture_DoSwapGreatWorks>(host, &ReplaceCvPlayerCulture_DoSwapGreatWorks);

Code

1067/// AI routine to decide what Great Work swapping should take place (including placing Great Works up for swap from another player)1068#if defined(MOD_GLOBAL_GREATWORK_YIELDTYPES)1069void CvPlayerCulture::DoSwapGreatWorks(YieldTypes eFocusYield)1070{1071	// CUSTOMLOG("DoSwapGreatWorks focus is %i", ((int) eFocusYield));1072#else1073void CvPlayerCulture::DoSwapGreatWorks()1074{1075#endif1076	GreatWorkClass eWritingClass = (GreatWorkClass)GC.getInfoTypeForString("GREAT_WORK_LITERATURE");1077	GreatWorkClass eArtClass = (GreatWorkClass)GC.getInfoTypeForString("GREAT_WORK_ART");1078	GreatWorkClass eArtifactsClass = (GreatWorkClass)GC.getInfoTypeForString("GREAT_WORK_ARTIFACT");1079	GreatWorkClass eMusicClass = (GreatWorkClass)GC.getInfoTypeForString("GREAT_WORK_MUSIC");10801081	vector<CvGreatWorkInMyEmpire> aGreatWorksWriting;1082	vector<CvGreatWorkInMyEmpire> aGreatWorksArt;1083	vector<CvGreatWorkInMyEmpire> aGreatWorksArtifacts;1084	vector<CvGreatWorkInMyEmpire> aGreatWorksMusic;1085	vector<CvGreatWorkInMyEmpire> aNull;10861087	vector<CvGreatWorkBuildingInMyEmpire> aGreatWorkBuildingsWriting;1088	vector<CvGreatWorkBuildingInMyEmpire> aGreatWorkBuildingsArt;1089	vector<CvGreatWorkBuildingInMyEmpire> aGreatWorkBuildingsMusic;10901091	CvCity* pLoopCity = NULL;1092	int iLoop = 0;10931094	// CUSTOMLOG("Processing Great Works by city -> building -> slot into art(ifact)/writing/music silos");1095	for(pLoopCity = m_pPlayer->firstCity(&iLoop); pLoopCity != NULL; pLoopCity = m_pPlayer->nextCity(&iLoop))1096	{1097		for(int iBuildingClassLoop = 0; iBuildingClassLoop < GC.getNumBuildingClassInfos(); iBuildingClassLoop++)1098		{1099			CvCivilizationInfo& playerCivilizationInfo = m_pPlayer->getCivilizationInfo();1100			BuildingTypes eBuilding = (BuildingTypes)playerCivilizationInfo.getCivilizationBuildings((BuildingClassTypes)iBuildingClassLoop);1101			if (eBuilding != NO_BUILDING)1102			{1103				CvBuildingEntry *pkBuilding = GC.getBuildingInfo(eBuilding);1104				if (pkBuilding)1105				{1106					if (pLoopCity->GetCityBuildings()->GetNumBuilding(eBuilding) > 0)1107					{1108						CvGreatWorkBuildingInMyEmpire building;1109						building.m_eBuilding = eBuilding;1110						building.m_iCityID = pLoopCity->GetID();1111#if defined(MOD_GLOBAL_GREATWORK_YIELDTYPES)1112						building.m_bEndangered = (pLoopCity->getDamage() > (pLoopCity->GetMaxHitPoints() / 2)) || (pLoopCity->IsRazing() && pLoopCity->getPopulation() < 3);1113						building.m_bPuppet = pLoopCity->IsPuppet();1114						building.m_eYieldType = GC.GetGameBuildings()->GetEntry(eBuilding)->GetGreatWorkYieldType();1115#else1116						building.m_bEndangered = (pLoopCity->getDamage() > 0);1117#endif11181119						GreatWorkSlotType eSlotType = pkBuilding->GetGreatWorkSlotType();1120						if (eSlotType == CvTypes::getGREAT_WORK_SLOT_LITERATURE())1121						{1122							aGreatWorkBuildingsWriting.push_back(building);1123						}1124						else if (eSlotType == CvTypes::getGREAT_WORK_SLOT_ART_ARTIFACT())1125						{1126							aGreatWorkBuildingsArt.push_back(building);1127						}1128						else if (eSlotType == CvTypes::getGREAT_WORK_SLOT_MUSIC())1129						{1130							aGreatWorkBuildingsMusic.push_back(building);1131						}11321133						int iNumSlots = pkBuilding->GetGreatWorkCount();1134						for (int iI = 0; iI < iNumSlots; iI++)1135						{1136							int iGreatWorkIndex = pLoopCity->GetCityBuildings()->GetBuildingGreatWork((BuildingClassTypes)iBuildingClassLoop, iI);1137							if (iGreatWorkIndex != -1)1138							{1139								CvGreatWorkInMyEmpire work;1140								work.m_eBuilding = eBuilding;1141								work.m_iCityID = pLoopCity->GetID();1142								work.m_iGreatWorkIndex = iGreatWorkIndex;1143								work.m_iSlot = iI;1144								work.m_ePlayer = GC.getGame().GetGameCulture()->GetGreatWorkCreator(iGreatWorkIndex);1145								work.m_eEra = GC.getGame().GetGameCulture()->m_CurrentGreatWorks[iGreatWorkIndex].m_eEra;11461147								GreatWorkType eGreatWorkType = GC.getGame().GetGameCulture()->GetGreatWorkType(iGreatWorkIndex);1148								GreatWorkClass eGWClass = CultureHelpers::GetGreatWorkClass(eGreatWorkType);1149								if (eGWClass == eWritingClass)1150								{1151									aGreatWorksWriting.push_back(work);1152								}1153								else if (eGWClass == eArtClass)1154								{1155									aGreatWorksArt.push_back(work);1156								}1157								else if (eGWClass == eArtifactsClass)1158								{1159									aGreatWorksArtifacts.push_back(work);1160								}1161								else if (eGWClass == eMusicClass)1162								{1163									aGreatWorksMusic.push_back(work);1164								}1165							}1166						}1167					}1168				}1169			}1170		}1171	}11721173#if defined(MOD_GLOBAL_GREATWORK_YIELDTYPES)1174	MoveWorks (CvTypes::getGREAT_WORK_SLOT_LITERATURE(), aGreatWorkBuildingsWriting, aGreatWorksWriting, aNull, eFocusYield);1175	MoveWorks (CvTypes::getGREAT_WORK_SLOT_ART_ARTIFACT(), aGreatWorkBuildingsArt, aGreatWorksArt, aGreatWorksArtifacts, eFocusYield);1176	MoveWorks (CvTypes::getGREAT_WORK_SLOT_MUSIC(), aGreatWorkBuildingsMusic, aGreatWorksMusic, aNull, eFocusYield);1177#else1178	MoveWorks (CvTypes::getGREAT_WORK_SLOT_LITERATURE(), aGreatWorkBuildingsWriting, aGreatWorksWriting, aNull);1179	MoveWorks (CvTypes::getGREAT_WORK_SLOT_ART_ARTIFACT(), aGreatWorkBuildingsArt, aGreatWorksArt, aGreatWorksArtifacts);1180	MoveWorks (CvTypes::getGREAT_WORK_SLOT_MUSIC(), aGreatWorkBuildingsMusic, aGreatWorksMusic, aNull);1181#endif1182}

Calls

Called by