Mechanica Multiplayer Fix banner

Mechanica Multiplayer Fix

3 devlogs
7h 32m 20s

A BepInEx mod for the game Mechanica (a survival and programming game abandoned during development, still unstable) that fixes multiplayer to make it playable.

Oignon

Seems I’ve fixed the infinite loading issue!


BUT, because why not, I found more major bugs. Most are fixed, but one is a real wall:

Under unknown conditions, the host gets timed out from their own server. I’ve ensured that if the server cuts out, clients now return to the menu with an error message. The base game didn’t handle this, leaving everyone stuck on infinite loads—mind-blowing, since handling connection loss is Networking 101.


Problem is, I can’t find the cause of the host timeout yet. Limited tester availability and the bug’s random nature are slowing me down.


Other issues: Laser Triggers are totally desynced 🤷, and conveyor belts are broken even in solo…

List of fixes/patchs applied:

  • Fix #12: Simplified (removed the code causing HarmonyX warnings)
  • Fix #13: Computer.ReceiveVirtualFunctionExecute() - Checks bounds before access
  • Fix #14: Computer.ReceiveVirtualEventInvoke() - Checks bounds
  • Fix #15: Computer.ReceiveVirtualObjectDestroy() - Checks bounds
  • Fix #16: ObjectManager.ApplyAllGUS() - Absorbs NullRefs during shutdown
  • Fix #17: Automatic recovery and menu return if the server crashes or disappears.
  • Fix #18: Proper disconnection handling (prevents infinite loading and shows clear error reasons).
  • Fix #19: Improved stability and error prevention for Spline/Curve calculations.
  • Fix #20: Added safety nets to prevent crashes during control point processing.
  • Fix #21: Final security layer to catch remaining errors in curve refreshing.

Sorry for the random image, I didn’t really have any ideas for a proper illustration for this devlog.

Attachment
0
Oignon

I wrote a Python script to check the date format in the save files to see if they’ve been patched by the mod

Attachment
0
Oignon

The main issue with Mechanica’s multiplayer is the infinite loading when a player joins a game that has already been created.

I conducted extensive tests and collected logs to identify the causes of this problem. I decompiled the game code and used profiling tools to pinpoint failure points.

This allowed me to discover several major issues, some of which were much harder to identify than others. So far, I have identified and theoretically fixed 12 problems, ranging from simple precautions to logging improvements to help identify new issues in the future.

I also wrote a PowerShell build script to automatically compile the mod and update it in the game.

The patches I applied are as follows:

  1. Date reading issue

    • Fixed saved dates with incompatible formats between players.
  2. New game creation issue

    • Corrected date formats when creating new games.
  3. Save sorting issue

    • Fixed incorrectly sorted saves caused by invalid date formats.
  4. Corrupted lobby data

    • Prevented crashes caused by corrupted Steam data.
  5. Inventory loading issue

    • Prevented crashes when loading inventories with invalid Steam IDs.
  6. Network errors

    • Logged network errors without interrupting sessions.
  7. Premature disconnection

    • Blocked unintentional disconnections when the game is not paused.
  8. Lobby transition issue

    • Prevented UI crashes during lobby state changes.
  9. Lobby refresh issue

    • Prevented crashes during lobby UI refreshes.
  10. Lobby connection issue

    • Prevented crashes when attempting to join a lobby.
  11. Player connect/disconnect issue

    • Prevented crashes during player connection or disconnection events.
  12. Disconnection without saving

    • Logged and validated premature disconnections.
Attachment
0