예제 #1
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;
			}
		}
	}
예제 #2
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()));
	}
}
예제 #3
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);
	}
}
예제 #4
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 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);
			}
		}
	}
}