CustomMods::prefetchCache()
- Defined in
- CustomMods.cpp, line 178
- Class
- CustomMods
- Hook name
CivHooks::CustomMods_prefetchCache
Hooks
static bool BeforeCustomMods_prefetchCache(CustomMods* self);static void AfterCustomMods_prefetchCache(CustomMods* self);static void ReplaceCustomMods_prefetchCache(void (*original)(CustomMods*), CustomMods* self);CivRegisterBefore<CivHooks::CustomMods_prefetchCache>(host, &BeforeCustomMods_prefetchCache);CivRegisterAfter<CivHooks::CustomMods_prefetchCache>(host, &AfterCustomMods_prefetchCache);CivRegisterReplace<CivHooks::CustomMods_prefetchCache>(host, &ReplaceCustomMods_prefetchCache);
Code
176// Update CustomModOptions table from references in CustomModPostDefines177// Based on code in CvDllDatabaseUtility::PerformDatabasePostProcessing()178void CustomMods::prefetchCache() {179 Database::Connection* db = GC.GetGameDatabase();180 db->BeginTransaction();181182 Database::Results kInsert;183 db->Execute(kInsert, "INSERT OR REPLACE INTO CustomModOptions(Name, Value) VALUES(?, ?)");184185 Database::Results kPostDefines;186 db->SelectAll(kPostDefines, "CustomModPostDefines");187 while (kPostDefines.Step()) {188 Database::Results kLookup;189 char szSQL[512];190 sprintf_s(szSQL, "select ROWID from %s where Type = '%s' LIMIT 1", kPostDefines.GetText("Table"), kPostDefines.GetText("Type"));191192 if (db->Execute(kLookup, szSQL)) {193 if (kLookup.Step()) {194 kInsert.Bind(1, kPostDefines.GetText("Name"));195 kInsert.Bind(2, kLookup.GetInt(0));196 kInsert.Step();197 kInsert.Reset();198 }199 }200 }201202 db->EndTransaction();203}
Calls
- CvGlobals::GetGameDatabase()
Database::Connection::BeginTransactionDatabase::Connection::EndTransactionDatabase::Connection::ExecuteDatabase::Connection::SelectAllDatabase::Results::BindDatabase::Results::BindDatabase::Results::GetIntDatabase::Results::GetTextDatabase::Results::ResetDatabase::Results::ResultsDatabase::Results::Stepsprintf_s