1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
// Copyright 2016-2021 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_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++) {
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;
// 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], avatar_front_corrector[3], avatar_top_corrector[3];
// Char values for extra features
char host[22], servername[50], map[30];
// Team
uint8_t team;
// Peekproc and assign game addresses to our containers, so we can retrieve positional data
ok =
peekProc(pModule + 0x0188248, &state, 1) && // Magical state value: 1 when in-game and 0 when in main menu.
peekProc(pModule + 0x1041CAC, &spec, 1) && // Spectator state value: 1 when spectating and 0 when playing.
peekProc(pModule + 0x0EB8950, avatar_pos_corrector, 12) && // Avatar Position values (X, Z and Y, respectively).
peekProc(pModule + 0x0E6093C, camera_pos_corrector, 12) && // Camera Position values (X, Z and Y, respectively).
peekProc(pModule + 0x0EC5B50, avatar_front_corrector, 12) && // Avatar front values (X, Z and Y, respectively).
peekProc(pModule + 0x0EC5B68, avatar_top_corrector, 12) && // Avatar top values (X, Z and Y, respectively).
peekProc(pModule + 0x0E4A638, host)
&& // Server value: "IP:Port" when in a remote server, "loopback" when on a local server.
peekProc(pModule + 0x106E24B, servername) && // Server name.
peekProc(pModule + 0x12DE8D8, map) && // Map name.
peekProc(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;
}
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.
}
if (state && spec) { // If in-game as spectator
// Set to 0 avatar and camera values.
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;
}
// Set team to SPEC.
std::wostringstream oidentity;
oidentity << "{\"team\": \"SPEC\"}";
identity = oidentity.str();
return true; // This results in all vectors beeing zero which tells Mumble to ignore them.
}
// Begin context
escape(host, sizeof(host));
std::ostringstream ocontext;
ocontext << " {";
if (strcmp(host, "") != 0
&& !strstr(host, "loopback")) { // 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";
}
ocontext << "}";
context = ocontext.str();
// End context
// Begin identity
std::wostringstream oidentity;
oidentity << "{";
// Map
escape(map, sizeof(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 <= 3) {
if (team == 0)
oidentity << std::endl << "\"Team\": \"FFA\""; // If team value is 0, set "FFA" as team in identity.
if (team == 1)
oidentity << std::endl << "\"Team\": \"Red\""; // If team value is 1, set "Red" as team in identity.
if (team == 2)
oidentity << std::endl << "\"Team\": \"Blue\""; // If team value is 2, set "Blue" as team in identity.
if (team == 3)
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
/*
Mumble | Game
X | X
Y | Z
Z | Y
*/
avatar_pos[0] = avatar_pos_corrector[0];
avatar_pos[1] = avatar_pos_corrector[2];
avatar_pos[2] = avatar_pos_corrector[1];
camera_pos[0] = camera_pos_corrector[0];
camera_pos[1] = camera_pos_corrector[2];
camera_pos[2] = camera_pos_corrector[1];
avatar_front[0] = avatar_front_corrector[0];
avatar_front[1] = avatar_front_corrector[2];
avatar_front[2] = avatar_front_corrector[1];
avatar_top[0] = avatar_top_corrector[0];
avatar_top[1] = avatar_top_corrector[2];
avatar_top[2] = avatar_top_corrector[1];
// Scale to meters
for (int i = 0; i < 3; i++) {
camera_front[i] = avatar_front[i];
camera_top[i] = avatar_top[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")) { // Retrieve game executable's memory address
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 Quake Live version 1069 with context and identity support."); // Plugin long 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() {
return trylock(std::multimap< std::wstring, unsigned long long int >());
}
static MumblePlugin qlplug = { MUMBLE_PLUGIN_MAGIC, description, shortname, nullptr, nullptr, trylock1,
generic_unlock, longdesc, fetch };
static MumblePlugin2 qlplug2 = { MUMBLE_PLUGIN_MAGIC_2, MUMBLE_PLUGIN_VERSION, trylock };
extern "C" MUMBLE_PLUGIN_EXPORT MumblePlugin *getMumblePlugin() {
return &qlplug;
}
extern "C" MUMBLE_PLUGIN_EXPORT MumblePlugin2 *getMumblePlugin2() {
return &qlplug2;
}
|