Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert <krzmbrzl@gmail.com>2020-09-11 19:29:33 +0300
committerRobert <krzmbrzl@gmail.com>2020-09-11 19:29:33 +0300
commitaf7dac72f4063dd8d4dac71973ea51c25896089a (patch)
tree35558695aea94d48fd9e77d164d63fd8b7c76e90 /plugins/bf1
parent40b28b03c150b453e00c6bc4f8d6957caea59c51 (diff)
FORMAT: Run clang-format 10 on all C/CXX source-files
Diffstat (limited to 'plugins/bf1')
-rw-r--r--plugins/bf1/bf1.cpp172
1 files changed, 93 insertions, 79 deletions
diff --git a/plugins/bf1/bf1.cpp b/plugins/bf1/bf1.cpp
index 20d9e7a66..5a8fedf60 100644
--- a/plugins/bf1/bf1.cpp
+++ b/plugins/bf1/bf1.cpp
@@ -3,11 +3,12 @@
// 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_main.h" // Include standard plugin header.
+#include "../mumble_plugin_main.h" // Include standard plugin header.
#include "../mumble_plugin_utils.h" // Include plugin header for special functions, like "escape".
-static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, float *camera_pos, float *camera_front, float *camera_top, std::string &context, std::wstring &identity) {
- for (int i=0;i<3;i++) {
+static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, float *camera_pos, float *camera_front,
+ float *camera_top, std::string &context, std::wstring &identity) {
+ 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;
}
@@ -17,84 +18,104 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa
// State pointers
procptr_t state_base = peekProcPtr(pModule + 0x33DBD08);
- if (!state_base) return false;
+ if (!state_base)
+ return false;
procptr_t state_offset_0 = peekProcPtr(state_base + 0x5F0);
- if (!state_offset_0) return false;
+ if (!state_offset_0)
+ return false;
procptr_t state_offset_1 = peekProcPtr(state_offset_0 + 0x488);
- if (!state_offset_1) return false;
+ if (!state_offset_1)
+ return false;
procptr_t state_offset_2 = peekProcPtr(state_offset_1 + 0x8);
- if (!state_offset_2) return false;
+ if (!state_offset_2)
+ return false;
procptr_t state_offset_3 = peekProcPtr(state_offset_2 + 0x8);
- if (!state_offset_3) return false;
+ if (!state_offset_3)
+ return false;
// Camera pointer
procptr_t camera_base = peekProcPtr(pModule + 0x368E828);
- if (!camera_base) return false;
+ if (!camera_base)
+ return false;
// Server name pointers
procptr_t server_name_base = peekProcPtr(pModule + 0x3103A38);
- if (!server_name_base) return false;
+ if (!server_name_base)
+ return false;
procptr_t server_name_offset_0 = peekProcPtr(server_name_base + 0x738);
- if (!server_name_offset_0) return false;
+ if (!server_name_offset_0)
+ return false;
procptr_t server_name_offset_1 = peekProcPtr(server_name_offset_0 + 0x370);
- if (!server_name_offset_1) return false;
+ if (!server_name_offset_1)
+ return false;
procptr_t server_name_offset_2 = peekProcPtr(server_name_offset_1 + 0x10);
- if (!server_name_offset_2) return false;
+ if (!server_name_offset_2)
+ return false;
// Team pointers
procptr_t team_base = peekProcPtr(pModule + 0x36CC128);
- if (!team_base) return false;
+ if (!team_base)
+ return false;
procptr_t team_offset_0 = peekProcPtr(team_base + 0x20);
- if (!team_offset_0) return false;
+ if (!team_offset_0)
+ return false;
procptr_t team_offset_1 = peekProcPtr(team_offset_0 + 0x648);
- if (!team_offset_1) return false;
+ if (!team_offset_1)
+ return false;
procptr_t team_offset_2 = peekProcPtr(team_offset_1 + 0xF8);
- if (!team_offset_2) return false;
+ if (!team_offset_2)
+ return false;
// Squad pointers
procptr_t squad_base = peekProcPtr(pModule + 0x31C3E40);
- if (!squad_base) return false;
+ if (!squad_base)
+ return false;
procptr_t squad_offset_0 = peekProcPtr(squad_base + 0x30);
- if (!squad_offset_0) return false;
+ if (!squad_offset_0)
+ return false;
procptr_t squad_offset_1 = peekProcPtr(squad_offset_0 + 0x578);
- if (!squad_offset_1) return false;
+ if (!squad_offset_1)
+ return false;
procptr_t squad_offset_2 = peekProcPtr(squad_offset_1 + 0xC0);
- if (!squad_offset_2) return false;
+ if (!squad_offset_2)
+ return false;
procptr_t squad_offset_3 = peekProcPtr(squad_offset_2 + 0x58);
- if (!squad_offset_3) return false;
+ if (!squad_offset_3)
+ return false;
// Peekproc and assign game addresses to our containers, so we can retrieve positional data
- // Magical state value: 1 when in-game and 0 when not spawned or playing.
+ // Magical state value: 1 when in-game and 0 when not spawned or playing.
ok = peekProc(state_offset_3 + 0x50, &state, 1)
- // Avatar position values (X, Y and Z).
- && peekProc(pModule + 0x36B1500, avatar_pos, 12)
- // Camera position values (X, Y and Z).
- && peekProc(camera_base + 0x2B0, camera_pos, 12)
- // Avatar front vector values (X, Y and Z).
- && peekProc(camera_base + 0x260, camera_front, 12)
- // Avatar top vector values (X, Y and Z).
- && peekProc(camera_base + 0x250, camera_top, 12)
- // Server name.
- && peekProc(server_name_offset_2, server_name)
- // Team name.
- && peekProc(team_offset_2 + 0x13, team)
- // Squad value: 0 (not in a squad), 1 (Apples), 2 (Butter), 3 (Charlie)... 26 (Zebra).
- && peekProc(squad_offset_3 + 0x240, squad)
- // Squad leader value: 0 (False), 1 (True).
- && peekProc(squad_offset_3 + 0x244, squad_leader);
-
- // This prevents the plugin from linking to the game in case something goes wrong during values retrieval from memory addresses.
+ // Avatar position values (X, Y and Z).
+ && peekProc(pModule + 0x36B1500, avatar_pos, 12)
+ // Camera position values (X, Y and Z).
+ && peekProc(camera_base + 0x2B0, camera_pos, 12)
+ // Avatar front vector values (X, Y and Z).
+ && peekProc(camera_base + 0x260, camera_front, 12)
+ // Avatar top vector values (X, Y and Z).
+ && peekProc(camera_base + 0x250, camera_top, 12)
+ // Server name.
+ && peekProc(server_name_offset_2, server_name)
+ // Team name.
+ && peekProc(team_offset_2 + 0x13, team)
+ // Squad value: 0 (not in a squad), 1 (Apples), 2 (Butter), 3 (Charlie)... 26 (Zebra).
+ && peekProc(squad_offset_3 + 0x240, squad)
+ // Squad leader value: 0 (False), 1 (True).
+ && peekProc(squad_offset_3 + 0x244, squad_leader);
+
+ // This prevents the plugin from linking to the game in case something goes wrong during values retrieval from
+ // memory addresses.
if (!ok) {
return false;
}
- if (!state) { // If not in-game
- context.clear(); // Clear context
+ if (!state) { // If not in-game
+ context.clear(); // Clear context
identity.clear(); // Clear identity
// Set vectors values to 0.
- 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;
+ 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;
}
return true; // This tells Mumble to ignore all vectors.
@@ -123,7 +144,8 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa
}
// Squad
- if (squad > 0 && squad < 27) { // If squad value is between 1 and 26, set squad name in identity using RAF (1917) Phonetic alphabet.
+ if (squad > 0 && squad < 27) { // If squad value is between 1 and 26, set squad name in identity using RAF (1917)
+ // Phonetic alphabet.
// Squad name
if (squad == 1)
oidentity << std::endl << "\"Squad\": \"Apples\",";
@@ -179,13 +201,19 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa
oidentity << std::endl << "\"Squad\": \"Zebra\",";
// Squad leader
if (squad_leader == 1)
- oidentity << std::endl << "\"Squad leader\": true"; // If squad leader value is true, set squad leader state to "True" in identity.
+ oidentity << std::endl
+ << "\"Squad leader\": true"; // If squad leader value is true, set squad leader state to "True" in
+ // identity.
else
- oidentity << std::endl << "\"Squad leader\": false"; // If squad leader value is false, set squad leader state to "False" in identity.
- // When not in a squad
+ oidentity << std::endl
+ << "\"Squad leader\": false"; // If squad leader value is false, set squad leader state to "False"
+ // in identity.
+ // When not in a squad
} else {
- oidentity << std::endl << "\"Squad\": null,"; // If squad value isn't between 1 and 26, set squad to "null" in identity.
- oidentity << std::endl << "\"Squad leader\": null"; // If not in a squad, set squad leader state to "null" in identity.
+ oidentity << std::endl
+ << "\"Squad\": null,"; // If squad value isn't between 1 and 26, set squad to "null" in identity.
+ oidentity << std::endl
+ << "\"Squad leader\": null"; // If not in a squad, set squad leader state to "null" in identity.
}
oidentity << std::endl << "}";
@@ -193,28 +221,27 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa
// End identity
// Flip the front vector
- for (int i=0;i<3;i++) {
+ for (int i = 0; i < 3; i++) {
camera_front[i] = -camera_front[i];
}
// Convert from right to left handed
- avatar_pos[0] = -avatar_pos[0];
- camera_pos[0] = -camera_pos[0];
+ avatar_pos[0] = -avatar_pos[0];
+ camera_pos[0] = -camera_pos[0];
camera_front[0] = -camera_front[0];
- camera_top[0] = -camera_top[0];
+ camera_top[0] = -camera_top[0];
// Sync avatar front and top vectors with camera ones
- for (int i=0;i<3;i++) {
+ for (int i = 0; i < 3; i++) {
avatar_front[i] = camera_front[i];
- avatar_top[i] = camera_top[i];
+ avatar_top[i] = camera_top[i];
}
return true;
}
-static int trylock(const std::multimap<std::wstring, unsigned long long int> &pids) {
-
- if (! initialize(pids, L"bf1.exe")) { // Retrieve game executable's memory address
+static int trylock(const std::multimap< std::wstring, unsigned long long int > &pids) {
+ if (!initialize(pids, L"bf1.exe")) { // Retrieve game executable's memory address
return false;
}
@@ -236,29 +263,16 @@ static const std::wstring longdesc() {
}
static std::wstring description(L"Battlefield 1 version 1.0.49.52296"); // Plugin short description
-static std::wstring shortname(L"Battlefield 1"); // Plugin short name
+static std::wstring shortname(L"Battlefield 1"); // Plugin short name
static int trylock1() {
- return trylock(std::multimap<std::wstring, unsigned long long int>());
+ return trylock(std::multimap< std::wstring, unsigned long long int >());
}
-static MumblePlugin bf1plug = {
- MUMBLE_PLUGIN_MAGIC,
- description,
- shortname,
- nullptr,
- nullptr,
- trylock1,
- generic_unlock,
- longdesc,
- fetch
-};
-
-static MumblePlugin2 bf1plug2 = {
- MUMBLE_PLUGIN_MAGIC_2,
- MUMBLE_PLUGIN_VERSION,
- trylock
-};
+static MumblePlugin bf1plug = { MUMBLE_PLUGIN_MAGIC, description, shortname, nullptr, nullptr, trylock1,
+ generic_unlock, longdesc, fetch };
+
+static MumblePlugin2 bf1plug2 = { MUMBLE_PLUGIN_MAGIC_2, MUMBLE_PLUGIN_VERSION, trylock };
extern "C" MUMBLE_PLUGIN_EXPORT MumblePlugin *getMumblePlugin() {
return &bf1plug;