Skip to content

Commit

Permalink
Add RE3 support
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Mar 20, 2020
1 parent 6d179aa commit f9fc29f
Show file tree
Hide file tree
Showing 14 changed files with 3,112 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
build64/
build64_re3
6 changes: 6 additions & 0 deletions build_vs2017.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,10 @@ git submodule update --init --recursive
mkdir build64
cd build64
cmake .. -G "Visual Studio 15 2017 Win64" -DDEVELOPER_MODE=OFF
cmake --build . --config Release

cd ..
mkdir build64_re3
cd build64_re3
cmake .. -G "Visual Studio 15 2017 Win64" -DDEVELOPER_MODE=OFF -DRE3=ON
cmake --build . --config Release
6 changes: 6 additions & 0 deletions build_vs2017_devmode.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,10 @@ git submodule update --init --recursive
mkdir build64
cd build64
cmake .. -G "Visual Studio 15 2017 Win64" -DDEVELOPER_MODE=ON
cmake --build . --config Release

cd ..
mkdir build64_re3
cd build64_re3
cmake .. -G "Visual Studio 15 2017 Win64" -DDEVELOPER_MODE=ON -DRE3=ON
cmake --build . --config Release
6 changes: 6 additions & 0 deletions build_vs2019.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,10 @@ git submodule update --init --recursive
mkdir build64
cd build64
cmake .. -G "Visual Studio 16 2019" -A x64 -DDEVELOPER_MODE=OFF
cmake --build . --config Release

cd ..
mkdir build64_re3
cd build64_re3
cmake .. -G "Visual Studio 16 2019" -A x64 -DDEVELOPER_MODE=OFF -DRE3=ON
cmake --build . --config Release
12 changes: 12 additions & 0 deletions build_vs2019_devmode.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
git pull --recurse-submodules
git submodule update --init --recursive
mkdir build64
cd build64
cmake .. -G "Visual Studio 16 2019" -A x64 -DDEVELOPER_MODE=ON
cmake --build . --config Release

