void CSmartMine::FullSerialize( TSerialize ser )
{
	uint32 targetCount = m_trackedEntities.size();

	ser.Value( "MineEnabled", m_enabled );
	ser.Value( "MineFaction", m_factionId );
	ser.Value( "MineTargetCount", targetCount );

	CryFixedStringT<16> targetName;
	if (ser.IsReading())
	{
		m_trackedEntities.clear();
		for(uint32 i = 0; i < targetCount; ++i)
		{
			m_trackedEntities.push_back();
			targetName.Format( "MineTarget_%d", i );
			ser.Value( targetName.c_str(), m_trackedEntities[i] );
		}
	}
	else
	{
		for(uint32 i = 0; i < targetCount; ++i)
		{
			targetName.Format( "MineTarget_%d", i );
			ser.Value( targetName.c_str(), m_trackedEntities[i] );
		}
	}

	StateMachineSerializeBehavior( SStateEventSerialize( ser ) );
}
Example #2
0
void CDLCManager::OnDLCRemoved(const char* sDLCRootFolder)
{
	//clear all the data
	for( int iDLC = 0; iDLC < MAX_DLC_COUNT; iDLC++ )
	{
		if( IsDLCLoaded( iDLC ) )
		{
			if( strcmpi( m_dlcContents[iDLC].root.c_str(), sDLCRootFolder ) == 0 )
			{
				m_loadedDLCs &= ~BIT(iDLC);
				m_allowedDLCs &= ~BIT(iDLC);

				//close the paks
				CryFixedStringT<ICryPak::g_nMaxPath> path;

				path.Format("%s/dlcLevelExtras.pak", sDLCRootFolder);
				CryLog( "DLC: Closing %s", path.c_str() );
				gEnv->pCryPak->ClosePack( path.c_str() );

				path.Format("%s/dlcData.pak", sDLCRootFolder);
				CryLog( "DLC: Closing %s", path.c_str() );
				gEnv->pCryPak->ClosePack( path.c_str() );
			}

		}
	}
}
bool SUnlock::GetUnlockDisplayString( EUnlockType type, const char* name, CryFixedStringT<32>& outStr )
{
	// TODO: Setup Playlist unlocks and any others
	bool retval = false;

	switch( type )
	{
	case eUT_Weapon:
		{
			const CItemSharedParams* pItemShared = g_pGame->GetGameSharedParametersStorage()->GetItemSharedParameters( name, false );
			if( pItemShared )
			{
				outStr.Format( pItemShared->params.display_name.c_str() );
				retval = true;
			}
			break;
		}
	case eUT_CreateCustomClass:
		{
			CEquipmentLoadout *pEquipmentLoadout = g_pGame->GetEquipmentLoadout();
			if( pEquipmentLoadout )
			{
				const char* packageName = pEquipmentLoadout->GetPackageDisplayFromName( name );
				if( packageName )
				{
					outStr.Format( CHUDUtils::LocalizeString(packageName) );
					retval = true;
				}
			}

			break;
		}
	case eUT_Attachment:
		{
			const char* pAttachmentName = strstr(name, ".");
			if( pAttachmentName && pAttachmentName[0] )
			{	
				CEquipmentLoadout* pEquipmentLoadout = g_pGame->GetEquipmentLoadout();
				if( pEquipmentLoadout )
				{
					if( const CEquipmentLoadout::SEquipmentItem *pUnlockItem = pEquipmentLoadout->GetItemByName( pAttachmentName+1 ) )
					{
						outStr.Format( pUnlockItem->m_displayName.c_str() );
						retval = true;
					}
				}
			}
			break;
		}
	}

	return retval;
}
Example #4
0
void CGameStats::Report()
{
	if(!m_serverReport)
		return;

	int playerCount = m_playerMap.size();
	if (CGameServerNub * pServerNub = CCryAction::GetCryAction()->GetGameServerNub())
		playerCount = pServerNub->GetPlayerCount();

	//All server reporting is done here 
	m_serverReport->SetReportParams(playerCount,m_teamMap.size());
  m_serverReport->SetServerValue("gamemode",m_playing?"game":"pre-game");

	CryFixedStringT<32>  timeleft("-");
	if(IGameRulesSystem* pGR = gEnv->pGame->GetIGameFramework()->GetIGameRulesSystem())
	{
		IGameRules *pR = pGR->GetCurrentGameRules();
		if(pR && pR->IsTimeLimited() && m_playing)
		{
				timeleft.Format("%.0f",pR->GetRemainingGameTime());
		}
	}

	m_serverReport->SetServerValue("timeleft",timeleft);

	CryFixedStringT<256> tempStr;

	m_serverReport->SetServerValue("numplayers",tempStr.Format("%d",playerCount));
  
  int i=0;

	string mode;
  for(PlayerStatsMap::const_iterator it=m_playerMap.begin();it!=m_playerMap.end();++it)
	{
		static string value;
		m_serverReport->SetPlayerValue(i, "player", it->second.name);
		value.Format("%d",it->second.rank);
    m_serverReport->SetPlayerValue(i, "rank", value);
		value.Format("%d",it->second.team?it->second.team:(it->second.spectator?0:1));
    m_serverReport->SetPlayerValue(i, "team", value);
		for (std::map<string, int>::const_iterator sit=it->second.scores.begin(); sit!=it->second.scores.end(); ++sit)
			m_serverReport->SetPlayerValue(i, sit->first, tempStr.Format("%d",sit->second));
    ++i;
	}
	while (i < playerCount)
	{
		m_serverReport->SetPlayerValue(i, "player", "<connecting>");
		++i;
	}
}
void CRevertibleConfigLoader::RevertCVarChanges()
{
	if (!m_savedCVars.empty())
	{
		CryLog ("Need to undo %" PRISIZE_T " %s...", m_savedCVars.size(), (m_savedCVars.size() == 1) ? "variable" : "variables");
		IConsole * pConsole = gEnv->pConsole;
		CryFixedStringT<128> cmd;
		//Revert the saved cvars in reverse order to handle duplicate settings of the same cvar (which shouldn't be done but people ignore warnings)
		for (int n = m_savedCVars.size()-1; n >= 0; --n)
		{
			ICVar * var = gEnv->pConsole->GetCVar(m_savedCVars[n].m_name);
			
			if (var && var->GetType() == CVAR_STRING && strlen(m_savedCVars[n].m_value) == 0)
			{
				var->Set(m_savedCVars[n].m_value);
			}
			else
			{
				cmd.Format("%s %s", m_savedCVars[n].m_name, m_savedCVars[n].m_value);
			}
			
			pConsole->ExecuteString(cmd.c_str(), true);
		}

		m_cvarsTextBlock.EmptyWithoutFreeing();
		m_savedCVars.clear();
	}
}
bool CModInfoManager::LoadMod(const char* modName)
{
	CryFixedStringT<256> command;
	command.Format("g_loadMod %s", modName);
	gEnv->pConsole->ExecuteString(command.c_str());
	return true;
}
Example #7
0
//------------------------------------------------------------------------
int CScriptBind_Item::GetUsableText(IFunctionHandler *pH)
{
	CItem *pItem = GetItem(pH);
	if (!pItem)
		return pH->EndFunction();

	CryFixedWStringT<64> localizedString;
	CryFixedStringT<64> finalString;
	CryFixedStringT<64> tempString;

	tempString.Format("@ui_item_pickup %s", pItem->GetSharedItemParams()->params.display_name.c_str());
	localizedString = CHUDUtils::LocalizeStringW(tempString.c_str());
	finalString.Format("%ls", localizedString.c_str());

	return pH->EndFunction(finalString.c_str());
}
Example #8
0
void CAntiCheatManager::ParseAntiCheatConfig(const char * filename)
{
	CCryFile file;

	CryFixedStringT<128> realFileName;
	realFileName.Format("%s/%s", PathUtil::GetGameFolder().c_str(), filename);
	if (file.Open( realFileName.c_str(), "rb", ICryPak::FOPEN_HINT_QUIET | ICryPak::FOPEN_ONDISK ))
	{
		const size_t fileSize = file.GetLength();
		char* pBuffer = new char [fileSize];

		file.ReadRaw(pBuffer, fileSize);

		XmlNodeRef xmlData = gEnv->pSystem->LoadXmlFromBuffer(pBuffer, fileSize);

		SAFE_DELETE_ARRAY(pBuffer);

		if(xmlData)
		{
			CryLog("Parsing Anti-Cheat Configuration...");
			ParseAntiCheatConfig(xmlData);
		}
		else
		{
			CryLog("Unable to parse Anti-Cheat Configuration");
		}
	}
	else
	{
		CryLog("Unable to load '%s'", realFileName.c_str());
	}
}
Example #9
0
void CView::CreateAudioListener()
{
	if (m_pAudioListener == NULL)
	{
		SEntitySpawnParams oEntitySpawnParams;
		oEntitySpawnParams.sName  = "SoundListener";
		oEntitySpawnParams.pClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass("SoundListener");
		m_pAudioListener = gEnv->pEntitySystem->SpawnEntity(oEntitySpawnParams, true);

		if (m_pAudioListener != NULL)
		{
			m_pAudioListener->SetFlagsExtended(m_pAudioListener->GetFlagsExtended() | ENTITY_FLAG_EXTENDED_AUDIO_LISTENER);
			gEnv->pEntitySystem->AddEntityEventListener(m_pAudioListener->GetId(), ENTITY_EVENT_DONE, this);
			CryFixedStringT<64> sTemp;
			sTemp.Format("SoundListener(%d)", static_cast<int>(m_pAudioListener->GetId()));
			m_pAudioListener->SetName(sTemp.c_str());

			IEntityAudioProxyPtr pIEntityAudioProxy = crycomponent_cast<IEntityAudioProxyPtr>(m_pAudioListener->CreateProxy(ENTITY_PROXY_AUDIO));
			CRY_ASSERT(pIEntityAudioProxy.get());
		}
		else
		{
			CryFatalError("<Sound>: audio listener creation failed in CView ctor!");
		}
	}
}
Example #10
0
int DesignerWarningFunc(const char * message)
{
	if (g_pGameCVars->designer_warning_enabled && (!gEnv->IsDedicated()))
	{
		GameWarning("!DESIGNER WARNING\n%s", message);
	}

	// kept because autotests gather all designer warnings out of logs with this form
	CryLogAlways("---DESIGNER_WARNING: %s", message);
	CryLogAlways("----------------------------------------");

#if ENABLE_FEATURE_TESTER
	// If feature testing is in progress, write each designer warning out as a failed feature test

	CFeatureTester * featureTester = CFeatureTester::GetInstance();
	if (featureTester)
	{
		CAutoTester * autoTestResultWriter = featureTester->GetAutoTesterIfActive();
		if (autoTestResultWriter)
		{
			CryFixedStringT<32> warningName;
			warningName.Format("DesignerWarning%04u", s_numDesignerWarningsHit);
			autoTestResultWriter->AddSimpleTestCase("DesignerWarnings", warningName.c_str(), 0.1f, message);
		}
	}
#endif

	s_numDesignerWarningsHit++;
	return 0;
}
Example #11
0
void CView::CreateAudioListener()
{
	if (m_pAudioListener == nullptr)
	{
		SEntitySpawnParams oEntitySpawnParams;
		oEntitySpawnParams.sName  = "AudioListener";
		oEntitySpawnParams.pClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass("AudioListener");
		m_pAudioListener          = gEnv->pEntitySystem->SpawnEntity(oEntitySpawnParams, true);

		if (m_pAudioListener != nullptr)
		{
			// We don't want the audio listener to serialize as the entity gets completely removed and recreated during save/load!
			m_pAudioListener->SetFlags(m_pAudioListener->GetFlags() | (ENTITY_FLAG_TRIGGER_AREAS | ENTITY_FLAG_NO_SAVE));
			m_pAudioListener->SetFlagsExtended(m_pAudioListener->GetFlagsExtended() | ENTITY_FLAG_EXTENDED_AUDIO_LISTENER);
			gEnv->pEntitySystem->AddEntityEventListener(m_pAudioListener->GetId(), ENTITY_EVENT_DONE, this);
			CryFixedStringT<64> sTemp;
			sTemp.Format("AudioListener(%d)", static_cast<int>(m_pAudioListener->GetId()));
			m_pAudioListener->SetName(sTemp.c_str());

			IEntityAudioProxyPtr pIEntityAudioProxy = crycomponent_cast<IEntityAudioProxyPtr>(m_pAudioListener->CreateProxy(ENTITY_PROXY_AUDIO));
			CRY_ASSERT(pIEntityAudioProxy.get());
		}
		else
		{
			CryFatalError("<Audio>: Audio listener creation failed in CView::CreateAudioListener!");
		}
	}
	else
	{
		m_pAudioListener->SetFlagsExtended(m_pAudioListener->GetFlagsExtended() | ENTITY_FLAG_EXTENDED_AUDIO_LISTENER);
		m_pAudioListener->InvalidateTM(ENTITY_XFORM_POS);
	}
}
Example #12
0
void CItemComponent::GetSharedParameters(XmlNodeRef rootParams)
{
	// Parameters get stored under a combination of the class name and the section name for the parameters.
	CryFixedStringT<256> sharedName;
	sharedName.Format("item::%s::%s", GetEntity()->GetClass()->GetName(), "itemBase");

	ISharedParamsManager* pSharedParamsManager = gEnv->pGameFramework->GetISharedParamsManager();
	CRY_ASSERT(pSharedParamsManager);
	m_itemBaseParameter = CastSharedParamsPtr<SItemBaseParameter>(pSharedParamsManager->Get(sharedName));

	// If no parameter set exists we should attempt to create and register one.
	if (!m_itemBaseParameter)
	{
		SItemBaseParameter sharedParams;

		// Load in the base item shared parameters.
		XmlNodeRef itemBaseParams = rootParams->findChild("itemBase");
		if (itemBaseParams)
			sharedParams.Read(itemBaseParams);

		// Register a new set of parameters and retrieve a shared pointer to them.
		m_itemBaseParameter = CastSharedParamsPtr<SItemBaseParameter>(pSharedParamsManager->Register(sharedName, sharedParams));
	}

	// Double check the shared parameter.
	CRY_ASSERT(m_itemBaseParameter.get());
}
CryFixedStringT<64>	CPickAndThrowProxy::GetSharedParamsName() const
{
	const char* szEntityClassName = m_player.GetEntityClassName();
	CryFixedStringT<64>	sharedParamsName;
	sharedParamsName.Format("%s_%s", SPnTProxyParams::s_typeInfo.GetName(), szEntityClassName);

	return sharedParamsName;
}
Example #14
0
/*static*/
void CGameBrowser::LocaliseInGamePresenceString(CryFixedStringT<MAX_PRESENCE_STRING_SIZE> &out, const char* stringId, const int32 gameModeId, const int32 mapId)
{
#if USE_CRYLOBBY_GAMESPY
	out.Format("%s:%d:%d", stringId, gameModeId, mapId);
#else
	out = CHUDUtils::LocalizeString("@mp_rp_gameplay", GetGameModeStringFromId(gameModeId), GetMapStringFromId(mapId));
#endif
}
//------------------------------------------------------------------------
bool CVehicleDamageBehaviorEffect::Init(IVehicle *pVehicle, const CVehicleParams &table)
{
	m_pVehicle			= pVehicle;
	m_pDamageEffect	= NULL;
	m_slot					= -1;

	CVehicleParams	effectParams = table.findChild("Effect");

	if(!effectParams)
	{
		return false;
	}

	string								effectName = effectParams.getAttr("effect");

	CryFixedStringT<256>	sharedParamsName;

	sharedParamsName.Format("%s::DamageBehaviorEffect::%s", pVehicle->GetEntity()->GetClass()->GetName(), effectName.c_str());

	ISharedParamsManager	*pSharedParamsManager = CCryAction::GetCryAction()->GetISharedParamsManager();

	CRY_ASSERT(pSharedParamsManager);

	m_pSharedParams = CastSharedParamsPtr<SSharedParams>(pSharedParamsManager->Get(sharedParamsName));

	if(!m_pSharedParams)
	{
		SSharedParams	sharedParams;

		sharedParams.effectName = effectName;

		sharedParams.damageRatioMin = 1.0f;
		sharedParams.updateFromHelper = false;

		table.getAttr("damageRatioMin", sharedParams.damageRatioMin);

		sharedParams.disableAfterExplosion = false;

		effectParams.getAttr("disableAfterExplosion", sharedParams.disableAfterExplosion);

		effectParams.getAttr("updateFromHelper", sharedParams.updateFromHelper);

		m_pSharedParams = CastSharedParamsPtr<SSharedParams>(pSharedParamsManager->Register(sharedParamsName, sharedParams));
	}

	CRY_ASSERT(m_pSharedParams.get());

	return true;
}
Example #16
0
string STransition::GetDescription() const
{
	CryFixedStringT<256> sResult;
	sResult.Format("signal=%s\ttype=%s\tspeed=%s\tdir=%+3.1f\tarrdir=%+3.1f\ttargtdir=%+3.1f\tjukeAngle=%+3.1f", 
		animGraphSignal.c_str(), 
		MovementTransitionsDebug::GetTransitionTypeName(transitionType), 
		MovementTransitionsDebug::GetPseudoSpeedName(pseudoSpeed), 
		RAD2DEG(desiredTravelAngle), 
		RAD2DEG(desiredArrivalAngle),
		RAD2DEG(desiredTargetTravelAngle),
		RAD2DEG(desiredJukeAngle)
		);

	return sResult;
}
//------------------------------------------------------------------------
bool CPlaylistActivityTracker::CreatedGame( ILevelRotation::TExtInfoId playlistId, uint32 variantId )
{
    bool success = false;

    //ensure service is initialised
    if(! AnyActiveRequestsOfType( eRTT_AnnounceCreateGame ) )
    {
        //construct the http request
        CryFixedStringT<MAX_CONTENT> httpParams;

        httpParams.Format( "?platform=1&playlist=%d&variant=%d", playlistId, variantId );

        success = UploadData( "playlist/game_created/", httpParams.c_str(), 1024, eRTT_AnnounceCreateGame );
    }

    return success;
}
Example #18
0
void
CFlowInspectorDefault::DrawLabel( float col,float row,const ColorF& color,float glow,const char* szText,float fScale ) const
{
	const float ColumnSize = COL_SIZE;
	const float RowSize = ROW_SIZE;

	CryFixedStringT<128> msg;
	msg.Format("%s", szText ? szText : "No message");

	if (glow > 0.1f)
	{
		ColorF glowColor (color[0],color[1],color[2],glow);
		m_pRenderer->Draw2dLabel( (float)(ColumnSize*col+1),(float)(BASE_Y+RowSize*row+1), fScale*1.2f, &glowColor[0],false,"%s", msg.c_str() );
	}
	ColorF tmp (color);
	m_pRenderer->Draw2dLabel( (float)(ColumnSize*col),(float)(BASE_Y+RowSize*row), fScale*1.2f, &tmp[0], false,"%s", msg.c_str() );
}
//------------------------------------------------------------------------
bool CPlaylistActivityTracker::RequestCurrentActivity( PlayListActivityCallback callback )
{
    bool success = false;

    // Don't start another request if we're already waiting on one
    if( ! AnyActiveRequestsOfType( eRTT_RequestActivity ) )
    {
        CryFixedStringT<MAX_CONTENT> httpParams;
        httpParams.Format( "?platform=1");

        success = UploadData( "playlist/all_playlist_activity/", httpParams.c_str(), 4096, eRTT_RequestActivity );

        m_currentActivityCallback = callback;
    }

    return success;
}
Example #20
0
void CNetLerper::AddNewPoint(const Vec3& inPos, const Vec3& inVel, const Vec3& entityPos, EntityId standingOn)
{
	CRY_ASSERT(m_settings);

	m_desired.pos = inPos;
	m_desired.worldPos = inPos;
	m_standingOn = standingOn;
	if (IEntity* pGroundEntity = gEnv->pEntitySystem->GetEntity(standingOn))
	{
		m_desired.worldPos = pGroundEntity->GetWorldTM() * inPos;
	}
	
	// Run the desired velocity at slightly below the real velocity
	// helps to smooth the lerping since there is large granularity in
	// the network quantisation of the velocity
	m_desired.vel = inVel * 0.9f;

#if SNAP_ERROR_LOGGING
	if (m_snapErrorInProgress)
	{
		if ((m_pPlayer != NULL) && (!m_pPlayer->IsDead()))
		{
			CryFixedStringT<128> buffer;
			buffer.Format("[netlerper] prediction error ended for [%s] after %fs", m_pPlayer->GetEntity()->GetName(), m_clock);
#if ENABLE_STATOSCOPE
			if(gEnv->pStatoscope)
			{
				gEnv->pStatoscope->AddUserMarker("NetLerper", buffer.c_str());
			}
#endif // ENABLE_STATOSCOPE
			CryLog(buffer.c_str());
			m_snapErrorInProgress = false;
		}
	}
#endif // SNAP_ERROR_LOGGING

	// Zero clock and re calibrate the lerp error
	m_clock = 0.f;
	m_lerpedError = entityPos - m_desired.worldPos;
	m_lerpedPos = m_desired.worldPos;

	m_enabled = true;
}
Example #21
0
  void InitialiseScreenResolutions()
  {
    #if !defined(CONSOLE)
		
		CryFixedStringT<16> format;

		SDispFormat *formats = NULL;
		int numFormats = gEnv->pRenderer->EnumDisplayFormats(NULL);
		if(numFormats)
		{
			formats = new SDispFormat[numFormats];
			gEnv->pRenderer->EnumDisplayFormats(formats);
		}

		int lastWidth, lastHeight;
		lastHeight = lastWidth = -1;

		for(int i = 0; i < numFormats; ++i)
		{

			if(HasResolution(formats[i].m_Width, formats[i].m_Height))
			{
				continue;
			}

			if(formats[i].m_Width < 800)
				continue;

			format.Format("%i X %i", formats[i].m_Width, formats[i].m_Height);

			SScreenResolution resolution(formats[i].m_Width, formats[i].m_Height, formats[i].m_BPP, format.c_str());
			s_ScreenResolutions.push_back(resolution);

			lastHeight = formats[i].m_Height;
			lastWidth = formats[i].m_Width;
		}

		if(formats)
			delete[] formats;

    #endif
  }
