Aurora 4x

C# Aurora => C# Bug Reports => Topic started by: Tikigod on April 28, 2020, 05:14:02 PM

Title: [PSA] Why are my % and other figures broken?!?! (If this is you. Please read)
Post by: Tikigod on April 28, 2020, 05:14:02 PM
(https://i.imgur.com/Jo1ezUE.jpg)



In order for Aurora to function as it is intended, this is what your operating system regional format settings need to look like.

If they look like this, you will have no problems with your:

* Research rates being crazy.
* Population numbers being wonky.
* Growth rates being silly broken.
* Income/Wealth not calculating properly.

And all other manner of weirdness you may have just been about to post as a bug despite Steve explicitly stating the factor in multiple locations.

Hopefully a visual representation will make it easier for those that still seemed to be confused.
Title: Re: [PSA] Why are my % and other figures broken?!?! (If this is you. Please read)
Post by: Omnivore on April 28, 2020, 06:21:52 PM
If you are running Windows 10 and would like to keep your own regional settings for everything else other than Aurora, the following approach works:

1) Create a new local user (settings) be sure and give it a password
2) Log out and then Log in as the new local user, follow the instructions in the previous post above to change settings.
3) Log out of the new local user and Log back in as your normal user.

For then on, when you want to start Aurora, control+shift+right-click on the Aurora.exe file, select 'run as different user', enter the name and password for the new local user you created.  This runs Aurora with the regional settings it needs and leaves the rest of your programs (and desktop) as you like (had set previously).
Title: Re: [PSA] Why are my % and other figures broken?!?! (If this is you. Please read)
Post by: Faber81 on April 29, 2020, 03:25:03 AM
If you are running Windows 10 and would like to keep your own regional settings for everything else other than Aurora, the following approach works:

1) Create a new local user (settings) be sure and give it a password
2) Log out and then Log in as the new local user, follow the instructions in the previous post above to change settings.
3) Log out of the new local user and Log back in as your normal user.

For then on, when you want to start Aurora, control+shift+right-click on the Aurora.exe file, select 'run as different user', enter the name and password for the new local user you created.  This runs Aurora with the regional settings it needs and leaves the rest of your programs (and desktop) as you like (had set previously).
thank you, that was exactly my concern.

EDIT: actually, regarding the OP, I changed the settings but I still get the odd % in Aurora. Any other advice? Version 0.8 worked like a charm
EDIT2: aaaand after changing settings a few times, and actually resetting them to default (decimal comma), now everything works. I really don't get computers at all... -_-
Title: Re: [PSA] Why are my % and other figures broken?!?! (If this is you. Please read)
Post by: Inglonias on April 29, 2020, 06:47:34 PM
I changed my decimal separator to 😃 to see what would happen. Windows didn't stop me. It's a unicode character, after all. Aurora seemed not to mind so much either, but for obvious reasons I'm not exactly going to keep trying to use my computer in that state.

I think I will stick with dots for the future, though.
Title: Re: [PSA] Why are my % and other figures broken?!?! (If this is you. Please read)
Post by: Agraelgrimm on April 29, 2020, 07:13:28 PM
I am really confused about this at all. I dont even see any diference here whatsoever.
Title: Re: [PSA] Why are my % and other figures broken?!?! (If this is you. Please read)
Post by: Inglonias on April 29, 2020, 09:42:16 PM
Aurora sees the number 100,00 as ten thousand, not 100. Simple as that.
Title: Re: [PSA] Why are my % and other figures broken?!?! (If this is you. Please read)
Post by: Erik L on April 29, 2020, 10:17:12 PM
Aurora sees the number 100,00 as ten thousand, not 100. Simple as that.

Well, I think it is more that the comma throws off the SQL statements.
Title: Re: [PSA] Why are my % and other figures broken?!?! (If this is you. Please read)
Post by: Asanda Nima on May 01, 2020, 03:03:06 AM
Thank you for your advise and also the tipp with the second user.

But I have a question, is this something that will be addressed in future? Because I do not remember having this issue with the VB version or Aurora 4X.
Or will this stay like this? In this case I think this should be added to the installation instruction, to make sure that the game works as it should.
Title: Re: [PSA] Why are my % and other figures broken?!?! (If this is you. Please read)
Post by: Inglonias on May 01, 2020, 07:12:32 AM
From what I can tell, this was an issue with VB6 Aurora that was solved by running the game through the popular wrapper that existed for it.

As for making the issue more widely known, I believe that Steve is planning to add a popup window warning when the game starts up in the future.
Title: Re: [PSA] Why are my % and other figures broken?!?! (If this is you. Please read)
Post by: Father Tim on May 02, 2020, 12:22:54 AM
Thank you for your advise and also the tipp with the second user.

But I have a question, is this something that will be addressed in future? Because I do not remember having this issue with the VB version or Aurora 4X.
Or will this stay like this? In this case I think this should be added to the installation instruction, to make sure that the game works as it should.


