virtual void ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo )
	{
		switch (event)
		{
		case eFE_Activate:
			if (IsPortActive(pActInfo, 0))
			{
				ILevelInfo* pLevelInfo = NULL;
				string mapname = GetPortString(pActInfo, IN_MAPNAME);
				
				//If mapname is provided, try and fetch those rules
				if(strcmp(mapname, "") != 0)
					pLevelInfo = CCryAction::GetCryAction()->GetILevelSystem()->GetLevelInfo(mapname);
				
				if(pLevelInfo)
				{
					ILevelInfo::TStringVec gamerules = pLevelInfo->GetGameRules();
					string outString = "";
					
					for (int i = 0; i < gamerules.size(); i++)
					{
						if(i > 0)
							outString.append("|");
						outString.append(gamerules[i]);
					}
					ActivateOutput(pActInfo, OUT_DONE, outString);
				}
			}
		}
	}
Ejemplo n.º 2
0
	virtual void ProcessEvent(EFlowEvent event, SActivationInfo *pActInfo)
	{
		switch (event)
		{
		case eFE_Activate:
			{
				if(IsPortActive(pActInfo, EIP_LevelComplete))
				{
					// Send the level name to the persistant stats system.
					ILevelSystem* pLS = g_pGame->GetIGameFramework()->GetILevelSystem();
					ILevel* pLevel = pLS ? pLS->GetCurrentLevel() : NULL;
					ILevelInfo* pLevelInfo = pLevel ? pLevel->GetLevelInfo() : NULL;
					if(pLevelInfo)
					{
						// level name case differs (lowercase on ps3, initial caps on xbox) so force lower here
						stack_string levelName = pLevelInfo->GetName();
						levelName.MakeLower();
						if(AccountLevelForStats( levelName.c_str() ))
						{
							g_pGame->GetPersistantStats()->OnSPLevelComplete( levelName.c_str() );
						}
					}
				}

				if(IsPortActive(pActInfo, EIP_Trigger))
				{
					int achievementId = -1;
					int input = GetPortInt(pActInfo, EIP_Achievement);

				/*	COMPILE_TIME_ASSERT( 0 == eC3A_Tutorial );
					COMPILE_TIME_ASSERT( 7 == eC3A_Cave );
					
					COMPILE_TIME_ASSERT( 23 == eC3A_SPLevel_CanYouHearMe );
					COMPILE_TIME_ASSERT( 24 == eC3A_SPLevel_Jailbreak_Rockets );
					COMPILE_TIME_ASSERT( 25 == eC3A_SPLevel_Donut_Surf );
					COMPILE_TIME_ASSERT( 26 == eC3A_SPLevel_Roadkill );
					COMPILE_TIME_ASSERT( 30 == eC3A_SPSkill_Improviser );*/

					if((input >= 0 && input <= 7) || (input >= 24 && input <= 28) || (input == eC3A_SPSkill_Improviser) )
					{
						achievementId = input;
					}
					else
					{
						assert(false);
					}

					if(achievementId != -1)
					{
						g_pGame->GetGameAchievements()->GiveAchievement((ECrysis3Achievement)achievementId);
					}
				}
				break;
			}
		}
	}
