Skip to content

Commit 985faf7

Browse files
authored
Merge branch 'praydog:master' into master
2 parents 17d0c7b + 9e3b6b4 commit 985faf7

14 files changed

Lines changed: 1457 additions & 36 deletions

.github/workflows/build-pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: windows-latest
88
strategy:
99
matrix:
10-
target: [RE2, RE2_TDB66, RE3, RE3_TDB67, RE4, RE7, RE7_TDB49, RE8, RE9, DMC5, MHRISE, SF6, DD2, MHWILDS, PRAGMATA, MHSTORIES3]
10+
target: [RE2, RE2_TDB66, RE3, RE3_TDB67, RE4, RE7, RE7_TDB49, RE8, RE9, DMC5, MHRISE, SF6, DD2, MHWILDS, PRAGMATA, MHSTORIES3, STARFORCE]
1111
steps:
1212
- name: Checkout
1313
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683

.github/workflows/dev-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
runs-on: windows-latest
4646
strategy:
4747
matrix:
48-
target: [RE2, RE2_TDB66, RE3, RE3_TDB67, RE4, RE7, RE7_TDB49, RE8, RE9, DMC5, MHRISE, SF6, DD2, MHWILDS, PRAGMATA, MHSTORIES3]
48+
target: [RE2, RE2_TDB66, RE3, RE3_TDB67, RE4, RE7, RE7_TDB49, RE8, RE9, DMC5, MHRISE, SF6, DD2, MHWILDS, PRAGMATA, MHSTORIES3, STARFORCE]
4949
steps:
5050
- name: Checkout
5151
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683

CMakeLists.txt

Lines changed: 1166 additions & 0 deletions
Large diffs are not rendered by default.

cmake.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ REF_BUILD_SF6_SDK = false
6363
REF_BUILD_DD2_SDK = false
6464
REF_BUILD_MHWILDS_SDK = false
6565
REF_BUILD_MHSTORIES3_SDK = false
66+
REF_BUILD_STARFORCE_SDK = false
6667
REF_BUILD_RE9_SDK = false
6768
REF_BUILD_PRAGMATA_SDK = false
6869
REF_BUILD_FRAMEWORK = { value = true }
@@ -85,6 +86,7 @@ build-sf6-sdk = "REF_BUILD_SF6_SDK OR REF_BUILD_FRAMEWORK"
8586
build-dd2-sdk = "REF_BUILD_DD2_SDK OR REF_BUILD_FRAMEWORK"
8687
build-mhwilds-sdk = "REF_BUILD_MHWILDS_SDK OR REF_BUILD_FRAMEWORK"
8788
build-mhstories3-sdk = "REF_BUILD_MHSTORIES3_SDK OR REF_BUILD_FRAMEWORK"
89+
build-starforce-sdk = "REF_BUILD_STARFORCE_SDK OR REF_BUILD_FRAMEWORK"
8890
build-re9-sdk = "REF_BUILD_RE9_SDK OR REF_BUILD_FRAMEWORK"
8991
build-pragmata-sdk = "REF_BUILD_PRAGMATA_SDK OR REF_BUILD_FRAMEWORK"
9092
build-framework-dependencies = "REF_BUILD_DEPENDENCIES AND CMAKE_SIZEOF_VOID_P EQUAL 8"
@@ -406,6 +408,14 @@ condition = "build-mhstories3-sdk"
406408
[target.MHSTORIES3]
407409
type = "game"
408410

411+
[target.STARFORCESDK]
412+
type = "sdk"
413+
compile-definitions = ["STARFORCE", "REENGINE_PACKED", "REENGINE_AT"]
414+
condition = "build-starforce-sdk"
415+
416+
[target.STARFORCE]
417+
type = "game"
418+
409419
[target.RE9SDK]
410420
type = "sdk"
411421
compile-definitions = ["RE9", "REENGINE_PACKED", "REENGINE_AT"]

shared/sdk/REGlobals.cpp

Lines changed: 67 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,22 @@ REGlobals::REGlobals() {
6666
}
6767

