bool FRawProfilerSession::HandleTicker( float DeltaTime )
{
#if	0
	StatsThreadStats;
	Stream;

	enum
	{
		MAX_NUM_DATA_PER_TICK = 30
	};
	int32 NumDataThisTick = 0;

	// Add the data to the mini-view.
	for( int32 FrameIndex = CurrentMiniViewFrame; FrameIndex < Stream.FramesInfo.Num(); ++FrameIndex )
	{
		const FStatsFrameInfo& StatsFrameInfo = Stream.FramesInfo[FrameIndex];
		// Convert from cycles to ms.
		TMap<uint32, float> ThreadMS;
		for( auto InnerIt = StatsFrameInfo.ThreadCycles.CreateConstIterator(); InnerIt; ++InnerIt )
		{
			ThreadMS.Add( InnerIt.Key(), StatMetaData->ConvertCyclesToMS( InnerIt.Value() ) );
		}

		// Pass the reference to the stats' metadata.
		// @TODO yrx 2014-04-03 Figure out something better later.
		OnAddThreadTime.ExecuteIfBound( FrameIndex, ThreadMS, StatMetaData );

		//CurrentMiniViewFrame++;
		NumDataThisTick++;
		if( NumDataThisTick > MAX_NUM_DATA_PER_TICK )
		{
			break;
		}
	}
#endif // 0

	return true;
}
Exemple #2
0
/**
 * insert
 */                                        
BOOST_AUTO_TEST_CASE_TEMPLATE(stest_insert, TMap, test_types) {
    // insert x values, insert them again, check values
    using char_tt = typename TMap::char_type; 
    
    const size_t nb_values = 100000;
    TMap set;
    typename TMap::iterator it;
    bool inserted;
    
    for(size_t i = 0; i < nb_values; i++) {
        std::tie(it, inserted) = set.insert(utils::get_key<char_tt>(i));
        
        BOOST_CHECK_EQUAL(it.key(), (utils::get_key<char_tt>(i)));
        BOOST_CHECK(inserted);
    }
    BOOST_CHECK_EQUAL(set.size(), nb_values);
    
    for(size_t i = 0; i < nb_values; i++) {
        std::tie(it, inserted) = set.insert(utils::get_key<char_tt>(i));
        
        BOOST_CHECK_EQUAL(it.key(), (utils::get_key<char_tt>(i)));
        BOOST_CHECK(!inserted);
    }
    
    for(size_t i = 0; i < nb_values; i++) {
        it = set.find(utils::get_key<char_tt>(i));
        
        BOOST_CHECK(it != set.end());
        BOOST_CHECK_EQUAL(it.key(), (utils::get_key<char_tt>(i)));
    }
    
    for(auto it = set.begin(); it != set.end(); ++it) {
        auto it_find = set.find(it.key());
        
        BOOST_CHECK(it_find != set.end());
        BOOST_CHECK_EQUAL(it_find.key(), it.key());
    }
}
Exemple #3
0
void ldvcellValidaObj(RayCell c, const TMap & map, Objetos_t & obj, int nivelMech){
  THex * infoCell = NULL;
  THex * infoCellAlt = NULL;
  Objetos_t objCell, objCellAlt;
  
  // Vemos los objetos en el hexagono
  infoCell = map.getHex( c.p );
  if( infoCell != NULL && (infoCell->nivel + 2) > nivelMech ){
    if( infoCell->objeto == 2 )
      objCell.bosqueDenso++;
    else if( infoCell->humo )
      objCell.humo++;
    else if( infoCell->objeto == 1 )
      objCell.bosqueDisperso++;
  }
  
  // Vemos los objetos en el Hexagono alternativo
  // En caso de existir
  if( c.alt != NULL ){
    infoCellAlt = map.getHex( *c.alt );
    if( infoCellAlt != NULL && (infoCellAlt->nivel + 2) > nivelMech){
      if( infoCellAlt->objeto == 2 )
	objCellAlt.bosqueDenso++;
      else if( infoCellAlt->humo )
	objCellAlt.humo++;
      else if( infoCellAlt->objeto == 1 )
	objCellAlt.bosqueDisperso++;
    }
  }

  // Comparamos a ver que Hexagono penaliza mas
  if(objCell.bosqueDenso > 0 || objCellAlt.bosqueDenso > 0)
    obj.bosqueDenso++;
  else if(objCell.humo > 0 || objCellAlt.humo > 0)
    obj.humo++;
  else if(objCell.bosqueDisperso > 0 || objCellAlt.bosqueDisperso > 0)
    obj.bosqueDisperso++;  
}
	void VerifyFormatVersions(TMap<FString, uint16>& ReceivedFormatVersionMap)
	{
		for (auto Pair : ReceivedFormatVersionMap)
		{
			auto* Found = FormatVersionMap.Find(Pair.Key);
			if (Found)
			{
				GFailedDueToShaderFormatVersion = true;
				FCString::Snprintf(GErrorExceptionDescription, sizeof(GErrorExceptionDescription), TEXT("Mismatched shader version for format %s; did you forget to build ShaderCompilerWorker?"), *Pair.Key, *Found, Pair.Value);

				checkf(Pair.Value == *Found, TEXT("Exiting due to mismatched shader version for format %s, version %d from ShaderCompilerWorker, received %d! Did you forget to build ShaderCompilerWorker?"), *Pair.Key, *Found, Pair.Value);
			}
		}
	}