Ejemplo n.º 3
0
void CEditorGame::OnSaveLevel()
{
	ILevel* pCurrentLevel = m_pGame->GetIGameFramework()->GetILevelSystem()->GetCurrentLevel();

	if (pCurrentLevel)
	{
		ILevelInfo* pLevelInfo = pCurrentLevel->GetLevelInfo();
		string levelPath = PathUtil::GetGameFolder() + "/" + pLevelInfo->GetPath();
		InitEntityArchetypeEnums(m_pGTE, levelPath, PathUtil::GetFile(pLevelInfo->GetName()));
	}
}
Ejemplo n.º 4
0
void CUIGameEvents::OnLoadGame( bool shouldResume )
{
	if (gEnv->IsEditor()) return;

	ILevelInfo* pLevel = m_pLevelSystem->GetCurrentLevel();
	if (pLevel)
	{
		m_pGameFramework->LoadGame(pLevel->GetPath(), true);
		if ( shouldResume && m_pGameFramework->IsGamePaused() )
			m_pGameFramework->PauseGame(false, true);
	}
}
Ejemplo n.º 5
0
void CUIGameEvents::OnReloadLevel()
{
	if (gEnv->IsEditor()) return;

	ILevelInfo* pLevel = m_pLevelSystem->GetCurrentLevel();
	if (pLevel)
	{
		m_pGameFramework->ExecuteCommandNextFrame(string().Format("map %s", pLevel->GetName()));
		if ( m_pGameFramework->IsGamePaused() )
			m_pGameFramework->PauseGame(false, true);
	}
}
string CDevMode::TagFileName()
{
	ILevelSystem * pLevelSystem = CCryAction::GetCryAction()->GetILevelSystem();
	ILevelInfo* pLevel = pLevelSystem->GetCurrentLevel();
	if (!pLevel)
		return "";

	string path = pLevel->GetPath();
	path = PathUtil::GetGameFolder()+ string("/") + path + "/tags.txt";

	return path;
}
Ejemplo n.º 7
0
	EContextEstablishTaskResult OnStep(SContextEstablishState& state)
	{
		ILevel*			pLevel = CCryAction::GetCryAction()->GetILevelSystem()->GetCurrentLevel();
		if (!pLevel)
		{
			GameWarning("level is null");
			return eCETR_Failed;
		}
		const char * levelName = CCryAction::GetCryAction()->GetLevelName();
		if (!levelName)
		{
			GameWarning("levelName is null");
			return eCETR_Failed;
		}
		ILevelInfo* pLevelInfo = CCryAction::GetCryAction()->GetILevelSystem()->GetLevelInfo(levelName);
		if (!pLevelInfo)
		{
			GameWarning("levelInfo is null");
			return eCETR_Failed;
		}


		// delete any pending entities before reserving EntityIds in LoadEntities()
		gEnv->pEntitySystem->DeletePendingEntities();

		string missionXml = pLevelInfo->GetDefaultGameType()->xmlFile;
		string xmlFile = string(pLevelInfo->GetPath()) + "/" + missionXml;

		XmlNodeRef rootNode = GetISystem()->LoadXmlFromFile(xmlFile.c_str());

		if (rootNode)
		{
			const char *script = rootNode->getAttr("Script");

			if (script && script[0])
				gEnv->pScriptSystem->ExecuteFile(script, true, true);

			XmlNodeRef objectsNode = rootNode->findChild("Objects");

			if (objectsNode)
				gEnv->pEntitySystem->LoadEntities(objectsNode, false);
		}
		else
			return eCETR_Failed;

		SEntityEvent loadingCompleteEvent(ENTITY_EVENT_LEVEL_LOADED);
		gEnv->pEntitySystem->SendEventToAll( loadingCompleteEvent );

		return eCETR_Ok;
	}
    virtual void ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo )
    {
        switch (event)
        {
        case eFE_Initialize:
            break;
        case eFE_Activate:
        {
            if(!IsPortActive(pActInfo, EIP_Load))
                return;

            // get the file name
            string pathAndfileName;
            const string fileName = GetPortString(pActInfo, EIP_FileName);
            if (fileName.empty())
                return;

            ILevelInfo* pCurrentLevel = gEnv->pGame->GetIGameFramework()->GetILevelSystem()->GetCurrentLevel();
            string path = pCurrentLevel ? pCurrentLevel->GetPath() : "";
            pathAndfileName.Format("%s/%s", path.c_str(), fileName.c_str());

            // try to load it
            XmlNodeRef root = GetISystem()->LoadXmlFromFile( pathAndfileName );
            if (root == NULL)
            {
                CryWarning(VALIDATOR_MODULE_SYSTEM, VALIDATOR_WARNING, "FlowGraph: TimeOfDay Loading Node: Could not load tod file %s. Aborting.", pathAndfileName.c_str());
                ActivateOutput(pActInfo, EOP_Fail, true);
                return;
            }

            // get the TimeofDay interface
            ITimeOfDay *pTimeOfDay = gEnv->p3DEngine->GetTimeOfDay();
            if (pTimeOfDay == NULL)
            {
                CryWarning(VALIDATOR_MODULE_SYSTEM, VALIDATOR_WARNING, "FlowGraph: TimeOfDay Loading Node: Could not obtain ITimeOfDay interface from engine. Aborting.");
                ActivateOutput(pActInfo, EOP_Fail, true);
                return;
            }

            // try to serialize from that file
            pTimeOfDay->Serialize( root,true );
            pTimeOfDay->Update(true, true);

            ActivateOutput(pActInfo, EOP_Success, true);
        }
        break;
        }
    }
