Jump to content
Null 45

SC4 Auto Save - a DLL plugin that saves a city at user-specified intervals

11 posts in this topic Last Reply

Highlighted Posts

Posted:
Last Online:  
 

A DLL Plugin for SimCity 4 that automatically saves a city at user-specified intervals.

This auto-save plugin does not require any launcher and will work with any digital Windows version of the game, Steam, GOG, etc. The disc-based versions are not supported due to the fact that they are incompatible with Windows 10.

If you use a 3rd-party launcher that has its own auto-save setting you will need to disable that option when installing this plugin.

Download: https://community.simtropolis.com/files/file/35761-sc4autosave/

Source Code: https://github.com/0xC0000054/sc4-auto-save

System Requirements

    Windows 10 or later

Installation

    Close SimCity 4.
    Copy SC4AutoSave.dll and SC4AutoSave.ini into the Plugins folder in the SimCity 4 installation directory.
    Configure the auto-save settings, see the Configuring the plugin section.

Configuring the plugin

    Open SC4AutoSave.ini in a text editor (e.g. Notepad).
    Note that depending on the permissions of your SimCity 4 installation directory you may need to start the text editor with administrator permissions to be able to save the file.

    Adjust the settings in the [AutoSave] section to your preferences.

    Save the file and start the game.

Settings overview:

IntervalInMinutes is the number of minutes that elapse between auto-save attempts, defaults to 15 minutes. Note that the save timing may not be exactly this value depending on what the game is doing. For example, auto-save is disabled when the game is paused.

FastSave controls whether the game skips updating the region thumbnail when saving, defaults to true. With this option enabled the save operation is equivalent to the Ctrl + Alt + S keyboard shortcut, when disabled it is equivalent to the Ctrl + S keyboard shortcut.

IgnoreTimePaused controls whether the time the game spends paused is ignored when counting towards the next auto-save point, defaults to true.

LogSaveEvents controls whether the save events for the current session will be written to the log file, defaults to true.


Troubleshooting

The plugin should write a SC4AutoSave.log file in the same folder as the plugin.
The log contains status information for the most recent run of the plugin.

  • Like 3
  • Thanks 1

Share this post


Link to post
Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    6 hours ago, nos.17 said:

    Thank you for this. I can confirm it works with the Steam version.

    Thanks for confirming that. I expected that it would work with any Windows digital distribution of the game. I decided against trying to support the disc-based versions and pre Windows 10 operating systems as I had no way to test it. But in theory the DLL should work on those platforms if recompiled with the correct options.

    Does the Steam version use its own launcher? I assume it does as that is how most games on that platform work.

    Finally, are there any features that I missed?

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    9 minutes ago, Null 45 said:

    Thanks for confirming that. I expected that it would work with any Windows digital distribution of the game. I decided against trying to support the disc-based versions and pre Windows 10 operating systems as I had no way to test it. But in theory the DLL should work on those platforms if recompiled with the correct options.

    Does the Steam version use its own launcher? I assume it does as that is how most games on that platform work.

    Finally, are there any features that I missed?

    Steam pretty much is its own launcher I'd say. Adding a shortcut to desktop just points to steam://rungameid/24780. You can specify the command line parameters and other Steam-specific launch options in a menu they provide.

    I'm probably not the best person to comment on this as I hardly play the game other than to test, but I think it seems pretty comprehensive. The only thing I would have been wanting is a customizable save duration, and you've nailed that. Also kudos for the documentation - simple but effective.


    Looking for a prop or texture? The SC4 Prop & Texture Catalog might help! View online here.

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    25 minutes ago, nos.17 said:

    I'm probably not the best person to comment on this as I hardly play the game other than to test, but I think it seems pretty comprehensive. The only thing I would have been wanting is a customizable save duration, and you've nailed that. Also kudos for the documentation - simple but effective.

    I also only play the game to test mods, I only recently reinstalled it after years of not playing to work on DLL mods. I already posted on SC4E that I am a much better programmer than a mayor. It wouldn't be an EA game without the glitches, crashes, and occasionally freezing so badly that you need to kill it in task manager. *:)

    I had considered posting this plugin as a beta due to being unsure if I missed anything feature or gameplay related. But I decided that it was working well enough for a stable release.

    • Yes 1

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    Release version 1.1.0. Changes:

    • Make the auto-save checks independent of the simulation speed.
    • Changed the log output timestamp to use the local system time.
    • Fixed the DLL description.

    I also added a note to the system requirements about the possible compatibility with Windows 7.

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    The plugin produces unintended behaviors. 1) A save will be made when a UI element, such as the exit prompt, is open that normally disallows interaction with the city or other UI elements. 2) A save will be made while the game is minimized.

    The unmodified game disallows saving in such cases. Based on testing, 1 is harmless*. and while 2 has yet to produce a corrupted city, SimCity 4 has a well documented history of corrupting cities when focus is lost while saving, and could well do the same if focus is forced back onto it during a save.

    *: Although there is the potential of shenanigans if one manages to save or exit a city at the same time the plugin attempts a save. Testing this has proven difficult.

    Question: What was your reasoning behind hooking into the save routine instead of sending keyboard shortcuts?

    • Like 1

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    8 hours ago, xnight34 said:

    Question: What was your reasoning behind hooking into the save routine instead of sending keyboard shortcuts?

    It was easier to have the DLL directly call the game's save routine than trying to inject keyboard shortcuts.

    The DLL already disables saving if the game is paused, etc. SC4 has a few methods that appear to be intended to temporarily disable saving a city, but they don't appear to be used.

    It should be fairly simple to add checks that no modal dialogs are active and that the game has focus.

    • Yes 1

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    Interesting. It was thought the opposite was true, where directly calling the save routine was the harder road to hoe. I am glad to have asked. Your response is appreciated, and thank you for accepting my feedback.

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    3 hours ago, xnight34 said:

    It was thought the opposite was true, where directly calling the save routine was the harder road to hoe.

    For an external launcher, sending keyboard shortcuts to SC4 is the only way an auto-save feature could work.

    It took a long time for SC4 DLL modding to become a reality, and writing one can be complex. But it offers a lot more control than any external launcher could have. For example, I don't think there is any way that an external launcher could have its auto-save timer ignore the time the game spends paused. This auto-save DLL mod has that option.

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    Release version 1.2.0. Changes:

    • Disable auto-save when a modal dialog is active.
    • Disable auto-save when the game is not the foreground application.
    • Reduce CPU usage when the game is paused.

     

    • Like 1
    • Thanks 2

    Share this post


    Link to post
    Share on other sites

    Sign In or register to comment...

    To comment in reply, you must be a community member

    Sign In  

    Already have an account? Sign in here.

    Sign In Now

    Create an Account  

    Sign up to join our friendly community. It's easy!  

    Register a New Account


    ×

    Thank You for the Continued Support!

    Simtropolis depends on donations to fund site maintenance costs.
    Without your support, we just would not be in our 24th year online!  You really help make this a great community. *:thumb:

    But we still need your support to stay online. If you're able to, please consider a donation to help us stay up and running. This helps sustain a platform where we can share our community creations for years to come.

    Make a Donation, Get a Gift!

    Expand your city with the best from the Simtropolis Exchange.
    Make a Donation and get one or all three discs today!

    STEX Collections

    By way of a "Thank You" gift, we'd like to send you our STEX Collector's DVD. It's some of the best buildings, lots, maps and mods collected for you over the years. Check out the STEX Collections for more info.

    Each donation helps keep Simtropolis online, open and free!

    Thank you for reading and enjoy the site!

    More About STEX Collections