void FCameraFilmbackSettingsCustomization::CustomizeChildren(TSharedRef<IPropertyHandle> StructPropertyHandle, class IDetailChildrenBuilder& ChildBuilder, IPropertyTypeCustomizationUtils& StructCustomizationUtils)
{
	// Retrieve structure's child properties
	uint32 NumChildren;
	StructPropertyHandle->GetNumChildren( NumChildren );	
	TMap<FName, TSharedPtr< IPropertyHandle > > PropertyHandles;	
	for( uint32 ChildIndex = 0; ChildIndex < NumChildren; ++ChildIndex )
	{
		TSharedRef<IPropertyHandle> ChildHandle = StructPropertyHandle->GetChildHandle( ChildIndex ).ToSharedRef();
		const FName PropertyName = ChildHandle->GetProperty()->GetFName();

		PropertyHandles.Add(PropertyName, ChildHandle);
	}
	
	// Retrieve special case properties
	SensorWidthHandle = PropertyHandles.FindChecked(GET_MEMBER_NAME_CHECKED(FCameraFilmbackSettings, SensorWidth));
	SensorHeightHandle = PropertyHandles.FindChecked(GET_MEMBER_NAME_CHECKED(FCameraFilmbackSettings, SensorHeight));

	for( auto Iter(PropertyHandles.CreateConstIterator()); Iter; ++Iter  )
	{
		IDetailPropertyRow& SettingsRow = ChildBuilder.AddChildProperty(Iter.Value().ToSharedRef());
	}	
}
void UActorComponent::PreEditChange(UProperty* PropertyThatWillChange)
{
	Super::PreEditChange(PropertyThatWillChange);

	if(IsRegistered())
	{
		// The component or its outer could be pending kill when calling PreEditChange when applying a transaction.
		// Don't do do a full recreate in this situation, and instead simply detach.
		if( !IsPendingKill() )
		{
			check(!EditReregisterContexts.Find(this));
			EditReregisterContexts.Add(this,new FComponentReregisterContext(this));
		}
		else
		{
			ExecuteUnregisterEvents();
			World = NULL;
		}
	}

	// Flush rendering commands to ensure the rendering thread processes the component detachment before it is modified.
	FlushRenderingCommands();
}
Exemple #7
0
static uint32_t ParticleColor(int rgb)
{
	int *val;
	int stuff;

	val = ColorSaver.CheckKey(rgb);
	if (val != NULL)
	{
		return *val;
	}
	stuff = rgb | (ColorMatcher.Pick(RPART(rgb), GPART(rgb), BPART(rgb)) << 24);
	ColorSaver[rgb] = stuff;
	return stuff;
}
void FIOSDeviceHelper::DoDeviceDisconnect(void* deviceHandle)
{
    IOSDevice* device = NULL;
    for (auto DeviceIterator = ConnectedDevices.CreateIterator(); DeviceIterator; ++DeviceIterator)
    {
        if (DeviceIterator.Key()->Handle() == deviceHandle)
        {
            device = DeviceIterator.Key();
            break;
        }
    }
    if (device != NULL)
    {
        // extract the device id from the connected list¯
		FIOSLaunchDaemonPong Event = ConnectedDevices.FindAndRemoveChecked(device);
    
        // fire the event
        FIOSDeviceHelper::OnDeviceDisconnected().Broadcast(Event);
        
        // delete the device
        delete device;
    }
}
	virtual void RegisterNets(FKismetFunctionContext& Context, UEdGraphNode* Node) override
	{
		UK2Node_Switch* SwitchNode = Cast<UK2Node_Switch>(Node);

		FNodeHandlingFunctor::RegisterNets(Context, Node);

		// Create a term to determine if the compare was successful or not
		//@TODO: Ideally we just create one ever, not one per switch
		FBPTerminal* BoolTerm = Context.CreateLocalTerminal();
		BoolTerm->Type.PinCategory = CompilerContext.GetSchema()->PC_Boolean;
		BoolTerm->Source = Node;
		BoolTerm->Name = Context.NetNameMap->MakeValidName(Node) + TEXT("_CmpSuccess");
		BoolTermMap.Add(Node, BoolTerm);
	}
