Beispiel #1
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() );
			}

		}
	}
}
Beispiel #2
0
void COptionsManager::SystemConfigChanged(bool silent)
{
	//gEnv->pConsole->ExecuteString("sys_SaveCVars 1");
	//gEnv->pSystem->SaveConfiguration();
	//gEnv->pConsole->ExecuteString("sys_SaveCVars 0");

	if(m_pPlayerProfileManager)
	{
		UpdateToProfile();
		SaveProfile();
	}
	
	if(!silent)
	{
		if(CFlashMenuScreen *pCurrentMenu = GetCurrentMenu())
		{
			pCurrentMenu->Invoke("showErrorMessage", "Box1");
			CryFixedStringT<128> text = "@system_spec_";
			text.append(gEnv->pConsole->GetCVar("sys_spec")->GetString());
			pCurrentMenu->Invoke("setErrorText", text.c_str());
			text = "sys_spec_Full \0";
			text.append(gEnv->pConsole->GetCVar("sys_spec")->GetString());
			gEnv->pConsole->ExecuteString(text.c_str());
		}
	}
	UpdateFlashOptions();

}
Beispiel #3
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());
	}
}
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 ) );
}
int CGameStartup::Run(const char* autoStartLevelName)
{
	gEnv->pConsole->ExecuteString("exec autoexec.cfg");

	if (autoStartLevelName)
	{
		//load savegame
		if(CryStringUtils::stristr(autoStartLevelName, CRY_SAVEGAME_FILE_EXT) != 0)
		{
			CryFixedStringT<256> fileName (autoStartLevelName);
			// NOTE! two step trimming is intended!
			fileName.Trim(" ");  // first:  remove enclosing spaces (outside ")
			fileName.Trim("\""); // second: remove potential enclosing "
			gEnv->pGame->GetIGameFramework()->LoadGame(fileName.c_str());
		}
		else	//start specified level
		{
			CryFixedStringT<256> mapCmd ("map ");
			mapCmd+=autoStartLevelName;
			gEnv->pConsole->ExecuteString(mapCmd.c_str());
		}
	}
	else
	{
		gEnv->pConsole->ExecuteString("map example");
	}

#if CRY_PLATFORM_WINDOWS
	if (!(gEnv && gEnv->pSystem) || (!gEnv->IsEditor() && !gEnv->IsDedicated()))
	{
		::ShowCursor(FALSE);
		if (GetISystem()->GetIHardwareMouse())
			GetISystem()->GetIHardwareMouse()->DecrementCounter();
	}
#else
	if (gEnv && gEnv->pHardwareMouse)
		gEnv->pHardwareMouse->DecrementCounter();
#endif

#if !CRY_PLATFORM_DURANGO
	for(;;)
	{
		if (!Update(true, 0))
		{
			break;
		}
	}
#endif

	return 0;
}
bool CModInfoManager::LoadMod(const char* modName)
{
	CryFixedStringT<256> command;
	command.Format("g_loadMod %s", modName);
	gEnv->pConsole->ExecuteString(command.c_str());
	return true;
}
void CCheckpointSystem::WriteMetaData(EntityId checkpointId, XmlNodeRef parentNode, SCheckpointData &outMetaData)
{
	XmlNodeRef node = GetISystem()->CreateXmlNode(META_DATA_SECTION);

	const char *levelName = CCryAction::GetCryAction()->GetLevelName();
	CRY_ASSERT(levelName);
	CryFixedStringT<32> curlevelName = levelName;
	RepairLevelName(curlevelName);

	node->setAttr("Version", CHECKPOINT_VERSION_NUMBER);
	node->setAttr("LevelName", curlevelName.c_str());
	node->setAttr("CheckpointId", checkpointId);

	//write checkpoint name to be independent of entityId
	IEntity *pCheckpointEntity = gEnv->pEntitySystem->GetEntity(checkpointId);
	if(pCheckpointEntity)
		node->setAttr("CheckpointName", pCheckpointEntity->GetName());
	else
		node->setAttr("CheckpointName", "none");
	
	string timeString;
	GameUtils::timeToString(time(NULL), timeString);
	node->setAttr("Timestamp", timeString.c_str());

	parentNode->addChild(node);

	//write back metadata for listeners
	outMetaData.m_checkPointId = checkpointId;
	outMetaData.m_levelName = levelName;
	outMetaData.m_saveTime = timeString.c_str();
}
Beispiel #8
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());
}
Beispiel #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!");
		}
	}
}
Beispiel #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;
}
Beispiel #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);
	}
}
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();
	}
}
char const* const CAudioSystemImpl_sdlmixer::GetAudioFileLocation(SATLAudioFileEntryInfo* const pFileEntryInfo)
{
	static CryFixedStringT<MAX_AUDIO_FILE_PATH_LENGTH> sPath;
	sPath = m_sGameFolder.c_str();
	sPath += ms_sSDLSoundLibraryPath;

	return sPath.c_str();
}
Beispiel #14
0
SMMMigrateCompletedEvent::SMMMigrateCompletedEvent( CryFixedStringT<DISPLAY_NAME_LENGTH>& newServer, CrySessionID& sessionId )
{
	cry_strncpy( m_newServer, newServer.c_str(), sizeof(m_newServer) );
	sessionId->AsCStr( m_newSessionID, sizeof(m_newSessionID) );

	size = sizeof( SMMMigrateCompletedEvent );
	type = eMMTelE_MigrateCompleted;
}
Beispiel #15
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;
}
Beispiel #16
0
void COptionsManager::SetAntiAliasingMode(const char* params)
{
	if(params)
	{
		if(g_pGame->GetMenu())
		{
			CFlashMenuObject::FSAAMode mode = g_pGame->GetMenu()->GetFSAAMode(params);
			if(mode.samples == 0)
			{
				gEnv->pConsole->ExecuteString("r_fsaa 0");
				gEnv->pConsole->ExecuteString("r_fsaa_samples 0");
				gEnv->pConsole->ExecuteString("r_fsaa_quality 0");
			}
			else
			{
				gEnv->pConsole->ExecuteString("r_fsaa 1");	
				CryFixedStringT<32> command = "r_fsaa_samples ";
				char buffer[16];
				itoa(mode.samples, buffer, 10);
				command.append(buffer);
				gEnv->pConsole->ExecuteString(command.c_str());
				command = "r_fsaa_quality ";
				itoa(mode.quality, buffer, 10);
				command.append(buffer);
				gEnv->pConsole->ExecuteString(command.c_str());

				// FSAA requires HDR mode on, to get consistent menu settings we switch sys_spec_shading to 3 or 4
				// search for #LABEL_FSAA_HDR
				{
					bool bHDREnabled = gEnv->pRenderer->EF_Query(EFQ_HDRModeEnabled)!=0;

					if(!bHDREnabled)		// no HDR so we either have sys_spec_Shading in 1 or 2 or user
					{										// (it cannot be the machine is not capable of HDR as we have a list of FSAA modes)
						ICVar *pSpecShading = gEnv->pConsole->GetCVar("sys_spec_Shading");			assert(pSpecShading);

						if(pSpecShading)
							pSpecShading->Set(3);		// starting with mode 3 we have HDR on
					}
				}
			}
		}
	}
}
	virtual void ProcessEvent(EFlowEvent flowEvent, SActivationInfo *pActivationInfo)
	{
		if(flowEvent == eFE_Activate && IsPortActive(pActivationInfo, EIP_SetLimit))
		{
			const float fVal = GetPortFloat(pActivationInfo, EIP_Limit);
			CryFixedStringT<128> buf;
			buf.FormatFast("%g", fVal);
			g_pGameCVars->pAltitudeLimitCVar->ForceSet(buf.c_str());
		}
	}
