-
Notifications
You must be signed in to change notification settings - Fork 147
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
Fix FindObject and Mod:SetSharedVariable userdata type matching #342
Fix FindObject and Mod:SetSharedVariable userdata type matching #342
Conversation
* "UWorld" and "AActor" should retain the prefix when comparing against userdata.get_object_name().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes make sense.
The missing A
and U
prefixes for Actor
and World
was unintentional.
I also want to clarify the comment in the code.
Right now, we're comparing the object name to several strings, that's bad, because it's annoying and slow.
What we should be doing is storing the type information somewhere in a non-string format so that we can check the type (inheritance included) by doing something like: if (userdata->is_a<LuaUObject>)
or something similar.
Technically, the |
There seems to be a I don't see any use of |
I can't think of a reason why we're not using those functions very much. Regarding It looks like it's only LuaUEnum and LuaUWorld in the whole system that are UObjects that don't inherit from I believe In the end, I would think we should be able to do: if (userdata.derives_from_object()) instead of: if (lua_object_name == "UObject" || lua_object_name == "UWorld" || lua_object_name == "AActor") And the same for the FName check. In the one place that we do use it, we call |
Tested locally, passing UWorld and AActor instances to second param of
FindObject(UClass InClass, UObject InOuter, string Name, bool ExactClass)
(overload 2) does not error with "No overload found for function 'FindObject'" anymore. Fix is good if there's still no solution to the todo comment.Currently,
userdata.get_object_name()
is compared against"Actor"
and"World"
, whereasuserdata.get_object_name()
will return"AActor"
and"UWorld"
instead, so should keep those prefixes in the comparison strings.note: Unsure if
FindObject
'sInOuter
param should also acceptUClass
,UScriptStruct
, and/orUStruct
types like inSetSharedVariable
.