64
69
static void about(HWND h) {
65
::MessageBox(h, L"Reads audio position information from Team Fortress 2 (Build 3971)", L"Mumble TF2 Plugin", MB_OK);
70
::MessageBox(h, L"Reads audio position information from Team Fortress 2 (Build 4013). IP:Port context without team discriminator.", L"Mumble TF2 Plugin", MB_OK);
68
73
static bool calcout(float *pos, float *rot, float *opos, float *front, float *top) {
101
static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, float *camera_pos, float *camera_front, float *camera_top, string &context, wstring &identity) {
102
for (int i=0;i<3;i++)
103
avatar_pos[i] = avatar_front[i] = avatar_top[i] = 0;
105
float ipos[3], rot[3];
109
wostringstream new_identity;
110
ostringstream new_context;
112
ok = peekProc(posptr, ipos, 12) &&
113
peekProc(rotptr, rot, 12) &&
114
peekProc(stateptr, &state, 1) &&
115
peekProc(hostptr, chHostStr, 40);
121
new_context << "<context>"
122
<< "<game>tf2</game>"
123
<< "<hostport>" << chHostStr << "</hostport>"
125
context = new_context.str();
128
new_identity << "<identity>"
129
<< "<name>" << "SAS" << "</name>"
131
identity = new_identity.str(); */
133
// Check to see if you are in a server
134
if (state == 0 || state == 1 || state == 3)
135
return true; // Deactivate plugin
138
int res = calcout(ipos, rot, avatar_pos, avatar_front, avatar_top);
140
for (int i=0;i<3;++i) {
141
camera_pos[i] = avatar_pos[i];
142
camera_front[i] = avatar_front[i];
143
camera_top[i] = avatar_top[i];
96
152
static int trylock() {
104
160
BYTE *mod=getModuleAddr(pid, L"client.dll");
163
BYTE *mod_engine=getModuleAddr(pid, L"engine.dll");
107
167
h=OpenProcess(PROCESS_VM_READ, false, pid);
111
171
// Check if we really have TF2 running
113
position tuple: client.dll+0x4b3830 (x,y,z, float)
114
orientation tuple: client.dll+0x4b37f0 (v,h float)
115
ID string: client.dll+0x4ab30b = "teamJet@@" (9 characters, text)
116
spawn state: client.dll+0x49ab9c (0 when at main menu, 1 when spectator, 3 when at team selection menu, and 6 or 9 when on a team (depending on the team side and gamemode), byte)
173
position tuple: client.dll+0x5753d8 (x,y,z, float)
174
orientation tuple: client.dll+0x4b691c (v,h float)
175
ID string: client.dll+0x4eb30b = "teamJet@@" (9 characters, text)
176
spawn state: client.dll+0x49db9c (0 when at main menu, 1 when spectator, 3 when at team selection menu, and 6 or 9 when on a team (depending on the team side and gamemode), byte)
177
host string: engine.dll+0x3c8124 (ip:port zero-terminated string; localhost:27015 if create a server ingame)
178
note that memory addresses in this comment are for example only; the real ones are defined below
181
// Remember addresses for later
182
posptr = mod + 0x52A6A4;
183
rotptr = mod + 0x4D6B78;
184
stateptr = mod + 0x4BDBF4;
185
hostptr = mod_engine + 0x3C91A4;
119
if (!peekProc(mod + 0x4ab30b, sMagic, 9) || strncmp("teamJet@@", sMagic, 9)!=0)
189
if (!peekProc(mod + 0x4CE38B, sMagic, 9) || strncmp("teamJet@@", sMagic, 9)!=0)
122
// Remember addresses for later
123
posptr = mod + 0x4b3830;
124
rotptr = mod + 0x4b37f0;
125
stateptr = mod + 0x49ab9c;
129
float opos[3], top[3], front[3];
131
bool ok = peekProc(posptr, pos, 12) &&
132
peekProc(rotptr, rot, 12);
135
return calcout(pos, rot, opos, top, front);
192
// Check if we can get meaningful data from it
193
float apos[3], afront[3], atop[3];
194
float cpos[3], cfront[3], ctop[3];
198
if (fetch(apos, afront, atop, cpos, cfront, ctop, scontext, sidentity))
136
201
// If it failed clean up
150
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) {
151
for (int i=0;i<3;i++)
152
avatar_pos[i] = avatar_front[i] = avatar_top[i] = 0;
154
float ipos[3], rot[3];
158
ok = peekProc(posptr, ipos, 12) &&
159
peekProc(rotptr, rot, 12) &&
160
peekProc(stateptr, &state, 1);
164
// Check to see if you are in a server
165
if (state == 0 || state == 1 || state == 3)
166
return true; // Deactivate plugin
169
int res = calcout(ipos, rot, avatar_pos, avatar_front, avatar_top);
171
for (int i=0;i<3;++i) {
172
camera_pos[i] = avatar_pos[i];
173
camera_front[i] = avatar_front[i];
174
camera_top[i] = avatar_top[i];
183
215
static const std::wstring longdesc() {
184
return std::wstring(L"Supports TF2 build 3971. No identity or context support yet.");
216
return std::wstring(L"Supports TF2 build 4013. No identity or context support yet.");
187
static std::wstring description(L"Team Fortress 2 (Build 3971)");
219
static std::wstring description(L"Team Fortress 2 (Build 4013)");
188
220
static std::wstring shortname(L"Team Fortress 2");
190
222
static MumblePlugin tf2plug = {