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

Increase max loan for big companies #5298

Closed
DorpsGek opened this issue Sep 15, 2012 · 16 comments
Closed

Increase max loan for big companies #5298

DorpsGek opened this issue Sep 15, 2012 · 16 comments
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay

Comments

@DorpsGek
Copy link
Member

Rosuav opened the ticket and wrote:

In a huge company that's trying to expand massively (esp when using a NewGRF like vactrain), the 500K max loan is ridiculously small. Attached patch ensures that borrowing money is still viable by permitting a loan up to the current company value, if that is greater than the max would otherwise be.

Open questions:

* Is Company::GetIfValid(_local_company) the right way to get a company pointer for the player's company?
* What happens in multiplayer? Is max loan mandatorially global?
* Should this be an option, controlled from the Advanced Options dialogue?

Patch originally made against svn r24334 (via git), applies cleanly to current r24524.

Attachments

Reported version: trunk
Operating system: All


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

Terkhen wrote:

In my opinion, the goal of loans is to give small companies an easier start. Because of this, I don't think that big companies should be able to get greater loans than smaller ones. If we were to allow this, new companies would have a hard time when trying to make their own niche in a multiplayer game that has been running for some time. I do agree that a greater customization of the maximum loan would be a good thing, though.

Given that bigger loans (both in the "only for big companies" and in the "for everyone" flavours) might not be wanted in every game, this should of course be selectable by the user in some way. If your suggestion were to be implemented, it should be an advanced setting. Another option is to modify the current "maximum loan" setting to make it a completely customizable number and allow it to have higher values.


This comment was imported from FlySpray: https://bugs.openttd.org/task/5298#comment11526

@DorpsGek
Copy link
Member Author

Rosuav wrote:

Fair enough.

Since submitting this patch, I've been playing the patched game, and there's another issue, which may turn out to be quite nasty: Nothing triggers a recalculation of the max loan. For this to work out, something would need to re-check this (annually?), and deal with what happens when the max loan goes down, like when you borrow heaps of money to build infrastructure (permit current loan to exceed max loan, or record the previous max loan and never reduce it, or something else??). This isn't such a simple easy patch as I thought it might be.

My goal with this change was to make it possible to get piles of money, but instead of using the Cheats menu, do something that just lets you borrow more. Doing it as a config option might serve; it would also solve the other issue, namely that borrowing/repaying 10K is useless when your debt is hundreds of million.

How about - just throwing an idea out there - a scaling factor for both max loan and the borrow/repay amounts? If you set it to 1, behaviour is as per current. Set it to 2 and you can borrow twice as much, but your increment is 20K. Set it to 100 and you borrow and repay a million quid at a time, up to a fairly hefty maximum. Would that make sense?

Might have to deal with problems if someone tries to change the scaling factor when they don't have a valid loan - may need to immediately make them borrow up to the next new increment.


This comment was imported from FlySpray: https://bugs.openttd.org/task/5298#comment11527

@DorpsGek
Copy link
Member Author

Terkhen wrote:

The problem you mention makes me wonder about the possibility of desyncs. Your changes to maximum loan amounts should probably be done at fixed intervals (for example monthly or yearly) and when the game is loaded (in such a way that the value is exactly the same that it was at the previous fixed interval where it was updated). If it is possible for a client that joins a multiplayer game to get a different maximum loan amount for any of the companies present in the game than the maximum loan amount calculated by the other clients, you will get a desync as soon as one client thinks that there is enough money in a company for running some command and another one think that there is not.

The scaling factor sounds nice to me. It should probably be an advanced setting.


This comment was imported from FlySpray: https://bugs.openttd.org/task/5298#comment11528

@DorpsGek
Copy link
Member Author

Rosuav wrote:

I've dug around in the code and tried to figure out the right places to do things, and I'm not sure I've succeeded. However, attached is a patch that creates an Advanced Setting for the loan scale factor.

I consumed one SDT_NULL to create the new setting, but it still breaks savefiles. Assistance requested in sorting this out!

It seems there's a lot of places to mention the new setting. Is there anything I've omitted to do?

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/5298#comment11536

@DorpsGek
Copy link
Member Author

Terkhen wrote:

There must have been some error on the upload, at the patch file you attached is empty. What do you mean exactly with "it breaks savefiles"?


This comment was imported from FlySpray: https://bugs.openttd.org/task/5298#comment11537

@DorpsGek
Copy link
Member Author

Rosuav wrote:

Oops! Re-attaching.

When I try to load a game that was saved before the patch was applied, the Load Game dialogue shows red text in the Game Details: "Broken savegame - invalid chunk size". My interpretation of that is that I errantly expanded or shrank the options section, which is what I thought taking out an SDT_NULL entry was supposed to avoid. Hence, I must have mucked something up.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/5298#comment11538

@DorpsGek
Copy link
Member Author

Terkhen wrote:

I think that what the SDT_NULL block that you replaced means is that since saveload version 1 (this would be a from field, taken from the [defaults]) to saveload version 140, a setting with length 1 existed and that it should be ignored. Removing it will probably break loading games that use saveload version from 1 to 140.

