ComputeryLib


About a week ago I started working on my TABG server mod again. (All my mods for modern Tabg can be found here: https://github.com/C0mputery/ComputerysTabgMods). Originally, like a year ago, ComputeryLib started as a mod made to replace the standard library mod CitrusLib. The reason for this is that CitrusLib is straight garbage: haphazard patches that don’t really take into context the entire game other mods that would depend on it, abysmal modding practices, and general disregard for any semblance of sensible software engineering. Only reason it was really used is because it provided commands along with some other helpful utilities to make people’s lives a bit easier, but Citrus was not the right person to be making this mod. The only reason it happened this way is that they had access to the server software as part of a closed beta before the rest of the community was given access. Obviously, some of the fault is on landfall for having such horribly written servers, but the community fumbled pretty bad by making that the de facto mod that everything relied on. Rule of thumb: read the code of the mods you’re depending on.

So let’s first cover what I implemented a year ago before talking about what I implemented in the last week:

  • Bug and Security Fixes
    • Packet handling fundamentally flawed:
      • Landfall, in their infinite wisdom, does not try catch within the loop where they handle packets, meaning that if a client sends a malformed packet, it throws that entire thing, and until the next full update loop gets back to it, it won’t handle any more packets. This also has the side effect of never disposing of the packet, meaning that it causes a memory leak. (note with the update loop thing, the dedicated servers are Unity dedicated server builds, so it’s using the entire Unity engine)
    • Servers not using the relay could not properly restart after the match had ended:
      • Landfall broke this in one of the updates for the dedicated server. They just didn’t set a value to null so some of their logic broke. Can’t blame them too much for this. The unity and nullability is bad.
    • Half-assed quantum entangling fixes
      • Partly fixes a bug where I think it allows the client to join the server twice, leading to the server getting confused and the client thinking that it’s a different player ID. This fix, unfortunately, doesn’t solve the root problem. It just stops the symptom of quantum entangling. It’ll add in the player and they will just never move at all, because all of their packets are for a different player ID.
  • Chat Commands
    • A replacement for the citrus lib solution that rather than having a cluncky registration system is done via attributes. Had help, start, set level.
  • TUI & Pipe System (scapped in my changes)
    • Allowed for users of the server to actually interact with it while running, kind of like a Minecraft server console was pretty jank, so I ended up scrapping it later. I might introduce something similar to what other people in the community are doing, where your game launches a web server that you can access via a browser to replace this.
  • Misc Changes
    • Removes a bunch of places where unnecessary information was constantly written to the log file for no good reason.
    • Cleans up the log output so that it’s actually readable
    • Fixes compatibility problems between the log output and Bepinex’s logs
    • Comprehensive visitor log that uses a method I discovered for pulling Steam IDs from Playfab IDs via the leaderboard. Logs everything about a user that could matter and logs it over time. For moderation.
    • Other than that, a bunch of various utilities for people who would be depending on it.

Over the past year, I finally finished up Rehabg for the most part (blog post eventually), I gained significant amounts of knowledge on the way that TABG internals work, and that made it so that I could move much faster now.

In regards to dev speed, I think it’s important to mention and disclose my LLM usage.

I do use LLMs in my programming work, but I don’t think they write good code (By the metrics that I consider important: the trifecta of maintainability, performance, and functionality (I should also write a blog post on my philosophy of software engineering)) All of the code in ComputeryLib has been read by me and is understood by me, not every single thing has been written by me in the sense of handwriting every line. Commits like 1a139fbea0 - slop fix for PrivateMessage and 9e6b2d9cda - EnetConnectionFixes also slop heavy (Shortly followed up by 21d810a10c - slop heavy stuff had issues who could have guessed lol), I try my best to annotate Where I believe that things are too LLM heavy. All of those are instances where I knew the problem, I did not want to write the problem’s solution. So I told the LLM what I wanted written. Came down to laziness. I try to keep problem solving entirely on my end so that I don’t atrophy on that skill (Is that still a valuable skill? 🙃). Along with this, I also do use LLMs for review as well as finding things in the codebase. The way I see review for coding is that 9 out of 10 times it doesn’t find much of great significance, and that 1 out of 10 times it makes up for all of that because I’ve learned something new. For example, this is how I learned about [HarmonyPrepare], a way for conditionally toggling patches based on your own code. Just did not have that knowledge beforehand. Now that I do, I use it everywhere. LLMs are also fast at exploring a code base to do very fuzzy searching effectively. For example, Tabg has a spaghetti codebase. It’s hard to find stuff in it If I ask an LLM to Where do remote players reload visually on a local client, and what are possible reasons for them reloading when they pull out new weapons? Good chance it’s going to respond with something that’s somewhat accurate and correctly point out the places where that visual reload could happen. Where I can then go read the code and actually get an understanding in significantly less time than having to troll through the DnSPY. With that exact example, I read through the stuff, I deemed it to be entirely impossible to block the reloading bug that happens for players pulling out their weapons, and again, I don’t think there’s a good reason to not ask the LLM for what are your possible thoughts on how this could possibly be fixed. So that’s what I did. Most of the time, it won’t come back with anything I haven’t thought of. This time, brought up the client-side solution, as well as a very small note on that you could possibly just block the remote players from ever having any ammo types in your local client’s inventory server side. I didn’t think of this, and that pisses me off. I went and actually implemented that in the correct way because its suggestion was subtly wrong, but the fundamentals behind it were sound. At some point, I plan to write a blog post covering my stance on AI in The games development industry or maybe the modding scene. For example, purely vibe-coded slop mods made by clueless people have done irreparable damage to modding communities, it’s awful. I think it’s a topic that requires nuance to actually discuss and can’t be summed up within a single paragraph, let alone a tweet, gut reaction, or vibe.

Now, the current state of the project:

  • Bug and Security Fixes
    • Packet handling fundamentally flawed
    • Servers not using the relay could not properly restart after the match had ended
    • Quantum entangling fixes
      • Fully fixed by disconnecting any clients that get into the bad state
    • Player ID allocation now works correctly:
      • Across both the transport and ENet, if a player leaves, it frees up that ID now.
    • Server ending now disconnects players
      • Before it would just wait for the clients to time out this was bad for restarts.
    • The ring no longer spams start moving packets every frame after its done.
    • respawning clears skydiving state
    • Makes the server on the transport use the client fragmentation capacity
      • Basically, Landfall configured the server to have a fragmentation capacity of 80,000 while the client only has 20,000. This leads to silently dropping packets server-side if they’re too large
    • Fixes packets being dropped when too much stuff gets sent to a single client
      • The transport has a limit of 64 reliable packets at once, we hold on to them in our own buffer if there’s not enough space and send them after. This alone just fixes so many of the problems with the relay
    • Fixes the chunk entry packet in a lot of different ways
      • Landfall quadratically scales the number of bytes allocated in the buffer for the amount of players that are in the chunk for no reason. Then that entire buffer of mostly just zeros is sent over the network. So first they take the total number of bytes they’re going to need to allocate for all of the player’s gear, and then they use that number multiplied by 4 in how much each player needs for just their gear, and then they multiply how much each player needs by the number of players. If you’re entering a chunk with 11 players, that’s over 20,000 bytes, and you have broken the relay!
      • We break up loot across multiple packets on the relay so that it won’t hit the 20,000 byte limit
      • By default, we sort the loot order sent to the client by distance from the player so that it loads in a little faster.
      • Only send the chunk enter packets to players who are actually seeing them enter their view rather than all of the players who might have already been able to see them.
    • Desync Fixes:
      • Resends loot removals every handful of seconds for a bit after loot gets picked up to hopefully curb certain ghost items
      • Non-weapon pickups from other players get loot removed rather than the weapon pickup packet so that no ammo or anything else gets put into their inventory this stops the reload on weapon pullout bug. As covered before, I didn’t think of this and I’m pissed about it. LLM discovered fix.
      • Sending blessing updates after chunk entry because the player chunk entered packet only puts blessings in the first slot. This fixes blessings not showing up, meaning stuff like max health desync is basically non-existent.
      • Fix trade based desync downs. If you try to attack a player and kill them after you’ve died, we send a revive packet back to your client so that the player is no longer desynced on your screen.
      • Configurable time after somebody’s been hit to make self-damage attributed to the last valid other player. This is a patch for stuff like rapier alt fires that don’t properly attribute kills.
      • Fixes playfab not getting sent to the client on community servers. Along with this, it also sends this data over time as to not hit the client-side rate limit. Meaning that very reliably, everybody’s catchphrase, chat throwable, and gangster mode will load in.
    • Anti-cheat-ish
      • Blocks duping and kills players who equip blessings that they don’t have
  • Chat Commands
    • help, start, list, give, setlevel, kick, ban, broadcast.
  • Adds mid-match joining support
  • Misc Changes
    • A lot more, mostly for devs.

If you’re someone making server mods, send me a message on Discord. I’m happy to provide whatever support you need within reason, obviously. This mod is not compatible with either StarterPack or CitrusLib because they were awfully made.