Merge PR #3511: plugins: compile plugins for Windows games also on Linux, for Proton/Wine support

This commit is contained in:
Davide Beatrici 2019-10-11 23:33:17 +02:00 committed by GitHub
commit b54351cfba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
66 changed files with 67 additions and 128 deletions

View File

@ -7,6 +7,3 @@ include(../plugins.pri)
TARGET = aoc
SOURCES = aoc.cpp
LIBS += -luser32

View File

@ -7,4 +7,3 @@ include(../plugins.pri)
TARGET = arma2
SOURCES = arma2.cpp
LIBS += -luser32

View File

@ -13,7 +13,7 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa
bool ok, state;
char server_name[100], team[4];
BYTE squad, squad_leader;
uint8_t squad, squad_leader;
// State pointers
procptr_t state_base = peekProcPtr(pModule + 0x33DBD08);

View File

@ -2,4 +2,3 @@ include(../plugins.pri)
TARGET = bf1
SOURCES = bf1.cpp
LIBS += -luser32

View File

@ -7,6 +7,3 @@ include(../plugins.pri)
TARGET = bf1942
SOURCES = bf1942.cpp
LIBS += -luser32

View File

@ -100,7 +100,7 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa
avatar_pos[i] = avatar_front[i] = avatar_top[i] = camera_pos[i] = camera_front[i] = camera_top[i] = 0.0f;
bool ok;
BYTE logincheck;
uint8_t logincheck;
ok = peekProc(login_ptr, &logincheck, 1);
if (! ok)
return false;
@ -108,7 +108,7 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa
if (logincheck == 0)
return false;
BYTE state;
uint8_t state;
ok = peekProc(state_ptr , &state, 1); // Magical state value
if (! ok)
return false;
@ -126,13 +126,13 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa
char ccontext[128];
BYTE is_commander;
BYTE is_squad_leader;
BYTE is_in_squad;
BYTE is_opfor;
BYTE on_voip;
BYTE on_voip_com;
BYTE target_squad_id;
uint8_t is_commander;
uint8_t is_squad_leader;
uint8_t is_in_squad;
uint8_t is_opfor;
uint8_t on_voip;
uint8_t on_voip_com;
uint8_t target_squad_id;
ok = peekProc(pos_ptr, avatar_pos, 12) &&
peekProc(face_ptr, avatar_front, 12) &&

View File

@ -7,4 +7,3 @@ include(../plugins.pri)
TARGET = bf2
SOURCES = bf2.cpp
LIBS += -luser32

View File