Exemple #10
0
bool FindDataSample(const TMap &lookup, TObjArray &sampleinfis){
        //
        // Find Data sample in the list of samples
        //
        TObjArray *entry = dynamic_cast<TObjArray *>(lookup.GetValue(g_sample.Data()));
        if(!entry){
                printf("Sample %s not found in the list of samples", g_sample.Data());
                return false;
        }
        // Copy to output container
        sampleinfis.SetOwner(kFALSE);
        for(int ival = 0; ival < 4; ival++) sampleinfis.AddAt(entry->At(ival), ival);
        return true;
}
void UJavascriptEditorLibrary::GetHeightmapDataToMemory(ULandscapeInfo* LandscapeInfo, int32 MinX, int32 MinY, int32 MaxX, int32 MaxY)
{
	const int32 SizeX = (1 + MaxX - MinX);
	const int32 SizeY = (1 + MaxY - MinY);

	if (SizeX * SizeY * 2 == FArrayBufferAccessor::GetSize())
	{
		auto Buffer = (uint16*)FArrayBufferAccessor::GetData();

		FHeightmapAccessor<false> Accessor(LandscapeInfo);

		TMap<FIntPoint, uint16> Data;
		Accessor.GetData(MinX, MinY, MaxX, MaxY, Data);

		FMemory::Memzero(Buffer, SizeX * SizeY * 2);

		for (auto it = Data.CreateConstIterator(); it; ++it)
		{
			const auto& Point = it.Key();
			Buffer[Point.X + Point.Y * SizeX] = it.Value();
		}
	}
}
Exemple #12
0
bool FD3DGPUProfiler::FinishProfiling(TMap<int32, double>& OutEventIdToTimestampMap, ID3D11DeviceContext* Direct3DDeviceIMContext)
{
	bool bSuccess = true;

	check(CurrentGPUProfile);

	// Get the disjoint timestamp query result.
	CurrentGPUProfile->DisjointQuery.EndTracking();
	D3D11_QUERY_DATA_TIMESTAMP_DISJOINT DisjointQueryResult = CurrentGPUProfile->DisjointQuery.GetResult();
	if(DisjointQueryResult.Disjoint)
	{
		bSuccess = false;
	}
	else
	{
		// Read back the timestamp query results.
		for(int32 EventIndex = 0;EventIndex < CurrentGPUProfile->EventTimestampQueries.Num();++EventIndex)
		{
			TRefCountPtr<ID3D11Query> EventTimestampQuery = CurrentGPUProfile->EventTimestampQueries[EventIndex];

			uint64 EventTimestamp;
			const double StartTime = FPlatformTime::Seconds();
			HRESULT QueryGetDataResult;
			while(true)
			{
				QueryGetDataResult = Direct3DDeviceIMContext->GetData(EventTimestampQuery,&EventTimestamp,sizeof(EventTimestamp),0);
				if(QueryGetDataResult == S_FALSE && (FPlatformTime::Seconds() - StartTime) < 0.5)
				{
					FPlatformProcess::Sleep(0.005f);
				}
				else
				{
					break;
				}
			}
			if(QueryGetDataResult != S_OK)
			{
				bSuccess = false;
				break;
			}
			else
			{
				OutEventIdToTimestampMap.Add(EventIndex,(double)EventTimestamp / (double)DisjointQueryResult.Frequency);
			}
		}
	}

	CurrentGPUProfile.Reset();
	return bSuccess;
}
Exemple #13
0
//*****************************************************************************
//
void COOP_PotentiallyStoreUVDPickup ( const PClass *pType )
{
	// [BB] The current game mode doesn't need voodoo dolls, so no need to store any pickups.
	if ( COOP_VoodooDollsSelectedByGameMode() == false )
		return;

	// [BB] There is no ingame joining in such gamemodes, so no need to store any pickups.
	if ( GAMEMODE_GetFlags( GAMEMODE_GetCurrentMode( )) & GMF_MAPRESETS )
		return;

	// [BB] Nothing to store.
	if ( pType == NULL )
		return;

	// [BB] We only store weapons and keys since they might be crucial to finish a map.
	if ( ( pType->IsDescendantOf( RUNTIME_CLASS( AWeapon )) == false )
		&& ( pType->IsDescendantOf( RUNTIME_CLASS( AKey )) == false ) )
		return;

	const FName pickupName = pType->TypeName.GetChars();
	if ( UVDpickupMap.CheckKey( pickupName ) == false )
		UVDpickupMap.Insert( pickupName, 1 );
}
Exemple #14
0
// Called when the game starts or when spawned
void AGridV1::BeginPlay()
{
	Super::BeginPlay();

	int32 HalfX = GridSize.X / 2;
	int32 HalfY = GridSize.Y / 2;
	int32 HalfZ = GridSize.Z / 2;

	FActorSpawnParameters param;
	param.Owner = this;

	for (int32 x = -HalfX; x < HalfX; x++)
	{
		for (int32 y = -HalfY; y < HalfY; y++)
		{
			for (int32 z = -HalfZ; z < HalfZ; z++)
			{
				ACellV1* cell = GetWorld()->SpawnActor<ACellV1>(FVector(x, y, z) * VoxelSize * CellSize, FRotator(), param);
				cell->GridPosition = FInt3(x, y, z);
				cell->Grid = this;
				cell->FutureData = Async<TMap<FInt3, uint16>>(EAsyncExecution::ThreadPool, []()
				{
					TMap<FInt3, uint16> ret;
					for (int32 i = 0; i < 32; i++)
						for (int32 j = 0; j < 32; j++)
							for (int32 k = 0; k < 32; k++)
								ret.Add(FInt3(i, j, k), 1);
					return ret;
				});
				cell->OngoingLoading = true;

				cell->Mesh->SetMaterial(0, Material);
				Data.Add(FInt3(x, y, z), cell);
			}
		}
	}
}
void FDirectoryWatchRequestLinux::UnwatchDirectoryTree(const FString & RootAbsolutePath)
{
	UE_LOG(LogDirectoryWatcher, VeryVerbose, TEXT("Unwatching tree '%s'"), *RootAbsolutePath);
	// remove the watch for the folder and all subfolders
	// since it is expected that there will be a lot of them, just create a new TMap
	TMap<FString, int32, FDefaultSetAllocator, FCaseSensitiveLookupKeyFuncs<int32>> NewPathsToWatchDescriptors;
	for (auto MapIt = PathsToWatchDescriptors.CreateIterator(); MapIt; ++MapIt)
	{
		if (!MapIt->Key.StartsWith(RootAbsolutePath, ESearchCase::CaseSensitive))
		{
			NewPathsToWatchDescriptors.Add(MapIt->Key, MapIt->Value);
		}
		else
		{
			UE_LOG(LogDirectoryWatcher, VeryVerbose, TEXT("- Removing a watch %d for '%s'"), MapIt->Value, *MapIt->Key);

			// delete the descriptor
			int RetVal = inotify_rm_watch(FileDescriptor, MapIt->Value);

			// why check for RootAbsolutePath? Because this function may be called when root path has been deleted, and inotify_rm_watch() will fail
			// removing a watch on a deleted file... yay for API symmetry. Just "leak" the watch descriptor without the warning
			if (RetVal == -1 || MapIt->Key != RootAbsolutePath)
			{
				int ErrNo = errno;
				UE_LOG(LogDirectoryWatcher, Error, TEXT("inotify_rm_watch cannot remove descriptor %d for folder '%s' (errno = %d, %s)"),
					MapIt->Value,
					*MapIt->Key,
					ErrNo,
					ANSI_TO_TCHAR(strerror(ErrNo))
				);
			}
			WatchDescriptorsToPaths.Remove(MapIt->Value);
		}
	}

	PathsToWatchDescriptors = NewPathsToWatchDescriptors;
}
Exemple #16
0
void r3blandsim(
  const Int_t n_neutrons,
  const Int_t n_events,
  const string neuland_geo_file,
  const string input_file,
  const string basename
){

  // Output files
  const TString out_file = "r3bsim." + basename + ".root";
  const TString par_file = "r3bpar." + basename + ".root";

  // Constant configuration
  const TString  target = "LiH";
  const TString  fMC   = "TGeant3";
  const TString  fGene = "ascii";
  const Bool_t   fEventDisplay = kTRUE;
  const Bool_t   fUserPList = kTRUE;
  const Bool_t   fR3BMagnet = kTRUE;
  const Double_t fMeasCurrent = 2500.; 

  // Geometry
  TMap geometry;
  geometry.Add(new TObjString("TARGET"),        new TObjString("target_" + target + ".geo.root"));
  geometry.Add(new TObjString("ALADIN"),        new TObjString("aladin_v13a.geo.root"));
  geometry.Add(new TObjString("CRYSTALBALL"),   new TObjString("cal_v13a.geo.root"));
  geometry.Add(new TObjString("DCH"),           new TObjString("dch_v13a.geo.root"));
  geometry.Add(new TObjString("SCINTNEULAND"),  new TObjString(TString(neuland_geo_file)));


  // Load the Main Simulation macro
  const TString macro_r3ball = TString(getenv("VMCWORKDIR")) + TString("/macros/r3b/r3ball.C");
  gROOT->LoadMacro(macro_r3ball.Data());

  // Main Sim function call
  r3ball( n_events, geometry, target, fEventDisplay, fMC, fGene, fUserPList, fR3BMagnet, fMeasCurrent, out_file, par_file, input_file);
}
ALWAYS_INLINE
typename std::enable_if<
  std::is_base_of<BaseMap, TMap>::value, Object>::type
