Skip to content

Commit

Permalink
l4d2 plugin change some variable names
Browse files Browse the repository at this point in the history
Rename *_address to *_offset
  • Loading branch information
EmperorArthur committed Nov 25, 2016
1 parent 06c04eb commit 9f6c172
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions plugins/l4d2/l4d2.cpp
Expand Up @@ -17,15 +17,15 @@ procptr32_t server = 0;
procptr32_t engine = 0;

#ifdef WIN32
// Memory addresses
const procptr32_t state_address = 0x6ACBD5;
const procptr32_t avatar_pos_address = 0x6B9E1C;
const procptr32_t camera_pos_address = 0x774B98;
const procptr32_t avatar_front_address = 0x774BF8;
const procptr32_t avatar_top_address = 0x774C28;
const procptr32_t host_address = 0x772B24;
const procptr32_t servername_address = 0x772D2C;
const procptr32_t map_address = 0x772C28;
// Memory offsets
const procptr32_t state_offset = 0x6ACBD5;
const procptr32_t avatar_pos_offset = 0x6B9E1C;
const procptr32_t camera_pos_offset = 0x774B98;
const procptr32_t avatar_front_offset = 0x774BF8;
const procptr32_t avatar_top_offset = 0x774C28;
const procptr32_t host_offset = 0x772B24;
const procptr32_t servername_offset = 0x772D2C;
const procptr32_t map_offset = 0x772C28;
const procptr32_t serverid_steamclient_offset = 0x95E56D;
const procptr32_t player_server_offset = 0x7F87BC;
const procptr32_t playerid_engine_offset = 0x4EBF88;
Expand All @@ -36,15 +36,15 @@ const wchar_t *steamclient_name = L"steamclient.dll";
const wchar_t *server_name = L"server.dll";
const wchar_t *engine_name = L"engine.dll";
#else
// Memory addresses
const procptr32_t state_address = 0xE0A24C;
const procptr32_t avatar_pos_address = 0xE773FC;
const procptr32_t camera_pos_address = 0xED8700;
const procptr32_t avatar_front_address = 0xE3C138;
const procptr32_t avatar_top_address = 0xE3C150;
const procptr32_t host_address = 0xE356D0;
const procptr32_t servername_address = 0xE358D8;
const procptr32_t map_address = 0xE09E9D;
// Memory offsets
const procptr32_t state_offset = 0xE0A24C;
const procptr32_t avatar_pos_offset = 0xE773FC;
const procptr32_t camera_pos_offset = 0xED8700;
const procptr32_t avatar_front_offset = 0xE3C138;
const procptr32_t avatar_top_offset = 0xE3C150;
const procptr32_t host_offset = 0xE356D0;
const procptr32_t servername_offset = 0xE358D8;
const procptr32_t map_offset = 0xE09E9D;
const procptr32_t serverid_steamclient_offset = 0x1216CA5;
const procptr32_t player_server_offset = 0xF340E4;
const procptr32_t playerid_engine_offset = 0xA62C60;
Expand All @@ -71,17 +71,17 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa
unsigned char state;

// Peekproc and assign game addresses to our containers, so we can retrieve positional data
ok = peekProc(pModule + state_address, &state, 1) && // Magical state value: 0 or 255 when in main menu and 1 when in-game.
peekProc(pModule + avatar_pos_address, avatar_pos_corrector, 12) && // Avatar Position values (X, Z and Y).
peekProc(pModule + camera_pos_address, camera_pos_corrector, 12) && // Camera Position values (X, Z and Y).
peekProc(pModule + avatar_front_address, avatar_front_corrector, 12) && // Front vector values (X, Z and Y).
peekProc(pModule + avatar_top_address, avatar_top_corrector, 12) && // Top vector values (Z, X and Y).
peekProc(steamclient + serverid_steamclient_offset, serverid) && // Unique server Steam ID.
peekProc(pModule + host_address, host) && // Server value: "IP:Port" (xxx.xxx.xxx.xxx:yyyyy) when in a remote server, "loopback:0" when on a local server and empty when not playing.
peekProc(pModule + servername_address, servername) && // Server name.
peekProc(pModule + map_address, map) && // Map name.
peekProc(server + player_server_offset, player) && // Player nickname.
peekProc(engine + playerid_engine_offset, playerid); // Unique player Steam ID.
ok = peekProc(pModule + state_offset, &state, 1) && // Magical state value: 0 or 255 when in main menu and 1 when in-game.
peekProc(pModule + avatar_pos_offset, avatar_pos_corrector, 12) && // Avatar Position values (X, Z and Y).
peekProc(pModule + camera_pos_offset, camera_pos_corrector, 12) && // Camera Position values (X, Z and Y).
peekProc(pModule + avatar_front_offset, avatar_front_corrector, 12) && // Front vector values (X, Z and Y).
peekProc(pModule + avatar_top_offset, avatar_top_corrector, 12) && // Top vector values (Z, X and Y).
peekProc(steamclient + serverid_steamclient_offset, serverid) && // Unique server Steam ID.
peekProc(pModule + host_offset, host) && // Server value: "IP:Port" (xxx.xxx.xxx.xxx:yyyyy) when in a remote server, "loopback:0" when on a local server and empty when not playing.
peekProc(pModule + servername_offset, servername) && // Server name.
peekProc(pModule + map_offset, map) && // Map name.
peekProc(server + player_server_offset, player) && // Player nickname.
peekProc(engine + playerid_engine_offset, playerid); // Unique player Steam ID.

// This prevents the plugin from linking to the game in case something goes wrong during values retrieval from memory addresses.
if (! ok)
Expand Down

0 comments on commit 9f6c172

Please sign in to comment.