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

Feature: Infinite money mode #11902

Merged
merged 5 commits into from Jan 30, 2024
Merged

Feature: Infinite money mode #11902

merged 5 commits into from Jan 30, 2024

Conversation

merni-ns
Copy link
Contributor

@merni-ns merni-ns commented Jan 27, 2024

Motivation / Problem

Many players want to play in a "sandbox" style where they don't care about the money-making mechanics and just want to build cool networks. At present, this has to be achieved by cheating arbitrary amounts of money, which is an unsatisfactory and clunky solution, apart from messing up the company financial statements.

Description

This PR adds a setting called "Infinite money mode". When enabled, it allows any command to be performed even if the company's money balance is less than the amount required (or even negative). It also disables the company bankruptcy mechanism, and replaces the balance in the status bar with "infinite money". The actual balance is still shown in the finance window.

This approach has the advantage that it maintains the integrity of the company financial statements. It charges the company all costs, and does not add any extra arbitrary income (like the money cheat does). It also removes the need for occasionally cheating more money or otherwise infusing money -- players can just forget about the existence of the money mechanism for the duration of the game. Furthermore, it works perfectly fine with AI and multiplayer.

Screenshot:
image

Limitations

  • It takes effect on all companies, even AI. At present no check is done whether the company is a human or AI one.
  • Looking at vehicle, company, station, etc income statistics, still shows the "real" negative values which (says @TrueBrain) might put off players. (But it is anyway the same at present except for companies)
  • Not tested in multiplayer.
  • There may be some other edge case where some command/function directly checks how much money a company has instead of going through functions such as GetAvailableMoneyForCommand, CheckCompanyHasMoney, etc. I have done my best to find and fix all such instances, but there is no guarantee that one more is not lurking somewhere.

Checklist for review

Some things are not automated, and forgotten often. This list is a reminder for the reviewers.

  • The bug fix is important enough to be backported? (label: 'backport requested')
  • This PR touches english.txt or translations? Check the guidelines
  • This PR affects the save game format? (label 'savegame upgrade')
  • This PR affects the GS/AI API? (label 'needs review: Script API')
    • ai_changelog.hpp, game_changelog.hpp need updating.
    • The compatibility wrappers (compat_*.nut) need updating.
  • This PR affects the NewGRF API? (label 'needs review: NewGRF')

@merni-ns merni-ns force-pushed the freelunch branch 2 times, most recently from e770f35 to e0b8a7f Compare January 27, 2024 19:06
src/saveload/saveload.h Outdated Show resolved Hide resolved
@PeterN
Copy link
Member

PeterN commented Jan 27, 2024

I don't think the last three bullet points are needed. 3 and 4 are already existing options independently toggeable, and 5 is just... unnecessary?

@merni-ns
Copy link
Contributor Author

I don't think the last three bullet points are needed. 3 and 4 are already existing options independently toggeable, and 5 is just... unnecessary?

Ah I didn't even realise 3 had an existing option.
4: yes, the floating income/expense texts can be disabled. I was thinking of not making the numbers in the train list, the train details window, etc. not be red when negative (which to my understanding would not be very hard) but I agree this may be overkill.
Regarding hiding the money balance, that was a something that was suggested in discord. If there is agreement that that is unnecessary, I would be happy to ditch it.

@PeterN
Copy link
Member

PeterN commented Jan 27, 2024

IMHO sandbox money just means you don't want the game to limit what you do because of money. A player might still want to make an cost-effective network at the same time.

@merni-ns
Copy link
Contributor Author

merni-ns commented Jan 27, 2024

IMHO sandbox money just means you don't want the game to limit what you do because of money. A player might still want to make an cost-effective network at the same time.

Indeed. That is the reason I have not implemented it by not actually subtracting costs!

On further reflection, I have removed the 3rd and 4th points. I am not sure yet about the display of the money balance, whether this should be a separate option, or not in at all.

@merni-ns merni-ns changed the title Add: Setting to ignore negative money balance Add: Infinite money mode Jan 27, 2024
@merni-ns merni-ns force-pushed the freelunch branch 2 times, most recently from 97868a3 to 0951a40 Compare January 27, 2024 20:00
@merni-ns merni-ns marked this pull request as ready for review January 27, 2024 20:19
src/saveload/saveload.h Outdated Show resolved Hide resolved
Copy link
Member

@2TallTyler 2TallTyler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commit prefix for this one should definitely be Feature:. I suspect there will be a fair amount of excitement for this one. 😄 Other than that and my one code nitpick, it looks good!

src/company_cmd.cpp Outdated Show resolved Hide resolved
@merni-ns merni-ns changed the title Add: Infinite money mode Feature: Infinite money mode Jan 28, 2024
Copy link
Member

