Store...

Think you've found a bug? Here's the place to talk about it. It might actually get fixed.

Moderator: Public Forum Moderators

User avatar

Topic author
Right2Wrong2000
Chat Moderator
Posts: 216
Joined: Mon Feb 18, 2008 7:36 pm
Location: Ohio
Contact:

Store...

Unread post by Right2Wrong2000 » Fri Feb 06, 2009 3:18 pm

I don't know if its not so much a bug as it is a pain in the bum, but whenever entering commas into the price of one's store, it causes the item to be placed in the store at minimum price. Not really a problem as of now, but when we get bigger... I could see it being a pain.
-Coda

User avatar

invisible
Forum Addict
Posts: 147
Joined: Thu Jan 22, 2009 7:29 am

Re: Store...

Unread post by invisible » Fri Feb 06, 2009 4:35 pm

yea thats a strange one R2.. Im not one to normally use commas in my prices but did try it and that would be a pain one day...

User avatar

Grokly
Forum Addict
Posts: 585
Joined: Sat Jun 23, 2007 4:17 pm
Location: Missouri, USA
Contact:

Re: Store...

Unread post by Grokly » Sat Feb 07, 2009 10:23 am

Just a note on this one....

Different countries use different punctuation within currency amounts (prices). Some use commas, some use decimal points. Considering this, I suspect we will probably continue to not use commas to separate values of thousands.

However, perhaps we should reject values with thousands-separators (or ignore them and take only the numerics) to eliminate confusion. This brings up the issue of having to code further validation for that field so it may not be something that happens right away, if at all.
Image

User avatar

Topic author
Right2Wrong2000
Chat Moderator
Posts: 216
Joined: Mon Feb 18, 2008 7:36 pm
Location: Ohio
Contact:

Re: Store...

Unread post by Right2Wrong2000 » Sat Feb 07, 2009 3:15 pm

Okay.. I just ended minimum pricing some stuff the other day and was like ahh!
-Coda

User avatar

Gobberwart
Developer
Posts: 3396
Joined: Wed Jun 20, 2007 12:41 am
Location: Melbourne, Australia
Contact:

Re: Store...

Unread post by Gobberwart » Sat Feb 07, 2009 3:38 pm

It's always a good idea to have the option "Auto-Activate on Add New Item" disabled to protect you against exactly that kind of thing.
Image

User avatar

Topic author
Right2Wrong2000
Chat Moderator
Posts: 216
Joined: Mon Feb 18, 2008 7:36 pm
Location: Ohio
Contact:

Re: Store...

Unread post by Right2Wrong2000 » Sat Feb 07, 2009 4:29 pm

Ohh! Good idea! Gobb... Your so smart...
-Coda


McFeisty
Chat Moderator
Posts: 45
Joined: Thu Dec 11, 2008 6:04 pm

Re: Store...

Unread post by McFeisty » Thu Feb 12, 2009 3:53 pm

It doesn't just happen in the store, when I'm trying to withdraw from stash, it takes the numbers before the comma, and that's all. I was copying and pasting a number that was displayed on the page - with commas - and it didn't take it properly (I selected 34,987 and pasted it in the box, when I had 1,234,987 as displayed in stash). Whether you want the system to work without or with commas, it ought to jive with how the game displays it, so it seems to me.

Perhaps, instead of just taking the numbers before the comma as the total amount, it could generate an error, like it does for other incorrect numbers (too large, etc.) if it encounters a comma. Would it be feasible to have the commas parsed out or something? I know, it's really just a minor annoyance, but it does happen.

User avatar

Gobberwart
Developer
Posts: 3396
Joined: Wed Jun 20, 2007 12:41 am
Location: Melbourne, Australia
Contact:

Re: Store...

Unread post by Gobberwart » Thu Feb 12, 2009 5:07 pm

If only PHP understood that 1,234,567 was the same thing as 1234567, we'd be sweet, but it doesn't do that natively. PHP things a number with comma-separators is a string value, not a number, so I need to write a function to strip the commas out.

