Exemplo n.º 1
0
void CEditorGame::InitActionMapsEnums(IGameToEditorInterface* pGTE)
{
	IActionMapManager* pAM = m_pGame->GetIGameFramework()->GetIActionMapManager();
	IActionMapIteratorPtr iter = pAM->CreateActionMapIterator();

	const int numActionMaps = pAM->GetActionMapsCount();

	if(numActionMaps == 0)
		return;

	const char** nameValueStrings = new const char*[numActionMaps];
	int curEntryIndex = 0;
	while (IActionMap* pMap = iter->Next())
	{
		assert(curEntryIndex < numActionMaps);
		PREFAST_ASSUME(curEntryIndex < numActionMaps);
		nameValueStrings[curEntryIndex++] = pMap->GetName();

		if (curEntryIndex > numActionMaps)
		{
			CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_WARNING, "[InitActionMapsEnums] Wrong number of Action Maps.");
			break;
		}
	}

	pGTE->SetUIEnums("action_maps", nameValueStrings, numActionMaps);

	delete[] nameValueStrings;
}
Exemplo n.º 2
0
//------------------------------------------------------------------------
CVehicleActionEntityAttachment* CFlowVehicleEntityAttachment::GetVehicleAction()
{
	if (!m_vehicleId)
		return NULL;

	IVehicleSystem* pVehicleSystem = gEnv->pGame->GetIGameFramework()->GetIVehicleSystem();
	assert(pVehicleSystem);

	if (IVehicle* pVehicle = pVehicleSystem->GetVehicle(m_vehicleId))
	{
		for (int i = 1; i < pVehicle->GetActionCount(); i++)
		{
			IVehicleAction* pAction = pVehicle->GetAction(i);
			assert(pAction);
			PREFAST_ASSUME(pAction);

			if (CVehicleActionEntityAttachment* pAttachment = 
				CAST_VEHICLEOBJECT(CVehicleActionEntityAttachment, pAction))
			{
				return pAttachment;
			}
		}
	}

	return NULL;
}
Exemplo n.º 3
0
void CEditorGame::InitModularBehaviorTreeEnum(IGameToEditorInterface* pGTE)
{
	std::vector<string> behaviorTrees;
	// no behavior tree
	behaviorTrees.push_back("");
	ScanBehaviorTrees("Scripts/AI/BehaviorTrees/", behaviorTrees);

	size_t numTrees = 0;
	const int behaviorTreeCount = behaviorTrees.size();
	const char** allTrees = new const char*[behaviorTreeCount];
	std::vector<string>::const_iterator iter = behaviorTrees.begin();
	std::vector<string>::const_iterator iterEnd = behaviorTrees.end();

	while (iter != iterEnd)
	{
		assert(numTrees >= 0 && numTrees < behaviorTreeCount);
		PREFAST_ASSUME(numTrees >= 0 && numTrees < behaviorTreeCount);
		allTrees[numTrees++] = iter->c_str();
		++iter;
	}

	pGTE->SetUIEnums("ModularBehaviorTree", allTrees, numTrees);

	SAFE_DELETE_ARRAY(allTrees);
}
// Description:
//   Create
// Arguments:
//
// Return:
//
CVisualLog& CVisualLog::ref()
{
	if ( NULL == m_pInstance )
	{
		Create();
	}
	CRY_ASSERT(m_pInstance);
	PREFAST_ASSUME(m_pInstance);

	return( *m_pInstance );
}
Exemplo n.º 5
0
void CEditorGame::InitLevelTypesEnums(IGameToEditorInterface* pGTE)
{
	DynArray<string>* levelTypes;
	levelTypes = g_pGame->GetIGameFramework()->GetILevelSystem()->GetLevelTypeList();
	
	const char** allLevelTypes = new const char*[levelTypes->size()];
	for (int i = 0; i < levelTypes->size(); i++)
	{
		PREFAST_ASSUME(i > 0 && i < levelTypes->size());
		allLevelTypes[i] = (*levelTypes)[i];
	}

	pGTE->SetUIEnums("level_types", allLevelTypes, levelTypes->size());
	delete[] allLevelTypes;
}
// Description:
//
// Arguments:
//
// Return:
//
void CVisualLog::InitCVars()
{
	m_pCVVisualLog = REGISTER_INT( "cl_visualLog", 0, 0, "Enables Visual Logging." );
	m_pCVVisualLogFolder = REGISTER_STRING( "cl_visualLogFolder", "VisualLog", 0, "Specifies sub folder to write logs to." );
	m_pCVVisualLogImageFormat = REGISTER_STRING( "cl_visualLogImageFormat", "bmp", 0, "Specifies file format of captured files (jpg, bmp)." );
	m_pCVVisualLogImageScale = REGISTER_FLOAT( "cl_visualLogImageScale", 128, 0, "Image size. [0-1] = scale value. >1 = actual pixels for image width" );

	assert(gEnv->pConsole);
	PREFAST_ASSUME(gEnv->pConsole);
	m_pCV_capture_frames = gEnv->pConsole->GetCVar("capture_frames");
	m_pCV_capture_file_format = gEnv->pConsole->GetCVar("capture_file_format");
	m_pCV_capture_frame_once = gEnv->pConsole->GetCVar("capture_frame_once");
	m_pCV_capture_file_name = gEnv->pConsole->GetCVar("capture_file_name");

	CRY_ASSERT( m_pCV_capture_frames );
	CRY_ASSERT( m_pCV_capture_file_format );
	CRY_ASSERT( m_pCV_capture_frame_once );
	CRY_ASSERT( m_pCV_capture_file_name );
}
	virtual void ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo )
	{
		if ( event != eFE_Activate )
			return;

		ICustomAction* pCustomAction = pActInfo->pGraph->GetCustomAction();
		if (!pCustomAction) // Not inside a custom graph, must be an instance hack, get associated entity
		{
			IEntity* pEntity = pActInfo->pEntity;
			if(!pEntity)
			{
				CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_WARNING, "CFlowNode_CustomActionEnd::ProcessEvent: Instance hack must have assigned entity");
				return;
			}
				
			ICustomActionManager* pCustomActionManager = gEnv->pGame->GetIGameFramework()->GetICustomActionManager();
			if (pCustomActionManager)
			{
				pCustomAction = pCustomActionManager->GetActiveCustomAction(pEntity);
				if (!pCustomAction)
				{
					CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_WARNING, "CFlowNode_CustomActionEnd::ProcessEvent: Can't find custom action for entity");
					return;
				}
			}
		}
		
		PREFAST_ASSUME(pCustomAction); // is validated above, if it fails it should already have returned

		if ( IsPortActive(pActInfo, 0) )
			pCustomAction->SucceedAction();
		if ( IsPortActive(pActInfo, 1) )
			pCustomAction->SucceedWaitAction();
		if ( IsPortActive(pActInfo, 2) )
			pCustomAction->SucceedWaitCompleteAction();
		else if ( IsPortActive(pActInfo, 3) )
			pCustomAction->AbortAction();
		else if ( IsPortActive(pActInfo, 4) )
			pCustomAction->EndActionSuccess();
		else if ( IsPortActive(pActInfo, 5) )
			pCustomAction->EndActionFailure();
	}
