Skip to content

Commit

Permalink
SDK: Fix Rotator name on really old UE ( < 4.8)
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Aug 23, 2023
1 parent 95e0287 commit 30ff905
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ list(APPEND sdk_SOURCES
"shared/sdk/FViewportInfo.cpp"
"shared/sdk/Globals.cpp"
"shared/sdk/ScriptMatrix.cpp"
"shared/sdk/ScriptRotator.cpp"
"shared/sdk/ScriptVector.cpp"
"shared/sdk/Slate.cpp"
"shared/sdk/StereoStuff.cpp"
Expand Down Expand Up @@ -361,6 +362,7 @@ list(APPEND sdk_SOURCES
"shared/sdk/Math.hpp"
"shared/sdk/RHICommandList.hpp"
"shared/sdk/ScriptMatrix.hpp"
"shared/sdk/ScriptRotator.hpp"
"shared/sdk/ScriptVector.hpp"
"shared/sdk/Slate.hpp"
"shared/sdk/StereoStuff.hpp"
Expand Down Expand Up @@ -442,6 +444,7 @@ list(APPEND sdk-nolog_SOURCES
"shared/sdk/FViewportInfo.cpp"
"shared/sdk/Globals.cpp"
"shared/sdk/ScriptMatrix.cpp"
"shared/sdk/ScriptRotator.cpp"
"shared/sdk/ScriptVector.cpp"
"shared/sdk/Slate.cpp"
"shared/sdk/StereoStuff.cpp"
Expand Down Expand Up @@ -474,6 +477,7 @@ list(APPEND sdk-nolog_SOURCES
"shared/sdk/Math.hpp"
"shared/sdk/RHICommandList.hpp"
"shared/sdk/ScriptMatrix.hpp"
"shared/sdk/ScriptRotator.hpp"
"shared/sdk/ScriptVector.hpp"
"shared/sdk/Slate.hpp"
"shared/sdk/StereoStuff.hpp"
Expand Down
3 changes: 2 additions & 1 deletion shared/sdk/AActor.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <vector>
#include "UObjectArray.hpp"
#include "ScriptVector.hpp"
#include "ScriptRotator.hpp"

#include "AActor.hpp"

Expand Down Expand Up @@ -69,7 +70,7 @@ glm::vec3 AActor::get_actor_location() {
}
bool AActor::set_actor_rotation(const glm::vec3& rotation, bool teleport) {
static const auto func = static_class()->find_function(L"K2_SetActorRotation");
static const auto frotator = sdk::find_uobject<UScriptStruct>(L"ScriptStruct /Script/CoreUObject.Rotator");
const auto frotator = sdk::ScriptRotator::static_struct();

const auto is_ue5 = frotator->get_struct_size() == sizeof(glm::vec<3, double>);

Expand Down
12 changes: 12 additions & 0 deletions shared/sdk/ScriptRotator.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include "UObjectArray.hpp"

#include "ScriptRotator.hpp"

namespace sdk {
UScriptStruct* ScriptRotator::static_struct() {
static auto modern_class = sdk::find_uobject<UScriptStruct>(L"ScriptStruct /Script/CoreUObject.Rotator");
static auto old_class = sdk::find_uobject<UScriptStruct>(L"ScriptStruct /Script/CoreUObject.Object.Rotator");

return modern_class != nullptr ? modern_class : old_class;
}
}
12 changes: 12 additions & 0 deletions shared/sdk/ScriptRotator.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#pragma once

#include "UClass.hpp"

namespace sdk {
class ScriptRotator : public UObject {
public:
static UScriptStruct* static_struct();

protected:
};
}

0 comments on commit 30ff905

Please sign in to comment.