Bazaar developer reference

CvGame::GetWorldMilitaryStrengthAverage(PlayerTypes, bool, bool)

Defined in
CvGame.cpp, line 6799
Class
CvGame
Hook name
CivHooks::CvGame_GetWorldMilitaryStrengthAverage

Hooks

static bool BeforeCvGame_GetWorldMilitaryStrengthAverage(CvGame* self, PlayerTypes ePlayer, bool bIncludeMe, bool bIncludeOnlyKnown, int& result);static void AfterCvGame_GetWorldMilitaryStrengthAverage(CvGame* self, PlayerTypes ePlayer, bool bIncludeMe, bool bIncludeOnlyKnown, int& result);static int ReplaceCvGame_GetWorldMilitaryStrengthAverage(int (*original)(CvGame*, PlayerTypes, bool, bool), CvGame* self, PlayerTypes ePlayer, bool bIncludeMe, bool bIncludeOnlyKnown);CivRegisterBefore<CivHooks::CvGame_GetWorldMilitaryStrengthAverage>(host, &BeforeCvGame_GetWorldMilitaryStrengthAverage);CivRegisterAfter<CivHooks::CvGame_GetWorldMilitaryStrengthAverage>(host, &AfterCvGame_GetWorldMilitaryStrengthAverage);CivRegisterReplace<CivHooks::CvGame_GetWorldMilitaryStrengthAverage>(host, &ReplaceCvGame_GetWorldMilitaryStrengthAverage);

Code

6798/// Returns the Average Military Might of all Players in the game6799int CvGame::GetWorldMilitaryStrengthAverage(PlayerTypes ePlayer, bool bIncludeMe, bool bIncludeOnlyKnown)6800{6801	int iWorldMilitaryStrength = 0;6802	int iNumAlivePlayers = 0;68036804	// Look at our military strength relative to everyone else in the world6805	for(int iMajorLoop = 0; iMajorLoop < MAX_MAJOR_CIVS; iMajorLoop++)6806	{6807		if(GET_PLAYER((PlayerTypes) iMajorLoop).isAlive())6808		{6809			if(bIncludeMe || iMajorLoop != ePlayer)6810			{6811				if(!bIncludeOnlyKnown || (GET_TEAM(GET_PLAYER(ePlayer).getTeam()).isHasMet(GET_PLAYER((PlayerTypes) iMajorLoop).getTeam())))6812				{6813					iNumAlivePlayers++;6814					iWorldMilitaryStrength += GET_PLAYER((PlayerTypes) iMajorLoop).GetMilitaryMight();6815				}6816			}6817		}6818	}68196820	if(iNumAlivePlayers > 0)6821	{6822		iWorldMilitaryStrength /= iNumAlivePlayers;6823	}68246825	return iWorldMilitaryStrength;6826}

Calls

Called by