Bazaar developer reference

CvDiplomacyAI::DoFirstContact(PlayerTypes)

Defined in
CvDiplomacyAI.cpp, line 10333
Class
CvDiplomacyAI
Hook name
CivHooks::CvDiplomacyAI_DoFirstContact

Hooks

static bool BeforeCvDiplomacyAI_DoFirstContact(CvDiplomacyAI* self, PlayerTypes ePlayer);static void AfterCvDiplomacyAI_DoFirstContact(CvDiplomacyAI* self, PlayerTypes ePlayer);static void ReplaceCvDiplomacyAI_DoFirstContact(void (*original)(CvDiplomacyAI*, PlayerTypes), CvDiplomacyAI* self, PlayerTypes ePlayer);CivRegisterBefore<CivHooks::CvDiplomacyAI_DoFirstContact>(host, &BeforeCvDiplomacyAI_DoFirstContact);CivRegisterAfter<CivHooks::CvDiplomacyAI_DoFirstContact>(host, &AfterCvDiplomacyAI_DoFirstContact);CivRegisterReplace<CivHooks::CvDiplomacyAI_DoFirstContact>(host, &ReplaceCvDiplomacyAI_DoFirstContact);

Code

10332/// First contact between this player and another10333void CvDiplomacyAI::DoFirstContact(PlayerTypes ePlayer)10334{10335	CvAssertMsg(ePlayer >= 0, "DIPLOMACY_AI: Invalid Player Index.  Please send Jon this with your last 5 autosaves and what changelist # you're playing.");10336	CvAssertMsg(ePlayer < MAX_CIV_PLAYERS, "DIPLOMACY_AI: Invalid Player Index.  Please send Jon this with your last 5 autosaves and what changelist # you're playing.");1033710338	if(ePlayer != GetPlayer()->GetID())10339	{10340		DoFirstContactInitRelationship(ePlayer);1034110342		//// Major Civ10343		//if (!GET_PLAYER(ePlayer).isMinorCiv())10344		//{10345		//	SetPlayerMilitaryStrengthComparedToUs(ePlayer, STRENGTH_AVERAGE);10346		//	SetMajorCivApproach(ePlayer, MAJOR_CIV_APPROACH_NEUTRAL);10347		//	SetMajorCivOpinion(ePlayer, MAJOR_CIV_OPINION_NEUTRAL);10348		//}10349		//// Minor Civ10350		//else10351		//	SetMinorCivApproach(ePlayer, MINOR_CIV_APPROACH_IGNORE);1035210353		// Default States, will be updated on turn cycling10354		//SetPlayerTargetValue(ePlayer, TARGET_VALUE_AVERAGE);1035510356#if defined(MOD_AI_MP_DIPLOMACY)10357		if (MOD_AI_MP_DIPLOMACY) {10358			// JdH => notifications do get send in MP + updated to new send request behaviour10359			if (GC.getGame().isFinalInitialized())10360			{10361				if (!IsAtWar(ePlayer) && CvPreGame::isHuman(ePlayer))10362				{10363#if defined(MOD_DIPLOMACY_STFU)10364					SendAILeaderMessage(GetPlayer()->GetID(), ePlayer, DIPLO_UI_STATE_DEFAULT_ROOT, DIPLO_MESSAGE_INTRO, LEADERHEAD_ANIM_INTRO);10365#else10366					const char* szText = GetDiploStringForMessage(DIPLO_MESSAGE_INTRO);10367#if defined(MOD_API_PLAYER_LOGS)10368					CvDiplomacyRequests::SendRequest(GetPlayer()->GetID(), ePlayer, DIPLO_UI_STATE_DEFAULT_ROOT, DIPLO_MESSAGE_INTRO, szText, LEADERHEAD_ANIM_INTRO);10369#else10370					CvDiplomacyRequests::SendRequest(GetPlayer()->GetID(), ePlayer, DIPLO_UI_STATE_DEFAULT_ROOT, szText, LEADERHEAD_ANIM_INTRO);10371#endif10372#endif10373				}10374			}10375		} else {10376#endif10377		// Humans don't say hi to one another through the shadow diplo AI and, uh, don't show up in MP please10378		if(!GC.getGame().isNetworkMultiPlayer())	// KWG: Candidate for !GC.getGame().IsOption(GAMEOPTION_SIMULTANEOUS_TURNS)10379		{10380			if(!GetPlayer()->isHuman())10381			{10382				// Should fire off a diplo message when we meet a human10383				if(GET_PLAYER(ePlayer).isHuman())10384				{10385					if(!IsAtWar(ePlayer))10386					{10387						if(GC.getGame().isFinalInitialized())10388						{10389							if(std::find(m_aGreetPlayers.begin(), m_aGreetPlayers.end(), ePlayer) == m_aGreetPlayers.end())10390							{10391								// Put in the list of people to greet when their turn comes up.10392								m_aGreetPlayers.push_back(ePlayer);10393							}10394						}10395					}10396				}10397			}10398			else10399			{10400				// Human to Human will just send a notification10401				CvPlayer& kTargetPlayer = GET_PLAYER(ePlayer);10402				if(kTargetPlayer.isHuman())10403				{10404					if(!IsAtWar(ePlayer))10405					{10406						if(GC.getGame().isFinalInitialized())10407						{10408							CvNotifications* pNotifications = kTargetPlayer.GetNotifications();10409							if(pNotifications)10410							{10411								CvString strBuffer = GetLocalizedText("TXT_KEY_NOTIFICATION_SUMMARY_MET_MINOR_CIV", GetPlayer()->getNameKey());10412								pNotifications->Add(NOTIFICATION_GENERIC, strBuffer, strBuffer, -1, -1, GetPlayer()->GetID());10413							}10414						}10415					}10416				}10417			}10418		}10419#if defined(MOD_AI_MP_DIPLOMACY)10420		}10421#endif1042210423		// Catch up on public declarations this player has made1042410425		if(!GET_PLAYER(ePlayer).isMinorCiv())10426		{10427			PublicDeclarationTypes eDeclaration;10428			int iData1;10429			int iData2;10430			PlayerTypes eMustHaveMetPlayer;10431			bool bActive;1043210433			for(int iLoop = 0; iLoop < MAX_DIPLO_LOG_STATEMENTS; iLoop++)10434			{10435				eDeclaration = GetDeclarationLogTypeForIndex(iLoop);1043610437				// Does this entry in the log exist?10438				if(eDeclaration != NO_PUBLIC_DECLARATION_TYPE)10439				{10440					bActive = IsDeclarationLogForIndexActive(iLoop);1044110442					iData1 = GetDeclarationLogData1ForIndex(iLoop);10443					iData2 = GetDeclarationLogData2ForIndex(iLoop);1044410445					// Validate active status - minors must be alive10446					if(eDeclaration == PUBLIC_DECLARATION_PROTECT_MINOR)10447					{10448						CvAssert(((PlayerTypes) iData1) != NO_PLAYER);10449						if(((PlayerTypes) iData1) != NO_PLAYER)10450						{10451							if(!GET_PLAYER((PlayerTypes) iData1).isAlive())10452								bActive = false;10453						}10454					}10455					else if(eDeclaration == PUBLIC_DECLARATION_ABANDON_MINOR)10456					{10457						CvAssert(((PlayerTypes) iData1) != NO_PLAYER);10458						if(((PlayerTypes) iData1) != NO_PLAYER)10459						{10460							if(!GET_PLAYER((PlayerTypes) iData1).isAlive())10461								bActive = false;10462						}10463					}1046410465					// Is this still an active Declaration?10466					if(bActive)10467					{10468						eMustHaveMetPlayer = GetDeclarationLogMustHaveMetPlayerForIndex(iLoop);1046910470						DoMakePublicDeclaration(eDeclaration, iData1, iData2, eMustHaveMetPlayer, ePlayer);10471					}10472				}10473			}10474		}10475	}10476}

Calls

Called by