Page 1 of 1

Move "give money" to company window

Posted: 07 Jan 2013 17:52
by estys
An attempt to implement "Change the "give money to" function so that money is donated to the company and not a specific player" (from the TODO list) raises some questions which I would like to hear your opinions on. My implementation basically adds a button to the company gui and removes the give money selection from the client list.

This allows giving money to a company which has no player. However, since the original implementation of the "give money" feature uses the "send to team" network chat functionality to notify the players, and since there is no player in that team, the message is not displayed for any player (also not at the giver). So, there is no confirmation, that the action succeeded (other than the decreased money...). The question is now, whether this is desireable and, if not, what would be the best solution.

The easiest one is not to display the button, if there is no player in the company, but i doubt that this is a good solution, since it relates the company finance to the network status.

A second also rather easy option would be to change the type of the message not to be a team chat, but a broadcast, making it available to all players (incl. spectators), so it is not "secret" any more. This is also very easy to implement, but still does not convince me to 100%.

The third option, that comes to my mind is to make a newspaper message of the company information category of it. This also would make it an "official" notification, not related to the network at all, and would allow to include the give-money feature also in offline/singleplayer mode (e.g., to finacially support an AI). (Potentially, this would alo require a notification to the AI so it can react. (Are there even notification callbacks for the AI? This is IMHO already an additional step/patch on top then.))


Any other ideas? What are your thoughts on this? I would be interested in your opinions.

Re: Move "give money" to company window

Posted: 07 Jan 2013 18:00
by planetmaker
estys wrote: The third option, that comes to my mind is to make a newspaper message of the company information category of it. This also would make it an "official" notification, not related to the network at all, and would allow to include the give-money feature also in offline/singleplayer mode (e.g., to finacially support an AI). (Potentially, this would alo require a notification to the AI so it can react. (Are there even notification callbacks for the AI? This is IMHO already an additional step/patch on top then.))
I think that makes most sense, especially also for the reasons you outlined with AI and single player. News events can be parsed by AIs. And having a global message in MP that company A transfers money to company B is not too bad either.

Re: Move "give money" to company window

Posted: 07 Jan 2013 20:14
by Zuu
To inform AIs you would issue an AI Event. All subclasses of AIEvent in the API doc is different events that the AI can receive: http://noai.openttd.org/api/1.2.3/classAIEvent.html

Pick one of them of your choice and take a look how it is implemented in OpenTTD.

Re: Move "give money" to company window

Posted: 08 Jan 2013 20:05
by estys
Please find attached two patches, to move the give money command to the company gui and to change the notification to use a news item. There is no additional event for the AI implemented for now.

In the process of moving the command, to stay clean, it was necessary to rename some strings. E.g., STR_NETWORK_CLIENTLIST_GIVE_MONEY should rather be STR_COMPANY_VIEW_GIVE_MONEY_BUTTON. I renamed them in all src/lang/*.txt files and removed the obsolete strings (that's why the diff files are so big). There are some new ones (for the newspaper), which were added just to english.txt.

Re: Move "give money" to company window

Posted: 31 Mar 2013 09:25
by estys
Update for r25127.

Re: Move "give money" to company window

Posted: 24 Dec 2014 15:56
by estys
Update for r27088

Re: Move "give money" to company window

Posted: 26 Feb 2017 13:21
by burty
Updated the move diff to be against R27748