@2TallTyler 2TallTyler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, just noticed... All of our .ini files end with an empty line. Add that back and I'll approve this! 😄

2TallTyler
2TallTyler previously approved these changes Jan 28, 2024
@rubidium42
Copy link
Contributor

Sadly the infinite money isn't as infinite as I would expect. When I try to clear/flatten/raise/lower the whole world, I'm still getting error messages about insufficient funds (start a game with no to little money). This is due to those functions checking for money in a different manner, because they are not all-or-nothing commands, but do-as-much-as-possible for the money you have commands.

There might be more commands than just clear/flatten/raise/lower that exhibit this behaviour, but I haven't looked into that.

@merni-ns
Copy link
Contributor Author

merni-ns commented Jan 29, 2024

Sadly the infinite money isn't as infinite as I would expect. When I try to clear/flatten/raise/lower the whole world, I'm still getting error messages about insufficient funds (start a game with no to little money). This is due to those functions checking for money in a different manner, because they are not all-or-nothing commands, but do-as-much-as-possible for the money you have commands.

There might be more commands than just clear/flatten/raise/lower that exhibit this behaviour, but I haven't looked into that.

This was because those commands used GetAvailableMoneyForCommand (which was sitting in command.cpp and not in company_cmd.cpp where I would have expected it). That has now been fixed and the following commands work now:

  • Clearing an area of land
  • Levelling an area of land
  • Dragging to build multiple objects over an area
  • "Removing a long piece of road" (CmdRemoveLongRoad; I don't know what exactly qualifies as long here)
  • Founding a town.

I hope there isn't yet another mechanism for commands to check the amount of money a company has.

src/command.cpp Outdated Show resolved Hide resolved
…dd GetAvailableMoney

The function belongs better in company_cmd.cpp along with the similar CheckCompanyHasMoney and SubtractMoneyFromCompany.
The generalised function GetAvailableMoney is added which allows finding the money of any company, not just the current one. This will be useful in the next commit.
@merni-ns
Copy link
Contributor Author

I have now looked at (I hope) all the instances in the code where a company's money is checked and ensured that this setting is checked wherever it is relevant.

@LC-Zorg
Copy link

LC-Zorg commented Jan 29, 2024

This doesn't seem like a good solution to me. Someone who wants to build freely and not worry about the lack of cash (sometimes that includes me) rather doesn't want to see constantly increasing debt. It looks bad and doesn't give you a sense of freedom. It's also not like everyone who wants to play casually isn't interested in making money. I think that even a player for whom the economy is not the most important thing in this game would rather want it to make some sense anyway. Spending money you don't have doesn't seem logical.

I think this could have been solved in at least a few other ways, which I also think would be simpler and wouldn't cause such complications.
1. Make the Infinite money option add a very large amount that is difficult to squander.
Instead of allowing the player to go into debt forever, give him enough money so that he never actually runs out of it.
2. Adding the "Own funds" feature
This would be an alternative to a loan and it could be arranged in the same way before the game starts. A player who wanted to have truly infinite money could simply enter, for example, £1 trillion and not have to worry about it anymore.
3. Extension of the loan interest rate range to 0%
This would mean that the player would not have to worry about running out of funds. A nice solution could also be to have fractional values between 0 and 1%, which would make the game simply easy and light, but not trivial and therefore a bit boring. By the way, extending the maximum interest rate to 10 or even 20 or 30% would make the game more demanding for those players who expect it.
4. Adding the "My uncle is the king of Zamunda" option ;)
Do you remember the movie Coming to America? If the player chooses this option, he will never run out of money. He would get, for example, £10M or £100M to start. Each time the amount in the account would drop to half, the king would send more money, each time in larger amounts, so that the player would not have to worry about anything. A special message could appear on this occasion.

@merni-ns
Copy link
Contributor Author

merni-ns commented Jan 29, 2024

This doesn't seem like a good solution to me. Someone who wants to build freely and not worry about the lack of cash (sometimes that includes me) rather doesn't want to see constantly increasing debt. It looks bad and doesn't give you a sense of freedom.

They see no such thing, unless they go out of their way to open the company finance window. In the status bar "infinite money" is displayed. I will be soon adding screenshots and updating the PR description to better explain what happens from a player perspective.

It's also not like everyone who wants to play casually isn't interested in making money. I think that even a player for whom the economy is not the most important thing in this game would rather want it to make some sense anyway. Spending money you don't have doesn't seem logical.

That is not what happens internally. It is just that you are allowed to rack up infinite negative balance. If you are anyway making a mostly profitable company, your balance will still be positive as it ever was. In either case, if you really care about money, you can open the finance window and the total will be accurate, unlike the situation with cheats.

