//------------------------------------------------------------------------------ bool CvProjectEntry::CacheResults(Database::Results& kResults, CvDatabaseUtility& kUtility) { if(!CvBaseInfo::CacheResults(kResults, kUtility)) return false; m_iMaxGlobalInstances = kResults.GetInt("MaxGlobalInstances"); m_iMaxTeamInstances = kResults.GetInt("MaxTeamInstances"); m_iProductionCost = kResults.GetInt("Cost"); m_iNukeInterception = kResults.GetInt("NukeInterception"); m_iCultureBranchesRequired = kResults.GetInt("CultureBranchesRequired"); m_iTechShare = kResults.GetInt("TechShare"); m_iVictoryDelayPercent = kResults.GetInt("VictoryDelayPercent"); m_bSpaceship = kResults.GetBool("Spaceship"); m_bAllowsNukes = kResults.GetBool("AllowsNukes"); #if defined(MOD_BALANCE_CORE) const char* szFreeBuilding = kResults.GetText("FreeBuildingClassIfFirst"); if(szFreeBuilding) { m_eFreeBuilding = (BuildingClassTypes)GC.getInfoTypeForString(szFreeBuilding, true); } const char* szFreePolicy = kResults.GetText("FreePolicyIfFirst"); if(szFreePolicy) { m_eFreePolicy = (PolicyTypes)GC.getInfoTypeForString(szFreePolicy, true); } #endif m_strMovieArtDef = kResults.GetText("MovieDefineTag"); const char* szVictoryPrereq = kResults.GetText("VictoryPrereq"); m_iVictoryPrereq = GC.getInfoTypeForString(szVictoryPrereq, true); const char* szTechPrereq = kResults.GetText("TechPrereq"); m_iTechPrereq = GC.getInfoTypeForString(szTechPrereq, true); const char* szEveryoneSpecialUnit = kResults.GetText("EveryoneSpecialUnit"); m_iEveryoneSpecialUnit = GC.getInfoTypeForString(szEveryoneSpecialUnit, true); const char* szCreateSound = kResults.GetText("CreateSound"); SetCreateSound(szCreateSound); const char* szAnyonePrereqProject = kResults.GetText("AnyonePrereqProject"); m_iAnyoneProjectPrereq = GC.getInfoTypeForString(szAnyonePrereqProject, true); //Arrays const char* szProjectType = GetType(); kUtility.PopulateArrayByValue(m_piResourceQuantityRequirements, "Resources", "Project_ResourceQuantityRequirements", "ResourceType", "ProjectType", szProjectType, "Quantity"); //Victory Thresholds { const int iNumVictories = kUtility.MaxRows("Victories"); kUtility.InitializeArray(m_piVictoryThreshold, iNumVictories); kUtility.InitializeArray(m_piVictoryMinThreshold, iNumVictories); Database::Results kDBResults; char szQuery[512] = {0}; sprintf_s(szQuery, "select VictoryType, Threshold, MinThreshold from Project_VictoryThresholds where ProjectType = '%s';", szProjectType); if(DB.Execute(kDBResults, szQuery)) { while(kDBResults.Step()) { const char* szVictoryType = kDBResults.GetText("VictoryType"); const int idx = GC.getInfoTypeForString(szVictoryType, true); const int iThreshold = kDBResults.GetInt("Threshold"); const int iMinThreshold = kDBResults.GetInt("MinThreshold"); m_piVictoryThreshold[idx] = iThreshold; m_piVictoryMinThreshold[idx] = iMinThreshold; } } } kUtility.SetFlavors(m_piFlavorValue, "Project_Flavors", "ProjectType", szProjectType); kUtility.PopulateArrayByValue(m_piProjectsNeeded, "Projects", "Project_Prereqs", "PrereqProjectType", "ProjectType", szProjectType, "AmountNeeded"); return true; }
//------------------------------------------------------------------------------ bool CvProjectEntry::CacheResults(Database::Results& kResults, CvDatabaseUtility& kUtility) { if(!CvBaseInfo::CacheResults(kResults, kUtility)) return false; m_iMaxGlobalInstances = kResults.GetInt("MaxGlobalInstances"); m_iMaxTeamInstances = kResults.GetInt("MaxTeamInstances"); m_iProductionCost = kResults.GetInt("Cost"); m_iNukeInterception = kResults.GetInt("NukeInterception"); m_iCultureBranchesRequired = kResults.GetInt("CultureBranchesRequired"); m_iTechShare = kResults.GetInt("TechShare"); m_iVictoryDelayPercent = kResults.GetInt("VictoryDelayPercent"); m_bSpaceship = kResults.GetBool("Spaceship"); m_bAllowsNukes = kResults.GetBool("AllowsNukes"); m_strMovieArtDef = kResults.GetText("MovieDefineTag"); const char* szVictoryPrereq = kResults.GetText("VictoryPrereq"); m_iVictoryPrereq = GC.getInfoTypeForString(szVictoryPrereq, true); const char* szTechPrereq = kResults.GetText("TechPrereq"); m_iTechPrereq = GC.getInfoTypeForString(szTechPrereq, true); const char* szEveryoneSpecialUnit = kResults.GetText("EveryoneSpecialUnit"); m_iEveryoneSpecialUnit = GC.getInfoTypeForString(szEveryoneSpecialUnit, true); const char* szCreateSound = kResults.GetText("CreateSound"); SetCreateSound(szCreateSound); const char* szAnyonePrereqProject = kResults.GetText("AnyonePrereqProject"); m_iAnyoneProjectPrereq = GC.getInfoTypeForString(szAnyonePrereqProject, true); //Arrays const char* szProjectType = GetType(); kUtility.PopulateArrayByValue(m_piResourceQuantityRequirements, "Resources", "Project_ResourceQuantityRequirements", "ResourceType", "ProjectType", szProjectType, "Quantity"); //Victory Thresholds { const int iNumVictories = kUtility.MaxRows("Victories"); kUtility.InitializeArray(m_piVictoryThreshold, iNumVictories); kUtility.InitializeArray(m_piVictoryMinThreshold, iNumVictories); Database::Results kDBResults; char szQuery[512] = {0}; sprintf_s(szQuery, "select VictoryType, Threshold, MinThreshold from Project_VictoryThresholds where ProjectType = '%s';", szProjectType); if(DB.Execute(kDBResults, szQuery)) { while(kDBResults.Step()) { const char* szVictoryType = kDBResults.GetText("VictoryType"); const int idx = GC.getInfoTypeForString(szVictoryType, true); const int iThreshold = kDBResults.GetInt("Threshold"); const int iMinThreshold = kDBResults.GetInt("MinThreshold"); m_piVictoryThreshold[idx] = iThreshold; m_piVictoryMinThreshold[idx] = iMinThreshold; } } } kUtility.SetFlavors(m_piFlavorValue, "Project_Flavors", "ProjectType", szProjectType); kUtility.PopulateArrayByValue(m_piProjectsNeeded, "Projects", "Project_Prereqs", "PrereqProjectType", "ProjectType", szProjectType, "AmountNeeded"); // EventEngine - v0.1, Snarko { m_asziFlagPrereqs.clear(); std::string strKey("Project_PrereqFlags"); Database::Results* pResults = kUtility.GetResults(strKey); if(pResults == NULL) { pResults = kUtility.PrepareResults(strKey, "select * from Project_PrereqFlags where ProjectType = ?"); } pResults->Bind(1, szProjectType); while(pResults->Step()) { std::string szFlag = pResults->GetText("Flag"); int iMinimumValue = pResults->GetInt("MinimumValue"); m_asziFlagPrereqs.push_back(std::make_pair(szFlag, iMinimumValue)); } } // END EventEngine return true; }