本文整理汇总了C++中database::Results类的典型用法代码示例。如果您正苦于以下问题:C++ Results类的具体用法?C++ Results怎么用?C++ Results使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Results类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: RegisterDynamicEnums
//------------------------------------------------------------------------------
void CvLuaEnums::RegisterDynamicEnums(lua_State* L, const char* szTableName, const char* szIdField, const char* szNameField, const char* szCountName)
{
Database::Connection& db = *GC.GetGameDatabase();
Database::Results kResults;
char zSQL[256];
sprintf_s(zSQL, 255, "select %s, %s from %s", szIdField, szNameField, szTableName);
if(db.Execute(kResults, zSQL))
{
while(kResults.Step())
{
const int value = kResults.GetInt(0);
const char* name = kResults.GetText(1);
lua_pushstring(L, name);
lua_pushvalue(L, -1);
lua_pushinteger(L, value);
lua_rawset(L, -4);
lua_rawseti(L, -2, value);
}
}
if(szCountName != NULL)
{
lua_pushstring(L, szCountName);
lua_pushinteger(L, db.Count(szTableName, false));
lua_rawset(L, -3);
}
}
开发者ID:Mandritti,项目名称:Community-Patch-DLL,代码行数:33,代码来源:CvLuaEnums.cpp
示例2: InsertGameDefine
//Just a quick utility function to save from writing lots of verbose code.
void InsertGameDefine(Database::Results& kInsertDefine, const char* szValue, int iValue)
{
kInsertDefine.Bind(1, szValue);
kInsertDefine.Bind(2, iValue);
kInsertDefine.Execute();
kInsertDefine.Reset();
}
开发者ID:doktorstick,项目名称:civsdk,代码行数:8,代码来源:CvDllDatabaseUtility.cpp
示例3: PopulateArrayByExistence
//------------------------------------------------------------------------------
bool CvDatabaseUtility::PopulateArrayByExistence(int*& pArray, const char* szTypeTableName, const char* szDataTableName, const char* szTypeColumn, const char* szFilterColumn, const char* szFilterValue)
{
InitializeArray(pArray, MaxRows(szTypeTableName), -1);
std::string strKey = "_PABE_";
strKey.append(szTypeTableName);
strKey.append(szDataTableName);
strKey.append(szFilterColumn);
Database::Results* pResults = GetResults(strKey);
if(pResults == NULL)
{
char szSQL[512];
sprintf_s(szSQL, "select %s.ID from %s inner join %s on %s = %s.Type where %s = ?", szTypeTableName, szDataTableName, szTypeTableName, szTypeColumn, szTypeTableName, szFilterColumn);
pResults = PrepareResults(strKey, szSQL);
if(pResults == NULL)
return false;
}
if(!pResults->Bind(1, szFilterValue, false))
{
CvAssertMsg(false, GetErrorMessage());
return false;
}
int idx = 0;
while(pResults->Step())
{
pArray[idx++] = pResults->GetInt(0);
}
pResults->Reset();
return true;
}
开发者ID:Be1eriand,项目名称:Civ5-DLL,代码行数:36,代码来源:CvDatabaseUtility.cpp
示例4: ReadDBLookup
/// Helper function to read a single type (as a string) and find its ID in a database table.
/// Assumes the type is in the table's field "Type"
int ReadDBLookup(FDataStream& kStream, const char* szTable, bool* bValid /*= NULL*/)
{
FStringFixedBuffer(sTemp, 256);
kStream >> sTemp;
if (bValid) *bValid = true;
if(sTemp.GetLength() > 0 && sTemp != "NO_TYPE")
{
Database::Connection* pDB = GC.GetGameDatabase();
if(pDB)
{
Database::Results kResults;
CvString szCommand;
szCommand.Format("SELECT ID from %s where Type = ? LIMIT 1", szTable);
if(pDB->Execute(kResults, szCommand.c_str()))
{
kResults.Bind(1, sTemp.c_str());
if(kResults.Step())
{
return kResults.GetInt(0);
}
else
if (bValid) *bValid = false;
}
}
else
if (bValid) *bValid = false;
}
return -1;
}
开发者ID:Yonyonnisan,项目名称:Civ5-UAM-Mod,代码行数:32,代码来源:CvInfosSerializationHelper.cpp
示例5: CacheResults
bool CvAchievementInfo::CacheResults(Database::Results& kResults, CvDatabaseUtility& kUtility)
{
if(!CvBaseInfo::CacheResults(kResults, kUtility))
return false;
m_bBroken = kResults.GetBool("Broken");
m_bAchieved = kResults.GetBool("Achieved");
return true;
}
开发者ID:rmarquis,项目名称:Community-Patch-DLL,代码行数:10,代码来源:CvAchievementInfo.cpp
示例6: CacheResults
bool CvPlotInfo::CacheResults(Database::Results& kResults, CvDatabaseUtility& kUtility)
{
if(!CvBaseInfo::CacheResults(kResults, kUtility))
return false;
m_bWater = kResults.GetBool("Water");
m_bImpassable = kResults.GetBool("Impassable");
//Arrays
const char* szPlotType = GetType();
kUtility.SetYields(m_piYields, "Plot_Yields", "PlotType", szPlotType);
return true;
}
开发者ID:rmarquis,项目名称:Community-Patch-DLL,代码行数:14,代码来源:CvPlotInfo.cpp
示例7: MaxRows
//------------------------------------------------------------------------------
int CvDatabaseUtility::MaxRows(const char* szTableName)
{
char szSQL[256] = {0};
sprintf_s(szSQL, "SELECT max(rowid) from %s", szTableName);
Database::Results kResults;
int maxValue = 0;
if(DB.Execute(kResults, szSQL))
{
if(kResults.Step())
{
//Since some rowid's start at 0 in Civ, let's increase this # by 1.
maxValue = kResults.GetInt(0) + 1;
}
}
return maxValue;
}
开发者ID:Be1eriand,项目名称:Civ5-DLL,代码行数:18,代码来源:CvDatabaseUtility.cpp
示例8: PopulateArrayByValue
//------------------------------------------------------------------------------
bool CvDatabaseUtility::PopulateArrayByValue(int*& pArray, const char* szTypeTableName, const char* szDataTableName, const char* szTypeColumn, const char* szFilterColumn, const char* szFilterValue, const char* szValueColumn, int iDefaultValue /* = 0 */, int iMinArraySize /* = 0 */)
{
int iSize = MaxRows(szTypeTableName);
InitializeArray(pArray, (iSize<iMinArraySize)?iMinArraySize:iSize, iDefaultValue);
std::string strKey = "_PABV_";
strKey.append(szTypeTableName);
strKey.append(szDataTableName);
strKey.append(szFilterColumn);
strKey.append(szValueColumn);
Database::Results* pResults = GetResults(strKey);
if(pResults == NULL)
{
char szSQL[512];
sprintf_s(szSQL, "select %s.ID, %s from %s inner join %s on %s = %s.Type where %s = ?", szTypeTableName, szValueColumn, szDataTableName, szTypeTableName, szTypeColumn, szTypeTableName, szFilterColumn);
pResults = PrepareResults(strKey, szSQL);
if(pResults == NULL)
return false;
}
if(!pResults->Bind(1, szFilterValue, false))
{
CvAssertMsg(false, GetErrorMessage());
return false;
}
while(pResults->Step())
{
const int idx = pResults->GetInt(0);
const int value = pResults->GetInt(1);
pArray[idx] = value;
}
pResults->Reset();
return true;
}
开发者ID:Be1eriand,项目名称:Civ5-DLL,代码行数:38,代码来源:CvDatabaseUtility.cpp
示例9: ValidateGameDatabase
//------------------------------------------------------------------------------
bool CvDllDatabaseUtility::ValidateGameDatabase()
{
//This function contains a suite of useful game database unit tests that will
//ensure the database conforms to certain unique rules of Civ5.
cvStopWatch kPerfTest("Validating Game Database", "xml-perf.log");
bool bError = false;
LogMsg("**** Validating Game Database *****");
//Test that all Tables w/ 'ID' column start at 0 and not 1.
{
Database::Results kTables("name");
if(DB.SelectAt(kTables, "sqlite_master", "type", "table"))
{
while(kTables.Step())
{
const char* szTableName = kTables.GetText(0);
if(DB.Count(szTableName) > 0)
{
//Test if table has 'ID' column
bool bHasIDColumn = false;
{
//Execute "select ID from <table_name> limit 1;
//If there's a SQL error, it's most likely due to a lack of an 'id' column.
char szSQL[512];
sprintf_s(szSQL, "pragma table_info(%s)", szTableName);
Database::Results kResults;
DB.Execute(kResults, szSQL);
while(kResults.Step())
{
const char* szName = kResults.GetText("name");
if(strcmp(szTableName, szName) == 0)
{
bHasIDColumn = true;
break;
}
}
}
if(bHasIDColumn)
{
Database::SingleResult kTest;
if(!DB.SelectAt(kTest, szTableName, "ID", 0))
{
//Table has 'ID' column and contains data but does not use ID 0.
char szError[512];
sprintf_s(szError, "Table '%s' contains 'ID' column that starts at 1 instead of 0.", szTableName);
LogMsg(szError);
bError = true;
}
}
}
}
}
}
//Validate FK constraints
DB.ValidateFKConstraints();
LogMsg("Performing Localization Checks");
{
LogMsg("Checking Tag Format...");
LogMsg("Note: Tags must only use [A-Z_] characters, start with 'TXT_KEY_', and be under 128 characters long.");
Database::Results kLanguages;
if(DB.SelectAll(kLanguages, "Languages"))
{
while(kLanguages.Step())
{
const char* szTagColumnName = kLanguages.GetText("TagColumnName");
const char* szTableName = kLanguages.GetText("TableName");
Database::Results kResults;
char szSQL[512];
sprintf_s(szSQL, "SELECT DISTINCT %s from %s", szTagColumnName, szTableName);
if(DB.Execute(kResults, szSQL))
{
bool bFirst = true;
while(kResults.Step())
{
const char* szTag = kResults.GetText(0);
const size_t len = strlen(szTag);
if(len > 128)
{
if(bFirst)
{
LogMsg("In table %s...", szTableName);
bFirst = false;
}
bError = true;
LogMsg("Tag (%s) has size greater than 127 characters.", szTag);
}
else
{
if(strncmp("TXT_KEY_", szTag, 8) != 0)
{
//.........这里部分代码省略.........
开发者ID:doktorstick,项目名称:civsdk,代码行数:101,代码来源:CvDllDatabaseUtility.cpp
示例10: CacheResults
bool CvUnitEntry::CacheResults(Database::Results& kResults, CvDatabaseUtility& kUtility)
{
if(!CvBaseInfo::CacheResults(kResults, kUtility))
return false;
//Basic Properties
m_iProductionCost = kResults.GetInt("Cost");
m_iFaithCost = kResults.GetInt("FaithCost");
m_bRequiresFaithPurchaseEnabled = kResults.GetBool("RequiresFaithPurchaseEnabled");
m_iHurryCostModifier = kResults.GetInt("HurryCostModifier");
m_iAdvancedStartCost = kResults.GetInt("AdvancedStartCost");
m_iMinAreaSize = kResults.GetInt("MinAreaSize");
m_iMoves = kResults.GetInt("Moves");
m_bMoves = kResults.GetInt("Immobile");
m_iBaseSightRange = kResults.GetInt("BaseSightRange");
m_iRange = kResults.GetInt("Range");
m_iAirInterceptRange = kResults.GetInt("AirInterceptRange");
m_iAirUnitCap = kResults.GetInt("AirUnitCap");
m_iNukeDamageLevel = kResults.GetInt("NukeDamageLevel");
m_iWorkRate = kResults.GetInt("WorkRate");
m_iNumFreeTechs = kResults.GetInt("NumFreeTechs");
m_iBaseBeakersTurnsToCount = kResults.GetInt("BaseBeakersTurnsToCount");
m_iBaseHurry = kResults.GetInt("BaseHurry");
m_iHurryMultiplier = kResults.GetInt("HurryMultiplier");
m_bRushBuilding= kResults.GetInt("RushBuilding");
m_iBaseGold = kResults.GetInt("BaseGold");
m_iNumGoldPerEra = kResults.GetInt("NumGoldPerEra");
m_bSpreadReligion = kResults.GetBool("SpreadReligion");
m_bRemoveHeresy = kResults.GetBool("RemoveHeresy");
m_iReligionSpreads = kResults.GetInt("ReligionSpreads");
m_iReligiousStrength = kResults.GetInt("ReligiousStrength");
m_bFoundReligion = kResults.GetBool("FoundReligion");
m_bRequiresEnhancedReligion = kResults.GetBool("RequiresEnhancedReligion");
m_bProhibitsSpread = kResults.GetBool("ProhibitsSpread");
m_iCombat = kResults.GetInt("Combat");
m_iCombatLimit = kResults.GetInt("CombatLimit");
m_iRangedCombat = kResults.GetInt("RangedCombat");
m_iRangedCombatLimit = kResults.GetInt("RangedCombatLimit");
m_iXPValueAttack = kResults.GetInt("XPValueAttack");
m_iXPValueDefense = kResults.GetInt("XPValueDefense");
m_iConscriptionValue = kResults.GetInt("Conscription");
m_iExtraMaintenanceCost = kResults.GetInt("ExtraMaintenanceCost");
m_bNoMaintenance = kResults.GetBool("NoMaintenance");
m_iUnhappiness = kResults.GetInt("Unhappiness");
m_iUnitFlagIconOffset = kResults.GetInt("UnitFlagIconOffset");
m_iUnitPortraitOffset = kResults.GetInt("PortraitIndex");
m_iLeaderExperience = kResults.GetInt("LeaderExperience");
m_bFoodProduction = kResults.GetBool("Food");
m_bNoBadGoodies = kResults.GetBool("NoBadGoodies");
m_bRivalTerritory = kResults.GetBool("RivalTerritory");
m_bMilitarySupport = kResults.GetBool("MilitarySupport");
m_bMilitaryProduction = kResults.GetBool("MilitaryProduction");
m_bPillage = kResults.GetBool("Pillage");
m_bFound = kResults.GetBool("Found");
m_bFoundAbroad = kResults.GetBool("FoundAbroad");
m_iCultureBombRadius = kResults.GetInt("CultureBombRadius");
m_iGoldenAgeTurns = kResults.GetInt("GoldenAgeTurns");
m_bIgnoreBuildingDefense = kResults.GetBool("IgnoreBuildingDefense");
m_bPrereqResources = kResults.GetBool("PrereqResources");
m_bMechanized = kResults.GetBool("Mechanized");
m_bSuicide = kResults.GetBool("Suicide");
m_bCaptureWhileEmbarked = kResults.GetBool("CaptureWhileEmbarked");
m_bRangeAttackOnlyInDomain = kResults.GetBool("RangeAttackOnlyInDomain");
m_strUnitArtInfoTag = kResults.GetText("UnitArtInfo");
m_bUnitArtInfoCulturalVariation = kResults.GetBool("UnitArtInfoCulturalVariation");
m_bUnitArtInfoEraVariation = kResults.GetBool("UnitArtInfoEraVariation");
//References
const char* szTextVal = NULL;
szTextVal = kResults.GetText("Class");
m_iUnitClassType = GC.getInfoTypeForString(szTextVal, true);
szTextVal = kResults.GetText("Special");
m_iSpecialUnitType = GC.getInfoTypeForString(szTextVal, true);
szTextVal = kResults.GetText("Capture");
m_iUnitCaptureClassType = GC.getInfoTypeForString(szTextVal, true);
szTextVal = kResults.GetText("CombatClass");
m_iUnitCombatType = GC.getInfoTypeForString(szTextVal, true);
szTextVal = kResults.GetText("Domain");
m_iDomainType = GC.getInfoTypeForString(szTextVal, true);
szTextVal = kResults.GetText("CivilianAttackPriority");
m_iCivilianAttackPriority = GC.getInfoTypeForString(szTextVal, true);
szTextVal = kResults.GetText("DefaultUnitAI");
m_iDefaultUnitAIType = GC.getInfoTypeForString(szTextVal, true);
szTextVal = kResults.GetText("PillagePrereqTech");
m_iPrereqPillageTech = GC.getInfoTypeForString(szTextVal, true);
szTextVal = kResults.GetText("PrereqTech");
m_iPrereqAndTech = GC.getInfoTypeForString(szTextVal, true);
szTextVal = kResults.GetText("ObsoleteTech");
m_iObsoleteTech = GC.getInfoTypeForString(szTextVal, true);
//.........这里部分代码省略.........
开发者ID:Decker87,项目名称:civ5DllMod,代码行数:101,代码来源:CvUnitClasses.cpp
示例11: CacheResults
/// Read from XML file (pass 1)
bool CvNotificationEntry::CacheResults(Database::Results& kResults, CvDatabaseUtility&)
{
m_strNotificationType = kResults.GetText("NotificationType");
return true;
}
开发者ID:Be1eriand,项目名称:Civ5-DLL,代码行数:6,代码来源:CvNotificationClasses.cpp
示例12: CacheResults
//------------------------------------------------------------------------------
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;
}
开发者ID:DivineYuri,项目名称:Community-Patch-DLL,代码行数:82,代码来源:CvProjectClasses.cpp
示例13: CacheResults
bool CvCorporationEntry::CacheResults(Database::Results& kResults, CvDatabaseUtility& kUtility)
{
if(!CvBaseInfo::CacheResults(kResults, kUtility))
return false;
m_iMaxFranchises = kResults.GetInt("MaxFranchises");
m_iNumFreeTradeRoutes = kResults.GetInt("NumFreeTradeRoutes");
m_iTradeRouteLandDistanceModifier = kResults.GetInt("TradeRouteLandDistanceModifier");
m_iTradeRouteSeaDistanceModifier = kResults.GetInt("TradeRouteSeaDistanceModifier");
m_iTradeRouteSpeedModifier = kResults.GetInt("TradeRouteSpeedModifier");
m_iTradeRouteVisionBoost = kResults.GetInt("TradeRouteVisionBoost");
m_bTradeRoutesInvulnerable = kResults.GetBool("TradeRoutesInvulnerable");
m_iTradeRouteRecipientBonus = kResults.GetInt("TradeRouteRecipientBonus");
m_iTradeRouteTargetBonus = kResults.GetInt("TradeRouteTargetBonus");
//References
const char* szTextVal = NULL;
szTextVal = kResults.GetText("HeadquartersBuildingClass");
m_eHeadquartersBuildingClass = (BuildingClassTypes) GC.getInfoTypeForString(szTextVal, true);
szTextVal = kResults.GetText("OfficeBuildingClass");
m_eOfficeBuildingClass = (BuildingClassTypes) GC.getInfoTypeForString(szTextVal, true);
szTextVal = kResults.GetText("FranchiseBuildingClass");
m_eFranchiseBuildingClass = (BuildingClassTypes) GC.getInfoTypeForString(szTextVal, true);
szTextVal = kResults.GetText("OfficeBenefitHelper");
m_strOfficeBenefitHelper = szTextVal;
// This is not ideal, but Corporations are loaded last, and I want an easy way to tell if a building class is owned by a Corporation
// Note: Intellisense may lie here! This will compile (declared as friend)
CvBuildingClassInfo* pkBuildingInfo = GC.getBuildingClassInfo(m_eHeadquartersBuildingClass);
if (pkBuildingInfo)
{
pkBuildingInfo->m_eCorporationType = (CorporationTypes) GetID();
pkBuildingInfo->m_bIsHeadquarters = true;
}
pkBuildingInfo = GC.getBuildingClassInfo(m_eOfficeBuildingClass);
if (pkBuildingInfo)
{
pkBuildingInfo->m_eCorporationType = (CorporationTypes) GetID();
pkBuildingInfo->m_bIsOffice = true;
}
pkBuildingInfo = GC.getBuildingClassInfo(m_eFranchiseBuildingClass);
if (pkBuildingInfo)
{
pkBuildingInfo->m_eCorporationType = (CorporationTypes) GetID();
pkBuildingInfo->m_bIsFranchise = true;
}
const char* szCorporationType = GetType();
kUtility.PopulateArrayByExistence(m_piResourceMonopolyAnd, "Resources", "Corporation_ResourceMonopolyAnds", "ResourceType", "CorporationType", szCorporationType);
kUtility.PopulateArrayByExistence(m_piResourceMonopolyOrs, "Resources", "Corporation_ResourceMonopolyOrs", "ResourceType", "CorporationType", szCorporationType);
kUtility.PopulateArrayByValue(m_piNumFreeResource, "Resources", "Corporation_NumFreeResource", "ResourceType", "CorporationType", szCorporationType, "NumResource");
kUtility.PopulateArrayByValue(m_piUnitResourceProductionModifier, "Resources", "Corporation_UnitResourceProductionModifier", "ResourceType", "CorporationType", szCorporationType, "Modifier");
kUtility.SetYields(m_piTradeRouteCityMod, "Corporation_TradeRouteCityYield", "CorporationType", szCorporationType);
kUtility.SetYields(m_piTradeRouteMod, "Corporation_TradeRouteMod", "CorporationType", szCorporationType);
//BuildingClassYieldChanges
{
kUtility.Initialize2DArray(m_ppiBuildingClassYieldChanges, "BuildingClasses", "Yields");
std::string strKey("Corporation_BuildingClassYieldChanges");
Database::Results* pResults = kUtility.GetResults(strKey);
if (pResults == NULL)
{
pResults = kUtility.PrepareResults(strKey, "select BuildingClasses.ID as BuildingClassID, Yields.ID as YieldID, YieldChange from Corporation_BuildingClassYieldChanges inner join BuildingClasses on BuildingClasses.Type = BuildingClassType inner join Yields on Yields.Type = YieldType where CorporationType = ?");
}
pResults->Bind(1, szCorporationType);
while (pResults->Step())
{
const int BuildingClassID = pResults->GetInt(0);
const int iYieldID = pResults->GetInt(1);
const int iYieldChange = pResults->GetInt(2);
m_ppiBuildingClassYieldChanges[BuildingClassID][iYieldID] = iYieldChange;
}
}
//ResourceYieldChanges
{
kUtility.Initialize2DArray(m_ppaiResourceYieldChange, "Resources", "Yields");
std::string strKey("Corporation_ResourceYieldChanges");
Database::Results* pResults = kUtility.GetResults(strKey);
if (pResults == NULL)
{
pResults = kUtility.PrepareResults(strKey, "select Resources.ID as ResourceID, Yields.ID as YieldID, Yield from Corporation_ResourceYieldChanges inner join Resources on Resources.Type = ResourceType inner join Yields on Yields.Type = YieldType where CorporationType = ?");
}
pResults->Bind(1, szCorporationType);
while (pResults->Step())
{
const int ResourceID = pResults->GetInt(0);
const int YieldID = pResults->GetInt(1);
const int yield = pResults->GetInt(2);
//.........这里部分代码省略.........
开发者ID:Skidizzle,项目名称:Community-Patch-DLL,代码行数:101,代码来源:CvCorporationClasses.cpp
示例14: CacheResults
/// 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)
{
//.........这里部分代码省略.........
开发者ID:Kirschi,项目名称:Community-Patch-DLL,代码行数:101,代码来源:CvImprovementClasses.cpp
示例15: CacheResults
/// 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);
//.........这里部分代码省略.........
开发者ID:Be1eriand,项目名称:Civ5-DLL,代码行数:101,代码来源:CvImprovementClasses.cpp
示例16: AcquireTypes
void CvTypes::AcquireTypes(Database::Connection& db)
{
//MissionTypes
{
typedef std::tr1::unordered_map<std::string, MissionTypes*> LookupTable;
LookupTable kMissionTypesLookupTable;
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_MOVE_TO"), &s_eMISSION_MOVE_TO));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_ROUTE_TO"), &s_eMISSION_ROUTE_TO));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_MOVE_TO_UNIT"), &s_eMISSION_MOVE_TO_UNIT));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_SWAP_UNITS"), &s_eMISSION_SWAP_UNITS));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_SKIP"), &s_eMISSION_SKIP));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_SLEEP"), &s_eMISSION_SLEEP));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_ALERT"), &s_eMISSION_ALERT));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_FORTIFY"), &s_eMISSION_FORTIFY));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_GARRISON"), &s_eMISSION_GARRISON));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_SET_UP_FOR_RANGED_ATTACK"), &s_eMISSION_SET_UP_FOR_RANGED_ATTACK));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_EMBARK"), &s_eMISSION_EMBARK));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_DISEMBARK"), &s_eMISSION_DISEMBARK));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_AIRPATROL"), &s_eMISSION_AIRPATROL));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_HEAL"), &s_eMISSION_HEAL));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_AIRLIFT"), &s_eMISSION_AIRLIFT));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_NUKE"), &s_eMISSION_NUKE));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_PARADROP"), &s_eMISSION_PARADROP));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_AIR_SWEEP"), &s_eMISSION_AIR_SWEEP));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_REBASE"), &s_eMISSION_REBASE));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_RANGE_ATTACK"), &s_eMISSION_RANGE_ATTACK));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_PILLAGE"), &s_eMISSION_PILLAGE));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_FOUND"), &s_eMISSION_FOUND));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_JOIN"), &s_eMISSION_JOIN));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_CONSTRUCT"), &s_eMISSION_CONSTRUCT));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_DISCOVER"), &s_eMISSION_DISCOVER));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_HURRY"), &s_eMISSION_HURRY));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_TRADE"), &s_eMISSION_TRADE));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_REPAIR_FLEET"), &s_eMISSION_REPAIR_FLEET));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_SPACESHIP"), &s_eMISSION_SPACESHIP));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_CULTURE_BOMB"), &s_eMISSION_CULTURE_BOMB));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_FOUND_RELIGION"), &s_eMISSION_FOUND_RELIGION));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_GOLDEN_AGE"), &s_eMISSION_GOLDEN_AGE));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_BUILD"), &s_eMISSION_BUILD));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_LEAD"), &s_eMISSION_LEAD));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_DIE_ANIMATION"), &s_eMISSION_DIE_ANIMATION));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_BEGIN_COMBAT"), &s_eMISSION_BEGIN_COMBAT));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_END_COMBAT"), &s_eMISSION_END_COMBAT));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_AIRSTRIKE"), &s_eMISSION_AIRSTRIKE));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_SURRENDER"), &s_eMISSION_SURRENDER));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_CAPTURED"), &s_eMISSION_CAPTURED));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_IDLE"), &s_eMISSION_IDLE));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_DIE"), &s_eMISSION_DIE));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_DAMAGE"), &s_eMISSION_DAMAGE));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_MULTI_SELECT"), &s_eMISSION_MULTI_SELECT));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_MULTI_DESELECT"), &s_eMISSION_MULTI_DESELECT));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_WAIT_FOR"), &s_eMISSION_WAIT_FOR));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_SPREAD_RELIGION"), &s_eMISSION_SPREAD_RELIGION));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_ENHANCE_RELIGION"), &s_eMISSION_ENHANCE_RELIGION));
kMissionTypesLookupTable.insert(make_pair(std::string("MISSION_REMOVE_HERESY"), &s_eMISSION_REMOVE_HERESY));
Database::Results kResults;
if(db.Execute(kResults, "SELECT Type, ID from Missions"))
{
while(kResults.Step())
{
std::string strMissionType = kResults.GetText(0);
LookupTable::iterator it = kMissionTypesLookupTable.find(strMissionType);
if(it != kMissionTypesLookupTable.end())
{
(*it->second) = static_cast<MissionTypes>(kResults.GetInt(1));
}
}
}
int iNumTypes = db.Count("Missions", false);
if(iNumTypes >= 0)
{
s_uiNUM_MISSION_TYPES = static_cast<unsigned int>(iNumTypes);
}
for(LookupTable::iterator it = kMissionTypesLookupTable.begin(); it != kMissionTypesLookupTable.end(); ++it)
{
if((*it->second) == NO_MISSION)
{
char msg[256] = {0};
sprintf_s(msg, "MissionType - %s is used in the DLL but does not exist in the database.", it->first.c_str());
FILogFile* pLog = LOGFILEMGR.GetLog("Gamecore.log", FILogFile::kDontTimeStamp);
pLog->WarningMsg(msg);
CvAssertMsg(false, msg);
}
}
}
}
|
请发表评论