1
/* Copyright (C) 2005-2011, Thorvald Natvig <thorvald@natvig.com>
1
/* Copyright (C) 2005-2012, Thorvald Natvig <thorvald@natvig.com>
2
Copyright (C) 2012, dark_skeleton (d-rez) <dark.skeleton@gmail.com>
69
71
static int trylock(const std::multimap<std::wstring, unsigned long long int> &pids) {
70
posptr = rotptr = NULL;
72
posptr = rotptr = stateptr = contextptr = NULL;
72
74
if (! initialize(pids, L"left4dead2.exe", L"client.dll"))
75
posptr = pModule + 0x6F9250;
77
posptr = pModule + 0x641A4C;
76
78
rotptr = pModule + 0x641A08;
77
// stateptr = pModule + 0x690A3C;
79
stateptr = pModule + 0x6A1AF4;
80
contextptr = pModule + 0x6f487c;
81
84
float opos[3], top[3], front[3];
85
char state, _context[21];
83
86
bool ok = peekProc(posptr, pos, 12) &&
84
peekProc(rotptr, rot, 12);
87
peekProc(rotptr, rot, 12) &&
88
peekProc(stateptr, &state, 1) &&
89
peekProc(contextptr, _context);
87
92
return calcout(pos, rot, opos, top, front);
94
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) {
99
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*/) {
95
100
for (int i=0;i<3;i++)
96
101
avatar_pos[i] = avatar_front[i] = avatar_top[i] = camera_pos[i] = camera_front[i] = camera_top[i] = 0.0f;
98
103
float ipos[3], rot[3];
102
108
// stateptr returns byte values: 0 when map is not loaded; 8 when loaded
103
109
ok = peekProc(posptr, ipos, 12) &&
104
peekProc(rotptr, rot, 12);
105
// peekProc(stateptr, &state, 1);
110
peekProc(rotptr, rot, 12) &&
111
peekProc(stateptr, &state, 1) &&
112
peekProc(contextptr, _context);
108
// return true; // This results in all vectors beeing zero which tells Mumble to ignore them.
115
context = std::string(""); // clear context
116
return true; // This results in all vectors beeing zero which tells Mumble to ignore them.
111
120
int res = calcout(ipos, rot, avatar_pos, avatar_front, avatar_top);
116
125
camera_top[i] = avatar_top[i];
118
127
// Example only -- only set these when you have sane values, and make sure they're pretty constant (every change causes a sever message).
119
context = std::string("server/map/blah");
120
identity = std::wstring(L"STEAM_1:2:3456789");
128
//context = std::string("server/map/blah");
129
//identity = std::wstring(L"STEAM_1:2:3456789");
131
std::string sHost(_context);
132
// This string can be either "xxx.xxx.xxx.xxx:yyyyy" (or shorter), "loopback:0" or "" (empty) when in menus. Hence 21 size for char.
135
if (sHost.find("loopback") == std::string::npos)
137
std::ostringstream newcontext;
138
newcontext << "{\"ipport\": \"" << sHost << "\"}";
139
context = newcontext.str();
129
150
static const std::wstring longdesc() {
130
return std::wstring(L"Supports L4D2 build 4490. No identity or context support yet.");
151
return std::wstring(L"Supports L4D2 build 4777 with context support. No identity support yet.");
133
static std::wstring description(L"Left 4 Dead 2 (Build 4490)");
154
static std::wstring description(L"Left 4 Dead 2 (Build 4777)");
134
155
static std::wstring shortname(L"Left 4 Dead 2");
136
157
static int trylock1() {