diff --git a/Source/SkyPortal/Private/SkyPortalIO.cpp b/Source/SkyPortal/Private/SkyPortalIO.cpp index a3a4b3e..9e68070 100644 --- a/Source/SkyPortal/Private/SkyPortalIO.cpp +++ b/Source/SkyPortal/Private/SkyPortalIO.cpp @@ -206,7 +206,11 @@ uint8* USkyPortalIO::QueryBlock(uint8 FigureIndex, uint8 BlockIndex) } } - } while (write == false && (output[0] != 'Q' || (output[1] % 0x10 != FigureIndex && output[1] != 0x01) || output[2] != BlockIndex) && attempt < 10); + } while (write == false && output && (output[0] != 'Q' || (output[1] % 0x10 != FigureIndex && output[1] != 0x01) || output[2] != BlockIndex) && attempt < 10); + if (output == nullptr) { + UE_LOG(LogSkyportalIO, Error, TEXT("Query failed after %d attempts"), attempt); + return 0; // Return early if the loop failed to get valid output + } UE_LOG(LogSkyportalIO, Verbose, TEXT("Querying block %d - success"), BlockIndex); UE_LOG(LogSkyportalIO, VeryVerbose, TEXT("Data block %d = \n %s"), BlockIndex,*OutputToString(output)); return output; diff --git a/Source/SkyPortal/Private/SkyPortalRunner.cpp b/Source/SkyPortal/Private/SkyPortalRunner.cpp index 5fa3c4f..5b1475b 100644 --- a/Source/SkyPortal/Private/SkyPortalRunner.cpp +++ b/Source/SkyPortal/Private/SkyPortalRunner.cpp @@ -71,6 +71,8 @@ void FPortalStatusChecker::CheckPortalStatus() if ( //!FalsePositive() //filter conflicting infos true) { + int32 figID = 0; + UFigureData* figData = NewObject(); //FigureDataBlock FigureData; switch (CurrentStatusData.StatusArray[i]) { @@ -78,8 +80,12 @@ void FPortalStatusChecker::CheckPortalStatus() case EFigureStatus::PRESENT: break; case EFigureStatus::ADDED: - //figData = PortalHandleRef->ReadFigureBlocks(i); - subref->OnSkylanderAdded.Broadcast(00, i); + figData = PortalHandleRef->ReadFigureBlocks(i); + if (figData) + { + figID = figData->GetFigureID(); + } + subref->OnSkylanderAdded.Broadcast(figID, i); break; case EFigureStatus::REMOVED: subref->OnSkylanderRemoved.Broadcast(00, i);