Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,15 @@ void UResources::getExtractor(UObject* WorldContext, FRequestData RequestData, T

float CurrentProd = Productivity * MaxProd;

TSharedPtr<FJsonObject> JProduct = GetItemValueObject(ResourceClass->GetResourceClass(), ExtractorInventory->GetNumItems(ItemClass), Extractor->GetFluidInventoryStackSizeScalar());
// GetNumItems() asserts mInventoryStacks.Num() > 0 ("Inventory need to be
// initialized before use"), so an extractor whose output inventory has not
// been initialized yet - e.g. while the world is still streaming in - takes
// the whole game down. GetSizeLinear() reads the same array without asserting.
const int32 NumItems = (IsValid(ExtractorInventory) && ExtractorInventory->GetSizeLinear() > 0)
? ExtractorInventory->GetNumItems(ItemClass)
: 0;

TSharedPtr<FJsonObject> JProduct = GetItemValueObject(ResourceClass->GetResourceClass(), NumItems, Extractor->GetFluidInventoryStackSizeScalar());
JProduct->Values.Add("CurrentProd", MakeShared<FJsonValueNumber>(CurrentProd));
JProduct->Values.Add("MaxProd", MakeShared<FJsonValueNumber>(MaxProd));
JProduct->Values.Add("ProdPercent", MakeShared<FJsonValueNumber>(100 * UKismetMathLibrary::SafeDivide(CurrentProd, MaxProd)));
Expand Down Expand Up @@ -314,7 +322,10 @@ void UResources::getFrackingActivator(UObject* WorldContext, FRequestData Reques
const float Productivity = SatelliteExtractor->GetProductivity();
const UFGInventoryComponent* ExtractorInventory = SatelliteExtractor->GetOutputInventory();

const float NumItems = ExtractorInventory->GetNumItems(ItemClass);
// Same uninitialised-inventory assert as getExtractor above.
const float NumItems = (IsValid(ExtractorInventory) && ExtractorInventory->GetSizeLinear() > 0)
? ExtractorInventory->GetNumItems(ItemClass)
: 0;
BaseNumItems += NumItems;
float CurrentProd = Productivity * MaxProd;

Expand Down
12 changes: 9 additions & 3 deletions Source/FicsitRemoteMonitoring/Private/FicsitRemoteMonitoring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -756,10 +756,13 @@ void AFicsitRemoteMonitoring::InitAPIRegistry()
RegisterEndpoint(FAPIEndpoint("GET", "getEncoder", &UFactoryLibrary::getEncoder));
RegisterEndpoint(FAPIEndpoint("GET", "getExplorationSink", &USession::getExplorationSink));
RegisterEndpoint(FAPIEndpoint("GET", "getExplorer", &UVehicles::getExplorer).RequiresGameThread());
RegisterEndpoint(FAPIEndpoint("GET", "getExtractor", &UResources::getExtractor));
// RequiresGameThread: calls AFGBuildableFactory::GetProductivity(), which
// check()s IsInGameThread() and crashes when served off the uWS event loop.
RegisterEndpoint(FAPIEndpoint("GET", "getExtractor", &UResources::getExtractor).RequiresGameThread());
RegisterEndpoint(FAPIEndpoint("GET", "getFactoryCart", &UVehicles::getFactoryCart).RequiresGameThread());
RegisterEndpoint(FAPIEndpoint("GET", "getFoundry", &UFactoryLibrary::getFoundry));
RegisterEndpoint(FAPIEndpoint("GET", "getFrackingActivator", &UResources::getFrackingActivator));
// RequiresGameThread: same GetProductivity() game-thread check as getExtractor.
RegisterEndpoint(FAPIEndpoint("GET", "getFrackingActivator", &UResources::getFrackingActivator).RequiresGameThread());
RegisterEndpoint(FAPIEndpoint("GET", "getFuelGenerator", &UPower::getFuelGenerator));
RegisterEndpoint(FAPIEndpoint("GET", "getGeothermalGenerator", &UPower::getGeothermalGenerator));
RegisterEndpoint(FAPIEndpoint("GET", "getHazards", &UPlayerLibrary::getHazards).RequiresGameThread());
Expand All @@ -780,7 +783,10 @@ void AFicsitRemoteMonitoring::InitAPIRegistry()
RegisterEndpoint(FAPIEndpoint("GET", "getPower", &UPower::getPower));
RegisterEndpoint(FAPIEndpoint("GET", "getPowerSlug", &UResources::getPowerSlug).RequiresGameThread());
RegisterEndpoint(FAPIEndpoint("GET", "getPowerUsage", &UPower::getPowerUsage));
RegisterEndpoint(FAPIEndpoint("GET", "getProdStats", &USession::getProdStats));
// RequiresGameThread: walks every manufacturer/extractor/generator calling
// GetProductivity(), which check()s IsInGameThread(). This was the most
// frequent startup crash - the web UI polls it on a timer.
RegisterEndpoint(FAPIEndpoint("GET", "getProdStats", &USession::getProdStats).RequiresGameThread());
RegisterEndpoint(FAPIEndpoint("GET", "getPump", &ULogistics::getPump));
RegisterEndpoint(FAPIEndpoint("GET", "getRadarTower", &USupport::getRadarTower));
RegisterEndpoint(FAPIEndpoint("GET", "getRecipes", &UResearch::getRecipes).RequiresGameThread());
Expand Down
Loading