diff options
author | Davide Beatrici <davidebeatrici@users.noreply.github.com> | 2016-06-10 23:04:22 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-10 23:04:22 +0300 |
commit | 3e7b0bab4fd3246dc1b568a9813c2ba6f147d782 (patch) | |
tree | 089361749769eb8818ddb7b0ee2b61fe9d02f66f /plugins/ql | |
parent | a3275f579ba7f16ecc820e91b3e3d1c7c0337f67 (diff) |
plugins/ql: Plugin update for game's latest version
Added:
Context/Identity escape function
Map name in identity
Improved:
Horizontal and vertical view memory addresses changed, the new ones are updated in real-time
Team names
Fixed:
Avatar/Camera front and top vectors calculation
Wrong comment at line 140
Game version: 1069
http://steamcommunity.com/games/282440/announcements/detail/876328108049672536
Diffstat (limited to 'plugins/ql')
-rw-r--r-- | plugins/ql/ql.cpp | 126 |
1 files changed, 77 insertions, 49 deletions
diff --git a/plugins/ql/ql.cpp b/plugins/ql/ql.cpp index c18ad7a28..957ae4e7f 100644 --- a/plugins/ql/ql.cpp +++ b/plugins/ql/ql.cpp @@ -3,30 +3,34 @@ // 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_win32.h" +#include "../mumble_plugin_win32.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++) { avatar_pos[i] = avatar_front[i] = avatar_top[i] = camera_pos[i] = camera_front[i] = camera_top[i] = 0.0f; } + // Boolean values to check if game addresses retrieval is successful and if player is in-game bool ok, state, spec; - char host[22]; - BYTE team; - // Create containers to stuff our raw data into, so we can convert it to Mumble's coordinate system float avatar_pos_corrector[3], camera_pos_corrector[3], viewHor, viewVer; + // Char values for extra features + char host[22], map[30]; + // Team + BYTE team; // Peekproc and assign game addresses to our containers, so we can retrieve positional data ok = peekProc((BYTE *) pModule + 0x0188248, &state, 1) && // Magical state value: 1 when in-game and 0 when in main menu. - peekProc((BYTE *) pModule + 0x1041CAC, &spec, 1) && // Spectator state value: 1 when spectating and 0 when playing. - peekProc((BYTE *) pModule + 0x0EB8950, &avatar_pos_corrector, 12) && // Avatar Position values (Z, X and Y, respectively). - peekProc((BYTE *) pModule + 0x0E6093C, &camera_pos_corrector, 12) && // Camera Position values (Z, X and Y, respectively). - peekProc((BYTE *) pModule + 0x1072954, &viewHor, 4) && // Changes in a range from 87.890625 (looking down) to -87.890625 (looking up). - peekProc((BYTE *) pModule + 0x1072950, &viewVer, 4) && // Changes in a range from 180 to -180 when moving the view to left/right. - peekProc((BYTE *) pModule + 0x0E4A638, host) && // Server value: "IP:Port" when in a remote server, "loopback" when on a local server. - peekProc((BYTE *) pModule + 0x106CE6C, team); // Team value: 0 when in a FFA game (no team); 1 when in Red team; 2 when in Blue team; 3 when in Spectators. - + peekProc((BYTE *) pModule + 0x1041C68, &spec, 1) && // Spectator state value: 1 when spectating and 0 when playing. + peekProc((BYTE *) pModule + 0x0EB8950, avatar_pos_corrector, 12) && // Avatar Position values (Z, X and Y, respectively). + peekProc((BYTE *) pModule + 0x0E6093C, camera_pos_corrector, 12) && // Camera Position values (Z, X and Y, respectively). + peekProc((BYTE *) pModule + 0x106CE04, &viewHor, 4) && // Changes in a range from 180 to -180 when moving the view to left/right. + peekProc((BYTE *) pModule + 0x106CE00, &viewVer, 4) && // Changes in a range from 87.890625 (looking down) to -87.890625 (looking up). + peekProc((BYTE *) pModule + 0x0E4A638, host) && // Server value: "IP:Port" when in a remote server, "loopback" when on a local server. + peekProc((BYTE *) pModule + 0x12DE8D8, map) && // Map name. + peekProc((BYTE *) pModule + 0x106CE6C, team); // Team value: 0 when in a FFA game (no team); 1 when in Red team; 2 when in Blue team; 3 when in Spectators. + if (! ok) { return false; } @@ -34,7 +38,7 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa if (! state) { // If not in-game context.clear(); // Clear context identity.clear(); // Clear identity - + return true; // This results in all vectors beeing zero which tells Mumble to ignore them. } @@ -47,37 +51,62 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa std::wostringstream oidentity; oidentity << "{\"team\": \"SPEC\"}"; identity = oidentity.str(); - + return true; // This results in all vectors beeing zero which tells Mumble to ignore them. } - host[sizeof(host) - 1] = '\0'; - std::string Server(host); - // This string can be either "xxx.xxx.xxx.xxx:yyyyy" (or shorter), "loopback" or "" (empty) when loading. Hence 22 size for char. - if (!Server.empty()) { - if (Server.find("loopback") == std::string::npos) { - std::ostringstream newcontext; - newcontext << "{\"ipport\": \"" << Server << "\"}"; - context = newcontext.str(); - } + // Begin context + host[sizeof(host)-1] = 0; // NUL terminate queried C strings. We do this to ensure the strings from the game are NUL terminated. They should be already, but we can't take any chances. + escape(host); + std::ostringstream ocontext; + ocontext << " {"; + if (strcmp(host, "") != 0 && strstr(host, "loopback") == NULL) { // Only include host (IP:Port) if it is not empty and does not include the string "loopback" (which means it's a local server). + ocontext << "\"Host\": \"" << host << "\""; // Set host address in identity. + } else { + ocontext << "\"Host\": null"; + } - std::wostringstream oidentity; + ocontext << "}"; + context = ocontext.str(); + // End context + + // Begin identity + std::wostringstream oidentity; + oidentity << "{"; + + // Map + map[sizeof(map)-1] = 0; // NUL terminate queried C strings. We do this to ensure the strings from the game are NUL terminated. They should be already, but we can't take any chances. + escape(map); + if (strcmp(map, "") != 0) { + oidentity << std::endl; + oidentity << "\"Map\": \"" << map << "\","; // Set map name in identity. + } else { + oidentity << std::endl << "\"Map\": null,"; + } + + // Team + if (team >= 0 && team <= 3) { if (team == 0) - oidentity << "{\"team\": \"FFA\"}"; + oidentity << std::endl << "\"Team\": \"FFA\""; // If team value is 0, set "FFA" as team in identity. else if (team == 1) - oidentity << "{\"team\": \"RED\"}"; + oidentity << std::endl << "\"Team\": \"Red\""; // If team value is 1, set "Red" as team in identity. else if (team == 2) - oidentity << "{\"team\": \"BLUE\"}"; + oidentity << std::endl << "\"Team\": \"Blue\""; // If team value is 2, set "Blue" as team in identity. else if (team == 3) - oidentity << "{\"team\": \"SPEC\"}"; - identity = oidentity.str(); + oidentity << std::endl << "\"Team\": \"Spectators\""; // If team value is 3, set "Spectators" as team in identity. + } else { + oidentity << std::endl << "\"Team\": null"; } - + + oidentity << std::endl << "}"; + identity = oidentity.str(); + // End identity + /* - Game | Mumble - X | Y - Y | Z - Z | X + Mumble | Game + X | Y + Y | Z + Z | X */ avatar_pos[0] = avatar_pos_corrector[1]; avatar_pos[1] = avatar_pos_corrector[2]; @@ -86,30 +115,29 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa camera_pos[0] = camera_pos_corrector[1]; camera_pos[1] = camera_pos_corrector[2]; camera_pos[2] = camera_pos_corrector[0]; - - // Scale to meters - for (int i=0;i<3;i++) { - avatar_pos[i]/=70.0f; - camera_pos[i]/=70.0f; - } - + + // Calculate view unit vector viewVer *= static_cast<float>(M_PI / 180.0f); viewHor *= static_cast<float>(M_PI / 180.0f); - avatar_front[0] = camera_front[0] = -sin(viewHor) * cos(viewVer); + avatar_front[0] = camera_front[0] = cos(viewVer) * cos(viewHor); avatar_front[1] = camera_front[1] = -sin(viewVer); - avatar_front[2] = camera_front[2] = cos(viewHor) * cos(viewVer); + avatar_front[2] = camera_front[2] = cos(viewVer) * sin(viewHor); + + avatar_top[2] = camera_top[2] = -1; // This tells Mumble to automatically calculate top vector using front vector. - avatar_top[0] = camera_top[0] = -sin(viewHor) * cos(viewVer); - avatar_top[1] = camera_top[1] = -sin(viewVer); - avatar_top[2] = camera_top[2] = cos(viewHor) * cos(viewVer); + // Scale to meters + for (int i=0;i<3;i++) { + avatar_pos[i]/=70.0f; + camera_pos[i]/=70.0f; + } return true; } static int trylock(const std::multimap<std::wstring, unsigned long long int> &pids) { - if (! initialize(pids, L"quakelive_steam.exe")) { // Link the game executable + if (! initialize(pids, L"quakelive_steam.exe")) { // Retrieve game executable's memory address return false; } @@ -127,10 +155,10 @@ static int trylock(const std::multimap<std::wstring, unsigned long long int> &pi } static const std::wstring longdesc() { - return std::wstring(L"Supports Quake Live version 1068 with context and identity support."); // Plugin long description + return std::wstring(L"Supports Quake Live version 1069 with context and identity support."); // Plugin long description } -static std::wstring description(L"Quake Live (v1068)"); // Plugin short description +static std::wstring description(L"Quake Live (v1069)"); // Plugin short description static std::wstring shortname(L"Quake Live"); // Plugin short name static int trylock1() { |