Bazaar developer reference

CvDiplomacyAI::GetNumTurnsSinceSomethingSent(PlayerTypes)

Defined in
CvDiplomacyAI.cpp, line 24592
Class
CvDiplomacyAI
Hook name
CivHooks::CvDiplomacyAI_GetNumTurnsSinceSomethingSent

Hooks

static bool BeforeCvDiplomacyAI_GetNumTurnsSinceSomethingSent(CvDiplomacyAI* self, PlayerTypes ePlayer, int& result);static void AfterCvDiplomacyAI_GetNumTurnsSinceSomethingSent(CvDiplomacyAI* self, PlayerTypes ePlayer, int& result);static int ReplaceCvDiplomacyAI_GetNumTurnsSinceSomethingSent(int (*original)(CvDiplomacyAI*, PlayerTypes), CvDiplomacyAI* self, PlayerTypes ePlayer);CivRegisterBefore<CivHooks::CvDiplomacyAI_GetNumTurnsSinceSomethingSent>(host, &BeforeCvDiplomacyAI_GetNumTurnsSinceSomethingSent);CivRegisterAfter<CivHooks::CvDiplomacyAI_GetNumTurnsSinceSomethingSent>(host, &AfterCvDiplomacyAI_GetNumTurnsSinceSomethingSent);CivRegisterReplace<CivHooks::CvDiplomacyAI_GetNumTurnsSinceSomethingSent>(host, &ReplaceCvDiplomacyAI_GetNumTurnsSinceSomethingSent);

Code

24590#if defined(MOD_AI_MP_DIPLOMACY)24591/// How long has it been since we sent something?24592int CvDiplomacyAI::GetNumTurnsSinceSomethingSent(PlayerTypes ePlayer)24593{24594	CvAssertMsg(ePlayer >= 0, "DIPLOMACY_AI: Invalid Player Index.  Please send Jon this with your last 5 autosaves and what changelist # you're playing.");24595	CvAssertMsg(ePlayer < MAX_MAJOR_CIVS, "DIPLOMACY_AI: Invalid Player Index.  Please send Jon this with your last 5 autosaves and what changelist # you're playing.");24596	24597	int iMostRecentTurn = MAX_TURNS_SAFE_ESTIMATE;2459824599	int iLoopTurnNum;24600	DiploStatementTypes eLoopStatement;2460124602	for (int iI = 0; iI < MAX_DIPLO_LOG_STATEMENTS; iI++)24603	{24604		eLoopStatement = GetDiploLogStatementTypeForIndex(ePlayer, iI);2460524606		if (eLoopStatement != NO_DIPLO_STATEMENT_TYPE)24607		{24608			iLoopTurnNum = GetDiploLogStatementTurnForIndex(ePlayer, iI);2460924610			if (iMostRecentTurn == MAX_TURNS_SAFE_ESTIMATE || iLoopTurnNum > iMostRecentTurn)24611			{24612				iMostRecentTurn = iLoopTurnNum;2461324614				// Now break out, otherwise we'll find later entries and think it's been longer since we sent something than it really has been!24615				break;24616			}24617		}24618	}2461924620	return iMostRecentTurn;24621}

Calls

Called by