Bazaar developer reference

CvDiplomacyAI::DoWarDamageDecay()

Defined in
CvDiplomacyAI.cpp, line 9079
Class
CvDiplomacyAI
Hook name
CivHooks::CvDiplomacyAI_DoWarDamageDecay

Hooks

static bool BeforeCvDiplomacyAI_DoWarDamageDecay(CvDiplomacyAI* self);static void AfterCvDiplomacyAI_DoWarDamageDecay(CvDiplomacyAI* self);static void ReplaceCvDiplomacyAI_DoWarDamageDecay(void (*original)(CvDiplomacyAI*), CvDiplomacyAI* self);CivRegisterBefore<CivHooks::CvDiplomacyAI_DoWarDamageDecay>(host, &BeforeCvDiplomacyAI_DoWarDamageDecay);CivRegisterAfter<CivHooks::CvDiplomacyAI_DoWarDamageDecay>(host, &AfterCvDiplomacyAI_DoWarDamageDecay);CivRegisterReplace<CivHooks::CvDiplomacyAI_DoWarDamageDecay>(host, &ReplaceCvDiplomacyAI_DoWarDamageDecay);

Code

9078/// Every turn we're at peace war damage goes down a bit9079void CvDiplomacyAI::DoWarDamageDecay()9080{9081	if((int)m_eTargetPlayer >= (int)DIPLO_FIRST_PLAYER)9082		return;90839084	int iValue;90859086	TeamTypes eLoopThirdTeam;9087	PlayerTypes eLoopThirdPlayer;9088	int iThirdPlayerLoop;90899090	// Loop through all (known) Players9091	TeamTypes eLoopTeam;9092	PlayerTypes eLoopPlayer;9093	for(int iPlayerLoop = 0; iPlayerLoop < MAX_CIV_PLAYERS; iPlayerLoop++)9094	{9095		eLoopPlayer = (PlayerTypes) iPlayerLoop;9096		eLoopTeam = GET_PLAYER(eLoopPlayer).getTeam();90979098		if(IsPlayerValid(eLoopPlayer, /*bMyTeamIsValid*/ true))9099		{9100			// Update war damage we've suffered9101			if(!IsAtWar(eLoopPlayer))9102			{9103				iValue = GetWarValueLost(eLoopPlayer);91049105				if(iValue > 0)9106				{9107					// Go down by 1/20th every turn at peace9108					iValue /= 20;91099110					// Make sure it's changing by at least 19111					iValue = max(1, iValue);91129113					ChangeWarValueLost(eLoopPlayer, -iValue);9114				}9115			}91169117			// Update war damage other players have suffered from our viewpoint9118			for(iThirdPlayerLoop = 0; iThirdPlayerLoop < MAX_CIV_PLAYERS; iThirdPlayerLoop++)9119			{9120				eLoopThirdPlayer = (PlayerTypes) iThirdPlayerLoop;9121				eLoopThirdTeam = GET_PLAYER(eLoopThirdPlayer).getTeam();91229123				// These two players not at war?9124				if(!GET_TEAM(eLoopThirdTeam).isAtWar(eLoopTeam))9125				{9126					iValue = GetOtherPlayerWarValueLost(eLoopPlayer, eLoopThirdPlayer);91279128					if(iValue > 0)9129					{9130						// Go down by 1/20th every turn at peace9131						iValue /= 20;91329133						// Make sure it's changing by at least 19134						iValue = max(1, iValue);91359136						ChangeOtherPlayerWarValueLost(eLoopPlayer, eLoopThirdPlayer, -iValue);9137					}9138				}9139			}9140		}9141	}9142}

Calls

Called by