Example #22
0
bool CDLCManager::VerifyCRCs(const XmlNodeRef &crcNode, const char* sDLCRootFolder)
{
	bool success = true;
	CryFixedStringT<ICryPak::g_nMaxPath> path;
	int numFiles = crcNode->getChildCount();
	XmlString fileName;
	uint32 storedCrc;
	for (int i=0; i<numFiles; ++i)
	{
		XmlNodeRef fileNode = crcNode->getChild(i);
		if (fileNode->getAttr("name", fileName) &&
			fileNode->getAttr("crc", storedCrc))
		{
			bool useCryFile = false;

#if defined(WIN32) || defined(WIN64)
			path.Format("%s/%s", sDLCRootFolder, fileName.c_str());
			useCryFile = true;
#else
			CryWarning( VALIDATOR_MODULE_GAME, VALIDATOR_ERROR, "No Platform defined in DLCManager" );
#endif
			CryLog( "CRC: Checking CRC of %s", path.c_str() );

			success = gEnv->pCryPak->OpenPack( path.c_str() );

			if( !success )
			{
					CryLog( "CRC: Failed to open pack" );
			}

			uint32 computedCrc = gEnv->pCryPak->ComputeCachedPakCDR_CRC( path.c_str(), useCryFile );
			if (computedCrc != storedCrc)
			{
				CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_WARNING, "CRC on file %s (%u) does not match stored value (%u)", path.c_str(), computedCrc, storedCrc);
				success = false;
			}
			gEnv->pCryPak->ClosePack( path.c_str() );
		}
	}
	return success;
}
Example #23
0
void CNetLerper::LogSnapError()
{
#if SNAP_ERROR_LOGGING
	if (!m_snapErrorInProgress)
	{
		if ((m_pPlayer != NULL) && (!m_pPlayer->IsDead()))
		{
			CryFixedStringT<128> buffer;
			buffer.Format("[netlerper] prediction error started for [%s]", m_pPlayer->GetEntity()->GetName());
#if ENABLE_STATOSCOPE
			if(gEnv->pStatoscope)
			{
				gEnv->pStatoscope->AddUserMarker("NetLerper", buffer.c_str());
			}
#endif // ENABLE_STATOSCOPE
			CryLog(buffer.c_str());
			m_snapErrorInProgress = true;
		}
	}
#endif // SNAP_ERROR_LOGGING
}
Example #24
0
int CScriptBind_Boids::GetUsableMessage(IFunctionHandler *pH, SmartScriptTable flockEntity)
{
	CFlock* flock = GetFlock(flockEntity);
	IActor* pActor = g_pGame->GetIGameFramework()->GetClientActor();

	if (pActor)
	{
		CPlayer* pPlayer = static_cast<CPlayer*>(pActor);

		CryFixedStringT<64> finalString;
		CryFixedStringT<64> tempString;

		if (pPlayer && !pPlayer->IsInPickAndThrowMode() && flock != NULL)
		{
			SBoidContext bc;
			flock->GetBoidSettings(bc);

			tempString.Format("@ui_boid_pickup %s", bc.pickableMessage);
			finalString = CHUDUtils::LocalizeString(tempString.c_str());
		}
		return pH->EndFunction(finalString.c_str());
	}
	return pH->EndFunction();
}
//------------------------------------------------------------------------
int CScriptBind_Game::CacheResource(IFunctionHandler *pH, const char* whoIsRequesting, const char* resourceName, int resourceType, int resourceFlags)
{
	//Only cache in pure game mode
	if (gEnv->IsEditor())
		return pH->EndFunction();

	CGameCache& gameCache = g_pGame->GetGameCache();

	switch(resourceType)
	{
	case eGCRT_Texture:
		{
			gameCache.CacheTexture(resourceName, resourceFlags);	

			LogLuaCacheResource(whoIsRequesting, "Texture", resourceName, resourceFlags);
		}	
		break;

	case eGCRT_TextureDeferredCubemap:
		{
			//Some magic strings ops Copy&Pasted from ScriptBind_Entity::ParseLightProperties
			const char* specularCubemap = resourceName;

			if (specularCubemap && strlen(specularCubemap) > 0)
			{
				CryFixedStringT<256> sSpecularName(specularCubemap);
				int strIndex = sSpecularName.find("_diff");
				if(strIndex >= 0)
				{
					sSpecularName = sSpecularName.substr(0, strIndex) + sSpecularName.substr(strIndex + 5, sSpecularName.length());
					specularCubemap = sSpecularName.c_str();
				}

				CryFixedStringT<256> diffuseCubemap;
				diffuseCubemap.Format("%s%s%s.%s",	PathUtil::AddSlash(PathUtil::GetPath(specularCubemap).c_str()).c_str(), 
													PathUtil::GetFileName(specularCubemap).c_str(), "_diff", PathUtil::GetExt(specularCubemap));

				// '\\' in filename causing texture duplication
				string specularCubemapUnix = PathUtil::ToUnixPath(specularCubemap);
				string diffuseCubemapUnix = PathUtil::ToUnixPath(diffuseCubemap.c_str());

				gameCache.CacheTexture(specularCubemapUnix.c_str(), resourceFlags);
				gameCache.CacheTexture(diffuseCubemapUnix.c_str(), resourceFlags);

				LogLuaCacheResource(whoIsRequesting, "CubeMap Specular", specularCubemapUnix.c_str(), resourceFlags);
				LogLuaCacheResource(whoIsRequesting, "CubeMap Diffuse", diffuseCubemapUnix.c_str(), resourceFlags);
			}
		}
		break;

	case eGCRT_StaticObject:
		{
			gameCache.CacheGeometry(resourceName);

			LogLuaCacheResource(whoIsRequesting, "Static Object", resourceName, resourceFlags);
		}
		break;

	case eGCRT_Material:
		{
			gameCache.CacheMaterial(resourceName);

			LogLuaCacheResource(whoIsRequesting, "Material", resourceName, resourceFlags);
		}
		break;
	}

	return pH->EndFunction();
}
Example #26
0
void COptionsManager::ResetDefaults(const char* option)
{
	if(!m_pPlayerProfileManager)
		return;

	const char* user = m_pPlayerProfileManager->GetCurrentUser();
	IPlayerProfile *pProfile = m_pPlayerProfileManager->GetCurrentProfile(user);
	if(!pProfile)
		return;
	XmlNodeRef root = GetISystem()->LoadXmlFile("libs/config/profiles/default/attributes.xml");
	bool resetAll = (option==NULL);
	bool detectHardware = false;
	for (int i = 0; i < root->getChildCount(); ++i)
	{
		XmlNodeRef enumNameNode = root->getChild(i);
		const char *name = enumNameNode->getAttr("name");
		const char *value = enumNameNode->getAttr("value");
		if(name && value)
		{
			const char* attribCVar = "";
			bool bWriteToCfg = false;
			const bool bIsOption = IsOption(name, attribCVar, bWriteToCfg);
			if(bIsOption)
			{
				if(!resetAll && strcmp(attribCVar,option))
					continue;

				if(!strcmp(attribCVar, "sys_spec_Shadows"))
				{
					detectHardware = true;
				}

				if(!strcmp(attribCVar, "hud_colorLine"))
				{
					CryFixedStringT<32> color;
					color.Format("%d", g_pGameCVars->hud_colorLine);
					SetCrysisProfileColor(color.c_str());
				}

				if(!strcmp(attribCVar,"pb_client"))
				{
					if(atoi(value)==0)
					{
						m_pbEnabled = false;
						gEnv->pConsole->ExecuteString("net_pb_cl_enable false");
					}
					else
					{
						m_pbEnabled = true;
						gEnv->pConsole->ExecuteString("net_pb_cl_enable true");
					}
				}
				else if(!strcmp(attribCVar, "g_difficultyLevel"))
				{
					SetDifficulty(value);
				}
				else
				{
					ICVar *pCVar = gEnv->pConsole->GetCVar(attribCVar);
					if(pCVar)
					{
						pCVar->Set(value);
					}
				}
				if(!resetAll)
					break;
			}
		}
	}
	if(detectHardware)
		AutoDetectHardware("");
}
Example #27
0
void CDownloadableResource::StartDownloading()
{
	if (m_state==k_notStarted)
	{
		if (m_port==0)
		{
			GameWarning("Error tried to start downloading on unconfigured CDownloadableResource");
			m_state=k_failedInternalError;
		}
		else
		{
			STCPServiceDataPtr		pTransaction(NULL);

			m_pService=gEnv->pNetwork->GetLobby()->GetLobbyService()->GetTCPService(m_server,m_port);
			if (m_pService)
			{
				static const int					MAX_HEADER_SIZE=300;
				CryFixedStringT<MAX_HEADER_SIZE>	httpHeader;

				// For HTTP 1.0.
				/*httpHeader.Format(
				"GET /%s%s HTTP/1.0\n"
				"\n",
				m_urlPrefix.c_str(),
				m_url.c_str());*/

				// For HTTP 1.1. Needed to download data from servers that are "multi-homed"
				httpHeader.Format(
					"GET /%s%s HTTP/1.1\n"
					"Host: %s:%d\n"
					"\n",
					m_urlPrefix.c_str(),
					m_url.c_str(),
					m_server.c_str(),
					m_port);

				pTransaction=new STCPServiceData();

				if (pTransaction)
				{
					int		len=httpHeader.length();
					pTransaction->length=len;
					pTransaction->pData=new char[len];
					if (pTransaction->pData)
					{
						memcpy(pTransaction->pData,httpHeader.c_str(),len);
						pTransaction->tcpServReplyCb=ReceiveDataCallback;
						pTransaction->pUserArg=this;		// do ref counting manually for callback data
						this->AddRef();
#if DOWNLOAD_MGR_DBG
						m_downloadStarted=gEnv->pTimer->GetAsyncCurTime();
#endif
						m_state=k_awaitingHTTPResponse;
						if (!m_pService->UploadData(pTransaction))
						{
							this->Release();
							pTransaction=NULL;
						}
					}
					else
					{
						pTransaction=NULL;
					}
				}
			}

			if (!pTransaction)
			{
				m_state=k_failedInternalError;
			}
		}
	}
}
Example #28
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
}
Example #29
0
//-----------------------------------------------------------------------
void CSpectacularKill::ReadXmlData( const IItemParamsNode* pRootNode)
{
	CRY_ASSERT(pRootNode);

	ISharedParamsManager* pSharedParamsManager = gEnv->pGame->GetIGameFramework()->GetISharedParamsManager();
	CRY_ASSERT(pSharedParamsManager);

	// If we change the SharedParamsManager to accept CRCs on its interface we could compute this once and store
	// the name's CRC32 instead of constructing it here each time this method is invoked (it shouldn't be invoked 
	// too often, though)
	const char* szEntityClassName = m_pOwner->GetEntityClassName();
	CryFixedStringT<64>	sharedParamsName;
	sharedParamsName.Format("%s_%s", SSharedSpectacularParams::s_typeInfo.GetName(), szEntityClassName);

	ISharedParamsConstPtr pSharedParams = pSharedParamsManager->Get(sharedParamsName);
	if (pSharedParams)
	{
		m_pParams = CastSharedParamsPtr<SSharedSpectacularParams>(pSharedParams);
		return;
	}

	m_pParams.reset();

	const IItemParamsNode* pParams = pRootNode->GetChild("SpectacularKill");
	if (pParams)
	{
		SSharedSpectacularParams newParams;

		const int childCount = pParams->GetChildCount();
		newParams.paramsList.reserve(childCount);

		for (int i = 0; i < childCount; ++i)
		{
			const IItemParamsNode* pTargetParams = pParams->GetChild(i);
			CRY_ASSERT(pTargetParams);

			IEntityClass* pTargetClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass(pTargetParams->GetName());
			if (pTargetClass)
			{
				SSpectacularKillParams targetParams;
				const IItemParamsNode* pChildParamsNode = pTargetParams->GetChild("Params");
				const IItemParamsNode* pChildAnimsNode = pTargetParams->GetChild("Anims");

				targetParams.pEnemyClass = pTargetClass;

				if(pChildParamsNode)
				{
					pChildParamsNode->GetAttribute("impulseScale", targetParams.impulseScale);

					const char* szImpulseBone = pChildParamsNode->GetAttributeSafe("impulseBone");
					ICharacterInstance* pCharacter = m_pOwner->GetEntity()->GetCharacter(0);
					targetParams.impulseBone = pCharacter ? pCharacter->GetIDefaultSkeleton().GetJointIDByName(szImpulseBone) : -1;
				}

				if(pChildAnimsNode)
				{
					const int animCount = pChildAnimsNode->GetChildCount();
					targetParams.animations.reserve(animCount);

					for(int j = 0; j < animCount; j++)
					{
						const IItemParamsNode* pAnimNode = pChildAnimsNode->GetChild(j);

						if(pAnimNode)
						{
							SSpectacularKillAnimation newAnimation;

							newAnimation.victimAnimation = pAnimNode->GetAttributeSafe("victimAnimation");
							newAnimation.killerAnimation = pAnimNode->GetAttributeSafe("killerAnimation");

							pAnimNode->GetAttribute("optimalDist", newAnimation.optimalDist);

							if (pAnimNode->GetAttribute("targetToKillerAngle", newAnimation.targetToKillerAngle))
								newAnimation.targetToKillerAngle = DEG2RAD(newAnimation.targetToKillerAngle);

							if (pAnimNode->GetAttribute("targetToKillerAngleRange", newAnimation.targetToKillerMinDot))
								newAnimation.targetToKillerMinDot = cos_tpl(DEG2RAD(newAnimation.targetToKillerMinDot) / 2.0f);

							pAnimNode->GetAttribute("obstacleCheckStartOffset", newAnimation.vKillerObstacleCheckOffset);
							pAnimNode->GetAttribute("obstacleCheckLength", newAnimation.fObstacleCheckLength);

							targetParams.animations.push_back(newAnimation);
						}
					}
				}

				CRY_ASSERT_MESSAGE(targetParams.animations.size() > 0, string().Format("No Animations defined for %s spectacular kill", pTargetClass->GetName()));

				newParams.paramsList.push_back(targetParams);
			}
#ifdef SPECTACULAR_KILL_DEBUG
			else
			{
				GameWarning("spectacular Kill: Couldn't find entity of class '%s', skipping", pTargetParams->GetName());
			}
#endif
		}

		m_pParams = CastSharedParamsPtr<SSharedSpectacularParams>(pSharedParamsManager->Register(sharedParamsName, newParams));
	}
}
Example #30
0
const char* CFlowGraphModuleManager::GetCallerNodeName(const char* moduleName) const
{
	static CryFixedStringT<64> temp;
	temp.Format("Module:Call_%s", moduleName);
	return temp.c_str();
}