@ -13,7 +13,7 @@ procptr_t RendDX9 = 0;
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) {
bool ok;
char server_name[100], soldier_name[100];
BYTE team_id, squad_id, is_commander, is_squad_leader, target_squad_id, on_voip, on_voip_com;
uint8_t team_id, squad_id, is_commander, is_squad_leader, target_squad_id, on_voip, on_voip_com;
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;

View File

@ -7,4 +7,3 @@ include(../plugins.pri)
TARGET = bf2142
SOURCES = bf2142.cpp
LIBS += -luser32

View File

@ -89,16 +89,16 @@ inline bool resolve_ptrs() {
*/
/*
Magic:
state : 0x238ABDC BYTE 1 when playing
state : 0x238ABDC uint8_t 1 when playing
2 while in menu/dead
Context:
IP:Port of server: 0x0235DB90 char[128] ip:port of the server
Identity:
Squad state: BF3.exe+0x01EF25C4 + 0x1C + 0xBC + 0x36C + 0x8 + 0x104 BYTE 0 is not in squad; 1 is in Alpha squad, 2 Bravo, ... , 9 India
SLead state: BF3.exe+0x01EF25C4 + 0x1C + 0xBC + 0x36C + 0x8 + 0x108 BYTE 0 is not lead; 1 is lead
Team state: BF3.exe+0x01EF25C4 + 0x1C + 0xBC + 0x31C BYTE 1 is blufor (US team, for example), 2 is opfor (RU), 0 is probably upcoming spec mode
Squad state: BF3.exe+0x01EF25C4 + 0x1C + 0xBC + 0x36C + 0x8 + 0x104 uint8_t 0 is not in squad; 1 is in Alpha squad, 2 Bravo, ... , 9 India
SLead state: BF3.exe+0x01EF25C4 + 0x1C + 0xBC + 0x36C + 0x8 + 0x108 uint8_t 0 is not lead; 1 is lead
Team state: BF3.exe+0x01EF25C4 + 0x1C + 0xBC + 0x31C uint8_t 1 is blufor (US team, for example), 2 is opfor (RU), 0 is probably upcoming spec mode
*/
procptr_t base_bf3 = peekProcPtr(pModule + base_offset);
@ -126,10 +126,10 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa
avatar_pos[i] = avatar_front[i] = avatar_top[i] = camera_pos[i] = camera_front[i] = camera_top[i] = 0.0f;
char ccontext[128];
char state;
BYTE squad_state;
BYTE is_squadleader;
BYTE team_state;
uint8_t state;
uint8_t squad_state;
uint8_t is_squadleader;
uint8_t team_state;
bool ok;
ok = peekProc(state_ptr, &state, 1); // State value

View File

@ -7,4 +7,3 @@ include(../plugins.pri)
TARGET = bf3
SOURCES = bf3.cpp
LIBS += -luser32

View File

@ -13,7 +13,7 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa
bool ok, state;
char serverid[37], host[22], team[3];
BYTE squad, squad_leader, squad_state;
uint8_t squad, squad_leader, squad_state;
// Server ID pointers
procptr_t serverid_base = peekProcPtr(pModule + 0x23D5368);

View File

@ -2,4 +2,3 @@ include(../plugins.pri)
TARGET = bf4
SOURCES = bf4.cpp
LIBS += -luser32

View File

@ -13,7 +13,7 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa
bool ok, state;
char serverid[37], host[22], team[3];
BYTE squad, squad_leader, squad_state;
uint8_t squad, squad_leader, squad_state;
// Server ID pointers
procptr_t serverid_base = peekProcPtr(pModule + 0x1D39C64);

View File

@ -2,4 +2,3 @@ include(../plugins.pri)
TARGET = bf4_x86
SOURCES = bf4_x86.cpp
LIBS += -luser32

View File

@ -7,4 +7,3 @@ include(../plugins.pri)
TARGET = bfbc2
SOURCES = bfbc2.cpp
LIBS += -luser32

View File

@ -7,4 +7,3 @@ include(../plugins.pri)
TARGET = bfheroes
SOURCES = bfheroes.cpp
LIBS += -luser32

View File

@ -59,7 +59,7 @@ static procptr_t camtopptr = camfrontptr + 0xC;
static procptr_t camptr = camfrontptr + 0x18;
static procptr_t hostipportptr;
static char prev_hostipport[22];
static std::string prev_hostipport;
static char state = 0; // 1 if connected to a server, 0 if not
@ -88,7 +88,7 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa
float cam[3], camtop[3], camfront[3];
bool ok;
char hostipport[sizeof(prev_hostipport)];
char hostipport[22];
ok = peekProc(camfrontptr, camfront, 12) &&
peekProc(camtopptr, camtop, 12) &&
@ -99,16 +99,17 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa
return false;
hostipport[sizeof(hostipport) - 1] = '\0';
if (strcmp(hostipport, prev_hostipport) != 0) {
if (hostipport != prev_hostipport) {
context.clear();
state = 0;
strcpy_s(prev_hostipport, sizeof(prev_hostipport), hostipport);
prev_hostipport = hostipport;
if (strcmp(hostipport, "") != 0 && strcmp(hostipport, "bot") != 0) {
char buffer[50];
sprintf_s(buffer, sizeof(buffer), "{\"ipport\": \"%s\"}", hostipport);
context.assign(buffer);
std::ostringstream contextstream;
contextstream << "{\"ipport\": \"" << hostipport << "\"}";
context = contextstream.str();
state = 1;
}
}
@ -131,15 +132,14 @@ static int trylock(const std::multimap<std::wstring, unsigned long long int> &pi
return false;
if (refreshPointers()) { // unlink plugin if this fails
*prev_hostipport = '\0';
prev_hostipport.clear();
float avatar_pos[3], avatar_front[3], avatar_top[3];
float camera_pos[3], camera_front[3], camera_top[3];
std::string context;
std::wstring identity;
if (fetch(avatar_pos, avatar_front, avatar_top, camera_pos, camera_front, camera_top, context, identity)) {
*prev_hostipport = '\0'; // we need to do this again since fetch() above overwrites this (which results in empty context until next change)
prev_hostipport.clear(); // we need to do this again since fetch() above overwrites this (which results in empty context until next change)
return true;
}
}

View File

@ -7,4 +7,3 @@ include(../plugins.pri)
TARGET = blacklight
SOURCES = blacklight.cpp
LIBS += -luser32

View File

@ -7,4 +7,3 @@ include(../plugins.pri)
TARGET = borderlands
SOURCES = borderlands.cpp
LIBS += -luser32

View File

@ -7,4 +7,3 @@ include(../plugins.pri)
TARGET = borderlands2
SOURCES = borderlands2.cpp
LIBS += -luser32

View File

@ -7,5 +7,3 @@ include(../plugins.pri)
TARGET = breach
SOURCES = breach.cpp
LIBS += -luser32

View File

@ -7,4 +7,3 @@ include(../plugins.pri)
TARGET = cod2
SOURCES = cod2.cpp
LIBS += -luser32

View File

@ -7,4 +7,3 @@ include(../plugins.pri)
TARGET = cod4
SOURCES = cod4.cpp
LIBS += -luser32

View File

@ -7,4 +7,3 @@ include(../plugins.pri)
TARGET = cod5
SOURCES = cod5.cpp
LIBS += -luser32

View File

@ -7,6 +7,3 @@ include(../plugins.pri)
TARGET = codmw2
SOURCES = codmw2.cpp
LIBS += -luser32

View File

@ -7,4 +7,3 @@ include(../plugins.pri)
TARGET = codmw2so
SOURCES = codmw2so.cpp
LIBS += -luser32

View File

@ -7,4 +7,3 @@ include(../plugins.pri)
TARGET = cs
SOURCES = cs.cpp
LIBS += -luser32

View File

@ -8,4 +8,3 @@ include(../plugins.pri)
DEFINES += "NULL_DESC=\"L\\\"CounterStrike : Source (Retracted, now using link)\\\"\""
TARGET = css
SOURCES = ../null_plugin.cpp
LIBS += -luser32

View File

@ -8,4 +8,3 @@ include(../plugins.pri)
DEFINES += "NULL_DESC=\"L\\\"Day of Defeat : Source (Retracted, now using link)\\\"\""
TARGET = dods
SOURCES = ../null_plugin.cpp
LIBS += -luser32

View File

@ -7,4 +7,3 @@ include(../plugins.pri)
TARGET = dys
SOURCES = dys.cpp
LIBS += -luser32

View File

@ -7,4 +7,3 @@ include(../plugins.pri)
TARGET = etqw
SOURCES = etqw.cpp
LIBS += -luser32

View File

@ -7,5 +7,3 @@ include(../plugins.pri)
TARGET = ffxiv
SOURCES = ffxiv.cpp
win32:LIBS += -luser32

View File

@ -9,4 +9,3 @@ TARGET = ffxiv_x64
SOURCES = ../ffxiv/ffxiv.cpp
DEFINES *= FFXIV_USE_x64
win32:LIBS += -luser32

View File

@ -7,4 +7,3 @@ include(../plugins.pri)
TARGET = gmod
SOURCES = gmod.cpp
LIBS += -luser32

View File

@ -7,4 +7,3 @@ include(../plugins.pri)
TARGET = gtaiv
SOURCES = gtaiv.cpp
LIBS += -luser32

View File

@ -7,5 +7,3 @@ include(../plugins.pri)
TARGET = gtasa
SOURCES = gtasa.cpp
LIBS += -luser32

View File

@ -7,4 +7,3 @@ include(../plugins.pri)
TARGET = gtav
SOURCES = gtav.cpp
LIBS += -luser32

View File

@ -159,15 +159,14 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa
calcout(pos, front, cam, camfront, avatar_pos, avatar_front, camera_pos, camera_front);
if (areaid != prev_areaid || location != prev_location) {
context.clear();
prev_areaid = areaid;
prev_location = location;
char buffer[50];
sprintf_s(buffer, sizeof(buffer), "{\"instance\": \"%d:%d\"}", areaid, static_cast<int>(location));
context.assign(buffer);
std::ostringstream contextstream;
contextstream << "{\"instance\": \"" << areaid << ":" << static_cast<int>(location) << "\"}";
context = contextstream.str();
}
return true;
}

View File

@ -7,4 +7,3 @@ include(../plugins.pri)
TARGET = gw
SOURCES = gw.cpp
LIBS += -luser32

View File

@ -8,4 +8,3 @@ include(../plugins.pri)
DEFINES += "NULL_DESC=\"L\\\"Half Life 2 Death Match (Retracted, now using link)\\\"\""
TARGET = hl2dm
SOURCES = ../null_plugin.cpp
LIBS += -luser32

View File

@ -7,4 +7,3 @@ include(../plugins.pri)
TARGET = insurgency
SOURCES = insurgency.cpp
LIBS += -luser32

View File

@ -7,4 +7,3 @@ include(../plugins.pri)
TARGET = jc2
SOURCES = jc2.cpp
LIBS += -luser32

View File

@ -7,4 +7,3 @@ include(../plugins.pri)
TARGET = l4d
SOURCES = l4d.cpp
LIBS += -luser32

View File

@ -7,5 +7,3 @@ include(../plugins.pri)
TARGET = l4d2
SOURCES = l4d2.cpp
win32:LIBS += -luser32

View File

@ -9,7 +9,6 @@ TARGET = link
win32 {
SOURCES = link.cpp
LIBS += -luser32
}
unix {

View File

@ -67,7 +67,7 @@ static procptr_t gameptr = 0xE22E90;
static procptr_t hostipptr = 0xAF69D18;
static procptr_t hostportptr = hostipptr + 0x1C;
static char prev_hostip[16]; // These should never change while the game is running, but just in case...
static std::string prev_hostip; // These should never change while the game is running, but just in case...
static int prev_hostport;
static bool calcout(float *pos, float *cam, float *opos, float *ocam) {
@ -128,18 +128,19 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa
calcout(ipos, cam, avatar_pos, camera_pos); //calculate proper position values
if (strcmp(hostip, prev_hostip) != 0 || hostport != prev_hostport) {
context.clear();
strcpy_s(prev_hostip, sizeof(prev_hostip), hostip);
if (hostip != prev_hostip || hostport != prev_hostport) {
prev_hostip = hostip;
prev_hostport = hostport;
if (strcmp(hostip, "") != 0) {
char buffer[50];
sprintf_s(buffer, sizeof(buffer), "{\"ipport\": \"%s:%d\"}", hostip, hostport);
context.assign(buffer);
std::ostringstream contextstream;
contextstream << "{\"ipport\": \"" << hostip << ":" << hostport << "\"}";
context = contextstream.str();
} else {
context.clear();
}
}
return true;
}
@ -148,7 +149,7 @@ static int trylock(const std::multimap<std::wstring, unsigned long long int> &pi
return false;
if (refreshPointers()) { // unlink plugin if this fails
*prev_hostip = '\0';
prev_hostip.clear();
prev_hostport = 0;
float avatar_pos[3], avatar_front[3], avatar_top[3];
@ -157,7 +158,7 @@ static int trylock(const std::multimap<std::wstring, unsigned long long int> &pi
std::wstring identity;
if (fetch(avatar_pos, avatar_front, avatar_top, camera_pos, camera_front, camera_top, context, identity)) {
*prev_hostip = '\0'; // we need to do this again since fetch() above overwrites this (which results in empty context until next change)
prev_hostip.clear(); // we need to do this again since fetch() above overwrites this (which results in empty context until next change)
prev_hostport = 0;
return true;
}

View File

@ -7,4 +7,3 @@ include(../plugins.pri)
TARGET = lol
SOURCES = lol.cpp
LIBS += -luser32

View File

@ -42,8 +42,8 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa
bool ok;
byte l[2];
byte r,i;
uint8_t l[2];
uint8_t r,i;
float o[3];
procptr_t hPtr;
float h;
@ -51,7 +51,7 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa
/*
Position as represented by /loc command
lx, ly = 8 * (byte)l;
lx, ly = 8 * (uint8_t)l;
ox, oy, oz = (float)o;
0 < ox < 160

View File

@ -7,5 +7,3 @@ include(../plugins.pri)
TARGET = lotro
SOURCES = lotro.cpp
LIBS += -luser32
CONFIG += qt

View File

@ -6,6 +6,14 @@
#ifndef MUMBLE_MUMBLE_PLUGIN_UTILS_H_
#define MUMBLE_MUMBLE_PLUGIN_UTILS_H_
#include <codecvt>
#include <locale>
static inline std::string utf16ToUtf8(const std::wstring &wstr) {
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> conv;
return conv.to_bytes(wstr);
}
// escape lossily converts the given
// string to ASCII, replacing any
// character not within the printable

View File

@ -16,6 +16,8 @@ CONFIG(static) {
CONFIG += qt_dynamic_lookup
}
win32:LIBS += -luser32
DESTDIR = $$DESTDIR/plugins
include(../qmake/symbols.pri)

View File

@ -10,14 +10,15 @@ TEMPLATE = subdirs
CONFIG += debug_and_release
SUBDIRS = link
win32 {
SUBDIRS += aoc arma2 bf1942 bf2 bf3 bf2142 bfbc2 bfheroes bf4_x86 blacklight borderlands borderlands2 breach cod2 cod4 cod5 codmw2 codmw2so cs css dods dys etqw ffxiv tf2 gmod gtaiv gtasa gw hl2dm insurgency jc2 l4d l4d2 lol lotro ql rl sr sto ut2004 ut3 ut99 wolfet wow
win32|linux {
SUBDIRS += aoc arma2 bf1942 bf2 bf3 bf2142 bfbc2 bfheroes bf4_x86 blacklight borderlands borderlands2 breach cod2 cod4 cod5 codmw2 codmw2so cs dys etqw ffxiv gmod gtaiv gtasa gw insurgency jc2 l4d l4d2 lol lotro ql rl sr ut2004 ut3 ut99 wolfet wow
equals(MUMBLE_ARCH, x86_64) {
SUBDIRS += bf1 bf4 ffxiv_x64 gtav wow_x64
}
}
linux {
SUBDIRS += l4d2 rl
# Plugins which are now retracted were only released for Windows
win32 {
SUBDIRS += css dods hl2dm sto tf2
}

View File

@ -18,7 +18,7 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa
// Char values for extra features
char host[22], servername[50], map[30];
// Team
BYTE 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.

View File

@ -7,4 +7,3 @@ include(../plugins.pri)
TARGET = ql
SOURCES = ql.cpp
LIBS += -luser32

View File

@ -7,5 +7,3 @@ include(../plugins.pri)
TARGET = rl
SOURCES = rl.cpp
win32:LIBS += -luser32

View File

@ -7,4 +7,3 @@ include(../plugins.pri)
TARGET = sr
SOURCES = sr.cpp
LIBS += -luser32

View File

@ -8,4 +8,3 @@ include(../plugins.pri)
DEFINES += "NULL_DESC=\"L\\\"Star Trek Online (Retracted due to lack of maintenance)\\\"\""
TARGET = sto
SOURCES = ../null_plugin.cpp
LIBS += -luser32

View File

@ -8,4 +8,3 @@ include(../plugins.pri)
DEFINES += "NULL_DESC=\"L\\\"Team Fortress 2 (Retracted, now using link)\\\"\""
TARGET = tf2
SOURCES = ../null_plugin.cpp
LIBS += -luser32

View File

@ -7,4 +7,3 @@ include(../plugins.pri)
TARGET = ut2004
SOURCES = ut2004.cpp
LIBS += -luser32

View File

@ -7,4 +7,3 @@ include(../plugins.pri)
TARGET = ut3
SOURCES = ut3.cpp
LIBS += -luser32

View File

@ -35,20 +35,12 @@
*/
#include "../mumble_plugin_main.h"
#include "../mumble_plugin_utils.h"
procptr_t posptr;
procptr_t frtptr;
procptr_t topptr;
static void wcsToMultibyteStdString(wchar_t *wcs, std::string &str) {
const int size = WideCharToMultiByte(CP_UTF8, 0, wcs, -1, NULL, 0, NULL, NULL);
if (size == 0) return;
str.resize(size);
WideCharToMultiByte(CP_UTF8, 0, wcs, -1, &str[0], size, NULL, NULL);
}
static bool cross(float *a, float *b, float *c) {
if (a == 0 || b == 0 || c == 0)
return false;
@ -161,8 +153,7 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa
wservername[sizeof(wservername)/sizeof(wservername[0]) - 1] = '\0';
std::string servername;
wcsToMultibyteStdString(wservername, servername);
const std::string servername = utf16ToUtf8(wservername);
std::ostringstream contextss;
contextss << "{"

View File

@ -7,4 +7,3 @@ include(../plugins.pri)
TARGET = ut99
SOURCES = ut99.cpp
LIBS += -luser32

View File

@ -7,4 +7,3 @@ include(../plugins.pri)
TARGET = wolfet
SOURCES = wolfet.cpp
LIBS += -luser32

View File

@ -7,4 +7,3 @@ include(../plugins.pri)
TARGET = wow
SOURCES = wow.cpp
LIBS += -luser32

View File

@ -7,4 +7,3 @@ include(../plugins.pri)
TARGET = wow_x64
SOURCES = wow_x64.cpp
LIBS += -luser32