Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge PR #3372: plugins/rl: single source file for both Linux and Win…
…dows
  • Loading branch information
davidebeatrici committed Mar 15, 2018
2 parents b230c28 + ebb79ee commit 208ff15
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 114 deletions.
47 changes: 41 additions & 6 deletions plugins/rl/rl_win32.cpp → plugins/rl/rl.cpp
Expand Up @@ -3,7 +3,31 @@
// that can be found in the LICENSE file at the root of the
// Mumble source tree or at <https://www.mumble.info/LICENSE>.

#ifdef WIN32
#include "../mumble_plugin_win32.h"
#else
#include "../mumble_plugin_linux.h"
#endif

#ifdef WIN32
// Memory offsets
const procptr_t camera_pos_offset = 0x17428D8;
const procptr_t camera_front_offset = 0x17428C0;
const procptr_t camera_top_offset = 0x17428CC;
const procptr_t avatar_pos_offset = 0x0;
const procptr_t avatar_front_offset = 0xC;
// Executable name
const wchar_t *exe_name = L"RocketLeague.exe";
#else
// Memory offsets
const procptr_t camera_pos_offset = 0x302AAB8;
const procptr_t camera_front_offset = 0x302AAA0;
const procptr_t camera_top_offset = 0x302AAAC;
const procptr_t avatar_pos_offset = 0x60;
const procptr_t avatar_front_offset = 0x6C;
// Executable name
const wchar_t *exe_name = L"RocketLeague";
#endif

static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, float *camera_pos, float *camera_front, float *camera_top, std::string &, std::wstring &) {
for (int i=0;i<3;i++)
Expand All @@ -13,6 +37,7 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa
bool ok;

// Avatar pointers
#ifdef WIN32
procptr_t avatar_base = peekProcPtr(pModule + 0x174269C);
if (!avatar_base) return false;
procptr_t avatar_offset_0 = peekProcPtr(avatar_base + 0x448);
Expand All @@ -23,13 +48,23 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa
if (!avatar_offset_2) return false;
procptr_t avatar_offset = peekProcPtr(avatar_offset_2 + 0x1C);
if (!avatar_offset) return false;
#else
procptr_t avatar_base = peekProcPtr(pModule + 0x302A4F0);
if (!avatar_base) return false;
procptr_t avatar_offset_0 = peekProcPtr(avatar_base + 0x6c8);
if (!avatar_offset_0) return false;
procptr_t avatar_offset_1 = peekProcPtr(avatar_offset_0 + 0x2b0);
if (!avatar_offset_1) return false;
procptr_t avatar_offset = peekProcPtr(avatar_offset_1 + 0x38);
if (!avatar_offset) return false;
#endif

// Peekproc and assign game addresses to our containers, so we can retrieve positional data
ok = peekProc(avatar_offset + 0x0, avatar_pos, 12) && // Avatar Position values (X, Y and Z).
peekProc(pModule + 0x17428D8, camera_pos, 12) && // Camera Position values (X, Y and Z).
peekProc(avatar_offset + 0xC, avatar_front, 12) && // Avatar Front values (X, Y and Z).
peekProc(pModule + 0x17428C0, camera_front, 12) && // Camera Front Vector values (X, Y and Z).
peekProc(pModule + 0x17428CC, camera_top, 12); // Camera Top Vector values (X, Y and Z).
ok = peekProc(avatar_offset + avatar_pos_offset, avatar_pos, 12) && // Avatar Position values (X, Y and Z).
peekProc(pModule + camera_pos_offset, camera_pos, 12) && // Camera Position values (X, Y and Z).
peekProc(avatar_offset + avatar_front_offset, avatar_front, 12) && // Avatar Front values (X, Y and Z).
peekProc(pModule + camera_front_offset, camera_front, 12) && // Camera Front Vector values (X, Y and Z).
peekProc(pModule + camera_top_offset, camera_top, 12); // Camera Top Vector values (X, Y and Z).

// This prevents the plugin from linking to the game in case something goes wrong during values retrieval from memory addresses.
if (! ok)
Expand All @@ -48,7 +83,7 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa

static int trylock(const std::multimap<std::wstring, unsigned long long int> &pids) {

if (! initialize(pids, L"RocketLeague.exe")) // Link the game executable
if (! initialize(pids, exe_name)) // Link the game executable
return false;

// Check if we can get meaningful data from it
Expand Down
10 changes: 2 additions & 8 deletions plugins/rl/rl.pro
Expand Up @@ -6,12 +6,6 @@
include(../plugins.pri)

TARGET = rl
SOURCES = rl.cpp

win32 {
SOURCES = rl_win32.cpp
LIBS += -luser32
}

linux {
SOURCES = rl_linux.cpp
}
win32:LIBS += -luser32
100 changes: 0 additions & 100 deletions plugins/rl/rl_linux.cpp

This file was deleted.

0 comments on commit 208ff15

Please sign in to comment.