Skip to content

Commit

Permalink
Merge branch 'praydog:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
joeyhodge authored Oct 19, 2024
2 parents 69f76e1 + d474aa0 commit f02df96
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 8 deletions.
24 changes: 24 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ if(REF_BUILD_RE2_SDK OR REF_BUILD_FRAMEWORK) # build-re2-sdk
"shared/sdk/MurmurHash.cpp"
"shared/sdk/REArray.cpp"
"shared/sdk/REContext.cpp"
"shared/sdk/REGameObject.cpp"
"shared/sdk/REGlobals.cpp"
"shared/sdk/REManagedObject.cpp"
"shared/sdk/RETransform.cpp"
Expand Down Expand Up @@ -585,6 +586,7 @@ if(REF_BUILD_RE2_SDK OR REF_BUILD_FRAMEWORK) # build-re2-sdk
"shared/sdk/REArray.hpp"
"shared/sdk/REComponent.hpp"
"shared/sdk/REContext.hpp"
"shared/sdk/REGameObject.hpp"
"shared/sdk/REGlobals.hpp"
"shared/sdk/REManagedObject.hpp"
"shared/sdk/REMath.hpp"
Expand Down Expand Up @@ -1385,6 +1387,7 @@ if(REF_BUILD_RE2_TDB66SDK OR REF_BUILD_FRAMEWORK) # build-re2tdb66-sdk
"shared/sdk/MurmurHash.cpp"
"shared/sdk/REArray.cpp"
"shared/sdk/REContext.cpp"
"shared/sdk/REGameObject.cpp"
"shared/sdk/REGlobals.cpp"
"shared/sdk/REManagedObject.cpp"
"shared/sdk/RETransform.cpp"
Expand Down Expand Up @@ -1414,6 +1417,7 @@ if(REF_BUILD_RE2_TDB66SDK OR REF_BUILD_FRAMEWORK) # build-re2tdb66-sdk
"shared/sdk/REArray.hpp"
"shared/sdk/REComponent.hpp"
"shared/sdk/REContext.hpp"
"shared/sdk/REGameObject.hpp"
"shared/sdk/REGlobals.hpp"
"shared/sdk/REManagedObject.hpp"
"shared/sdk/REMath.hpp"
Expand Down Expand Up @@ -2629,6 +2633,7 @@ if(REF_BUILD_RE3_SDK OR REF_BUILD_FRAMEWORK) # build-re3-sdk
"shared/sdk/MurmurHash.cpp"
"shared/sdk/REArray.cpp"
"shared/sdk/REContext.cpp"
"shared/sdk/REGameObject.cpp"
"shared/sdk/REGlobals.cpp"
"shared/sdk/REManagedObject.cpp"
"shared/sdk/RETransform.cpp"
Expand Down Expand Up @@ -2658,6 +2663,7 @@ if(REF_BUILD_RE3_SDK OR REF_BUILD_FRAMEWORK) # build-re3-sdk
"shared/sdk/REArray.hpp"
"shared/sdk/REComponent.hpp"
"shared/sdk/REContext.hpp"
"shared/sdk/REGameObject.hpp"
"shared/sdk/REGlobals.hpp"
"shared/sdk/REManagedObject.hpp"
"shared/sdk/REMath.hpp"
Expand Down Expand Up @@ -3458,6 +3464,7 @@ if(REF_BUILD_RE3_TDB67SDK OR REF_BUILD_FRAMEWORK) # build-re3tdb67-sdk
"shared/sdk/MurmurHash.cpp"
"shared/sdk/REArray.cpp"
"shared/sdk/REContext.cpp"
"shared/sdk/REGameObject.cpp"
"shared/sdk/REGlobals.cpp"
"shared/sdk/REManagedObject.cpp"
"shared/sdk/RETransform.cpp"
Expand Down Expand Up @@ -3487,6 +3494,7 @@ if(REF_BUILD_RE3_TDB67SDK OR REF_BUILD_FRAMEWORK) # build-re3tdb67-sdk
"shared/sdk/REArray.hpp"
"shared/sdk/REComponent.hpp"
"shared/sdk/REContext.hpp"
"shared/sdk/REGameObject.hpp"
"shared/sdk/REGlobals.hpp"
"shared/sdk/REManagedObject.hpp"
"shared/sdk/REMath.hpp"
Expand Down Expand Up @@ -4909,6 +4917,7 @@ if(REF_BUILD_RE4_SDK OR REF_BUILD_FRAMEWORK) # build-re4-sdk
"shared/sdk/MurmurHash.cpp"
"shared/sdk/REArray.cpp"
"shared/sdk/REContext.cpp"
"shared/sdk/REGameObject.cpp"
"shared/sdk/REGlobals.cpp"
"shared/sdk/REManagedObject.cpp"
"shared/sdk/RETransform.cpp"
Expand Down Expand Up @@ -4938,6 +4947,7 @@ if(REF_BUILD_RE4_SDK OR REF_BUILD_FRAMEWORK) # build-re4-sdk
"shared/sdk/REArray.hpp"
"shared/sdk/REComponent.hpp"
"shared/sdk/REContext.hpp"
"shared/sdk/REGameObject.hpp"
"shared/sdk/REGlobals.hpp"
"shared/sdk/REManagedObject.hpp"
"shared/sdk/REMath.hpp"
Expand Down Expand Up @@ -5740,6 +5750,7 @@ if(REF_BUILD_RE7_SDK OR REF_BUILD_FRAMEWORK) # build-re7-sdk
"shared/sdk/MurmurHash.cpp"
"shared/sdk/REArray.cpp"
"shared/sdk/REContext.cpp"
"shared/sdk/REGameObject.cpp"
"shared/sdk/REGlobals.cpp"
"shared/sdk/REManagedObject.cpp"
"shared/sdk/RETransform.cpp"
Expand Down Expand Up @@ -5769,6 +5780,7 @@ if(REF_BUILD_RE7_SDK OR REF_BUILD_FRAMEWORK) # build-re7-sdk
"shared/sdk/REArray.hpp"
"shared/sdk/REComponent.hpp"
"shared/sdk/REContext.hpp"
"shared/sdk/REGameObject.hpp"
"shared/sdk/REGlobals.hpp"
"shared/sdk/REManagedObject.hpp"
"shared/sdk/REMath.hpp"
Expand Down Expand Up @@ -6569,6 +6581,7 @@ if(REF_BUILD_RE7_TDB49SDK OR REF_BUILD_FRAMEWORK) # build-re7tdb49-sdk
"shared/sdk/MurmurHash.cpp"
"shared/sdk/REArray.cpp"
"shared/sdk/REContext.cpp"
"shared/sdk/REGameObject.cpp"
"shared/sdk/REGlobals.cpp"
"shared/sdk/REManagedObject.cpp"
"shared/sdk/RETransform.cpp"
Expand Down Expand Up @@ -6598,6 +6611,7 @@ if(REF_BUILD_RE7_TDB49SDK OR REF_BUILD_FRAMEWORK) # build-re7tdb49-sdk
"shared/sdk/REArray.hpp"
"shared/sdk/REComponent.hpp"
"shared/sdk/REContext.hpp"
"shared/sdk/REGameObject.hpp"
"shared/sdk/REGlobals.hpp"
"shared/sdk/REManagedObject.hpp"
"shared/sdk/REMath.hpp"
Expand Down Expand Up @@ -7813,6 +7827,7 @@ if(REF_BUILD_RE8_SDK OR REF_BUILD_FRAMEWORK) # build-re8-sdk
"shared/sdk/MurmurHash.cpp"
"shared/sdk/REArray.cpp"
"shared/sdk/REContext.cpp"
"shared/sdk/REGameObject.cpp"
"shared/sdk/REGlobals.cpp"
"shared/sdk/REManagedObject.cpp"
"shared/sdk/RETransform.cpp"
Expand Down Expand Up @@ -7842,6 +7857,7 @@ if(REF_BUILD_RE8_SDK OR REF_BUILD_FRAMEWORK) # build-re8-sdk
"shared/sdk/REArray.hpp"
"shared/sdk/REComponent.hpp"
"shared/sdk/REContext.hpp"
"shared/sdk/REGameObject.hpp"
"shared/sdk/REGlobals.hpp"
"shared/sdk/REManagedObject.hpp"
"shared/sdk/REMath.hpp"
Expand Down Expand Up @@ -8851,6 +8867,7 @@ if(REF_BUILD_DMC5_SDK OR REF_BUILD_FRAMEWORK) # build-dmc5-sdk
"shared/sdk/MurmurHash.cpp"
"shared/sdk/REArray.cpp"
"shared/sdk/REContext.cpp"
"shared/sdk/REGameObject.cpp"
"shared/sdk/REGlobals.cpp"
"shared/sdk/REManagedObject.cpp"
"shared/sdk/RETransform.cpp"
Expand Down Expand Up @@ -8880,6 +8897,7 @@ if(REF_BUILD_DMC5_SDK OR REF_BUILD_FRAMEWORK) # build-dmc5-sdk
"shared/sdk/REArray.hpp"
"shared/sdk/REComponent.hpp"
"shared/sdk/REContext.hpp"
"shared/sdk/REGameObject.hpp"
"shared/sdk/REGlobals.hpp"
"shared/sdk/REManagedObject.hpp"
"shared/sdk/REMath.hpp"
Expand Down Expand Up @@ -9887,6 +9905,7 @@ if(REF_BUILD_MHRISE_SDK OR REF_BUILD_FRAMEWORK) # build-mhrise-sdk
"shared/sdk/MurmurHash.cpp"
"shared/sdk/REArray.cpp"
"shared/sdk/REContext.cpp"
"shared/sdk/REGameObject.cpp"
"shared/sdk/REGlobals.cpp"
"shared/sdk/REManagedObject.cpp"
"shared/sdk/RETransform.cpp"
Expand Down Expand Up @@ -9916,6 +9935,7 @@ if(REF_BUILD_MHRISE_SDK OR REF_BUILD_FRAMEWORK) # build-mhrise-sdk
"shared/sdk/REArray.hpp"
"shared/sdk/REComponent.hpp"
"shared/sdk/REContext.hpp"
"shared/sdk/REGameObject.hpp"
"shared/sdk/REGlobals.hpp"
"shared/sdk/REManagedObject.hpp"
"shared/sdk/REMath.hpp"
Expand Down Expand Up @@ -10925,6 +10945,7 @@ if(REF_BUILD_SF6_SDK OR REF_BUILD_FRAMEWORK) # build-sf6-sdk
"shared/sdk/MurmurHash.cpp"
"shared/sdk/REArray.cpp"
"shared/sdk/REContext.cpp"
"shared/sdk/REGameObject.cpp"
"shared/sdk/REGlobals.cpp"
"shared/sdk/REManagedObject.cpp"
"shared/sdk/RETransform.cpp"
Expand Down Expand Up @@ -10954,6 +10975,7 @@ if(REF_BUILD_SF6_SDK OR REF_BUILD_FRAMEWORK) # build-sf6-sdk
"shared/sdk/REArray.hpp"
"shared/sdk/REComponent.hpp"
"shared/sdk/REContext.hpp"
"shared/sdk/REGameObject.hpp"
"shared/sdk/REGlobals.hpp"
"shared/sdk/REManagedObject.hpp"
"shared/sdk/REMath.hpp"
Expand Down Expand Up @@ -11963,6 +11985,7 @@ if(REF_BUILD_DD2_SDK OR REF_BUILD_FRAMEWORK) # build-dd2-sdk
"shared/sdk/MurmurHash.cpp"
"shared/sdk/REArray.cpp"
"shared/sdk/REContext.cpp"
"shared/sdk/REGameObject.cpp"
"shared/sdk/REGlobals.cpp"
"shared/sdk/REManagedObject.cpp"
"shared/sdk/RETransform.cpp"
Expand Down Expand Up @@ -11992,6 +12015,7 @@ if(REF_BUILD_DD2_SDK OR REF_BUILD_FRAMEWORK) # build-dd2-sdk
"shared/sdk/REArray.hpp"
"shared/sdk/REComponent.hpp"
"shared/sdk/REContext.hpp"
"shared/sdk/REGameObject.hpp"
"shared/sdk/REGlobals.hpp"
"shared/sdk/REManagedObject.hpp"
"shared/sdk/REMath.hpp"
Expand Down
30 changes: 30 additions & 0 deletions shared/sdk/REGameObject.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include "RETypeDB.hpp"

