OpenTTD-patches/os/emscripten
Patric Stout 69118d063f
Change: use TCP for everything except for master-server and initial server scan (#9130)
This means that pressing Refresh button and adding servers manually
now uses TCP.

The master-server and initial scan are still UDP as they will be
replaced by Game Coordinator; no need to change this now.

If we query a server that is too old, show a proper warning to the
user informing him the server is too old.
2021-04-30 11:34:47 +02:00
..
cmake
Dockerfile
emsdk-liblzma.patch
loading.png
pre.js Change: use TCP for everything except for master-server and initial server scan (#9130) 2021-04-30 11:34:47 +02:00
README.md
shell.html

How to build with Emscripten

Building with Emscripten works with emsdk 2.0.10 and above.

Currently there is no LibLZMA support upstream; for this we suggest to apply the provided patch in this folder to your emsdk installation.

For convenience, a Dockerfile is supplied that does this patches for you against upstream emsdk docker. Best way to use it:

Build the docker image:

  docker build -t emsdk-lzma .

Build the host tools first:

  mkdir build-host
  docker run -it --rm -v $(pwd):$(pwd) -u $(id -u):$(id -g) --workdir $(pwd)/build-host emsdk-lzma cmake .. -DOPTION_TOOLS_ONLY=ON
  docker run -it --rm -v $(pwd):$(pwd) -u $(id -u):$(id -g) --workdir $(pwd)/build-host emsdk-lzma make -j5 tools

Next, build the game with emscripten:

  mkdir build
  docker run -it --rm -v $(pwd):$(pwd) -u $(id -u):$(id -g) --workdir $(pwd)/build emsdk-lzma emcmake cmake .. -DHOST_BINARY_DIR=$(pwd)/build-host -DCMAKE_BUILD_TYPE=RelWithDebInfo -DOPTION_USE_ASSERTS=OFF
  docker run -it --rm -v $(pwd):$(pwd) -u $(id -u):$(id -g) --workdir $(pwd)/build emsdk-lzma emmake make -j5

And now you have in your build folder files like "openttd.html".

To run it locally, you would have to start a local webserver, like:

  cd build
  python3 -m http.server

Now you can play the game via http://127.0.0.1:8000/openttd.html .