Bazaar developer reference

CvDiplomacyAI::GetNumTurnsSinceStatementSent(PlayerTypes, DiploStatementTypes)

Defined in
CvDiplomacyAI.cpp, line 24554
Class
CvDiplomacyAI
Hook name
CivHooks::CvDiplomacyAI_GetNumTurnsSinceStatementSent

Hooks

static bool BeforeCvDiplomacyAI_GetNumTurnsSinceStatementSent(CvDiplomacyAI* self, PlayerTypes ePlayer, DiploStatementTypes eDiploLogStatement, int& result);static void AfterCvDiplomacyAI_GetNumTurnsSinceStatementSent(CvDiplomacyAI* self, PlayerTypes ePlayer, DiploStatementTypes eDiploLogStatement, int& result);static int ReplaceCvDiplomacyAI_GetNumTurnsSinceStatementSent(int (*original)(CvDiplomacyAI*, PlayerTypes, DiploStatementTypes), CvDiplomacyAI* self, PlayerTypes ePlayer, DiploStatementTypes eDiploLogStatement);CivRegisterBefore<CivHooks::CvDiplomacyAI_GetNumTurnsSinceStatementSent>(host, &BeforeCvDiplomacyAI_GetNumTurnsSinceStatementSent);CivRegisterAfter<CivHooks::CvDiplomacyAI_GetNumTurnsSinceStatementSent>(host, &AfterCvDiplomacyAI_GetNumTurnsSinceStatementSent);CivRegisterReplace<CivHooks::CvDiplomacyAI_GetNumTurnsSinceStatementSent>(host, &ReplaceCvDiplomacyAI_GetNumTurnsSinceStatementSent);

Code

24553/// How long has it been since we sent eDiploLogStatement?24554int CvDiplomacyAI::GetNumTurnsSinceStatementSent(PlayerTypes ePlayer, DiploStatementTypes eDiploLogStatement)24555{24556	CvAssertMsg(ePlayer >= 0, "DIPLOMACY_AI: Invalid Player Index.  Please send Jon this with your last 5 autosaves and what changelist # you're playing.");24557	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.");24558	CvAssertMsg(eDiploLogStatement >= 0, "DIPLOMACY_AI: Invalid Diplo Log Statement Type.  Please send Jon this with your last 5 autosaves and what changelist # you're playing.");24559	CvAssertMsg(eDiploLogStatement < NUM_DIPLO_LOG_STATEMENT_TYPES, "DIPLOMACY_AI: Invalid Diplo Log Statement Type.  Please send Jon this with your last 5 autosaves and what changelist # you're playing.");2456024561	int iMostRecentTurn = MAX_TURNS_SAFE_ESTIMATE;2456224563	int iLoopTurnNum;24564	DiploStatementTypes eLoopStatement;2456524566	for(int iI = 0; iI < MAX_DIPLO_LOG_STATEMENTS; iI++)24567	{24568		eLoopStatement = GetDiploLogStatementTypeForIndex(ePlayer, iI);2456924570		if(eLoopStatement != NO_DIPLO_STATEMENT_TYPE)24571		{24572			if(eLoopStatement == eDiploLogStatement)24573			{24574				iLoopTurnNum = GetDiploLogStatementTurnForIndex(ePlayer, iI);2457524576				if(iMostRecentTurn == MAX_TURNS_SAFE_ESTIMATE || iLoopTurnNum > iMostRecentTurn)24577				{24578					iMostRecentTurn = iLoopTurnNum;2457924580					// Now break out, otherwise we'll find later entries and think it's been longer since we sent something than it really has been!24581					break;24582				}24583			}24584		}24585	}2458624587	return iMostRecentTurn;24588}

Calls

Called by

51 functions in 1 files