Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
CoreMisc.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "API/UE/Containers/Array.h"
6#include "API/UE/Containers/ContainerAllocationPolicies.h"
7#include "API/UE/Containers/Map.h"
8#include "API/UE/Containers/UnrealString.h"
9#include "API/UE/CoreGlobals.h"
10#include "API/UE/CoreTypes.h"
11#include "API/UE/HAL/PlatformProperties.h"
12#include "API/UE/HAL/ThreadSingleton.h"
13#include "API/UE/Logging/LogVerbosity.h"
14#include "API/UE/Math/IntPoint.h"
15#include "API/UE/Misc/Build.h"
16#include "API/UE/Misc/Exec.h"
17#include "API/UE/Templates/Function.h"
18#include "API/UE/UObject/NameTypes.h"
19
20class FOutputDevice;
21class UWorld;
22
23/**
24 * Exec handler that registers itself and is being routed via StaticExec.
25 * Note: Not intended for use with UObjects!
26 */
28{
29public:
30 /** Constructor, registering this instance. */
32 /** Destructor, unregistering this instance. */
34
35 /** Routes a command to the self-registered execs. */
36 static bool StaticExec( UWorld* Inworld, const TCHAR* Cmd, FOutputDevice& Ar );
37};
38
39/** Registers a static Exec function using FSelfRegisteringExec. */
41{
42public:
43
44 /** Initialization constructor. */
45 FStaticSelfRegisteringExec(bool (*InStaticExecFunc)(UWorld* Inworld, const TCHAR* Cmd,FOutputDevice& Ar));
46
47 //~ Begin Exec Interface
49 virtual bool Exec( UWorld* InWorld, const TCHAR* Cmd, FOutputDevice& Ar ) override;
50#endif
51 //~ End Exec Interface
52
53private:
54
55 bool (*StaticExecFunc)(UWorld* Inworld, const TCHAR* Cmd,FOutputDevice& Ar);
56};
57
58/** Registers a static Exec_Dev function using FSelfRegisteringExec. */
60{
61public:
62
63 /** Initialization constructor. */
64 explicit FStaticSelfRegisteringExec_Dev(bool (*InStaticExecFunc)(UWorld* Inworld, const TCHAR* Cmd, FOutputDevice& Ar));
65
66 //~ Begin Exec Interface
67 virtual bool Exec_Dev(UWorld* InWorld, const TCHAR* Cmd, FOutputDevice& Ar) override;
68 //~ End Exec Interface
69
70private:
71
72 bool (*StaticExecFunc)(UWorld* Inworld, const TCHAR* Cmd,FOutputDevice& Ar);
73};
74
75/** Registers a static Exec_Editor function using FSelfRegisteringExec. */
77{
78public:
79
80 /** Initialization constructor. */
81 explicit FStaticSelfRegisteringExec_Editor(bool (*InStaticExecFunc)(UWorld* Inworld, const TCHAR* Cmd, FOutputDevice& Ar));
82
83 //~ Begin Exec Interface
84 virtual bool Exec_Editor(UWorld* InWorld, const TCHAR* Cmd, FOutputDevice& Ar) override;
85 //~ End Exec Interface
86
87private:
88
89 bool (*StaticExecFunc)(UWorld* Inworld, const TCHAR* Cmd, FOutputDevice& Ar);
90};
91
92// Interface for returning a context string.
94{
95public:
96 virtual ~FContextSupplier() {}
97 virtual FString GetContext()=0;
98};
99
100
102{
103 /** deletes log files older than a number of days specified in the Engine ini file */
104 static void DeleteOldLogs();
105};
106
107/*-----------------------------------------------------------------------------
108 Module singletons.
109-----------------------------------------------------------------------------*/
110
111/** Returns the derived data cache interface if it is available, otherwise null. */
112class FDerivedDataCacheInterface* GetDerivedDataCache();
113
114/** Returns the derived data cache interface, or fatal error if it is not available. */
115class FDerivedDataCacheInterface& GetDerivedDataCacheRef();
116
117/** Returns the derived data cache interface if it is available and initialized, otherwise null. */
118class FDerivedDataCacheInterface* TryGetDerivedDataCache();
119
120/**
121 * Return the Target Platform Manager interface, if it is available, otherwise return nullptr.
122 *
123 * @param bFailOnInitErrors If true (default) and errors occur during init of the TPM, an error will be logged and the process may terminate, otherwise will return whether there was an error or not.
124 * @return The Target Platform Manager interface, if it is available, otherwise return nullptr.
125*/
126class ITargetPlatformManagerModule* GetTargetPlatformManager(bool bFailOnInitErrors = true);
127
128/** Return the Target Platform Manager interface, fatal error if it is not available. **/
129class ITargetPlatformManagerModule& GetTargetPlatformManagerRef();
130
131/**
132 * Return true if we are currently in a commandlet is targeting platforms with AV requirements (ie not a server)
133 * or we are not targetingother platforms, and the current platform needs to render (CanEverRender())
134 */
136
137/*-----------------------------------------------------------------------------
138 Runtime.
139-----------------------------------------------------------------------------*/
140
141/**
142 * Check to see if this executable is running as dedicated server
143 * Editor can run as dedicated with -server
144 */
146{
147 if (FPlatformProperties::IsServerOnly())
148 {
149 return true;
150 }
151
152 if (FPlatformProperties::IsGameOnly())
153 {
154 return false;
155 }
156
157#if UE_EDITOR
158 extern int32 StaticDedicatedServerCheck();
159 return (StaticDedicatedServerCheck() == 1);
160#else
161 return false;
162#endif
163}
164
165/**
166 * Check to see if this executable is running as "the game"
167 * - contains all net code (WITH_SERVER_CODE=1)
168 * Editor can run as a game with -game
169 */
171{
172 if (FPlatformProperties::IsGameOnly())
173 {
174 return true;
175 }
176
177 if (FPlatformProperties::IsServerOnly())
178 {
179 return false;
180 }
181
182#if UE_EDITOR
183 extern int32 StaticGameCheck();
184 return (StaticGameCheck() == 1);
185#else
186 return false;
187#endif
188}
189
190/**
191 * Check to see if this executable is running as "the client"
192 * - removes all net code (WITH_SERVER_CODE=0)
193 * Editor can run as a game with -clientonly
194 */
196{
197 if (FPlatformProperties::IsClientOnly())
198 {
199 return true;
200 }
201
202#if UE_EDITOR
203 extern int32 StaticClientOnlyCheck();
204 return (StaticClientOnlyCheck() == 1);
205#else
206 return false;
207#endif
208}
209
210/**
211 * Helper for obtaining the default Url configuration
212 */
214{
221
222 /**
223 * Initialize with defaults from ini
224 */
225 void Init();
226
227 /**
228 * Reset state
229 */
230 void Reset();
231};
232
233bool StringHasBadDashes(const TCHAR* Str);
234
235/** Helper structure for boolean values in config */
237{
238private:
239 bool bValue;
240public:
241 FBoolConfigValueHelper(const TCHAR* Section, const TCHAR* Key, const FString& Filename = GEditorIni);
242
243 operator bool() const
244 {
245 return bValue;
246 }
247};
248
249/**
250 * Function signature for handlers for script exceptions.
251 */
252typedef TFunction<void(ELogVerbosity::Type /*Verbosity*/, const TCHAR* /*ExceptionMessage*/, const TCHAR* /*StackMessage*/)> FScriptExceptionHandlerFunc;
253
254/**
255 * Exception handler stack used for script exceptions.
256 */
258{
259public:
260 /**
261 * Get the exception handler for the current thread
262 */
264
265 /**
266 * Push an exception handler onto the stack
267 */
269
270 /**
271 * Pop an exception handler from the stack
272 */
274
275 /**
276 * Handle an exception using the active exception handler
277 */
278 void HandleException(ELogVerbosity::Type Verbosity, const TCHAR* ExceptionMessage, const TCHAR* StackMessage);
279
280 /**
281 * Handler for a script exception that emits an ensure (for warnings or errors)
282 */
283 static void AssertionExceptionHandler(ELogVerbosity::Type Verbosity, const TCHAR* ExceptionMessage, const TCHAR* StackMessage);
284
285 /**
286 * Handler for a script exception that emits a log message
287 */
288 static void LoggingExceptionHandler(ELogVerbosity::Type Verbosity, const TCHAR* ExceptionMessage, const TCHAR* StackMessage);
289
290private:
291 /**
292 * Default script exception handler
293 */
295
296 /**
297 * Stack of active exception handlers
298 * The top of the stack will be called on an exception, or DefaultExceptionHandler will be used if the stack is empty
299 */
301};
302
303/**
304 * Scoped struct used to push and pop a script exception handler
305 */
307{
310};
311
312/**
313 * Enables named events when profiling.
314 * Increments/decrements GCycleStatsShouldEmitNamedEvents based on bIsProfiling.
315 * Functionality is controlled by stats.AutoEnableNamedEventsWhenProfiling.
316 */
318{
319public:
320 void Update(bool bIsProfiling);
321
322private:
324};
325
326/**
327 * This define enables the blueprint runaway and exception stack trace checks
328 * If this is true, it will create a FBlueprintContextTracker (previously FBlueprintExceptionTracker) which is defined in Script.h
329 */
330#ifndef DO_BLUEPRINT_GUARD
332 #define DO_BLUEPRINT_GUARD 1
333 #else
334 #define DO_BLUEPRINT_GUARD 0
335 #endif
336#endif
337
338/** This define enables ScriptAudit exec commands */
339#ifndef SCRIPT_AUDIT_ROUTINES
341 #define SCRIPT_AUDIT_ROUTINES 1
342 #else
343 #define SCRIPT_AUDIT_ROUTINES 0
344 #endif
345#endif
#define UE_BUILD_TEST
Definition Build.h:23
#define UE_BUILD_SHIPPING
Definition Build.h:4
#define WITH_EDITOR
Definition Build.h:7
#define UE_EDITOR
Definition Build.h:32
FString GEditorIni
class FDerivedDataCacheInterface * GetDerivedDataCache()
FORCEINLINE bool IsRunningClientOnly()
Definition CoreMisc.h:195
class FDerivedDataCacheInterface & GetDerivedDataCacheRef()
class ITargetPlatformManagerModule * GetTargetPlatformManager(bool bFailOnInitErrors=true)
FORCEINLINE bool IsRunningDedicatedServer()
Definition CoreMisc.h:145
bool WillNeedAudioVisualData()
bool StringHasBadDashes(const TCHAR *Str)
class ITargetPlatformManagerModule & GetTargetPlatformManagerRef()
TFunction< void(ELogVerbosity::Type, const TCHAR *, const TCHAR *) FScriptExceptionHandlerFunc)
Definition CoreMisc.h:252
class FDerivedDataCacheInterface * TryGetDerivedDataCache()
FORCEINLINE bool IsRunningGame()
Definition CoreMisc.h:170
#define UE_ALLOW_EXEC_COMMANDS
Definition Exec.h:15
#define FORCEINLINE
Definition Platform.h:644
void Update(bool bIsProfiling)
virtual FString GetContext()=0
virtual ~FContextSupplier()
Definition CoreMisc.h:96
Definition Exec.h:29
static void LoggingExceptionHandler(ELogVerbosity::Type Verbosity, const TCHAR *ExceptionMessage, const TCHAR *StackMessage)
static FScriptExceptionHandlerFunc DefaultExceptionHandler
Definition CoreMisc.h:294
void PushExceptionHandler(const FScriptExceptionHandlerFunc &InFunc)
void HandleException(ELogVerbosity::Type Verbosity, const TCHAR *ExceptionMessage, const TCHAR *StackMessage)
static void AssertionExceptionHandler(ELogVerbosity::Type Verbosity, const TCHAR *ExceptionMessage, const TCHAR *StackMessage)
TArray< FScriptExceptionHandlerFunc, TInlineAllocator< 4 > > ExceptionHandlerStack
Definition CoreMisc.h:300
static FScriptExceptionHandler & Get()
static bool StaticExec(UWorld *Inworld, const TCHAR *Cmd, FOutputDevice &Ar)
virtual ~FSelfRegisteringExec()
virtual bool Exec_Dev(UWorld *InWorld, const TCHAR *Cmd, FOutputDevice &Ar) override
FStaticSelfRegisteringExec_Dev(bool(*InStaticExecFunc)(UWorld *Inworld, const TCHAR *Cmd, FOutputDevice &Ar))
bool(* StaticExecFunc)(UWorld *Inworld, const TCHAR *Cmd, FOutputDevice &Ar)
Definition CoreMisc.h:72
FStaticSelfRegisteringExec_Editor(bool(*InStaticExecFunc)(UWorld *Inworld, const TCHAR *Cmd, FOutputDevice &Ar))
virtual bool Exec_Editor(UWorld *InWorld, const TCHAR *Cmd, FOutputDevice &Ar) override
bool(* StaticExecFunc)(UWorld *Inworld, const TCHAR *Cmd, FOutputDevice &Ar)
Definition CoreMisc.h:89
bool(* StaticExecFunc)(UWorld *Inworld, const TCHAR *Cmd, FOutputDevice &Ar)
Definition CoreMisc.h:55
FStaticSelfRegisteringExec(bool(*InStaticExecFunc)(UWorld *Inworld, const TCHAR *Cmd, FOutputDevice &Ar))
FBoolConfigValueHelper(const TCHAR *Section, const TCHAR *Key, const FString &Filename=GEditorIni)
static void DeleteOldLogs()
FScopedScriptExceptionHandler(const FScriptExceptionHandlerFunc &InFunc)
FString DefaultPortal
Definition CoreMisc.h:218
int32 DefaultPort
Definition CoreMisc.h:220
FString DefaultHost
Definition CoreMisc.h:217
void Reset()
FString DefaultSaveExt
Definition CoreMisc.h:219
void Init()
FString DefaultProtocol
Definition CoreMisc.h:215
FString DefaultName
Definition CoreMisc.h:216