void CGameStartup::HandleResizeForVOIP(WPARAM wparam) { if(gEnv->pConsole) { ICVar * pVOIPCvar = gEnv->pConsole->GetCVar("net_blaze_voip_enable"); if(pVOIPCvar) { if(wparam == SIZE_RESTORED || wparam == SIZE_MAXIMIZED) { int currentVal = pVOIPCvar->GetIVal(); if(m_nVOIPWasActive == -1) { m_nVOIPWasActive = currentVal; } if(m_nVOIPWasActive != currentVal) { pVOIPCvar->Set(m_nVOIPWasActive); } CryLog("[VOIP] Game maximized or restored, VOIP was set to %d, saved value %d - now restored", currentVal, m_nVOIPWasActive); } else if(wparam == SIZE_MINIMIZED) { m_nVOIPWasActive = pVOIPCvar->GetIVal(); pVOIPCvar->Set(0); CryLog("[VOIP] Game minimized, VOIP was set to %d, setting to 0 while minimized", m_nVOIPWasActive); } } } }
CBasicEventListener::EAction CBasicEventListener::OnSysKeyDown(HWND hWn, WPARAM wParam, LPARAM lParam) { if (wParam != VK_RETURN && wParam != VK_F4) { return eA_None; } else { if (wParam == VK_RETURN && (lParam & (1<<29)) != 0) { if (gEnv && gEnv->pRenderer) { ICVar *pVar = gEnv->pConsole->GetCVar("r_Fullscreen"); if (pVar) { if(IPlayerProfileManager *pPlayerProfileManager = gEnv->pGame->GetIGameFramework()->GetIPlayerProfileManager()) { if(const char *pCurrentUser = pPlayerProfileManager->GetCurrentUser()) { int fullscreen = pVar->GetIVal(); pVar->Set((int)(fullscreen == 0)); IPlayerProfileManager::EProfileOperationResult result; pPlayerProfileManager->SaveProfile(pCurrentUser, result, ePR_Options); } } } } } // let the F4 pass through to default handler (it will send an WM_CLOSE) } return eA_Default; }
virtual void OnSystemEvent( ESystemEvent event,UINT_PTR wparam,UINT_PTR lparam ) { switch (event) { case ESYSTEM_EVENT_RANDOM_SEED: g_random_generator.seed((uint32)wparam); break; case ESYSTEM_EVENT_CHANGE_FOCUS: { CGameStartup::AllowAccessibilityShortcutKeys(wparam==0); } break; case ESYSTEM_EVENT_LEVEL_LOAD_START: { // workaround for needed for Crysis - to reset cvar set in level.cfg ICVar *pCVar = gEnv->pConsole->GetCVar("r_EyeAdaptationBase"); assert(pCVar); float fOldVal = pCVar->GetFVal(); if(fOldVal!=EYEADAPTIONBASEDEFAULT) { CryLog("r_EyeAdaptationBase was reset to default"); pCVar->Set(EYEADAPTIONBASEDEFAULT); // set to default value } } break; case ESYSTEM_EVENT_LEVEL_POST_UNLOAD: STLALLOCATOR_CLEANUP; break; } }
CFlowConvoyNode::CFlowConvoyNode( SActivationInfo * pActInfo ) { m_distanceOnPath = 0; m_bFirstUpdate = true; m_bXAxisFwd = false; m_speed = 0.0f; m_desiredSpeed = 0.0f; m_ShiftTime = 0.0f; m_splitSpeed = 0; m_coachIndex = -1; m_splitCoachIndex = 0; m_loopCount = 0; m_loopTotal = 0; m_offConvoyStartTime=0.f; m_splitDistanceOnPath=0; m_hornSoundID=INVALID_SOUNDID; m_engineStartSoundID=INVALID_SOUNDID; m_startBreakSoundShifted=0; pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, true ); if (gFlowConvoyNodes.empty()) gEnv->pPhysicalWorld->AddEventClient(EventPhysPostStep::id, OnPhysicsPostStep_static, 0); gFlowConvoyNodes.push_back(this); ICVar* pICVar = gEnv->pConsole->GetCVar("es_UsePhysVisibilityChecks"); if(pICVar) //prevent distance problem between coaches pICVar->Set(0); m_processNode = false; m_atEndOfPath = false; }
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(); } }
void CLuaRemoteDebug::ReceiveVersion(CSerializationHelper &buffer) { buffer.Read(m_clientVersion); if (m_clientVersion != LUA_REMOTE_DEBUG_HOST_VERSION) { CryLogAlways("Warning: Lua remote debug client connected with version %d, host is version %d", m_clientVersion, LUA_REMOTE_DEBUG_HOST_VERSION); } else { CryLog("Lua remote debug client connected with version: %d, host is version: %d", m_clientVersion, LUA_REMOTE_DEBUG_HOST_VERSION); } SendVersion(); SendGameFolder(); // Make sure the debugger is enabled when the remote debugger connects ICVar* pCvar = gEnv->pConsole->GetCVar("lua_debugger"); if (pCvar) { pCvar->Set(1); } // Send Lua state to newly connected debugger if (m_bExecutionStopped && m_pHaltedLuaDebug) { SendLuaState(m_pHaltedLuaDebug); SendVariables(); } if (m_bBinaryLuaDetected) { SendBinaryFileDetected(); } }
void CStereoZoom::SetStereoEyeDistCVAR(float eyeDist) { ICVar* pICVar = gEnv->pConsole->GetCVar("r_StereoEyeDist"); if ( pICVar != NULL) { pICVar->Set(eyeDist); } }
void CStereoZoom::SetStereoPlaneDistCVAR(float planeDist) { ICVar* pICVar = gEnv->pConsole->GetCVar("r_StereoScreenDist"); if ( pICVar != NULL) { pICVar->Set(planeDist); } }
//////////////////////////////////////////////////////////////////////////// // ui events /////////////////////////////////////////////////////////////////////////////////////////////////////////// void CUIGameEvents::OnLoadLevel( const char* mapname, bool isServer, const char* gamerules ) { if (gEnv->IsEditor()) return; ICVar* pGameRulesVar = gEnv->pConsole->GetCVar("sv_GameRules"); if (pGameRulesVar) pGameRulesVar->Set( gamerules ); m_pGameFramework->ExecuteCommandNextFrame(string().Format("map %s%s", mapname, isServer ? " s" : "")); if ( m_pGameFramework->IsGamePaused() ) m_pGameFramework->PauseGame(false, true); }
bool CTweakMetadataCVAR::ChangeValue(bool bIncrement) { // Get delta double fDelta = m_fDelta; if (!bIncrement) fDelta *= -1.0; // Get and check CVAR ICVar *cVar = GetCVar(); if (!cVar) return false; // Deal with appropriate type switch (cVar->GetType()) { case CVAR_INT: cVar->Set( (int) (cVar->GetIVal() + fDelta) ); break; case CVAR_FLOAT: cVar->Set( (float) (cVar->GetFVal() + fDelta) ); break; default:; // Strings are non-obvious // Might also be a non-exisitent variable } return true; }
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 } } } } } }
CFlowConvoyNode::~CFlowConvoyNode() { for (size_t i=0; i<gFlowConvoyNodes.size(); ++i) { if (gFlowConvoyNodes[i] == this) { gFlowConvoyNodes.erase(gFlowConvoyNodes.begin() + i); break; } } if (gFlowConvoyNodes.empty()) { gEnv->pPhysicalWorld->RemoveEventClient(EventPhysPostStep::id, OnPhysicsPostStep_static, 0); stl::free_container(gFlowConvoyNodes); } ICVar* pICVar = gEnv->pConsole->GetCVar("es_UsePhysVisibilityChecks"); if(pICVar) pICVar->Set(1); }
LRESULT CALLBACK CGameStartup::WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CLOSE: if (gEnv && gEnv->pSystem) gEnv->pSystem->Quit(); return 0; case WM_MOUSEACTIVATE: if (g_debugWindowsMessages && gEnv && gEnv->pLog) gEnv->pLog->Log("MSG: WM_MOUSEACTIVATE (%s %s)", (GetFocus()==hWnd)?"focused":"", (GetForegroundWindow()==hWnd)?"foreground":""); return MA_ACTIVATEANDEAT; case WM_ENTERSIZEMOVE: if (g_debugWindowsMessages && gEnv && gEnv->pLog) gEnv->pLog->Log("MSG: WM_ENTERSIZEMOVE (%s %s)", (GetFocus()==hWnd)?"focused":"", (GetForegroundWindow()==hWnd)?"foreground":""); if (gEnv && gEnv->pSystem && gEnv->pSystem->GetIHardwareMouse()) { gEnv->pSystem->GetIHardwareMouse()->IncrementCounter(); } return 0; case WM_EXITSIZEMOVE: if (g_debugWindowsMessages && gEnv && gEnv->pLog) gEnv->pLog->Log("MSG: WM_EXITSIZEMOVE (%s %s)", (GetFocus()==hWnd)?"focused":"", (GetForegroundWindow()==hWnd)?"foreground":""); if (gEnv && gEnv->pSystem && gEnv->pSystem->GetIHardwareMouse()) { gEnv->pSystem->GetIHardwareMouse()->DecrementCounter(); } return 0; case WM_ENTERMENULOOP: if (g_debugWindowsMessages && gEnv && gEnv->pLog) gEnv->pLog->Log("MSG: WM_ENTERMENULOOP (%s %s)", (GetFocus()==hWnd)?"focused":"", (GetForegroundWindow()==hWnd)?"foreground":""); if (gEnv && gEnv->pSystem && gEnv->pSystem->GetIHardwareMouse()) { gEnv->pSystem->GetIHardwareMouse()->IncrementCounter(); } return 0; case WM_EXITMENULOOP: if (g_debugWindowsMessages && gEnv && gEnv->pLog) gEnv->pLog->Log("MSG: WM_EXITMENULOOP (%s %s)", (GetFocus()==hWnd)?"focused":"", (GetForegroundWindow()==hWnd)?"foreground":""); if (gEnv && gEnv->pSystem && gEnv->pSystem->GetIHardwareMouse()) { gEnv->pSystem->GetIHardwareMouse()->DecrementCounter(); } return 0; case WM_HOTKEY: case WM_SYSCHAR: // prevent ALT + key combinations from creating 'ding' sounds return 0; case WM_CHAR: { if (gEnv && gEnv->pInput) { SInputEvent event; event.modifiers = gEnv->pInput->GetModifiers(); event.deviceId = eDI_Keyboard; event.state = eIS_UI; event.value = 1.0f; event.pSymbol = 0;//m_rawKeyboard->GetSymbol((lParam>>16)&0xff); if (event.pSymbol) event.keyId = event.pSymbol->keyId; event.inputChar = (wchar_t)wParam; gEnv->pInput->PostInputEvent(event); } } break; case WM_SYSKEYDOWN: // prevent ALT-key entering menu loop if (wParam != VK_RETURN && wParam != VK_F4) { return 0; } else { if (wParam == VK_RETURN) // toggle fullscreen { if (gEnv && gEnv->pRenderer && gEnv->pRenderer->GetRenderType() != eRT_DX11) { ICVar *pVar = gEnv->pConsole->GetCVar("r_Fullscreen"); if (pVar) { int fullscreen = pVar->GetIVal(); pVar->Set((int)(fullscreen == 0)); } } } // let the F4 pass through to default handler (it will send an WM_CLOSE) } break; case WM_SETCURSOR: if(g_pGame) { HCURSOR hCursor = LoadCursor(GetModuleHandle(0),MAKEINTRESOURCE(DEFAULT_CURSOR_RESOURCE_ID)); ::SetCursor(hCursor); } return 0; case WM_MOUSEMOVE: if(gEnv && gEnv->pHardwareMouse) { gEnv->pHardwareMouse->Event(LOWORD(lParam),HIWORD(lParam),HARDWAREMOUSEEVENT_MOVE); } return 0; case WM_LBUTTONDOWN: if(gEnv && gEnv->pHardwareMouse) { gEnv->pHardwareMouse->Event(LOWORD(lParam),HIWORD(lParam),HARDWAREMOUSEEVENT_LBUTTONDOWN); } return 0; case WM_LBUTTONUP: if(gEnv && gEnv->pHardwareMouse) { gEnv->pHardwareMouse->Event(LOWORD(lParam),HIWORD(lParam),HARDWAREMOUSEEVENT_LBUTTONUP); } return 0; case WM_LBUTTONDBLCLK: if(gEnv && gEnv->pHardwareMouse) { gEnv->pHardwareMouse->Event(LOWORD(lParam),HIWORD(lParam),HARDWAREMOUSEEVENT_LBUTTONDOUBLECLICK); } return 0; case WM_MOVE: if (g_debugWindowsMessages && gEnv && gEnv->pLog) gEnv->pLog->Log("MSG: WM_MOVE %d %d (%s %s)", LOWORD(lParam), HIWORD(lParam), (GetFocus()==hWnd)?"focused":"", (GetForegroundWindow()==hWnd)?"foreground":""); if(gEnv && gEnv->pSystem && gEnv->pSystem->GetISystemEventDispatcher()) { gEnv->pSystem->GetISystemEventDispatcher()->OnSystemEvent(ESYSTEM_EVENT_MOVE,LOWORD(lParam), HIWORD(lParam)); } return DefWindowProc(hWnd, msg, wParam, lParam); case WM_SIZE: if (g_debugWindowsMessages && gEnv && gEnv->pLog) gEnv->pLog->Log("MSG: WM_SIZE %d %d (%s %s)", LOWORD(lParam), HIWORD(lParam), (GetFocus()==hWnd)?"focused":"", (GetForegroundWindow()==hWnd)?"foreground":""); if(gEnv && gEnv->pSystem && gEnv->pSystem->GetISystemEventDispatcher()) { gEnv->pSystem->GetISystemEventDispatcher()->OnSystemEvent(ESYSTEM_EVENT_RESIZE,LOWORD(lParam), HIWORD(lParam)); } return DefWindowProc(hWnd, msg, wParam, lParam); case WM_ACTIVATE: if (g_debugWindowsMessages && gEnv && gEnv->pLog) gEnv->pLog->Log("MSG: WM_ACTIVATE %d (%s %s)", LOWORD(wParam), (GetFocus()==hWnd)?"focused":"", (GetForegroundWindow()==hWnd)?"foreground":""); if(gEnv && gEnv->pSystem && gEnv->pSystem->GetISystemEventDispatcher()) { gEnv->pSystem->GetISystemEventDispatcher()->OnSystemEvent(ESYSTEM_EVENT_ACTIVATE, LOWORD(wParam) != WA_INACTIVE, HIWORD(wParam)); } break; case WM_SETFOCUS: if (g_debugWindowsMessages && gEnv && gEnv->pLog) gEnv->pLog->Log("MSG: WM_SETFOCUS (%s %s)", (GetFocus()==hWnd)?"focused":"", (GetForegroundWindow()==hWnd)?"foreground":""); if(gEnv && gEnv->pSystem && gEnv->pSystem->GetISystemEventDispatcher()) { gEnv->pSystem->GetISystemEventDispatcher()->OnSystemEvent(ESYSTEM_EVENT_CHANGE_FOCUS, 1, 0); } break; case WM_KILLFOCUS: if (g_debugWindowsMessages && gEnv && gEnv->pLog) gEnv->pLog->Log("MSG: WM_KILLFOCUS (%s %s)", (GetFocus()==hWnd)?"focused":"", (GetForegroundWindow()==hWnd)?"foreground":""); if(gEnv && gEnv->pSystem && gEnv->pSystem->GetISystemEventDispatcher()) { gEnv->pSystem->GetISystemEventDispatcher()->OnSystemEvent(ESYSTEM_EVENT_CHANGE_FOCUS, 0, 0); } break; case WM_WINDOWPOSCHANGED: if (g_debugWindowsMessages && gEnv && gEnv->pLog) gEnv->pLog->Log("MSG: WM_WINDOWPOSCHANGED (%s %s)", (GetFocus()==hWnd)?"focused":"", (GetForegroundWindow()==hWnd)?"foreground":""); if(gEnv && gEnv->pSystem && gEnv->pSystem->GetISystemEventDispatcher()) { gEnv->pSystem->GetISystemEventDispatcher()->OnSystemEvent(ESYSTEM_EVENT_POS_CHANGED, 1, 0); } break; case WM_STYLECHANGED: if (g_debugWindowsMessages && gEnv && gEnv->pLog) gEnv->pLog->Log("MSG: WM_STYLECHANGED (%s %s)", (GetFocus()==hWnd)?"focused":"", (GetForegroundWindow()==hWnd)?"foreground":""); if(gEnv && gEnv->pSystem && gEnv->pSystem->GetISystemEventDispatcher()) { gEnv->pSystem->GetISystemEventDispatcher()->OnSystemEvent(ESYSTEM_EVENT_STYLE_CHANGED, 1, 0); } break; case WM_INPUTLANGCHANGE: if (g_debugWindowsMessages && gEnv && gEnv->pLog) gEnv->pLog->Log("MSG: WM_INPUTLANGCHANGE"); if(gEnv && gEnv->pSystem && gEnv->pSystem->GetISystemEventDispatcher()) { gEnv->pSystem->GetISystemEventDispatcher()->OnSystemEvent(ESYSTEM_EVENT_LANGUAGE_CHANGE, wParam, lParam); } break; } return DefWindowProc(hWnd, msg, wParam, lParam); }
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; }
//-------------------------------------------------------------------------------------------------- // Name: CFrontEndModelCache // Desc: Constructor //-------------------------------------------------------------------------------------------------- CFrontEndModelCache::CFrontEndModelCache() { #if FEMC_USE_LEVEL_HEAP SwitchToLevelHeap(); #endif // #if FEMC_USE_LEVEL_HEAP FE_LOG("Front End model cache creation"); INDENT_LOG_DURING_SCOPE(); IGameFramework* pGameFramework = g_pGame->GetIGameFramework(); if(pGameFramework) { pGameFramework->StartNetworkStallTicker(true); } m_bIsMultiplayerCache = gEnv->bMultiplayer; #if FEMC_FILE_ACCESS_LOG gEnv->pConsole->GetCVar("sys_FileAccessLog")->Set(1); #endif // #if FEMC_FILE_ACCESS_LOG #ifdef FEMC_LOG_CACHE_TIME const float startTime = gEnv->pTimer->GetAsyncCurTime(); #endif // #ifdef FEMC_LOG_CACHE_TIME #if FEMC_CACHE_FILE_ACCESSES if (g_pGameCVars->g_FEMenuCacheSaveList) { gEnv->pCryPak->RegisterFileAccessSink(this); m_recordedFiles.clear(); } int oldSaveLevelResourceList = 0; ICVar* pPakSaveLevelResourceListCvar = gEnv->pConsole->GetCVar("sys_PakSaveLevelResourceList"); if(pPakSaveLevelResourceListCvar) { oldSaveLevelResourceList = pPakSaveLevelResourceListCvar->GetIVal(); pPakSaveLevelResourceListCvar->Set(0); } m_pReasonForReportingFileOpen = "CFrontEndModelCache constructor"; #endif // #if FEMC_CACHE_FILE_ACCESSES CRY_ASSERT(s_pSingletonInstance == NULL); s_pSingletonInstance = this; // Load model list from xml, and cache each entry XmlNodeRef pRootNode = gEnv->pSystem->LoadXmlFromFile(FEMC_CACHE_LIST_FILENAME); if(pRootNode) { CGameXmlParamReader xmlParamReader(pRootNode); const char* pPakName = NULL; // Pak const char* const pGameFolder = gEnv->pCryPak->GetGameFolder(); const XmlNodeRef pPakData = xmlParamReader.FindFilteredChild("PakData"); if(pPakData && pPakData->getChildCount()) { const XmlNodeRef pPak = pPakData->getChild(0); if(pPak) { pPakName = pPak->getAttr("name"); bool bSucceeded = gEnv->pCryPak->OpenPack(pGameFolder,pPakName,ICryPak::FLAGS_FILENAMES_AS_CRC32); bSucceeded |= gEnv->pCryPak->LoadPakToMemory(pPakName,ICryPak::eInMemoryPakLocale_GPU); FE_LOG ("%s to open pack file '%s' bound to %s", bSucceeded ? "Managed" : "Failed", pPakName, pGameFolder); } // There is a pak, so reserve space for some materials in cache const uint materialCacheReserve = 64; m_materialCache.reserve(materialCacheReserve); } // Cache character models const XmlNodeRef pCharacterModelList = xmlParamReader.FindFilteredChild("CharacterModels"); if(pCharacterModelList) { const int characterModelCount = pCharacterModelList->getChildCount(); if(characterModelCount) { CreateSupportForFrontEnd3dModels(); } for(int i=0; i<characterModelCount; i++) { const XmlNodeRef pCharacterModel = pCharacterModelList->getChild(i); if(pCharacterModel) { const char* pCharacterModelName = pCharacterModel->getAttr("name"); CacheCharacterModel(pCharacterModelName); } } } // Cache item models const XmlNodeRef pItemModelsList = xmlParamReader.FindFilteredChild("ItemModels"); if(pItemModelsList) { const int itemModelCount = pItemModelsList->getChildCount(); if(itemModelCount) { CreateSupportForFrontEnd3dModels(); } for(int i=0; i<itemModelCount; i++) { const XmlNodeRef pItemModel = pItemModelsList->getChild(i); if(pItemModel) { const char* pItemModelName = pItemModel->getAttr("name"); if (strcmp(pItemModel->getTag(), "GeometryModels") == 0) { m_myGeometryCache.CacheGeometry(pItemModelName, false, IStatObj::ELoadingFlagsIgnoreLoDs); } else if (strcmp(pItemModel->getTag(), "ItemModel") == 0) { CacheItemModel(pItemModelName); } } } } // Unload pak if(pPakName) { gEnv->pCryPak->LoadPakToMemory( pPakName,ICryPak::eInMemoryPakLocale_Unload ); bool bSucceeded = gEnv->pCryPak->ClosePack( pPakName,0 ); FE_LOG ("%s to close pack file '%s'", bSucceeded ? "Managed" : "Failed", pPakName); } } #if FEMC_FILE_ACCESS_LOG gEnv->pConsole->GetCVar("sys_FileAccessLog")->Set(0); #endif // #if FEMC_FILE_ACCESS_LOG #ifdef FEMC_LOG_CACHE_TIME const float endTime = gEnv->pTimer->GetAsyncCurTime(); const float deltaTime = endTime - startTime; FE_LOG("FrontEndModelCache loading took %3.1f seconds", deltaTime); #endif // #FEMC_LOG_CACHE_TIME FE_MODEL_CACHE_LOG_CACHE_TIME #if FEMC_CACHE_FILE_ACCESSES m_pReasonForReportingFileOpen = NULL; if (g_pGameCVars->g_FEMenuCacheSaveList) { // To stop any other threads from messing gEnv->pCryPak->UnregisterFileAccessSink(this); std::set<string> fileset; // eliminate duplicate values std::vector<string>::iterator endLocation = std::unique( m_recordedFiles.begin(),m_recordedFiles.end() ); m_recordedFiles.erase( endLocation,m_recordedFiles.end() ); fileset.insert( m_recordedFiles.begin(),m_recordedFiles.end() ); string sResourceSetFilename = PathUtil::AddSlash("Levels/Multiplayer") + "mpmenu_list.txt"; { FILE* pFile = fxopen(sResourceSetFilename,"wb",true); if(pFile) { for(std::set<string>::iterator it = fileset.begin(); it != fileset.end(); ++it) { const char *pStr = it->c_str(); fprintf( pFile,"%s\n",pStr ); // Automatically add cgf->cgfm, cga->cgam, dds->dds.0 const char* const pExt = PathUtil::GetExt(pStr); if (strcmp(pExt, "cgf") == 0) { fprintf( pFile,"%sm\n",pStr ); } else if (strcmp(pExt, "cga") == 0) { fprintf( pFile,"%sm\n",pStr ); } else if (strcmp(pExt, "dds") == 0) { fprintf( pFile,"%s.0\n",pStr ); } } fclose(pFile); } } } if(pPakSaveLevelResourceListCvar) { pPakSaveLevelResourceListCvar->Set(oldSaveLevelResourceList); } #endif // #if FEMC_CACHE_FILE_ACCESSES if(pGameFramework) { pGameFramework->StopNetworkStallTicker(); } FE_LOG("Done caching items for front end"); #if FEMC_USE_LEVEL_HEAP SwitchToGlobalHeap(); #endif // #if FEMC_USE_LEVEL_HEAP }//-------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------- bool COptionsManager::HandleFSCommand(const char *szCommand,const char *szArgs) { if(!m_pPlayerProfileManager) return false; const char* user = m_pPlayerProfileManager->GetCurrentUser(); IPlayerProfile *pProfile = m_pPlayerProfileManager->GetCurrentProfile(user); if(!pProfile) return false; if(!stricmp(szCommand, "SaveProfile")) { UpdateToProfile(); SaveProfile(); return true; } if(!stricmp(szCommand, "RestoreDefaultProfile")) { if(szArgs && szArgs[0]) ResetDefaults(szArgs); else ResetDefaults(NULL); return true; } if(!stricmp(szCommand, "UpdateCVars")) { UpdateFlashOptions(); return true; } if(!stricmp(szCommand, "hud_showAllObjectives")) { if(szArgs) { SAFE_HUD_FUNC(SetShowAllOnScreenObjectives(atoi(szArgs)?true:false)); } } else if(!stricmp(szCommand,"hud_colorLine")) { SetCrysisProfileColor(szArgs); } else if(gEnv->bMultiplayer && !stricmp(szCommand,"g_psTutorial_Enabled")) { if(atoi(szArgs)==1) { gEnv->pConsole->ExecuteString("g_psTutorial_Reset"); } } std::map<string,SOptionEntry>::iterator it = m_profileOptions.find(szCommand); if(it!=m_profileOptions.end()) { ICVar *pCVAR = gEnv->pConsole->GetCVar(szCommand); if(pCVAR) { if(pCVAR->GetType()==1) //int { int value = atoi(szArgs); pCVAR->Set(value); } else if(pCVAR->GetType()==2) //float { float value = atof(szArgs); pCVAR->Set(value); } else if(pCVAR->GetType()==3) //string pCVAR->Set(szArgs); return true; // it's a CVAR, we are done! } } //else //does this map to an options function? even if it is inside m_profileOptions, but not a console variable (e.g. pb_client), we want to see if it's a registered command { TOpFuncMapIt iter = m_opFuncMap.find(szCommand); if(iter!=m_opFuncMap.end()) { (this->*(iter->second))(szArgs); return true; } } return false; }
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(""); }
void COptionsManager::InitProfileOptions(bool switchProfiles) { if(!m_pPlayerProfileManager) return; if(g_pGameCVars->g_useProfile==0) return; if(g_pGameCVars->g_startFirstTime==1) { ICVar *pCVar = gEnv->pConsole->GetCVar("g_startFirstTime"); if(pCVar && pCVar->GetIVal()==1) { pCVar->Set(0); m_firstStart = true; } switchProfiles=true; } const char* user = m_pPlayerProfileManager->GetCurrentUser(); IPlayerProfile *pProfile = m_pPlayerProfileManager->GetCurrentProfile(user); if(!pProfile) return; IAttributeEnumeratorPtr attribEnum = pProfile->CreateAttributeEnumerator(); IAttributeEnumerator::SAttributeDescription attrib; m_profileOptions.clear(); while(attribEnum->Next(attrib)) { bool bWriteToCfg = false; const char* attribCVar = ""; const bool bIsOption = IsOption(attrib.name, attribCVar, bWriteToCfg); if (bIsOption) { SOptionEntry entry (attrib.name, bWriteToCfg); m_profileOptions[attribCVar] = entry; if(!bWriteToCfg || switchProfiles) { string value; if(!strcmp(attribCVar, "pb_client")) { GetProfileValue(attrib.name, value); 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"); } continue; } else if(!strcmp(attribCVar, "fsaa_mode")) { GetProfileValue(attrib.name, value); SetAntiAliasingMode(value.c_str()); } else if(!strcmp(attribCVar, "g_difficultyLevel")) { GetProfileValue(attrib.name, value); SetDifficulty(value); } ICVar *pCVar = gEnv->pConsole->GetCVar(attribCVar); if(pCVar && GetProfileValue(attrib.name, value)) { if(stricmp(pCVar->GetString(), value.c_str())) { //CryLogAlways("Inited, loaded and changed: %s = %s (was %s)", attrib.name, value, pCVar->GetString()); pCVar->Set(value.c_str()); } else { //CryLogAlways("Inited, loaded, but not changed: %s = %s", attrib.name, value); } if(!stricmp(attrib.name,"Option.hud_colorLine")) { SetCrysisProfileColor(value.c_str()); } } } } } WriteGameCfg(); }
//-------------------------------------------------------------------------------------------------- // Name: OnInputEvent // Desc: Handles any debug input for the game effects system to test effects //-------------------------------------------------------------------------------------------------- bool GameSDKCGameEffectsSystem::OnInputEvent(const SInputEvent& inputEvent) { #if DEBUG_GAME_FX_SYSTEM int debugEffectCount = s_effectDebugList.Size(); if((g_pGameCVars->g_gameFXSystemDebug) && (debugEffectCount > 0)) { if(inputEvent.deviceType == eIDT_Keyboard && inputEvent.state == eIS_Pressed) { switch(inputEvent.keyId) { case GAME_FX_INPUT_IncrementDebugEffectId: { if(s_currentDebugEffectId < (debugEffectCount-1)) { s_currentDebugEffectId++; } break; } case GAME_FX_INPUT_DecrementDebugEffectId: { if(s_currentDebugEffectId > 0) { s_currentDebugEffectId--; } break; } case GAME_FX_INPUT_DecrementDebugView: { if(m_debugView > 0) { OnDeActivateDebugView(m_debugView); m_debugView--; OnActivateDebugView(m_debugView); } break; } case GAME_FX_INPUT_IncrementDebugView: { if(m_debugView < (eMAX_GAME_FX_DEBUG_VIEWS-1)) { OnDeActivateDebugView(m_debugView); m_debugView++; OnActivateDebugView(m_debugView); } break; } case GAME_FX_INPUT_ReloadEffectData: { ReloadData(); break; } case GAME_FX_INPUT_ResetParticleManager: { gEnv->pParticleManager->Reset(false); break; } case GAME_FX_INPUT_PauseParticleManager: { #if DEBUG_GAME_FX_SYSTEM ICVar* pParticleDebugCVar = gEnv->pConsole->GetCVar("e_ParticlesDebug"); if(pParticleDebugCVar) { int flagValue = pParticleDebugCVar->GetIVal(); if(flagValue & AlphaBit('z')) { flagValue &= ~AlphaBit('z'); } else { flagValue |= AlphaBit('z'); } pParticleDebugCVar->Set(flagValue); } #endif break; } } // Send input to current debug effect if(s_effectDebugList[s_currentDebugEffectId].inputCallback) { s_effectDebugList[s_currentDebugEffectId].inputCallback(inputEvent.keyId); } } } #endif return false; // Return false so that other listeners will get this event }//-------------------------------------------------------------------------------------------------