Exemplo n.º 8
0
			void CreateEnum(IGameToEditorInterface *pGTEInterface, const char* enumName) const
			{
				assert(pGTEInterface);
				assert(enumName && enumName[0]);

				if (!m_vecNames.empty())
				{
					const size_t numNames = m_vecNames.size();
					const char** pNameArray = new const char* [numNames];

					TNamesVec::const_iterator itName = m_vecNames.begin();
					TNamesVec::const_iterator itNameEnd = m_vecNames.end();
					for (size_t index = 0; itName != itNameEnd; ++itName, ++index)
					{
						assert(index >= 0 && index < numNames);
						PREFAST_ASSUME(index >= 0 && index < numNames);
						pNameArray[index] = *itName;
					}

					pGTEInterface->SetUIEnums(enumName, pNameArray, numNames);

					delete [] pNameArray;
				}
			}
Exemplo n.º 9
0
void CRecordingSystem::ClProcessKillCamData(IActor *pActor, const CActor::KillCamFPData &packet)
{
	// Receiver gets a second to validate the expectations.
	static float timeToValidateUnexpectedData = 1.f;

	// Find the existing StreamData for this packet.
	SKillCamStreamData* pStreamData = m_streamer.GetExpectedStreamData(packet.m_victim);

	// If it arrived before the kill was relayed to the client, then create false expectations of this data and store it in anticipation of validation.
	if(!pStreamData)
	{
		CryLogAlways("Receiving unexpected packet data. This is most likely because the data is arriving before the kill has been requested. Creating false expectations.");
		SKillCamExpectedData falseExpectations(pActor->GetEntityId(), packet.m_victim, packet.m_bToEveryone);
		pStreamData = m_streamer.ExpectStreamData(falseExpectations, false);
		if(!pStreamData)
		{
			CryFatalError("CRecordingSystem::ClProcessKillCamData: Cannot find free slot to add new receive data from: Sender[%d] Victim[%d]", falseExpectations.m_sender, falseExpectations.m_victim);
		}
		PREFAST_ASSUME(pStreamData); //validated above
		pStreamData->SetValidationTimer(timeToValidateUnexpectedData);
	}
	else
	{
		// Update the timer if it's still not been validated and we receive a new packet...
		if(pStreamData->IsValidationTimerSet())
		{
			pStreamData->SetValidationTimer(timeToValidateUnexpectedData);
		}
	}

	if(pStreamData)
	{
		// Process the Packet.
		CRecordingSystem::ProcessKillCamData(pActor, packet, *pStreamData, true);
	}
}
Exemplo n.º 10
0
	virtual void Run()
	{
		SetName("ZLibCompressor");

#if defined (DURANGO)
		SetThreadAffinityMask(GetCurrentThread(), BIT(3));
#endif

		while(!m_bCancelled || !m_files.empty())
		{
			m_event.Wait();

			uint8* pZLibCompressedBuffer = AllocateBlock();

			while(!m_files.empty())
			{
				CFile* pFile = m_files.pop();
				assert(pFile);
				PREFAST_ASSUME(pFile);

				while(!pFile->Closed() || !pFile->m_blocks.empty())
				{
					if( pFile->m_blocks.empty() )
					{ 
						CrySleep(1); // yield to give other threads a chance to do some work        
					}

					while(!pFile->m_blocks.empty())
					{
						SZLibBlock* block = pFile->m_blocks.pop();
						assert(block);
						PREFAST_ASSUME(block);

						if(pFile->m_pCompressor->m_bUseZLibCompression)
						{
							size_t compressedLength = XMLCPB_ZLIB_BUFFER_SIZE;
							bool compressionOk = gEnv->pSystem->CompressDataBlock( block->m_pZLibBuffer, block->m_ZLibBufferSizeUsed, pZLibCompressedBuffer, compressedLength );

							SZLibBlockHeader zlibHeader;
							zlibHeader.m_compressedSize = compressionOk ? compressedLength : SZLibBlockHeader::NO_ZLIB_USED;
							zlibHeader.m_uncompressedSize = block->m_ZLibBufferSizeUsed;
							pFile->m_bytesWrittenIntoFileUncompressed += block->m_ZLibBufferSizeUsed;

							pFile->Write( &zlibHeader, sizeof(SZLibBlockHeader) );
							if (compressionOk)
								pFile->Write( pZLibCompressedBuffer, compressedLength );
							else
								pFile->Write( block->m_pZLibBuffer, block->m_ZLibBufferSizeUsed );
						}
						else
						{
							pFile->Write(block->m_pZLibBuffer, block->m_ZLibBufferSizeUsed);
						}

						delete block;
					}
				}

				pFile->Finish();
				delete pFile;
			}

			FreeBlock(pZLibCompressedBuffer);
		}
	}