It has been addressed several times already.  VB Aurora had the 'advantage' of failing catastrophically if you didn't use a period decimal separator, so there wasn't much of an opportunity to do it 'wrong'.  Steve tried to accomodate comma users in C# Aurora, and ran into the problem that 98% of it worked -- so people could get much deeper into the game before having a problem, and that most such problems aren't game-breaking.

But yeah, given how difficult it has been trying to accomodate comma users it is likely that C# Aurora will go back to being period-only until C# itself (or Windows) changes.
Title: Re: [PSA] Why are my % and other figures broken?!?! (If this is you. Please read)
Post by: Tyrope on May 02, 2020, 12:59:52 AM
The fact that the way numbers display affects the way the back-end interprets the numbers at all makes me wonder what is happening. . .  I've done my fair share of programming and never have I ever bumped into an issue where front-end affects back-end.  Then again, I've never written something half as complex as Aurora.  :D
Title: Re: [PSA] Why are my % and other figures broken?!?! (If this is you. Please read)
Post by: Asanda Nima on May 02, 2020, 01:30:24 AM
Quote from: Tyrope link=topic=11139. msg129859#msg129859 date=1588399192
The fact that the way numbers display affects the way the back-end interprets the numbers at all makes me wonder what is happening.  .  .   I've done my fair share of programming and never have I ever bumped into an issue where front-end affects back-end.   Then again, I've never written something half as complex as Aurora.   :D

Yeah that surprised me too.  And I am 100% sure that there are some ways in C# to avoid that.  Else C# based programs would have to be done with comma and period version, nobody would use C# then. .
But as you said Aurora is one hell of complex program, and without knowing how exactly it works, we can only speculate. 

 
Title: Re: [PSA] Why are my % and other figures broken?!?! (If this is you. Please read)
Post by: Garfunkel on May 02, 2020, 01:32:08 AM
It''s also 20 years old and done by Steve alone, as a hobby. So literally anything is possible.
Title: Re: [PSA] Why are my % and other figures broken?!?! (If this is you. Please read)
Post by: smoelf on May 02, 2020, 04:18:59 AM
But yeah, given how difficult it has been trying to accomodate comma users it is likely that C# Aurora will go back to being period-only until C# itself (or Windows) changes.

Yeah, for me this is already the case. I used to be able to use comma as a decimal separator in the mineral search window, but since 1.9 I have had to use period in every window. It's a bit of a shame, since everything is so much faster with numpad and comma as decimal separator, but considering the (possible?) time investment to make it work, I'd much rather that Steve spent his time on something else. It's not that big of a deal to learn to use period instead.
Title: Re: [PSA] Why are my % and other figures broken?!?! (If this is you. Please read)
Post by: Second Foundationer on May 02, 2020, 05:30:30 AM
Quote from: smoelf link=topic=11139. msg129896#msg129896 date=1588411139
Quote from: Father Tim link=topic=11139. msg129858#msg129858 date=1588396974
But yeah, given how difficult it has been trying to accomodate comma users it is likely that C# Aurora will go back to being period-only until C# itself (or Windows) changes.

Yeah, for me this is already the case.  I used to be able to use comma as a decimal separator in the mineral search window, but since 1. 9 I have had to use period in every window.  It's a bit of a shame, since everything is so much faster with numpad and comma as decimal separator, but considering the (possible?) time investment to make it work, I'd much rather that Steve spent his time on something else.  It's not that big of a deal to learn to use period instead.

As for the numpad: I have myself a , for it printed on my current physical keyboard on the numpad, but I use an English (US) keyboard layout (and others at other times), so the numpad works fine.  If you do not need various keyboard layouts otherwise and don't want to switch the whole layout because other keys will then not do what they say on the label, it should be possible with very simple tools to create your own custom keyboard layout.  I myself use two adapted for special tasks with a bunch of additional signs stuffed in.  But for this, you can create one with just one or two keys changed from default, in this case just exchange comma with period, so that the numpad works for decimals.  You can then use that custom layout in Windows while running Aurora by selecting it in the language bar (I'm not sure if it's displayed by default these days, but it's easy to find) in the taskbar just like any standard keyboard layout or add a shortcut for switching.

