Bazaar developer reference

CvDllNetMessageHandler::ResponseUpdatePolicies(PlayerTypes, bool, int, bool)

Defined in
CvDllNetMessageHandler.cpp, line 1017
Class
CvDllNetMessageHandler
Hook name
CivHooks::CvDllNetMessageHandler_ResponseUpdatePolicies

Hooks

static bool BeforeCvDllNetMessageHandler_ResponseUpdatePolicies(CvDllNetMessageHandler* self, PlayerTypes ePlayer, bool bNOTPolicyBranch, int iPolicyID, bool bValue);static void AfterCvDllNetMessageHandler_ResponseUpdatePolicies(CvDllNetMessageHandler* self, PlayerTypes ePlayer, bool bNOTPolicyBranch, int iPolicyID, bool bValue);static void ReplaceCvDllNetMessageHandler_ResponseUpdatePolicies(void (*original)(CvDllNetMessageHandler*, PlayerTypes, bool, int, bool), CvDllNetMessageHandler* self, PlayerTypes ePlayer, bool bNOTPolicyBranch, int iPolicyID, bool bValue);// CivHooks.h gives this hook point no types, so nothing checks these hooks' parameters.host->RegisterHook(host->pluginIndex, CivHooks::CvDllNetMessageHandler_ResponseUpdatePolicies::ID, CIV_HOOK_BEFORE, (void*)&BeforeCvDllNetMessageHandler_ResponseUpdatePolicies);host->RegisterHook(host->pluginIndex, CivHooks::CvDllNetMessageHandler_ResponseUpdatePolicies::ID, CIV_HOOK_AFTER, (void*)&AfterCvDllNetMessageHandler_ResponseUpdatePolicies);host->RegisterHook(host->pluginIndex, CivHooks::CvDllNetMessageHandler_ResponseUpdatePolicies::ID, CIV_HOOK_REPLACE, (void*)&ReplaceCvDllNetMessageHandler_ResponseUpdatePolicies);

Code

1017void CvDllNetMessageHandler::ResponseUpdatePolicies(PlayerTypes ePlayer, bool bNOTPolicyBranch, int iPolicyID, bool bValue)1018{1019	CvPlayerAI& kPlayer = GET_PLAYER(ePlayer);10201021	// Policy Update1022	if(bNOTPolicyBranch)1023	{1024		const PolicyTypes ePolicy = static_cast<PolicyTypes>(iPolicyID);1025		if(bValue)1026		{1027			kPlayer.doAdoptPolicy(ePolicy);1028		}1029		else1030		{1031			kPlayer.setHasPolicy(ePolicy, bValue);1032			kPlayer.DoUpdateHappiness();1033		}1034	}1035	// Policy Branch Update1036	else1037	{1038		const PolicyBranchTypes eBranch = static_cast<PolicyBranchTypes>(iPolicyID);1039		CvPlayerPolicies* pPlayerPolicies = kPlayer.GetPlayerPolicies();10401041		// If Branch was blocked by another branch, then unblock this one - this may be the only thing this NetMessage does1042		if(pPlayerPolicies->IsPolicyBranchBlocked(eBranch))1043		{1044			// Can't switch to a Branch that's still locked. DoUnlockPolicyBranch below will handle this for us1045			if(pPlayerPolicies->IsPolicyBranchUnlocked(eBranch))1046			{1047				//pPlayerPolicies->ChangePolicyBranchBlockedCount(eBranch, -1);1048				pPlayerPolicies->DoSwitchToPolicyBranch(eBranch);1049			}1050		}10511052		// Unlock the branch if it hasn't been already1053		if(!pPlayerPolicies->IsPolicyBranchUnlocked(eBranch))1054		{1055			pPlayerPolicies->DoUnlockPolicyBranch(eBranch);1056		}1057	}1058}

Calls