Try to detect steam wine and enforce parameter for an easier to emulate version

This commit is contained in:
ptitSeb 2024-02-25 12:13:34 +01:00
parent 49e6609182
commit 68503a37cf

View File

@ -1188,6 +1188,18 @@ void endBox86()
}
}
static void add_argv(const char* what) {
int there = 0;
for(int i=1; i<my_context->argc && !there; ++i)
if(!strcmp(my_context->argv[i], what))
there = 1;
if(!there) {
my_context->argv = (char**)box_realloc(my_context->argv, (my_context->argc+1)*sizeof(char*));
my_context->argv[my_context->argc] = box_strdup(what);
my_context->argc++;
}
}
static void load_rcfiles()
{
#ifndef TERMUX
@ -1353,6 +1365,7 @@ int main(int argc, const char **argv, char **env)
}
box86_wine = 1;
}
int wine_steam = 0;
// check if this is wine
if(!strcmp(prog, "wine") || (strlen(prog)>5 && !strcmp(prog+strlen(prog)-strlen("/wine"), "/wine"))) {
const char* prereserve = getenv("WINEPRELOADRESERVE");
@ -1370,6 +1383,23 @@ int main(int argc, const char **argv, char **env)
}
}
box86_wine = 1;
// if program being called is wine_steam (rudimentary check...) and if no other argument are there
if(argv[nextarg+1] && argv[nextarg+1][0]!='-' /*&& argc==(nextarg+2)*/) {
if(!strcasecmp(argv[nextarg+1], "steam.exe"))
wine_steam = 1;
else if(!strcasecmp(argv[nextarg+1], "steam"))
wine_steam = 1;
if(!wine_steam) {
const char* pp = strrchr(argv[nextarg+1], '/');
if(pp && !strcasecmp(pp+1, "steam.exe"))
wine_steam = 1;
else {
pp = strrchr(argv[nextarg+1], '\\');
if(pp && !strcasecmp(pp+1, "steam.exe"))
wine_steam = 1;
}
}
}
}
// check if this is wineserver
if(!strcmp(prog, "wineserver") || (strlen(prog)>9 && !strcmp(prog+strlen(prog)-strlen("/wineserver"), "/wineserver"))) {
@ -1538,18 +1568,16 @@ int main(int argc, const char **argv, char **env)
}
if(box86_nosandbox)
{
// check if sandbox is already there
int there = 0;
for(int i=1; i<my_context->argc && !there; ++i)
if(!strcmp(my_context->argv[i], "--no-sandbox"))
there = 1;
if(!there) {
my_context->argv = (char**)box_realloc(my_context->argv, (my_context->argc+1)*sizeof(char*));
my_context->argv[my_context->argc] = box_strdup("--no-sandbox");
my_context->argc++;
}
add_argv("--no-sandbox");
}
if(wine_steam) {
printf_log(LOG_INFO, "Steam.exe detected, adding -cef-single-process -cef-in-process-gpu -cef-disable-sandbox -no-cef-sandbox -cef-disable-breakpad to parameters");
add_argv("-cef-single-process");
add_argv("-cef-in-process-gpu");
add_argv("-cef-disable-sandbox");
add_argv("-no-cef-sandbox");
add_argv("-cef-disable-breakpad");
}
// check if file exist
if(!my_context->argv[0] || !FileExist(my_context->argv[0], IS_FILE)) {
printf_log(LOG_NONE, "Error: file is not found (check BOX86_PATH)\n");