Page 1 of 1

Max Loan amount not sending over to other clients during multiplayer

Posted: 29 May 2020 07:12
by djsider
Hi all,

I'm wondering if this is a bug or not with the way this setting is handled during multiplayer. We run with some pretty expensive trainset (2cc) and a pretty advanced start (1975) so the default max loan is not enough to get a good foundation going. It would take a few years of basically watching 1 train go back n forth.

I run the server and we decided we would set the max loan to be 3 times what is currently available. Changed the setting.ini MAX from 500000 to 1500000. Started a new game, and when the other client connects, they are unable to take out up to the max loan to start building up their empire. Is this considered a bug? Where can I look to see how the settings.ini values and the game settings are supposed to be passed over to other clients?

Re: Max Loan amount not sending over to other clients during multiplayer

Posted: 29 May 2020 11:27
by jfs
The maximum value for max_loan is defined to be 500k in the settings template (table definition):

Code: Select all

[SDT_VAR]
base     = GameSettings
var      = difficulty.max_loan
type     = SLE_UINT32
from     = SLV_97
guiflags = SGF_NEWGAME_ONLY | SGF_SCENEDIT_TOO | SGF_CURRENCY
def      = 300000
min      = 100000
max      = 500000
interval = 50000
str      = STR_CONFIG_SETTING_MAXIMUM_INITIAL_LOAN
strhelp  = STR_CONFIG_SETTING_MAXIMUM_INITIAL_LOAN_HELPTEXT
strval   = STR_JUST_CURRENCY_LONG
cat      = SC_BASIC
If you set it to a value outside the valid range, the value just gets clamped to the valid range. So even though you wrote 1500000 in settings.ini, when the game loads the settings it sees the out-of-range value and changes it back to the allowed maximum of 500000, and that's what gets used during the game.

Re: Max Loan amount not sending over to other clients during multiplayer

Posted: 29 May 2020 15:56
by djsider
I think you’re thinking about the value in OpenTTD.cfg which is what the current in game settings will modify.

First, I changed the settings.ini version and then went in game to set the max loan to the max defined in settings.ini. This works fine and as expected. I’m able to take out the big loan at the beginning of game.

The only issue was that clients joining my multiplayer game did not have the same max loan amount. I had to ship them the compiled exe and then they were able to take that loan amount out.

Re: Max Loan amount not sending over to other clients during multiplayer

Posted: 29 May 2020 20:47
by Yexo
djsider wrote: 29 May 2020 15:56I had to ship them the compiled exe and then they were able to take that loan amount out.
That's working as intended. Unless you're very careful with the changes you make, most source-code changes will make the server incompatible with clients unless they have exactly the same changes applied. In this case the effect was luckily quickly visible, other times you might simply get desyncs.

Re: Max Loan amount not sending over to other clients during multiplayer

Posted: 30 May 2020 01:11
by djsider
So the checks for loan and possibly other settings are not sent to server for checking? I was surprised that the save game that was transferred to other clients did not get the same ‘in-game’ settings. Or was it just double checking against the client’s own version of settings.ini and not trusting the one from game save?

Re: Max Loan amount not sending over to other clients during multiplayer

Posted: 30 May 2020 07:14
by jfs
Server and client need to be running the exact same game logic for multiplayer to possibly work, and this includes all limits for game settings. Every client also cross-checking settings changes when receiving a command for them is just common sense to avoid potential loopholes for cheating/hacking.

Re: Max Loan amount not sending over to other clients during multiplayer

Posted: 31 May 2020 20:35
by djsider
I'm not sure this is considered cheating or hacking. This is the server trying to change the max limit on a setting. If you were a client joining this server, shouldn't it just take the server and game settings as the truth? Everyone would be running the exact same settings in this case.

Re: Max Loan amount not sending over to other clients during multiplayer

Posted: 31 May 2020 22:34
by Yexo
djsider wrote: 31 May 2020 20:35 I'm not sure this is considered cheating or hacking. This is the server trying to change the max limit on a setting. If you were a client joining this server, shouldn't it just take the server and game settings as the truth? Everyone would be running the exact same settings in this case.
And it does exactly that. Clients that call settings from the savegame it gets from the server upon joining.

Limits however are not settings. Limits are mostly hardcoded into the gamecode itself. There is no reason to send such hardcoded values over the network at all, since a basic assumption for OpenTTD networking is that both the server and all clients have been built from the same source code, and as such have the same limits.

Re: Max Loan amount not sending over to other clients during multiplayer

Posted: 01 Jun 2020 00:49
by Eddi
djsider wrote: 31 May 2020 20:35 I'm not sure this is considered cheating or hacking.
yes, it definitely is.

if you change any code (including settings.ini) you must mark your version as modified (by the license requirements) and give this changed version to all other players that want to play on the server.

Re: Max Loan amount not sending over to other clients during multiplayer

Posted: 04 Jun 2020 16:10
by djsider
Please keep in mind it’s not cheating because all the players in my game want to have bigger seed money. We just want the option to change the setting on the server and see it as a bug that other clients don’t get the server values.

So what we are saying is that limits superceed settings, even if the save game will give the same option for all players in that game. I personally find this weird since it should only be server choice. The limits should only be applied when starting the game.

Is there a reason it checks limits during the game when the setting itself should be sufficient?

Re: Max Loan amount not sending over to other clients during multiplayer

Posted: 04 Jun 2020 16:14
by djsider
Also want to get my terminology checked. This seems like what they should be but some of you are telling me limits has more to do than just controlling the values settings can be during there settings page.

Limit: values that dictate what the per game settings can be set to. Ex: min-200 max-1000

Settings: what is actually being used in the save game. Every player will share the same settings in the game.