Bazaar developer reference

CvDllDatabaseUtility::CacheGameDatabaseData()

Defined in
CvDllDatabaseUtility.cpp, line 118
Class
CvDllDatabaseUtility
Not a hook point
calls into Bazaar

Code

118bool CvDllDatabaseUtility::CacheGameDatabaseData()119{120	//Do not cache everything if we don't need to.121	if(m_bGameDatabaseNeedsCaching == false)122		return true;123124	//The following code depends on a valid initialized database.125	bool bSuccess = true;126127	//TODO: Figure out how to handle cases where Validation has failed.128	/*bSuccess &= */129	ValidateGameDatabase();130	//bSuccess &= PerformDatabasePostProcessing();131132	//HACK Legacy 'FindInfoByType' support.133	//In order to support the legacy code still using the old infos system,134	//all of the id/type pairs must be added to gc.m_infosMap135	//I apologize for this horrendous code, please remove it in the near future.136	GC.infoTypeFromStringReset();137	Database::Results kTables("name");138	if(DB.SelectAt(kTables, "sqlite_master", "type", "table"))139	{140		while(kTables.Step())141		{142			Database::Results kTypes;143			if(DB.SelectAll(kTypes, kTables.GetText(0)))144			{145				bool bFirstStep = true;146				while(kTypes.Step())147				{148					if(bFirstStep)149					{150						if(!kTypes.HasColumn("ID") || !kTypes.HasColumn("Type"))151						{152							break;153						}154155						bFirstStep = false;156					}157158					const int rowid = kTypes.GetInt("ID");159					const char* szType = kTypes.GetText("Type");160					if(szType)161						GC.setInfoTypeFromString(szType, rowid);162				}163			}164		}165	}166167	bSuccess &= LoadGlobalDefines();168	bSuccess &= PrefetchGameData();169	bSuccess &= UpdatePlayableCivilizationCounts();170171	CvTypes::AcquireTypes(DB);172173	bSuccess &= SetGlobalActionInfo();174175	//Clear out database cache and tune for runtime use.176	DB.ClearCountCache();177178	//Log Database Memory statistics179	LogMsg(DB.CalculateMemoryStats());180181	CvAssertMsg(bSuccess, "Failed to load Gameplay Database Data! Not Good!");182183	if(bSuccess)184		m_bGameDatabaseNeedsCaching = false;185		186#if defined(CUSTOM_MODS_H)187	// Load up the CustomModOptions configuration188	gCustomMods.preloadCache();189#endif190191#if defined(CIV_HOST_API)192	CivHostOnDatabaseReady();193#endif194	return bSuccess;195}

Calls