The International Simutrans Forum

Simutrans Extended => Simutrans-Extended bug reports => Simutrans-Extended development => Simutrans-Extended closed bug reports => Topic started by: Matthew on May 21, 2018, 12:34:10 AM

Title: Bug: When you upgrade a stop, you win the lottery!
Post by: Matthew on May 21, 2018, 12:34:10 AM
Steps to reproduce:
1. Open this save game (https://simutrans-germany.com/files/upload/Roskill_ATC-AM_Curious_increase_in_cash.sve).
2. Switch to Allied Transport Company and find Darditch Slaughter-house Quay (should be [56,169]).
3. Note how much cash you have (should be about 60m Simucredits).
4. Build a Basic Bus Stop on the empty dirt-road tile between the school and the slaughter-house (should be [54, 169]).
5. Now upgrade it to Bus Stop with Shelter and Post Box.
6. Your cash will have increased by a large amount.

In my case, I receive 10m Simucredits, presumably because that's my starting_money; with default settings you might receive 250,000 Simucredits.

This was playing the Nightly from this morning (#657430b) on Windows 7.

For once, I feel reasonably certain that this is a bug rather than my mistake.  ;D
Title: Re: Bug: When you upgrade a stop, you win the lottery!
Post by: jamespetts on May 21, 2018, 09:31:27 PM
Thank you for the report - I think that I have now fixed this: I should be grateful if you could re-test and confirm.
Title: Re: Bug: When you upgrade a stop, you win the lottery!
Post by: ACarlotti on May 22, 2018, 01:36:08 AM
Quote from: Matthew on May 21, 2018, 12:34:10 AMFor once, I feel reasonably certain that this is a bug rather than my mistake.
This one was my mistake - I said (or at least considered saying) I'd introduce some bugs while porting stuff from Standard.

Your starting finance was unrelated to this bug. There are two ways that building prices can be calculated in the pakset, one of which involves a magic constant of 2^31-1. The bug meant that in some circumstances the magic constant could be interpreted as a number of simucents. Divide by 2 (for the cost you recover from having the old station), and there's your approximately 10m simucredits.
Title: Re: Bug: When you upgrade a stop, you win the lottery!
Post by: DrSuperGood on May 22, 2018, 07:25:35 PM
Quoteone of which involves a magic constant of 2^31-1
You mean the largest positive number representable by a 32bit signed integer?
Title: Re: Bug: When you upgrade a stop, you win the lottery!
Post by: Matthew on May 22, 2018, 10:21:47 PM
Quote from: jamespetts on May 21, 2018, 09:31:27 PM
Thank you for the report - I think that I have now fixed this: I should be grateful if you could re-test and confirm.

Yes, this seems to be fixed with last night's build. Thank you for fixing this so swiftly!

Quote from: ACarlotti on May 22, 2018, 01:36:08 AM
This one was my mistake - I said (or at least considered saying) I'd introduce some bugs while porting stuff from Standard.

Your starting finance was unrelated to this bug. There are two ways that building prices can be calculated in the pakset, one of which involves a magic constant of 2^31-1. The bug meant that in some circumstances the magic constant could be interpreted as a number of simucents. Divide by 2 (for the cost you recover from having the old station), and there's your approximately 10m simucredits.

You did say bugs were likely, and this one has given me an excuse to start some new towns, so I'm not in the least bit annoyed. ;D And it's interesting to learn why that number popped up. If it had been a number like 1024 or 512, then I might have expected some kind of magic programming number, but the divide by 2 threw me off the scent. Thank you for explaining.