Jump to content

3 Screenshots

About This File

This is a mod which visually alters the UI button labels for Save and Exit (and Save and Quit), to highlight the risk of using this one-step method. Two options are included.

The first option disables that choice completely. The second simply renames the buttons, but continues to perform the same function as before.

Buy me a coffee

 

Background Information

Regardless of how the save is initiated, the game writes out the city tile's game data which is in memory to the save file, along with updating neighbouring tiles. The potential problem can occur when using either of the and options (Save and Exit or Save and Quit).

Apparently Maxis never envisioned the sheer quantity of custom content many of us use today. When using either and option, the game code only allows a certain amount of time for the save to occur, before it proceeds to initiate the Exit or Quit. Should the save process not be completed when this happens, the save file will likely be corrupted.

Subsequent loading of a corrupted tile will either immediately crash to the desktop (CTD), or the whole city tile will be missing and show as a flat area in the region view.

 

Exceptions

Many times the one-step process is perfectly fine to use. Examples include when terraforming a region by hand, going through Mapper generated tiles to update the snapshot previews, or planting trees such as using the Flora Blast function. It's just the dangers of corruption become heightened when doing this for established cities with lots of development, and crucially featuring an abundance of custom content.

 

Purpose of this Mod

The idea is to discourage the one-step process for saving. My mod provides options to modify both the UI dialogs for saving, and changes the text shown on the buttons.

It does not save the game automatically, nor display any reminders to save.

By changing the appearance of the dialogs, this only intends to be a visual cue making this less desirable in normal circumstances.

 

Variations Included

There are 2 variations available. Pictured below are previews of each of the "Save and Exit to Region" dialogs. The same style is also done for the "Save and Quit" dialogs.

As follows:

Option A

SaveWarning-01_Disable_Exit_Quit.png

This is designed for those who wish to ensure they never accidentally Save and Exit. It completely prevents the button from being clicked out of habit. Regular direct saves (Ctrl+S) or clicking the Save Icon still work as they always have.

 

Option B

SaveWarning-02_Message_Button.png

This simply renames and styles the button as pictured. When clicking the top-most button highlighted in red, it still operates the standard function for saving and exiting just the same as always. It intends to be a visual clue so you're reminded of the potential risk.


Option A is the safest choice, since it's then not possible to trigger the one-step process for saving a tile. Option B is provided for those who are aware of the risks, but want a visual reminder each time when prompted at the save dialog.

 

Is the saving process changed?

No, not at all. Of course, there's still that potential risk for a city to become corrupted when saving with the direct one-step method. However, my mod alters nothing in the code with what the game's save routine does. In terms of functionality, it's still available when using Option B exactly how it is by default.

Option A prevents this from being triggered at all.

The recommended simple strategy is to make a habit of saving using the standard Save function. My mod merely encourages the use of such.

This can be done using the first button on the options panel at the bottom, or using the Ctrl+S keyboard combination. A confirmation dialog will appear after saving.

Upon clicking the button:

Save Button.png

A dialog is shown like so:

City Saved Dialog.png


Once this appears, it's safe to click OK and proceed to exit or quit as the next step. If so for the 2nd step after saving, you then select either Exit Without Saving or Quit Without Saving. (Remember you just saved it the regular way in the 1st step.)


Important Note  *:read:

It's worth mentioning how in any situation, switching focus from the game while saving is a very bad idea.

This is also known to result in city tile corruptions even if using the regular save and not exiting the tile.

So just remember to keep SC4 in view and not changing to another program (even if using Windowed mode). In other words, simply clicking another window removes focus from the game and has the potential to corrupt the save. Always wait for the save to complete before doing anything else.


Additionally, making regular full backups of your Regions folder is always a very wise idea. That way should you wish to restore a city in the event of issues occurring, or simply wanting to rollback to a previous instance for other reasons, it's a simple case of copying back individual named region subfolder (or the tiles inside).

See this topic for an overview of the basic process.

 

Installation

  This mod uses the standard process of installing SC4 content.


There are no dependencies.

Only ONE Option can be used at once. First choose either of the 2 available zip files when clicking the Download button.

Contained within each zip archive are the following:

Option A
SaveWarning_Disable_Exit_Quit.dat

Option B
SaveWarning_Message_Button.dat


Copy either of the above .dat files into your Plugins folder.


Hopefully this might prove useful. *:8)

 

Special Mention

A big thank you to  @CorinaMarie  for helping and supporting me with ideas for this project.

