Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugs ObjectDeliveryBoxUsingJson UE5.4.3 - Fix inside #70

Open
Micha95 opened this issue Aug 24, 2024 · 0 comments
Open

Bugs ObjectDeliveryBoxUsingJson UE5.4.3 - Fix inside #70

Micha95 opened this issue Aug 24, 2024 · 0 comments

Comments

@Micha95
Copy link

Micha95 commented Aug 24, 2024

Unfortunately the game crashes when using "Create Dynamic Object Delivery Box Using Json" or using "Create Custom Object Delivery Box Using Json" with "Write Type" Serializer. Because the ConstructorHelpers can now only be accessed within constructors.

Also the Map for "Create Custom Object Delivery Box Using Json" is not used at all.

To fix this replace the following functions:

ODObjectUtil.cpp:

bool UODObjectUtil::FindClass(const FString& ClassName, UClass*& Class)
{	
	UClass* LoadedClass = FSoftClassPath(ClassName).TryLoadClass<UObject>();

	bool bFound = false;
	if (LoadedClass)
	{
		LoadedClass->AddToRoot();
		bFound = true;
		Class = LoadedClass;
	}	
	if (!bFound) UE_LOG(LogObjectDeliverer, Error, TEXT("Can't find class."));
	return bFound;
}

ODJsonSerializer.cpp:

TSharedPtr<FJsonObject> UODJsonSerializer::CreateJsonObject(const UObject* Obj, int64 CheckFlags /*= 0*/, int64 SkipFlags /*= 0*/)
{
	return UObjectToJsonObject(Obj->GetClass(), Obj, CheckFlags, SkipFlags);
}

ODOverrideJsonSerializer.cpp:

TSharedPtr<FJsonObject> UODWriteTypeJsonSerializer::UObjectToJsonObject(UODJsonSerializer* JsonSerializer, const UObject* Obj, int64 CheckFlags, int64 SkipFlags) const
{
	TSharedPtr<FJsonObject> JsonObject = MakeShareable(new FJsonObject());

	if (!Obj) return JsonObject;
	JsonObject->SetStringField(TEXT("Type"), Obj->GetClass()->GetPathName());

	TSharedPtr<FJsonObject> JsonObjectBody = MakeShareable(new FJsonObject());

	for (TFieldIterator<FProperty> PropIt(Obj->GetClass(), EFieldIteratorFlags::IncludeSuper); PropIt; ++PropIt)
	{
		JsonSerializer->AddJsonValue(JsonObjectBody, Obj, *PropIt, CheckFlags, SkipFlags);
	}

	JsonObject->SetObjectField(TEXT("Body"), JsonObjectBody);

	return JsonObject;
}
@Micha95 Micha95 changed the title Bugs ObjectDeliveryBoxUsingJson UE5.4.3 Bugs ObjectDeliveryBoxUsingJson UE5.4.3 - Fix inside this comment Aug 24, 2024
@Micha95 Micha95 changed the title Bugs ObjectDeliveryBoxUsingJson UE5.4.3 - Fix inside this comment Bugs ObjectDeliveryBoxUsingJson UE5.4.3 - Fix inside Aug 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant