wip:regression on skylander status array fixed
This commit is contained in:
parent
b959059755
commit
952b184f10
2 changed files with 31 additions and 7 deletions
|
@ -13,7 +13,7 @@ void USkyPortalSubsystem::Initialize(FSubsystemCollectionBase& Collection)
|
||||||
|
|
||||||
Super::Initialize(Collection);
|
Super::Initialize(Collection);
|
||||||
// Start the status checker thread
|
// Start the status checker thread
|
||||||
StatusChecker = new FPortalStatusChecker(this, 0.01f); // Check every 10 milliseconds
|
StatusChecker = new FPortalStatusChecker(this, RunnerInterval);
|
||||||
StatusCheckerThread = FRunnableThread::Create(StatusChecker, TEXT("PortalStatusCheckerThread"), 0, TPri_AboveNormal);
|
StatusCheckerThread = FRunnableThread::Create(StatusChecker, TEXT("PortalStatusCheckerThread"), 0, TPri_AboveNormal);
|
||||||
|
|
||||||
UE_LOG(LogTemp, Log, TEXT("SkyPortalSubsystem Initialized"));
|
UE_LOG(LogTemp, Log, TEXT("SkyPortalSubsystem Initialized"));
|
||||||
|
@ -69,18 +69,18 @@ void USkyPortalSubsystem::PortalReady()
|
||||||
|
|
||||||
memset(command.data, 0, write_buf_size); //maybe not needed here
|
memset(command.data, 0, write_buf_size); //maybe not needed here
|
||||||
command.data[1] = 'R';
|
command.data[1] = 'R';
|
||||||
uint8* output;
|
unsigned char* output;
|
||||||
do {
|
do {
|
||||||
PortalHandle->Write(&command);
|
PortalHandle->Write(&command);
|
||||||
output = PortalHandle->Read();
|
output = PortalHandle->Read();
|
||||||
} while (output[0] != 'R');
|
} while (output[0] != 'R');
|
||||||
|
|
||||||
unsigned char _PortalId[2] = { output[1],output[2] };
|
unsigned char _PortalId[2] = { output[1],output[2] };
|
||||||
int32 BE_PortalId = (_PortalId[0] << 8) | _PortalId[1]; // Big-endian format
|
uint16_t BE_PortalId = (_PortalId[0] << 8) | _PortalId[1]; // Big-endian format
|
||||||
uint32 BEU_PortalId = (_PortalId[0] << 8) | _PortalId[1]; // Big-endian format unsigned
|
uint32 BEU_PortalId = (_PortalId[0] << 8) | _PortalId[1]; // Big-endian format unsigned
|
||||||
int32 LE_PortalId = (_PortalId[1] << 8) | _PortalId[0]; //little endian
|
uint16_t LE_PortalId = (_PortalId[1] << 8) | _PortalId[0]; //little endian
|
||||||
uint32 LEU_PortalId = (_PortalId[1] << 8) | _PortalId[0]; //little endian unsigned
|
//uint32 LEU_PortalId = (_PortalId[1] << 8) | _PortalId[0]; //little endian unsigned
|
||||||
PortalId = LE_PortalId; //Need a conversion as uint16 is not supported in BP
|
PortalId = BEU_PortalId; //Need a conversion as uint16 is not supported in BP
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,6 +101,25 @@ FPortalStatusData USkyPortalSubsystem::PortalStatus() {
|
||||||
return ParsePortalStatus(output);
|
return ParsePortalStatus(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SKYPORTAL_API bool USkyPortalSubsystem::RestartRunner()
|
||||||
|
{
|
||||||
|
if (StatusChecker)
|
||||||
|
{
|
||||||
|
StatusChecker->Stop();
|
||||||
|
StatusCheckerThread->WaitForCompletion();
|
||||||
|
|
||||||
|
delete StatusCheckerThread;
|
||||||
|
delete StatusChecker;
|
||||||
|
StatusChecker = nullptr;
|
||||||
|
StatusCheckerThread = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
StatusChecker = new FPortalStatusChecker(this, RunnerInterval); // Check every 10 milliseconds
|
||||||
|
StatusCheckerThread = FRunnableThread::Create(StatusChecker, TEXT("PortalStatusCheckerThread"), 0, TPri_AboveNormal);
|
||||||
|
|
||||||
|
UE_LOG(LogTemp, Log, TEXT("SkyPortalSubsystem Initialized"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,9 @@ public:
|
||||||
UFUNCTION(BlueprintCallable, CallInEditor, meta = (Category = "SkyPortal|Commands"))
|
UFUNCTION(BlueprintCallable, CallInEditor, meta = (Category = "SkyPortal|Commands"))
|
||||||
SKYPORTAL_API FPortalStatusData PortalStatus();
|
SKYPORTAL_API FPortalStatusData PortalStatus();
|
||||||
|
|
||||||
|
/**/
|
||||||
|
UFUNCTION(BlueprintCallable, CallInEditor, meta = (Category = "SkyPortal"))
|
||||||
|
SKYPORTAL_API bool RestartRunner();
|
||||||
|
|
||||||
|
|
||||||
/* Change the color of the portal, can separate side and even trap ligth
|
/* Change the color of the portal, can separate side and even trap ligth
|
||||||
|
@ -102,6 +104,9 @@ public:
|
||||||
UPROPERTY(BlueprintReadOnly)
|
UPROPERTY(BlueprintReadOnly)
|
||||||
FPortalStatusData StatusData;
|
FPortalStatusData StatusData;
|
||||||
|
|
||||||
|
UPROPERTY(BlueprintReadWrite)
|
||||||
|
float RunnerInterval = 0.01f; //In seconds
|
||||||
|
|
||||||
/* Different for each portal model.
|
/* Different for each portal model.
|
||||||
*
|
*
|
||||||
* SSA :
|
* SSA :
|
||||||
|
|
Loading…
Reference in a new issue