Refactoring to move things from GameMode into UlxEngineWrapper subsystem.
This commit is contained in:
@@ -11,29 +11,50 @@
|
||||
#include "CoreMinimal.h"
|
||||
#include "lpx-enginewrapper.hpp"
|
||||
#include "Common.h"
|
||||
#include "StreamBuffer.h"
|
||||
#include "Subsystems/GameInstanceSubsystem.h"
|
||||
#include "LockedWrapper.generated.h"
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FlxLockableWrapper
|
||||
// UlxEngineWrapper
|
||||
//
|
||||
// Contains the EngineWrapper and a Mutex to lock it.
|
||||
// This class has no methods. To access the
|
||||
// EngineWrapper, construct a FlxLockedWrapper.
|
||||
// GameInstanceSubsystem that owns the EngineWrapper and
|
||||
// a Mutex to lock it. To access the EngineWrapper,
|
||||
// construct a FlxLockedWrapper.
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
class FlxLockableWrapper {
|
||||
UCLASS()
|
||||
class INTEGRATION_API UlxEngineWrapper : public UGameInstanceSubsystem {
|
||||
GENERATED_BODY()
|
||||
|
||||
private:
|
||||
static UlxEngineWrapper* Instance;
|
||||
|
||||
// Called by luprex to output debugging messages.
|
||||
// A thin wrapper around UE_LOG.
|
||||
//
|
||||
static void DPrintHook(const char *Msg, size_t Size);
|
||||
|
||||
FCriticalSection Mutex;
|
||||
EngineWrapper Wrapper;
|
||||
|
||||
// Temporary buffers used only inside wrapper
|
||||
// methods. Nothing persistent in these.
|
||||
// The Lua Call Assembly Buffer. Used to build up
|
||||
// a call across multiple UFUNCTION invocations.
|
||||
// Only accessed from the game thread.
|
||||
//
|
||||
TArray<uint32> AQLenBuffer;
|
||||
TArray<const char*> AQStrBuffer;
|
||||
FlxStreamBuffer LuaCallBuffer;
|
||||
|
||||
public:
|
||||
virtual void Initialize(FSubsystemCollectionBase& Collection) override;
|
||||
virtual void Deinitialize() override;
|
||||
|
||||
// Get the Lua Call Assembly Buffer.
|
||||
// Only called from the game thread.
|
||||
//
|
||||
static FlxStreamBuffer& GetLuaCallBuffer() { return Instance->LuaCallBuffer; }
|
||||
|
||||
friend class FlxLockedWrapper;
|
||||
};
|
||||
|
||||
@@ -49,12 +70,7 @@ public:
|
||||
|
||||
class FlxLockedWrapper {
|
||||
private:
|
||||
FlxLockableWrapper& Lockable;
|
||||
|
||||
// Called by luprex to output debugging messages.
|
||||
// A thin wrapper around UE_LOG.
|
||||
//
|
||||
static void DPrintHook(const char *Msg, size_t Size);
|
||||
UlxEngineWrapper& Lockable;
|
||||
|
||||
public:
|
||||
// Import these types into our namespace.
|
||||
@@ -66,7 +82,7 @@ public:
|
||||
public:
|
||||
// The constructor claims the mutex.
|
||||
//
|
||||
FlxLockedWrapper(FlxLockableWrapper& w) : Lockable(w) {
|
||||
FlxLockedWrapper() : Lockable(*UlxEngineWrapper::Instance) {
|
||||
Lockable.Mutex.Lock();
|
||||
}
|
||||
|
||||
@@ -90,13 +106,6 @@ public:
|
||||
return &Lockable.Wrapper;
|
||||
}
|
||||
|
||||
// Initialize the engine wrapper if it's not
|
||||
// already. All this does is open the DLL and
|
||||
// hook up all the function pointers in the
|
||||
// wrapper to point into the DLL.
|
||||
//
|
||||
void InitWrapper();
|
||||
|
||||
// Fetch Stdout as a string.
|
||||
//
|
||||
FString ChannelPrints();
|
||||
|
||||
Reference in New Issue
Block a user