summaryrefslogtreecommitdiff
path: root/src/network/network_content.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/network_content.cpp')
-rw-r--r--src/network/network_content.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/network/network_content.cpp b/src/network/network_content.cpp
index 5e401d3e9..0140d3ef2 100644
--- a/src/network/network_content.cpp
+++ b/src/network/network_content.cpp
@@ -23,6 +23,10 @@
#include <zlib.h>
#endif
+#ifdef __EMSCRIPTEN__
+# include <emscripten.h>
+#endif
+
#include "../safeguards.h"
extern bool HasScenario(const ContentInfo *ci, bool md5sum);
@@ -289,6 +293,13 @@ void ClientNetworkContentSocketHandler::DownloadSelectedContent(uint &files, uin
{
bytes = 0;
+#ifdef __EMSCRIPTEN__
+ /* Emscripten is loaded via an HTTPS connection. As such, it is very
+ * difficult to make HTTP connections. So always use the TCP method of
+ * downloading content. */
+ fallback = true;
+#endif
+
ContentIDList content;
for (const ContentInfo *ci : this->infos) {
if (!ci->IsSelected() || ci->state == ContentInfo::ALREADY_HERE) continue;
@@ -535,6 +546,10 @@ void ClientNetworkContentSocketHandler::AfterDownload()
unlink(GetFullFilename(this->curInfo, false));
}
+#ifdef __EMSCRIPTEN__
+ EM_ASM(if (window["openttd_syncfs"]) openttd_syncfs());
+#endif
+
this->OnDownloadComplete(this->curInfo->id);
} else {
ShowErrorMessage(STR_CONTENT_ERROR_COULD_NOT_EXTRACT, INVALID_STRING_ID, WL_ERROR);