From 0136c5efc6ee7b833e62d345fe18fa1d06d4710a Mon Sep 17 00:00:00 2001
From: DarkGod <darkgod@te4.org>
Date: Tue, 15 Dec 2015 15:55:42 +0000
Subject: [PATCH] new --no-web command

Fixed the game not starting on some latest ubuntu installs
---
 src/main.c |  4 +++-
 src/web.c  | 12 ++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/main.c b/src/main.c
index 7aff539785..0c84a84f9d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1343,6 +1343,7 @@ int main(int argc, char *argv[])
 	bool logtofile = FALSE;
 	bool is_zygote = FALSE;
 	bool os_autoflush = FALSE;
+	bool no_web = FALSE;
 	FILE *logfile = NULL;
 
 	// Parse arguments
@@ -1371,6 +1372,7 @@ int main(int argc, char *argv[])
 		if (!strncmp(arg, "--type=renderer", 15)) is_zygote = TRUE;
 		if (!strncmp(arg, "--no-sandbox", 12)) is_zygote = TRUE;
 		if (!strncmp(arg, "--logtofile", 11)) logtofile = TRUE;
+		if (!strncmp(arg, "--no-web", 8)) no_web = TRUE;
 	}
 
 #ifdef SELFEXE_WINDOWS
@@ -1392,7 +1394,7 @@ int main(int argc, char *argv[])
 	}
 #endif
 
-	te4_web_load();
+	if (!no_web) te4_web_load();
 
 	// Initialize display lock for thread safety.
 	renderingLock = SDL_CreateMutex();
diff --git a/src/web.c b/src/web.c
index 66e22cf31d..a44a1d666b 100644
--- a/src/web.c
+++ b/src/web.c
@@ -577,6 +577,18 @@ void te4_web_load() {
 	printf("WebCore config: library(%s) spawn(%s)\n", libname ? libname : "--", spawnname ? spawnname : "--");
 	printf("Loading WebCore: %s\n", web ? "loaded!" : SDL_GetError());
 
+#if defined(SELFEXE_LINUX) || defined(SELFEXE_BSD)
+	// Hack to fix a strange bug when it fails to load the library on some linux version it core dumps. So we restart a new process and tell it to not even try
+	if (!web) {
+		char **newargs = calloc(g_argc + 2, sizeof(char*));
+		int i;
+		for (i = 0; i < g_argc; i++) newargs[i] = g_argv[i];
+		newargs[g_argc] = strdup("--no-web");
+		newargs[g_argc+1] = NULL;
+		execv(get_self_executable(g_argc, g_argv), newargs);
+	}
+#endif
+
 	if (web) {
 		webcore = TRUE;
 		te4_web_setup = (void (*)(
-- 
GitLab