diff options
author | davidebeatrici <davidebeatrici@gmail.com> | 2018-03-16 01:04:57 +0300 |
---|---|---|
committer | davidebeatrici <davidebeatrici@gmail.com> | 2018-03-16 01:05:08 +0300 |
commit | ebb79eec97ea6cd1e7f6ffd2a59c68312d25fb8f (patch) | |
tree | 43ecf4265c00a3013fb89f518ba10879a9d1af3c /plugins | |
parent | b230c2852b3b913b89c12033eb0cf23d138a1ac9 (diff) |
plugins/rl: single source file for both Linux and Windows
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/rl/rl.cpp (renamed from plugins/rl/rl_win32.cpp) | 47 | ||||
-rw-r--r-- | plugins/rl/rl.pro | 10 | ||||
-rw-r--r-- | plugins/rl/rl_linux.cpp | 100 |
3 files changed, 43 insertions, 114 deletions
diff --git a/plugins/rl/rl_win32.cpp b/plugins/rl/rl.cpp index f576c2a28..cd9099075 100644 --- a/plugins/rl/rl_win32.cpp +++ b/plugins/rl/rl.cpp @@ -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++) @@ -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); @@ -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) @@ -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 diff --git a/plugins/rl/rl.pro b/plugins/rl/rl.pro index 504852a6d..595e3de03 100644 --- a/plugins/rl/rl.pro +++ b/plugins/rl/rl.pro @@ -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 diff --git a/plugins/rl/rl_linux.cpp b/plugins/rl/rl_linux.cpp deleted file mode 100644 index 6c212b1e7..000000000 --- a/plugins/rl/rl_linux.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright 2005-2018 The Mumble Developers. All rights reserved. -// Use of this source code is governed by a BSD-style license -// that can be found in the LICENSE file at the root of the -// Mumble source tree or at <https://www.mumble.info/LICENSE>. - -#include "../mumble_plugin_linux.h" - -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++) - avatar_pos[i]=avatar_front[i]=avatar_top[i]=camera_pos[i]=camera_front[i]=camera_top[i]=0.0f; - - // Boolean value to check if game addresses retrieval is successful - bool ok; - - // Avatar pointers - 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; - - // Peekproc and assign game addresses to our containers, so we can retrieve positional data - ok = peekProc(avatar_offset + 0x60, avatar_pos, 12) && // Avatar Position values (X, Y and Z). - peekProc(pModule + 0x302AAB8, camera_pos, 12) && // Camera Position values (X, Y and Z). - peekProc(avatar_offset + 0x6C, avatar_front, 12) && // Avatar Front values (X, Y and Z). - peekProc(pModule + 0x302AAA0, camera_front, 12) && // Camera Front Vector values (X, Y and Z). - peekProc(pModule + 0x302AAAC, 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) - return false; - - avatar_top[2] = -1; // This tells Mumble to automatically calculate top vector using front vector. - - // Scale from centimeters to meters - for (int i=0;i<3;i++) { - avatar_pos[i]/=100.0f; - camera_pos[i]/=100.0f; - } - - return true; -} - -static int trylock(const std::multimap<std::wstring, unsigned long long int> &pids) { - - if (! initialize(pids, L"RocketLeague")) // Link the game executable - return false; - - // Check if we can get meaningful data from it - float apos[3], afront[3], atop[3], cpos[3], cfront[3], ctop[3]; - std::wstring sidentity; - std::string scontext; - - if (fetch(apos, afront, atop, cpos, cfront, ctop, scontext, sidentity)) { - return true; - } else { - generic_unlock(); - return false; - } -} - -static const std::wstring longdesc() { - return std::wstring(L"Supports Rocket League version 1.29 without context or identity support yet."); // Plugin long description -} - -static std::wstring description(L"Rocket League (v1.29)"); // Plugin short description -static std::wstring shortname(L"Rocket League"); // Plugin short name - -static int trylock1() { - return trylock(std::multimap<std::wstring, unsigned long long int>()); -} - -static MumblePlugin rlplug = { - MUMBLE_PLUGIN_MAGIC, - description, - shortname, - NULL, - NULL, - trylock1, - generic_unlock, - longdesc, - fetch -}; - -static MumblePlugin2 rlplug2 = { - MUMBLE_PLUGIN_MAGIC_2, - MUMBLE_PLUGIN_VERSION, - trylock -}; - -extern "C" MUMBLE_PLUGIN_EXPORT MumblePlugin *getMumblePlugin() { - return &rlplug; -} - -extern "C" MUMBLE_PLUGIN_EXPORT MumblePlugin2 *getMumblePlugin2() { - return &rlplug2; -} |