Bazaar developer reference

CvPreGame::SetMapOption(const char *, int)

Defined in
CvPreGame.cpp, line 1531
Hook name
CivHooks::CvPreGame_SetMapOption

Hooks

static bool BeforeCvPreGame_SetMapOption(const char* szOptionName, int iValue, bool& result);static void AfterCvPreGame_SetMapOption(const char* szOptionName, int iValue, bool& result);static bool ReplaceCvPreGame_SetMapOption(bool (*original)(const char*, int), const char* szOptionName, int iValue);CivRegisterBefore<CivHooks::CvPreGame_SetMapOption>(host, &BeforeCvPreGame_SetMapOption);CivRegisterAfter<CivHooks::CvPreGame_SetMapOption>(host, &AfterCvPreGame_SetMapOption);CivRegisterReplace<CivHooks::CvPreGame_SetMapOption>(host, &ReplaceCvPreGame_SetMapOption);

Code

1531bool SetMapOption(const char* szOptionName, int iValue)1532{1533	//DO NOT ALLOW NULL1534	if(szOptionName == NULL)1535		return false;15361537	for(size_t i = 0; i < s_MapOptions.size(); i++)1538	{1539		const CustomOption& option = s_MapOptions[i];1540		size_t bytes = 0;1541		const char* szCurrentOptionName = option.GetName(bytes);1542		if(strncmp(szCurrentOptionName, szOptionName, bytes) == 0)1543		{1544			//I'd like to just set the value here, but that doesn't seem possible1545			//so instead, create a new CustomOption type and assign it to this index.1546			s_MapOptions.setAt(i, CustomOption(szOptionName, iValue));1547			return true;1548		}15491550	}15511552	//Didn't find the option, push it.1553	s_MapOptions.push_back(CustomOption(szOptionName, iValue));1554	return true;1555}

Calls

Called by