Files
Ben Marsh 7ce4c05fda Copying //UE4/Dev-Core to //UE4/Dev-Main (Source: //UE4/Dev-Core @ 4034418)
#lockdown Nick.Penwarden
#rb none

============================
  MAJOR FEATURES & CHANGES
============================

Change 3851142 by Robert.Manuszewski

	When BP clustering is enabled, make sure to add the template to the BP cluster when replacing it.

Change 3853797 by Ben.Marsh

	BuildGraph: Add a <Trace> element, which allows logging messages after the string is parsed (as opposed to the Log task, which logs them at runtime). Useful for debugging macro expansion, etc...

	Also add a -showdiagnostics parameter, to have diagnostic messages output even when running with the -listonly option.

Change 3857540 by Graeme.Thornton

	Properly process the uexp file for a umap asset when generating a pak patch. Stop those uexp files being included in the patch even when they haven't changed

Change 3860062 by Steve.Robb

	Fix for FString::Reset()'s buffer not being an empty null-terminated string (affects FString::ParseIntoArray, for example).

Change 3860138 by Steve.Robb

	Fix for FString::ParseIntoArray() for when string memory has been allocated but has no characters.

Change 3860273 by Steve.Robb

	Tidy up of FHotReloadClassReinstancer::FCDOWriter to not do stuff in constructors.

Change 3863203 by Steve.Robb

	Crash fix for UObjects whose constructors are defined as = default;, which would re-null the UObject state (ClassPrivate, OuterPrivate etc.).

	See: https://udn.unrealengine.com/questions/412930/crash-due-to-default-constructor.html

Change 3864588 by Graeme.Thornton

	Crypto Keys Improvements
	 - Removed UAT command line params for encryption. Centrally configured by the editor settings now.
	 - UAT staging now creates a small json file containing the keys and settings used for encryption and signing and stores it in the build metadata
	 - Minor refactoring of UAT encryption processing to use the new cryptokeys json file
	 - UnrealPak can be told to get its encryption settings from a json crypto file with the "-CryptoKeys=<filename>"
	 - UnrealPak can now accept a "PatchCryptoKeys=<filename" parameter which gives it a filename to a cryptokeys json file that it can use to unpack the patch reference paks

Change 3864691 by Robert.Manuszewski

	Don't add objects that are in root set to GC clusters to prevent them from keeping the clusters alive forever.

Change 3864744 by Robert.Manuszewski

	Added the ability to get the actual filename of the log file FOutputDeviceFile writes to.

Change 3864816 by Graeme.Thornton

	TBA: Minor formatting improvements to textasset commandlet

Change 3868939 by Graeme.Thornton

	TBA: If -outputPath isn't supplied to TextAsset commandlet, output converted files to the {ProjectSaved}/TextAssets directory

Change 3869031 by Graeme.Thornton

	TBA: Changed timing logs in TextAsset commandlet to be Display so we can see them in the EC log

Change 3871802 by Steve.Robb

	Class cast flags and property flags are now visible in the debugger.

Change 3871863 by Robert.Manuszewski

	Serializing object will now be passed to GC so that it can be logged in case the referenced objects is garbage.

Change 3874413 by Steve.Robb

	Algo::MinElement and Algo::MaxElement, for finding the minimum and maximum element in a range, and *By versions which take projections.
	TRangePointerType moved to its own file and used in Algo::MinElement and Algo::MaxElement.

Change 3874457 by Ben.Marsh

	When spawning child processes, only allow them to inherit the writable ends of the stderr and stdout pipe. Fixes an issue related to AutomationTool hanging when the editor closes after running automation tests.

	The editor launches ADB.EXE (Android Debug Bridge) on editor startup, which forks itself to initialize a server. Even though the child process has its own stdout and stderr pipes, it also inherits the pipes for the editor. When run from C#, as we do for automation tests, Process.WaitForExit() waits for all pipes to be closed before returning. This can't happen if the forked ADB instance still has a reference to the editor's pipes.

Change 3876435 by Robert.Manuszewski

	Don't add root set objects to level actor container to prevent situations where clusters are kept alive forever

Change 3878762 by Robert.Manuszewski

	Fixing potential LinkerLoad leak when a package that still has a linker associated with it is being destroyed.

Change 3878850 by Robert.Manuszewski

	SerializePreloadDependencies will now serialize raw data into the array instead of serializing one element at a time to speed up serialization performance.

Change 3881331 by Graeme.Thornton

	TBA: SavePackage rejigged to write all header information in terms of FStructuredArchive, with all exports written through an FArchive adapter

Change 3886983 by Ben.Marsh

	UGS: Fix notification window not expanding to fit long captions.

Change 3887006 by Ben.Marsh

	UGS: Change modal dialog to regular window style to avoid weird alignment issues under Windows 10.

Change 3887500 by Ben.Marsh

	UGS: Add support for grouping build badges by a prefix. Badges such as "Foo:Bar1", "Foo:Bar2" will be grouped together (with "Foo:" stripped from the displayed badge names).

	Also add a separate column showing the type of each change, rather than including it in the CIS column, and change badges to a more angular Windows 10 style.

Change 3887513 by Ben.Marsh

	UGS: Fix badge text drawing outside the clipping bounds.

Change 3888010 by Josh.Engebretson

	Fix UVS logging to UnrealVersionSelector/Saved/Logs and instead use project's log path
	#jira none

Change 3888418 by Ben.Marsh

	UGS: Add a cache for computed badge layout information. Improves responsiveness when redrawing.

Change 3889457 by Steve.Robb

	GitHub #4457 : Display abbreviations properly when converting FNames to display string

	#jira UE-54611

Change 3889547 by Ben.Marsh

	UGS: Add an extensible method for adding arbitrary badges to the right of the "description" column, by running a regular expression over the changelist description.

	Epic uses a "#tag" style annotations in changelist descriptions and Perforce triggers to verify them. "#jira" is used to link a changelist to an issue tracked in Jira, for example. A matcher to add a badge next to every changelist with a #jira tag, and link to the corresponding issue in Jira, could be set up with an addition to the project's Build/UnrealGameSync.ini file like this:

	[Badges]
	+DescriptionBadges=(Pattern="(?i)#\\s*jira\\s*:?\\s+([A-Za-z]+-[0-9]+)", Name="$1", Group="Jira", Color="#c0c0c0", HoverColor="#e0e0e0", Url="https://jira.it.epicgames.net/browse/$1")

	The "Pattern" attribute specifies the regex to match, and may capture portions of the matched text to be substituted later. "Label" specifies the label to appear on the badge. "Group" specifies an arbitrary identifier used to group related badges together rather than separating them with whitespace. "Color" and "HoverColor" specify hex RGB colors for the badges. "Url" specifies the path to open with a C# Process.Open call if the badge is clicked.

Change 3889726 by Ben.Marsh

	UGS: Fix description badges that don't have any associated URL.

Change 3889995 by Ben.Marsh

	UGS: Fix issue where popup menus can create top level windows in the taskbar. Seemlingly caused by capturing mouse before the window has been activated - removed capture code, and replaced with handling of OnMouseLeave() event instead.

Change 3890007 by Ben.Marsh

	UGS: Add a caption underneath the project logo which shows the current stream, to make it more obvious.

Change 3890057 by Ben.Marsh

	UGS: Fix repainting glitch when resizing window; bounds for status panel lines was not being reset correctly.

Change 3891069 by Robert.Manuszewski

	Fixing a crash in MallocBinned2 when running with malloc profiler enabled.

Change 3891084 by Steve.Robb

	Back out changelist 3881331 because it's causing cook errors.

