Bazaar developer reference

CvPreGame::GetGameOption(GameOptionTypes, int &)

Defined in
CvPreGame.cpp, line 959
Hook name
CivHooks::CvPreGame_GetGameOption_with_GameOptionTypes_int

Hooks

static bool BeforeCvPreGame_GetGameOption_with_GameOptionTypes_int(GameOptionTypes eOption, int& iValue, bool& result);static void AfterCvPreGame_GetGameOption_with_GameOptionTypes_int(GameOptionTypes eOption, int& iValue, bool& result);static bool ReplaceCvPreGame_GetGameOption_with_GameOptionTypes_int(bool (*original)(GameOptionTypes, int&), GameOptionTypes eOption, int& iValue);CivRegisterBefore<CivHooks::CvPreGame_GetGameOption_with_GameOptionTypes_int>(host, &BeforeCvPreGame_GetGameOption_with_GameOptionTypes_int);CivRegisterAfter<CivHooks::CvPreGame_GetGameOption_with_GameOptionTypes_int>(host, &AfterCvPreGame_GetGameOption_with_GameOptionTypes_int);CivRegisterReplace<CivHooks::CvPreGame_GetGameOption_with_GameOptionTypes_int>(host, &ReplaceCvPreGame_GetGameOption_with_GameOptionTypes_int);

Code

959bool GetGameOption(GameOptionTypes eOption, int& iValue)960{961	if((uint)eOption >= 0 && (uint)eOption < (uint)NUM_GAMEOPTION_TYPES)962	{963		iValue = s_EnumBasedGameOptions[(size_t)eOption];964		return true;965	}966	else967	{968		// Hash lookup969		HashToOptionMap::const_iterator itr = s_GameOptionsHash.find((uint)eOption);970		if(itr != s_GameOptionsHash.end())971		{972			if(itr->second <= s_GameOptions.size())973			{974				iValue = s_GameOptions[itr->second].GetValue();975				return true;976			}977		}978979		// Must get the string from the hash980		GameOptionTypes eOptionIndex = (GameOptionTypes)GC.getInfoTypeForHash((uint)eOption);981		if(eOptionIndex >= 0)982		{983			CvGameOptionInfo* pkInfo = GC.getGameOptionInfo(eOptionIndex);984			if(pkInfo)985			{986				//Try and lookup the default value.987				Database::Results kLookup;988				if(GC.GetGameDatabase()->Execute(kLookup, "Select \"Default\" from GameOptions where Type = ? LIMIT 1"))989				{990					kLookup.Bind(1, pkInfo->GetType());991					if(kLookup.Step())992					{993						iValue = kLookup.GetInt(0);994						return true;995					}996				}997			}998		}9991000		return false;1001	}1002}

Calls

Called by