BaseMap::php_differenceByKey(const Variant& it) {
  if (!it.isObject()) {
    SystemLib::throwInvalidArgumentExceptionObject(
               "Parameter it must be an instance of Iterable");
  }
  ObjectData* obj = it.getObjectData();
  TMap* target = BaseMap::Clone<TMap>(this);
  auto ret = Object::attach(target);
  if (obj->isCollection()) {
    if (isMapCollection(obj->collectionType())) {
      auto map = static_cast<BaseMap*>(obj);
      auto* eLimit = map->elmLimit();
      for (auto* e = map->firstElm(); e != eLimit; e = nextElm(e, eLimit)) {
        if (e->hasIntKey()) {
          target->remove((int64_t)e->ikey);
        } else {
          assert(e->hasStrKey());
          target->remove(e->skey);
        }
      }
      return ret;
    }
  }
  for (ArrayIter iter(obj); iter; ++iter) {
    Variant k = iter.first();
    if (k.isInteger()) {
      target->remove(k.toInt64());
    } else {
      assert(k.isString());
      target->remove(k.getStringData());
    }
  }
  return ret;
}
Exemple #18
0
void FGlobalShaderMapId::AppendKeyString(FString& KeyString) const
{
	TMap<const TCHAR*,FCachedUniformBufferDeclaration> ReferencedUniformBuffers;

	for (int32 ShaderIndex = 0; ShaderIndex < ShaderTypeDependencies.Num(); ShaderIndex++)
	{
		KeyString += TEXT("_");
		const FShaderTypeDependency& ShaderTypeDependency = ShaderTypeDependencies[ShaderIndex];
		KeyString += ShaderTypeDependency.ShaderType->GetName();

		// Add the type's source hash so that we can invalidate cached shaders when .usf changes are made
		KeyString += ShaderTypeDependency.SourceHash.ToString();

		// Add the serialization history to the key string so that we can detect changes to global shader serialization without a corresponding .usf change
		ShaderTypeDependency.ShaderType->GetSerializationHistory().AppendKeyString(KeyString);

		const TMap<const TCHAR*,FCachedUniformBufferDeclaration>& ReferencedUniformBufferStructsCache = ShaderTypeDependency.ShaderType->GetReferencedUniformBufferStructsCache();

		// Gather referenced uniform buffers
		for (TMap<const TCHAR*,FCachedUniformBufferDeclaration>::TConstIterator It(ReferencedUniformBufferStructsCache); It; ++It)
		{
			ReferencedUniformBuffers.Add(It.Key(), It.Value());
		}
	}

	{
		TArray<uint8> TempData;
		FSerializationHistory SerializationHistory;
		FMemoryWriter Ar(TempData, true);
		FShaderSaveArchive SaveArchive(Ar, SerializationHistory);

		// Save uniform buffer member info so we can detect when layout has changed
		SerializeUniformBufferInfo(SaveArchive, ReferencedUniformBuffers);

		SerializationHistory.AppendKeyString(KeyString);
	}
}
float FGAEffectModifiersContainer::GatherMods(const FGameplayTagContainer& TagsIn, const TMap<FGAGameEffectHandle, TArray<FGAGameEffectModifier>>& Data)
{
	//possible optimization when needed - create separate thread.

	float ModifierVal = 0;
	float Add = 0;
	float Multiply = 1;
	float Subtract = 0;
	float Divide = 1;
	float PercentageAdd = 0;
	float PercentageSubtract = 0;
	for (auto It = Data.CreateConstIterator(); It; ++It)
	{
		for (const FGAGameEffectModifier& Test : It->Value)
		{
			if (TagsIn.MatchesAll(Test.RequiredTags, false))
			{
				switch (Test.ModType)
				{
				case EGAAttributeMod::Add:
					Add += Test.Value;
					break;
				case EGAAttributeMod::Multiply:
					Multiply += Test.Value;
					break;
				case EGAAttributeMod::Subtract:
					Subtract += Test.Value;
					break;
				case EGAAttributeMod::Divide:
					Divide += Test.Value;
					break;
				case EGAAttributeMod::PercentageAdd:
					PercentageAdd += Test.Value;
					break;
				case EGAAttributeMod::PercentageSubtract:
					PercentageSubtract += Test.Value;
					break;
				default:
					break;
				}
			}
		}
	}
	ModifierVal = ((Add - Subtract) * Multiply) / Divide;
	ModifierVal = ModifierVal + (ModifierVal * PercentageAdd);
	ModifierVal = ModifierVal - (ModifierVal * PercentageSubtract);
	SCOPE_CYCLE_COUNTER(STAT_GatherModifiers);
	return ModifierVal;
}
void UActorComponent::ConsolidatedPostEditChange(const FPropertyChangedEvent& PropertyChangedEvent)
{
	FComponentReregisterContext* ReregisterContext = EditReregisterContexts.FindRef(this);
	if(ReregisterContext)
	{
		delete ReregisterContext;
		EditReregisterContexts.Remove(this);

		AActor* MyOwner = GetOwner();
		if ( MyOwner && !MyOwner->IsTemplate() && PropertyChangedEvent.ChangeType != EPropertyChangeType::Interactive )
		{
			MyOwner->RerunConstructionScripts();
		}
	}

	// The component or its outer could be pending kill when calling PostEditChange when applying a transaction.
	// Don't do do a full recreate in this situation, and instead simply detach.
	if( IsPendingKill() )
	{
		// @todo UE4 james should this call UnregisterComponent instead to remove itself from the RegisteredComponents array on the owner?
		ExecuteUnregisterEvents();
		World = NULL;
	}
}
Exemple #21
0
//==========================================================================
//
// CheckForUnsafeStates
//
// Performs a quick analysis to find potentially bad states.
// This is not perfect because it cannot track jumps by function.
// For such cases a runtime check in the relevant places is also present.
//
//==========================================================================
static void CheckForUnsafeStates(PClassActor *obj)
{
	static ENamedName weaponstates[] = { NAME_Ready, NAME_Deselect, NAME_Select, NAME_Fire, NAME_AltFire, NAME_Hold, NAME_AltHold, NAME_Flash, NAME_AltFlash, NAME_None };
	static ENamedName pickupstates[] = { NAME_Pickup, NAME_Drop, NAME_Use, NAME_None };
	TMap<FState *, bool> checked;
	ENamedName *test;

	if (obj->IsDescendantOf(RUNTIME_CLASS(AWeapon)))
	{
		if (obj->Size == RUNTIME_CLASS(AWeapon)->Size) return;	// This class cannot have user variables.
		test = weaponstates;
	}
	else if (obj->IsDescendantOf(RUNTIME_CLASS(ACustomInventory)))
	{
		if (obj->Size == RUNTIME_CLASS(ACustomInventory)->Size) return;	// This class cannot have user variables.
		test = pickupstates;
	}
	else return;	// something else derived from AStateProvider. We do not know what this may be.

	for (; *test != NAME_None; test++)
	{
		FState *state = obj->FindState(*test);
		while (state != nullptr && checked.CheckKey(state) == nullptr)	// have we checked this state already. If yes, we can stop checking the current chain.
		{
			checked[state] = true;
			if (state->ActionFunc && state->ActionFunc->Unsafe)
			{
				// If an unsafe function (i.e. one that accesses user variables) is being detected, print a warning once and remove the bogus function. We may not call it because that would inevitably crash.
				auto owner = FState::StaticFindStateOwner(state);
				GetStateSource(state).Message(MSG_ERROR, TEXTCOLOR_RED "Unsafe state call in state %s.%d which accesses user variables, reached by %s.%s.\n",
					owner->TypeName.GetChars(), state - owner->OwnedStates, obj->TypeName.GetChars(), FName(*test).GetChars());
			}
			state = state->NextState;
		}
	}
}
Exemple #22
0
    bool OnSelectTab(int value)
    {
        TRef<Pane> pPane;
        if (m_nPaneIDCurrent != value && m_mapPanes.Find(value, pPane)) {
            if (pPane != m_pPaneCurrent) {
                if (m_pSubTabCurrent) {
                    m_pSubTabCurrent->ShowSelPane(false);
                }

                m_pSubTabCurrent = NULL;

                if (m_mapSubTabs.Find(value, m_pSubTabCurrent)) {
                    m_pSubTabCurrent->ShowSelPane(true);
                }

                m_pColumnPane->RemoveChild(m_pPaneCurrent);
                m_pColumnPane->InsertAtBottom(m_pPaneCurrent = pPane);
            }

            m_nPaneIDCurrent = value;
            m_pEventSource->Trigger(value); // tell sinks what tab is active
        }
        return true;
    }
