Example #1
0
bool CEntityPoolSignature::CalculateFromEntity(CEntity *pEntity)
{
	FUNCTION_PROFILER(GetISystem(), PROFILE_ENTITY);
	LOADING_TIME_PROFILE_SECTION(GetISystem());

	assert(pEntity);

	if (!m_bGenerated && pEntity)
	{
		m_bGenerated = true;

		ISerialize *pWriter = m_pSignatureSerializer->GetWriter(m_Signature);
		TSerialize signatureWriter(pWriter);

		m_bGenerated &= pEntity->GetSignature(signatureWriter);

		if (!m_bGenerated)
		{
			m_Signature->removeAllChilds();
			m_Signature->removeAllAttributes();
		}
	}

	return m_bGenerated;
}
Example #2
0
/* virtual */ bool CDialogSystem::ReloadScripts(const char *levelName)
{
	LOADING_TIME_PROFILE_SECTION(gEnv->pSystem);

	ReleaseSessions();
	ReleaseScripts();

	bool bSuccessOld = false;
	bool bSuccessNew = false;

	// load old excel based dialogs
	if (sLoadExcelScripts) 
	{
		CDialogLoader loader (this);

		string path = DIALOG_LIBS_PATH_EXCEL;
		bSuccessOld = loader.LoadScriptsFromPath(path, m_dialogScriptMap);
	}

	// load new DialogEditor based dialogs
	{
		CDialogLoaderMK2 loader (this);

		const string path = DIALOG_LIBS_PATH_MK2;
		bSuccessNew = loader.LoadScriptsFromPath(path, m_dialogScriptMap, levelName);
		
		if (!gEnv->IsEditor())
		{
			bSuccessNew |= loader.LoadScriptsFromPath(path, m_dialogScriptMap, "All_Levels");
		}
	}

	return bSuccessOld || bSuccessNew;
}
void CToolboxApplication::LoadLevel(const char *levelName)
{
	LOADING_TIME_PROFILE_SECTION(gEnv->pSystem);

	GetISystem()->GetISystemEventDispatcher()->OnSystemEvent(ESYSTEM_EVENT_LEVEL_LOAD_START, 0, 0);

	CryLogAlways("Loading level %s", levelName);

	CryLogAlways("Finished level %s", levelName);

	GetISystem()->GetISystemEventDispatcher()->OnSystemEvent(ESYSTEM_EVENT_LEVEL_LOAD_END, 0, 0);

	m_bLoadedLevel = true;
}
void CToolboxApplication::CreateLevel(const char *levelName)
{
	LOADING_TIME_PROFILE_SECTION(gEnv->pSystem);

	CryLogAlways("Creating empty level %s", levelName);

	string levelPath = PathUtil::GetGameFolder().append("/Levels/").append(levelName).append("/");
	string editorFile = levelPath.append(levelName).append(".tbx");

	gEnv->pCryPak->MakeDir(levelPath, true);

	XmlNodeRef todRoot = GetISystem()->LoadXmlFromFile("Toolbox/default_time_of_day.tod");
	if(todRoot)
	{
		ITimeOfDay *pTimeOfDay = gEnv->p3DEngine->GetTimeOfDay();
		pTimeOfDay->Serialize(todRoot, true);
		pTimeOfDay->SetTime(12.0f, true);
	}

	// Reset systems
	{
		gEnv->pEntitySystem->Reset();
		gEnv->p3DEngine->UnloadLevel();
		gEnv->pPhysicalWorld->SetupEntityGrid(2, Vec3(ZERO), 128, 128, 4, 4, 1);
	}

	if(!gEnv->p3DEngine->InitLevelForEditor(levelPath, ""))
	{
		ToolboxWarning("Failed to initialize level");
		return;
	}

	STerrainInfo terrainInfo;

	terrainInfo.nHeightMapSize_InUnits = terrainInfo.nSectorSize_InMeters = 256;
	terrainInfo.nUnitSize_InMeters = 1;
	terrainInfo.nSectorsTableSize_InSectors = 1;
	terrainInfo.fHeightmapZRatio = 0.003f;
	terrainInfo.fOceanWaterLevel = 20;

	gEnv->p3DEngine->CreateTerrain(terrainInfo);

	XmlNodeRef environmentRoot = GetISystem()->LoadXmlFromFile("Toolbox/default_environment_settings.xml");
	gEnv->p3DEngine->LoadEnvironmentSettingsFromXML(environmentRoot);

	GetISystem()->GetISystemEventDispatcher()->OnSystemEvent(ESYSTEM_EVENT_LEVEL_LOAD_END, 0, 0);

	m_bLoadedLevel = true;
}
Example #5
0
bool CEntityPoolSignature::CompareSignature(const CEntityPoolSignature& otherSignature) const
{
	FUNCTION_PROFILER(GetISystem(), PROFILE_ENTITY);
	LOADING_TIME_PROFILE_SECTION(GetISystem());

	bool bResult = false;

	if (m_bGenerated)
	{
		// Perform quick test first
		//if (m_uTestMask == otherSignature.m_uTestMask)
		{
			// Perform in-depth test using serialization objects
			bResult = CompareNodes(m_Signature, otherSignature.m_Signature);
		}
	}

	return bResult;
}
void CGameTokenSystem::LoadLibs( const char *sFileSpec )
{
	LOADING_TIME_PROFILE_SECTION(GetISystem());

	ICryPak *pPak = gEnv->pCryPak;
	_finddata_t fd;
	string dir = PathUtil::GetPath(sFileSpec);
	intptr_t handle = pPak->FindFirst( sFileSpec,&fd );
	if (handle != -1)
	{
		int res = 0;
		do {
			_InternalLoadLibrary( PathUtil::Make(dir,fd.name), "GameTokensLibrary" );
			res = pPak->FindNext( handle,&fd );
		} 
		while (res >= 0);
		pPak->FindClose(handle);
	}
}
Example #7
0
IGameRef CGameStartup::Init(SSystemInitParams &startupParams)
{
	MEMSTAT_CONTEXT(EMemStatContextTypes::MSC_Other, 0, "Game startup initialization");

	LOADING("game_startup");

	if (!InitFramework(startupParams))
	{
		return 0;
	}

	// Configuration for this game
	ICVar *pCVar = gEnv->pConsole->GetCVar("ai_CompatibilityMode");
	if (pCVar)
		pCVar->Set("crysis");

  LOADING_TIME_PROFILE_SECTION(m_pFramework->GetISystem());

	ISystem* pSystem = m_pFramework->GetISystem();
	IConsole* pConsole = gEnv->pConsole;
	startupParams.pSystem = pSystem;

#if defined(ENABLE_STATS_AGENT)
	const ICmdLineArg *pPipeArg = pSystem->GetICmdLine()->FindArg(eCLAT_Pre,"lt_pipename");
	CStatsAgent::CreatePipe( pPipeArg );
#endif

	PluginManager::InitPluginManager(startupParams);
    PluginManager::InitPluginsBeforeFramework();

	REGISTER_COMMAND("g_loadMod", RequestLoadMod,VF_NULL,"");

	// load the appropriate game/mod
	const ICmdLineArg *pModArg = pSystem->GetICmdLine()->FindArg(eCLAT_Pre,"MOD");

	IGameRef pOut;
	if (pModArg && (*pModArg->GetValue() != 0) && (pSystem->IsMODValid(pModArg->GetValue())))
	{
		const char* pModName = pModArg->GetValue();
		assert(pModName);

		pOut = Reset(pModName);
	}
	else
	{
		pOut = Reset(GAME_NAME);
	}

	// Load all localized strings.
	LoadLocalizationData();

	if (!m_pFramework->CompleteInit())
	{
		pOut->Shutdown();
		return 0;
	}

	LOADING_DONE;

	// should be after init game (should be executed even if there is no game)
	if(startupParams.bExecuteCommandLine)
		pSystem->ExecuteCommandLine();

	pSystem->GetISystemEventDispatcher()->RegisterListener( &g_system_event_listener_game );

	// Creates and starts the realtime update system listener.
	if (pSystem->IsDevMode())
	{
		CGameRealtimeRemoteUpdateListener::GetGameRealtimeRemoteUpdateListener().Enable(true);
	}

	GCOV_FLUSH;

	if (gEnv && GetISystem())
	{
	}
	else
	{
		CryLogAlways("failed to find ISystem to register error observer");
		assert(0);
	}

	PluginManager::InitPluginsLast();
	return pOut;
}
Example #8
0
IGameRef CGameStartup::Init(SSystemInitParams &startupParams)
{
	MEMSTAT_CONTEXT(EMemStatContextTypes::MSC_Other, 0, "Game startup initialisation");

#if defined(CVARS_WHITELIST)
	startupParams.pCVarsWhitelist = &g_CVarsWhiteList;
#endif // defined(CVARS_WHITELIST)
	startupParams.pGameStartup = this;

	if (!InitFramework(startupParams))
	{
		return 0;
	}

	InlineInitializationProcessing("CGameStartup::Init");

  LOADING_TIME_PROFILE_SECTION(m_pFramework->GetISystem());

	ISystem* pSystem = m_pFramework->GetISystem();
	startupParams.pSystem = pSystem;

	const ICmdLineArg* pSvBind = gEnv->pSystem->GetICmdLine()->FindArg(eCLAT_Pre, "sv_bind"); 
	IConsole* pConsole = pSystem->GetIConsole();
	if ((pSvBind != NULL) && (pConsole != NULL))
	{
		string command = pSvBind->GetName() + string(" ") + pSvBind->GetValue();
		pConsole->ExecuteString(command.c_str(), true, false);
	}

#if defined(ENABLE_STATS_AGENT)
	const ICmdLineArg *pPipeArg = pSystem->GetICmdLine()->FindArg(eCLAT_Pre,"lt_pipename");
	CStatsAgent::CreatePipe( pPipeArg );
#endif

	REGISTER_COMMAND("g_loadMod", CGameStartupStatic::RequestLoadMod,VF_NULL,"");
	REGISTER_COMMAND("g_unloadMod", CGameStartupStatic::RequestUnloadMod, VF_NULL, "");

	// load the appropriate game/mod
#if !defined(_RELEASE)
	const ICmdLineArg *pModArg = pSystem->GetICmdLine()->FindArg(eCLAT_Pre,"MOD");
#else
	const ICmdLineArg *pModArg = NULL;
#endif // !defined(_RELEASE)

	InlineInitializationProcessing("CGameStartup::Init LoadLocalizationData");

	IGameRef pOut;
	if (pModArg && (*pModArg->GetValue() != 0) && (pSystem->IsMODValid(pModArg->GetValue())))
	{
		const char* pModName = pModArg->GetValue();
		assert(pModName);

		pOut = Reset(pModName);
	}
	else
	{
		pOut = Reset(GAME_NAME);
	}

	if (!m_pFramework->CompleteInit())
	{
		pOut->Shutdown();
		return 0;
	}

	InlineInitializationProcessing("CGameStartup::Init FrameworkCompleteInit");

	// should be after init game (should be executed even if there is no game)
	if(startupParams.bExecuteCommandLine)
		pSystem->ExecuteCommandLine();

	pSystem->GetISystemEventDispatcher()->RegisterListener(this);

	// Creates and starts the realtime update system listener.
	if (pSystem->IsDevMode())
	{
		CGameRealtimeRemoteUpdateListener::GetGameRealtimeRemoteUpdateListener().Enable(true);
	}


	GCOV_FLUSH;

	if (ISystem *pSystem = gEnv ? GetISystem() : NULL)
	{
		pSystem->RegisterErrorObserver(&m_errorObsever);
		pSystem->RegisterWindowMessageHandler(this);
	}
	else
	{
		CryLogAlways("failed to find ISystem to register error observer");
		assert(0);
	}

	
	InlineInitializationProcessing("CGameStartup::Init End");

#if defined(CRY_UNIT_TESTING)
	// Register All unit tests of this module.
#if defined(_LIB)
	if(gEnv->pSystem)
	{
		CryUnitTest::Test *pTest = CryUnitTest::Test::m_pFirst; 
		for (; pTest != 0; pTest = pTest->m_pNext)
		{
			CryUnitTest::IUnitTestManager *pTestManager = gEnv->pSystem->GetITestSystem()->GetIUnitTestManager();
			if (pTestManager)
			{
				pTest->m_unitTestInfo.module = "StaticBinary";
				pTestManager->CreateTest( pTest->m_unitTestInfo );
			}
		}
	}
#endif

	// run unit tests
	CryUnitTest::IUnitTestManager *pTestManager =  (gEnv && gEnv->pSystem) ? gEnv->pSystem->GetITestSystem()->GetIUnitTestManager() : NULL;
	if (pTestManager)
	{
		const ICmdLineArg* pSkipUnitTest = gEnv->pSystem->GetICmdLine()->FindArg(eCLAT_Pre, "skip_unit_tests"); 
		if(pSkipUnitTest == NULL)
		{
			const ICmdLineArg* pUseUnitTestExcelReporter = gEnv->pSystem->GetICmdLine()->FindArg(eCLAT_Pre, "use_unit_test_excel_reporter"); 
			if(pUseUnitTestExcelReporter)
			{
				gEnv->pSystem->GetITestSystem()->GetIUnitTestManager()->RunAllTests(CryUnitTest::ExcelReporter);
			}
			else // default is the minimal reporter
			{
				gEnv->pSystem->GetITestSystem()->GetIUnitTestManager()->RunAllTests(CryUnitTest::MinimalReporter);
			}
		}
	}
#endif // CRY_UNIT_TESTING
	
	assert(gEnv);
	PREFAST_ASSUME(gEnv);
	
	GetISystem()->GetISystemEventDispatcher()->OnSystemEvent(ESYSTEM_EVENT_RANDOM_SEED, (UINT_PTR)gEnv->pTimer->GetAsyncTime().GetMicroSecondsAsInt64(), 0);
	return pOut;
}