#pragma once #include "CoreMinimal.h" class UWorld; /** * Helpers shared by every DescentCommands_.cpp, so no commands file defines its own copy (two anonymous- * namespace helpers with one name in two files break the unity build the moment those files are merged). * * A commands file is one .cpp per system, self-registering with file-scope FAutoConsoleCommand objects: * * // Debug/DescentCommands_Carrier.cpp * static void CmdHelm(const TArray& Args, UWorld* World) * { * TArray N; * if (!Descent::Cmd::ParseNumbers(Args, 0, 1, N)) { Descent::Cmd::Fail(World, TEXT("Descent.Carrier.Helm"), TEXT("usage: Descent.Carrier.Helm <0 or 1>")); return; } * ... * } * static FAutoConsoleCommandWithWorldAndArgs GCarrierCmdHelm(TEXT("Descent.Carrier.Helm"), TEXT("..."), * FConsoleCommandWithWorldAndArgsDelegate::CreateStatic(&CmdHelm)); * * Give file-local helpers and variables a name that carries your system (CmdHelm, GCarrierCmdHelm), never a bare * common name: files of one module can be compiled together as a single unit. */ namespace Descent::Cmd { /** Parses Count numbers from Args starting at index First. False if too few arguments or one is not a number. */ THEDESCENT_API bool ParseNumbers(const TArray& Args, int32 First, int32 Count, TArray& Out); /** True for "1", "true", "on", "yes" (any case); false for "0", "false", "off", "no". Anything else: false with OutValid = false. */ THEDESCENT_API bool ParseBool(const FString& Arg, bool& OutValid); /** * Reports that a command failed (DESIGN_UE.md section 9.3): logs `DESCENT_CMD_FAIL : ` as an * error and, when a scenario is running, fails the scenario. */ THEDESCENT_API void Fail(UWorld* World, const TCHAR* Command, const FString& Reason); }