6868
// Create a list of getter functions instead
69-
if (m_objects.empty()) {
69+
if (m_objects.empty() || TDB_VER >= 78) {
7070
spdlog::info("Usual pattern for REGlobals not working, falling back to scanning for SingletonBehavior types");
7171

7272
auto& types = reframework::get_types();
7373
auto& type_list = types->get_types();
7474

7575
size_t i = 0;
7676

77-
for (auto t : type_list) {
77+
for (auto t : type_list) try {
7878
auto name = std::string{t->name};
7979

8080
if (name.find(game_namespace("SingletonBehavior`1")) != std::string::npos ||
8181
name.find(game_namespace("SingletonBehaviorRoot`1")) != std::string::npos ||
8282
name.find(game_namespace("SnowSingletonBehaviorRoot`1")) != std::string::npos ||
83-
name.find(game_namespace("RopewaySingletonBehaviorRoot`1")) != std::string::npos)
83+
name.find(game_namespace("RopewaySingletonBehaviorRoot`1")) != std::string::npos ||
84+
name.find(game_namespace("ace.GAElement`1")) != std::string::npos)
8485
{
8586
const auto type_definition = utility::re_type::get_type_definition(t);
8687

@@ -89,6 +90,8 @@ REGlobals::REGlobals() {
8990
continue;
9091
}
9192

93+
spdlog::info("Found singleton type: {}", name);
94+
9295
//using asdf = decltype(m_getters)::value_type::second_type::_Func_class;
9396
using Getter = REManagedObject* (*)();
9497
auto getter = (Getter)sdk::find_native_method(type_definition, "get_Instance");
@@ -106,6 +109,61 @@ REGlobals::REGlobals() {
106109

107110
m_getters[type_name] = getter;
108111
}
112+
} catch(...) {
113+
continue;
114+
}
115+
}
116+
117+
// lets just go through the tdb types
118+
if (m_objects.empty() || TDB_VER >= 78) {
119+
auto tdb = sdk::RETypeDB::get();
120+
121+
for (size_t i = 0; i < tdb->get_num_types(); ++i) try {
122+
auto type_definition = tdb->get_type(i);
123+
124+
if (type_definition == nullptr || type_definition->get_name() == nullptr) {
125+
continue;
126+
}
127+
128+
auto high_name = std::string_view{ type_definition->get_name() };
129+
130+
for (auto super = type_definition; super != nullptr; super = super->get_parent_type()) {
131+
auto name = std::string_view{ super->get_name() };
132+
133+
if (name.find("SingletonBehavior`1") != std::string::npos ||
134+
name.find("SingletonBehaviorRoot`1") != std::string::npos ||
135+
name.find("SnowSingletonBehaviorRoot`1") != std::string::npos ||
136+
name.find("RopewaySingletonBehaviorRoot`1") != std::string::npos ||
137+
name.find("GAElement`1") != std::string::npos ||
138+
name.find("AppSingleton`1") != std::string::npos)
139+
{
140+
if (high_name == name) {
141+
continue; // dont care.
142+
}
143+
144+
auto full_name = super->get_full_name();
145+
146+
spdlog::info("Found singleton type: {}", high_name.data());
147+
148+
using Getter = REManagedObject* (*)();
149+
auto getter = (Getter)sdk::find_native_method(type_definition, "get_Instance");
150+
151+
if (getter == nullptr) {
152+
spdlog::warn("Failed to find get_Instance method for {}", high_name.data());
153+
continue;
154+
}
155+
156+
// Get the contained type by grabbing the string between the "`1<"" and the ">""
157+
auto type_name = std::string{full_name}.substr(full_name.find("`1<") + 3, full_name.find(">") - full_name.find("`1<") - 3);
158+
159+
spdlog::info("{}", type_name);
160+
161+
m_getters[type_name] = getter;
162+
break;
163+
}
164+
}
165+
} catch(...) {
166+
continue;
109167
}
110168
}
111169

@@ -124,13 +182,13 @@ std::unordered_set<REManagedObject*> REGlobals::get_objects() {
124182
out.insert(*obj_ptr);
125183
}
126184
}
127-
} else {
128-
for (auto getter : m_getters) {
129-
auto result = getter.second();
185+
}
130186

131-
if (result != nullptr) {
132-
out.insert(result);
133-
}
187+
for (auto getter : m_getters) {
188+
auto result = getter.second();
189+
190+
if (result != nullptr) {
191+
out.insert(result);
134192
}
135193
}
136194

shared/sdk/ReClass.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include "ReClass_Internal_MHWILDS.hpp" // Copy of DD2 (for now)
1717
#elif defined(MHSTORIES3)
1818
#include "ReClass_Internal_MHSTORIES3.hpp" // Copy of MHWILDS (for now)
19+
#elif defined(STARFORCE)
20+
#include "ReClass_Internal_MHSTORIES3.hpp" // Copy of MHSTORIES3 (for now)
1921
#elif defined(DD2)
2022
#include "ReClass_Internal_DD2.hpp" // Copy of SF6
2123
#elif defined(SF6)

shared/sdk/Renderer.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,7 @@ void RenderContext::copy_texture(Texture* dest, Texture* src, Fence& fence) {
782782
return;
783783
#else*/
784784

785+
#if TDB_VER < 82
785786
using CopyTexFn = void (*)(RenderContext*, Texture*, Texture*, Fence&);
786787
static auto func = []() -> CopyTexFn {
787788
spdlog::info("Searching for RenderContext::copy_texture");
@@ -866,6 +867,35 @@ void RenderContext::copy_texture(Texture* dest, Texture* src, Fence& fence) {
866867
}();
867868

868869
func(this, dest, src, fence);
870+
#else
871+
using CopyTexFn = void (*)(RenderContext*, Texture*, int32_t, Texture*, int32_t, Fence&);
872+
static auto func = []() -> CopyTexFn {
873+
spdlog::info("Searching for RenderContext::copy_texture (>= TDB82)");
874+
875+
const auto game = utility::get_executable();
876+
// constants 0x301 (the typeid 1 or'd with something) 0x36, 0x3f, 0x2a.
877+
const auto mid_result = utility::scan(game, "01 03 00 00 *[64] 36 *[32] 3f *[32] 2a");
878+
879+
if (!mid_result) {
880+
spdlog::error("Failed to find copy_texture (>= TDB82)");
881+
return nullptr;
882+
}
883+
884+
const auto fn_start = utility::find_function_start_unwind(*mid_result);
885+
886+
if (!fn_start) {
887+
spdlog::error("Failed to find copy_texture function start (>= TDB82)");
888+
return nullptr;
889+
}
890+
891+
spdlog::info("Found copy_texture (>= TDB82) at {:x}", *fn_start);
892+
893+
return (CopyTexFn)*fn_start;
894+
}();
895+
896+
// src, src_subresource, dst, dst_subresource, fence
897+
func(this, src, -1, dest, -1, fence);
898+
#endif
869899
//#endif
870900
}
871901

shared/sdk/TDBVer.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#define TDB_VER 84
77
#elif defined(RE9)
88
#define TDB_VER 83
9+
#elif defined(STARFORCE)
10+
#define TDB_VER 78
911
#elif defined(MHSTORIES3)
1012
#define TDB_VER 82
1113
#elif defined(MHWILDS)
@@ -68,6 +70,10 @@ using RETypeDefinition_ = sdk::RETypeDefVersion84;
6870
#define TYPE_INDEX_BITS 19
6971
#define FIELD_BITS 20
7072
using RETypeDefinition_ = sdk::RETypeDefVersion83;
73+
#elif defined(STARFORCE)
74+
#define TYPE_INDEX_BITS 19
75+
#define FIELD_BITS 19
76+
using RETypeDefinition_ = sdk::RETypeDefVersion74;
7177
#elif defined(MHSTORIES3)
7278
#define TYPE_INDEX_BITS 19
7379
#define FIELD_BITS 20

src/Mods.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Mods::Mods() {
3535
m_mods.emplace_back(Hooks::get());
3636
m_mods.emplace_back(LooseFileLoader::get());
3737

38-
#if defined(MHWILDS)
38+
#if TDB_VER >= 81
3939
m_mods.emplace_back(FaultyFileDetector::get());
4040
#endif
4141

src/REFramework.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ REFramework::REFramework(HMODULE reframework_module)
504504
startup_lookup_thread->detach();
505505
#endif
506506

507-
#if defined(MHWILDS)
507+
#if TDB_VER >= 81
508508
FaultyFileDetector::early_init();
509509
#endif
510510

0 commit comments

Comments
 (0)