Exemplo n.º 11
0
void CEditorGame::InitEntityArchetypeEnums(IGameToEditorInterface* pGTE, const char* levelFolder /*= NULL*/, const char* levelName /*= NULL*/)
{
	CRY_ASSERT(pGTE);

	// Look in all the archetype files
	ICryPak* pCryPak = gEnv->pCryPak;
	CRY_ASSERT(pCryPak);

	std::vector<string> vecArchetypeNames;

	if (levelFolder && levelName)
	{
		string levelPath = string(levelFolder) + "/" + string(levelName) + ".cry";

		if (pCryPak && pCryPak->OpenPack(levelPath))
		{
			string editorXML = string(levelFolder) + "/Level.editor_xml";
			XmlNodeRef pRoot = gEnv->pSystem->LoadXmlFromFile(editorXML);

			if (pRoot)
				GetArchetypesFromLevelLib(pRoot, &vecArchetypeNames);

			pCryPak->ClosePack(levelPath);
		}
	}

	_finddata_t fd;
	string sSearchPath = PathUtil::Make("Libs\\EntityArchetypes", "*", "xml");
	intptr_t handle = pCryPak->FindFirst(sSearchPath, &fd);
	if (handle >= 0)
	{
		do
		{
			string sFilePath = PathUtil::Make("Libs\\EntityArchetypes", fd.name, "xml");

			XmlNodeRef pRoot = gEnv->pSystem->LoadXmlFromFile(sFilePath.c_str());
			if (!pRoot || stricmp(pRoot->getTag(), "EntityPrototypeLibrary"))
				continue;

				XmlString sRootName;
				pRoot->getAttr("Name", sRootName);

				GetArchetypesFromLib(pRoot, sRootName, &vecArchetypeNames);
		}
		while (pCryPak->FindNext(handle, &fd) >= 0);
		pCryPak->FindClose(handle);
	}

	if (!vecArchetypeNames.empty())
	{
		size_t numFilters = 0;
		const int allArchetypeCount = vecArchetypeNames.size()+1;
		const char** allArchetypeNames = new const char*[allArchetypeCount];
		allArchetypeNames[numFilters++] = ""; // Blank entry at top
		std::vector<string>::const_iterator iter = vecArchetypeNames.begin();
		std::vector<string>::const_iterator iterEnd = vecArchetypeNames.end();
		while (iter != iterEnd)
		{
			assert(numFilters > 0 && numFilters < allArchetypeCount);
			PREFAST_ASSUME(numFilters > 0 && numFilters < allArchetypeCount);
			allArchetypeNames[numFilters++] = iter->c_str();
			++iter;
		}
		pGTE->SetUIEnums("entity_archetypes", allArchetypeNames, numFilters);
		delete[] allArchetypeNames;
	}
}
Exemplo n.º 12
0
void CVar::Init( struct IConsole *pConsole )
{
	assert(gEnv->pConsole);
	PREFAST_ASSUME(gEnv->pConsole);

	REGISTER_COMMAND("es_dump_entities", (ConsoleCommandFunc)DumpEntities, 0, "Dumps current entities and their states!");
	REGISTER_COMMAND("es_dump_entity_classes_in_use", (ConsoleCommandFunc)DumpEntityClassesInUse, 0, "Dumps all used entity classes");
	REGISTER_COMMAND("es_compile_area_grid", (ConsoleCommandFunc)CompileAreaGrid, 0, "Trigger a recompile of the area grid");
	REGISTER_COMMAND("es_dump_bookmarks", (ConsoleCommandFunc)DumpEntityBookmarks, 0, "Dumps information about all bookmarked entities");
	REGISTER_COMMAND("es_AudioListenerOffset", (ConsoleCommandFunc)SetAudioListenerOffsets, 0,
		"Sets by how much the audio listener offsets its position and rotation in regards to its entity.\n"
		"Usage: es_AudioListenerOffset PosX PosY PosZ RotX RotY RotZ\n");

	REGISTER_CVAR( es_SortUpdatesByClass, 0, 0, "Sort entity updates by class (possible optimization)" );
	pDebug = REGISTER_INT("es_debug",0,VF_CHEAT,
		"Enable entity debugging info\n"
		"Usage: es_debug [0/1]\n"
		"Default is 0 (on).");
	pCharacterIK = REGISTER_INT("p_CharacterIK",1,VF_CHEAT,
		"Toggles character IK.\n"
		"Usage: p_characterik [0/1]\n"
		"Default is 1 (on). Set to 0 to disable inverse kinematics.");	
	pEntityBBoxes = REGISTER_INT("es_bboxes",0,VF_CHEAT,
		"Toggles entity bounding boxes.\n"
		"Usage: es_bboxes [0/1]\n"
		"Default is 0 (off). Set to 1 to display bounding boxes.");
	pEntityHelpers = REGISTER_INT("es_helpers",0,VF_CHEAT,
		"Toggles helpers.\n"
		"Usage: es_helpers [0/1]\n"
		"Default is 0 (off). Set to 1 to display entity helpers.");
	pProfileEntities = REGISTER_INT("es_profileentities",0,VF_CHEAT,
		"Usage: es_profileentities 1,2,3\n"
		"Default is 0 (off).");
/*	pUpdateInvisibleCharacter = REGISTER_INT("es_UpdateInvisibleCharacter",0,VF_CHEAT,
		"Usage: \n"
		"Default is 0 (off).");
	pUpdateBonePositions = REGISTER_INT("es_UpdateBonePositions",1,VF_CHEAT,
		"Usage: \n"
		"Default is 1 (on).");
*/	pUpdateScript = REGISTER_INT("es_UpdateScript",1,VF_CHEAT,
		"Usage: es_UpdateScript [0/1]\n"
		"Default is 1 (on).");
	pUpdatePhysics = REGISTER_INT("es_UpdatePhysics",1,VF_CHEAT,
		"Toggles updating of entity physics.\n"
		"Usage: es_UpdatePhysics [0/1]\n"
		"Default is 1 (on). Set to 0 to prevent entity physics from updating.");
	pUpdateAI = REGISTER_INT("es_UpdateAI",1,VF_CHEAT,
		"Toggles updating of AI entities.\n"
		"Usage: es_UpdateAI [0/1]\n"
		"Default is 1 (on). Set to 0 to prevent AI entities from updating.");
	pUpdateEntities = REGISTER_INT("es_UpdateEntities",1,VF_CHEAT,
		"Toggles entity updating.\n"
		"Usage: es_UpdateEntities [0/1]\n"
		"Default is 1 (on). Set to 0 to prevent all entities from updating.");
	pUpdateCollision= REGISTER_INT("es_UpdateCollision",1,VF_CHEAT,
		"Toggles updating of entity collisions.\n"
		"Usage: es_UpdateCollision [0/1]\n"
		"Default is 1 (on). Set to 0 to disable entity collision updating.");
	pUpdateContainer= REGISTER_INT("es_UpdateContainer",1,VF_CHEAT,
		"Usage: es_UpdateContainer [0/1]\n"
		"Default is 1 (on).");
	pUpdateTimer = REGISTER_INT("es_UpdateTimer",1,VF_CHEAT,
		"Usage: es_UpdateTimer [0/1]\n"
		"Default is 1 (on).");
	pUpdateCollisionScript = REGISTER_INT("es_UpdateCollisionScript",1,VF_CHEAT,
		"Usage: es_UpdateCollisionScript [0/1]\n"
		"Default is 1 (on).");
	pVisCheckForUpdate = REGISTER_INT("es_VisCheckForUpdate",1,VF_CHEAT,
		"Usage: es_VisCheckForUpdate [0/1]\n"
		"Default is 1 (on).");
	pMinImpulseVel = REGISTER_FLOAT("es_MinImpulseVel",0.0f,VF_CHEAT,
		"Usage: es_MinImpulseVel 0.0");
	pImpulseScale = REGISTER_FLOAT("es_ImpulseScale",0.0f,VF_CHEAT,
		"Usage: es_ImpulseScale 0.0");
	pMaxImpulseAdjMass = REGISTER_FLOAT("es_MaxImpulseAdjMass",2000.0f,VF_CHEAT,
		"Usage: es_MaxImpulseAdjMass 2000.0");
	pDebrisLifetimeScale = REGISTER_FLOAT("es_DebrisLifetimeScale",1.0f,0,
		"Usage: es_DebrisLifetimeScale 1.0");
	pSplashThreshold = REGISTER_FLOAT("es_SplashThreshold",1.0f,VF_CHEAT,
		"minimum instantaneous water resistance that is detected as a splash"
		"Usage: es_SplashThreshold 200.0");
	pSplashTimeout = REGISTER_FLOAT("es_SplashTimeout",3.0f,VF_CHEAT,
		"minimum time interval between consecutive splashes"
		"Usage: es_SplashTimeout 3.0");
	pHitCharacters = REGISTER_INT("es_HitCharacters",1,0,
		"specifies whether alive characters are affected by bullet hits (0 or 1)");
	pHitDeadBodies = REGISTER_INT("es_HitDeadBodies",1,0,
		"specifies whether dead bodies are affected by bullet hits (0 or 1)");
	pCharZOffsetSpeed = REGISTER_FLOAT("es_CharZOffsetSpeed",2.0f,VF_DUMPTODISK,
		"sets the character Z-offset change speed (in m/s), used for IK");

	pNotSeenTimeout = REGISTER_INT("es_not_seen_timeout", 30, VF_DUMPTODISK,
		"number of seconds after which to cleanup temporary render buffers in entity");
	pDebugNotSeenTimeout = REGISTER_INT("es_debug_not_seen_timeout", 0, VF_DUMPTODISK,
		"if true, log messages when entities undergo not seen timeout");

	pEnableFullScriptSave = REGISTER_INT("es_enable_full_script_save",0,
		VF_DUMPTODISK,"Enable (experimental) full script save functionality");
	
	pLogCollisions = REGISTER_INT("es_log_collisions",0,0,"Enables collision events logging" );
	REGISTER_CVAR(es_DebugTimers,0,VF_CHEAT,
		"This is for profiling and debugging (for game coders and level designer)\n"
		"By enabling this you get a lot of console printouts that show all entities that receive OnTimer\n"
		"events - it's good to minimize the call count. Certain entities might require this feature and\n"
		"using less active entities can often be defined by the level designer.\n"
		"Usage: es_DebugTimers 0/1");
	REGISTER_CVAR(es_DebugFindEntity,0,VF_CHEAT,"" );
	REGISTER_CVAR(es_DebugEvents,0,VF_CHEAT,"Enables logging of entity events" );
	REGISTER_CVAR(es_DisableTriggers,0,0,"Disable enter/leave events for proximity and area triggers");
	REGISTER_CVAR(es_DrawProximityTriggers,0,0,
		"Shows Proximity Triggers.\n"
		"Usage: es_DrawProximityTriggers [0-255].  The parameter sets the transparency (alpha) level.\n"
		"Value 1 will be changed to 70.\n"
		"Default is 0 (off)\n");

	REGISTER_CVAR(es_DebugEntityUsage,0,0,
		"Draws information to the screen to show how entities are being used, per class, including total, active and hidden counts and memory usage"
		"\nUsage: es_DebugEntityUsage update_rate"
		"\nupdate_rate - Time in ms to refresh memory usage calculation or 0 to disable");
	REGISTER_CVAR(es_DebugEntityUsageFilter,"",0,"Filter entity usage debugging to classes which have this string in their name");

	REGISTER_CVAR(es_EnablePoolUse,-1,0,
		"Force toggle the use of entity pools on/off.\n"
		"Usage: es_EnablePoolUse 1\n"
		"Default is -1, or normal behavior. 0 forces system off. 1 forces system on.");

	REGISTER_CVAR(es_DebugPool,0,0,"Enable debug drawing of entity pools");
	REGISTER_CVAR(es_TestPoolSignatures,0,VF_CHEAT,"Enable signature testing on entity classes the first time they're prepared from an entity pool");
	REGISTER_CVAR(es_DebugPoolFilter,"",0,"Filter entity pool debugging for just this pool and draw more info about it");

	REGISTER_CVAR(es_LayerSaveLoadSerialization, 0, VF_CHEAT, 
		"Switches layer entity serialization: \n" 
		"0 - serialize all \n"
		"1 - automatically ignore entities on disabled layers \n"
		"2 - only ignore entities on non-save layers.");
	REGISTER_CVAR(es_LayerDebugInfo, 0, VF_CHEAT, 
		"Render debug info on active layers: \n"
		"0 - inactive \n"
		"1 - active brush layers \n"
		"2 - all layer info \n"
		"3 - all layer and all layer pak info");
	REGISTER_CVAR(es_SaveLoadUseLUANoSaveFlag, 0, VF_CHEAT, "Save&Load optimization : use lua flag to not serialize entities, for example rigid bodies.");
	
	REGISTER_CVAR(es_ClearPoolBookmarksOnLayerUnload, 1, VF_CHEAT, "Clear pool bookmarks when a layer is unloaded (saves memory and makes smaller saves)");
	pUpdateType = REGISTER_INT_CB("es_updateType", CComponentEventDistributer::EEventUpdatePolicy_UseDistributer, VF_CHEAT, "Defines how we update type for the entities", OnUpdateTypeChange);

	pDrawAreas = REGISTER_INT("es_DrawAreas",0,VF_CHEAT,"Enables drawing of Areas" );
	pDrawAreaGrid = REGISTER_INT("es_DrawAreaGrid",0,VF_CHEAT,"Enables drawing of Area Grid" );
	pDrawAreaDebug = REGISTER_INT("es_DrawAreaDebug",0,VF_CHEAT,"Enables debug drawing of Areas, set 2 for log details" );
	pDrawAudioProxyZRay = REGISTER_INT("es_DrawAudioProxyZRay",0,VF_CHEAT,"Enables drawing of Z ray on check for Z visibility" );

	REGISTER_CVAR(es_UsePhysVisibilityChecks, 1, 0,
		"Activates physics quality degradation and forceful sleeping for invisible and faraway entities" );
	REGISTER_CVAR(es_MaxPhysDist, 300.0f, 0,
		"Physical entities farther from the camera than this are forcefully deactivated" );
	REGISTER_CVAR(es_MaxPhysDistCloth, 300.0f, 0,
		"Cloth entities farther from the camera than this are forcefully deactivated" );
	REGISTER_CVAR(es_MaxPhysDistInvisible, 40.0f, 0,
		"Invisible physical entities farther from the camera than this are forcefully deactivated" );
	REGISTER_CVAR(es_FarPhysTimeout, 4.0f, 0,
		"Timeout for faraway physics forceful deactivation" );

  pMotionBlur = gEnv->pConsole->GetCVar("r_MotionBlur");
	pSysSpecLight = gEnv->pConsole->GetCVar("sys_spec_light");
	if (pSysSpecLight && gEnv->IsEditor())
		pSysSpecLight->SetOnChangeCallback( OnSysSpecLightChange );

 	REGISTER_CVAR(es_debugEntityLifetime,0,0,
		"Debug entities creation and deletion time" );

	REGISTER_COMMAND("es_debugAnim", (ConsoleCommandFunc)EnableDebugAnimText, 0, "Debug entity animation (toggle on off)");

  REGISTER_CVAR(es_EntityUpdatePosDelta, 0.1f, 0,
    "Indicates the position delta by which an entity must move before the AreaManager updates position relevant data.\n"
    "Default: 0.1 (10 cm)");

	REGISTER_CVAR(es_debugDrawEntityIDs, 0, VF_CHEAT,
		"Displays the EntityId of all entities.\n"
		"Default is 0 (off), any other number enables it.\n"
		"Note: es_debug must be set to 1 also (or else the EntityId won't be displayed)");
}
Exemplo n.º 13
0
int CGameStartup::Update(bool haveFocus, unsigned int updateFlags)
{
	CRYPROFILE_SCOPE_PROFILE_MARKER("MT: MainLoop");

#if defined(JOBMANAGER_SUPPORT_PROFILING)
	gEnv->GetJobManager()->SetFrameStartTime(gEnv->pTimer->GetAsyncTime());
#endif
	
	int returnCode = 0;

	if (gEnv && gEnv->pSystem && gEnv->pConsole)
	{
#ifdef WIN32
		if(gEnv && gEnv->pRenderer && gEnv->pRenderer->GetHWND())
		{
			bool focus = (::GetFocus() == gEnv->pRenderer->GetHWND());
			static bool focused = focus;
			if (focus != focused)
			{
				if(gEnv->pSystem->GetISystemEventDispatcher())
				{
					gEnv->pSystem->GetISystemEventDispatcher()->OnSystemEvent(ESYSTEM_EVENT_CHANGE_FOCUS, focus, 0);
				}
				focused = focus;
			}
		}
#endif
	}

	// update the game
	if (m_pMod)
	{
		returnCode = m_pMod->Update(haveFocus, updateFlags);
	}

#if defined(ENABLE_STATS_AGENT)
	CStatsAgent::Update();
#endif

#if defined(JOBMANAGER_SUPPORT_FRAMEPROFILER)

	// Update Backend profilers
	uint32 timeSample = JobManager::IWorkerBackEndProfiler::GetTimeSample();

	assert(gEnv);
	PREFAST_ASSUME(gEnv);
	
	const JobManager::IBackend * const __restrict pBackends[] = 
	{
		gEnv->GetJobManager()->GetBackEnd(JobManager::eBET_Thread),
		gEnv->GetJobManager()->GetBackEnd(JobManager::eBET_Blocking),
	};

	for(int i=0; i<sizeof(pBackends)/sizeof(pBackends[0]); ++i)
	{
		if(pBackends[i])
		{
			JobManager::IWorkerBackEndProfiler* pWorkerProfiler = pBackends[i]->GetBackEndWorkerProfiler();
			pWorkerProfiler->Update(timeSample);
		}
	}
#endif

	// ghetto fullscreen detection, because renderer does not provide any kind of listener
	if (!m_fullScreenCVarSetup && gEnv && gEnv->pSystem && gEnv->pConsole)
	{
		ICVar *pVar = gEnv->pConsole->GetCVar("r_Fullscreen");
		if (pVar)
		{
			pVar->SetOnChangeCallback(FullScreenCVarChanged);
			m_fullScreenCVarSetup = true;
		}
	}
#if ENABLE_AUTO_TESTER 
	s_autoTesterSingleton.Update();
#endif
	GCOV_FLUSH_UPDATE;

	return returnCode;
}
Exemplo n.º 14
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;
}