Bazaar developer reference

CvTeam::testCircumnavigated()

Defined in
CvTeam.cpp, line 6336
Class
CvTeam
Hook name
CivHooks::CvTeam_testCircumnavigated
Lua events
GameEvents.CircumnavigatedGlobe

Hooks

static bool BeforeCvTeam_testCircumnavigated(CvTeam* self);static void AfterCvTeam_testCircumnavigated(CvTeam* self);static void ReplaceCvTeam_testCircumnavigated(void (*original)(CvTeam*), CvTeam* self);CivRegisterBefore<CivHooks::CvTeam_testCircumnavigated>(host, &BeforeCvTeam_testCircumnavigated);CivRegisterAfter<CivHooks::CvTeam_testCircumnavigated>(host, &AfterCvTeam_testCircumnavigated);CivRegisterReplace<CivHooks::CvTeam_testCircumnavigated>(host, &ReplaceCvTeam_testCircumnavigated);

Code

6336void CvTeam::testCircumnavigated()6337{6338	CvPlot* pPlot;6339	CvString strBuffer;6340	bool bFoundVisible;6341	int iX, iY;63426343	if(isBarbarian())6344	{6345		return;6346	}63476348	CvGame& kGame = GC.getGame();6349	if(!kGame.circumnavigationAvailable())6350	{6351		return;6352	}63536354	CvMap& kMap = GC.getMap();63556356	// Test one of the wrapping axises.  This is brute force and not exactly "correct".6357	// It does not test for continuity and is not able to test whether the plot was revealed by exploration or6358	// some other method such as gifted "maps".6359	TeamTypes eTeamID = GetID();6360	if(kMap.isWrapX())6361	{6362		for(iX = kMap.getGridWidth(); iX--;)6363		{6364			bFoundVisible = false;63656366			for(iY = kMap.getGridHeight(); iY--;)6367			{6368				pPlot = kMap.plotUnchecked(iX, iY);63696370				if(pPlot->isRevealed(eTeamID))6371				{6372					bFoundVisible = true;6373					break;6374				}6375			}63766377			if(!bFoundVisible)6378			{6379				return;6380			}6381		}6382	}6383	else if(kMap.isWrapY())6384	{6385		for(iY = kMap.getGridHeight(); iY--;)6386		{6387			bFoundVisible = false;63886389			for(iX = kMap.getGridWidth(); iX--;)6390			{6391				pPlot = kMap.plotUnchecked(iX, iY);63926393				if(pPlot->isRevealed(GetID()))6394				{6395					bFoundVisible = true;6396					break;6397				}6398			}63996400			if(!bFoundVisible)6401			{6402				return;6403			}6404		}6405	}64066407	kGame.makeCircumnavigated();64086409	int iActivePlayerID = GC.getGame().getActivePlayer();64106411	if(kGame.getElapsedGameTurns() > 0)6412	{6413		int iFreeMoves = GC.getCIRCUMNAVIGATE_FREE_MOVES();6414		if(iFreeMoves != 0)6415			changeExtraMoves(DOMAIN_SEA, GC.getCIRCUMNAVIGATE_FREE_MOVES());64166417		for(int iI = 0; iI < MAX_PLAYERS; iI++)6418		{6419			CvPlayer& kPlayer = GET_PLAYER((PlayerTypes)iI);6420			if(kPlayer.isAlive())6421			{6422				if(eTeamID == kPlayer.getTeam())6423				{6424#if !defined(NO_ACHIEVEMENTS)6425					if(!kGame.isGameMultiPlayer() && kPlayer.isHuman())6426					{6427						gDLL->UnlockAchievement(ACHIEVEMENT_ROUND_WORLD);6428					}6429#endif6430				}64316432				if(iActivePlayerID == iI)6433				{6434					if(eTeamID == kPlayer.getTeam())6435					{6436						if(iFreeMoves == 0)6437							// Not the most ideal solution, but if the free moves are 0, use the string designed for telling about another team circling the globe6438							strBuffer = GetLocalizedText("TXT_KEY_MISC_SOMEONE_CIRC_GLOBE", kPlayer.getName());6439						else6440							strBuffer = GetLocalizedText("TXT_KEY_MISC_YOU_CIRC_GLOBE", iFreeMoves);6441					}6442					else if(isHasMet(kPlayer.getTeam()))6443					{6444						strBuffer = GetLocalizedText("TXT_KEY_MISC_SOMEONE_CIRC_GLOBE", getName().GetCString());6445					}6446					else6447					{6448						strBuffer = GetLocalizedText("TXT_KEY_MISC_UNKNOWN_CIRC_GLOBE");6449					}6450					DLLUI->AddMessage(0, ((PlayerTypes)iI), false, GC.getEVENT_MESSAGE_TIME(), strBuffer);64516452#if defined(MOD_EVENTS_CIRCUMNAVIGATION)6453					if (MOD_EVENTS_CIRCUMNAVIGATION) {6454						GAMEEVENTINVOKE_HOOK(GAMEEVENT_CircumnavigatedGlobe, eTeamID);6455						6456						// Notifications should now be sent via the event6457						// CvString strSummary = GetLocalizedText("TXT_KEY_NOTIFICATION_SUMMARY_CIRC_GLOBE");6458						// AddNotification(NOTIFICATION_GENERIC, strBuffer, strSummary, -1, -1, -1);6459					} else {6460#endif6461					ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem();6462					if (pkScriptSystem)6463					{6464						CvLuaArgsHandle args;6465						args->Push(eTeamID);64666467						bool bResult = false;6468						LuaSupport::CallHook(pkScriptSystem, "CircumnavigatedGlobe", args.get(), bResult);6469					}6470#if defined(MOD_EVENTS_CIRCUMNAVIGATION)6471					}6472#endif6473				}6474			}6475		}64766477		strBuffer = GetLocalizedText("TXT_KEY_MISC_SOMEONE_CIRC_GLOBE", getName().GetCString());6478		GC.getGame().addReplayMessage(REPLAY_MESSAGE_MAJOR_EVENT, getLeaderID(), strBuffer, -1, -1);6479	}6480}

Calls

Called by