#include "REGameObject.hpp"

namespace utility::re_game_object {
std::string get_name(REGameObject* obj) {
if (obj == nullptr) {
return {};
}

// Only doing this on newer versions where we know it works
// Haven't tested it on older versions so just to be safe.
#if TDB_VER >= 71
static const auto game_object_t = sdk::find_type_definition("via.GameObject");
static const auto get_name_fn = game_object_t != nullptr ? game_object_t->get_method("get_Name") : nullptr;

if (get_name_fn != nullptr) {
auto str = get_name_fn->call<::SystemString*>(sdk::get_thread_context(), obj);

if (str != nullptr) {
return utility::re_string::get_string(str);
}
}
#endif

// We rely on the reflected function first because
// this offset might change between versions.
return utility::re_string::get_string(obj->name);
}
}
9 changes: 9 additions & 0 deletions shared/sdk/REGameObject.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once

#include "REManagedObject.hpp"

namespace utility {
namespace re_game_object {
std::string get_name(::REGameObject* obj);
}
}
3 changes: 2 additions & 1 deletion src/mods/Graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <sdk/MurmurHash.hpp>
#include <sdk/Renderer.hpp>
#include <sdk/resources/ShaderResource.hpp>
#include <sdk/REGameObject.hpp>

#include "VR.hpp"
#include "Graphics.hpp"
Expand Down Expand Up @@ -483,7 +484,7 @@ bool Graphics::on_pre_gui_draw_element(REComponent* gui_element, void* primitive
}
}

