Jump to content
  • Power.dat overwritten with empty file when server is shutting down during restart.


    I will keep this short since it doesn't need any further explaination.


    The game overwrites the power.dat when shutting down before loading the original power.dat resulting in an empty file for next server start making all wires and items form elec. blocks disappear.

    You can fix this by simply adding a global flag when the power.dat was loaded/created and not letting the game writing it when it's not set.



    https://steamcommunity.com/app/251570/discussions/1/3191364450207680233/ (This is from 2018)


    User Feedback

    Recommended Comments

    I can also confirm this bug, and was kinda hoping, given the easiness of the fix, that TFP would have come up with that fix by now instead of having to do it myself (again) ...






    To reproduce it you simply need to `Alt+F4` quit the game when it starts loading stuff.

    I have added some log messages here with harmony to better see what is going on.
    I've hit `Alt+F4` when `shapes` were loading and last warning is from my mod (rest is cut).


    116.295 INF StartAsServer
    116.734 INF Set Microsplat diffuse: MicroSplatConfig_diff_tarray (UnityEngine.Texture2DArray)
    116.734 INF Set Microsplat normals: MicroSplatConfig_normal_tarray (UnityEngine.Texture2DArray)
    116.734 INF Set Microsplat smooth:  MicroSplatConfig_smoothAO_tarray (UnityEngine.Texture2DArray)
    116.762 INF Loaded (local): materials
    116.789 INF Loaded (local): physicsbodies
    116.806 INF Loaded (local): painting
    116.924 INF Loaded (local): shapes
    119.803 INF Preparing quit
    119.803 INF Disconnect
    119.803 INF [NET] ServerShutdown
    119.803 INF NET: Stopping server protocols
    120.133 INF NET: LiteNetLib server stopped
    120.134 INF [EOS-P2PS] Server stopped
    120.134 INF SaveAndCleanupWorld
    120.134 INF [Steamworks.NET] Stopping server
    120.134 INF [Steamworks.NET] Exiting Lobby
    120.216 WRN No culture info found for given name: cultureInfoName
    120.218 WRN No culture info found for given name: cultureInfoName
    120.218 INF [MODS] Loading localization from mod: OcbRemoteTurretControl
    120.219 WRN No culture info found for given name: cultureInfoName
    121.227 INF Clearing queues.
    121.227 INF Cleared queues.
    121.227 INF Clear LOD Disabled Prefabs
    121.227 WRN Saving PowerDat without loading it first!?


    Given that scenario it is also highly possible that this issue is also triggered when the game can't successfully load any of the xml configs due to issues introduced by mods.


    For completeness I will also give a detailed explanation what is going wrong in the code.

    The following is happening on the server initialization (where the correct loading happens).


    yield return (object) null;


    In GameManager we have the following initialization:

    This is actually called before any game loads!

    if (PowerManager.Instance != null)


    Unfortunately the "Instance" Field is a getter:

    public static PowerManager Instance
            if (PowerManager.instance == null)
            PowerManager.instance = new PowerManager();
            return PowerManager.instance;


    Meaning the check PowerManager.Instance != null will happily create the singleton instance on itself. Seems highly unwanted given the semantics of that check. So either fix that initialization fiasco or add a proper check to the save method to only overwrite power.dat if properly initialized.

    Link to comment
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

  • Create New...