Navigation
Browse the developer docs

FH2 Mod Platform for .NET

GameDb

Rewrite the game's database queries and answer string lookups while it runs.

By Bartholomew Ho (qiangqiang101) · MIT license · v0.12.0 · 15 Nov 2026 · repository · original page

On this page

The game's database and string lookups while it runs: rewrite the SQL the game sends to gamedb, and answer string keys no string table has. With Mod.AddSql (new rows) and Mod.SetFile (icons), these make a custom upgrade part, as FnFNitro's NOS kit and FH2 Underglow's kit are made.

New in 0.12.0. ⚠️ Not tested in the game yet.

Thread: add and remove from any thread. Your functions run on whichever thread the game asked from, often the game's own.

Example

protected override void OnInit()
{
    // a part of our own, in rows added with AddSql, named through a string key no table has
    GameDb.AddStringAnswer((table, key) => key == 60001 ? "Turbo kit" : null);
    // and a query seen (or changed) as the game runs it: null leaves it as it is
    GameDb.AddQueryRewriter(sql =>
    {
        if (sql.Contains("Profile0_Career_PurchasedParts")) Log(sql);
        return null;
    });
}

Members

MemberWhat it does
AddQueryRewriter(Func<string, string?> rewriter)Gets each SQL statement the game runs on gamedb and gives back the one to run instead, or null to leave it.
RemoveQueryRewriter(Func<string, string?> rewriter)Stops it.
AddStringAnswer(Func<int, int, string?> answer)Gets the table (as the game numbers it while it runs) and the key of a string the game looked up and found nothing for, and gives back the text, or null.
RemoveStringAnswer(Func<int, int, string?> answer)Stops it.

Notes

  • Every query goes through your rewriter, often many a frame in the garage. Keep it fast, and give back null for the ones you leave alone.
  • A string answer is only asked for when the game found nothing, so use keys the game doesn't have.
  • The hooks go in the first time you add one. The database query is found a moment after the game starts; until then statements run as they are.
  • A hosted mod's functions go when it's reloaded.
  • For text the game already has, Mod.SetString edits the string tables instead. For text in every language, see Translations.

See also

Copied from the wiki page GameDb at commit 7396a07 · MIT license
MIT License

Copyright (c) 2026 Bartholomew Ho

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.