Bazaar developer reference

CvDiplomacyAI::DoRequest(PlayerTypes, DiploStatementTypes &, CvDeal *)

Defined in
CvDiplomacyAI.cpp, line 14943
Class
CvDiplomacyAI
Hook name
CivHooks::CvDiplomacyAI_DoRequest

Hooks

static bool BeforeCvDiplomacyAI_DoRequest(CvDiplomacyAI* self, PlayerTypes ePlayer, DiploStatementTypes& eStatement, CvDeal* pDeal);static void AfterCvDiplomacyAI_DoRequest(CvDiplomacyAI* self, PlayerTypes ePlayer, DiploStatementTypes& eStatement, CvDeal* pDeal);static void ReplaceCvDiplomacyAI_DoRequest(void (*original)(CvDiplomacyAI*, PlayerTypes, DiploStatementTypes&, CvDeal*), CvDiplomacyAI* self, PlayerTypes ePlayer, DiploStatementTypes& eStatement, CvDeal* pDeal);CivRegisterBefore<CivHooks::CvDiplomacyAI_DoRequest>(host, &BeforeCvDiplomacyAI_DoRequest);CivRegisterAfter<CivHooks::CvDiplomacyAI_DoRequest>(host, &AfterCvDiplomacyAI_DoRequest);CivRegisterReplace<CivHooks::CvDiplomacyAI_DoRequest>(host, &ReplaceCvDiplomacyAI_DoRequest);

Code

14942/// Possible Contact Statement - Request14943void CvDiplomacyAI::DoRequest(PlayerTypes ePlayer, DiploStatementTypes& eStatement, CvDeal* pDeal)14944{14945	CvAssertMsg(ePlayer >= 0, "DIPLOMACY_AI: Invalid Player Index.  Please send Jon this with your last 5 autosaves and what changelist # you're playing.");14946	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.");1494714948	if(eStatement == NO_DIPLO_STATEMENT_TYPE)14949	{14950		DiploStatementTypes eTempStatement = DIPLO_STATEMENT_REQUEST;1495114952		// If a request was accepted or rejected, wait 60 turns. If we rolled for rand and failed, wait 15 turns before we try again14953		if(GetNumTurnsSinceStatementSent(ePlayer, eTempStatement) >= 60 &&14954	       GetNumTurnsSinceStatementSent(ePlayer, DIPLO_STATEMENT_REQUEST_RANDFAILED) >= 15)14955		{14956			bool bRandPassed;	// This is used to see if we WOULD have made a request, but the rand roll failed (so add an entry to the log)14957			bool bMakeRequest = IsMakeRequest(ePlayer, pDeal, bRandPassed);1495814959			// Want to make a request of ePlayer? Pass pDeal in to see if there's actually anything we want14960			if(bMakeRequest)14961			{14962				eStatement = eTempStatement;14963				pDeal->SetRequestingPlayer(GetPlayer()->GetID());14964			}1496514966			// Clear out the deal if we don't want to offer it so that it's not tainted for the next trade possibility we look at14967			else14968				pDeal->ClearItems();1496914970			// Add this statement to the log so we don't evaluate it again until 15 turns has come back around14971			if(!bRandPassed)14972				DoAddNewStatementToDiploLog(ePlayer, DIPLO_STATEMENT_REQUEST_RANDFAILED);14973		}14974	}14975}

Calls

Called by