The International Simutrans Forum

 

Author Topic: Bug: When you upgrade a stop, you win the lottery!  (Read 512 times)

0 Members and 1 Guest are viewing this topic.

Offline Matthew

  • *
  • Posts: 99
  • Languages: EN, some ZH, DE & SQ
Bug: When you upgrade a stop, you win the lottery!
« on: May 21, 2018, 12:34:10 AM »
Steps to reproduce:
1. Open this save game.
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

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18030
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Bug: When you upgrade a stop, you win the lottery!
« Reply #1 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.

Offline ACarlotti

  • *
  • Posts: 299
Re: Bug: When you upgrade a stop, you win the lottery!
« Reply #2 on: May 22, 2018, 01:36:08 AM »
For 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.

Offline DrSuperGood

  • Dev Team
  • Devotee
  • *
  • Posts: 2549
  • Languages: EN
Re: Bug: When you upgrade a stop, you win the lottery!
« Reply #3 on: May 22, 2018, 07:25:35 PM »
Quote
one of which involves a magic constant of 2^31-1
You mean the largest positive number representable by a 32bit signed integer?

Offline Matthew

  • *
  • Posts: 99
  • Languages: EN, some ZH, DE & SQ
Re: Bug: When you upgrade a stop, you win the lottery!
« Reply #4 on: May 22, 2018, 10:21:47 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!

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.