I think this could have been solved in at least a few other ways, which I also think would be simpler and wouldn't cause such complications. 1. Make the Infinite money option add a very large amount that is difficult to squander. Instead of allowing the player to go into debt forever, give him enough money so that he never actually runs out of it.

This is rather arbitrary. How much money can you give? Theoretically any amount of money, even INT64_MAX, can be eventually spent.

2. Adding the "Own funds" feature This would be an alternative to a loan and it could be arranged in the same way before the game starts. A player who wanted to have truly infinite money could simply enter, for example, £1 trillion and not have to worry about it anymore.

Initial loan setting already exists. Perhaps the minimum of 2% on interest rate could be removed to allow this. In any case, once again, this means thinking about money (how much to give yourself? will it be enough?) I just want to forget that this feature called 'money' exists.

3. Extension of the loan interest rate range to 0% This would mean that the player would not have to worry about running out of funds. A nice solution could also be to have fractional values between 0 and 1%, which would make the game simply easy and light, but not trivial and therefore a bit boring. By the way, extending the maximum interest rate to 10 or even 20 or 30% would make the game more demanding for those players who expect it.

I agree that this could be possible. It has to be seen whether any technical reason prevents this. But this is strictly unrelated and orthogonal to this feature.

4. Adding the "My uncle is the king of Zamunda" option ;) Do you remember the movie Coming to America? If the player chooses this option, he will never run out of money. He would get, for example, £10M or £100M to start. Each time the amount in the account would drop to half, the king would send more money, each time in larger amounts, so that the player would not have to worry about anything. A special message could appear on this occasion.

This is basically the same as the existing money cheat. The reason I do not go with this is that it messes up all financial statements of the company and is also more complicated and less elegant to implement.

@LC-Zorg
Copy link

LC-Zorg commented Jan 29, 2024

This doesn't seem like a good solution to me. Someone who wants to build freely and not worry about the lack of cash (sometimes that includes me) rather doesn't want to see constantly increasing debt. It looks bad and doesn't give you a sense of freedom.

They see no such thing, unless they go out of their way to open the company finance window. In the status bar "infinite money" is displayed. I will be soon adding screenshots and updating the PR description to better explain what happens from a player perspective.

They see because opening the finance window is not difficult. ;) And then the sight of the constantly increasing debt will be quite unpleasant.
I know what it looks like from the player's perspective (preview).

  1. Make the Infinite money option add a very large amount that is difficult to squander. Instead of allowing the player to go into debt forever, give him enough money so that he never actually runs out of it.

This is rather arbitrary. How much money can you give? Theoretically any amount of money, even INT64_MAX, can be eventually spent.

Infinite money doesn't have to be literal. Such £1 trillion would not be wasted in practice, unless someone made it a challenge, which could also be interesting. ;)

@merni-ns
Copy link
Contributor Author

merni-ns commented Jan 30, 2024

They see because opening the finance window is not difficult. ;) And then the sight of the constantly increasing debt will be quite unpleasant. I know what it looks like from the player's perspective (preview).

I am not here to protect players from deliberately opening a window and getting upset or whatever. If a player totally does not care about money, they can just not open the finance window. There is already a setting to avoid opening that window annually, which can ve used in combination with this feature. I have already hidden the balance from the status bar to avoid distraction/confusion, but retained it in the finance window so that someone genuinely curious about their finances can still check. It stands to reason that players who play without caring about finance should not expect to find pleasing numbers in the finance window.

By the way, even if you give the player a zillion pounds at the start, the finance window will still be full of red in the annual profit figures, which are much more prominent in that window than the bank balance.

One of the main merits of the method in this PR, IMO, is that it does not add any arbitrary money at random, so all financial numbers are fully accurate. This is an advantage over cheating money and over most of the methods you suggested.

Infinite money doesn't have to be literal. Such £1 trillion would not be wasted in practice, unless someone made it a challenge, which could also be interesting. ;)

If someone wants a challenge of spending 1 trillion, they can use GS or cheats. Infinite money is not the same as 1 trillion money IMO.

@Ufiby
Copy link

Ufiby commented Jan 30, 2024

In a slightly different way, let's call it "free money". It gives you the opportunity to build the way you want, buy transport, service and interest rate, everything costs 0 money. An idea?

@PeterN
Copy link
Member

PeterN commented Jan 30, 2024

Should be squashed on merge as all the commits (except #2) are part of the feature.

@PeterN PeterN merged commit 5a88027 into OpenTTD:master Jan 30, 2024
20 checks passed
@merni-ns merni-ns deleted the freelunch branch January 31, 2024 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preview This PR is receiving preview builds
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants