Bazaar developer reference

CvDiplomacyAI::DoUpdateLandDisputeLevels()

Defined in
CvDiplomacyAI.cpp, line 7599
Class
CvDiplomacyAI
Hook name
CivHooks::CvDiplomacyAI_DoUpdateLandDisputeLevels

Hooks

static bool BeforeCvDiplomacyAI_DoUpdateLandDisputeLevels(CvDiplomacyAI* self);static void AfterCvDiplomacyAI_DoUpdateLandDisputeLevels(CvDiplomacyAI* self);static void ReplaceCvDiplomacyAI_DoUpdateLandDisputeLevels(void (*original)(CvDiplomacyAI*), CvDiplomacyAI* self);CivRegisterBefore<CivHooks::CvDiplomacyAI_DoUpdateLandDisputeLevels>(host, &BeforeCvDiplomacyAI_DoUpdateLandDisputeLevels);CivRegisterAfter<CivHooks::CvDiplomacyAI_DoUpdateLandDisputeLevels>(host, &AfterCvDiplomacyAI_DoUpdateLandDisputeLevels);CivRegisterReplace<CivHooks::CvDiplomacyAI_DoUpdateLandDisputeLevels>(host, &ReplaceCvDiplomacyAI_DoUpdateLandDisputeLevels);

Code

7598/// Updates what is our level of Dispute with a player is over Land7599void CvDiplomacyAI::DoUpdateLandDisputeLevels()7600{7601	PlayerTypes ePlayer;76027603	DisputeLevelTypes eDisputeLevel;76047605	int iLandDisputeWeight;7606	int iExpansionFlavor;76077608	AggressivePostureTypes eAggression;7609	PlayerProximityTypes eProximity;76107611	// Loop through all (known) Players7612	for(int iPlayerLoop = 0; iPlayerLoop < MAX_CIV_PLAYERS; iPlayerLoop++)7613	{7614		ePlayer = (PlayerTypes) iPlayerLoop;76157616		// Update last turn's values7617		m_paePlayerLastTurnLandDisputeLevel[ePlayer] = GetLandDisputeLevel(ePlayer);76187619		if(IsPlayerValid(ePlayer))7620		{7621			eDisputeLevel = DISPUTE_LEVEL_NONE;76227623			iLandDisputeWeight = 0;76247625			// Expansion aggression7626			eAggression = GetExpansionAggressivePosture(ePlayer);76277628			if(eAggression == AGGRESSIVE_POSTURE_NONE)7629				iLandDisputeWeight += /*0*/ GC.getLAND_DISPUTE_EXP_AGGRESSIVE_POSTURE_NONE();7630			else if(eAggression == AGGRESSIVE_POSTURE_LOW)7631				iLandDisputeWeight += /*10*/ GC.getLAND_DISPUTE_EXP_AGGRESSIVE_POSTURE_LOW();7632			else if(eAggression == AGGRESSIVE_POSTURE_MEDIUM)7633				iLandDisputeWeight += /*32*/ GC.getLAND_DISPUTE_EXP_AGGRESSIVE_POSTURE_MEDIUM();7634			else if(eAggression == AGGRESSIVE_POSTURE_HIGH)7635				iLandDisputeWeight += /*50*/ GC.getLAND_DISPUTE_EXP_AGGRESSIVE_POSTURE_HIGH();7636			else if(eAggression == AGGRESSIVE_POSTURE_INCREDIBLE)7637				iLandDisputeWeight += /*60*/ GC.getLAND_DISPUTE_EXP_AGGRESSIVE_POSTURE_INCREDIBLE();76387639			// Plot Buying aggression7640			eAggression = GetPlotBuyingAggressivePosture(ePlayer);76417642			if(eAggression == AGGRESSIVE_POSTURE_NONE)7643				iLandDisputeWeight += /*0*/ GC.getLAND_DISPUTE_PLOT_BUY_AGGRESSIVE_POSTURE_NONE();7644			else if(eAggression == AGGRESSIVE_POSTURE_LOW)7645				iLandDisputeWeight += /*5*/ GC.getLAND_DISPUTE_PLOT_BUY_AGGRESSIVE_POSTURE_LOW();7646			else if(eAggression == AGGRESSIVE_POSTURE_MEDIUM)7647				iLandDisputeWeight += /*12*/ GC.getLAND_DISPUTE_PLOT_BUY_AGGRESSIVE_POSTURE_MEDIUM();7648			else if(eAggression == AGGRESSIVE_POSTURE_HIGH)7649				iLandDisputeWeight += /*20*/ GC.getLAND_DISPUTE_PLOT_BUY_AGGRESSIVE_POSTURE_HIGH();7650			else if(eAggression == AGGRESSIVE_POSTURE_INCREDIBLE)7651				iLandDisputeWeight += /*30*/ GC.getLAND_DISPUTE_PLOT_BUY_AGGRESSIVE_POSTURE_INCREDIBLE();76527653			// Look at our Proximity to the other Player7654			eProximity = GetPlayer()->GetProximityToPlayer(ePlayer);76557656			if(eProximity == PLAYER_PROXIMITY_DISTANT)7657				iLandDisputeWeight += /*0*/ GC.getLAND_DISPUTE_DISTANT();7658			else if(eProximity == PLAYER_PROXIMITY_FAR)7659				iLandDisputeWeight += /*10*/ GC.getLAND_DISPUTE_FAR();7660			else if(eProximity == PLAYER_PROXIMITY_CLOSE)7661				iLandDisputeWeight += /*18*/ GC.getLAND_DISPUTE_CLOSE();7662			else if(eProximity == PLAYER_PROXIMITY_NEIGHBORS)7663				iLandDisputeWeight += /*30*/ GC.getLAND_DISPUTE_NEIGHBORS();76647665			// JON: Turned off to counter-balance the lack of the next block functioning7666			// Is the player already cramped?7667			if(GetPlayer()->IsCramped())7668			{7669				iLandDisputeWeight += /*0*/ GC.getLAND_DISPUTE_CRAMPED_MULTIPLIER();7670			}76717672			// JON: Is this Strategy deprecated?76737674			// If we're not actually trying to expand any more, then we shouldn't be as upset about land!7675			//EconomicAIStrategyTypes eStrategyNormalExpansion = (EconomicAIStrategyTypes) GC.getInfoTypeForString("ECONOMICAISTRATEGY_EARLY_EXPANSION", true);76767677			//if (eStrategyNormalExpansion != NO_ECONOMICAISTRATEGY)7678			//{7679			//	if (!GetPlayer()->GetEconomicAI()->IsUsingStrategy(eStrategyNormalExpansion))7680			//	{7681			//		iLandDisputeWeight += /*0*/ GC.getLAND_DISPUTE_NO_EXPANSION_STRATEGY();7682			//	}7683			//}76847685			// If the player has deleted the EXPANSION Flavor we have to account for that7686			iExpansionFlavor = /*5*/ GC.getDEFAULT_FLAVOR_VALUE();76877688			for(int iFlavorLoop = 0; iFlavorLoop < GC.getNumFlavorTypes(); iFlavorLoop++)7689			{7690				if(GC.getFlavorTypes((FlavorTypes) iFlavorLoop) == "FLAVOR_EXPANSION")7691				{7692					iExpansionFlavor = GetPlayer()->GetGrandStrategyAI()->GetPersonalityAndGrandStrategy((FlavorTypes) iFlavorLoop);7693					break;7694				}7695			}76967697			// Add weight for Player's natural EXPANSION preference7698			iLandDisputeWeight *= iExpansionFlavor;76997700			// Now See what our new Dispute Level should be7701			if(iLandDisputeWeight >= /*400*/ GC.getLAND_DISPUTE_FIERCE_THRESHOLD())7702				eDisputeLevel = DISPUTE_LEVEL_FIERCE;7703			else if(iLandDisputeWeight >= /*230*/ GC.getLAND_DISPUTE_STRONG_THRESHOLD())7704				eDisputeLevel = DISPUTE_LEVEL_STRONG;7705			else if(iLandDisputeWeight >= /*100*/ GC.getLAND_DISPUTE_WEAK_THRESHOLD())7706				eDisputeLevel = DISPUTE_LEVEL_WEAK;77077708			// Actually set the Level7709			SetLandDisputeLevel(ePlayer, eDisputeLevel);7710		}7711	}7712}

Calls

Called by