Hooks
static bool BeforeCvDllDatabaseUtility_PrefetchGameData(CvDllDatabaseUtility* self, bool& result);static void AfterCvDllDatabaseUtility_PrefetchGameData(CvDllDatabaseUtility* self, bool& result);static bool ReplaceCvDllDatabaseUtility_PrefetchGameData(bool (*original)(CvDllDatabaseUtility*), CvDllDatabaseUtility* self);// CivHooks.h gives this hook point no types, so nothing checks these hooks' parameters.host->RegisterHook(host->pluginIndex, CivHooks::CvDllDatabaseUtility_PrefetchGameData::ID, CIV_HOOK_BEFORE, (void*)&BeforeCvDllDatabaseUtility_PrefetchGameData);host->RegisterHook(host->pluginIndex, CivHooks::CvDllDatabaseUtility_PrefetchGameData::ID, CIV_HOOK_AFTER, (void*)&AfterCvDllDatabaseUtility_PrefetchGameData);host->RegisterHook(host->pluginIndex, CivHooks::CvDllDatabaseUtility_PrefetchGameData::ID, CIV_HOOK_REPLACE, (void*)&ReplaceCvDllDatabaseUtility_PrefetchGameData);
Code
296bool CvDllDatabaseUtility::PrefetchGameData()297{298 cvStopWatch kTest("PrefetchGameData", "xml-perf.log");299300 //Because Colors and PlayerColors are used everywhere during load301 //(by the translator) we load interface infos first.302 //Interface303 PrefetchCollection(GC.GetColorInfo(), "Colors");304 PrefetchCollection(GC.GetPlayerColorInfo(), "PlayerColors");305 PrefetchCollection(GC.getInterfaceModeInfo(), "InterfaceModes");306307 //AI308 PrefetchCollection(GC.getAICityStrategyInfo(), "AICityStrategies");309 PrefetchCollection(GC.getEconomicAIStrategyInfo(), "AIEconomicStrategies");310 PrefetchCollection(GC.getAIGrandStrategyInfo(), "AIGrandStrategies");311 PrefetchCollection(GC.getMilitaryAIStrategyInfo(), "AIMilitaryStrategies");312 PrefetchCollection(GC.getCitySpecializationInfo(), "CitySpecializations");313 PrefetchCollection(GC.getTacticalMoveInfo(), "TacticalMoves");314315 //BasicInfos316 //AnimationOperators?317 //Attitudes?318 PrefetchCollection(GC.getUnitAIInfo(), "UnitAIInfos");319 PrefetchCollection(GC.getUnitCombatClassInfo(), "UnitCombatInfos");320321 //Buildings322 PrefetchCollection(GC.getBuildingClassInfo(), "BuildingClasses");323 PrefetchCollection(GC.getBuildingInfo(), "Buildings");324325 //GameInfo326 PrefetchCollection(GC.getEmphasisInfo(), "EmphasizeInfos");327 PrefetchCollection(GC.getEraInfo(), "Eras");328 PrefetchCollection(GC.getGameOptionInfo(), "GameOptions");329 PrefetchCollection(GC.getGameSpeedInfo(), "GameSpeeds");330 PrefetchCollection(GC.getHandicapInfo(), "HandicapInfos");331 PrefetchCollection(GC.getHurryInfo(), "HurryInfos");332 PrefetchCollection(GC.getMPOptionInfo(), "MultiplayerOptions");333 PrefetchCollection(GC.getPlayerOptionInfo(), "PlayerOptions");334 PrefetchCollection(GC.getPolicyInfo(), "Policies");335 PrefetchCollection(GC.getPolicyBranchInfo(), "PolicyBranchTypes");336 PrefetchCollection(GC.getProcessInfo(), "Processes");337 PrefetchCollection(GC.getProjectInfo(), "Projects");338 PrefetchCollection(GC.getSmallAwardInfo(), "SmallAwards");339 PrefetchCollection(GC.getSpecialistInfo(), "Specialists");340 PrefetchCollection(GC.getVictoryInfo(), "Victories");341 PrefetchCollection(GC.getVoteInfo(), "Votes");342 PrefetchCollection(GC.getVoteSourceInfo(), "VoteSources");343 PrefetchCollection(GC.getUnitDomainInfo(), "Domains");344345#if defined(MOD_EVENTS_DIPLO_MODIFIERS)346 PrefetchCollection(GC.getDiploModifierInfo(), "DiploModifiers");347#endif348349 //Leaders350 PrefetchCollection(GC.getLeaderHeadInfo(), "Leaders");351352 //Misc353 PrefetchCollection(GC.getRouteInfo(), "Routes");354355 CvNotificationXMLEntries* pkNotificationEntries = GC.GetNotificationEntries();356 if(pkNotificationEntries != NULL)357 {358 PrefetchCollection(pkNotificationEntries->GetNotificationEntries(), "Notifications");359 }360361 //Technologies362 PrefetchCollection(GC.getTechInfo(), "Technologies");363364 //Terrain365 PrefetchCollection(GC.getFeatureInfo(), "Features");366 PrefetchCollection(GC.getImprovementInfo(), "Improvements");367 PrefetchCollection(GC.getResourceClassInfo(), "ResourceClasses");368 PrefetchCollection(GC.getResourceInfo(), "Resources");369#if defined(MOD_API_PLOT_YIELDS)370 if (MOD_API_PLOT_YIELDS) {371 PrefetchCollection(GC.getPlotInfo(), "Plots");372 }373#endif374#if defined(MOD_API_UNIFIED_YIELDS)375 if (MOD_API_UNIFIED_YIELDS) {376 PrefetchCollection(GC.getGreatPersonInfo(), "GreatPersons");377 }378#endif379 PrefetchCollection(GC.getTerrainInfo(), "Terrains");380 PrefetchCollection(GC.getYieldInfo(), "Yields");381382 //Units383 PrefetchCollection(GC.getAutomateInfo(), "Automates");384 PrefetchCollection(GC.getBuildInfo(), "Builds");385 PrefetchCollection(GC.getCommandInfo(), "Commands");386 PrefetchCollection(GC.getControlInfo(), "Controls");387 PrefetchCollection(GC.getEntityEventInfo(), "EntityEvents");388 PrefetchCollection(GC.getMissionInfo(), "Missions");389 PrefetchCollection(GC.getMultiUnitFormationInfo(), "MultiUnitFormations");390 PrefetchCollection(GC.getSpecialUnitInfo(), "SpecialUnits");391 PrefetchCollection(GC.getUnitClassInfo(), "UnitClasses");392 PrefetchCollection(GC.getPromotionInfo(), "UnitPromotions");393 PrefetchCollection(GC.getUnitInfo(), "Units");394395 //Civilizations - must be after buildings and units396 PrefetchCollection(GC.getCivilizationInfo(), "Civilizations");397 PrefetchCollection(GC.getMinorCivInfo(), "MinorCivilizations");398#if defined(MOD_EVENTS_QUESTS)399 if (MOD_EVENTS_QUESTS) {400 PrefetchCollection(GC.getQuestInfo(), "Quests");401 }402#endif403 PrefetchCollection(GC.getTraitInfo(), "Traits");404 PrefetchCollection(GC.getReligionInfo(), "Religions");405 PrefetchCollection(GC.getBeliefInfo(), "Beliefs");406 PrefetchCollection(GC.getLeagueSpecialSessionInfo(), "LeagueSpecialSessions");407 PrefetchCollection(GC.getLeagueNameInfo(), "LeagueNames");408 PrefetchCollection(GC.getLeagueProjectInfo(), "LeagueProjects");409 PrefetchCollection(GC.getLeagueProjectRewardInfo(), "LeagueProjectRewards");410 PrefetchCollection(GC.getResolutionInfo(), "Resolutions");411412#if defined(MOD_API_ACHIEVEMENTS) || defined(ACHIEVEMENT_HACKS)413 PrefetchCollection(GC.getAchievementInfo(), "Achievements");414#endif415416 //Copy flavors into string array417 {418 CvDatabaseUtility kUtility;419 CvString*& paFlavors = GC.getFlavorTypes();420 const int iNumFlavors = kUtility.MaxRows("Flavors");421 //GC.getNumFlavorTypes() = iNumFlavors;422 GC.setNumFlavorTypes(iNumFlavors);423 paFlavors = FNEW(CvString[iNumFlavors], c_eCiv5GameplayDLL, 0);424425 Database::Results kResults;426 if(DB.SelectWhere(kResults, "Flavors", "ID > -1"))427 {428 while(kResults.Step())429 {430 const int iFlavor = kResults.GetInt("ID");431 CvAssert(iFlavor >= 0 && iFlavor < iNumFlavors);432 if(iFlavor >= 0 && iFlavor < iNumFlavors)433 {434 paFlavors[iFlavor] = kResults.GetText("Type");435436 }437 }438 }439 else440 {441 CvAssertMsg(false, DB.ErrorMessage());442 }443 }444445 ValidatePrefetchProcess();446447 return true;448}