/// Read from XML file bool CvImprovementEntry::CacheResults(Database::Results& kResults, CvDatabaseUtility& kUtility) { if(!CvBaseInfo::CacheResults(kResults, kUtility)) return false; //Basic properties const char* szArtDefineTag = kResults.GetText("ArtDefineTag"); SetArtDefineTag(szArtDefineTag); m_iGoldMaintenance = kResults.GetInt("GoldMaintenance"); m_iCultureBombRadius = kResults.GetInt("CultureBombRadius"); m_iRequiresXAdjacentLand = kResults.GetInt("RequiresXAdjacentLand"); #if defined(MOD_API_EXTENSIONS) m_iRequiresXAdjacentWater = kResults.GetInt("RequiresXAdjacentWater"); #endif #if defined(MOD_GLOBAL_STACKING_RULES) m_iAdditionalUnits = kResults.GetInt("AdditionalUnits"); #endif m_iCultureAdjacentSameType = kResults.GetInt("CultureAdjacentSameType"); m_bHillsMakesValid = kResults.GetBool("HillsMakesValid"); #if defined(MOD_GLOBAL_ALPINE_PASSES) m_bMountainsMakesValid = kResults.GetBool("MountainsMakesValid"); #endif #if defined(MOD_GLOBAL_PASSABLE_FORTS) m_bMakesPassable = kResults.GetBool("MakesPassable"); #endif m_bFreshWaterMakesValid = kResults.GetBool("FreshWaterMakesValid"); m_bRiverSideMakesValid = kResults.GetBool("RiverSideMakesValid"); m_bNoFreshWater = kResults.GetBool("NoFreshWater"); #if defined(MOD_API_EXTENSIONS) if (MOD_API_EXTENSIONS) { m_bAddsFreshWater = kResults.GetBool("AddsFreshWater"); } #endif m_bRequiresFlatlands = kResults.GetBool("RequiresFlatlands"); m_bRequiresFlatlandsOrFreshWater = kResults.GetBool("RequiresFlatlandsOrFreshWater"); m_bRequiresFeature = kResults.GetBool("RequiresFeature"); m_bRequiresImprovement = kResults.GetBool("RequiresImprovement"); m_bRemovesResource = kResults.GetBool("RemovesResource"); m_bPromptWhenComplete = kResults.GetBool("PromptWhenComplete"); m_bWater = kResults.GetBool("Water"); m_bCoastal = kResults.GetBool("Coastal"); m_bDestroyedWhenPillaged = kResults.GetBool("DestroyedWhenPillaged"); m_bDisplacePillager = kResults.GetBool("DisplacePillager"); m_bBuildableOnResources = kResults.GetBool("BuildableOnResources"); m_eImprovementUsageType = m_bBuildableOnResources ? IMPROVEMENTUSAGE_LANDMARK : IMPROVEMENTUSAGE_BASIC; m_bBarbarianCamp = kResults.GetBool("BarbarianCamp"); m_bGoody = kResults.GetBool("Goody"); m_bPermanent = kResults.GetBool("Permanent"); m_iTilesPerGoody = kResults.GetInt("TilesPerGoody"); m_iGoodyUniqueRange = kResults.GetInt("GoodyRange"); m_iFeatureGrowthProbability = kResults.GetInt("FeatureGrowth"); m_iUpgradeTime = kResults.GetInt("UpgradeTime"); m_iRiverSideUpgradeMod = kResults.GetInt("RiverSideUpgradeMod"); m_iCoastalLandUpgradeMod = kResults.GetInt("CoastalLandUpgradeMod"); m_iHillsUpgradeMod = kResults.GetInt("HillsUpgradeMod"); m_iFreshWaterUpgradeMod = kResults.GetInt("FreshWaterUpgradeMod"); m_iDefenseModifier = kResults.GetInt("DefenseModifier"); m_iNearbyEnemyDamage = kResults.GetInt("NearbyEnemyDamage"); m_iPillageGold = kResults.GetInt("PillageGold"); m_bOutsideBorders = kResults.GetBool("OutsideBorders"); m_bInAdjacentFriendly = kResults.GetBool("InAdjacentFriendly"); m_bIgnoreOwnership = kResults.GetBool("IgnoreOwnership"); m_bOnlyCityStateTerritory = kResults.GetBool("OnlyCityStateTerritory"); #if defined(MOD_DIPLOMACY_CITYSTATES) if (MOD_DIPLOMACY_CITYSTATES) { m_bIsEmbassy = kResults.GetBool("IsEmbassy"); } #endif #if defined(MOD_BALANCE_CORE) const char* szObsoleteTech = kResults.GetText("ObsoleteTech"); m_iGetObsoleteTech = (CivilizationTypes)GC.getInfoTypeForString(szObsoleteTech, true); m_bAdjacentLake = kResults.GetBool("Lakeside"); m_bAdjacentCity = kResults.GetBool("Cityside"); m_iGrantsVision = kResults.GetInt("GrantsVisionXTiles"); #endif m_bNoTwoAdjacent = kResults.GetBool("NoTwoAdjacent"); m_bAdjacentLuxury = kResults.GetBool("AdjacentLuxury"); m_bAllowsWalkWater = kResults.GetBool("AllowsWalkWater"); m_bCreatedByGreatPerson = kResults.GetBool("CreatedByGreatPerson"); m_bSpecificCivRequired = kResults.GetBool("SpecificCivRequired"); m_iResourceExtractionMod = kResults.GetInt("ResourceExtractionMod"); m_iLuxuryCopiesSiphonedFromMinor = kResults.GetInt("LuxuryCopiesSiphonedFromMinor"); #if defined(MOD_DIPLOMACY_CITYSTATES) if (MOD_DIPLOMACY_CITYSTATES) { m_iImprovementLeagueVotes = kResults.GetInt("ImprovementLeagueVotes"); } #endif const char* szCivilizationType = kResults.GetText("CivilizationType"); m_eRequiredCivilization = (CivilizationTypes)GC.getInfoTypeForString(szCivilizationType, true); #if defined(MOD_BALANCE_CORE) const char* szImprovementResource = kResults.GetText("ImprovementResource"); m_iImprovementResource = (ResourceTypes)GC.getInfoTypeForString(szImprovementResource, true); m_iImprovementResourceQuantity = kResults.GetInt("ImprovementResourceQuantity"); const char* szTextVal; szTextVal = kResults.GetText("UnitFreePromotion"); if(szTextVal != NULL) { m_iUnitFreePromotionImprovement = GC.getInfoTypeForString(szTextVal, true); } #endif //References const char* szWorldsoundscapeAudioScript = kResults.GetText("WorldSoundscapeAudioScript"); if(szWorldsoundscapeAudioScript != NULL) { m_iWorldSoundscapeScriptId = gDLL->GetAudioTagIndex(szWorldsoundscapeAudioScript, AUDIOTAG_SOUNDSCAPE); } else { m_iWorldSoundscapeScriptId = -1; Remark(1, "Warning: Missing soundscape definition in XML for feature: '%s'", GetType()); } const char* szImprovementPillage = kResults.GetText("ImprovementPillage"); m_iImprovementPillage = GC.getInfoTypeForString(szImprovementPillage, true); const char* szImprovementUpgrade = kResults.GetText("ImprovementUpgrade"); m_iImprovementUpgrade = GC.getInfoTypeForString(szImprovementUpgrade, true); //Arrays const char* szImprovementType = GetType(); const size_t lenImprovementType = strlen(szImprovementType); kUtility.PopulateArrayByExistence(m_pbTerrainMakesValid, "Terrains", "Improvement_ValidTerrains", "TerrainType", "ImprovementType", szImprovementType); kUtility.PopulateArrayByExistence(m_pbFeatureMakesValid, "Features", "Improvement_ValidFeatures", "FeatureType", "ImprovementType", szImprovementType); kUtility.PopulateArrayByExistence(m_pbImprovementMakesValid, "Improvements", "Improvement_ValidImprovements", "PrereqImprovement", "ImprovementType", szImprovementType); #if defined(MOD_API_UNIFIED_YIELDS) kUtility.SetYields(m_piAdjacentSameTypeYield, "Improvement_YieldAdjacentSameType", "ImprovementType", szImprovementType); kUtility.SetYields(m_piAdjacentTwoSameTypeYield, "Improvement_YieldAdjacentTwoSameType", "ImprovementType", szImprovementType); #endif kUtility.SetYields(m_piYieldChange, "Improvement_Yields", "ImprovementType", szImprovementType); kUtility.SetYields(m_piYieldPerEra, "Improvement_YieldPerEra", "ImprovementType", szImprovementType); kUtility.SetYields(m_piAdjacentCityYieldChange, "Improvement_AdjacentCityYields", "ImprovementType", szImprovementType); kUtility.SetYields(m_piAdjacentMountainYieldChange, "Improvement_AdjacentMountainYieldChanges", "ImprovementType", szImprovementType); kUtility.SetYields(m_piCoastalLandYieldChange, "Improvement_CoastalLandYields", "ImprovementType", szImprovementType); kUtility.SetYields(m_piFreshWaterChange, "Improvement_FreshWaterYields", "ImprovementType", szImprovementType); kUtility.SetYields(m_piHillsYieldChange, "Improvement_HillsYields", "ImprovementType", szImprovementType); kUtility.SetYields(m_piRiverSideYieldChange, "Improvement_RiverSideYields", "ImprovementType", szImprovementType); kUtility.SetYields(m_piPrereqNatureYield, "Improvement_PrereqNatureYields", "ImprovementType", szImprovementType); kUtility.SetFlavors(m_piFlavorValue, "Improvement_Flavors", "ImprovementType", szImprovementType); { //Initialize Improvement Resource Types to number of Resources const int iNumResources = kUtility.MaxRows("Resources"); m_paImprovementResource = FNEW(CvImprovementResourceInfo[iNumResources], c_eCiv5GameplayDLL, 0); kUtility.InitializeArray(m_piResourceQuantityRequirements, iNumResources); std::string strResourceTypesKey = "Improvements - ResourceTypes"; Database::Results* pResourceTypes = kUtility.GetResults(strResourceTypesKey); if(pResourceTypes == NULL) { pResourceTypes = kUtility.PrepareResults(strResourceTypesKey, "select Resources.ID, ResourceType, ResourceMakesValid, ResourceTrade, DiscoveryRand from Improvement_ResourceTypes inner join Resources on ResourceType = Resources.Type where ImprovementType = ?"); } std::string strYieldResultsKey = "Improvements - YieldResults"; Database::Results* pYieldResults = kUtility.GetResults(strYieldResultsKey); if(pYieldResults == NULL) { pYieldResults = kUtility.PrepareResults(strYieldResultsKey, "select Yields.ID, Yield from Improvement_ResourceType_Yields inner join Yields on YieldType = Yields.Type where ImprovementType = ? and ResourceType = ?"); } pResourceTypes->Bind(1, szImprovementType, lenImprovementType, false); while(pResourceTypes->Step()) { const int idx = pResourceTypes->GetInt("ID"); CvImprovementResourceInfo& pResourceInfo = m_paImprovementResource[idx]; const char* szResourceType = pResourceTypes->GetText("ResourceType"); pResourceInfo.m_bResourceMakesValid = pResourceTypes->GetBool("ResourceMakesValid"); pResourceInfo.m_bResourceTrade = pResourceTypes->GetBool("ResourceTrade"); pResourceInfo.m_iDiscoverRand = pResourceTypes->GetInt("DiscoveryRand"); m_piResourceQuantityRequirements[idx] = pResourceTypes->GetInt("QuantityRequirement"); //Populate Yields for structure kUtility.InitializeArray(pResourceInfo.m_piYieldChange, "Yields"); pYieldResults->Bind(1, szImprovementType, lenImprovementType, false); pYieldResults->Bind(2, szResourceType, -1, false); while(pYieldResults->Step()) { const int yieldIdx = pYieldResults->GetInt("ID"); const int yield = pYieldResults->GetInt("Yield"); pResourceInfo.m_piYieldChange[yieldIdx] = yield; } pYieldResults->Reset(); } pResourceTypes->Reset(); } const int iNumYields = kUtility.MaxRows("Yields"); #if defined(MOD_BALANCE_CORE) //AdjacentImprovementYieldChanges { const int iNumImprovements = kUtility.MaxRows("Improvements"); CvAssertMsg(iNumImprovements > 0, "Num Improvement Infos <= 0"); kUtility.Initialize2DArray(m_ppiAdjacentImprovementYieldChanges, iNumImprovements, iNumYields); std::string strKey = "Improvements - AdjacentImprovementYieldChanges"; Database::Results* pResults = kUtility.GetResults(strKey); if(pResults == NULL) { pResults = kUtility.PrepareResults(strKey, "select Yields.ID as YieldID, Improvements.ID as ImprovementID, Yield from Improvement_AdjacentImprovementYieldChanges inner join Yields on YieldType = Yields.Type inner join Improvements on OtherImprovementType = Improvements.Type where ImprovementType = ?"); } pResults->Bind(1, szImprovementType, lenImprovementType, false); while(pResults->Step()) { const int yield_idx = pResults->GetInt(0); CvAssert(yield_idx > -1); const int improvement_idx = pResults->GetInt(1); CvAssert(improvement_idx > -1); const int yield = pResults->GetInt(2); m_ppiAdjacentImprovementYieldChanges[improvement_idx][yield_idx] = yield; } pResults->Reset(); } #endif const int iNumTechs = GC.getNumTechInfos(); CvAssertMsg(iNumTechs > 0, "Num Tech Infos <= 0"); //TechYieldChanges { kUtility.Initialize2DArray(m_ppiTechYieldChanges, iNumTechs, iNumYields); std::string strKey = "Improvements - TechYieldChanges"; Database::Results* pResults = kUtility.GetResults(strKey); if(pResults == NULL) { pResults = kUtility.PrepareResults(strKey, "select Yields.ID as YieldID, Technologies.ID as TechID, Yield from Improvement_TechYieldChanges inner join Yields on YieldType = Yields.Type inner join Technologies on TechType = Technologies.Type where ImprovementType = ?"); } pResults->Bind(1, szImprovementType, lenImprovementType, false); while(pResults->Step()) { const int yield_idx = pResults->GetInt(0); CvAssert(yield_idx > -1); const int tech_idx = pResults->GetInt(1); CvAssert(tech_idx > -1); const int yield = pResults->GetInt(2); m_ppiTechYieldChanges[tech_idx][yield_idx] = yield; } } //TechNoFreshWaterYieldChanges { kUtility.Initialize2DArray(m_ppiTechNoFreshWaterYieldChanges, iNumTechs, iNumYields); std::string strKey = "Improvements - TechNoFreshWaterYieldChanges"; Database::Results* pResults = kUtility.GetResults(strKey); if(pResults == NULL) { pResults = kUtility.PrepareResults(strKey, "select Yields.ID as YieldID, Technologies.ID as TechID, Yield from Improvement_TechNoFreshWaterYieldChanges inner join Yields on YieldType = Yields.Type inner join Technologies on TechType = Technologies.Type where ImprovementType = ?"); } pResults->Bind(1, szImprovementType, lenImprovementType, false); while(pResults->Step()) { const int yield_idx = pResults->GetInt(0); CvAssert(yield_idx > -1); const int tech_idx = pResults->GetInt(1); CvAssert(tech_idx > -1); const int yield = pResults->GetInt(2); m_ppiTechNoFreshWaterYieldChanges[tech_idx][yield_idx] = yield; } pResults->Reset(); } //TechFreshWaterYieldChanges { kUtility.Initialize2DArray(m_ppiTechFreshWaterYieldChanges, iNumTechs, iNumYields); std::string strKey = "Improvements - TechFreshWaterYieldChanges"; Database::Results* pResults = kUtility.GetResults(strKey); if(pResults == NULL) { pResults = kUtility.PrepareResults(strKey, "select Yields.ID as YieldID, Technologies.ID as TechID, Yield from Improvement_TechFreshWaterYieldChanges inner join Yields on YieldType = Yields.Type inner join Technologies on TechType = Technologies.Type where ImprovementType = ?"); } pResults->Bind(1, szImprovementType, lenImprovementType, false); while(pResults->Step()) { const int yield_idx = pResults->GetInt(0); CvAssert(yield_idx > -1); const int tech_idx = pResults->GetInt(1); CvAssert(tech_idx > -1); const int yield = pResults->GetInt(2); m_ppiTechFreshWaterYieldChanges[tech_idx][yield_idx] = yield; } pResults->Reset(); } //RouteYieldChanges { const int iNumRoutes = kUtility.MaxRows("Routes"); kUtility.Initialize2DArray(m_ppiRouteYieldChanges, iNumRoutes, iNumYields); std::string strKey = "Improvements - RouteYieldChanges"; Database::Results* pResults = kUtility.GetResults(strKey); if(pResults == NULL) { pResults = kUtility.PrepareResults(strKey, "select Yields.ID as YieldID, Routes.ID as RouteID, Yield from Improvement_RouteYieldChanges inner join Yields on YieldType = Yields.Type inner join Routes on RouteType = Routes.Type where ImprovementType = ?;"); } pResults->Bind(1, szImprovementType, lenImprovementType, false); while(pResults->Step()) { const int yield_idx = pResults->GetInt(0); CvAssert(yield_idx > -1); const int route_idx = pResults->GetInt(1); CvAssert(route_idx > -1); const int yield = pResults->GetInt(2); m_ppiRouteYieldChanges[route_idx][yield_idx] = yield; } pResults->Reset(); } return true; }
//------------------------------------------------------------------------------ bool CvDllDatabaseUtility::PrefetchGameData() { cvStopWatch kTest("PrefetchGameData", "xml-perf.log"); //Because Colors and PlayerColors are used everywhere during load //(by the translator) we load interface infos first. //Interface PrefetchCollection(GC.GetColorInfo(), "Colors"); PrefetchCollection(GC.GetPlayerColorInfo(), "PlayerColors"); PrefetchCollection(GC.getInterfaceModeInfo(), "InterfaceModes"); //AI PrefetchCollection(GC.getAICityStrategyInfo(), "AICityStrategies"); PrefetchCollection(GC.getEconomicAIStrategyInfo(), "AIEconomicStrategies"); PrefetchCollection(GC.getAIGrandStrategyInfo(), "AIGrandStrategies"); PrefetchCollection(GC.getMilitaryAIStrategyInfo(), "AIMilitaryStrategies"); PrefetchCollection(GC.getCitySpecializationInfo(), "CitySpecializations"); PrefetchCollection(GC.getTacticalMoveInfo(), "TacticalMoves"); //BasicInfos //AnimationOperators? //Attitudes? PrefetchCollection(GC.getUnitAIInfo(), "UnitAIInfos"); PrefetchCollection(GC.getUnitCombatClassInfo(), "UnitCombatInfos"); //Buildings PrefetchCollection(GC.getBuildingClassInfo(), "BuildingClasses"); PrefetchCollection(GC.getBuildingInfo(), "Buildings"); //GameInfo PrefetchCollection(GC.getEmphasisInfo(), "EmphasizeInfos"); PrefetchCollection(GC.getEraInfo(), "Eras"); PrefetchCollection(GC.getGameOptionInfo(), "GameOptions"); PrefetchCollection(GC.getGameSpeedInfo(), "GameSpeeds"); PrefetchCollection(GC.getHandicapInfo(), "HandicapInfos"); PrefetchCollection(GC.getHurryInfo(), "HurryInfos"); PrefetchCollection(GC.getMPOptionInfo(), "MultiplayerOptions"); PrefetchCollection(GC.getPlayerOptionInfo(), "PlayerOptions"); PrefetchCollection(GC.getPolicyInfo(), "Policies"); PrefetchCollection(GC.getPolicyBranchInfo(), "PolicyBranchTypes"); PrefetchCollection(GC.getProcessInfo(), "Processes"); PrefetchCollection(GC.getProjectInfo(), "Projects"); PrefetchCollection(GC.getSmallAwardInfo(), "SmallAwards"); PrefetchCollection(GC.getSpecialistInfo(), "Specialists"); PrefetchCollection(GC.getVictoryInfo(), "Victories"); PrefetchCollection(GC.getVoteInfo(), "Votes"); PrefetchCollection(GC.getVoteSourceInfo(), "VoteSources"); PrefetchCollection(GC.getUnitDomainInfo(), "Domains"); //Leaders PrefetchCollection(GC.getLeaderHeadInfo(), "Leaders"); //Misc PrefetchCollection(GC.getRouteInfo(), "Routes"); CvNotificationXMLEntries* pkNotificationEntries = GC.GetNotificationEntries(); if(pkNotificationEntries != NULL) { PrefetchCollection(pkNotificationEntries->GetNotificationEntries(), "Notifications"); } //Technologies PrefetchCollection(GC.getTechInfo(), "Technologies"); //Terrain PrefetchCollection(GC.getFeatureInfo(), "Features"); PrefetchCollection(GC.getImprovementInfo(), "Improvements"); PrefetchCollection(GC.getResourceClassInfo(), "ResourceClasses"); PrefetchCollection(GC.getResourceInfo(), "Resources"); PrefetchCollection(GC.getTerrainInfo(), "Terrains"); PrefetchCollection(GC.getYieldInfo(), "Yields"); //Units PrefetchCollection(GC.getAutomateInfo(), "Automates"); PrefetchCollection(GC.getBuildInfo(), "Builds"); PrefetchCollection(GC.getCommandInfo(), "Commands"); PrefetchCollection(GC.getControlInfo(), "Controls"); PrefetchCollection(GC.getEntityEventInfo(), "EntityEvents"); PrefetchCollection(GC.getMissionInfo(), "Missions"); PrefetchCollection(GC.getMultiUnitFormationInfo(), "MultiUnitFormations"); PrefetchCollection(GC.getSpecialUnitInfo(), "SpecialUnits"); PrefetchCollection(GC.getUnitClassInfo(), "UnitClasses"); PrefetchCollection(GC.getPromotionInfo(), "UnitPromotions"); PrefetchCollection(GC.getUnitInfo(), "Units"); //Civilizations - must be after buildings and units PrefetchCollection(GC.getCivilizationInfo(), "Civilizations"); PrefetchCollection(GC.getMinorCivInfo(), "MinorCivilizations"); PrefetchCollection(GC.getTraitInfo(), "Traits"); PrefetchCollection(GC.getReligionInfo(), "Religions"); PrefetchCollection(GC.getBeliefInfo(), "Beliefs"); //Copy flavors into string array { CvDatabaseUtility kUtility; CvString*& paFlavors = GC.getFlavorTypes(); const int iNumFlavors = kUtility.MaxRows("Flavors"); //GC.getNumFlavorTypes() = iNumFlavors; GC.setNumFlavorTypes(iNumFlavors); paFlavors = FNEW(CvString[iNumFlavors], c_eCiv5GameplayDLL, 0); Database::Results kResults("Type"); if(DB.SelectAll(kResults, "Flavors")) { int i = 0; while(kResults.Step()) { paFlavors[i++] = kResults.GetText(0); } } else { CvAssertMsg(false, DB.ErrorMessage()); } } ValidatePrefetchProcess(); return true; }
/// Read from XML file bool CvImprovementEntry::CacheResults(Database::Results& kResults, CvDatabaseUtility& kUtility) { if(!CvBaseInfo::CacheResults(kResults, kUtility)) return false; //Basic properties const char* szArtDefineTag = kResults.GetText("ArtDefineTag"); SetArtDefineTag(szArtDefineTag); m_iGoldMaintenance = kResults.GetInt("GoldMaintenance"); m_iCultureBombRadius = kResults.GetInt("CultureBombRadius"); m_iCultureAdjacentSameType = kResults.GetInt("CultureAdjacentSameType"); m_bHillsMakesValid = kResults.GetBool("HillsMakesValid"); m_bFreshWaterMakesValid = kResults.GetBool("FreshWaterMakesValid"); m_bRiverSideMakesValid = kResults.GetBool("RiverSideMakesValid"); m_bNoFreshWater = kResults.GetBool("NoFreshWater"); m_bRequiresFlatlands = kResults.GetBool("RequiresFlatlands"); m_bRequiresFlatlandsOrFreshWater = kResults.GetBool("RequiresFlatlandsOrFreshWater"); m_bRequiresFeature = kResults.GetBool("RequiresFeature"); m_bWater = kResults.GetBool("Water"); m_bCoastal = kResults.GetBool("Coastal"); m_bDestroyedWhenPillaged = kResults.GetBool("DestroyedWhenPillaged"); m_bBuildableOnResources = kResults.GetBool("BuildableOnResources"); m_eImprovementUsageType = m_bBuildableOnResources ? IMPROVEMENTUSAGE_LANDMARK : IMPROVEMENTUSAGE_BASIC; m_bBarbarianCamp = kResults.GetBool("BarbarianCamp"); m_bGoody = kResults.GetBool("Goody"); m_bPermanent = kResults.GetBool("Permanent"); m_iTilesPerGoody = kResults.GetInt("TilesPerGoody"); m_iGoodyUniqueRange = kResults.GetInt("GoodyRange"); m_iFeatureGrowthProbability = kResults.GetInt("FeatureGrowth"); m_iUpgradeTime = kResults.GetInt("UpgradeTime"); m_iRiverSideUpgradeMod = kResults.GetInt("RiverSideUpgradeMod"); m_iCoastalLandUpgradeMod = kResults.GetInt("CoastalLandUpgradeMod"); m_iHillsUpgradeMod = kResults.GetInt("HillsUpgradeMod"); m_iFreshWaterUpgradeMod = kResults.GetInt("FreshWaterUpgradeMod"); m_iDefenseModifier = kResults.GetInt("DefenseModifier"); m_iNearbyEnemyDamage = kResults.GetInt("NearbyEnemyDamage"); m_iPillageGold = kResults.GetInt("PillageGold"); m_bOutsideBorders = kResults.GetBool("OutsideBorders"); m_bInAdjacentFriendly = kResults.GetBool("InAdjacentFriendly"); m_bCreatedByGreatPerson = kResults.GetBool("CreatedByGreatPerson"); m_bSpecificCivRequired = kResults.GetBool("SpecificCivRequired"); m_iResourceExtractionMod = kResults.GetInt("ResourceExtractionMod"); const char* szCivilizationType = kResults.GetText("CivilizationType"); m_eRequiredCivilization = (CivilizationTypes)GC.getInfoTypeForString(szCivilizationType, true); //References const char* szWorldsoundscapeAudioScript = kResults.GetText("WorldSoundscapeAudioScript"); if(szWorldsoundscapeAudioScript != NULL) { m_iWorldSoundscapeScriptId = gDLL->GetAudioTagIndex(szWorldsoundscapeAudioScript, AUDIOTAG_SOUNDSCAPE); } else { m_iWorldSoundscapeScriptId = -1; Remark(1, "Warning: Missing soundscape definition in XML for feature: '%s'", GetType()); } const char* szImprovementPillage = kResults.GetText("ImprovementPillage"); m_iImprovementPillage = GC.getInfoTypeForString(szImprovementPillage, true); const char* szImprovementUpgrade = kResults.GetText("ImprovementUpgrade"); m_iImprovementUpgrade = GC.getInfoTypeForString(szImprovementUpgrade, true); //Arrays const char* szImprovementType = GetType(); const size_t lenImprovementType = strlen(szImprovementType); kUtility.PopulateArrayByExistence(m_pbTerrainMakesValid, "Terrains", "Improvement_ValidTerrains", "TerrainType", "ImprovementType", szImprovementType); kUtility.PopulateArrayByExistence(m_pbFeatureMakesValid, "Features", "Improvement_ValidFeatures", "FeatureType", "ImprovementType", szImprovementType); kUtility.SetYields(m_piYieldChange, "Improvement_Yields", "ImprovementType", szImprovementType); kUtility.SetYields(m_piAdjacentCityYieldChange, "Improvement_AdjacentCityYields", "ImprovementType", szImprovementType); kUtility.SetYields(m_piAdjacentMountainYieldChange, "Improvement_AdjacentMountainYieldChanges", "ImprovementType", szImprovementType); kUtility.SetYields(m_piCoastalLandYieldChange, "Improvement_CoastalLandYields", "ImprovementType", szImprovementType); kUtility.SetYields(m_piFreshWaterChange, "Improvement_FreshWaterYields", "ImprovementType", szImprovementType); kUtility.SetYields(m_piHillsYieldChange, "Improvement_HillsYields", "ImprovementType", szImprovementType); kUtility.SetYields(m_piRiverSideYieldChange, "Improvement_RiverSideYields", "ImprovementType", szImprovementType); kUtility.SetYields(m_piPrereqNatureYield, "Improvement_PrereqNatureYields", "ImprovementType", szImprovementType); kUtility.SetFlavors(m_piFlavorValue, "Improvement_Flavors", "ImprovementType", szImprovementType); { //Initialize Improvement Resource Types to number of Resources const int iNumResources = kUtility.MaxRows("Resources"); m_paImprovementResource = FNEW(CvImprovementResourceInfo[iNumResources], c_eCiv5GameplayDLL, 0); kUtility.InitializeArray(m_piResourceQuantityRequirements, iNumResources); std::string strResourceTypesKey = "Improvements - ResourceTypes"; Database::Results* pResourceTypes = kUtility.GetResults(strResourceTypesKey); if(pResourceTypes == NULL) { pResourceTypes = kUtility.PrepareResults(strResourceTypesKey, "select Resources.ID, ResourceType, ResourceMakesValid, ResourceTrade, DiscoveryRand from Improvement_ResourceTypes inner join Resources on ResourceType = Resources.Type where ImprovementType = ?"); } std::string strYieldResultsKey = "Improvements - YieldResults"; Database::Results* pYieldResults = kUtility.GetResults(strYieldResultsKey); if(pYieldResults == NULL) { pYieldResults = kUtility.PrepareResults(strYieldResultsKey, "select Yields.ID, Yield from Improvement_ResourceType_Yields inner join Yields on YieldType = Yields.Type where ImprovementType = ? and ResourceType = ?"); } pResourceTypes->Bind(1, szImprovementType, lenImprovementType, false); while(pResourceTypes->Step()) { const int idx = pResourceTypes->GetInt("ID"); CvImprovementResourceInfo& pResourceInfo = m_paImprovementResource[idx]; const char* szResourceType = pResourceTypes->GetText("ResourceType"); pResourceInfo.m_bResourceMakesValid = pResourceTypes->GetBool("ResourceMakesValid"); pResourceInfo.m_bResourceTrade = pResourceTypes->GetBool("ResourceTrade"); pResourceInfo.m_iDiscoverRand = pResourceTypes->GetInt("DiscoveryRand"); m_piResourceQuantityRequirements[idx] = pResourceTypes->GetInt("QuantityRequirement"); //Populate Yields for structure kUtility.InitializeArray(pResourceInfo.m_piYieldChange, "Yields"); pYieldResults->Bind(1, szImprovementType, lenImprovementType, false); pYieldResults->Bind(2, szResourceType, -1, false); while(pYieldResults->Step()) { const int yieldIdx = pYieldResults->GetInt("ID"); const int yield = pYieldResults->GetInt("Yield"); pResourceInfo.m_piYieldChange[yieldIdx] = yield; } pYieldResults->Reset(); } pResourceTypes->Reset(); } const int iNumYields = kUtility.MaxRows("Yields"); const int iNumTechs = GC.getNumTechInfos(); CvAssertMsg(iNumTechs > 0, "Num Tech Infos <= 0"); //TechYieldChanges { kUtility.Initialize2DArray(m_ppiTechYieldChanges, iNumTechs, iNumYields); std::string strKey = "Improvements - TechYieldChanges"; Database::Results* pResults = kUtility.GetResults(strKey); if(pResults == NULL) { pResults = kUtility.PrepareResults(strKey, "select Yields.ID as YieldID, Technologies.ID as TechID, Yield from Improvement_TechYieldChanges inner join Yields on YieldType = Yields.Type inner join Technologies on TechType = Technologies.Type where ImprovementType = ?"); } pResults->Bind(1, szImprovementType, lenImprovementType, false); while(pResults->Step()) { const int yield_idx = pResults->GetInt(0); CvAssert(yield_idx > -1); const int tech_idx = pResults->GetInt(1); CvAssert(tech_idx > -1); const int yield = pResults->GetInt(2); m_ppiTechYieldChanges[tech_idx][yield_idx] = yield; } } //TechNoFreshWaterYieldChanges { kUtility.Initialize2DArray(m_ppiTechNoFreshWaterYieldChanges, iNumTechs, iNumYields); std::string strKey = "Improvements - TechNoFreshWaterYieldChanges"; Database::Results* pResults = kUtility.GetResults(strKey); if(pResults == NULL) { pResults = kUtility.PrepareResults(strKey, "select Yields.ID as YieldID, Technologies.ID as TechID, Yield from Improvement_TechNoFreshWaterYieldChanges inner join Yields on YieldType = Yields.Type inner join Technologies on TechType = Technologies.Type where ImprovementType = ?"); } pResults->Bind(1, szImprovementType, lenImprovementType, false); while(pResults->Step()) { const int yield_idx = pResults->GetInt(0); CvAssert(yield_idx > -1); const int tech_idx = pResults->GetInt(1); CvAssert(tech_idx > -1); const int yield = pResults->GetInt(2); m_ppiTechNoFreshWaterYieldChanges[tech_idx][yield_idx] = yield; } pResults->Reset(); } //TechFreshWaterYieldChanges { kUtility.Initialize2DArray(m_ppiTechFreshWaterYieldChanges, iNumTechs, iNumYields); std::string strKey = "Improvements - TechFreshWaterYieldChanges"; Database::Results* pResults = kUtility.GetResults(strKey); if(pResults == NULL) { pResults = kUtility.PrepareResults(strKey, "select Yields.ID as YieldID, Technologies.ID as TechID, Yield from Improvement_TechFreshWaterYieldChanges inner join Yields on YieldType = Yields.Type inner join Technologies on TechType = Technologies.Type where ImprovementType = ?"); } pResults->Bind(1, szImprovementType, lenImprovementType, false); while(pResults->Step()) { const int yield_idx = pResults->GetInt(0); CvAssert(yield_idx > -1); const int tech_idx = pResults->GetInt(1); CvAssert(tech_idx > -1); const int yield = pResults->GetInt(2); m_ppiTechFreshWaterYieldChanges[tech_idx][yield_idx] = yield; } pResults->Reset(); } //RouteYieldChanges { const int iNumRoutes = kUtility.MaxRows("Routes"); kUtility.Initialize2DArray(m_ppiRouteYieldChanges, iNumRoutes, iNumYields); std::string strKey = "Improvements - RouteYieldChanges"; Database::Results* pResults = kUtility.GetResults(strKey); if(pResults == NULL) { pResults = kUtility.PrepareResults(strKey, "select Yields.ID as YieldID, Routes.ID as RouteID, Yield from Improvement_RouteYieldChanges inner join Yields on YieldType = Yields.Type inner join Routes on RouteType = Routes.Type where ImprovementType = ?;"); } pResults->Bind(1, szImprovementType, lenImprovementType, false); while(pResults->Step()) { const int yield_idx = pResults->GetInt(0); CvAssert(yield_idx > -1); const int route_idx = pResults->GetInt(1); CvAssert(route_idx > -1); const int yield = pResults->GetInt(2); m_ppiRouteYieldChanges[route_idx][yield_idx] = yield; } pResults->Reset(); } return true; }
// MetaRange //------------------------------------------------------------------------------ IMetaData & MetaRange( uint32_t minVal, uint32_t maxVal ) { return *FNEW( Meta_Range( minVal, maxVal ) ); }
// GetLibraryStatsRecurse //------------------------------------------------------------------------------ void Report::GetLibraryStatsRecurse( Array< LibraryStats * > & libStats, const Node * node, LibraryStats * currentLib ) const { // skip nodes we've already seen if ( node->GetStatFlag( Node::STATS_REPORT_PROCESSED ) ) { return; } node->SetStatFlag( Node::STATS_REPORT_PROCESSED ); Node::Type type = node->GetType(); // object? if ( type == Node::OBJECT_NODE ) { if ( currentLib == nullptr ) { ASSERT( false ); // should not be possible with a correctly formed dep graph return; } currentLib->objectCount++; bool cacheHit = node->GetStatFlag( Node::STATS_CACHE_HIT ); bool cacheMiss = node->GetStatFlag( Node::STATS_CACHE_MISS ); if ( cacheHit || cacheMiss ) { currentLib->objectCount_Cacheable++; if ( cacheHit ) { currentLib->objectCount_CacheHits++; } if ( node->GetStatFlag( Node::STATS_CACHE_STORE ) ) { currentLib->objectCount_CacheStores++; } } if ( cacheHit || cacheMiss || node->GetStatFlag( Node::STATS_BUILT ) ) { currentLib->objectCount_OutOfDate++; currentLib->cpuTimeMS += node->GetProcessingTime(); } return; // Stop recursing at Objects } bool isLibrary = false; switch ( type ) { case Node::DLL_NODE: isLibrary = true; break; case Node::LIBRARY_NODE: isLibrary = true; break; case Node::OBJECT_LIST_NODE: isLibrary = true; break; case Node::CS_NODE: { isLibrary = node->GetName().EndsWithI( ".dll" ); // TODO:C - robustify this (could have an aribtrary extension) break; } default: break; // not a library } if ( isLibrary ) { currentLib = FNEW( LibraryStats ); currentLib->library = node; currentLib->cpuTimeMS = 0; currentLib->objectCount = 0; currentLib->objectCount_OutOfDate = 0; currentLib->objectCount_Cacheable = 0; currentLib->objectCount_CacheHits = 0; currentLib->objectCount_CacheStores = 0; // count time for library/dll itself if ( node->GetStatFlag( Node::STATS_BUILT ) || node->GetStatFlag( Node::STATS_FAILED ) ) { currentLib->cpuTimeMS += node->GetProcessingTime(); } libStats.Append( currentLib ); // recurse into this new lib } // Dependencies GetLibraryStatsRecurse( libStats, node->GetPreBuildDependencies(), currentLib ); GetLibraryStatsRecurse( libStats, node->GetStaticDependencies(), currentLib ); GetLibraryStatsRecurse( libStats, node->GetDynamicDependencies(), currentLib ); }
// MetaOptional //------------------------------------------------------------------------------ IMetaData & MetaOptional() { return *FNEW( Meta_Optional() ); }
// MetaPath //------------------------------------------------------------------------------ IMetaData & MetaPath( bool relative ) { return *FNEW( Meta_Path( relative ) ); }
// MetaFile //------------------------------------------------------------------------------ IMetaData & MetaFile( bool relative ) { return *FNEW( Meta_File( relative ) ); }
//------------------------------------------------------------------------------ void CvDllScriptSystemUtility::PushReplayFromStream(lua_State* L, FDataStream& stream) { CvReplayInfo* pkReplay = FNEW(CvReplayInfo(), c_eMPoolTypeGame, 0); if(pkReplay) { if(!pkReplay->read(stream)) { delete pkReplay; pkReplay = NULL; } } if(pkReplay) { lua_createtable(L, 0, 0); const int t = lua_gettop(L); lua_pushstring(L, pkReplay->getMapScriptName()); lua_setfield(L, t, "MapScriptName"); lua_pushinteger(L, pkReplay->getActivePlayer()); lua_setfield(L, t, "ActivePlayer"); lua_pushinteger(L, pkReplay->getWorldSize()); lua_setfield(L, t, "WorldSize"); lua_pushinteger(L, pkReplay->getClimate()); lua_setfield(L, t, "Climate"); lua_pushinteger(L, pkReplay->getSeaLevel()); lua_setfield(L, t, "SeaLevel"); lua_pushinteger(L, pkReplay->getEra()); lua_setfield(L, t, "Era"); lua_pushinteger(L, pkReplay->getGameSpeed()); lua_setfield(L, t, "GameSpeed"); lua_pushinteger(L, pkReplay->getVictoryType()); lua_setfield(L, t, "VictoryType"); lua_pushinteger(L, pkReplay->getGameType()); lua_setfield(L, t, "GameType"); lua_pushinteger(L, pkReplay->getInitialTurn()); lua_setfield(L, t, "InitialTurn"); lua_pushinteger(L, pkReplay->getFinalTurn()); lua_setfield(L, t, "FinalTurn"); lua_pushinteger(L, pkReplay->getStartYear()); lua_setfield(L, t, "StartYear"); lua_pushstring(L, pkReplay->getFinalDate()); lua_setfield(L, t, "FinalDate"); lua_pushinteger(L, pkReplay->getCalendar()); lua_setfield(L, t, "Calendar"); lua_pushinteger(L, pkReplay->getNormalizedScore()); lua_setfield(L, t, "NormalizedScore"); lua_pushinteger(L, pkReplay->getMapHeight()); lua_setfield(L, t, "MapHeight"); lua_pushinteger(L, pkReplay->getMapWidth()); lua_setfield(L, t, "MapWidth"); const int numPlayers = pkReplay->getNumPlayers(); lua_createtable(L, numPlayers, 0); const unsigned int uiNumDataSets = pkReplay->getNumPlayerDataSets(); for(int iPlayer = 0; iPlayer < numPlayers; iPlayer++) { lua_createtable(L, 0, 0); const int playerIdx = lua_gettop(L); lua_pushinteger(L, pkReplay->getPlayerCivilization(iPlayer)); lua_setfield(L, playerIdx, "Civilization"); lua_pushinteger(L, pkReplay->getPlayerLeader(iPlayer)); lua_setfield(L, playerIdx, "Leader"); lua_pushinteger(L, pkReplay->getPlayerColor(iPlayer)); lua_setfield(L, playerIdx, "PlayerColor"); lua_pushinteger(L, pkReplay->getPlayerDifficulty(iPlayer)); lua_setfield(L, playerIdx, "Difficulty"); lua_pushstring(L , pkReplay->getPlayerLeaderName(iPlayer)); lua_setfield(L, playerIdx, "LeaderName"); lua_pushstring(L, pkReplay->getPlayerCivDescription(iPlayer)); lua_setfield(L, playerIdx, "CivDescription"); lua_pushstring(L, pkReplay->getPlayerShortCivDescription(iPlayer)); lua_setfield(L, playerIdx, "CivShortDescription"); lua_pushstring(L, pkReplay->getPlayerCivAdjective(iPlayer)); lua_setfield(L, playerIdx, "CivAdjective"); lua_createtable(L, 0, 0); int iFinalTurn = pkReplay->getFinalTurn(); for(int iTurn = pkReplay->getInitialTurn(); iTurn <= iFinalTurn; ++iTurn) { lua_createtable(L, 0, 0); for(unsigned int uiDataSet = 0; uiDataSet < uiNumDataSets; ++uiDataSet) { int iValue = 0; if(pkReplay->getPlayerDataSetValue(iPlayer, uiDataSet, iTurn, iValue)) { lua_pushinteger(L, iValue); lua_setfield(L, -2, pkReplay->getPlayerDataSetName(uiDataSet)); } } lua_rawseti(L, -2, iTurn); } lua_setfield(L, playerIdx, "Scores"); lua_rawseti(L, -2, iPlayer + 1); //Adjust iPlayer to be 1-based instead of 0-based. } lua_setfield(L, t, "PlayerInfo"); const int numReplayMessages = pkReplay->getNumReplayMessages(); lua_createtable(L, numReplayMessages, 0); for(int i = 0; i < numReplayMessages; i++) { const CvReplayMessage* pkMessage = pkReplay->getReplayMessage(i); lua_createtable(L, 0, 0); lua_pushinteger(L, pkMessage->getTurn()); lua_setfield(L, -2, "Turn"); lua_pushinteger(L, pkMessage->getType()); lua_setfield(L, -2, "Type"); int iPlayer = pkMessage->getPlayer(); lua_pushinteger(L, (iPlayer > -1)? iPlayer + 1 : iPlayer); //Adjust iPlayer to match the 1-based index scheme. lua_setfield(L, -2, "Player"); lua_pushstring(L, pkMessage->getText()); lua_setfield(L, -2, "Text"); const int numPlots = pkMessage->getNumPlots(); lua_createtable(L, numPlots, 0); for(int iPlot = 0; iPlot < numPlots; ++iPlot) { int iPlotX = 0; int iPlotY = 0; pkMessage->getPlot(iPlot, iPlotX, iPlotY); lua_createtable(L, 0, 2); lua_pushinteger(L, iPlotX); lua_setfield(L, -2, "X"); lua_pushinteger(L, iPlotY); lua_setfield(L, -2, "Y"); lua_rawseti(L, -2, iPlot + 1); } lua_setfield(L, -2, "Plots"); lua_rawseti(L, -2, i); } lua_setfield(L, t, "Messages"); const int uiHeight = pkReplay->getMapHeight(); const int uiWidth = pkReplay->getMapWidth(); lua_createtable(L, uiHeight * uiWidth, 0); int idx = 1; for(int uiY = 0; uiY < uiHeight; ++uiY) { for(int uiX = 0; uiX < uiWidth; ++uiX) { lua_createtable(L, 0, 0); for(int i = pkReplay->getInitialTurn(); i <= pkReplay->getFinalTurn(); ++i) { CvReplayInfo::PlotState plotState; if(pkReplay->getPlotState(uiX, uiY, i, plotState)) { lua_createtable(L, 6, 0); lua_pushinteger(L, plotState.m_ePlotType); lua_setfield(L, -2, "PlotType"); lua_pushinteger(L, plotState.m_eTerrain); lua_setfield(L, -2, "TerrainType"); lua_pushinteger(L, plotState.m_eFeature); lua_setfield(L, -2, "FeatureType"); lua_pushinteger(L, plotState.m_bNEOfRiver); lua_setfield(L, -2, "NEOfRiver"); lua_pushinteger(L, plotState.m_bWOfRiver); lua_setfield(L, -2, "WOfRiver"); lua_pushinteger(L, plotState.m_bNWOfRiver); lua_setfield(L, -2, "NWOfRiver"); lua_rawseti(L, -2, i); } } lua_rawseti(L, -2, idx++); } } lua_setfield(L, t, "Plots"); delete pkReplay; } }
// Create //------------------------------------------------------------------------------ /*static*/ void Function::Create() { FNEW( FunctionAlias ); FNEW( FunctionCompiler ); FNEW( FunctionCopy ); FNEW( FunctionCopyDir ); FNEW( FunctionCSAssembly ); FNEW( FunctionDLL ); FNEW( FunctionExec ); FNEW( FunctionExecutable ); FNEW( FunctionForEach ); FNEW( FunctionLibrary ); FNEW( FunctionPrint ); FNEW( FunctionRemoveDir ); FNEW( FunctionSettings ); FNEW( FunctionSLN ); FNEW( FunctionTest ); FNEW( FunctionUnity ); FNEW( FunctionUsing ); FNEW( FunctionVCXProject ); FNEW( FunctionObjectList ); FNEW( FunctionXCodeProject ); }
//------------------------------------------------------------------------------ bool CvDllDatabaseUtility::PrefetchGameData() { cvStopWatch kTest("PrefetchGameData", "xml-perf.log"); //Because Colors and PlayerColors are used everywhere during load //(by the translator) we load interface infos first. //Interface PrefetchCollection(GC.GetColorInfo(), "Colors"); PrefetchCollection(GC.GetPlayerColorInfo(), "PlayerColors"); PrefetchCollection(GC.getInterfaceModeInfo(), "InterfaceModes"); //AI PrefetchCollection(GC.getAICityStrategyInfo(), "AICityStrategies"); PrefetchCollection(GC.getEconomicAIStrategyInfo(), "AIEconomicStrategies"); PrefetchCollection(GC.getAIGrandStrategyInfo(), "AIGrandStrategies"); PrefetchCollection(GC.getMilitaryAIStrategyInfo(), "AIMilitaryStrategies"); PrefetchCollection(GC.getCitySpecializationInfo(), "CitySpecializations"); PrefetchCollection(GC.getTacticalMoveInfo(), "TacticalMoves"); //BasicInfos //AnimationOperators? //Attitudes? PrefetchCollection(GC.getUnitAIInfo(), "UnitAIInfos"); PrefetchCollection(GC.getUnitCombatClassInfo(), "UnitCombatInfos"); //Buildings PrefetchCollection(GC.getBuildingClassInfo(), "BuildingClasses"); PrefetchCollection(GC.getBuildingInfo(), "Buildings"); //GameInfo PrefetchCollection(GC.getEmphasisInfo(), "EmphasizeInfos"); PrefetchCollection(GC.getEraInfo(), "Eras"); PrefetchCollection(GC.getGameOptionInfo(), "GameOptions"); PrefetchCollection(GC.getGameSpeedInfo(), "GameSpeeds"); PrefetchCollection(GC.getHandicapInfo(), "HandicapInfos"); PrefetchCollection(GC.getHurryInfo(), "HurryInfos"); PrefetchCollection(GC.getMPOptionInfo(), "MultiplayerOptions"); PrefetchCollection(GC.getPlayerOptionInfo(), "PlayerOptions"); PrefetchCollection(GC.getPolicyInfo(), "Policies"); PrefetchCollection(GC.getPolicyBranchInfo(), "PolicyBranchTypes"); PrefetchCollection(GC.getProcessInfo(), "Processes"); PrefetchCollection(GC.getProjectInfo(), "Projects"); PrefetchCollection(GC.getSmallAwardInfo(), "SmallAwards"); PrefetchCollection(GC.getSpecialistInfo(), "Specialists"); PrefetchCollection(GC.getVictoryInfo(), "Victories"); PrefetchCollection(GC.getVoteInfo(), "Votes"); PrefetchCollection(GC.getVoteSourceInfo(), "VoteSources"); #if defined(MOD_BALANCE_CORE) PrefetchCollection(GC.getEventInfo(), "Events"); PrefetchCollection(GC.getEventChoiceInfo(), "EventChoices"); PrefetchCollection(GC.getCityEventInfo(), "CityEvents"); PrefetchCollection(GC.getCityEventChoiceInfo(), "CityEventChoices"); #endif PrefetchCollection(GC.getUnitDomainInfo(), "Domains"); #if defined(MOD_EVENTS_DIPLO_MODIFIERS) PrefetchCollection(GC.getDiploModifierInfo(), "DiploModifiers"); #endif //Leaders PrefetchCollection(GC.getLeaderHeadInfo(), "Leaders"); //Misc PrefetchCollection(GC.getRouteInfo(), "Routes"); CvNotificationXMLEntries* pkNotificationEntries = GC.GetNotificationEntries(); if(pkNotificationEntries != NULL) { PrefetchCollection(pkNotificationEntries->GetNotificationEntries(), "Notifications"); } //Technologies PrefetchCollection(GC.getTechInfo(), "Technologies"); //Terrain PrefetchCollection(GC.getFeatureInfo(), "Features"); PrefetchCollection(GC.getImprovementInfo(), "Improvements"); PrefetchCollection(GC.getResourceClassInfo(), "ResourceClasses"); PrefetchCollection(GC.getResourceInfo(), "Resources"); #if defined(MOD_API_PLOT_YIELDS) if (MOD_API_PLOT_YIELDS) { PrefetchCollection(GC.getPlotInfo(), "Plots"); } #endif #if defined(MOD_API_UNIFIED_YIELDS) if (MOD_API_UNIFIED_YIELDS) { PrefetchCollection(GC.getGreatPersonInfo(), "GreatPersons"); } #endif PrefetchCollection(GC.getTerrainInfo(), "Terrains"); PrefetchCollection(GC.getYieldInfo(), "Yields"); //Units PrefetchCollection(GC.getAutomateInfo(), "Automates"); PrefetchCollection(GC.getBuildInfo(), "Builds"); PrefetchCollection(GC.getCommandInfo(), "Commands"); PrefetchCollection(GC.getControlInfo(), "Controls"); PrefetchCollection(GC.getEntityEventInfo(), "EntityEvents"); PrefetchCollection(GC.getMissionInfo(), "Missions"); PrefetchCollection(GC.getMultiUnitFormationInfo(), "MultiUnitFormations"); PrefetchCollection(GC.getSpecialUnitInfo(), "SpecialUnits"); PrefetchCollection(GC.getUnitClassInfo(), "UnitClasses"); PrefetchCollection(GC.getPromotionInfo(), "UnitPromotions"); PrefetchCollection(GC.getUnitInfo(), "Units"); //Civilizations - must be after buildings and units PrefetchCollection(GC.getCivilizationInfo(), "Civilizations"); PrefetchCollection(GC.getMinorCivInfo(), "MinorCivilizations"); PrefetchCollection(GC.getTraitInfo(), "Traits"); PrefetchCollection(GC.getReligionInfo(), "Religions"); PrefetchCollection(GC.getBeliefInfo(), "Beliefs"); PrefetchCollection(GC.getLeagueSpecialSessionInfo(), "LeagueSpecialSessions"); PrefetchCollection(GC.getLeagueNameInfo(), "LeagueNames"); PrefetchCollection(GC.getLeagueProjectInfo(), "LeagueProjects"); PrefetchCollection(GC.getLeagueProjectRewardInfo(), "LeagueProjectRewards"); PrefetchCollection(GC.getResolutionInfo(), "Resolutions"); #if defined(MOD_API_ACHIEVEMENTS) || defined(ACHIEVEMENT_HACKS) PrefetchCollection(GC.getAchievementInfo(), "Achievements"); #endif #if defined(MOD_BALANCE_CORE) // Must be after buildings because this calls from Buildings PrefetchCollection(GC.getCorporationInfo(), "Corporations"); PrefetchCollection(GC.getContractInfo(), "Contracts"); #endif //Copy flavors into string array { CvDatabaseUtility kUtility; CvString*& paFlavors = GC.getFlavorTypes(); const int iNumFlavors = kUtility.MaxRows("Flavors"); //GC.getNumFlavorTypes() = iNumFlavors; GC.setNumFlavorTypes(iNumFlavors); paFlavors = FNEW(CvString[iNumFlavors], c_eCiv5GameplayDLL, 0); Database::Results kResults; if(DB.SelectWhere(kResults, "Flavors", "ID > -1")) { while(kResults.Step()) { const int iFlavor = kResults.GetInt("ID"); CvAssert(iFlavor >= 0 && iFlavor < iNumFlavors); if(iFlavor >= 0 && iFlavor < iNumFlavors) { paFlavors[iFlavor] = kResults.GetText("Type"); } } } else { CvAssertMsg(false, DB.ErrorMessage()); } } ValidatePrefetchProcess(); return true; }
// Custom MetaData //------------------------------------------------------------------------------ IMetaData & MetaName( const char * name ) { return *FNEW( Meta_Name( name ) ); }