Beispiel #18
0
void COptionsManager::CCVarSink::OnElementFound(ICVar *pCVar)
{
	if (pCVar == 0)
		return;

	CryFixedStringT<128> szLine = pCVar->GetName();
	CryFixedStringT<128> szValue = pCVar->GetString();

	// only save if we have an option to it
	std::map<string, SOptionEntry>::const_iterator iter = m_pOptionsManager->m_profileOptions.find(CONST_TEMP_STRING(pCVar->GetName()));
	if (iter == m_pOptionsManager->m_profileOptions.end())
		return;
	const SOptionEntry& entry = iter->second;
	if (entry.bWriteToConfig == false)
		return;

	size_t pos;

	// replace \ with \\ 
	pos = 1;
	for(;;)
	{
		pos = szValue.find_first_of("\\", pos);

		if (pos == CryFixedStringT<128>::npos)
		{
			break;
		}

		szValue.replace(pos, 1, "\\\\", 2);
		pos+=2;
	}

	// replace " with \" 
	pos = 1;
	for(;;)
	{
		pos = szValue.find_first_of("\"", pos);

		if (pos == CryFixedStringT<128>::npos)
		{
			break;
		}

		szValue.replace(pos, 1, "\\\"", 2);
		pos+=2;
	}

	if(pCVar->GetType()==CVAR_STRING)
		szLine += " = \"" + szValue + "\"\r\n";
	else
		szLine += " = " + szValue + "\r\n";

	fputs(szLine.c_str(), m_pFile);
}
void CCheckpointSystem::GetCurrentLevelCheckpoints(std::vector<string> &saveNames)
{
	//get current level
	const char *levelName = CCryAction::GetCryAction()->GetLevelName();
	CryFixedStringT<32> curlevelName = levelName;
	if(levelName)
		CCheckpointSystem::GetInstance()->RepairLevelName(curlevelName);

	//parse savegames fitting current level
	ParseSavedFiles(saveNames, curlevelName.c_str());
}
Beispiel #20
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;
}
Beispiel #21
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
}
static bool ModInfo_LoadFromXML(ModInfo* pMod, const XmlNodeRef& pRoot)
{
	ModInfo_FetchAttribute(&pMod->displayName, pRoot, "Name", "name");
	ModInfo_FetchAttribute(&pMod->author, pRoot, "Author", "name");
	CryFixedStringT<32> type;
	if (ModInfo_FetchAttribute(&type, pRoot, "Type", "name"))
		pMod->modType = ModInfoTypeFromString(type.c_str());
	ModInfo_FetchAttribute(&pMod->website, pRoot, "URL", "address");
	ModInfo_FetchAttribute(&pMod->versionMajor, pRoot, "Version", "major");
	ModInfo_FetchAttribute(&pMod->versionMinor, pRoot, "Version", "minor");
	ModInfo_FetchContent(&pMod->description, pRoot, "Description");
	return true;
}
Beispiel #23
0
SMMPlayerLeftMMEvent::SMMPlayerLeftMMEvent( SCryUserInfoResult* pUser, CrySessionID& id, int32 nCurrentPlayers, bool isLocal )
{
	CryFixedStringT<40> guid = pUser->m_userID.get()->GetGUIDAsString();

	CryLog( "MMTel: User guid %s", guid.c_str() );
	if( pUser->m_userID.get() )
	{
		cry_sprintf( m_guid, sizeof(m_guid), guid.c_str() );
	}
	else
	{
		m_guid[0]=0;
	}

	memcpy( m_userName, pUser->m_userName, sizeof(m_userName) );
	id->AsCStr( m_sessionID, sizeof(m_sessionID) );

	m_nCurrentPlayers = nCurrentPlayers;
	m_local = isLocal;

	size = sizeof( SMMPlayerLeftMMEvent );
	type = eMMTelE_PlayerLeftMM;
}
Beispiel #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();
}
Beispiel #25
0
void CFlowGraphModuleManager::ScanFolder(const string& folderName, bool bGlobal)
{
	_finddata_t fd;
	intptr_t handle = 0;
	ICryPak *pPak = gEnv->pCryPak;

	CryFixedStringT<512> searchString = folderName.c_str();
	searchString.append("*.*");

	handle = pPak->FindFirst(searchString.c_str(), &fd);

	CryFixedStringT<512> moduleName("");
	string newFolder("");

	if (handle > -1)
	{
		do
		{
			if (!strcmp(fd.name, ".") || !strcmp(fd.name, "..") || (fd.attrib & _A_HIDDEN))
				continue;

			if (fd.attrib & _A_SUBDIR)
			{
				newFolder = folderName;
				newFolder = newFolder + fd.name;
				newFolder = newFolder + "\\";
				ScanFolder(newFolder, bGlobal);
			}
			else
			{
				moduleName = fd.name;
				if(!strcmpi(PathUtil::GetExt(moduleName.c_str()), "xml"))
				{
					PathUtil::RemoveExtension(moduleName);
					PathUtil::MakeGamePath(folderName);

					// initial load: creates module, registers nodes
					CFlowGraphModule* pModule = PreLoadModuleFile(moduleName.c_str(), PathUtil::GetPath(folderName)+fd.name, bGlobal);
					// important: the module should be added using its internal name rather than the filename
					m_ModulesPathInfo.insert(TModulesPathInfo::value_type(pModule->GetName(), PathUtil::GetPath(folderName)+fd.name));
				}
			}

		} while (pPak->FindNext(handle, &fd) >= 0);

		pPak->FindClose(handle);
	}
}
//------------------------------------------------------------------------
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;
}
//------------------------------------------------------------------------
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;
}
Beispiel #28
0
//////////////////////////////////////////////////////////////////////////
// Session Quality Events
SMMPlayerJoinedEvent::SMMPlayerJoinedEvent( CryFixedStringT<CRYLOBBY_USER_NAME_LENGTH>& name, CryUserID& uid, SCryMatchMakingConnectionUID& conUID )
{
	if( uid.get() )
	{
		cry_sprintf( m_guid, sizeof(m_guid), uid.get()->GetGUIDAsString().c_str() );
	}
	else
	{
		m_guid[0]=0;
	}
	m_conUID = conUID;

	cry_sprintf( m_name, sizeof(m_name), name.c_str() );

	size = sizeof( SMMPlayerJoinedEvent );
	type = eMMTelE_PlayerJoined;
}
//------------------------------------------------------------------------
void CVehicleSeatActionRotateTurret::Serialize(TSerialize ser, EEntityAspects aspects)
{
	// MR: for network, only turret parts are serialized
	// for savegame, all parts are serialized (by CVehicle)
	if (ser.GetSerializationTarget() == eST_Network)
	{
		for (int i = 0; i < eVTRT_NumRotationTypes; ++i)
		{
			if (m_rotations[i].m_pPart)
			{
				m_rotations[i].m_pPart->Serialize(ser, aspects);
			}
		}
	}
	else
	{
		// save rotation details
		CryFixedStringT<16> tag;
		for (int i = 0; i < eVTRT_NumRotationTypes; ++i)
		{
			if (m_rotations[i].m_pPart)
			{
				Quat     q;
				Matrix34 currentTM = m_rotations[i].m_pPart->GetLocalBaseTM();
				if (ser.IsWriting())
					q = Quat(currentTM);

				tag = (i == eVTRT_Pitch) ? "rotation_pitch" : "rotation_yaw";
				ser.Value(tag.c_str(), q, 'ori1');

				if (ser.IsReading())
				{
					Matrix34 newTM(q);
					newTM.SetTranslation(currentTM.GetTranslation());
					m_rotations[i].m_pPart->SetLocalBaseTM(newTM);
					m_rotations[i].m_orientation.Set(q);
				}
			}
		}
	}
}
Beispiel #30
0
void CProfileOptions::CCVarSink::OnElementFound(ICVar *pCVar)
{
	if (pCVar == 0)
		return;

	const char* name = pCVar->GetName();
	const char* val = pCVar->GetString();

	COption* pOption = m_pOptions->GetOptionByCVar(name);
	if(!pOption)
		return;

	if(!pOption->IsWriteToConfig())
		return;

	const char* optionName = pOption->GetName().c_str();
	const char* writeValue = pOption->Get().c_str();

	const std::vector<SPendingOption>& pendingOptions = m_pOptions->GetPendingOptions();

	std::vector<SPendingOption>::const_iterator it = pendingOptions.begin();
	std::vector<SPendingOption>::const_iterator end = pendingOptions.end();

	for(; it!=end; ++it)
	{
		const SPendingOption& option = (*it);

		if(!option.writeToConfig)
			continue;

		if(option.command.compareNoCase(optionName))
			continue;

		writeValue = option.param.c_str();
		break;
	}

	CryFixedStringT<128> format;
	pOption->GetWriteToConfigString(format, pCVar, writeValue);
	fputs(format.c_str(), m_pFile);
}