2020/06/26 - games
I’ve been trying to improve the performance of this engine. It does a few things that I couldn’t stand for anymore. It restarts the file system too many times when starting a server. That was a pretty easy fix to comment out a few lines pointing to
FS_Restart(). The engine also restarts the renderer a few times. This is because while games are loading, shaders could be inserted that might allow the player to wallhack. I’ll just comment this out for now, so the renderer only starts once, and then add an in memory check for shader names, for security, later.
I’ve made various bug fixes. A few keys weren’t registering. Sound starts the first time the user clicks on the page. I added Offline mode! This is great, now if you visit the page quake.games at least once, all the content you need to run the game will be cached and you can use the same page offline. Just visit quake.games in offline mode, or airplane mode and it will load the previously downloaded version. This is very similar to an instant app if you save a shortcut on your homescreen.
I had to reorganize a bunch of file system code to get web-workers to work with Emscripten. That was a huge pain. Emscripten isn’t hugely intuitive and I am considering removing it and just keeping a few system calls that the game needs. I moved the local server into a web-worker. Part of the motivation for this was to reduce the CPU usage on the main thread, by about 15%. So when you start a local game, you are actually connecting to a web-worker with
set dedicated 1. This is great because I can use the local server to do things like instant replays, and set up some kind of synchronization between multiple remote servers. I could seamlessly transition between a live multiplayer game and a demo.
I’ve had the opportunity to explore the Discord API. Now, someone can launch a new match using a Discord Bot. All they have to write is
challenge @megamind, and use a mention for any users. The bot then waits for a
:thumbsup: reaction and launches a new server. It actually selects an empty server from a pool of servers waiting around, but I plan to reduce the idling even more by launching servers using a proxy service. It would be pretty easy for someone to donate an empty server, all they have to do is
+set sv_master1 22.214.171.124 and it will show up in the pool if there is no one connected.
I got this Huffman decoder working, but I am not sure it is being used by the server, so I took it out. My next coding adventure will be continuing to hack on this web-worker net-separated server code. I would like to pull in this multi-view code from Cyrax, and combine it with my previous multi-world work. Then I would like to divide up a
.BSP map into sections, and have a client switch instantaneously. The server could tell the client which part of the map to load first, spawn the player, then load the rest of the map in a worker or background thread. Unfortunately, there will still be frame drops because OpenGL web workers are only supported in Chrome. But I hope by splitting up maps into smaller pieces, it will not be very noticeable.