Cori has given valuable input on ways it should best be implemented, and also for encouraging me to finally get the mod dusted down, polished up, and released. *:)

 

  • Like 32
  • Thanks 6



User Feedback

Recommended Comments

Out of curiosity, what's the maximum time given in this particular case before the other routine takes over?

 

(Also, having something with a variable duration overridden by a fixed timer is a horrible idea to begin with. Why even code it that way?)

  • Yes 1

Share this comment


Link to comment
Share on other sites
5 hours ago, Wiimeiser said:

Out of curiosity, what's the maximum time given in this particular case before the other routine takes over?

I don't believe there is an actual fixed time limit as such, and instead the duration gets determined by the quantity of data being saved.

Depending on the size of the city tile and the number of objects inside, this uses up more system RAM. Running a city tile for a while and this accumulates as changes are made, and it's possible this gets swapped into memory in cycles. Then when saving, the game attempts to write this to file (which includes bordering tile references for neighbour connections). It will need longer and longer time to complete the more data there is to write from that stored in memory. Then having been instructed to exit the tile, the game can "bail out" before finishing the job in full.

Performing a regular Save (Ctrl+S) is recommended since this process cannot be interrupted until completion. The problems occur with the one-step process when the game exits the current tile to region, or quitting completely. Should this not fully write out the data, that's when problems will occur, and almost certainly making the city save become corrupted (and possibly neighbouring ones too).

Understandably only limited info is known about the save process, where observations can mostly just be made through experimentation. Back when Maxis coded the routine, it seems logical to presume they never expected city tile data to be as large as it can get today due to custom content (especially MMPs).


Here's some useful insight as posted by @rsc204 which elaborates on this further:
 

On 20/12/2017 at 11:06 PM, rsc204 said:

SC4 is a little unique in how it saves the game, from what we have managed to decipher, it pretty much takes the detail of the city as it's held in RAM and duplicates it onto your Hard Drive. The reason this is important to know, is because that process is amazingly intensive as an operation, but there is a flaw in how it works. See, at the same time SC4 is trying to save the city data, it also is trying to make a screenshot of the city for region view to be updated. In addition when you use Save and Exit/Quit, the computer is also doing other things to facilitate those processes too, it easily becomes too much and leads to CTDs.

Long and short, it's a known issue that using either Save and Exit to Region or Save and Quit, can cause the game to hang. The bigger the city and more objects in it, the more likely the problem. As such, it is recommended to avoid these options altogether and only ever use just "Save", which appears on the lower menu bar or can be activated with CTRL+S. Then use Exit without Saving or Quit without Saving instead.

On 29/08/2018 at 1:30 AM, rsc204 said:

As the save file gets larger, it takes more system resources to save the data. If the computer is busy with other tasks, it might not be able to finish the process properly. Creating the region thumbnail is one of the last parts of this, it can easily get corrupted, then it no longer works. The extra load of processing exiting either the city or game, increases the odds that the save process doesn't end properly. Just using save is seemingly foolproof, since the game has all the time it needs to finish the save, with no interruptions.

It's very likely that this issue is due to the large plugin suites and use of custom content. This hugely increases the save times/sizes, probably beyond anything Maxis ever envisioned users doing.

 

  • Like 2

Share this comment


Link to comment
Share on other sites
6 hours ago, Wiimeiser said:

(Also, having something with a variable duration overridden by a fixed timer is a horrible idea to begin with. Why even code it that way?)

Indeed I don't believe it was. I think simply that one process doesn't quite finish properly before the game moves back to region-view or exiting entirely. Since this would have been extensively tested at the time (during development), the issue never really came up. The point being, Maxis could never really have envisioned what a monster SC4 would become from a modding perspective.

Think about it this way, if you had more than 1GB RAM in a system in 2003, that would mean you had very, very, deep pockets. Yet today SC4 uses 1.6GB of my RAM when it's running. This should give some indication of how well the code's held up for the most part. But I suspect is a major reason why the save routine is pushed beyond what it can handle on occasion. Not to mention, background applications might interrupt SC4's use of the system bus. It's totally understandable how changes in how computers and Windows works today, could have turned something reliable into something otherwise.

The good news though, both this problem and other save-file corruption issues are pretty much a non-event. Provided you know how to avoid them.

@Cyclone Boom: Just a thought, could we alter the "Save and..." options, to simply "Save". Not sure how to re-direct the button's functions, but for me I think that would be a nice alteration too.

  • Like 2

