Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverse base methods for traffic handling #55

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions code/client/src/sdk/patterns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,13 @@ namespace SDK {
// C_GameTrafficModule
gPatterns.C_GameTrafficModule__GetInstance = hook::get_opcode_address("E8 ? ? ? ? 80 7E 07 00");

// C_TrafficSpawnManager
gPatterns.C_TrafficSpawnManager__SetTrainDensity = reinterpret_cast<uint64_t>(hook::get_pattern("80 B9 ? ? ? ? ? F3 0F 11 89 ? ? ? ? 74 0C"));

// C_StreamingTrafficModule
gPatterns.C_StreamingTrafficModule__GetInstance = hook::get_opcode_address("E8 ? ? ? ? 4C 8B 44 F3 ?");
gPatterns.C_StreamingTrafficModule__SetMaxHumanElements = reinterpret_cast<uint64_t>(hook::get_pattern("48 83 EC 28 3B 91 ? ? ? ? 74 25"));

// C_Fader
gPatterns.C_Fader__FadeIn = hook::get_opcode_address("E8 ? ? ? ? 48 8B 4D 67 48 8B 9C 24 ? ? ? ?");
gPatterns.C_Fader__FadeOut = hook::get_opcode_address("E8 ? ? ? ? 48 8B 4C 24 ? 0F 28 74 24 ? 48 85 C9 74 1E");
Expand Down
7 changes: 7 additions & 0 deletions code/client/src/sdk/patterns.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,13 @@ namespace SDK {
// C_GameTrafficModule
uint64_t C_GameTrafficModule__GetInstance = 0x0;

// C_TrafficSpawnManager
uint64_t C_TrafficSpawnManager__SetTrainDensity = 0x0;

// C_StreamingTrafficModule
uint64_t C_StreamingTrafficModule__GetInstance = 0x0;
uint64_t C_StreamingTrafficModule__SetMaxHumanElements = 0x0;

// C_Fader
uint64_t C_Fader__FadeIn = 0x0;
uint64_t C_Fader__FadeOut = 0x0;
Expand Down
15 changes: 15 additions & 0 deletions code/client/src/sdk/ue/game/traffic/c_streaming_traffic_module.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "c_streaming_traffic_module.h"

#include "../../../patterns.h"

#include <utils/hooking/hooking.h>

namespace ue::game::traffic {
void C_StreamingTrafficModule::SetMaxHumanElements(int64_t maxHumanElements) {
hook::this_call<void>(gPatterns.C_StreamingTrafficModule__SetMaxHumanElements, this, maxHumanElements);
}

C_StreamingTrafficModule *C_StreamingTrafficModule::GetInstance() {
return hook::this_call<C_StreamingTrafficModule *>(gPatterns.C_StreamingTrafficModule__GetInstance);
}
}
10 changes: 10 additions & 0 deletions code/client/src/sdk/ue/game/traffic/c_streaming_traffic_module.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#pragma once

namespace ue::game::traffic {
class C_StreamingTrafficModule {
public:
void SetMaxHumanElements(int64_t);

static C_StreamingTrafficModule *GetInstance();
}
}
16 changes: 16 additions & 0 deletions code/client/src/sdk/ue/game/traffic/c_traffic_spawn_manager.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "c_traffic_spawn_manager.h"

#include "../../../patterns.h"

#include <utils/hooking/hooking.h>

namespace ue::game::traffic {
void C_TrafficSpawnManager::SetTrainDensity(float density) {
hook::this_call<void>(gPatterns.C_TrafficSpawnManager__SetTrainDensity, this, density);
}

void C_TrafficSpawnManager::SwitchAmbientTraffic(bool enable) {
// TODO: switch to pattern - find the path to the pointer
hook::this_call<void>(0x000000142F0C, this, enable);
}
};
14 changes: 14 additions & 0 deletions code/client/src/sdk/ue/game/traffic/c_traffic_spawn_manager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once

namespace ue::game::traffic {
class C_TrafficSpawnManager {
public:
void SetTrainDensity(float);
void SwitchAmbientTraffic(bool);


static C_TrafficSpawnManager* GetInstance() {
return *(C_TrafficSpawnManager**)0x0000001463DA8F0;
}
};
};