const auto name = utility::re_string::get_string(game_object->name);
const auto name = utility::re_game_object::get_name(game_object);
const auto name_hash = utility::hash(name);

switch(name_hash) {
Expand Down
3 changes: 2 additions & 1 deletion src/mods/VR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "sdk/Application.hpp"
#include "sdk/Renderer.hpp"
#include "sdk/REMath.hpp"
#include "sdk/REGameObject.hpp"

#include "utility/Scan.hpp"
#include "utility/FunctionHook.hpp"
Expand Down Expand Up @@ -2363,7 +2364,7 @@ bool VR::on_pre_gui_draw_element(REComponent* gui_element, void* primitive_conte
if (game_object != nullptr && game_object->transform != nullptr) {
auto context = sdk::get_thread_context();

const auto name = utility::re_string::get_string(game_object->name);
const auto name = utility::re_game_object::get_name(game_object);
const auto name_hash = utility::hash(name);

switch (name_hash) {
Expand Down
3 changes: 2 additions & 1 deletion src/mods/tools/ChainViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "sdk/RETypeDB.hpp"
#include "sdk/REManagedObject.hpp"
#include "sdk/Renderer.hpp"
#include "sdk/REGameObject.hpp"

#if TDB_VER < 69
#include "sdk/regenny/re3/via/motion/Chain.hpp"
Expand Down Expand Up @@ -182,7 +183,7 @@ void ChainViewer::on_frame() {
return;
}

auto owner_name = utility::re_string::get_string(owner->name);
auto owner_name = utility::re_game_object::get_name(owner);

if (owner_name.empty()) {
owner_name = "";
Expand Down
3 changes: 2 additions & 1 deletion src/mods/tools/GameObjectsDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "sdk/SceneManager.hpp"
#include "sdk/RETypeDB.hpp"
#include "sdk/REManagedObject.hpp"
#include "sdk/REGameObject.hpp"

#include "GameObjectsDisplay.hpp"

Expand Down Expand Up @@ -130,7 +131,7 @@ void GameObjectsDisplay::on_frame() {
continue;
}

auto owner_name = utility::re_string::get_string(owner->name);
auto owner_name = utility::re_game_object::get_name(owner);

if (owner_name.empty()) {
continue;
Expand Down
11 changes: 7 additions & 4 deletions src/mods/tools/ObjectExplorer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "Genny.hpp"
#include "GennyIda.hpp"

#include <sdk/REGameObject.hpp>
#include "REFramework.hpp"
#include "ObjectExplorer.hpp"

Expand Down Expand Up @@ -2290,7 +2291,7 @@ void ObjectExplorer::handle_address(Address address, int32_t offset, Address par
context_menu(real_address);

if (is_game_object) {
additional_text = utility::re_string::get_string(address.as<REGameObject*>()->name);
additional_text = utility::re_game_object::get_name(address.as<REGameObject*>());
}
else {
// Change name based on VMType
Expand Down Expand Up @@ -2508,7 +2509,9 @@ void ObjectExplorer::handle_game_object(REGameObject* game_object) {
m_add_component_name.reserve(256);
}

ImGui::Text("Name: %s", utility::re_string::get_string(game_object->name).c_str());
auto game_object_name = utility::re_game_object::get_name(game_object);

ImGui::Text("Name: %s", game_object_name.c_str());
make_tree_offset(game_object, offsetof(REGameObject, transform), "Transform");
make_tree_offset(game_object, offsetof(REGameObject, folder), "Folder");

Expand All @@ -2519,7 +2522,7 @@ void ObjectExplorer::handle_component(REComponent* component) {
auto display_component_preview = [&](REComponent* comp) {
if (comp != nullptr && comp->ownerGameObject != nullptr) {
auto prev_name = utility::re_managed_object::get_type_name(comp);
auto prev_gameobject_name = utility::re_string::get_string(comp->ownerGameObject->name);
auto prev_gameobject_name = utility::re_game_object::get_name(comp->ownerGameObject);

auto tree_hovered = ImGui::IsItemHovered();

Expand Down Expand Up @@ -4052,7 +4055,7 @@ void ObjectExplorer::context_menu(void* address, std::optional<std::string> name
}
else {
auto owner = obj->ownerGameObject;
spdlog::info("[{:s}] {:s} ({:x})", utility::re_string::get_string(owner->name), t->name, (uintptr_t)obj);
spdlog::info("[{:s}] {:s} ({:x})", utility::re_game_object::get_name(owner), t->name, (uintptr_t)obj);
}
}

Expand Down

0 comments on commit f02df96

Please sign in to comment.