void FDesktopPlatformBase::EnumerateLauncherEngineInstallations(TMap<FString, FString> &OutInstallations)
{
	// Cache the launcher install list if necessary
	ReadLauncherInstallationList();

	// We've got a list of launcher installations. Filter it by the engine installations.
	for(TMap<FString, FString>::TConstIterator Iter(LauncherInstallationList); Iter; ++Iter)
	{
		FString AppName = Iter.Key();
		if(AppName.RemoveFromStart(TEXT("UE_"), ESearchCase::CaseSensitive))
		{
			OutInstallations.Add(AppName, Iter.Value());
		}
	}
}
bool FDesktopPlatformBase::GetDefaultEngineIdentifier(FString &OutId)
{
	TMap<FString, FString> Installations;
	EnumerateEngineInstallations(Installations);

	bool bRes = false;
	if (Installations.Num() > 0)
	{
		// Default to the first install
		TMap<FString, FString>::TConstIterator Iter(Installations);
		OutId = Iter.Key();
		++Iter;

		// Try to find the most preferred install
		for(; Iter; ++Iter)
		{
			if(IsPreferredEngineIdentifier(Iter.Key(), OutId))
			{
				OutId = Iter.Key();
			}
		}
	}
	return bRes;
}
void CStatCounterArray::Insert (const CString &sStat, int iCount, const CString &sSection, const CString &sSort)