Your new block means that your new setting existed from savegame version 1 to savegame version max (the default values). Since all existing savegames fall in that range and they don't have your new setting, OpenTTD will fall to load them. What you probably should do (I'm not 100% certain as I have not modified the settings since before they were moved to the new ini format) is to leave the SDT_NULL block as is (since it is only used for loading old savegames), to bump the saveload version (you can find it at src/saveload/saveload.cpp) and to define your setting with a "from" field set to the new saveload version. That way, old savegames will be loaded correctly (as they are not expected to have the new setting) and new savegames will be loaded too as they will contain the setting.

I'm not sure about which would be the value of the setting when you load a savegame without it. If it results to be "undefined" you might want to give src/saveload/afterload.cpp a look to know how to initialize values that are not present in old savegames.


This comment was imported from FlySpray: https://bugs.openttd.org/task/5298#comment11539

@DorpsGek
Copy link
Member Author

Rosuav wrote:

Ah! Thanks for that explanation. Much appreciated! Now it works beautifully. Fresh patch attached (replaces the previous ones).

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/5298#comment11540

@DorpsGek
Copy link
Member Author

Rosuav wrote:

After some experimentation, I've become dissatisfied with 125,000,000 pound loans, so I've upped the option to a 16-bit number. This will break savefiles done using the previous patch, and should be considered an alternative to the above.

Take your pick! :)

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/5298#comment11542

@DorpsGek
Copy link
Member Author

Terkhen wrote:

With your patch applied, when you change the loan factor, the values for the maximum loan shown at the difficulty window stay the same. I consider that a bug.

Did you check how this change affects AIs? They should realize that they are able to loan more money, but I suspect that they still calculate with the old value. I don't know if game scripts do something with loans too.

IMO a loan of 255M € is quite huge already. I consider that, with the "vanilla" settings, a loan of 10M € is already enough to turn the game into a sandbox. Maybe a limit of 20 would be reasonable.

If your problems with loans appear when you are using NewGRFs with quite increased costs, maybe you should consider another approach. NewGRFs such as Base Costs (http://dev.openttdcoop.org/projects/basecosts) allow you to reduce each cost in the game separately. Another way of dealing with this could be introducing a new NewGRF base cost that allows to modify loans in a similar way than the other base costs do for certain costs. You can check more about NewGRF base costs here: http://newgrf-specs.tt-wiki.net/wiki/BaseCosts


This comment was imported from FlySpray: https://bugs.openttd.org/task/5298#comment11544

@DorpsGek
Copy link
Member Author

Rosuav wrote:

You're right that the difficulty window doesn't change; I'm not sure whether or not it should, as this affects everything to do with loans.

AIs should "notice" the different value. They're part of one of the edits in the patch. I haven't actually tested it though.

And yeah, that's a pretty ridiculously high loan :) I just figured, why limit it? You're right that it can turn the game into a sandbox, but the only thing I'd consider changing would be the interest rate - 4% isn't all that high. With higher interest, a ridiculous loan will self-manage.


This comment was imported from FlySpray: https://bugs.openttd.org/task/5298#comment11546

@DorpsGek
Copy link
Member Author

Terkhen wrote:

I wonder if the right approach for changing maximum loan, interest and the like is to let Goal Scripts control these values and other values related to economy. That way you could be able to implement custom economic models with Goal Scripts, just as you can already implement custom town growth models now.


This comment was imported from FlySpray: https://bugs.openttd.org/task/5298#comment11604

@DorpsGek
Copy link
Member Author

planetmaker wrote:

Certainly it'd be interesting to give GS an interface to these variables. But still, a more flexible max loan setting in the new game or difficulty or adv. settings dialogue would be nice.


This comment was imported from FlySpray: https://bugs.openttd.org/task/5298#comment11610

@DorpsGek
Copy link
Member Author

DorpsGek commented Nov 3, 2012

Rosuav wrote:

Changes made to trunk have bumped the version number, so the patches above no longer cleanly apply. Modified patch attached; no other changes AFAIK.

UI tweak attached too; reducing the loan scale factor after acquiring max loan results in your current loan exceeding your max loan, with the minor UI bug that the "Borrow" button is enabled but will error on being clicked. This patch is completely independent of the loan scaling patch.

Additional patch attached to permit the interest rate to go higher. It's now possible to make loans truly significant. See how high an interest rate you can survive with!

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/5298#comment11653

@DorpsGek
Copy link
Member Author

krinn wrote:

You will do random bugs on AI/GS, and at bare minimum if they are aware of it, they won't be able to use such huge number because of squirrel integer limit.
See : http://bugs.openttd.org/task/5410?project=1


This comment was imported from FlySpray: https://bugs.openttd.org/task/5298#comment11884

@DorpsGek
Copy link
Member Author

andythenorth closed the ticket.

Reason for closing: Won't implement

Mass closure of patch tickets with no commentary for nearly 5 years. Goal is to reduce patch queue as an experiment to see if it aids faster reviewing and rejection/acceptance (it may not). If this offends you and the patch is maintained and compiles with current trunk, discuss with andythenorth in irc. (andythenorth has no ability to review patches but can re-open tickets).


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

@DorpsGek DorpsGek added Core flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay labels Apr 7, 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/) patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay
Projects
None yet
Development

No branches or pull requests

1 participant