Share this comment


Link to comment
Share on other sites

Could there be an expansion to provide a reminder for when a city has been modified but not saved? I've had the occasional situation in which I forget to save the city after taking screenshots and then lose the progress of what was made. I'm sure other folks have also experienced something similar.

Share this comment


Link to comment
Share on other sites
On 21/03/2019 at 3:00 PM, rsc204 said:

Just a thought, could we alter the "Save and..." options, to simply "Save". Not sure how to re-direct the button's functions, but for me I think that would be a nice alteration too.

That would certainly be useful as another option. A few months ago when I originally created the modified button and disabled variations, I tried to swap over the function of the dedicated Save button. In Reader (version 1.5.4 which has a more advanced UI editor), I located the Save button and noted the IID used. Then I replaced this with the button control on my override. As I recall this did nothing other than caused the dialog to immediately close as when clicking Cancel.

I'll revisit this though and see if anything can be done. Or please let me know if you've any ideas of how it may or may not be possible. *;)

 

15 hours ago, Lucario Boricua said:

Could there be an expansion to provide a reminder for when a city has been modified but not saved?

That might be doable, but isn't something within the scope of what I can technically achieve with my current knowledge. It may well need to rely on custom coded LUA code, or even DLL file to provide the necessary functionality.

I'm aware of a Save Alarm mod which might come in handy as a periodic reminder.

  • Like 2

Share this comment


Link to comment
Share on other sites
1 hour ago, moSonče said:

That's a weird bug, still never experienced, seems perks of playing vanilla :)

It's very true how without using lots of custom content in a city tile, there is a reduced probability of save corruption from the Save and Exit OR Save and Quit one-step process. That's how Maxis designed the game after all, and adding more content is increasing variables and memory overhead.

Doing so playing mostly or exclusively vanilla makes it highly unlikely in fact, although not impossible. The chances will be increased for large city tiles which are significantly developed. Also running the game for extended periods or tabbing out from SC4 may raise the likelihood due to memory accumulation, especially without saving within the current tile per session. I remember reading how it does a garbage collection (system memory cleanup, not trash in the game) when saving directly. So that seems a good habit to get into at regular intervals.

Exiting to the region is something I'll personally still do after terraforming or planting flora. In otherwise empty undeveloped tiles, this really is a negligible risk. Also should anything go wrong, there's a lot less progress lost compared with a detailed crafted city built over time.

It's hard to estimate the quantity of content where corruption is more likely to occur when exiting or quitting in one-step. The biggest danger in any case is to not switch focus from the game when saving either way (even using the regular Save).

Anyway, glad to hear you've not encountered it before, but just thought I'd mention how it might still be safer to consider using the two-step process. *;)

  • Like 1

Share this comment


Link to comment
Share on other sites
On 24.03.2019 at 4:57 AM, Cyclone Boom said:

It's very true how without using lots of custom content in a city tile, there is a reduced probability of save corruption from the Save and Exit OR Save and Quit one-step process. That's how Maxis designed the game after all, and adding more content is increasing variables and memory overhead.

Doing so playing mostly or exclusively vanilla makes it highly unlikely in fact, although not impossible. The chances will be increased for large city tiles which are significantly developed. Also running the game for extended periods or tabbing out from SC4 may raise the likelihood due to memory accumulation, especially without saving within the current tile per session. I remember reading how it does a garbage collection (system memory cleanup, not trash in the game) when saving directly. So that seems a good habit to get into at regular intervals.

Exiting to the region is something I'll personally still do after terraforming or planting flora. In otherwise empty undeveloped tiles, this really is a negligible risk. Also should anything go wrong, there's a lot less progress lost compared with a detailed crafted city built over time.

It's hard to estimate the quantity of content where corruption is more likely to occur when exiting or quitting in one-step. The biggest danger in any case is to not switch focus from the game when saving either way (even using the regular Save).

Anyway, glad to hear you've not encountered it before, but just thought I'd mention how it might still be safer to consider using the two-step process. *;)

I see no harm in being cautious anyway but still it seems more of GC done wrong ( or not anticipated with more content as mentioned ) than a timing issue, that's abstracted in OS level after all. ( Unless you suggest game dumping allocated memory to file but does GC meanwhile therefore corrupts file ) 

At the end, we don't need to understand inner works though :) can simply avoid it this way.

  • Like 2

Share this comment


Link to comment
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