//	Insert
//
//	Adds the given stat. If the stat already exists (by name) the counts are added

	{
	if (iCount == 0)
		return;

	ASSERT(!sStat.IsBlank());
	ASSERT(!sSection.IsBlank());

	//	First look for the section

	TMap<CString, SEntry> *pSection = m_Array.Find(sSection);
	if (pSection == NULL)
		pSection = m_Array.Insert(sSection);

	//	Next look for the entry

	SEntry *pEntry = pSection->Find(sStat);
	if (pEntry == NULL)
		{
		pEntry = pSection->Insert(sStat);
		pEntry->iCount = iCount;
		pEntry->sSort = sSort;
		}
	else
		{
		if (iCount > pEntry->iCount)
			pEntry->sSort = sSort;

		pEntry->iCount += iCount;
		}
	}
int CMarkovWordGenerator::GenerateUnique (int iCount, TArray<CString> *retArray)

//	GenerateUnique
//
//	Generates an array of unique words

	{
	int i;
	TMap<CString, DWORD> Generated;

	for (i = 0; i < iCount; i++)
		{
		int iTriesLeft = 500;

		while (iTriesLeft > 0)
			{
			//	Generate a random word

			CString sWord = Generate();

			//	Lookup the word in our map. If we found it,
			//	try again.

			if (Generated.Find(sWord))
				{
				iTriesLeft--;
				continue;
				}

			//	If it is unique, add it

			Generated.Insert(sWord, 1);
			break;
			}

		//	If we couldn't find a unique word, then quit

		if (iTriesLeft == 0)
			break;
		}

	//	Add the entries that we generated to the output array

	CMapIterator j;
	Generated.Reset(j);
	int iGeneratedCount = 0;
	while (Generated.HasMore(j))
		{
		DWORD *pDummy;
		CString sWord = Generated.GetNext(j, &pDummy);
		retArray->Insert(sWord);
		iGeneratedCount++;
		}

	return iGeneratedCount;
	}