It's on the to-do list.
Image

User avatar

Gobberwart
Developer
Posts: 3396
Joined: Wed Jun 20, 2007 12:41 am
Location: Melbourne, Australia
Contact:

Re: Store...

Unread post by Gobberwart » Thu Feb 12, 2009 5:21 pm

Ok, so I just wrote the function (all 4 lines of it). Now I just have to go through ALL 700,000 or so lines of code to find everywhere that a number gets posted by a form and make it use the function. That might take a while :)
Image

User avatar

Grokly
Forum Addict
Posts: 585
Joined: Sat Jun 23, 2007 4:17 pm
Location: Missouri, USA
Contact:

Re: Store...

Unread post by Grokly » Thu Feb 12, 2009 10:44 pm

Grokly wrote:... However, perhaps we should reject values with thousands-separators (or ignore them and take only the numerics) to eliminate confusion. This brings up the issue of having to code further validation for that field so it may not be something that happens right away, if at all.
Looks like I spoke to soon.

See what you people do? There's more content not being created. :D
Image

User avatar

Gobberwart
Developer
Posts: 3396
Joined: Wed Jun 20, 2007 12:41 am
Location: Melbourne, Australia
Contact:

Re: Store...

Unread post by Gobberwart » Thu Feb 12, 2009 11:06 pm

Heh, it's not gonna happen tomorrow that's for sure. There's... something else I'm gonna be working on then if I hope to have it out by intermission tomorrow. And if I don't, it's kinda pointless doing at all.

At some point I WILL add the validation code in wherever it's needed. Just... not right now.
Image

User avatar

Topic author
Right2Wrong2000
Chat Moderator
Posts: 216
Joined: Mon Feb 18, 2008 7:36 pm
Location: Ohio
Contact:

Re: Store...

Unread post by Right2Wrong2000 » Fri Feb 13, 2009 6:19 am

I love the inconspicuous "something else" mentioned here. Whatever could that be!? Hehe But I appreciate you taking the time to fix that little quirk. And good luck with your "something else." Im stoked to see it!
-Coda

User avatar

Gobberwart
Developer
Posts: 3396
Joined: Wed Jun 20, 2007 12:41 am
Location: Melbourne, Australia
Contact:

Re: Store...

Unread post by Gobberwart » Fri Feb 13, 2009 7:07 pm

Just out of interest, I've discovered that PHP's "round" function rounds 1,234 down to 1 because, regardless of local convention, it treats both '.' and ',' the same. Which is going to make things a fraction harder than I'd like.

And you don't want to KNOW what it does to a number like "1,234,567.89"
Image


Elusis
Forum Addict
Posts: 109
Joined: Thu Jan 15, 2009 5:51 am

Re: Store...

Unread post by Elusis » Fri Feb 13, 2009 8:11 pm

I want to KNOW.
Image

User avatar

Topic author
Right2Wrong2000
Chat Moderator
Posts: 216
Joined: Mon Feb 18, 2008 7:36 pm
Location: Ohio
Contact:

Re: Store...

Unread post by Right2Wrong2000 » Sat Feb 14, 2009 2:33 pm

It destroys the game. Deathstar style.
-Coda

User avatar

Gobberwart
Developer
Posts: 3396
Joined: Wed Jun 20, 2007 12:41 am
Location: Melbourne, Australia
Contact:

Re: Store...

Unread post by Gobberwart » Sat Feb 14, 2009 2:52 pm

I'd tell you, but the universe would probably implode.
Image


heliosa10
Forum Addict
Posts: 128
Joined: Fri Dec 12, 2008 7:12 pm

Re: Store...

Unread post by heliosa10 » Sat Feb 14, 2009 3:43 pm

It would convert it into 1,234,567,89. Or over one billion.

User avatar

jimmyBUFFET
Forum Addict
Posts: 285
Joined: Tue Jan 06, 2009 10:10 pm
Location: Brackney, PA
Contact:

