Bazaar developer reference

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

Defined in
CvDiplomacyAI.cpp, line 14978
Class
CvDiplomacyAI
Hook name
CivHooks::CvDiplomacyAI_DoGift

Hooks

static bool BeforeCvDiplomacyAI_DoGift(CvDiplomacyAI* self, PlayerTypes ePlayer, DiploStatementTypes& eStatement, CvDeal* pDeal);static void AfterCvDiplomacyAI_DoGift(CvDiplomacyAI* self, PlayerTypes ePlayer, DiploStatementTypes& eStatement, CvDeal* pDeal);static void ReplaceCvDiplomacyAI_DoGift(void (*original)(CvDiplomacyAI*, PlayerTypes, DiploStatementTypes&, CvDeal*), CvDiplomacyAI* self, PlayerTypes ePlayer, DiploStatementTypes& eStatement, CvDeal* pDeal);CivRegisterBefore<CivHooks::CvDiplomacyAI_DoGift>(host, &BeforeCvDiplomacyAI_DoGift);CivRegisterAfter<CivHooks::CvDiplomacyAI_DoGift>(host, &AfterCvDiplomacyAI_DoGift);CivRegisterReplace<CivHooks::CvDiplomacyAI_DoGift>(host, &ReplaceCvDiplomacyAI_DoGift);

Code

14977/// Possible Contact Statement - Gifrt14978void CvDiplomacyAI::DoGift(PlayerTypes ePlayer, DiploStatementTypes& eStatement, CvDeal* pDeal)14979{14980	CvAssertMsg(ePlayer >= 0, "DIPLOMACY_AI: Invalid Player Index.  Please send Jon this with your last 5 autosaves and what changelist # you're playing.");14981	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.");1498214983	if(eStatement == NO_DIPLO_STATEMENT_TYPE)14984	{14985		DiploStatementTypes eTempStatement = DIPLO_STATEMENT_GIFT;1498614987		// If a request was accepted or rejected, wait 60 turns. If we rolled for rand and failed, wait 15 turns before we try again14988		if(GetNumTurnsSinceStatementSent(ePlayer, eTempStatement) >= 60 &&14989		        GetNumTurnsSinceStatementSent(ePlayer, DIPLO_STATEMENT_GIFT_RANDFAILED) >= 15)14990		{14991			bool bRandPassed = false;	// This is used to see if we WOULD have made a gift, but the rand roll failed (so add an entry to the log)14992			bool bMakeGift = false;//IsMakeGift(ePlayer, pDeal, bRandPassed);1499314994			// Want to make a request of ePlayer? Pass pDeal in to see if there's actually anything we want14995			if(bMakeGift)14996			{14997				eStatement = eTempStatement;14998				pDeal->SetRequestingPlayer(GetPlayer()->GetID());14999			}1500015001			// 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 at15002			else15003				pDeal->ClearItems();1500415005			// Add this statement to the log so we don't evaluate it again until 15 turns has come back around15006			if(!bRandPassed)15007				DoAddNewStatementToDiploLog(ePlayer, DIPLO_STATEMENT_GIFT_RANDFAILED);15008		}15009	}15010}

Calls