Refactoring to move things from GameMode into UlxEngineWrapper subsystem.

This commit is contained in:
2026-02-27 17:00:46 -05:00
parent 0aea1e0798
commit 7bb4854844
6 changed files with 99 additions and 119 deletions

View File

@@ -1,6 +1,7 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#include "LuprexGameModeBase.h"
#include "LockedWrapper.h"
#include "lpx-drvutil.hpp"
#include "Misc/Paths.h"
#include "Tangible.h"
@@ -20,25 +21,17 @@ using namespace LpxCommonTypes;
ALuprexGameModeBase::ALuprexGameModeBase()
{
PlayerId = 0;
EngineSeconds = 0.0;
MustCallLookAtChanged = false;
//PrimaryActorTick.bCanEverTick = true; // Probably wrong
//PrimaryActorTick.bTickEvenWhenPaused = true; // Probably wrong
//PrimaryActorTick.TickGroup = TG_PrePhysics; // Probably wrong
ResetToInitialState();
}
ALuprexGameModeBase::~ALuprexGameModeBase()
{
ResetToInitialState();
}
// This method runs in the background thread,
// at the moment we trigger it.
//
uint32 ALuprexGameModeBase::Run() {
FlxLockedWrapper lockedwrap(LockableWrapper);
FlxLockedWrapper lockedwrap;
if (lockedwrap->get_rescan_lua_source(lockedwrap.Get()))
{
drvutil::ostringstream srcpak;
@@ -77,7 +70,7 @@ void ALuprexGameModeBase::ResetToInitialState()
// Now that the thread's gone, we should be able to
// just claim and hold the lock on the wrapper.
FlxLockedWrapper w(LockableWrapper);
FlxLockedWrapper w;
// Release and close all sockets.
if (Sockets != nullptr)
@@ -92,12 +85,12 @@ void ALuprexGameModeBase::ResetToInitialState()
w->release(w.Get());
}
// Clear the lua call assembly buffer.
UlxEngineWrapper::GetLuaCallBuffer().clear();
// Stop trapping log errors to the debugger.
BreakToDebuggerLogVerbosityDevice.Reset();
// Clear the lua call assembly buffer.
LuaCallBuffer.clear();
// Clear the PlayerID
PlayerId = 0;
@@ -112,7 +105,7 @@ void ALuprexGameModeBase::ResetToInitialState()
void ALuprexGameModeBase::UpdateConsoleOutput() {
// Copy Luprex Stdout into the console.
FlxLockedWrapper lockedwrap(LockableWrapper);
FlxLockedWrapper lockedwrap;
if (Playing) {
FString Text = lockedwrap.ChannelPrints();
if (!Text.IsEmpty())
@@ -130,7 +123,7 @@ void ALuprexGameModeBase::UpdateTangibles() {
UlxTangibleManager *TM = GetGameInstance()->GetSubsystem<UlxTangibleManager>();
TanArray alltans;
{
FlxLockedWrapper w(LockableWrapper);
FlxLockedWrapper w;
PlayerId = w.GetActor();
IdView nearids = w.GetNear(PlayerId, radius, radius, radius);
TM->UpdateNearAccordingToLuprex(nearids);
@@ -210,15 +203,12 @@ void ALuprexGameModeBase::BeginPlay()
void ALuprexGameModeBase::InitializeGlobalState()
{
FlxLockedWrapper w(LockableWrapper);
FlxLockedWrapper w;
// Sanity checks. Make sure everything is clean.
checkf(!LuprexUpdateTask.IsRunning(), TEXT("There should be no thread here."));
checkf(w->engine == nullptr, TEXT("There should be no engine here."));
// Try to initialize the wrapper.
w.InitWrapper();
// If we failed to initialize the wrapper, print an error message.
if (w->play_initialize == nullptr)
{