void UFoliageStatistics::FoliageOverlappingMeshCounts_Debug(UObject* WorldContextObject, FVector CenterPosition, float Radius, TMap<UStaticMesh*, int32>& OutMeshCounts)
{
	UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject);
	const FSphere Sphere(CenterPosition, Radius);

	OutMeshCounts.Reset();
	for (TActorIterator<AInstancedFoliageActor> It(World); It; ++It)
	{
		AInstancedFoliageActor* IFA = *It;
		if (!IFA->IsPendingKill())
		{
			IFA->GetOverlappingMeshCounts(Sphere, OutMeshCounts);
		}
	}
}
FHotReloadClassReinstancer::FHotReloadClassReinstancer(UClass* InNewClass, UClass* InOldClass, TMap<UObject*, UObject*>& OutReconstructedCDOsMap, TSet<UBlueprint*>& InBPSetToRecompile, TSet<UBlueprint*>& InBPSetToRecompileBytecodeOnly)
	: NewClass(nullptr)
	, bNeedsReinstancing(false)
	, CopyOfPreviousCDO(nullptr)
	, ReconstructedCDOsMap(OutReconstructedCDOsMap)
	, BPSetToRecompile(InBPSetToRecompile)
	, BPSetToRecompileBytecodeOnly(InBPSetToRecompileBytecodeOnly)
{
	ensure(InOldClass);
	ensure(!HotReloadedOldClass && !HotReloadedNewClass);
	HotReloadedOldClass = InOldClass;
	HotReloadedNewClass = InNewClass ? InNewClass : InOldClass;

	// If InNewClass is NULL, then the old class has not changed after hot-reload.
	// However, we still need to check for changes to its constructor code (CDO values).
	if (InNewClass)
	{
		SetupNewClassReinstancing(InNewClass, InOldClass);

		TMap<UObject*, UObject*> ClassRedirects;
		ClassRedirects.Add(InOldClass, InNewClass);

		for (TObjectIterator<UBlueprint> BlueprintIt; BlueprintIt; ++BlueprintIt)
		{
			FArchiveReplaceObjectRef<UObject> ReplaceObjectArch(*BlueprintIt, ClassRedirects, false, true, true);
			if (ReplaceObjectArch.GetCount())
			{
				EnlistDependentBlueprintToRecompile(*BlueprintIt, true);
			}
		}
	}
	else
	{
		RecreateCDOAndSetupOldClassReinstancing(InOldClass);
	}
}
void FBuildPatchAppManifest::EnumerateChunkPartInventory(const TArray<FGuid>& ChunksRequired, TMap<FGuid, TArray<FFileChunkPart>>& ChunkPartsAvailable) const
{
	ChunkPartsAvailable.Empty();
	// For each file in the manifest, check what chunks it is made out of, and grab details for the ones in ChunksRequired
	for (auto FileManifestIt = Data->FileManifestList.CreateConstIterator(); FileManifestIt && !FBuildPatchInstallError::HasFatalError(); ++FileManifestIt)
	{
		const FFileManifestData& FileManifest = *FileManifestIt;
		uint64 FileOffset = 0;
		for (auto ChunkPartIt = FileManifest.FileChunkParts.CreateConstIterator(); ChunkPartIt && !FBuildPatchInstallError::HasFatalError(); ++ChunkPartIt)
		{
			const FChunkPartData& ChunkPart = *ChunkPartIt;
			if (ChunksRequired.Contains(ChunkPart.Guid))
			{
				TArray<FFileChunkPart>& FileChunkParts = ChunkPartsAvailable.FindOrAdd(ChunkPart.Guid);
				FFileChunkPart FileChunkPart;
				FileChunkPart.Filename = FileManifest.Filename;
				FileChunkPart.ChunkPart = ChunkPart;
				FileChunkPart.FileOffset = FileOffset;
				FileChunkParts.Add(FileChunkPart);
			}
			FileOffset += ChunkPart.Size;
		}
	}
}
TMap<FString, FString> PackageAutoSaverJson::LoadRestoreFile()
{
	TMap<FString, FString> PackagesThatCanBeRestored;

	const FString Filename = GetRestoreFilename(false);
	FArchive* const FileAr = IFileManager::Get().CreateFileReader(*Filename);
	if(!FileAr)
	{
		// File doesn't exist; nothing to restore
		return PackagesThatCanBeRestored;
	}

	bool bJsonLoaded = false;
	TSharedPtr<FJsonObject> RootObject = MakeShareable(new FJsonObject);
	{
		TSharedRef<FJsonReader> Reader = FJsonReaderFactory::Create(FileAr);
		bJsonLoaded = FJsonSerializer::Deserialize(Reader, RootObject);		
		FileAr->Close();
	}

	if(!bJsonLoaded || !RootObject->GetBoolField(TagRestoreEnabled))
	{
		// File failed to load, or the restore is disabled; nothing to restore
		return PackagesThatCanBeRestored;
	}

	TArray< TSharedPtr<FJsonValue> > PackagesThatCanBeRestoredArray = RootObject->GetArrayField(TagPackages);
	for(auto It = PackagesThatCanBeRestoredArray.CreateConstIterator(); It; ++It)
	{
		TSharedPtr<FJsonObject> EntryObject = (*It)->AsObject();

		const FString PackagePathName = EntryObject->GetStringField(TagPackagePathName);
		const FString AutoSavePath = EntryObject->GetStringField(TagAutoSavePath);
		PackagesThatCanBeRestored.Add(PackagePathName, AutoSavePath);
	}

	return PackagesThatCanBeRestored;
}