Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suddenly, I have 12 billion euros #1590

Closed
DorpsGek opened this issue Dec 26, 2007 · 3 comments
Closed

Suddenly, I have 12 billion euros #1590

DorpsGek opened this issue Dec 26, 2007 · 3 comments
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)

Comments

@DorpsGek
Copy link
Member

pvz opened the ticket and wrote:

I (green player in the attached savegame) was playing on a multiplayer server. A few companies went bankrupt at close to the same time, and suddenly I had 12 billion euros. As far as I could see in the console log at the time nobody had given me any money.

I had bought 75% shares in a company that was at €2 (player 1). Somewhere between the two games autosave15 and autosave0 (those are the two closest two savegames before and after the bankrupcy) I gained 12 million euro and that company (and a few others) went bankrupt, probably via autoclean or reset_company. I'm not sure. I'm not even sure if the bankrupcy was responsible for the crash.

Apart from the server running, there were at least two clients connected. Myself on PPC Mac OS X, and another player (didn't ask which platform he was on). No desyncs were seen, and the other player could see the money I had even without reconnecting. Also, no "desyncy" behaviour was experienced. This leads me to believe that the bug is not platform specific. (Though I guess it's possible both the server, the other player, and myself were on PPC Mac OS X, but I think that's pretty unlikely.)

Since the company I had shares in was Player 1, reproducing this bug from this savegame might not be possible in single-player mode. A dedicated server process may be required.

The original TTD had a very similar bug -- which made it possible to buy shares in a failing AI company, leave the window open until the company went bankrupt, and then sell the shares. If you were lucky, the program would give you lots of money. If you were unlucky, it would crash. (That sounded like a dangling pointer thing to me.) I'm not sure if this bug is similar or a regression of some kind, but I thought it might be interesting nevertheless.

The attached .rar file contains 16 autosaves covering a few months before and after the bug occurred. The most interesting files are autosave15 and autosave0 -- directly before and after the bankrupcy happened, respectively.

In a few of the later files, blue and red player also get a few millions. That's not due to any bug. I gave them that money to spread the wealth -- so to speak :-)

This bug may be fixed already in the 0.6 branch according to SmatZ on IRC -- he couldn't reproduce it there on 0.6 when he tried. He could reproduce it in 0.5.3 though.

Attachments

Reported version: 0.5.3
Operating system: All


This issue was imported from FlySpray: https://bugs.openttd.org/task/1590
@DorpsGek
Copy link
Member Author

SmatZ wrote:

The reason is that player 'Lafayette Transport' has shares in inactive companies (p->is_active == 0).
CmdSellShareInCompany returns CMD_ERROR, but that is not checked and interpreted as a money value.
It doesn't show up in 0.6, but if it is still possible to acquire shares in non-existant companies, it must be fixed.


This comment was imported from FlySpray: https://bugs.openttd.org/task/1590#comment3077

@DorpsGek
Copy link
Member Author

SmatZ wrote:

The reason is that p->share_owners[] is initialized to 0, thus player 0 has all shares of companies that haven't been activated yet.
(as described above, this problem is visible only in 0.5.3, the CMD_ERROR returned from CmdSellShareInCompany is interpreted as money value - but it is present in 0.6 too)

I think there are three possible solutions:

  1. force all inactive players to have all shares INVALID_PLAYER (and do the update while loading older savegames)
  2. modify FOR_ALL_PLAYERS macro to do check "if (p->is_active)" (similiar as other FOR_ALL_* macros that do "if (x->IsValid())") - that may require some changes at other places where this macro is used
  3. do check p->is_active in ChangeOwnershipOfPlayerItems() (and risk somebody will forget about it in some other case)

I would like to do variant 1.


This comment was imported from FlySpray: https://bugs.openttd.org/task/1590#comment3078

@DorpsGek
Copy link
Member Author

SmatZ closed the ticket.

Reason for closing: Fixed

In r11717


This comment was imported from FlySpray: https://bugs.openttd.org/task/1590

@DorpsGek DorpsGek added Core flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) labels Apr 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)
Projects
None yet
Development

No branches or pull requests

1 participant