Skip to content

Instantly share code, notes, and snippets.

@TrueBrain
TrueBrain / network-improvements.md
Last active December 23, 2020 14:04
OpenTTD Network Improvements

Phase 1 - Add crypto

  • Add crypto library to OpenTTD
  • Generate a single crypto-based unique identifier on clients
  • On joining the server, the client gives the server his crypto-based unique identifier
  • The server challenges the client to validate he is the owner of this crypto-based unique identifier
  • On creating a new company, the server adds the unique identifier to the access list of the company
  • On joining a company, before a password is asked, the server checks if you are on the access list of the company, and lets you in passwordless if you are
  • The crypto-based unique identifiers who have access to companies are stored in the savegame
  • Reloading a savegame on the same server keeps the access list intact
@TrueBrain
TrueBrain / proposal-milek7.md
Last active December 19, 2020 22:10
OpenTTD multiplayer

Decentralized local authentication

Use a public key (pubkey) / secret key (secret) to authenticate yourself with the server. At login, you authenticate yourself to the server. If you protect your company, this is done based on your pubkey. This means that only you with the correct secret can still join that company.

A server stores this pubkey in the savegame, to make company protections survive restarts.

Server sharing pubkeys

@TrueBrain
TrueBrain / change_x_to_u.py
Last active December 14, 2020 18:49
Replace \x escape in C-strings to \u escape
import re
import sys
def replace_utf8(match):
char = match.group(0)
char = chr(int(char[2:4], 16)) + chr(int(char[6:8], 16))
char = char.encode("raw_unicode_escape").decode()
char = char.encode("unicode_escape").decode()
char = char.replace("\\x", "\\u00")
@TrueBrain
TrueBrain / Dockerfile
Created December 8, 2020 20:16
Emscripten + LZMA
FROM emscripten/emsdk
COPY emsdk-liblzma.patch /
RUN cd /emsdk/upstream/emscripten && patch -p1 < /emsdk-liblzma.patch
@TrueBrain
TrueBrain / nullptr_addition.patch
Last active December 4, 2020 21:10
News crash fix
diff --git a/src/news_gui.cpp b/src/news_gui.cpp
index a3f73d729..055979951 100644
--- a/src/news_gui.cpp
+++ b/src/news_gui.cpp
@@ -255,7 +255,7 @@ NewsDisplay NewsTypeData::GetDisplay() const
uint index;
const SettingDesc *sd = GetSettingFromName(this->name, &index);
assert(sd != nullptr);
- void *ptr = GetVariableAddress(nullptr, &sd->save);
+ void *ptr = GetVariableAddress(&_settings_game, &sd->save);
@TrueBrain
TrueBrain / features.md
Last active November 26, 2020 20:26
IRC Bot

Supported features

GitHub

  • GitHub event -> announcements (via .dorpsgek.yml)

User

  • User registration via Pull Request
  • Hostname to "auto" identify (especially in combination with NickServ and *.user.oftc.net a simple way for anyone to identify)
  • Channel permissions via Pull Request
@TrueBrain
TrueBrain / index.js
Last active September 18, 2020 21:18
grfsearch.openttd.org
'use strict';
const querystring = require('querystring');
exports.handler = (event, context, callback) => {
var request = event.Records[0].cf.request;
const params = querystring.parse(request.querystring);
var redirect_uri = '/index.php';
def func_00821b():
if False: yield
lda8((Pointer((cpu.dh << 8), 0xff, 0x13)) if (cpu.flag_e and cpu.dl == 0) else (Pointer(0, 0xffff, cpu.d + 0x13)))
sta8(Pointer(0, 0xffffff, (cpu.dbr << 16) + ((0x2100) & 0xffff)))
lda8((Pointer((cpu.dh << 8), 0xff, 0x9b)) if (cpu.flag_e and cpu.dl == 0) else (Pointer(0, 0xffff, cpu.d + 0x9b)))
sta8(Pointer(0, 0xffffff, (cpu.dbr << 16) + ((0x420c) & 0xffff)))
rep(0b00110000)
plb8()
pld16()
ply16()
@TrueBrain
TrueBrain / legal-entity.md
Last active November 10, 2023 14:48
Signing binaries and getting on Steam
@TrueBrain
TrueBrain / binaries-overview.txt
Last active April 11, 2020 13:23
Overview of binaries.openttd.org and related domains
(some parts allow HTTP, instead of redirecting HTTP to HTTPS, because the OpenTTD client cannot use HTTPS)
HTTP+HTTPS binaries.openttd via ALB
/bananas -> forwarded ECS openttd/content-server
/installer -> redirect 301 installer.cdn.openttd.org
HTTPS binaries.openttd via ALB
/bananas -> 404 (files changed to md5-name)
/binaries -> redirect 301 cdn.openttd.org
/extra -> redirect 301 cdn.openttd.org