Spawn rate resets to 0, and how to fix/prevent it

Well, for a starters, it doesn’t reset to zero, it gets rounded down in the Windows if the decimal symbol is set is set other than dot in Regional settings.

Way to reproduce:
(I’m still using XP so your methods may vary)
Go to Control panel -> Regional and language options
Press Customize…
In Customize Regional Options, set Decimal symbol for something else than dot
Apply your settings

Run Cataclysmdda
Go to options and set Spawn Rate scaling factor for something with decimal number
Save your options and restart Cataclysmdda
Go back to options to check the result

So what can user do?

  1. Every time you start Cataclysmdda, go to options and re-set your spawn rate to desired value. It can be a hassle and if you forget to do it, the next town you visit might be empty.

  2. Set your Decimal symbol to dot in Regional settings. Now the Cataclysmdda will understand what that 0.7 means in your options.txt. This can have some side effects in other programs you use.

How to fix it?

  1. Quick and dirty. In options.cpp, line 453, set the minimum accepted value to 0.1. Now the value 0 (from rounded down 0.7) is not accepted, and the value is set to default 1.0. Now the player has at least some zombies to fight for.

  2. Right way. Read float values in as a string. Then sanity check them for different kind of decimal symbols before converting them to float.

If my memory serves me right, there can be other ways too, but it’s been over 10 years since last time I banged my head against this brick wall.

Good find.

Thanks for outlining the issue in detail.
We’re switching to a different system for file handling for unrelated reasons, and I think it will not reference localization when loading the data, so that should clear this up. Will be keeping an eye on this.