Ejemplo n.º 9
0
void CAntiCheatManager::InitSession()
{
	OpenLogFile();

	const char * pSessionName = NULL;
	char sessionID[CRYSESSIONID_STRINGLEN];
	sessionID[0] = 0;
	
	if(CGameLobby * pGameLobby = g_pGame->GetGameLobby())
	{
		pSessionName = pGameLobby->GetSessionName();
		if (pSessionName && pSessionName[0]==0)
			pSessionName=NULL;
		pGameLobby->GetSessionIDAsString(sessionID, CRYSESSIONID_STRINGLEN);
	} 

	//This can't be logged via the cleaner XML method as we need to open the tag now, and close it later on, without leaving everything in memory the whole time
	CryStackStringT<char, 512> sessionStartTag;

	const char * pTelemetrySessionName = NULL;

	if(ITelemetryCollector * pTelemetryCollector = g_pGame->GetITelemetryCollector())
	{
		pTelemetrySessionName = pTelemetryCollector->GetSessionId().c_str();
	}

	sessionStartTag.Format("<Session name=\"%s\" telemetry_name=\"%s\" id=\"%s\">\n", pSessionName ? pSessionName : "UNKNOWN", pTelemetrySessionName ? pTelemetrySessionName : "UNKNOWN", sessionID[0] ? sessionID : "UNKNOWN");

	if (m_pLogFile)
	{
		gEnv->pCryPak->FWrite(sessionStartTag.c_str(), 1, sessionStartTag.length(), m_pLogFile);
	}

	if(CGameRules * pGameRules = g_pGame->GetGameRules())
	{
		XmlNodeRef sessionGameInfo = GetISystem()->CreateXmlNode("GameInfo");

		ILevelInfo* pLevel = g_pGame->GetIGameFramework()->GetILevelSystem()->GetCurrentLevel();

		sessionGameInfo->setAttr("map",				pLevel->GetName());
		sessionGameInfo->setAttr("gamemode",	CGameRules::S_GetGameModeNamesArray()[pGameRules->GetGameMode()]);

		CheatLogInternalXml(sessionGameInfo);
	}
}
void CEditorGame::SetGameRules()
{
	IGameFramework *pGameFramework = g_pGame->GetIGameFramework();
	IConsole *pConsole = gEnv->pConsole;
	const char *szGameRules = NULL;
	const char *szLevelName = pConsole->GetCVar("sv_map")->GetString();
	ILevelInfo *pLevelInfo = pGameFramework->GetILevelSystem()->GetLevelInfo(szLevelName);

	if (pLevelInfo)
	{
		szGameRules = pLevelInfo->GetDefaultGameRules();
	}

	if (!szGameRules)
	{
		szGameRules = s_pEditorGame->m_bUsingMultiplayerGameRules ? "DeathMatch" : "SinglePlayer";
	}

	pGameFramework->GetIGameRulesSystem()->CreateGameRules(szGameRules);
	pConsole->GetCVar("sv_gamerules")->Set(szGameRules);
}
Ejemplo n.º 11
0
void CModInfoManager::Refresh()
{
#ifndef _WIN32
	assert(0 && "Calling Windows-specific code");
	return;
#endif

	if (!gEnv || !gEnv->pCryPak)
	{
		assert(0);
		return;
	}

	ICryPak* pCryPak = gEnv->pCryPak;

	m_mods.clear();

	// look for MODs
	{
		_finddata_t fd;
		intptr_t h = pCryPak->FindFirst ("Mods\\*", &fd, 0, true);
		if (h != -1)
		{
			CryStackStringT<char, _MAX_PATH*2> path;
			do 
			{
				if ((fd.attrib & _A_SUBDIR) == 0)
					continue;
				if (strcmp(fd.name, ".") == 0 || strcmp(fd.name, "..") == 0)
					continue;

				path = "Mods\\";
				path += fd.name;

				ModInfo mod;

				if (ModInfo_LoadFromFile(&mod, (path + "\\info.xml").c_str()) && mod.modType != eMIT_SPLEVEL)
				{
					mod.keyName = fd.name;
					if (mod.displayName.empty())
						mod.displayName = mod.keyName;
					path.replace('\\', '/');
					path.insert(0, '/');
					mod.mainImage = (path + "/modpreview.jpg").c_str();
					mod.logoImage = (path + "/modteamlogo.jpg").c_str();
					m_mods.push_back(mod);
				}
			}
			while(0 == pCryPak->FindNext(h, &fd));

			pCryPak->FindClose (h);
		}
	}

	// look for SP-levels
	{
		CryStackStringT<char, _MAX_PATH*2> path;
		path += PathUtil::GetGameFolder();
		path += "\\Levels\\*";

		_finddata_t fd;
		intptr_t h = pCryPak->FindFirst (path.c_str(), &fd, 0, true);
		if (h != -1)
		{
			do 
			{
				if ((fd.attrib & _A_SUBDIR) == 0)
					continue;
				if (strcmp(fd.name, ".") == 0 || strcmp(fd.name, "..") == 0)
					continue;

				path = PathUtil::GetGameFolder();
				path += "\\Levels\\";
				path += fd.name;

				ModInfo mod;

				if (ModInfo_LoadFromFile(&mod, (path + "\\info.xml").c_str()))
				{
					mod.modType = eMIT_SPLEVEL;
					mod.keyName = fd.name;
					path = "/Levels/";
					path += fd.name;
					mod.mainImage = (path + "/modpreview.jpg").c_str();
					mod.logoImage = (path + "/modteamlogo.jpg").c_str();
					if (mod.displayName.empty())
						mod.displayName = mod.keyName;
					m_mods.push_back(mod);
				}
			}
			while(0 == pCryPak->FindNext(h, &fd));

			pCryPak->FindClose (h);
		}
	}

	// look for MOD levels
	{
		m_modLevels.clear();

		CryStackStringT<char, _MAX_PATH*2> path;

		ILevelSystem* pLevelSystem = g_pGame->GetIGameFramework()->GetILevelSystem();
		size_t levelCount = pLevelSystem->GetLevelCount();
		for (size_t i = 0; i < levelCount; ++i)
		{
			ILevelInfo* pInfo = pLevelSystem->GetLevelInfo(i);
			if (!pInfo)
				continue;
			if (pInfo->GetIsModLevel() && (!pInfo->HasGameRules() || pInfo->SupportsGameType("SinglePlayer")))
			{
				ModInfo mod;
				const char* szLevelInfoDisplayName = pInfo->GetDisplayName();
				if (strcmp(szLevelInfoDisplayName, "") != 0)
				{
					mod.displayName = szLevelInfoDisplayName;
				}
				else // Fallback to directory name
				{
					mod.displayName = pInfo->GetName();
				}

				// load info.xml as well
				path = pInfo->GetPath();
				path.replace('/', '\\');
				if (ModInfo_LoadFromFile(&mod, (path + "\\info.xml").c_str()))
				{
					path.replace('\\', '/');
					path.insert(0, '/');
					mod.mainImage = (path + "/modpreview.jpg").c_str();
					mod.logoImage = (path + "/modteamlogo.jpg").c_str();
				}

				mod.keyName = pInfo->GetName();
				mod.modType = eMIT_SPLEVEL;

				m_modLevels.push_back(mod);
			}
		}
	}
}