Skip to content

Commit

Permalink
SDK: AActor crash prevention
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Nov 29, 2023
1 parent 3e36763 commit 632dc2c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions shared/sdk/AActor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ UClass* AActor::static_class() {

bool AActor::set_actor_location(const glm::vec3& location, bool sweep, bool teleport) {
static const auto func = static_class()->find_function(L"K2_SetActorLocation");

if (func == nullptr) {
return false;
}

static const auto fhitresult = sdk::find_uobject<UScriptStruct>(L"ScriptStruct /Script/Engine.HitResult");
const auto fvector = sdk::ScriptVector::static_struct();

Expand Down Expand Up @@ -58,6 +63,11 @@ bool AActor::set_actor_location(const glm::vec3& location, bool sweep, bool tele

glm::vec3 AActor::get_actor_location() {
static const auto func = static_class()->find_function(L"K2_GetActorLocation");

if (func == nullptr) {
return glm::vec3{0.0f, 0.0f, 0.0f};
}

const auto fvector = sdk::ScriptVector::static_struct();

const auto is_ue5 = fvector->get_struct_size() == sizeof(glm::vec<3, double>);
Expand All @@ -81,6 +91,11 @@ 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");

if (func == nullptr) {
return false;
}

const auto frotator = sdk::ScriptRotator::static_struct();

const auto is_ue5 = frotator->get_struct_size() == sizeof(glm::vec<3, double>);
Expand Down Expand Up @@ -113,6 +128,11 @@ bool AActor::set_actor_rotation(const glm::vec3& rotation, bool teleport) {

glm::vec3 AActor::get_actor_rotation() {
static const auto func = static_class()->find_function(L"K2_GetActorRotation");

if (func == nullptr) {
return glm::vec3{0.0f, 0.0f, 0.0f};
}

const auto frotator = sdk::ScriptRotator::static_struct();

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

0 comments on commit 632dc2c

Please sign in to comment.