Skip to content

Commit

Permalink
Config struct BP fixes (#281)
Browse files Browse the repository at this point in the history
* SML/Configuration: Make `FillConfigStruct` non-pure

The `UConfigProperty::FillConfigStruct` function is exposed as a pure
function by default because it is `const`. However, since it does not
return anything, there's no good way to know when it will be executed
as pure functions do not have execution pins.

Explicitly make this function non-pure so that it has execution pins.

Signed-off-by: Angel Pons <[email protected]>

* SML/Reflection: Fix NULL check in custom thunks

The `execDeflectStruct` and `execReflectStruct` custom thunks would
throw a blueprint exception when `StructInfo.Struct` is *not* NULL.
This seems to be a mistake, as the log message says that the passed
struct was NULL and `CheckStructParameter` only returns NULL if the
passed struct parameter is invalid.

Flip the NULL checks to make struct reflection and deflection work.

Signed-off-by: Angel Pons <[email protected]>

---------

Signed-off-by: Angel Pons <[email protected]>
  • Loading branch information
Th3Fanbus authored Oct 5, 2024
1 parent e866629 commit a0cff60
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Mods/SML/Source/SML/Public/Configuration/ConfigProperty.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class SML_API UConfigProperty : public UObject {
FConfigVariableDescriptor CreatePropertyDescriptor(class UConfigGenerationContext* Context, const FString& OuterPath) const;

/** Fills variable of provided object with the value carried by this property */
UFUNCTION(BlueprintCallable, BlueprintNativeEvent)
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, BlueprintPure = false)
void FillConfigStruct(const FReflectedObject& ReflectedObject, const FString& VariableName) const;

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class SML_API UBlueprintReflectionLibrary : public UBlueprintFunctionLibrary {
P_FINISH;

P_NATIVE_BEGIN;
if (StructInfo.Struct != NULL) {
if (StructInfo.Struct == NULL) {
const FBlueprintExceptionInfo ExceptionInfo(EBlueprintExceptionType::AccessViolation,
INVTEXT("Tried to pass NULL struct to DeflectStruct"));
FBlueprintCoreDelegates::ThrowScriptException(Context, Stack, ExceptionInfo);
Expand All @@ -175,7 +175,7 @@ class SML_API UBlueprintReflectionLibrary : public UBlueprintFunctionLibrary {
P_FINISH;

P_NATIVE_BEGIN;
if (StructInfo.Struct != NULL) {
if (StructInfo.Struct == NULL) {
const FBlueprintExceptionInfo ExceptionInfo(EBlueprintExceptionType::AccessViolation,
INVTEXT("Tried to pass NULL struct to ReflectStruct"));
FBlueprintCoreDelegates::ThrowScriptException(Context, Stack, ExceptionInfo);
Expand Down

0 comments on commit a0cff60

Please sign in to comment.