Bazaar developer reference

CvPreGame::SetGameOption(const char *, int)

Defined in
CvPreGame.cpp, line 1009
Hook name
CivHooks::CvPreGame_SetGameOption

Hooks

static bool BeforeCvPreGame_SetGameOption(const char* szOptionName, int iValue, bool& result);static void AfterCvPreGame_SetGameOption(const char* szOptionName, int iValue, bool& result);static bool ReplaceCvPreGame_SetGameOption(bool (*original)(const char*, int), const char* szOptionName, int iValue);CivRegisterBefore<CivHooks::CvPreGame_SetGameOption>(host, &BeforeCvPreGame_SetGameOption);CivRegisterAfter<CivHooks::CvPreGame_SetGameOption>(host, &AfterCvPreGame_SetGameOption);CivRegisterReplace<CivHooks::CvPreGame_SetGameOption>(host, &ReplaceCvPreGame_SetGameOption);

Code

1009bool SetGameOption(const char* szOptionName, int iValue)1010{1011	//Do not allow NULL entries :P1012	if(szOptionName == NULL || strlen(szOptionName) == 0)1013		return false;10141015	for(size_t i = 0; i < s_GameOptions.size(); i++)1016	{1017		const CustomOption& option = s_GameOptions[i];1018		size_t bytes = 0;1019		const char* szCurrentOptionName = option.GetName(bytes);1020		if(strncmp(szCurrentOptionName, szOptionName, bytes) == 0)1021		{1022			//I'd like to just set the value here, but that doesn't seem possible1023			//so instead, create a new CustomOption type and assign it to this index.1024			s_GameOptions.setAt(i, CustomOption(szOptionName, iValue));1025			SyncGameOptionsWithEnumList();1026			return true;1027		}10281029	}10301031	//Didn't find the option, push it.1032	s_GameOptions.push_back(CustomOption(szOptionName, iValue));1033	s_GameOptionsHash[FString::Hash(szOptionName)] = s_GameOptions.size() - 1;1034	SyncGameOptionsWithEnumList();10351036	return true;1037}

Calls

Called by