Re: Store...

Unread post by jimmyBUFFET » Sat Feb 14, 2009 6:53 pm

unless it only considers them interchangeable within a like group, all periods or all commas. mixing and matching is best left to Maxis games and out of coding, methinks.

-jB
Image

User avatar

Gobberwart
Developer
Posts: 3396
Joined: Wed Jun 20, 2007 12:41 am
Location: Melbourne, Australia
Contact:

Re: Store...

Unread post by Gobberwart » Sun Feb 15, 2009 11:46 am

heliosa10 wrote:It would convert it into 1,234,567,89. Or over one billion.
Actually, no. PHP's inbuild "round", "floor" and "ceil" functions consider both commas and periods to be separators, so all three round 1,234,567.89 to....

1

No, really, it just discards everything after the first separator. Crap, huh?

To do this properly, then, extra code is needed to first strip out the thousand separators and THEN round the number to an integer, ie. "1,234,567.89" -> "1234567.89" -> "1234568" (or "1234567" if we're flooring the final result).

That's great, provided that commas are thousand separators and periods decimal points. If it's the other way around for whoever enters the values, results will be VERY different.

Leave it with me.
Image

User avatar

Gobberwart
Developer
Posts: 3396
Joined: Wed Jun 20, 2007 12:41 am
Location: Melbourne, Australia
Contact:

Re: Store...

Unread post by Gobberwart » Sun Feb 15, 2009 12:08 pm

Ackkk, apparently there's more inconsistency in these separators than I originally thought. For example, the number 1234567.89, formatted correctly would be:

Australia/UK/US: 1,234,567.89
France: 1 234 567,89
Germany: 1.234.567,89

So what IS consistent? Well, in all cases, the final separator is the decimal separator, so it should be a matter of finding out what this character is, splitting the string at that point, removing all non-numeric characters from the string on the left, joining it all back together in the local format, then rounding it up or down as required.

Of course, that assumes that, in some countries, thousand separators aren't also used AFTER the decimal point (eg. 1.234.567,891.23...

Alternatively, I could just strip out everything that's not a number, since the game only accepts integers, not decimals. That would mean that "1,234,567.89", "1 234 567,89" and "1.234.567,89" would all just end up as "123456789".

See what happens when I start thinking people are actually interested in all this geekiness? I start telling you about it :)
Image

User avatar

Gobberwart
Developer
Posts: 3396
Joined: Wed Jun 20, 2007 12:41 am
Location: Melbourne, Australia
Contact:

Re: Store...

Unread post by Gobberwart » Sun Feb 15, 2009 12:16 pm

After realising yet another complication with trying to identify thousand and decimal separators based on input, I've decided that the function will treat commas as thousand separators and periods as decimal separators and that's as far as it's going to go. When I finally get around to doing it.
Image

User avatar

jimmyBUFFET
Forum Addict
Posts: 285
Joined: Tue Jan 06, 2009 10:10 pm
Location: Brackney, PA
Contact:

Re: Store...

Unread post by jimmyBUFFET » Sun Feb 15, 2009 2:14 pm

/me holds up some pom-poms because there's no way he gets all this math this early in his day.

-jB
Image

User avatar

Gobberwart
Developer
Posts: 3396
Joined: Wed Jun 20, 2007 12:41 am
Location: Melbourne, Australia
Contact:

Re: Store...

Unread post by Gobberwart » Sun Feb 15, 2009 3:27 pm

OK, SOME pages will now let you input comma-separated values. Some won't. Oh, and I found an infinite-moolah bug and fixed it so I guess I get a bugzapper.
Image

User avatar

Topic author
Right2Wrong2000
Chat Moderator
Posts: 216
Joined: Mon Feb 18, 2008 7:36 pm
Location: Ohio
Contact:

Re: Store...

Unread post by Right2Wrong2000 » Sun Feb 15, 2009 4:04 pm

You can credit that to me Gobb... Seeing as I started this thread. Haha
-Coda

Post Reply