cd ..
mkdir build64_re3
cd build64_re3
cmake .. -G "Visual Studio 16 2019" -A x64 -DDEVELOPER_MODE=ON -DRE3=ON
cmake --build . --config Release
10 changes: 8 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ set(MODS_SRC
set(SDK_SRC
sdk/ReClass.hpp
sdk/ReClass_Internal.hpp
sdk/ReClass_Internal_RE3.hpp
sdk/Enums_Internal.hpp

sdk/REArray.hpp
Expand Down Expand Up @@ -103,8 +104,13 @@ include_directories(RE2 ${CMAKE_CURRENT_SOURCE_DIR})
set_target_properties(RE2 PROPERTIES OUTPUT_NAME dinput8)

option(DEVELOPER_MODE "Adds DeveloperTools option to menu" OFF)
option(RE3 "RE3 build" OFF)

if(DEVELOPER_MODE)
target_compile_definitions(RE2 PUBLIC DEVELOPER)
target_compile_options(RE2 PUBLIC /EHa)
target_compile_definitions(RE2 PUBLIC DEVELOPER)
target_compile_options(RE2 PUBLIC /EHa)
endif()

if (RE3)
target_compile_definitions(RE2 PUBLIC RE3)
endif()
24 changes: 20 additions & 4 deletions src/FirstPerson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ FirstPerson::FirstPerson() {
g_first_person = this;
m_attach_bone_imgui.reserve(256);

#ifdef RE3
// Jill (it looks better with 0?)
m_attach_offsets["pl2000"] = Vector4f{ 0.0f, 0.0f, 0.0f, 0.0f };
//m_attach_offsets["pl2000"] = Vector4f{ -0.23f, 0.4f, 1.0f, 0.0f };
#else
// Specific player model configs
// Leon
m_attach_offsets["pl0000"] = Vector4f{ -0.26f, 0.435f, 1.0f, 0.0f };
Expand All @@ -30,6 +35,7 @@ FirstPerson::FirstPerson() {
m_attach_offsets["pl5600"] = Vector4f{ -0.316, 0.556f, 1.02f, 0.0f };
// Elizabeth
m_attach_offsets["pl6400"] = Vector4f{ -0.316, 0.466f, 0.79f, 0.0f };
#endif
}

std::optional<std::string> FirstPerson::on_initialize() {
Expand Down Expand Up @@ -59,9 +65,9 @@ void FirstPerson::on_frame() {
m_camera_system == nullptr || m_camera_system->ownerGameObject == nullptr || m_sweet_light_manager == nullptr || m_sweet_light_manager->ownerGameObject == nullptr)
{
auto& globals = *g_framework->get_globals();
m_sweet_light_manager = globals.get<RopewaySweetLightManager>("app.ropeway.SweetLightManager");
m_camera_system = globals.get<RopewayCameraSystem>("app.ropeway.camera.CameraSystem");
m_post_effect_controller = globals.get<RopewayPostEffectController>("app.ropeway.posteffect.PostEffectController");
m_sweet_light_manager = globals.get<RopewaySweetLightManager>(game_namespace("SweetLightManager"));
m_camera_system = globals.get<RopewayCameraSystem>(game_namespace("camera.CameraSystem"));
m_post_effect_controller = globals.get<RopewayPostEffectController>(game_namespace("posteffect.PostEffectController"));

reset();
return;
Expand Down Expand Up @@ -249,6 +255,16 @@ void FirstPerson::on_update_camera_controller(RopewayPlayerCameraController* con
return;
}

#ifdef RE3
// Just update the FOV in here. Whatever.
update_fov(controller);

// Save the original position and rotation before our modifications.
// If we don't, the camera rotation will freeze up, because it keeps getting overwritten.
m_last_controller_pos = controller->worldPosition;
m_last_controller_rotation = *(glm::quat*)&controller->worldRotation;
#endif

// The following code fixes inaccuracies between the rotation set by the game and what's set in updateCameraTransform
controller->worldPosition = m_last_camera_matrix[3];
*(glm::quat*)&controller->worldRotation = glm::quat{ m_last_camera_matrix };
Expand Down Expand Up @@ -286,7 +302,7 @@ void FirstPerson::reset() {
void FirstPerson::set_vignette(via::render::ToneMapping::Vignetting value) {
// Assign tone mapping controller
if (m_tone_mapping_controller == nullptr && m_post_effect_controller != nullptr) {
m_tone_mapping_controller = utility::re_component::find<RopewayPostEffectControllerBase>(m_post_effect_controller, "app.ropeway.posteffect.ToneMapController");
m_tone_mapping_controller = utility::re_component::find<RopewayPostEffectControllerBase>(m_post_effect_controller, game_namespace("posteffect.ToneMapController"));
}

if (m_tone_mapping_controller == nullptr) {
Expand Down
6 changes: 3 additions & 3 deletions src/FreeCam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ void FreeCam::on_update_transform(RETransform* transform) {
bool FreeCam::update_pointers() {
if (m_camera_system == nullptr || m_input_system == nullptr || m_survivor_manager == nullptr) {
auto& globals = *g_framework->get_globals();
m_camera_system = globals.get<RopewayCameraSystem>("app.ropeway.camera.CameraSystem");
m_input_system = globals.get<RopewayInputSystem>("app.ropeway.InputSystem");
m_survivor_manager = globals.get<RopewaySurvivorManager>("app.ropeway.SurvivorManager");
m_camera_system = globals.get<RopewayCameraSystem>(game_namespace("camera.CameraSystem"));
m_input_system = globals.get<RopewayInputSystem>(game_namespace("InputSystem"));
m_survivor_manager = globals.get<RopewaySurvivorManager>(game_namespace("SurvivorManager"));
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/ManualFlashlight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void ManualFlashlight::on_update_transform(RETransform* transform) {
}

if (m_illumination_manager == nullptr) {
m_illumination_manager = g_framework->get_globals()->get<RopewayIlluminationManager>("app.ropeway.IlluminationManager");
m_illumination_manager = g_framework->get_globals()->get<RopewayIlluminationManager>(game_namespace("IlluminationManager"));
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/sdk/REGlobals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void REGlobals::refresh_map() {

if (m_acknowledged_objects.find(obj_ptr) == m_acknowledged_objects.end()) {
#ifdef DEVELOPER
spdlog::info("{:x}->{:x} ({:s})", (uintptr_t)objPtr, (uintptr_t)*objPtr, t->name);
spdlog::info("{:x}->{:x} ({:s})", (uintptr_t)obj_ptr, (uintptr_t)*obj_ptr, t->name);
#endif
m_acknowledged_objects.insert(obj_ptr);
}
Expand Down
13 changes: 11 additions & 2 deletions src/sdk/RETypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,23 @@
#include "REFramework.hpp"
#include "RETypes.hpp"

std::string game_namespace(std::string_view base_name)
{
#ifdef RE3
return std::string{ "offline." } + base_name.data();
#else
return std::string{ "app.ropeway." } + base_name.data();
#endif
}

RETypes::RETypes() {
spdlog::info("RETypes initialization");

auto mod = g_framework->get_module().as<HMODULE>();
auto ref = utility::scan(mod, "48 8d 0d ? ? ? ? e8 ? ? ? ? 48 8d 05 ? ? ? ? 48 89 03");

spdlog::info("Ref: {:x}", (uintptr_t)*ref);

//
m_raw_types = (TypeList*)(utility::calculate_absolute(*ref + 3));
spdlog::info("TypeList: {:x}", (uintptr_t)m_raw_types);

Expand All @@ -26,7 +35,7 @@ RETypes::RETypes() {
if (t == nullptr || IsBadReadPtr(t, sizeof(REType)) || ((uintptr_t)t & (sizeof(void*) - 1)) != 0) {
continue;
}

//
if (t->name == nullptr) {
continue;
}
Expand Down
2 changes: 2 additions & 0 deletions src/sdk/RETypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include "ReClass.hpp"

std::string game_namespace(std::string_view base_name);

// A list of types in the RE engine
class RETypes {
public:
Expand Down
6 changes: 5 additions & 1 deletion src/sdk/ReClass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
#include "Math.hpp"

#pragma pack(push, r1, 1)
#ifdef RE3
#include "ReClass_Internal_RE3.hpp"
#else
#include "ReClass_Internal.hpp"
#endif
#pragma pack(pop, r1)

#include "Enums_Internal.hpp"
Expand All @@ -17,4 +21,4 @@
#include "RETransform.hpp"
#include "REComponent.hpp"
#include "RopewaySweetLightManager.hpp"
#include "REGlobals.hpp"
#include "REGlobals.hpp"
Loading

0 comments on commit f9fc29f

Please sign in to comment.