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:
authorThorvald Natvig <slicer@users.sourceforge.net>2009-03-04 18:32:43 +0300
committerThorvald Natvig <slicer@users.sourceforge.net>2009-03-04 18:32:43 +0300
commitac0b3cf4d4214eaae34bf4f981f4e0ded06e86fd (patch)
treed7d9fb45f0bdca6fb278253af030a510059a4ce9 /plugins/l4d
parenta2765a6cb6f142a82f38db80fd0a494e818a5596 (diff)
Indenting
Diffstat (limited to 'plugins/l4d')
-rw-r--r--plugins/l4d/l4d.cpp332
1 files changed, 166 insertions, 166 deletions
diff --git a/plugins/l4d/l4d.cpp b/plugins/l4d/l4d.cpp
index f25890953..83a5b6c47 100644
--- a/plugins/l4d/l4d.cpp
+++ b/plugins/l4d/l4d.cpp
@@ -1,166 +1,166 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <windows.h>
-#include <tlhelp32.h>
-
-#define _USE_MATH_DEFINES
-#include <math.h>
-
-#include "../mumble_plugin.h"
-
-HANDLE h;
-BYTE *posptr;
-BYTE *rotptr;
-
-static DWORD getProcess(const wchar_t *exename) {
- PROCESSENTRY32 pe;
- DWORD pid = 0;
-
- pe.dwSize = sizeof(pe);
- HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
- if (hSnap != INVALID_HANDLE_VALUE) {
- BOOL ok = Process32First(hSnap, &pe);
-
- while (ok) {
- if (wcscmp(pe.szExeFile, exename)==0) {
- pid = pe.th32ProcessID;
- break;
- }
- ok = Process32Next(hSnap, &pe);
- }
- CloseHandle(hSnap);
- }
- return pid;
-}
-
-static BYTE *getModuleAddr(DWORD pid, const wchar_t *modname) {
- MODULEENTRY32 me;
- BYTE *addr = NULL;
- me.dwSize = sizeof(me);
- HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, pid);
- if (hSnap != INVALID_HANDLE_VALUE) {
- BOOL ok = Module32First(hSnap, &me);
-
- while (ok) {
- if (wcscmp(me.szModule, modname)==0) {
- addr = me.modBaseAddr;
- break;
- }
- ok = Module32Next(hSnap, &me);
- }
- CloseHandle(hSnap);
- }
- return addr;
-}
-
-
-static bool peekProc(VOID *base, VOID *dest, SIZE_T len) {
- SIZE_T r;
- BOOL ok=ReadProcessMemory(h, base, dest, len, &r);
- return (ok && (r == len));
-}
-
-static void about(HWND h) {
- ::MessageBox(h, L"Reads audio position information from Left 4 Dead (Build 3730)", L"Mumble L4D Plugin", MB_OK);
-}
-
-static bool calcout(float *pos, float *rot, float *opos, float *front, float *top) {
- float h = rot[0];
- float v = rot[1];
-
- if ((v < -180.0f) || (v > 180.0f) || (h < -180.0f) || (h > 180.0f))
- return false;
-
- h *= static_cast<float>(M_PI / 180.0f);
- v *= static_cast<float>(M_PI / 180.0f);
-
- // Seems L4D is in inches. INCHES?!?
- opos[0] = pos[0] / 39.37f;
- opos[1] = pos[2] / 39.37f;
- opos[2] = pos[1] / 39.37f;
-
- front[0] = cos(v) * cos(h);
- front[1] = -sin(h);
- front[2] = sin(v) * cos(h);
-
- h -= static_cast<float>(M_PI / 2.0f);
-
- top[0] = cos(v) * cos(h);
- top[1] = -sin(h);
- top[2] = sin(v) * cos(h);
- /*
- printf("Poll\n");
- printf("%f %f %f : %f %f\n",pos[0],pos[1],pos[2], rot[0], rot[1]);
- printf("%f %f %f :: %.2f %.2f %.2f :: %.2f %.2f %.2f\n", opos[0], opos[1], opos[2], front[0], front[1], front[2], top[0], top[1], top[2]);
- */
- return true;
-}
-
-static int trylock() {
- h = NULL;
- posptr = rotptr = NULL;
-
- DWORD pid=getProcess(L"left4dead.exe");
- if (!pid)
- return false;
-
- BYTE *mod=getModuleAddr(pid, L"client.dll");
- if (!mod)
- return false;
-
- h=OpenProcess(PROCESS_VM_READ, false, pid);
- if (!h)
- return false;
-
- posptr = mod + 0x576240;
- rotptr = mod + 0x576240 + 24;
-
- float pos[3];
- float rot[3];
- float opos[3], top[3], front[3];
-
- bool ok = peekProc(posptr, pos, 12) &&
- peekProc(rotptr, rot, 12);
-
- if (ok)
- return calcout(pos, rot, opos, top, front);
-
- CloseHandle(h);
- h = NULL;
- return false;
-}
-
-static void unlock() {
- if (h) {
- CloseHandle(h);
- h = NULL;
- }
- return;
-}
-
-static int fetch(float *pos, float *front, float *top) {
- float ipos[3], rot[3];
- bool ok;
- ok = peekProc(posptr, ipos, 12) &&
- peekProc(rotptr, rot, 12);
-
- if (ok)
- return calcout(ipos, rot, pos, front, top);
-
- return false;
-}
-
-static MumblePlugin l4dplug = {
- MUMBLE_PLUGIN_MAGIC,
- L"Left 4 Dead (Build 3730)",
- L"Left 4 Dead",
- about,
- NULL,
- trylock,
- unlock,
- fetch
-};
-
-extern "C" __declspec(dllexport) MumblePlugin *getMumblePlugin() {
- return &l4dplug;
-}
+#include <stdio.h>
+#include <stdlib.h>
+#include <windows.h>
+#include <tlhelp32.h>
+
+#define _USE_MATH_DEFINES
+#include <math.h>
+
+#include "../mumble_plugin.h"
+
+HANDLE h;
+BYTE *posptr;
+BYTE *rotptr;
+
+static DWORD getProcess(const wchar_t *exename) {
+ PROCESSENTRY32 pe;
+ DWORD pid = 0;
+
+ pe.dwSize = sizeof(pe);
+ HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
+ if (hSnap != INVALID_HANDLE_VALUE) {
+ BOOL ok = Process32First(hSnap, &pe);
+
+ while (ok) {
+ if (wcscmp(pe.szExeFile, exename)==0) {
+ pid = pe.th32ProcessID;
+ break;
+ }
+ ok = Process32Next(hSnap, &pe);
+ }
+ CloseHandle(hSnap);
+ }
+ return pid;
+}
+
+static BYTE *getModuleAddr(DWORD pid, const wchar_t *modname) {
+ MODULEENTRY32 me;
+ BYTE *addr = NULL;
+ me.dwSize = sizeof(me);
+ HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, pid);
+ if (hSnap != INVALID_HANDLE_VALUE) {
+ BOOL ok = Module32First(hSnap, &me);
+
+ while (ok) {
+ if (wcscmp(me.szModule, modname)==0) {
+ addr = me.modBaseAddr;
+ break;
+ }
+ ok = Module32Next(hSnap, &me);
+ }
+ CloseHandle(hSnap);
+ }
+ return addr;
+}
+
+
+static bool peekProc(VOID *base, VOID *dest, SIZE_T len) {
+ SIZE_T r;
+ BOOL ok=ReadProcessMemory(h, base, dest, len, &r);
+ return (ok && (r == len));
+}
+
+static void about(HWND h) {
+ ::MessageBox(h, L"Reads audio position information from Left 4 Dead (Build 3730)", L"Mumble L4D Plugin", MB_OK);
+}
+
+static bool calcout(float *pos, float *rot, float *opos, float *front, float *top) {
+ float h = rot[0];
+ float v = rot[1];
+
+ if ((v < -180.0f) || (v > 180.0f) || (h < -180.0f) || (h > 180.0f))
+ return false;
+
+ h *= static_cast<float>(M_PI / 180.0f);
+ v *= static_cast<float>(M_PI / 180.0f);
+
+ // Seems L4D is in inches. INCHES?!?
+ opos[0] = pos[0] / 39.37f;
+ opos[1] = pos[2] / 39.37f;
+ opos[2] = pos[1] / 39.37f;
+
+ front[0] = cos(v) * cos(h);
+ front[1] = -sin(h);
+ front[2] = sin(v) * cos(h);
+
+ h -= static_cast<float>(M_PI / 2.0f);
+
+ top[0] = cos(v) * cos(h);
+ top[1] = -sin(h);
+ top[2] = sin(v) * cos(h);
+ /*
+ printf("Poll\n");
+ printf("%f %f %f : %f %f\n",pos[0],pos[1],pos[2], rot[0], rot[1]);
+ printf("%f %f %f :: %.2f %.2f %.2f :: %.2f %.2f %.2f\n", opos[0], opos[1], opos[2], front[0], front[1], front[2], top[0], top[1], top[2]);
+ */
+ return true;
+}
+
+static int trylock() {
+ h = NULL;
+ posptr = rotptr = NULL;
+
+ DWORD pid=getProcess(L"left4dead.exe");
+ if (!pid)
+ return false;
+
+ BYTE *mod=getModuleAddr(pid, L"client.dll");
+ if (!mod)
+ return false;
+
+ h=OpenProcess(PROCESS_VM_READ, false, pid);
+ if (!h)
+ return false;
+
+ posptr = mod + 0x576240;
+ rotptr = mod + 0x576240 + 24;
+
+ float pos[3];
+ float rot[3];
+ float opos[3], top[3], front[3];
+
+ bool ok = peekProc(posptr, pos, 12) &&
+ peekProc(rotptr, rot, 12);
+
+ if (ok)
+ return calcout(pos, rot, opos, top, front);
+
+ CloseHandle(h);
+ h = NULL;
+ return false;
+}
+
+static void unlock() {
+ if (h) {
+ CloseHandle(h);
+ h = NULL;
+ }
+ return;
+}
+
+static int fetch(float *pos, float *front, float *top) {
+ float ipos[3], rot[3];
+ bool ok;
+ ok = peekProc(posptr, ipos, 12) &&
+ peekProc(rotptr, rot, 12);
+
+ if (ok)
+ return calcout(ipos, rot, pos, front, top);
+
+ return false;
+}
+
+static MumblePlugin l4dplug = {
+ MUMBLE_PLUGIN_MAGIC,
+ L"Left 4 Dead (Build 3730)",
+ L"Left 4 Dead",
+ about,
+ NULL,
+ trylock,
+ unlock,
+ fetch
+};
+
+extern "C" __declspec(dllexport) MumblePlugin *getMumblePlugin() {
+ return &l4dplug;
+}