Move "give money" to company window

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Post Reply
estys
Engineer
Engineer
Posts: 4
Joined: 07 Jan 2013 17:19

Move "give money" to company window

Post by estys » 07 Jan 2013 17:52

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.

User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9309
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Move "give money" to company window

Post by planetmaker » 07 Jan 2013 18:00

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.

User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: Move "give money" to company window

Post by Zuu » 07 Jan 2013 20:14

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.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)

estys
Engineer
Engineer
Posts: 4
Joined: 07 Jan 2013 17:19

Re: Move "give money" to company window

Post by estys » 08 Jan 2013 20:05

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.
Attachments
0001-Add-Move-giving-money-from-client-list-to-company-vi.patch
-Add: Move giving money from client list to company view.
(142.18 KiB) Downloaded 181 times
0002-Add-Use-news-item-for-notification-of-company-giving.patch
-Add: Use news item for notification of company giving money instead of team chat.
(66.89 KiB) Downloaded 125 times

estys
Engineer
Engineer
Posts: 4
Joined: 07 Jan 2013 17:19

Re: Move "give money" to company window

Post by estys » 31 Mar 2013 09:25

Update for r25127.
Attachments
0001-Add-Move-giving-money-from-client-list-to-company-vi.patch
(145.37 KiB) Downloaded 147 times
0002-Add-Use-news-item-for-notification-of-company-giving.patch
(70.16 KiB) Downloaded 181 times

estys
Engineer
Engineer
Posts: 4
Joined: 07 Jan 2013 17:19

Re: Move "give money" to company window

Post by estys » 24 Dec 2014 15:56

Update for r27088
Attachments
0001-Add-Move-giving-money-from-client-list-to-company-vi.patch
(160.11 KiB) Downloaded 150 times
0002-Add-Use-news-item-for-notification-of-company-giving.patch
(73.19 KiB) Downloaded 145 times

User avatar
burty
Transport Coordinator
Transport Coordinator
Posts: 326
Joined: 16 Jun 2006 17:18
Location: Somwhere near a computer

Re: Move "give money" to company window

Post by burty » 26 Feb 2017 13:21

Updated the move diff to be against R27748
Attachments
0001-Add-Move-giving-money-from-client-list-to-company-R27748.patch
(138.42 KiB) Downloaded 102 times

Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: Google [Bot] and 3 guests