BVB Source Codes

CRYENGINE Show CryActionCVars.cpp Source code

Return Download CRYENGINE: download CryActionCVars.cpp Source code - Download CRYENGINE Source code - Type:.cpp
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. #include "StdAfx.h"
  4. #include "CryActionCVars.h"
  5. #include <CryAISystem/IAIRecorder.h>
  6. #include "Serialization/XmlSerializeHelper.h"
  7. #include "Network/GameContext.h"
  8. #include "SegmentedWorld/SegmentedWorld.h"
  9.  
  10. CCryActionCVars* CCryActionCVars::s_pThis = 0;
  11.  
  12. CCryActionCVars::CCryActionCVars()
  13. {
  14.         CRY_ASSERT(!s_pThis);
  15.         s_pThis = this;
  16.  
  17.         IConsole* console = gEnv->pConsole;
  18.         assert(console);
  19.  
  20.         REGISTER_CVAR2("g_playerInteractorRadius", &playerInteractorRadius, 1.8f, VF_CHEAT, "Maximum radius at which player can interact with other entities");
  21.         REGISTER_CVAR2("i_itemSystemDebugMemStats", &debugItemMemStats, 0, VF_CHEAT, "Display item memory stats on screen");
  22.  
  23.         REGISTER_CVAR2("g_debug_stats", &g_debug_stats, 0, VF_NULL, "Enabled massive gameplay events debug");
  24.         REGISTER_CVAR2("g_statisticsMode", &g_statisticsMode, 2, VF_NULL, "Statistics mode\n"
  25.                                                                           " 0 - disabled\n"
  26.                                                                           " 1 - enabled crysis mode\n"
  27.                                                                           " 2 - enabled K01 mode\n");
  28.  
  29.         REGISTER_CVAR2("cl_useCurrentUserNameAsDefault", &useCurrentUserNameAsDefault, 1, 0, "Use the current user name instead of the default profile's name");
  30.  
  31. #if !defined(_RELEASE)
  32.         REGISTER_CVAR2("g_userNeverAutoSignsIn", &g_userNeverAutoSignsIn, 0, VF_CHEAT, "for autobuilds never automatically bring up the user sign in window, if the user isn't signed in. Can affect performance and skew performance test results. Has to be added to system.cfg, doesn't work if added to the commandline!");
  33. #endif
  34.  
  35. #ifdef AI_LOG_SIGNALS
  36.         REGISTER_CVAR2("ai_LogSignals", &aiLogSignals, 0, VF_CHEAT, "Maximum radius at which player can interact with other entities");
  37.         REGISTER_CVAR2("ai_MaxSignalDuration", &aiMaxSignalDuration, 3.f, VF_CHEAT, "Maximum radius at which player can interact with other entities");
  38. #endif
  39.  
  40.         // Currently, GameDLLs should set this cvar - it's a fundamental change in AI//depot/Games/Crysis2/Branches/Develop/MP/Trunk/Engine/Config/multiplayer.cfg
  41.         // 0 is the preferred value, 1 is for Crysis compatibility
  42.         int defaultAiFlowNodeAlertnessCheck = 1;
  43.         REGISTER_CVAR2("ai_FlowNodeAlertnessCheck", &aiFlowNodeAlertnessCheck, defaultAiFlowNodeAlertnessCheck, VF_INVISIBLE, "Enable the alertness check in AI flownodes");
  44.  
  45.         // Disable HUD debug text
  46.         REGISTER_CVAR2("cl_DisableHUDText", &cl_DisableHUDText, 0, 0, "Force disable all output from HUD Debug text nodes");
  47.  
  48.         //Gameplay Analyst
  49.         REGISTER_CVAR2("g_gameplayAnalyst", &g_gameplayAnalyst, 0, VF_REQUIRE_APP_RESTART, "Enable/Disable Gameplay Analyst");
  50.         REGISTER_CVAR2("g_multiplayerEnableVehicles", &g_multiplayerEnableVehicles, 1, 0, "Enable vehicles in multiplayer");
  51.  
  52.         // Cooperative Animation System
  53.         REGISTER_CVAR(co_coopAnimDebug, 0, 0, "Enable Cooperative Animation debug output");
  54.         REGISTER_CVAR(co_usenewcoopanimsystem, 1, VF_CHEAT, "Uses the new cooperative animation system which works without the animation graph");
  55.         REGISTER_CVAR(co_slideWhileStreaming, 0, 0, "Allows the sliding while the anims are being streamed. Otherwise the sliding step while wait until the anims are streaming");
  56.         // ~Cooperative Animation System
  57.  
  58.         // AI stances
  59.         ag_defaultAIStance = REGISTER_STRING("ag_defaultAIStance", "combat", 0, "Specifies default stance name for AI");
  60.  
  61.         REGISTER_CVAR(g_syncClassRegistry, 0, VF_NULL, "synchronize class registry from server to clients");
  62.  
  63.         REGISTER_CVAR(g_allowSaveLoadInEditor, 0, VF_NULL, "Allow saving and loading games in the editor (DANGEROUS)");
  64.         REGISTER_CVAR(g_saveLoadBasicEntityOptimization, 1, VF_NULL, "Switch basic entity data optimization");
  65.         REGISTER_CVAR(g_debugSaveLoadMemory, 0, VF_CHEAT, "Print debug information about save/load memory usage");
  66.         REGISTER_CVAR(g_saveLoadUseExportedEntityList, 1, VF_NULL, "Only save entities in the editor-generated save list (if available). 0 is the previous behavior");
  67.         REGISTER_CVAR(g_saveLoadExtendedLog, 0, VF_NULL, "Enables the generation of detailed log information regarding saveloads");
  68.         REGISTER_CVAR(g_useXMLCPBinForSaveLoad, 1, VF_REQUIRE_LEVEL_RELOAD, "Use XML compressed binary format for save and loads. DON'T CHANGE THIS DURING RUNTIME!");
  69.         REGISTER_CVAR(g_XMLCPBGenerateXmlDebugFiles, 0, VF_CHEAT, "Activates the generation, for debug purposes, of a text xml file each time that there is a binary save (LastBinarySaved.xml) or load (LastBinaryLoaded.xml).");
  70.         REGISTER_CVAR(g_XMLCPBAddExtraDebugInfoToXmlDebugFiles, 0, VF_CHEAT, "When the xml debug files are activated, this option adds the name and entity class name to every entity reference in the .xml .");
  71.         REGISTER_CVAR(g_XMLCPBSizeReportThreshold, 2048, VF_CHEAT, "defines the minimun size needed for nodes to be shown in the xml report file");
  72.         REGISTER_CVAR(g_XMLCPBUseExtraZLibCompression, 1, VF_CHEAT, "Enables an extra zlib compression pass on the binary saves.");
  73.         REGISTER_CVAR(g_XMLCPBBlockQueueLimit, 6, VF_CHEAT | VF_REQUIRE_APP_RESTART, "Limits the number of blocks to queue for saving, causes a main thread stall if exceeded. 0 for no limit.");
  74.  
  75.         REGISTER_CVAR(g_debugDialogBuffers, 0, VF_NULL, "Enables the on screen debug info for flownode dialog buffers.");
  76.  
  77.         REGISTER_CVAR(g_allowDisconnectIfUpdateFails, 1, VF_INVISIBLE, "");
  78.  
  79.         REGISTER_CVAR(g_useSinglePosition, 1, VF_NULL, "Activates the new Single Position update order");
  80.         REGISTER_CVAR(g_handleEvents, 1, VF_NULL, "Activates the registration requirement for GameObjectEvents");
  81.         REGISTER_CVAR(g_disableInputKeyFlowNodeInDevMode, 0, VF_NULL, "disables input Key flownodes even in dev mode. Pure game only, does not affect editor.");
  82.  
  83.         REGISTER_CVAR(g_disableSequencePlayback, 0, VF_NULL, "disable movie sequence playback");
  84.  
  85.         REGISTER_COMMAND("g_saveLoadDumpEntity", DumpEntitySerializationData, 0, "Print to console the xml data saved for a specified entity");
  86.         REGISTER_COMMAND("g_dumpClassRegistry", DumpClassRegistry, 0, "Print to console the list of classes and their associated ids");
  87.  
  88.         REGISTER_CVAR(sw_gridSize, 6, 0, "Number of active grids in both column and line for segmented world");
  89.         REGISTER_CVAR(sw_debugInfo, 1, 0, "Segmented World Debug Info (0=disable, 1=grid, 2=position, 3=memory, 4=color-coded object, 5=seg index, 6=seg index with layer info)");
  90.         REGISTER_INT("sw_draw_bbox", 1, 0, "Draw bounding box for segments.\nDefault is 1.\n");
  91.  
  92.         REGISTER_CVAR2("g_enableMergedMeshRuntimeAreas", &g_enableMergedMeshRuntimeAreas, 0, VF_CHEAT | VF_REQUIRE_APP_RESTART, "Enables the Merged Mesh cluster generation and density precalculations at game/level load");
  93.  
  94.         if (!gEnv->IsEditor())
  95.         {
  96.                 REGISTER_COMMAND("sw", SWCommandHandler, VF_CHEAT, "Control segmented world, use 'sw help' for more info");
  97.         }
  98. }
  99.  
  100. CCryActionCVars::~CCryActionCVars()
  101. {
  102.         assert(s_pThis != 0);
  103.         s_pThis = 0;
  104.  
  105.         IConsole* pConsole = gEnv->pConsole;
  106.  
  107.         pConsole->UnregisterVariable("g_disableInputKeyFlowNodeInDevMode", true);
  108.         pConsole->UnregisterVariable("g_useSinglePosition", true);
  109.         pConsole->UnregisterVariable("g_handleEvents", true);
  110.  
  111.         pConsole->UnregisterVariable("g_playerInteractorRadius", true);
  112.         pConsole->UnregisterVariable("i_itemSystemDebugMemStats", true);
  113.         pConsole->UnregisterVariable("g_debug_stats", true);
  114.         pConsole->UnregisterVariable("g_statisticsMode", true);
  115.  
  116. #ifdef AI_LOG_SIGNALS
  117.         pConsole->UnregisterVariable("ai_LogSignals", true);
  118.         pConsole->UnregisterVariable("ai_MaxSignalDuration", true);
  119. #endif
  120.         pConsole->UnregisterVariable("ai_FlowNodeAlertnessCheck", true);
  121.  
  122.         pConsole->UnregisterVariable("cl_DisableHUDText", true);
  123.         pConsole->UnregisterVariable("co_usenewcoopanimsystem", true);
  124.  
  125.         pConsole->UnregisterVariable("g_allowDisconnectIfUpdateFails", true);
  126.  
  127.         pConsole->UnregisterVariable("sw_gridSize");
  128.         pConsole->UnregisterVariable("sw_debugInfo");
  129.         pConsole->UnregisterVariable("sw_draw_bbox");
  130.         pConsole->UnregisterVariable("g_disableSequencePlayback", true);
  131.         pConsole->UnregisterVariable("g_enableMergedMeshRuntimeAreas", true);
  132. }
  133.  
  134. void CCryActionCVars::DumpEntitySerializationData(IConsoleCmdArgs* pArgs)
  135. {
  136.         if (pArgs->GetArgCount() != 2)
  137.         {
  138.                 CryLog("Format: es_dumpEntitySerializationData [id | name]");
  139.         }
  140.  
  141.         IEntity* pEntity = NULL;
  142.         const char* name = pArgs->GetArg(1);
  143.         pEntity = gEnv->pEntitySystem->FindEntityByName(name);
  144.         if (!pEntity)
  145.         {
  146.                 EntityId id = (EntityId)atoi(name);
  147.                 pEntity = gEnv->pEntitySystem->GetEntity(id);
  148.         }
  149.         if (!pEntity)
  150.         {
  151.                 CryLog("Unable to find entity %s", name);
  152.                 return;
  153.         }
  154.  
  155.         XmlNodeRef node = gEnv->pSystem->CreateXmlNode("root");
  156.         if (node)
  157.         {
  158.                 CXmlSerializeHelper serializer;
  159.                 TSerialize ser(serializer.GetWriter(node));
  160.  
  161.                 // first entity properties
  162.                 int32 iEntityFlags = pEntity->GetFlags();
  163.                 if ((iEntityFlags & ENTITY_SERIALIZE_PROPERTIES) && !(iEntityFlags & ENTITY_FLAG_UNREMOVABLE))
  164.                 {
  165.                         ser.BeginGroup("EntityProperties");
  166.                         pEntity->Serialize(ser, ENTITY_SERIALIZE_PROPERTIES);
  167.                         ser.EndGroup();
  168.                 }
  169.  
  170.                 // then extra data
  171.                 ser.BeginGroup("ExtraEntityData");
  172.                 if (iEntityFlags & ENTITY_FLAG_MODIFIED_BY_PHYSICS)
  173.                 {
  174.                         ser.BeginGroup("EntityGeometry");
  175.                         pEntity->Serialize(ser, ENTITY_SERIALIZE_GEOMETRIES);
  176.                         ser.EndGroup();
  177.                 }
  178.                 pEntity->Serialize(ser, ENTITY_SERIALIZE_PROXIES);
  179.                 ser.EndGroup();
  180.  
  181.                 CryLogAlways("Serializing entity %s", pEntity->GetName());
  182.                 string xml = node->getXML().c_str();
  183.                 int pos = 0;
  184.                 string line = xml.Tokenize("\n", pos);
  185.                 for (; (pos >= 0) && !line.empty(); line = xml.Tokenize("\n", pos))
  186.                 {
  187.                         CryLogAlways("%s", line.c_str());
  188.                 }
  189.         }
  190. }
  191.  
  192. void CCryActionCVars::DumpClassRegistry(IConsoleCmdArgs* pArgs)
  193. {
  194.         CGameContext* pGameContext = CCryAction::GetCryAction()->GetGameContext();
  195.         if (pGameContext)
  196.         {
  197.                 pGameContext->DumpClasses();
  198.         }
  199.         else
  200.         {
  201.                 CryLogAlways("Unable to dump class registry, game context is NULL");
  202.         }
  203. }
  204.  
  205. void CCryActionCVars::SWCommandHandler(IConsoleCmdArgs* pArgs)
  206. {
  207.         IConsole* pCon = GetISystem()->GetIConsole();
  208.         int nArg = pArgs->GetArgCount();
  209.         if (nArg <= 1)
  210.         {
  211.                 return;
  212.         }
  213.         const char* pcmd = pArgs->GetArg(1);
  214.  
  215.         const char* pcCmds[1024];
  216.         const char* pcHelps[1024];
  217.         int nCmds = 0;
  218.  
  219. #define CMD(cmd, help)   \
  220.   pcCmds[nCmds] = cmd;   \
  221.   pcHelps[nCmds] = help; \
  222.   ++nCmds;               \
  223.   if (!strcmpi(pcmd, cmd))
  224.  
  225.         CMD("goto", "[x, y]- move the player to segment(x, y), goto [Spawnpoint] - move the player to the specified spawn point")
  226.         {
  227.                 if (nArg < 3)
  228.                 {
  229.                         gEnv->pLog->LogToConsole("Invalid arguments");
  230.                         return;
  231.                 }
  232.  
  233.                 int iArgCount = pArgs->GetArgCount();
  234.                 int x, y;
  235.                 char name[1024];
  236.                 if ((iArgCount == 4)
  237.                     && sscanf(pArgs->GetArg(2), "%d", &x) == 1
  238.                     && sscanf(pArgs->GetArg(3), "%d", &y) == 1
  239.                     )
  240.                 {
  241.                         CCryAction::GetCryAction()->GoToSegment(x, y);
  242.                 }
  243.                 else if ((iArgCount == 3)
  244.                          && sscanf(pArgs->GetArg(2), "%1023s", name) == 1 // 1024-1 as the maximum field width does not include the terminating null byte.
  245.                          )
  246.                 {
  247.                         IEntity* pSpawnPointEnt = gEnv->pEntitySystem->FindEntityByName(name);
  248.                         if (pSpawnPointEnt)
  249.                         {
  250.                                 ray_hit hit;
  251.                                 IEntity* pClientEntity = gEnv->pGameFramework->GetClientEntity();
  252.                                 if (!gEnv->pGameFramework->GetClientEntity() || (gEnv->pGameFramework->GetClientEntity()->IsActive() == false))
  253.                                         return;
  254.  
  255.                                 AABB wBox;
  256.                                 pClientEntity->GetWorldBounds(wBox);
  257.                                 Vec3 origin = pSpawnPointEnt->GetPos() + Vec3(0, 0, wBox.max.z - wBox.min.z);
  258.                                 Vec3 dest = pSpawnPointEnt->GetPos();
  259.                                 IPhysicalEntity* pSkip = pClientEntity->GetPhysics();
  260.                                 Vec3 direction(0, 0, -1);
  261.                                 IPhysicalWorld* pWorld = gEnv->pPhysicalWorld;
  262.                                 int numHits = pWorld->RayWorldIntersection(
  263.                                   origin,
  264.                                   direction,
  265.                                   ent_all,
  266.                                   rwi_stop_at_pierceable | rwi_colltype_any,
  267.                                   &hit, 1,
  268.                                   &pSkip, 1);
  269.  
  270.                                 if (hit.pt.z > dest.z)
  271.                                 {
  272.                                         dest.z = hit.pt.z + 0.001f;
  273.                                 }
  274.  
  275.                                 Matrix34 tm = pClientEntity->GetWorldTM();
  276.                                 tm.SetTranslation(dest);
  277.                                 pClientEntity->SetWorldTM(tm);
  278.                         }
  279.                         return;
  280.                 }
  281.  
  282.                 if (!strcmpi(pcmd, "help"))
  283.                 {
  284.                         gEnv->pLog->LogToConsole("Available SW Doc commands:");
  285.                         for (int i = 0; i < nCmds; ++i)
  286.                                 gEnv->pLog->LogToConsole("  %s %s", pcCmds[i], pcHelps[i]);
  287.                         return;
  288.                 }
  289.         }
  290.  
  291.         gEnv->pLog->LogToConsole("Unknown command: %s", pcmd);
  292. }
  293.  
downloadCryActionCVars.cpp Source code - Download CRYENGINE Source code
Related Source Codes/Software:
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top