Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / extension.md
Last active January 6, 2021 14:57
GameScript identities

This is meant as extension on: https://wiki.openttd.org/en/Development/Design%20Drafts/Scripts/Capability-based%20API

In addition to having capabilities, GS would benefit from being able to instantiate controllers for certain objects.

For example, take a town. Currently either a GS controls all towns or it doesn't. By adding capabilities, as written in the wiki, it can either share all towns with other GSes or keep them all for him self. I would propose a more fine-graned method: instances.

Every GS has a function like: HasInstanceFor(capability). As example: HasInstanceFor(TownGrowth). The GS either returns 0 if it has nothing for this capability, or N with N > 0 for how many different forms it has for this instance. Next, OpenTTD adds up all the Ns, picks a random number in range, and selects that GS + index to handle that town now forths. For example: GetInstanceFor(TownGrowth, 2).

@TrueBrain
TrueBrain / workflow.md
Last active February 2, 2021 18:44
Title game competition
  • Organiser announces title game competition, and give an end-date for entries.
  • After end-date, organiser adds all savegames + metadata to git repo (say, OpenTTD/title-game-competition).
  • GitHub Actions generates the required screenshots + Markdown for it, and publishes this in another branch (say, "output"), which is published via GitHub Pages (read: available via https).

  • Organiser creates a "QA" Discussion thread for Title Game Competition.
  • Each entry will be its own reply.
  • People can upvote the reply if they like it.
  • After closing, we have a winner.
@TrueBrain
TrueBrain / redesign.md
Last active February 13, 2025 18:41
OpenTTD UI redesign

Intro

image

New game

image

New game - Advanced

@TrueBrain
TrueBrain / integration.md
Last active March 26, 2023 14:50
Steam / Discord integration (Rich Presence)

To start with, few things to keep in mind:

  • I am not a lawyer.
  • Neither are you.
  • 1000 people 1000 opinions; this is not so much about opinions, but about facts, options, and risk.
  • I did a morning of searching the web to gather this information, just so we have something to talk about. To bring this a bit more into facts rather than opinions we all have on what GPL is and isn't :D

Problem description

With us going to Steam, the request for Steam integration has increased.

@TrueBrain
TrueBrain / network-todo.md
Last active August 10, 2021 20:13
Network TODO list

GC = Game Coordinator

Cleanup

  • ✓ Server name not empty (or default to "playername's server"?)

Client Info

  • 9114 Add GAME_INFO to TCP and use it for lobby
  • 9469 Sync NetworkGameInfo from server with all clients, so clients locally know the server they are on (and sync servername changes when they happen); possibly only sync information client doesn't already know via a Command packet.
  • 9469 Show server name in GUI