If you want to try it and can't find on your own, I could look up which tool I used, and if it still exists, give you a link.  It may even be part of Windows, not sure.  It really takes only a minute.  Setup once, forget, use.  My main one must be more than a decade old and has already been ported across Windows versions.  It might only annoy you to have the language bar displayed permanently if you have no other use for it.  But as long as you don't forget to switch back when you need to: it should be possible to setup a shortcut without it, I think.
Title: Re: [PSA] Why are my % and other figures broken?!?! (If this is you. Please read)
Post by: smoelf on May 02, 2020, 05:34:03 AM
As for the numpad: I have myself a , for it printed on my current physical keyboard on the numpad, but I use an English (US) keyboard layout (and others at other times), so the numpad works fine.  If you do not need various keyboard layouts otherwise and don't want to switch the whole layout because other keys will then not do what they say on the label, it should be possible with very simple tools to create your own custom keyboard layout.  I myself use two adapted for special tasks with a bunch of additional signs stuffed in.  But for this, you can create one with just one or two keys changed from default, in this case just exchange comma with period, so that the numpad works for decimals.  You can then use that custom layout in Windows while running Aurora by selecting it in the language bar (I'm not sure if it's displayed by default these days, but it's easy to find) in the taskbar just like any standard keyboard layout or add a shortcut for switching.

If you want to try it and can't find on your own, I could look up which tool I used, and if it still exists, give you a link.  It may even be part of Windows, not sure.  It really takes only a minute.  Setup once, forget, use.  My main one must be more than a decade old and has already been ported across Windows versions.  It might only annoy you to have the language bar displayed permanently if you have no other use for it.  But as long as you don't forget to switch back when you need to: it should be possible to setup a shortcut without it, I think.

That's an excellent idea. Certainly a lot faster to change a saved keyboard layout than switching the area settings every time. Thanks :)
Title: Re: [PSA] Why are my % and other figures broken?!?! (If this is you. Please read)
Post by: Second Foundationer on May 02, 2020, 05:55:58 AM
A pleasure if it is of any help.

Only to make sure, a general note for all comma-separated problems: Changing the keyboard layout does NOT in itself change your operating system's number format.  For that, please refer to the first post in this thread.
Title: Re: [PSA] Why are my % and other figures broken?!?! (If this is you. Please read)
Post by: Tree on May 09, 2020, 03:08:29 AM
If you are running Windows 10 and would like to keep your own regional settings for everything else other than Aurora, the following approach works:

1) Create a new local user (settings) be sure and give it a password
2) Log out and then Log in as the new local user, follow the instructions in the previous post above to change settings.
3) Log out of the new local user and Log back in as your normal user.

For then on, when you want to start Aurora, control+shift+right-click on the Aurora.exe file, select 'run as different user', enter the name and password for the new local user you created.  This runs Aurora with the regional settings it needs and leaves the rest of your programs (and desktop) as you like (had set previously).

You can also create a .bat file for it so you can skip the ctrl+shift+right click and just double click as normal. Put this line in notepad:
runas /profile /env /savecred /user:computername\username "C:\Games\Aurora\Aurora.exe"
You'll have to replace computername and username with what fits your computer and new Aurora user, the .exe's path, save as a .bat file and now you can run Aurora off the .bat file. It'll only ask for the password once, too.
Title: Re: [PSA] Why are my % and other figures broken?!?! (If this is you. Please read)
Post by: Destragon on May 12, 2020, 06:45:27 PM
AuroraMod has a setting that lets you customise the number culture and date format, without having to change them in your system or having to create a new windows profile:

Edit: Fixed the link
http://aurora2.pentarch.org/index.php?topic=11382.0

Edit 2:
For Auora version 1.13 (and 2.0), the latest mod to change these settings is this one:
http://aurora2.pentarch.org/index.php?topic=12565.0
Title: Re: [PSA] Why are my % and other figures broken?!?! (If this is you. Please read)
Post by: SpikeTheHobbitMage on May 12, 2020, 07:00:53 PM
Aurora sees the number 100,00 as ten thousand, not 100. Simple as that.

Well, I think it is more that the comma throws off the SQL statements.
C# uses prepared statements so that shouldn't be a problem like it was in VB, since there are no text conversions involved any more.  At this point it should be restricted to reading and writing UI elements and that can safely be done using the user's locale.  It should now just be a matter of making certain that all code touching a given control agrees on what it is doing, which is admittedly a sizable chunk of code.
Title: Re: [PSA] Why are my % and other figures broken?!?!
Post by: hephep on September 29, 2020, 06:48:10 AM
I don't know what the internals of Aurora look like, but all inputs should be sanitised anyway as best practice (or standard practice for web dev) - when devs don't do this you end up with security holes; less of a problem with a game, but still.         

You just need two core functions:

string number_format(dynamic in_num) - takes in any type and outputs it as a formatted string using the system preferences.          For bonus points parameters for number of decimals etc.         

float/int parse_number(string in_str) - takes in a string and tries to parse it into a float/int as appropriate.       

C# has a bunch of functions to help with this:
https://docs.      microsoft.      com/en-us/dotnet/api/system.      globalization?view=netcore-3.      1

All user-inputted numbers should use parse_number before being used internally, and everything that's a number should go through number_format before being printed.       I suspect its on these where Aurora currently fails.     

Throw in some unit tests for both functions and you've got some rock solid code that can handle number input/output, and a swath of bug reports just disappears.