Change 3891100 by Ben.Marsh

	UGS: Add support for a per-branch "message of the day"-style feature. Messages can be specified in a project's config file in Perforce (eg. <ProjectDir>/Build/UnrealGameSync.ini) as follows:

	[//UE4/Main/Samples/Games/ShooterGame.uproject]
	Message=:alert:  Lockdown for fixes is **5pm on Friday**. Only fixes for the 2.0 release should be submitted to this branch. [34 issues](https://jira.it.epicgames.net) are remaining as of 2/15.

	A limited subset of Markdown is supported: [web links](http://www.google.com), *italic*, _italic_, **bold**, __bold__. Icons will be supported through :icon: syntax; the only icon currently available is :alert:

Change 3891346 by Steve.Robb

	TSharedPtr::operator bool, and some usage of it.

Change 3891787 by Steve.Robb

	Fix for buffer overflow in FDebug::LogFormattedMessageWithCallstack().

Change 3892379 by Ben.Marsh

	UGS: Fix notification window containing the group fix for each build type.

Change 3892400 by Ben.Marsh

	UGS: Shrink the size of the alert panel.

Change 3892496 by Ben.Marsh

	UGS: Dim badges for changes which aren't eligable for syncing.

Change 3893932 by Steve.Robb

	Re-removal of SetShouldHandleAsWeakRef, which was originally removed in CL# 3437205.

Change 3895872 by Ben.Marsh

	UGS: Show the stream name in tab labels by default.

Change 3896366 by Ben.Marsh

	UGS: Automatically resize columns when the main window is resized, and allow specifying desired column widths for projects that have a large number of CIS badges.

	Columns are now resized proportionally, clamped to a minimum size. Columns will automatically expand up to a desired maximum size, though can be explicitly resized larger if necessary. Columns will not be resized if they are already larger than the window can show, or smaller than the window has space to show.

Change 3896367 by Ben.Marsh

	UGS: UI tweaks - change and time columns are now centered, "Unknown" badge is displayed until a change's type has been determined, increase height of status panel.

Change 3896425 by Ben.Marsh

	UGS: Speculative fix for race condition on clients displaying "under investigation" state. If the DB event is received before a change where an investigation is cancelled is polled from Perforce, we will exclude the resolve event from the list of active investigations.

Change 3896461 by Ben.Marsh

	UGS: Add an option to allow setting a tint color to be applied to the status panel, to allow identifying streams more easily. To use, add a setting similar to the following to a project's Build/UnrealGameSync.ini file:

	[//UE4/Main/Samples/Games/ShooterGame/ShooterGame.uproject]
	StatusPanelColor=#dcdcf0

Change 3899530 by Ben.Marsh

	Add unified syntax for overriding branch specific settings. Checks branch settings first, then [Default] section.

Change 3901164 by Ben.Marsh

	UGS: Add a class to store all the resources for the status panel.

Change 3901165 by Graeme.Thornton

	TBA: Attempt #2 at submitting the text asset saving code. SavePackage rejigged to write all header information in terms of FStructuredArchive, with all exports written through an FArchive adapter. Minimal amount of structured archive serialization functions added to allow this data to be written

Change 3901301 by Ben.Marsh

	UGS: Add support for reading the latest version of the project config file from Perforce. Some settings should be read depending on the CL you are synced to (eg. build steps), whereas others (MOTD, branch status) should always use the latest version. Will read the local version if checked out, to allow testing local changes.

Change 3902454 by Ben.Marsh

	UGS: Fix logo not being redrawn in the correct position when starting to sync.

Change 3903416 by Ben.Marsh

	UGS: Group badges explicitly through INI file rather than by expecting name to contain ':'.

Change 3904154 by Josh.Engebretson

	Adding Breakpad to ThirdParty sources (Git Commit: 49907e1c3457570f56d959ae26dec6c3a5edd417 https://chromium.googlesource.com/breakpad/breakpad)
	#jira UE-55442

Change 3904648 by Ben.Marsh

	UGS: Remove files from the workspace that are excluded by the sync filter.

	The user's config file stores a hash of the last sync filter. During syncing, if this hash doesn not match the previous value, we enumerate all the files in the #have list and remove anything masked out by the filter.

	#jira UE-47335

Change 3905442 by Steve.Robb

	Change of the ConvertFromType() multi-bool return value to a more descriptive enum.
	Some return values here do not make sense - this is because the existing logic is being preserved and will be fixed in a separate change.

Change 3905629 by Ben.Marsh

	UGS: Fix race condition between two child processes starting on different threads, and inheriting the other's intended stdout/stderr pipes. This prevents pipes being closed when one of the child processes shuts down, and causes waits on the read ends of those pipes to continue indefinitely.

Change 3906447 by Steve.Robb

	Rename EConvertFromTypeResult enumerators.

Change 3906574 by Steve.Robb

	Crash fix for container conversion failure during tagged property import.

Change 3909255 by Daniel.Lamb

	Fixed issue with DLCpackaging crashing on windows
	#jira UE-42880
	#test EngineTest windows

Change 3909270 by Steve.Robb

	Seek instead of skipping bad properties byte-by-byte.

Change 3909324 by Steve.Robb

	Use switch statement instead of repeated if/else.

Change 3909525 by Ben.Marsh

	UGS: Use the StudioEditor target when syncing content-only Enterprise projects.

Change 3911754 by Daniel.Lamb

	Fix for building pak patches.

	#jira UE-55340

Change 3911942 by Robert.Manuszewski

	Fixing an ensure when MediaPlayer is being constructed from any thread other than the main one.

Change 3913067 by Ben.Marsh

	UGS: Allow workspace sync filter categories to re-enable categories that are disabled by the global filter.

Change 3913209 by Ben.Marsh

	UGS: Fix incorrect target name when compiling Enterprise projects.

Change 3917358 by Steve.Robb

	Fix for GetLen(FString).

Change 3919610 by Ben.Marsh

	Put data for CrashReportClient in a PAK file of its own (under Engine/Programs/CrashReportClient/Content/Paks/CrashReportClient.pak). There are a large number of small files required for it to run with loose files, which takes a lot of space on disk (due to cluster sizes), and is unweildy to move around.

	CrashReporter UFS files are tracked in a separate dictionary to regular UFS files to allow construction of the additional PAK file.

Change 3921002 by Ben.Marsh

	UGS: Add option for syncing all projects in a branch. Off by default. Also add support for masking in additional paths to be synced (eg. one or two extra projects).

Change 3921008 by Ben.Marsh

	UGS: Prevent pause waiting for mutual exclusivity when syncing precompiled binaries. We don't need to generate project files or build, so there's no need to wait in line.

Change 3921906 by Steve.Robb

	New interpolation functions for quaternions.

	https://udn.unrealengine.com/questions/419028/quaternion-interp-to-functions.html

Change 3921978 by Graeme.Thornton

	TBA: Make "Loader" member of FLinkerLoad private to prevent use outside of FLinkerLoad. This archive could be something unexpected if the linker is for a text asset package, so we need to stop people accessing it.

Change 3924520 by Graeme.Thornton

	UnrealPak: Improve encryption summary log messages

Change 3924522 by Graeme.Thornton

	UAT: Add *Encryption.ini to the list of auto-blacklisted config filenames

Change 3924604 by Graeme.Thornton

	UnrealPak: If encryption keys are parsed and fail the encrypt/decrypt test, throw a fatal error. The exectutable will have those same keys embedded so there is no point allowing the paks to be created with broken keys.

Change 3924638 by Graeme.Thornton

	Crypto: Improvements to parsing of old fashioned encryption.ini settings:
	 - AES keys that are too long or short (need to be 32 bytes) will now emit a warning when being parsed, and be truncated or expanded before adding to the crypto settings.
	 - Signing keys will emit an error when they are too long (>64bytes)
	 - Unrealpak will still assert when invalid settings are passed via the other mechanisms (command line or -encryptionini mode). Settings via the crypto json file should now be sanitized and not cause issues

	#jira UE-55080

Change 3924747 by Steve.Robb

	Fix for degrees.

Change 3925459 by Chad.Garyet

	Adding check to not to attempt to delete autosdk workspace if it doesn't already exist.

Change 3926703 by Ben.Marsh

	BuildGraph: Include the path to the XML file when displaying an XML parse error.

Change 3926917 by Ben.Marsh

	UBT: Allow overriding the name of the UE4 solution on a branch-specific basis. Useful for switching between multiple UE4 workspaces. Also add support to the editor and UGS for opening the correct solution (determined via a text file saved to Engine/Intermediate/ProjectFiles).

	Set the solution name using an entry in BuildConfiguration.xml as follows:

		<ProjectFileGenerator>
			<MasterProjectName>UE4_Main</MasterProjectName>
		</ProjectFileGenerator>

Change 3927683 by Graeme.Thornton

	UAT: When building with chunk installs enabled, don't generate the master manifest from each pak creation thread. Just do it once after all pak files have been created. Avoids intermittent crash with multiple threads trying to write the same json file.

Change 3928111 by Ben.Marsh

	UBT: Add an option <bMasterProjectNameFromFolder> which allows setting the solution name based on the folder that it's in.

Change 3928926 by Ben.Marsh

	BuildGraph: Add support for enumerating content copied by the <CsCompile> task. Also add support for invoking methods on string properties.

Change 3931041 by Graeme.Thornton

	TBA: Add option to textasset commandlet to also include engine content in a resave

Change 3931043 by Graeme.Thornton

	TBA: Redirect some more FArchive members in FArchiveProxy

Change 3931913 by Ben.Marsh

	UGS: Do not create a modal dialog if a scheduled sync is unable to run because the editor is open, and do not run the editor after a scheduled sync.

	#jira UE-47368

Change 3932419 by Ben.Marsh

	UGS: Allow selecting which projects to sync on schedule. Any projects not already opened at the time the schedule is triggered will be opened first.

	#jira UE-33541

Change 3932483 by Ben.Marsh

	PR #3949: UnrealGameSync: Add environment path field to custom BuildStep (Contributed by frankie-dipietro-epic)


Change 3932624 by Ben.Marsh

	UGS: Add an error dialog when trying to clean the workspace before closing the editor.

	#jira UE-42308

Change 3932679 by Ben.Marsh

	UGS: Add the date/time to the end of the sync log.

	#jira UE-33540

Change 3932705 by Ben.Marsh

	UGS: Prompt to close the editor before allowing the user to enter a changelist to sync to, when syncing to a specific changelist.

	#jira UE-53182

Change 3933318 by Ben.Marsh

	UGS: Detect more programs running before allowing a sync to start, show a dialog listing them, and add an option to ignore if necessary.

	#jira UE-33535, UE-53914

Change 3933840 by Graeme.Thornton

	TBA: When loading assets, only use structured archive adapters for exports when loading text files.

Change 3936040 by Ben.Marsh

	UGS: Rewrite application lifecycle to fix issues with scheduled syncs on background windows not activating, and window jumping to the front after auto-update.

	Now uses a custom application context to allow creating separate 'main' windows (first the "opening projects" form, then the regular form), and does not require any forms to be shown in order to be updating in the background.

	#jira UE-52870

Change 3940230 by Robert.Manuszewski

	Fixes for FilenameToLongPackageName crashes when runnign commandlets

Change 3940240 by Graeme.Thornton

	Automated cycling of encryption and signing keys

Change 3940243 by Graeme.Thornton

	UAT: CryptoKeys automation script

Change 3940321 by Ben.Marsh

	UGS: Add a "Bisect" mode for regressing bugs between a certain range of changes. To use, select a range of changes by holding down the shift key or individual changes by holidng the control key, then right click and select "Bisect these changes". Individual changes in the list can be marked as "Bisect: Pass" or "Bisect: Fail" from the context menu, and syncing will find the next change in the center of the range.

Change 3940538 by Ben.Marsh

	UBT: Always determine whether a project is a foreign project or not from the valid .uprojectdirs entries, rather than relying on the user passing -game on the command line.

Change 3941285 by Gil.Gribb

	UE4 - Removed PRAGMA_DISABLE_OPTIMIZATION from PlatformFileCommon.h. It was an oversight.
	#jira none

Change 3942404 by Graeme.Thornton

	Pak Signing:
	 - Unify naming of pak precacher and signedarchivereader signature check functions to make it easier to search for them in crash reporter
	 - Format the signedarchivereader output to match the pak precacher
	 - When signedarchivereader detects a signature check, do the same master signature hash check that the pak precacher does to confirm that the .sig file contents haven't been corrupted since load.
	 - Add PAK_SIGNATURE_CHECK_FAILS_ARE_FATAL guarded exit to signedarchivereader signature failure
	 - Optimization for pakprecacher signature checks. Instead of locking the cached files mutex for every decoded signature, take a local copy in blocks of 16. Only re-lock if we need more. Grab the initial batch when setting up. In most cases, reduces the number of locks to 1 per signature check call.

Change 3942825 by Ben.Marsh

	UAT: Allow passing -Project<N>=Foo.uproject arguments to the MegaXGE commandlet (eg. -Target1="ShooterGame Win64 Development" -Project1="D:\ShooterGame\ShooterGame.uproject") so it can be used from an installed engine build.

Change 3942839 by Ben.Marsh

	UBT: Explicitly query the number of logical processors in the system, to fix Environment.ProcessorCount just returning the number available to the .NET framework. For machines with > 64 cores, processors in a different processor group will not be included in this number.

Change 3943153 by Ben.Marsh

	Use the correct logical processor count in ParallelExecutor.

Change 3943210 by Ben.Marsh

	UGS: Add an option to the editor arguments window that allows prompting before launching the editor.

Change 3943329 by Ben.Marsh

	UGS: Tweak appearance of bisect mode; now shows slightly transparent version of pass/fail icons, and includes remaining CL range in status panel.

Change 3944294 by Ben.Marsh

	UGS: Prompt for confirmation before removing any files from the workspace.

Change 3945283 by Ben.Marsh

	UGS: Add support for project-specific connection settings, and detection of Perforce login tickets expiring.

Change 3945325 by Ben.Marsh

	PR #4558: Changed incorrect obsolete message for ReceiptPropertyList in Modules.cs (Contributed by ryanjon2040)


Change 3947359 by Graeme.Thornton

	TBA: Fixes to loading code to allow bulk data to get a pointer from its loader archive to an archive that it can load from at a later date. For binary archives, this is just a pointer back to the same archive, but for text assets it is a pointer to a "child reader" which maintains its own structured archive that is scoped to the current location in the file.

Change 3947360 by Graeme.Thornton

	TBA: Added RoundTrip mode to text asset commandlet. Performs determinism tests in project assets to see whether they save deterministically to binary and text files, and also when they are ping-ponged between the two formats.

Change 3949431 by Graeme.Thornton

	TBA: Refactored string escaping code in json output formatter FString serializer into a common function which is now used by FName and UObject path serialization too. Fixes some odd cases where an FName contained quotation marks

Change 3950843 by Ben.Marsh

	UBT: Add a better error if an XML config file is corrupt.

Change 3952504 by Steve.Robb

	GitHub #4545 : UE-55924: CaseSensitive token recognition

	#jira UE-55961
	#jira UE-55924

Change 3952707 by Graeme.Thornton

	Make RandInit(...) log message verbose

Change 3954694 by Ben.Marsh

	BuildGraph: Add support for user-defined macros, which can contain a list of buildgraph commands and be expanded within a node. Example script in Engine/Build/Graph/Examples/Macros.xml.

	To define a Macro, use the syntax:

		<Macro Name="MyTestMacro" Arguments="PrintFirstMessage;PrintSecondMessage" OptionalArguments="PrintThirdMessage">
			<Log Message="First message" If="$(PrintFirstMessage)"/>
			<Log Message="Second message" If="$(PrintSecondMessage)"/>
			<Log Message="Third message" If="'$(PrintThirdMessage)' == 'true'"/>
		</Macro>

	To expand a macro, use the syntax:

		<Expand Name="MyTestMacro" PrintFirstMessage="true" PrintSecondMessage="true"/>

	An error will be thrown if any required arguments are missing. Optional arguments default to empty if not specified.

	Tasks within a macro are validated by the schema at the point of definition using the same rules as apply to a <Node> element, but properties are not evaluated until the macro is expanded. This allows macros to get and set properties in scope at the point that it is expanded. Local properties that are introduced within a macro do not otherwise leak to the scope that they are expanded.

Change 3954695 by Ben.Marsh

	PR #4582: Fixed incorrect condition in StagedFileSystemReference.cs (Contributed by moadib)


	#jira UE-56283

Change 3954961 by Ben.Marsh

	UBT: Fix issues caused by toolchain assuming that the editor target will be the name of the project with an "Editor" suffix. This is not necessarily the case; the launcher will allow you to instantiate a project with any name, and it will not rename the target files.

	#jira UE-56040

Change 3955785 by Steve.Robb

	GitHub #4546 : Don't discard errors from zlib inflate

	#jira UE-55969

Change 3955940 by Steve.Robb

	Redundant and confusing macro check removed.

Change 3956809 by Ben.Marsh

	Guard against project paths passed on the command line to UBT being treated as project names. Previous code used to just take the first, which would mask this problem.

Change 3959590 by Steve.Robb

	Useless IsIntrinsic constant and COMPILED_IN_INTRINSIC macro removed.

Change 3959864 by Robert.Manuszewski

	Increasing the size of permanent object pool to fix warnings in cooked ShooterGame

	#jira UE-56001

Change 3960956 by Steve.Robb

	New ToCStr function which generically gets a TCHAR* from a 'string-like' argument.

Change 3963628 by Ben.Marsh

	UBT: Fix intellisense issues caused by _API macros being defined as DLLIMPORT (imported symbols cause an error if they are defined). Generate intellisense macros with the -Monolithic argument to work around it.

Change 3964349 by Ben.Marsh

	Move support for reading .modules files into FModuleManager, and always use it in modular builds. Pathway which discovers modules by filename only is no longer supported for simplicity, and due to platform-specific version checks being unreliable on any platforms other than Windows.

Change 3964821 by Ben.Marsh

	Use a custom tool for deleting directories on Windows, to handle paths longer than MAX_PATH correctly.

Change 3965269 by Ben.Marsh

	Add more [RequiresUniqueBuildEnvironment] attributes to target settings that modify the global environment.

Change 3966554 by James.Hopkin

	#core Removed redundant cast

Change 3966558 by James.Hopkin

	#core Removed redundant casts and changed some MakeShareables to MakeShared

	#robomerge #fortnite

Change 3966754 by Ben.Marsh

	Always use the compiled-in app name when looking for a module manifest. Fixes issues with XGEControlWorker.exe being a renamed copy of ShaderCompileWorker.exe.

Change 3967397 by Ben.Marsh

	Fix "copy local" files not being included in build products enumerated from C# projects. Remove files with "Embed Interop Types" from the output list.

Change 3967664 by Ben.Marsh

	Update UGS solution to use Visual Studio 2017.

Change 3967838 by Ben.Marsh

	Couple of fixes to conform scripts.

Change 3968767 by Ben.Marsh

	Compile the name of the module manifest into the executable via a define explicitly set by UBT, rather than guessing at runtime.

Change 3968771 by Ben.Marsh

	Fix compiled-in engine path being subject to macro expansion.

	#jira UE-56504

Change 3968886 by Robert.Manuszewski

	Merging 3914301:

	Remove any references we had added to the GGCObjectReferencer during Init

Change 3968978 by Steve.Robb

	FString->FName fixes for module names in HotReload.

Change 3969019 by Steve.Robb

	Minor refactor of property skipping logic in SerializeTaggedProperties().

Change 3969041 by Steve.Robb

	Simplification of Build.version filename construction.

Change 3969049 by Steve.Robb

	Always do rolling names when recompiling in editor, because an unloaded module may still actually by loaded-but-abandoned by the executable.

	This also removes HotReload's dependence on FModuleManager::GetCleanModuleFilename().

	#jira UE-52405

Change 3969120 by Ben.Marsh

	Enable errors for using undefined identifiers in conditional expressions by default.

Change 3969161 by Ben.Marsh

	Remove log line that should only be included in the log.

Change 3969216 by Steve.Robb

	Dump a list of module names - rather than DLL filenames - when the editor detects modules which need recompiling.
	This removes the only remaining use of FModuleManager::GetCleanModuleFilename(), which is also now removed.

	#jira UE-52405

Change 3969346 by Steve.Robb

	Missed some bad FScript(Map/Set)Helper usage from CL# 3698969.

Change 3969598 by Ben.Marsh

	Fix warning from VS2017.

Change 3971101 by Graeme.Thornton

	TBA: Added RoundTrip mode to TextAsset commandlet which does a sequence of saves and checks for determinism. It will do 3 binary saves, 3 text saves, then 3 alternate binary->text saves.

Change 3971407 by Ben.Marsh

	UBT: Fix exception when enumerating toolchains if the directory does not exist yet.

Change 3971523 by Graeme.Thornton

	Make compressed block offsets in a pak file store offsets relative to the file header, rather than absolute. Reduces the amount of entropy when data changes in the pak file, making it play nicely with patching

Change 3971613 by Ben.Marsh

	Fix Lightmass non-unity compile errors.

Change 3971649 by Ben.Marsh

	Disable optimization around FTickerObjectBase constructor on Win32 due to ICE.

Change 3971829 by Ben.Marsh

	Fix deprecated header warning from PVS Studio.

Change 3972503 by Ben.Marsh

	Changes to build failure notifications:

	* Only people that submitted between builds with different error messages will be included on emails by default.
	* Email subject line will be different for each failing build step, but will include the CL of the first failing step. This will result in one thread for each build failure (a success email is sent with the same subject line).
	* Anyone that starts a build will be included on all failure emails.

Change 3972732 by Ben.Marsh

	Changes to ensure notification messages are stable.

Change 3972810 by Ben.Marsh

	Write debug information about the digest computed for a change, to assist with debugging it if it's not stable.

Change 3973331 by Ben.Marsh

	Fix missing dependency on linker response file. Prevents target being relinked when build environment changes.

Change 3973343 by Ben.Marsh

	PR #4612: Adding support for PVS-Studio settings file to PVS-Studio Unreal Build Tool toolchain. (Contributed by PaulEremeeff)


Change 3973820 by Ben.Marsh

	Fix incorrect error message when unable to find Visual C++ install directory.

Change 3974295 by Robert.Manuszewski

	Made sure that lazy object pointers are only fixed up for PIE in actual PIE worlds.

Change 3975336 by Robert.Manuszewski

	CIS fix after the last merge from main

Change 3976999 by Ben.Marsh

	Move the Windows stack size settings onto the WindowsTargetRules object, and add the [RequiresUniqueBuildEnvironment] attribute to ensure it's not overwritten incorrectly.

	This should cause CIS to better errors for compiling Odin editor.

Change 3977934 by Ben.Marsh

	UBT: Allow setting additional compiler/linker arguments through properties on the TargetRules object.

Change 3977953 by Ben.Marsh

	UBT: Enumerate all Visual Studio 2017 install locations using the Visual Studio Setup interop SDK. Multiple simultaneous Visual Studio installations are now supported, and using registry keys to determine installation directories has been deprecated. Allows choosing toolchains from preview versions as well as full versions.

Change 3978544 by Ben.Marsh

	UBT: Include verbose timing information from compiler frontend if using VS2017 15.7 preview 2 or later.

Change 3978780 by Ben.Marsh

	Add Visual C++ 2017 redist files to AppLocalDependencies, and update the prereq installer to include 2017 support DLLs.

Change 3979313 by Ben.Marsh

	UBT: Add the EngineDirectory property to ModuleRules. Makes it easier to find paths to files under the engine folder.

Change 3980499 by Ben.Marsh

	UBT: Automatically enable /DEBUG:FASTLINK if we're using the VS2017 15.7 toolchain or newer and not doing a formal build. This contains fixes for debugger OOM issues present in older versions.

Change 3980890 by Ben.Marsh

	UBT: Update project file generator to support VS2017 solution options file; fixes C# projects being opened by default when generating new project files.

Change 3981495 by Ben.Marsh

	Do not include embedded interop assemblies in the list of references required by a C# project; they are not required build products.

	#jira UE-54343

Change 3982157 by Ben.Marsh

	Only output a warning message if BuildConfiguration.xml schema validation fails; we may have settings that only apply to code in another branch.

Change 3982239 by Ben.Marsh

	Update tooltip directing users to install Visual Studio 2017 instead of 2015.

Change 3983395 by Graeme.Thornton

	Fix reference to BUILD_VERSION in BootstrapPackagedGame RC file

Change 3983523 by Graeme.Thornton

	Backwards compatibility for pak files with compressed chunk offsets

Change 3983769 by Ben.Marsh

	UAT: Allow using PDBCOPY.EXE installed as part of the Windows 10 SDK to strip symbols, and add a better message if it can't be found.

Change 3984529 by Ben.Marsh

	BuildGraph: When run with the -Preprocess=... argument, no steps will be executed.

Change 3984557 by Ben.Marsh

	BuildGraph: Return the updated patterns from FilePattern.CreateMapping(), so we can print accurate messages when displaying the source and target directories for a copy or move task.

Change 3986520 by Ben.Marsh

	Remove hacks to uniquify response file name on Android and Linux.

Change 3987166 by Steve.Robb

	Allow overloading of functions which take TFunctions or TFunctionRefs with mutually exclusive signatures.

Change 3989061 by Graeme.Thornton

	TBA: Text asset loading/saving work
	 - Start using FStructuredArchive flavours of UObject Serialize functions when loading and saving exports.
	 - Only use FStructuredArchive interface for text assets, and for classes that have the CLASS_MatchingSerializers which tells us that the class can serialize to both FStructuredArchives and FArchives.
	 - Add GetCacheableArchive to FArchive, which allows transient archives to return a pointer to another archive that will outlive it. Used by bulk data to get a pointer to an archive that can be held and used at a later time to lazy load things. For text assets where the bulk data might be held inside a base64 encoded FArchiveFromStructuredArchive block, we can't dynamically seek back to that location after the on-stack wrapper has been destroyed after the original serialize, so this will return null. For binary assets, we just return a pointer to the same binary archive which can be used freely.

Change 3989109 by Graeme.Thornton

	TBA: TextAsset commandlet emits a warning when binary package determinism fails

Change 3990823 by Ben.Marsh

	UGS: Allow project settings to specify a client path rather than a filesystem path. Not currently usable through UI.

Change 3990832 by Ben.Marsh

	UGS: Make the schedule window resizable.

Change 3991569 by Steve.Robb

	GitHub #4636 : Fixed typo in HeaderParser.cpp for "missed WithValidation keyword" error message

Change 3991970 by Steve.Robb

	Fix for 4096 char limit on FParse::Value.

Change 3992222 by Steve.Robb

	Advice added to the coding standard for using default member initializers.

Change 3993675 by Ben.Marsh

	UGS: Add UI to allow creating new workspaces and selecting projects from existing workspaces that are not currently synced.

Change 3994199 by Ben.Marsh

	UGS: Fix child processes being unable to spawn other child processes with the CREATE_BREAKAWAY_FROM_JOB flag, to add them to their own job objects.

	In Windows 7 or earlier job objects cannot be nested, so child processes have to create separate job objects and spawn processes with CREATE_BREAKAWAY_FROM_JOB to be able to add them. This fails unless parent process' job object was created with JOB_OBJECT_LIMIT_BREAKAWAY_OK.

	Discussed here: https://msdn.microsoft.com/en-us/library/windows/desktop/hh448388(v=vs.85).aspx

Change 3994243 by Ben.Marsh

	UGS: Use the select stream dialog instead of displaying a drop list unless there's a stream filter specified. We have way too many streams for this to be useful in a menu unless it's filtered.

Change 3994260 by Ben.Marsh

	UGS: Tweak the stream filter dialog to only use the previous selected node if the filter terms match. It may be a parent node of something that matches, even though it doesn't match itself.

Change 3994350 by Ben.Marsh

	UGS: Automatically guess the correct root path for new workspaces based on the most common existing workspaces for the current user.

Change 3995159 by Ben.Marsh

	UGS: Do not delete files which are outside the sync filter. People expect to be able to sync different projects within a stream without having to update sync filters.

	Indend to re-introduce this functionality through the manual 'clean workspace' operation.

Change 3995169 by Ben.Marsh

	UGS: Show options as dimmed in the open project dialog, if the radio button for those controls is not checked. Automatically set the radio button if the focus is given to one of those controls.

Change 3995228 by Ben.Marsh

	UGS: Update recently opened projects list when editing project for an existing tab.

Change 3995312 by Ben.Marsh

	UGS: Stop showing all dialogs in the taskbar.

Change 3995929 by Robert.Manuszewski

	Completely rewritten FReferenceChainSearch class used by 'obj refs' command.

	- 3+ times faster
	- Uses the same code as GC to track all the references down
	- Actually reports all reference chains properly
	- Less code that is more readable than the previous version

Change 3995981 by Ben.Marsh

	UGS: Clean workspace window will now force-sync files that have been deleted or which are writable.

Change 3996113 by Ben.Marsh

	UGS: Fix crash upgrading config files from older versions.

Change 3997990 by Ben.Marsh

	UGS: Prevent error when syncing an empty workspace.

Change 3998095 by Ben.Marsh

	UGS: Change logic for dealing with job objects: rather than creating breakaway jobs (requires co-operation with spawning process), always try to use nested job objects (requires Windows 8.1+). If it fails, ignore the error if we're already part of a job.

	Also forcibly terminate the process on dispose to handle cases where the job object wasn't created.

Change 3998264 by Ben.Marsh

	UGS: Fix exception when switching projects in-place.

Change 3998643 by Ben.Marsh

	Fix shared DDC not being used for installed engine builds.

	#jira UE-57631

Change 4000266 by Ben.Marsh

	UnrealPak: Add an option that allows rebuilding a set of PAK files with different settings. Usage is:

	    UnrealPak [PakFile] -Repack [-Output=FileOrDirectory] [Options]

	The input pak file may be a single file or wildcard, and is overwritten unless the -Output parameter is specified.

Change 4000293 by Ben.Marsh

	Add a compression flag that allows selecting compressor without using the default platform implementation.

Change 4000315 by Ben.Marsh

	Add support for custom compressors implemented via modular features. Specify -compressor=<PathToDll> on the command line to UnrealPak to load a compressor from an external DLL.

Change 4000610 by Ben.Marsh

	UnrealPak: Add a parameter for compression block size (-compressionblocksize=XXX). Accepts arguments with MB/KB suffixes, as well as byte counts.

Change 4000627 by Ben.Marsh

	UBT: Include enabled plugin info in the UBT log.

Change 4000793 by Ben.Marsh

	UBT: Remove some member variables from VCEnvironment that don't need to be stored.

Change 4000909 by Ben.Marsh

	UBT: Add VS2017 installations to the list of paths checked for MSBuild installations.

Change 4001923 by Ben.Marsh

	UBT: Allow any plugins which are enabled by default to be included in the enabled list, even if they don't have any modules for the current platform. This changes the build-time logic to match the runtime logic.

	At some point in the future we may add a separate SupportedHostPlatforms list to each plugin to do this explicitly, rather than guessing via the per-module whitelist.

Change 4001927 by Ben.Marsh

	Fixes for compiling against the Windows 10 SDK.

Change 4002439 by Robert.Manuszewski

	Added TDefaultReferenceCollector and FSimpleReferenceProcessorBase to extract common code for clients of  TFastReferenceCollector

Change 4003508 by Ben.Marsh

	UGS: Fix new workspaces not having the correct owner and host set.

Change 4003622 by Ben.Marsh

	UGS: Add support for "skipped" as a build result.

Change 4004049 by Robert.Manuszewski

	Significantly improved performance of Reference Chain Search for objects that are nested deep in the object hierarchy

Change 4005077 by Ben.Marsh

	UGS: Update version number.

Change 4005112 by Ben.Marsh

	UBT: Reduce number of times a target has to be constructed while generating project files.

Change 4005513 by Ben.Marsh

	UBT: Reduce number of checks for directories existing when adding include paths to a module. Accounted for 40% of runtime time when generating project files.

Change 4005516 by Ben.Marsh

	UBT: Add warnings whenever a module adds an include path or library path that doesn't exist

Change 4006168 by Ben.Marsh

	CIS fixes.

Change 4006236 by Ben.Marsh

	UGS: Populate the workspace name/root directory text box with the cue banner when focus moves to the control.

Change 4006266 by Ben.Marsh

	UGS: Swap around the new workspace/existing file boxes on the open project dialog.

Change 4006552 by Ben.Marsh

	If staging fails because a restricted folder name is found, include a list of them in the error message.

Change 4007397 by Steve.Robb

	Comments added to make it clear that GetAllocatedSize() only counts direct allocations made by the container.

Change 4007458 by Ben.Marsh

	UBT: Change RPC utility to abort early, rather than continue to try to build even though SSH init failed.

Change 4009343 by Ben.Marsh

	UGS: Set the rmdir option on new workspaces by default.

Change 4009501 by Ben.Marsh

	UBT: Add Windows include paths to the compiler command line, rather than setting through environment variables. This ensures that incremental builds work correctly when SDK versions change.

Change 4009509 by Ben.Marsh

	UBT: Check in a non-versioned directory under the Windows 10 SDK for the resource compiler.

Change 4010543 by Ben.Marsh

	Remove the "Device" and "Simulator" platform groups, because they're unused and overly generic for folder names. Also remove source code for the HTML5 simulator (which is no longer supported).

Change 4010553 by Ben.Marsh

	UAT: Include platform groups in restricted folder names when staging.

Change 4012030 by Ben.Marsh

	UGS: Increase the size of the main window, and set the current stream as the default when creating a new workspace.

Change 4012204 by Chad.Garyet

	- Cleanup to get the POSTs returning 400s the same way the GETs would (now no longer returns the exception text)
	- Create directory for sqlite db if it doesn't exist
	#jira none

Change 4014209 by Brandon.Schaefer

	New changes in breakpad dump_syms to allow for producing a symbol file for elf files on windows

	#review-3998840 @Arciel.Rekman, @Ben.Marsh, @Josh.Engebreston, @Anthony.Bills

Change 4015606 by Brandon.Schaefer

	Missed a code project that needed updating for new Breakpad changes for Mac

Change 4017795 by Robert.Manuszewski

	GC assumption verification should now be 3-4x faster.

	- Refactored Disregard For GC to use TFastReferenceCollector
	- Move both Disregard For GC and Cluster verification code to separate source files

Change 4020381 by Ben.Marsh

	Add link to the new official doc page for UnrealGameSync.

Change 4020665 by Ben.Marsh

	UBT: Prevent plugins being precompiled if they don't support the current target platform.

Change 4021829 by Ben.Marsh

	Update message about downloading a new version of Visual Studio.

Change 4022063 by Ben.Marsh

	UBT: Suppress toolchain output when generating project files.

Change 4023248 by Ben.Marsh

	Install an unhandled exception filter to ensure we get crash reports from threads that are not spawned by the engine. At the moment, we only receive crashes that are routed through ReportCrash() via our structured exception handlers in WinMain() and FRunnableThreadWin::Run().

	(Also fix an exception within the exception handler, if GError has not been created yet)

Change 4025759 by Ben.Marsh

	Fix universal CRT include paths not being added to compile environment for VS2015.

Change 4026002 by Ben.Marsh

	UBT: Check the old registry locations for the Windows SDK installation directory.

Change 4026068 by Ben.Marsh

	UBT: Use the correct compiler version in the error message for not having the UCRT.

Change 4026181 by Ben.Marsh

	Fix DebugGame editor configurations not enumerating modules correctly.

	#jira UE-58153

Change 4026285 by Ben.Marsh

	UBT: Add additional logging for enumerating Windows SDKs.

Change 4026708 by Ben.Marsh

	UBT: Keep a separate list of installed Universal CRT versions to the list of Windows 10 SDK versions. It's possible to install C++ support without the Windows 10 SDK, which still includes UCRT files in Windows 10 SDK folders.

Change 4029404 by Ben.Marsh

	Remove incorrect include paths to fix CIS warnings.

Change 4031517 by Steve.Robb

	Fix for UHT errors not being clickable in the Message Log.

	#jira UE-58173

Change 4031544 by Ben.Marsh

	Fix errors building asset catalog for IOS due to modifying shared build environment.

	#jira UE-58240

Change 4032227 by Ben.Marsh

	BuildGraph: Print out a warning message when trying to submit without the -Submit argument in BuildGraph.

Change 4032262 by Ben.Marsh

	BuildGraph: Remove the need to copy files to the staging directory in BuildEditorAndTools.xml.

Change 4032288 by Ben.Marsh

	Remove UFE from the BuildEditorAndTools script.

Change 3833533 by Ben.Marsh

	Rewrite engine source files to base include paths relative to the "Public" directory. This allows reducing the number of public include paths that have to be added for engine modules.

Change 3838569 by Steve.Robb

	Algo moved up a folder.

Change 3848581 by Robert.Manuszewski

	Changing the UObjectArray to not be allocated up front but in 64K-FUObjectItem chunks. This is to fix strange OOM reports on editor startup where it's trying to allocate space for 1M+ FUObjectItems.

	#jira UE-49446

Change 3864743 by Steve.Robb

	Fix for buffer overrun when copying a context string.
	Fix for being unable to link to MallocLeakDetection.
	Fix to prefix for FMallocLeakDetection::ContextString.
	New MALLOCLEAK_SCOPED_CONTEXT macro to push/pop a context string.
	Overload for const TCHAR* added to FMallocLeakDetection::PushContext to save on redundant memory allocations.

	#jira UE-54612

Change 3865020 by Graeme.Thornton

	TBA: Changed FIELD_NAME macro to FIELD_NAME_TEXT so that FIELD_NAME can be used for non-literal name definitions

Change 3869550 by Josh.Engebretson

	New SymGen and SymUpload tasks (ShooterGame usage example)
	Example C# symbolicator (using saved crash and data router formats)
	Updates for stack walking and crash runtime xml on Windows/Mac

Change 3905453 by Steve.Robb

	USE_TUPLE_AUTO_RETURN_TYPES moved to PLATFORM_COMPILER_HAS_DECLTYPE_AUTO.

Change 3910012 by Ben.Marsh

	UGS: Show an error window and allow setting default P4 server settings if syncing UGS fails.

Change 3920044 by Graeme.Thornton

	TBA: Text asset loading

	* Added a structured archive layer to FLinkerLoad
	* Wrapped export loading in a ArchiveUObjectFromStructuredArchive
	* Updated TextAssetCommandlet to have a "loadtext" mode which will try to load every text asset in the project content
	* Changed text asset extensions to .utextasset and .utextmap. Couldn't go with the favourite .uasset.json because our various path functions (FPaths::GetCleanFilename etc.) will only strip one layer of extension, so leave a bogus filename.
	* Relaxed a few checks in structured archive where it was checking for field reentrance, which isn't a problem for loading.
	* Changed FArchiveFromStructuredArchive to not load all referenced objects at construction time. This introduced some changes to load order which don't work in the engine. Object names are resolved at the point that a reference to them is serialized from the main data block, same as with legacy archives.

Change 3921587 by Steve.Robb

	Static asserts inside ensureMsgf() macros to prevent them being passed invalid arguments or non-literal formatting strings.
	Fixes for various misuses.

	#jira UE-55681

Change 3942873 by Ben.Marsh

	UBT: Allow link time code generation on any configurations where bAllowLTCG is set to true. Microsoft platforms were previously only allowing this option in shipping; the target can decide when to enable it or not.

Change 3944629 by Graeme.Thornton

	Merging back a couple of fixes from Fortnite
	 - Extra parenthesis around some calculations in the pakprecacher
	 - Changed FChunkCacheWorker::DoSignatureCheck() back to ::CheckSignature()
	 - Added documentation for build script crypto options

Change 3945381 by Ben.Marsh

	Disable warning C4770 on Windows (partially validated enum 'xxx' used as index), which occurs when enabling LTCG. Can't find a reference online for this warning, but I suspect it's due to LTCG allowing the compiler to trace code paths where we don't validate that an enum is a known value.

Change 3968969 by Steve.Robb

	Fixes to incorrect uses of FScriptMapHelper and FScriptSetHelper, which weren't accounting for gaps in the sparse array.

Change 3969417 by Ben.Marsh

	Make Visual Studio 2017 the default compiler for UE4 projects, and add support using Visual C++ toolchains from an AutoSDKs.

	Also add support for selecting a specific toolchain version to use through the WindowsPlatform.CompilerVersion property, which can be configured via a Target.cs files or BuildConfiguration.xml (eg. <WindowsPlatform><CompilerVersion>14.13.26128</CompilerVersion></WindowsPlatform). As well as allowing a specific version number, you can always use the latest toolchain by setting it to "Latest".

Change 3972443 by Ben.Marsh

	Change build scripts to allow running any steps on non-compile workspaces. Setup Dev-Core to just use a non-compile Win64 workspace for everything.

Change 3977198 by Ben.Marsh

	Remove INI file override for editor stack size on Windows. This is rarely valid since editor targets share build products with other games by deafult. Fix to add linker response file as prerequisite exposed targets overriding this as a bug.

Change 3979632 by Ben.Marsh

	Consolidate codepaths for embedding versioning information in the engine. Engine/Build/Build.version is now the authoritative place to read version information; Engine/Source/Runtime/Launch/Resources/Version.h no longer includes macros for the current branch and changelist.

	* Settings from Build.version are compiled into the (tiny) BuildSettings module via macros set in BuildSettings.build.cs, which is used to initialize version information inside the engine at runtime.
	* The IsPromotedBuild value is now set to zero by default (but set to 1 by the UpdateLocalVersion UAT command).
	* The -Licensee argument to the UpdateLocalVersion UAT command, and the IsLicenseeVersion setting for UnrealGameSync, is determined automatically by looking for the Engine/Build/NotForLicensees/EpicInternal.txt file. This path is not visible to licensees.

Change 3981738 by Ben.Marsh

	Move utility classes for filtering files and matching wildcards into DotNETUtilities.

Change 3983888 by Steve.Robb

	Warning C4868 disabled, about evaluation order of braced initializer lists.

	https://udn.unrealengine.com/questions/426081/help-with-error-c4868-braced-initializers.html

Change 3984019 by Steve.Robb

	FString::Printf formatting argument checking added.
	Vararg support for FText::Format.
	All remaining usage fixed.

Change 3985502 by Steve.Robb

	Change to TFunction debugger visualization to allow right-clicking on the [Lambda] and selecting 'Go To Source Code'.

Change 3985999 by Graeme.Thornton

	TBA: Serialize function generation for FArchive and FStructuredArchive overloads on a UObject, using UHT.
	 - Adds a restriction that UObject::Serialize() functions MUST be declared outside of any conditional compilation directives, except for WITH_EDITORONLY_DATA

Change 3986461 by Ben.Marsh

	Fixup lots of platforms not adding response files as a prerequisite.

	This can cause incremental builds to fail if input files/compile arguments change, because the action graph does not know that the response file being updated invalidates the build artifacts.

Change 3990081 by Ben.Marsh

	Remove custom output formatters for errors and warnings. These are not well supported by different executors, and cause fences between actions with the same formatter with external executors like XGE.

	Clang supports -fdiagnostics-format=msvc for all platforms, which should do a better job than our crude attempts at regexing errors (causing botched output in some cases).

Change 3996714 by Chad.Garyet

	UGSRestAPI, conversion of UGS to use it.

	#jira none

Change 4008287 by Ben.Marsh

	UBT: Change the engine to use the Windows 10 SDK by default.

	Also add support for switching between specific Windows SDK versions. The WindowsPlatform.WindowsSdkVersion property in the target rules can be used to select a desired version, which can also be configured by the <WindowsPlatform><WindowsSdkVersion>Foo</WindowsSdkVersion></WindowsPlatform> parameter in the BuildConfiguration.xml file.

	The version of Windows to target (ie. the WINVER macro) can be modified by setting WindowsPlatform.TargetWindowsVersion. The default is 0x0601 (Windows 7).

Change 4008516 by Chad.Garyet

	- Adding support for both SQLite and MsSql
	- API now reads from only MsSql, but writes to both
	- Added support for POST to CIS for badges
	- PostBadgeStatus now writes out via API Url rather than a direct connection to the DB

	#jira none

Change 4010296 by Chad.Garyet

	Moving SQLite db initilization into Application_Start.  An exception thrown creating or seeding the db will unload the entire AppDomain and all pages will return a 404.
	#jira none

Change 4024045 by Ben.Marsh

	Set the list of supported target platforms for OnlineSubsystemGameCircle.

	#jira UE-57887

Change 4031014 by Ben.Marsh

	UAT: Add a WhitelistDirectories list in DefaultEngine.ini, which allows specifying folders that can be staged despite having restricted folder names.

[CL 4034515 by Ben Marsh in Main branch]
2018-04-26 14:11:04 -04:00

787 lines
35 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
Availability:Public
Title:Coding Standard
Crumbs:%ROOT%, Programming, Programming\Development
Description:Standards and conventions used by Epic Games in the Unreal Engine 4 codebase.
Version: 4.11
[TOC(start:2)]
At Epic, we have a few simple coding standards and conventions. This document is not meant to be a discussion or work in progress, but rather, reflects the state of Epic's current coding standards.
Code conventions are important to programmers for a number of reasons:
* 80% of the lifetime cost of a piece of software goes to maintenance.
* Hardly any software is maintained for its whole life by the original author.
* Code conventions improve the readability of the software, allowing engineers to understand new code more quickly and thoroughly.
* If we decide to expose source code to mod community developers, we want it to be easily understood.
* Many of these conventions are actually required for cross-compiler compatibility.
The coding standards below are C++-centric, but the spirit of the standards are expected to be followed no matter which language is used. A section may provide equivalent rules or exceptions for specific languages where it's applicable.
## Class Organization
Classes should be organized with the reader in mind rather than the writer. Since most readers will be using the public interface of the class, that should be declared first, followed by the class's private implementation.
## Copyright Notice
Any source file (.h, .cpp, .xaml, etc.) provided by Epic for distribution must contain a copyright notice as the first line in the file. The format of the notice must exactly match that shown below:
// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.
If this line is missing or not formatted properly, CIS will generate an error and fail.
## Naming Conventions
* The first letter of each word in a name (e.g. type or variable) is capitalized, and there is usually no underscore between words. For example, Health and UPrimitiveComponent, but not lastMouseCoordinates or delta_coordinates.
* Type names are prefixed with an additional upper-case letter to distinguish them from variable names. For example, FSkin is a type name, and Skin is an instance of a FSkin.
* Template classes are prefixed by T.
* Classes that inherit from UObject are prefixed by U.
* Classes that inherit from AActor are prefixed by A.
* Classes that inherit from SWidget are prefixed by S.
* Classes that are abstract interfaces are prefixed by I.
* Enums are prefixed by E.
* Boolean variables must be prefixed by b (e.g. "bPendingDestruction", or "bHasFadedIn").
* Most other classes are prefixed by F, though some subsystems use other letters.
* Typedefs should be prefixed by whatever is appropriate for that type: F if it's a typedef of a struct, U if it's a typedef of a UObject etc.
* A typedef of a particular template instantiation is no longer a template and should be prefixed accordingly, e.g.:
typedef TArray<FMyType> FArrayOfMyTypes;
* Prefixes are omitted in C#.
* UnrealHeaderTool requires the correct prefixes in most cases, so it's important to provide them.
* Type and variable names are nouns.
* Method names are verbs that describe the method's effect, or describe the return value of a method that has no effect.
Variable, method, and class names should be clear, unambiguous, and descriptive. The greater the scope of the name, the greater the importance of a good, descriptive name. Avoid over-abbreviation.
All variables should be declared one at a time so that a comment on the meaning of the variable can be provided. Also, the JavaDocs style requires it. You can use multi-line or single line comments before a variable, and the blank line is optional for grouping variables.
All functions that return a bool should ask a true/false question, such as IsVisible() or ShouldClearBuffer().
A procedure (a function with no return value) should use a strong verb followed by an Object. An exception is if the Object of the method is the Object it is in; then the Object is understood from context. Names to avoid include those beginning with "Handle" and "Process"; the verbs are ambiguous.
Though not required, we encourage you to prefix function parameter names with "Out" if they are passed by reference and the function is expected to write to that value. This makes it obvious that the value passed in this argument will be replaced by the function.
If an In or Out parameter is also a boolean, put the b before the In/Out prefix, e.g. "bOutResult".
Functions that return a value should describe the return value; the name should make clear what value the function will return. This is particularly important for boolean functions. Consider the following two example methods:
bool CheckTea(FTea Tea) {...} // what does true mean?
bool IsTeaFresh(FTea Tea) {...} // name makes it clear true means tea is fresh
### Examples
float TeaWeight;
int32 TeaCount;
bool bDoesTeaStink;
FName TeaName;
FString TeaFriendlyName;
UClass* TeaClass;
USoundCue* TeaSound;
UTexture* TeaTexture;
## Portable Aliases for Basic C++ Types
* bool for boolean values (NEVER assume the size of bool). BOOL will not compile.
* TCHAR for a character (NEVER assume the size of TCHAR).
* uint8 for unsigned bytes (1 byte).
* int8 for signed bytes (1 byte).
* uint16 for unsigned "shorts" (2 bytes).
* int16 for signed "shorts" (2 bytes).
* uint32 for unsigned ints (4 bytes).
* int32 for signed ints (4 bytes).
* uint64 for unsigned "quad words" (8 bytes).
* int64 for signed "quad words" (8 bytes).
* float for single precision floating point (4 bytes).
* double for double precision floating point (8 bytes).
* PTRINT for an integer that may hold a pointer (NEVER assume the size of PTRINT).
Use of C+\+'s int and unsigned int types - whose size may vary across platforms - is acceptable in code where the integer width is unimportant. Explicitly-sized types must still be used in serialized or replicated formats.
## Comments
Comments are communication; communication is vital. Some things to keep in mind about comments (from Kernighan & Pike _The Practice of Programming_):
### Guidelines
* Write self-documenting code:
// Bad:
t = s + l - b;
// Good:
TotalLeaves = SmallLeaves + LargeLeaves - SmallAndLargeLeaves;
* Write useful comments:
// Bad:
// increment Leaves
++Leaves;
// Good:
// we know there is another tea leaf
++Leaves;
* Do not comment bad code - rewrite it:
// Bad:
// total number of leaves is sum of
// small and large leaves less the
// number of leaves that are both
t = s + l - b;
// Good:
TotalLeaves = SmallLeaves + LargeLeaves - SmallAndLargeLeaves;
* Do not contradict the code:
// Bad:
// never increment Leaves!
++Leaves;
// Good:
// we know there is another tea leaf
++Leaves;
### Const correctness
const is documentation as much as it is a compiler directive, so all code should strive to be const-correct.
This includes passing function arguments by const pointer or reference if those arguments are not intended to be modified by the function, flagging methods as const if they do not modify the object, and using const iteration over containers if the loop isn't intended to modify the container.
void SomeMutatingOperation(FThing& OutResult, const TArray<int32>& InArray); // InArray will not be modified by SomeMutatingOperation, but OutResult probably will be
void FThing::SomeNonMutatingOperation() const
{
// This code will not modify the FThing it is invoked on
}
TArray<FString> StringArray;
for (const FString& : StringArray)
{
// The body of this loop will not modify StringArray
}
Const should also be preferred on by-value function parameters and locals. This tells a reader that the variable will not be modified in the body of the function, which helps understandability. If you do this, ensure that the declaration and the definition match, as this can affect the JavaDoc process:
void AddSomeThings(const int32 Count);
void AddSomeThings(const int32 Count)
{
const int32 CountPlusOne = Count + 1;
// Neither Count nor CountPlusOne can be changed during the body of the function
}
One exception to this is pass-by-value parameters which will ultimately be moved into a container (see "Move semantics"); this should be rare.
void FBlah::SetMemberArray(TArray<FString> InNewArray)
{
MemberArray = MoveTemp(InNewArray);
}
Put the const keyword on the end when making a pointer itself const (rather than what it points to). References cannot be 'reassigned' anyway, and so cannot be made const in the same way:
// Const pointer to non-const object - pointer cannot be resassigned, but T can still be modified
T* const Ptr = ...;
// Illegal
T& const Ref = ...;
Never use const on a return type, as this inhibits move semantics for complex types and will give compile warnings for built-in types. This rule only applies to the return type itself, not the target type of a pointer or reference being returned:
// Bad - returning a const array
const TArray<FString> GetSomeArray();
// Fine - returning a reference to a const array
const TArray<FString>& GetSomeArray();
// Fine - returning a pointer to a const array
const TArray<FString>* GetSomeArray();
// Bad - returning a const pointer to a const array
const TArray<FString>* const GetSomeArray();
### Example Formatting
We use a system based on JavaDoc to automatically extract comments from the code and build documentation, so there are some specific comment formatting rules to follow.
The following example demonstrates the format of class, state, method, and variable comments. Remember that comments should augment the code. The code documents the implementation and the comments document the intent. Make sure to update comments when you change the intent of a piece of code.
Note that two different parameter comment styles are supported, as embodied by the Steep and Sweeten methods. The @param style used by Steep is the traditional style, but for simple functions it can be clearer to integrate the parameter documentation into the descriptive comment for the function, as in the Sweeten example.
Method comments should only be included once, where the method is publically declared. The method comments should only contain information relevant to callers of the method, including any information about overrides of the method that may be relevant to the caller. Details about the implementation of the method and its overrides that are not relevant to callers should be commented within the method implementation.
class IDrinkable
{
public:
/**
* Called when a player drinks this object.
* @param OutFocusMultiplier - Upon return, will contain a multiplier to apply to the drinker's focus.
* @param OutThirstQuenchingFraction - Upon return, will contain the fraction of the drinker's thirst to quench (0-1).
*/
virtual void Drink(float& OutFocusMultiplier, float& OutThirstQuenchingFraction) = 0;
};
class FTea : public IDrinkable
{
public:
/**
* Calculate a delta-taste value for the tea given the volume and temperature of water used to steep.
* @param VolumeOfWater - Amount of water used to brew in mL
* @param TemperatureOfWater - Water temperature in Kelvins
* @param OutNewPotency - Tea's potency after steeping starts, from 0.97 to 1.04
* @return the change in intensity of the tea in tea taste units (TTU) per minute
*/
float Steep(
const float VolumeOfWater,
const float TemperatureOfWater,
float& OutNewPotency
);
void Sweeten(const float EquivalentGramsOfSucrose);
float GetPrice() const
{
return Price;
}
virtual void Drink(float& OutFocusMultiplier, float& OutThirstQuenchingFraction) override;
private:
float Price;
float Sweetness;
};
float FTea::Steep(const float VolumeOfWater, const float TemperatureOfWater, float& OutNewPotency)
{
...
}
void FTea::Sweeten(const float EquivalentGramsOfSucrose)
{
...
}
void FTea::Drink(float& OutFocusMultiplier, float& OutThirstQuenchingFraction)
{
...
}
What does a class comment include?
* A description of the problem this class solves. Why was this class created?
What do all those parts of the method comment mean?
* The purpose of the function is first; this documents the _problem this function solves._ As has been said above, comments document _intent_ and code documents _implementation_.
* Then come the parameter comments; each parameter comment should include units of measure, the range of expected values, "impossible" values, and the meaning of status/error codes.
* Then comes the return comment; it documents the expected return value just as an output variable is documented.
## C++11 and Modern Language Syntax
Unreal Engine is built to be massively portable to many C++ compilers, so we are careful to use features that are compatible with the compilers we can imagine supporting. Sometimes features are so useful that we will wrap them up in macros and use them pervasively, but usually we will wait until all of the compilers we could imagine supporting are up to the latest standard.
We are utilizing certain C++11 language features that appear to be well-supported across modern compilers, such as range-based-for, move semantics and lambdas. In some cases, we are able to wrap up usage of these features in preprocessor conditionals (such as rvalue references in containers.) However, certain language features we may opt to avoid entirely until we are confident we will not be surprised by a new platform appearing that cannot digest the syntax.
Unless specified below as a modern C++ compiler feature we are supporting, you should refrain from using compiler-specific language features unless they are wrapped in preprocessor macros or conditionals and used sparingly.
### static_assert
This keyword is valid for use where you need a compile-time assertion.
### override and final
These keywords are valid for use, and their use is strongly encouraged. There will likely be many places where these have been omitted but they will be fixed over time.
### nullptr
nullptr should be used instead of the C-style NULL macro in all cases.
One exception to this is that nullptr in C++/CX builds (e.g. Xbox One) is actually the managed null reference type. It is mostly compatible with nullptr from native C++ except in its type and some template instantiation contexts, and so you should use the TYPE_OF_NULLPTR macro instead of the more usual decltype(nullptr) for compatibility.
### The 'auto' Keyword
You should not use auto in C++ code, barring a few exceptions below. You must always be explicit about the type you're initializing. This means that the type must be plainly visible to the reader. This rule also applies to the use of the ‘var’ keyword in C#.
When is it acceptable to use auto?
* When you need to bind a lambda to a variable, as lambda types are not expressible in code.
* For iterator variables, but only where the iterator's type is very verbose and would impair readability.
* In template code, where the type of an expression cannot easily be discerned. This is an advanced case.
It's very important that types are clearly visible to someone who is reading the code. Even though some IDEs are able to infer the type, this relies on the code being in a compilable state. It also will not assist users of merge/diff tools, or when viewing individual source files in isolation, such as on GitHub.
If you're sure you are using auto in an acceptable way, always remember to correctly use const, & or * just like you would with the type name. With auto, this will coerce the inferred type to be what you want.
### Range Based For
This is preferred to keep the code easier to understand and more maintainable. When migrating code that uses old TMap iterators, be aware that the old Key() and Value() functions which were methods of the iterator type are now simply Key and Value fields of the underlying key-value TPair:
TMap<FString, int32> MyMap;
// Old style
for (auto It = MyMap.CreateIterator(); It; ++It)
{
UE_LOG(LogCategory, Log, TEXT("Key: %s, Value: %d"), It.Key(), *It.Value());
}
// New style
for (TPair<FString, int32>& Kvp : MyMap)
{
UE_LOG(LogCategory, Log, TEXT("Key: %s, Value: %d"), Kvp.Key, *Kvp.Value);
}
We also have range replacements for some standalone iterator types:
// Old style
for (TFieldIterator<UProperty> PropertyIt(InStruct, EFieldIteratorFlags::IncludeSuper); PropertyIt; ++PropertyIt)
{
UProperty* Property = *PropertyIt;
UE_LOG(LogCategory, Log, TEXT("Property name: %s"), *Property->GetName());
}
// New style
for (UProperty* Property : TFieldRange<UProperty>(InStruct, EFieldIteratorFlags::IncludeSuper))
{
UE_LOG(LogCategory, Log, TEXT("Property name: %s"), *Property->GetName());
}
### Lambdas and Anonymous Functions
Lambdas can now be used on all compilers, but their usage should be considered. The best lambdas should be no more than a couple of statements in length, particularly when used as part of a larger expression or statement, for example as a predicate in a generic algorithm:
// Find first Thing whose name contains the word "Hello"
Thing* HelloThing = ArrayOfThings.FindByPredicate([](const Thing& Th){ return Th.GetName().Contains(TEXT("Hello")); });
// Sort array in reverse order of name
AnotherArray.Sort([](const Thing& Lhs, const Thing& Rhs){ return Lhs.GetName() > Rhs.GetName(); });
Be aware that stateful lambdas cannot be assigned to function pointers, which we tend to use a lot.
Documentation of non-trivial lambdas and anonymous functions should be considered in the same way a regular function is documented. Don't be afraid to split them over a few more lines in order to comment them.
Prefer explicit capture over automatic capture ([&] and [=]), especially for large lambdas and deferred execution. Accidentally capturing a variable with the wrong capture semantics can have negative consequences, and this is more likely to happen as the code is maintained over time:
* By-reference capture and by-value capture of pointers can cause accidental dangling references, if the lambda is executed outside the context of the captured variables:
void Func()
{
int32 Value = GetSomeValue();
// Lots of code
AsyncTask([&]()
{
// Value is invalid here
for (int Index = 0; Index != Value; ++Index)
{
// ...
}
});
}
* By-value capture can be a performance concern because of unnecessary copies:
void Func()
{
int32 ValueToFind = GetValueToFind();
// The lambda takes a copy of ArrayOfThings because it is accidentally captured by [=] when it was only meant to capture ValueToFind
FThing* Found = ArrayOfThings.FindByPredicate(
[=](const FThing& Thing)
{
return Thing.Value == ValueToFind && Thing.Index < ArrayOfThings.Num();
}
);
}
* Accidentally captured UObject pointers are invisible to the garbage collector:
void Func(AActor* MyActor)
{
// Capturing the MyActor pointer will not prevent the object from being collected
AsyncTask([=]()
{
MyActor->DoSlowThing();
});
}
* Automatic capture always captures 'this' implicitly if any member variables are referenced, even with [=]. [=] gives the impression of the lambda having its own copy of the member when it doesn't:
void FStruct::Func()
{
int32 Local = 5;
Member = 5;
auto Lambda = [=]()
{
UE_LOG(LogTest, Log, TEXT("Local: %d, Member: %d"), Local, Member);
};
Local = 100;
Member = 100;
Lambda(); // Logs "Local: 5, Member: 100"
}
Prefer explicit return types for large lambdas or when you are returning the result of another function call. These should be considered in the same way as the 'auto' keyword:
// Without the return type here, the return type is unclear
auto Lambda = []() -> FMyType
{
return SomeFunc();
};
Automatic captures and implicit return types are acceptable for trivial lambdas, e.g. in Sort calls, where the semantics are obvious and being explicit would make it overly verbose - use your best judgment.
### Strongly-Typed Enums
Enum classes should always be used as a replacement for old-style namespaced enums, both for regular enums and UENUMs. For example:
// Old enum
UENUM()
namespace EThing
{
enum Type
{
Thing1,
Thing2
};
}
// New enum
UENUM()
enum class EThing : uint8
{
Thing1,
Thing2
};
These are also supported as UPROPERTYs, as long they are based on uint8 - this replaces the old `TEnumAsByte<>` workaround:
// Old property
UPROPERTY()
TEnumAsByte<EThing::Type> MyProperty;
// New property
UPROPERTY()
EThing MyProperty;
Enum classes used as flags can take advantage of the ENUM_CLASS_FLAGS(EnumType) macro to automatically define all of the bitwise operators:
enum class EFlags
{
None = 0x00,
Flag1 = 0x01,
Flag2 = 0x02,
Flag3 = 0x04
};
ENUM_CLASS_FLAGS(EFlags)
The one exception to this is the use of flags in a 'truth' context - this is a limitation of the language. Instead, all flags enums should have an enumerator called 'None' which is set to 0 for comparisons:
// Old
if (Flags & EFlags::Flag1)
// New
if ((Flags & EFlags::Flag1) != EFlags::None)
### Move Semantics
All of the main container types - TArray, TMap, TSet, FString - have move constructors and move assignment operators. These are often used automatically when passing/returning these types by value, but can be explicitly invoked by using MoveTemp, which is UE4's equivalent of std::move.
Returning containers or strings by value can be a win for expressivity without the usual cost of temporary copies. Rules around pass-by-value and use of MoveTemp are still being established, but can already be found in some optimized areas of the codebase.
### Default member initializers
Default member initializers can be used to define the defaults of a class inside the class itself:
UCLASS()
class UTeaOptions : public UObject
{
GENERATED_BODY()
public:
UPROPERTY()
int32 MaximumNumberOfCupsPerDay = 10;
UPROPERTY()
float CupWidth = 11.5f;
UPROPERTY()
FString TeaType = TEXT("Earl Grey");
UPROPERTY()
EDrinkingStyle DrinkingStyle = EDrinkingStyle::PinkyExtended;
};
Code written like this has the following benefits:
* It does not need to concern itself with having to duplicate initializers across multiple constructors
* It is not possible to mix the initialization order and declaration order.
* The member type, property flags and default values and are all in one place, aiding readability and maintainability.
However, there are also some downsides:
* Any change to the defaults will necessitate a rebuild of all dependent files.
* Headers cannot change in patch releases of the engine, so this style can limit the kinds of fixes that are possible.
* Not everything can be initialized in this way, e.g. base classes, UObject subobjects, pointers to forward-declared types, values deduced from constructor arguments, members initialized over multiple steps.
* Having some initializers in the header and the rest in constructors in the .cpp file can end up hampering readability and maintainability.
Use your best judgment when deciding whether to use them. As a rule of thumb, default member initializers make more sense in game code than engine code. Also consider using config files for default values.
## Third Party Code
Whenever you modify the code to a library that we use in the engine, be sure to tag your changes with a //@UE4 comment, as well as an explanation of why you made the change. This makes merging the changes into a new version of that library easier, and lets licensees easily find any modifications we have made.
Any third party code included in the engine should be marked with comments formatted to be easily searchable. For example:
// @third party code - BEGIN PhysX
#include <PhysX.h>
// @third party code - END PhysX
// @third party code - BEGIN MSDN SetThreadName
// [http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx]
// Used to set the thread name in the debugger
...
//@third party code - END MSDN SetThreadName
## Code Formatting
### Braces { }
Brace wars are foul. Epic has a long standing usage pattern of putting braces on a new line. Please continue to adhere to that.
Always include braces in single-statement blocks, e.g.:
if (bThing)
{
return;
}
### If - Else
Each block of execution in an if-else statement should be in braces. This is to prevent editing mistakes - when braces are not used, someone could unwittingly add another line to an if block. The line would not be controlled by the if expression, which would be bad. Worse yet is when conditionally compiled items cause if/else statements to break. So always use braces.
if (HaveUnrealLicense)
{
InsertYourGameHere();
}
else
{
CallMarkRein();
}
A multi-way if statement should be indented with each else if indented the same amount as the first if; this makes the structure clear to a reader:
if (TannicAcid < 10)
{
UE_LOG(LogCategory, Log, TEXT("Low Acid"));
}
else if (TannicAcid < 100)
{
UE_LOG(LogCategory, Log, TEXT("Medium Acid"));
}
else
{
UE_LOG(LogCategory, Log, TEXT("High Acid"));
}
### Tabs
* Indent code by execution block.
* Use tabs, not spaces, for whitespace at the beginning of a line. Set your tab size to 4 characters. However, spaces are sometimes necessary and allowed for keeping code aligned regardless of the number of spaces in a tab; e.g. when aligning code following non-tab characters.
* If you are writing code in C#, please also use tab characters, not spaces. The reason for this is that programmers often switch between C# and C++, and most prefer to use a consistent setting for tabs. Visual Studio defaults to using spaces for C# files, so you will need to remember to change this setting when working on Unreal Engine code.
### Switch Statements
Except for empty cases (multiple cases having identical code), switch case statements should explicitly label that a case falls through to the next case. Either include a break or a falls-through comment in each case. Other code control-transfer commands (return, continue, etc.) are fine as well.
Always have a default case, and include a break - just in case someone adds a new case after the default.
switch (condition)
{
case 1:
...
// falls through
case 2:
...
break;
case 3:
...
return;
case 4:
case 5:
...
break;
default:
break;
}
## Namespaces
You can use namespaces to organize your classes, functions and variables where appropriate, as long as you follow the rules below.
* Unreal code is currently not wrapped in a global namespace. You need to watch out for collisions in the global scope, especially when pulling in third party code.
* Do not put "using" declarations in the global scope, even in a .cpp file (it will cause problems with our "unity" build system.)
* It is fine to put "using" declarations within another namespace, or within a function body.
* Note that if you put "using" within a namespace, it will carry over to other occurrences of that namespace in the same translation unit. As long as you are consistent it will be fine, though.
* You can only use "using" in header files safely if you follow the above rules.
* Note that forward-declared types need to be declared within their respective namespace, otherwise you will get link errors.
* If you declare a lot of classes/types within a namespace, it can make it difficult to use those types in other global-scoped classes. (e.g. function signatures will need to use explicit namespace when appearing in class declarations.)
* You can use "using" to alias only specific variables within a namespace into your scope (e.g. using Foo::FBar), but we do not usually do that in Unreal code.
* Namespaces are not supported by UnrealHeaderTool, so should not be used when defining UCLASSes, USTRUCTs etc.
## Physical Dependencies
* File names should not be prefixed where possible; for example Scene.cpp instead of UnScene.cpp. This facilitates using tools like Workspace Whiz or Visual Assist's Open File in Solution by reducing the number of letters needed to disambiguate the file you want.
* All headers should protect against multiple includes with the #pragma once directive. Note that all compilers we need to use support #pragma once these days.
#pragma once
<file contents>
* In general, try to minimize physical coupling.
* If you can use forward declarations instead of including a header, do so.
* Include as fine grained as possible; do not include Core.h, include the specific headers in Core that you need definitions from.
* Try to include every header you need directly, to make fine-grained inclusion easier.
* Do not rely on a header that is included indirectly by another header you include
* Do not rely on being included through another header; include everything you need.
* Modules have Private and Public source directories. Any definitions that are needed by other modules must be in headers in the Public directory, but everything else should be in the Private directory. Note that in older Unreal modules, these directories may still be called Src and Inc, but those directories are meant to separate private and public code in the same way, and are not meant to separate header files from source files.
* Do not worry about setting up your headers for precompiled header generation. UnrealBuildTool can do a better job of this than you can.
* Split up large functions into logical sub-functions. One area of compilers' optimizations is the elimination of common subexpressions, and the bigger your functions are, the more work the compiler has to do to identity them, leading to greatly inflated build times.
* Use inline functions judiciously, as they force rebuilds even in files which don't use them. Inlining should only be used for trivial accessors and when profiling shows there is a benefit to doing so.
* Be even more conservative in the use of FORCEINLINE. All code and local variables will be expanded out into the calling function and will cause the same build time problems caused by large functions.
## Encapsulation
Enforce encapsulation with the protection keywords. Class members should almost always be declared private unless they are part of the public/protected interface to the class. Use your best judgment, but always be aware that a lack of accessors makes it hard to refactor later without breaking plugins and existing projects.
If particular fields are only intended to be usable by derived classes, make them private and provide protected accessors.
Use final if your class is not designed to be derived from.
## General Style Issues
* Minimize dependency distance. When code depends on a variable having a certain value, try to set that variable's value right before using it. Initializing a variable at the top of an execution block, and not using it for a hundred lines of code, gives lots of space for someone to accidentally change the value without realizing the dependency. Having it on the next line makes it clear why the variable is initialized the way it is and where it is used.
* Split methods into sub-methods where possible. Humans are better at looking at a big picture, and drilling down to the interesting details than to start with the details and reconstruct the big picture from them. In the same way, it is easier to understand a simple method that calls a sequence of several well named sub-methods than to understand an equivalent method that simply contains all the code in those sub-methods.
* In function declarations or function call sites, do not add a space between the function's name and the parentheses that precedes the argument list.
* Address compiler warnings. Compiler warning messages mean something is not as it should be. Fix what the compiler is complaining about. If you absolutely cannot address it, use #pragma to suppress the warning; this is a remedy of last resort.
* Leave a blank line at the end of the file. All .cpp and .h files should include a blank line to play nice with gcc.
* Never allow float to implicit convert to int32. This is a slow operation, and does not compile on all compilers. Instead, always use the appTrunc() function to convert to int32. This will ensure cross-compiler compatibility as well as generate faster code.
* Interface classes (prefixed with "I") should always be abstract and must not have member variables. Interfaces are allowed to contain methods that are not pure-virtual, and even methods that are non-virtual or static, as long as they are implemented inline.
* Debug code should either be generally useful and polished, or not checked in. Debug code intermixed with other code makes the other code much harder to read.
* Always use the TEXT() macro around string literals. Without it, code which constructs FStrings from literals will cause an undesirable string conversion process.
* Avoid repeating the same operation redundantly in loops. Hoist common subexpressions out of loops to avoid redundant calculations. Make use of statics in some cases to avoid globally-redundant operations across function calls, e.g. constructing an FName from a string literal.
* Be mindful of hot reload. Minimize dependencies to cut down on iteration time. Don't use inlining or templates for functions which are likely to change over a reload. Only use statics for things which are expected to remain constant over a reload.
* Use intermediate variables to simplify complicated expressions. If you have a complicated expression, it can be easier to understand if you split it into sub-expressions that are assigned to intermediate variables with names describing the meaning of the sub-expression within the parent expression. For example:
if ((Blah->BlahP->WindowExists->Etc && Stuff) &&
!(bPlayerExists && bGameStarted && bPlayerStillHasPawn &&
IsTuesday())))
{
DoSomething();
}
_should be replaced with_
const bool bIsLegalWindow = Blah->BlahP->WindowExists->Etc && Stuff;
const bool bIsPlayerDead = bPlayerExists && bGameStarted && bPlayerStillHasPawn && IsTuesday();
if (bIsLegalWindow && !bIsPlayerDead)
{
DoSomething();
}
* Use the virtual and override keywords when declaring an overriding method. When declaring a virtual function in a derived class that overrides a virtual function in the parent class, you must use both the virtual and the override keywords. For example:
class A
{
public:
virtual void F() {}
};
class B : public A
{
public:
virtual void F() override;
};
Note that there is a lot of existing code that does not follow this yet due to the recent addition of the override keyword, and the override keyword should be added to that code when convenient.
* Pointers and references should only have one space, which is to the right of the pointer / reference. This makes it easy to quickly Find in Files for all pointers or references to a certain type.
Use this:
FShaderType* Type
Not these:
FShaderType *Type
FShaderType * Type
* Shadowed variables are not allowed. C++ allows variables to be shadowed from an outer scope, making usage ambiguous to a reader. For example, there are three usable 'Count' variables in this member function:
class FSomeClass
{
public:
void Func(const int32 Count)
{
for (int32 Count = 0; Count != 10; ++Count)
{
// Use Count
}
}
private:
int32 Count;
};