Example #1
0
void CNetPlayerInput::Reset()
{
	CRY_TODO(24, 3, 2010, "Consider feeding into a timeout onto the inputs here");
	//SSerializedPlayerInput i(m_curInput);
	//i.leanl=i.leanr=i.sprint=false;
	//i.deltaMovement.zero();

	//DoSetState(i);

	//CHANGED_NETWORK_STATE(m_pPlayer, CPlayer::ASPECT_INPUT_CLIENT);
}
CWeaponStats::CWeaponStats()
{
	const int numStats = eWeaponStat_NumStats;
	for(int i=0; i<numStats; ++i)
	{
		SWeaponStatStoredData weaponStoredData;
		CRY_TODO(25,08,2010, "Dean - Remove setting weapon stat default value to 5 when all designer data is in");
		weaponStoredData.baseValue = MAX_STAT_VALUE / 2;
		weaponStoredData.totalValue = weaponStoredData.baseValue;
		m_weaponStats.push_back(weaponStoredData);
	}
}
void CPlayerVisTable::ClearRemovedEntities()
{
	for(VisEntryIndex i = 0; i < m_numUsedVisTableEntries; i++)
	{
		CRY_TODO(30,09,2009, "Prefetch to avoid cache misses");

		SVisTableEntry& visInfo = m_visTableEntries[i];

		if(visInfo.flags & eVF_Remove)
		{
			RemoveNthEntity(i);
		}
	}
}
VisEntryIndex CPlayerVisTable::GetEntityIndexFromID(EntityId entityId)
{
	CRY_TODO(30,09,2009, "Make faster");
	CryPrefetch(((char*)m_visTableEntries) + 128);

	for(VisEntryIndex i = 0; i < m_numUsedVisTableEntries; i++)
	{
		SVisTableEntry& visInfo = m_visTableEntries[i];

		if(m_visTableEntries[i].entityId == entityId)
		{
			return i;
		}		
	}

	return -1;
}
//------------------------------------------------------------------------
void CGameRulesKingOfTheHillObjective::OnChangedTeam( EntityId entityId, int oldTeamId, int newTeamId )
{
	BaseType::OnChangedTeam(entityId, oldTeamId, newTeamId);

	if ((g_pGame->GetIGameFramework()->GetClientActorId() == entityId) && newTeamId)
	{
		// Local player has changed teams, reset icons
		int currActiveIndex = -1;
		for (int i = 0; i < HOLD_OBJECTIVE_MAX_ENTITIES; ++ i)
		{
			SHoldEntityDetails *pDetails = &m_entities[i];
			if (pDetails->m_id)
			{
				SKotHEntity *pKotHEntity = static_cast<SKotHEntity *>(pDetails->m_pAdditionalData);
				CRY_ASSERT(pKotHEntity);

				pKotHEntity->m_needsIconUpdate = true;

				++currActiveIndex;
				if (pDetails->m_controllingTeamId == 1 || pDetails->m_controllingTeamId == 2)
				{
					CRY_TODO( 23,03,2010, "HUD: OnSiteCaptured events are being sent multiple times from multiple places. /FH");
					SHUDEvent siteIsCaptured(eHUDEvent_OnSiteCaptured);
					siteIsCaptured.eventIntData = currActiveIndex;
					siteIsCaptured.eventIntData2 = pDetails->m_controllingTeamId;
					CHUDEventDispatcher::CallEvent(siteIsCaptured);
				}

				IEntity *pEntity = gEnv->pEntitySystem->GetEntity(pDetails->m_id);
				if (pEntity)
				{
					IScriptTable *pScript = pEntity->GetScriptTable();
					if (pScript && pScript->GetValueType("LocalPlayerChangedTeam") == svtFunction)
					{
						IScriptSystem *pScriptSystem = gEnv->pScriptSystem;
						pScriptSystem->BeginCall(pScript, "LocalPlayerChangedTeam");
						pScriptSystem->PushFuncParam(pScript);
						pScriptSystem->EndCall();
					}
				}
			}
		}
	}
}
void CGameAchievements::GiveAchievement(int achievement)
{
	if(AllowAchievement())
	{
		CPersistantStats::GetInstance()->OnGiveAchievement(achievement);

		ICryLobby* pLobby = gEnv->pNetwork->GetLobby();
		IPlatformOS* pOS = gEnv->pSystem->GetPlatformOS();
		if(pLobby != NULL && pOS != NULL)
		{
			ICryReward* pReward = pLobby->GetReward();
			if(pReward)
			{
				unsigned int user = g_pGame->GetExclusiveControllerDeviceIndex();
				if(user != IPlatformOS::Unknown_User)
				{
					uint32 achievementId = achievement + ACHIEVEMENT_STARTINDEX;

					//-- Award() only puts awards into a queue to be awarded.
					//-- This code here only asserts that the award was added to the queue successfully, not if the award was successfully unlocked.
					//-- Function has been modified for a CryLobbyTaskId, callback and callback args parameters, similar to most other lobby functions,
					//-- to allow for callback to trigger when the award is successfully unlocked (eCLE_Success) or failed to unlock (eCLE_InternalError).
					//-- In the case of trying to unlock an award that has already been unlocked, the callback will return eCLE_Success.
					//-- Successful return value of the Award function has been changed from incorrect eCRE_Awarded to more sensible eCRE_Queued.
					CRY_TODO(3,9,2010, "Register a callback to inform game when queued award is processed successfully or failed.");

					ECryRewardError error = pReward->Award(user, achievementId, NULL, NULL, NULL);
					CryLog("Award error %d", error);
					CRY_ASSERT(error == eCRE_Queued);
				}
			}
		}
	}
	else
	{
		CryLog("Not Awarding achievement - have been disabled");
	}
}
//------------------------------------------------------------------------
void CGameRulesHoldObjectiveBase::DoAddEntityId(int type, EntityId entityId, int index, bool isNewEntity)
{
	CRY_ASSERT(index < HOLD_OBJECTIVE_MAX_ENTITIES);
	CryLog("CGameRulesHoldObjectiveBase::DoAddEntityId() received objective, eid=%i, index=%i", entityId, index);

	SHoldEntityDetails *pDetails = &m_entities[index];

	pDetails->m_id = entityId;

	if (m_spawnPOIType == eSPT_Avoid)
	{
		IGameRulesSpawningModule *pSpawningModule = g_pGame->GetGameRules()->GetSpawningModule();
		if (pSpawningModule)
		{
			pSpawningModule->AddAvoidPOI(entityId, m_spawnPOIDistance, true, AreObjectivesStatic());
		}
	}

	OnNewHoldEntity(pDetails, index);
	CCCPOINT(HoldObjective_AddEntity);

	gEnv->pEntitySystem->AddEntityEventListener(entityId, ENTITY_EVENT_ENTERAREA, this);
	gEnv->pEntitySystem->AddEntityEventListener(entityId, ENTITY_EVENT_LEAVEAREA, this);

	if (gEnv->bServer)
	{
		CHANGED_NETWORK_STATE(g_pGame->GetGameRules(), HOLD_OBJECTIVE_STATE_ASPECT);
	}

	if(isNewEntity)
	{
		//Not playing for the first time because it clashes with game start
		Announce("Incoming", k_announceType_CS_Incoming, m_shouldPlayIncomingAudio);
		m_shouldPlayIncomingAudio = true;
	}

	IEntity *pEntity = gEnv->pEntitySystem->GetEntity(entityId);
	if (pEntity)
	{
		IScriptTable *pScript = pEntity->GetScriptTable();
		CRY_TODO(11, 02, 2009, "function name from xml?");
		if (pScript)
		{
			if (pScript->GetValueType("ActivateCapturePoint") == svtFunction)
			{
				if (isNewEntity)
				{
					// Set flag to say we're expecting a trackview to start - so we can set the start position in the callback
					m_bExpectingMovieStart = true;

					if (!m_bAddedMovieListener)
					{
						if (gEnv->pMovieSystem)
						{
							CryLog("CGameRulesHoldObjectiveBase::CGameRulesHoldObjectiveBase() adding movie listener");
							gEnv->pMovieSystem->AddMovieListener(NULL, this);
							m_bAddedMovieListener = true;
						}
					}
				}

				IScriptSystem *pScriptSystem = gEnv->pScriptSystem;
				pScriptSystem->BeginCall(pScript, "ActivateCapturePoint");
				pScriptSystem->PushFuncParam(pScript);
				pScriptSystem->PushFuncParam(isNewEntity);
				pScriptSystem->EndCall();
			}
			SmartScriptTable propertiesTable;
			if (pScript->GetValue("Properties", propertiesTable))
			{
				pDetails->m_controlRadius = 5.f;
				propertiesTable->GetValue("ControlRadius", pDetails->m_controlRadius);
				pDetails->m_controlRadiusSqr = (pDetails->m_controlRadius * pDetails->m_controlRadius);
				pDetails->m_controlHeight = 5.f;
				propertiesTable->GetValue("ControlHeight", pDetails->m_controlHeight);
				pDetails->m_controlOffsetZ = 0.f;
				propertiesTable->GetValue("ControlOffsetZ", pDetails->m_controlOffsetZ);
			}
		}

		const IActor *pLocalPlayer = g_pGame->GetIGameFramework()->GetClientActor();
		if (pLocalPlayer != NULL && IsActorEligible(pLocalPlayer))
		{
			CheckLocalPlayerInside(pDetails, pEntity, pLocalPlayer->GetEntity());
		}
	}
}
//------------------------------------------------------------------------
void CGameRulesKingOfTheHillObjective::ClSiteChangedOwner( SHoldEntityDetails *pDetails, int oldTeamId )
{
	// Site has been captured
	CGameRules *pGameRules = g_pGame->GetGameRules();
	EntityId clientActorId = g_pGame->GetIGameFramework()->GetClientActorId();
	int localTeam = pGameRules->GetTeam(clientActorId);

	SKotHEntity *pKotHEntity = static_cast<SKotHEntity*>(pDetails->m_pAdditionalData);
	CRY_ASSERT(pKotHEntity);

	const int ownerTeamId = pDetails->m_controllingTeamId;
	if (ownerTeamId > 0)
	{
		ClSiteChangedOwnerAnnouncement(pDetails, clientActorId, ownerTeamId, localTeam);

		if (localTeam == ownerTeamId)
		{
			CCCPOINT(KingOfTheHillObjective_SiteCapturedByFriendlyTeam);
			if (!m_friendlyCaptureString.empty())
			{
				SHUDEventWrapper::GameStateNotify(m_friendlyCaptureString.c_str());
			}
			if (!m_gameStateFriendlyString.empty())
			{
				const char *localisedMessage = CHUDUtils::LocalizeString(m_gameStateFriendlyString.c_str());
				SHUDEventWrapper::OnGameStatusUpdate(eGBNFLP_Good, localisedMessage);
			}
		}
		else
		{
			CCCPOINT(KingOfTheHillObjective_SiteCapturedByEnemyTeam);
			if (!m_enemyCaptureString.empty())
			{
				SHUDEventWrapper::GameStateNotify(m_enemyCaptureString.c_str());
			}
			if (!m_gameStateEnemyString.empty())
			{
				const char *localisedMessage = CHUDUtils::LocalizeString(m_gameStateEnemyString.c_str());
				SHUDEventWrapper::OnGameStatusUpdate(eGBNFLP_Bad, localisedMessage);
			}
		}
	}
	else if (oldTeamId > 0)
	{
		if (localTeam == oldTeamId)
		{
			CCCPOINT(KingOfTheHillObjective_SiteLostByFriendlyTeam);
			if (!m_friendlyLostString.empty())
			{
				SHUDEventWrapper::GameStateNotify(m_friendlyLostString.c_str());
			}
		}
		else
		{
			CCCPOINT(KingOfTheHillObjective_SiteLostByEnemyTeam);
			if (!m_enemyLostString.empty())
			{
				SHUDEventWrapper::GameStateNotify(m_enemyLostString.c_str());
			}
		}

		if (!m_gameStateNeutralString.empty())
		{
			const char *localisedMessage = CHUDUtils::LocalizeString(m_gameStateNeutralString.c_str());
			SHUDEventWrapper::OnGameStatusUpdate(eGBNFLP_Neutral, localisedMessage);
		}
	}

	int currActiveIndex = -1;
	for (int i = 0; i < HOLD_OBJECTIVE_MAX_ENTITIES; i ++)
	{
		if( !m_entities[i].m_id)
		{
			continue;
		}
		++currActiveIndex;

		if( &m_entities[i] != pDetails )
		{
			continue;
		}

		CRY_TODO( 23,03,2010, "HUD: OnSiteCaptured events are being sent multiple times from multiple places. /FH");
		SHUDEvent siteIsCaptured(eHUDEvent_OnSiteCaptured);
		siteIsCaptured.eventIntData = currActiveIndex;
		siteIsCaptured.eventIntData2 = ownerTeamId;
		CHUDEventDispatcher::CallEvent(siteIsCaptured);
	}
}
Example #9
0
//-------------------------------------------------------------------------
// Process a search result.
void CGameBrowser::MatchmakingSessionSearchCallback(CryLobbyTaskID taskID, ECryLobbyError error, SCrySessionSearchResult* session, void* arg)
{
#ifdef USE_C2_FRONTEND
	CFlashFrontEnd *menu = g_pGame->GetFlashMenu();
	CMPMenuHub *mpMenuHub = menu ? menu->GetMPMenu() : NULL;
	CGameBrowser* pGameBrowser = (CGameBrowser*) arg;

	if (error == eCLE_SuccessContinue || error == eCLE_Success)
	{
		if(session && mpMenuHub != NULL && GameLobbyData::IsCompatibleVersion(GameLobbyData::GetSearchResultsData(session, LID_MATCHDATA_VERSION)))
		{
			CUIServerList::SServerInfo si;
			si.m_hostName     = session->m_data.m_name;

			CRY_TODO(20, 5, 2010, "In the case where too many servers have been filtered out, start a new search query and merge the results with the existing ones");
			int requiredDLCs = GameLobbyData::GetSearchResultsData(session, LID_MATCHDATA_REQUIRED_DLCS);
			CryLog("Found server (%s), num data (%d): with DLC version %d", si.m_hostName.c_str(), session->m_data.m_numData, requiredDLCs);
			if (g_pGameCVars->g_ignoreDLCRequirements || CDLCManager::MeetsDLCRequirements(requiredDLCs, g_pGame->GetDLCManager()->GetSquadCommonDLCs()) || pGameBrowser->m_bFavouriteIdSearch)
			{
				si.m_numPlayers   = session->m_numFilledSlots;
				si.m_maxPlayers   = session->m_data.m_numPublicSlots;
				si.m_gameTypeName = GameLobbyData::GetGameRulesFromHash(GameLobbyData::GetSearchResultsData(session, LID_MATCHDATA_GAMEMODE));
				si.m_gameTypeDisplayName = si.m_gameTypeName.c_str();
				si.m_mapName = GameLobbyData::GetMapFromHash(GameLobbyData::GetSearchResultsData(session, LID_MATCHDATA_MAP));
				si.m_mapDisplayName = PathUtil::GetFileName(si.m_mapName.c_str()).c_str();
				si.m_friends = (session->m_numFriends>0);
				si.m_reqPassword = session->m_flags&eCSSRF_RequirePassword;

				uint32 variantId = GameLobbyData::GetSearchResultsData(session, LID_MATCHDATA_VARIANT);
				CPlaylistManager *pPlaylistManager = g_pGame->GetPlaylistManager();
				if (pPlaylistManager)
				{
					const SGameVariant* pVariant = pPlaylistManager->GetVariant(variantId);
					if (pVariant)
					{
						si.m_gameVariantName = pVariant->m_name.c_str();
						si.m_gameVariantDisplayName = CHUDUtils::LocalizeString(pVariant->m_localName.c_str());
					}
				}

				// Get more readable map name and game type
				if (ILocalizationManager* pLocMgr = gEnv->pSystem->GetLocalizationManager())
				{
					si.m_mapDisplayName = CHUDUtils::LocalizeString(g_pGame->GetMappedLevelName(si.m_mapDisplayName.c_str()));

					CryFixedStringT<64> tmpString;
					tmpString.Format("ui_rules_%s", si.m_gameTypeName.c_str());
					SLocalizedInfoGame outInfo;
					if (pLocMgr->GetLocalizedInfoByKey(tmpString.c_str(), outInfo))
					{
						wstring wcharstr = outInfo.swTranslatedText;
						CryStringUtils::WStrToUTF8(wcharstr, si.m_gameTypeDisplayName);
					}
				}

#if USE_CRYLOBBY_GAMESPY
				int numData = session->m_data.m_numData;
				for (int i=0; i<numData; ++i)
				{
					SCryLobbyUserData& pUserData = session->m_data.m_data[i];
					if (pUserData.m_id == LID_MATCHDATA_FAVOURITE_ID)
					{
						CRY_ASSERT(pUserData.m_type == eCLUDT_Int32);
						if (pUserData.m_type == eCLUDT_Int32)
						{
							si.m_sessionFavouriteKeyId = pUserData.m_int32;
						}
					}
					else if ((pUserData.m_id == LID_MATCHDATA_REGION))
					{
						CRY_ASSERT(pUserData.m_type == eCLUDT_Int32);
						if (pUserData.m_type == eCLUDT_Int32)
						{
							si.m_region = pUserData.m_int32;
						}
					}
					else if ((pUserData.m_id == LID_MATCHDATA_OFFICIAL))
					{
						CRY_ASSERT(pUserData.m_type == eCLUDT_Int32);
						if (pUserData.m_type == eCLUDT_Int32)
						{
							si.m_official = (pUserData.m_int32!=0);
						}
					}
				}
#endif

				// FIXME :
				//   Make server id unique in some other way....
				si.m_serverId     = (int)session->m_id.get(); // for lack of unique ids deref the pointer location of the server. This is the id that gets sent to flash...
				si.m_sessionId    = session->m_id;
				si.m_ping         = session->m_ping;

				if (pGameBrowser->m_bFavouriteIdSearch)
				{
#if IMPLEMENT_PC_BLADES
					if (si.m_sessionFavouriteKeyId != INVALID_SESSION_FAVOURITE_ID)
					{
						for (uint32 i = 0; i < pGameBrowser->m_currentSearchFavouriteIdIndex; ++i)
						{
							if (si.m_sessionFavouriteKeyId == pGameBrowser->m_searchFavouriteIds[i])
							{
								g_pGame->GetGameServerLists()->ServerFound(si, pGameBrowser->m_currentFavouriteIdSearchType, si.m_sessionFavouriteKeyId);

								// Invalidate any current search favourite ids, as it has been found
								pGameBrowser->m_searchFavouriteIds[i] = INVALID_SESSION_FAVOURITE_ID;
								break;
							}
						}
					}
#endif
				}
				else
				{
					mpMenuHub->AddServer(si);
				}
			}
		}
	}
	else if (error != eCLE_SuccessUnreachable)
	{
		CryLogAlways("CGameBrowser search for sessions error %d", (int)error);
		CGameLobby::ShowErrorDialog(error, NULL, NULL, NULL);
	}

	if ((error != eCLE_SuccessContinue) && (error != eCLE_SuccessUnreachable))
	{
		CryLogAlways("CCGameBrowser::MatchmakingSessionSearchCallback DONE");

		pGameBrowser->FinishedSearch(true, !pGameBrowser->m_bFavouriteIdSearch); // FavouriteId might start another search after this one has finished
	}
#endif //#ifdef USE_C2_FRONTEND
}
//------------------------------------------------------------------------
void CGameRulesMPDamageHandling::ProcessVehicleDeath( const HitInfo &hitInfo )
{
	CRY_TODO(08, 09, 2009, "Implement ProcessVehicleDeath");
}