[patch] Improved Shares

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
User avatar
burty
Transport Coordinator
Transport Coordinator
Posts: 326
Joined: 16 Jun 2006 17:18
Location: Somwhere near a computer

[patch] Improved Shares

Post by burty »

I saw "TheJosh" wiki page about his plans to revamp/rework how shares work and found it interesting so after searching the forums and not being able to find anything similar being worked upon I decided that I would take a stab at doing it myself.

I will happily take critiscim of both the quality of the code (constructive please) and the patch. Hope you enjoy
Spoiler contains V1 -> V7 change log, hidden to keep post length smaller.
[+] Spoiler
[V1 - Against r26228]
- Made GUI changes so it shows multiples of 5%
- Made GUI changes so the button says buy in multiples of 5%
- Adjusted calculation so it's 1/20th of the value of the company
[V2 - Against r26228]
- Added Ctrl + Click
- Changed STR_ERROR_CAN_T_SELL_25_SHARE_IN to STR_ERROR_CAN_T_SELL_5_SHARE_IN
- Changed STR_ERROR_CAN_T_BUY_25_SHARE_IN_THIS to STR_ERROR_CAN_T_BUY_5_SHARE_IN_THIS
[V3 - Against r26228]
- Fixed selling with ctrl+click
[V4 - Against r26233]
- Allow company to enable/disable shares
- Added button to company GUI
- Added 2 strings for the Enable/Disable GUI button
[V5 - Against r26235]
- Fixed the multiplayer issue where the commands where not being sent over the network
[V6 - Against r26277]
- Added in dividends payment at the end/start of the year. This is fixed at 1% of company value per share owned.
[V7 - Against r27747]
- Completed dividend setting window
- This setting is now used when deciding how much to pay at year end
- Disabled the enable/disable button when allow shares setting is false
- Buy 5% button disabled when company is not set to sell shares
[V7.1 - Against r27747]
- Shares now save
- Save game bump
- Loading an older save will convert the old share style to the new enhanced share style
[V7.2 - Against r27747]
- Company selling shares now saved
- Payment amount per share owned now saved.

Known Issues
- Doesn't work with NON aware AI
Attachments
Improved Shares - 27747 - [V7].patch
V7 - Dividend payout now set when enabling selling of shares.
(23.64 KiB) Downloaded 159 times
Improved Shares - 27747 - [V7.1].patch
Save fix, bump and convert
(26 KiB) Downloaded 157 times
Improved Shares - 27747 - [V7.2].patch
Everything now saving
(27.07 KiB) Downloaded 173 times
Last edited by burty on 20 Feb 2017 15:08, edited 17 times in total.
frosch
OpenTTD Developer
OpenTTD Developer
Posts: 988
Joined: 20 Dec 2006 13:31
Location: Aschaffenburg

Re: Improved Shares

Post by frosch »

economy.cpp:1872 wrote: cost.AddCost(CalculateCompanyValue(c) >> 2);
">> 2" is nerdish for "/ 4".
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
User avatar
burty
Transport Coordinator
Transport Coordinator
Posts: 326
Joined: 16 Jun 2006 17:18
Location: Somwhere near a computer

Re: Improved Shares

Post by burty »

Thank you frosch. It was a case of not seeing the wood for the trees :)

Updated first post with patch file against 26228
User avatar
skippern
Traffic Manager
Traffic Manager
Posts: 195
Joined: 30 Oct 2013 13:57

Re: [patch] Improved Shares

Post by skippern »

Would it be possible to have on the company window, to have a list of shares owned together with the list of (other companies own X% of this company)?

And also, what happens with the shares owned by a bought company? If company A owns 20% of company B, and company C buys company A, will it take ownership of the 20% shares A have in B? What happens if C already own 80% of B?

With smaller units of shares it makes sence to have a stock list, lets say a graph showing how share value develop over time, either available per company from the company window, or for all companies available from the graph menu.

:arrow: Yes I like this idea :)
Skippern
OpenTTD Mac user
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: [patch] Improved Shares

Post by planetmaker »

skippern wrote:With smaller units of shares it makes sence to have a stock list, lets say a graph showing how share value develop over time, either available per company from the company window, or for all companies available from the graph menu.
I don't see how that relates to the company-% a single share represents. Anyhow, the curve would look identical to the one called 'company value' which is already nicely available.
User avatar
burty
Transport Coordinator
Transport Coordinator
Posts: 326
Joined: 16 Jun 2006 17:18
Location: Somwhere near a computer

Re: [patch] Improved Shares

Post by burty »

skippern wrote:Would it be possible to have on the company window, to have a list of shares owned together with the list of (other companies own X% of this company)?
This already exists doesn't it?
Company A window:
Company B owns 50%
Company C owns 10%
skippern wrote: And also, what happens with the shares owned by a bought company? If company A owns 20% of company B, and company C buys company A, will it take ownership of the 20% shares A have in B? What happens if C already own 80% of B?
This i don't know the answer to although at present I haven't adjusted anything to do with takeovers, that is still handled by the default code.
skippern wrote: Yes I like this idea :)
I am glad you like the idea and I hope to take this further and (maybe get it to trunk (unlikely but never know))

Planetmaker:
I think skippern was referring to just the shares that the _current_company owns? If so it would make it very easy to see if they are worth selling back? However I do agree that the curve would be the same as the already available company value graph.


EDIT: Just realised I was daft last night and didn't add the latest patch *facepalm*
User avatar
skippern
Traffic Manager
Traffic Manager
Posts: 195
Joined: 30 Oct 2013 13:57

Re: [patch] Improved Shares

Post by skippern »

But shouldn't share value increase when somebody tries to buy shares, and drop when somebody sells share? That way even if the graph will ressemble the net worth, there will be two main differences - values are significantly lower - there will be variations depending of how active the stock market is.
Skippern
OpenTTD Mac user
User avatar
skippern
Traffic Manager
Traffic Manager
Posts: 195
Joined: 30 Oct 2013 13:57

Re: [patch] Improved Shares

Post by skippern »

planetmaker wrote:
skippern wrote:With smaller units of shares it makes sence to have a stock list, lets say a graph showing how share value develop over time, either available per company from the company window, or for all companies available from the graph menu.
I don't see how that relates to the company-% a single share represents. Anyhow, the curve would look identical to the one called 'company value' which is already nicely available.
Yes, I would like to see in my company screen how many % shares I own of different companies, their values, and the same when I open the company screen of company A, I would like to see if they own shares in any companies
Skippern
OpenTTD Mac user
User avatar
burty
Transport Coordinator
Transport Coordinator
Posts: 326
Joined: 16 Jun 2006 17:18
Location: Somwhere near a computer

Re: [patch] Improved Shares

Post by burty »

skippern wrote:
planetmaker wrote:
skippern wrote:With smaller units of shares it makes sence to have a stock list, lets say a graph showing how share value develop over time, either available per company from the company window, or for all companies available from the graph menu.
I don't see how that relates to the company-% a single share represents. Anyhow, the curve would look identical to the one called 'company value' which is already nicely available.
Yes, I would like to see in my company screen how many % shares I own of different companies, their values, and the same when I open the company screen of company A, I would like to see if they own shares in any companies
You mean an aggregated type of view? Something like an extra window? Where you have

Company A owns shares in:
Company C - 10%
Company B - 5%

All this data is available if you open up Company Bs' window you see (however you have to open every companys window)

Company B:
Company A owns 5%
User avatar
skippern
Traffic Manager
Traffic Manager
Posts: 195
Joined: 30 Oct 2013 13:57

Re: [patch] Improved Shares

Post by skippern »

burty wrote:
skippern wrote: Yes, I would like to see in my company screen how many % shares I own of different companies, their values, and the same when I open the company screen of company A, I would like to see if they own shares in any companies
You mean an aggregated type of view? Something like an extra window? Where you have

Company A owns shares in:
Company C - 10%
Company B - 5%

All this data is available if you open up Company Bs' window you see (however you have to open every companys window)

Company B:
Company A owns 5%
I would like something like that, though it could be combined with the existing part, something like:

Company A owns shares in:
Company C - 10%
Company B - 5%

Company D owns 5%
Company E owns 10%
Skippern
OpenTTD Mac user
User avatar
burty
Transport Coordinator
Transport Coordinator
Posts: 326
Joined: 16 Jun 2006 17:18
Location: Somwhere near a computer

Re: [patch] Improved Shares

Post by burty »

skippern wrote:
burty wrote:
skippern wrote: Yes, I would like to see in my company screen how many % shares I own of different companies, their values, and the same when I open the company screen of company A, I would like to see if they own shares in any companies
You mean an aggregated type of view? Something like an extra window? Where you have

Company A owns shares in:
Company C - 10%
Company B - 5%

All this data is available if you open up Company Bs' window you see (however you have to open every companys window)

Company B:
Company A owns 5%
I would like something like that, though it could be combined with the existing part, something like:

Company A owns shares in:
Company C - 10%
Company B - 5%

Company D owns 5%
Company E owns 10%
I don't quite see how we need to replicate the existing data somewhere else. I could see the use of a central point where you had each Companys name and under that you had what *they* owned of other companies... But if you want to see who owns what % of a company then just use the existing system?
User avatar
skippern
Traffic Manager
Traffic Manager
Posts: 195
Joined: 30 Oct 2013 13:57

Re: [patch] Improved Shares

Post by skippern »

burty wrote: I don't quite see how we need to replicate the existing data somewhere else. I could see the use of a central point where you had each Companys name and under that you had what *they* owned of other companies... But if you want to see who owns what % of a company then just use the existing system?
For completeness

It is just as interesting, from a stock trader's point of view what stocks comes on the deal, as what stocks he have to look for elsewhere.

For instance it might be of interest to take over company A, but if A owns too much of B the situation changes. I might therefor wish to sell my part of B before I buy A

Reading pink newspapers you will rather see which companies A owns than which companies owns parts in A
Skippern
OpenTTD Mac user
User avatar
burty
Transport Coordinator
Transport Coordinator
Posts: 326
Joined: 16 Jun 2006 17:18
Location: Somwhere near a computer

Re: [patch] Improved Shares

Post by burty »

Progress has slowed as im now implementing the dividends stuff which is more new than adjusting and will take several game years to test properly.



Sent from my iPhone using Tapatalk
User avatar
burty
Transport Coordinator
Transport Coordinator
Posts: 326
Joined: 16 Jun 2006 17:18
Location: Somwhere near a computer

Re: [patch] Improved Shares

Post by burty »

Attached is V6 - This now includes dividends payment of 1% of company value for each share owned by a company... I need to finish off the "set dividend" window which is partly done and shows when you enable shares via the Company View...

Hope you enjoy
Attachments
Improved Shares - 26277 - [V6].patch
(20.72 KiB) Downloaded 183 times
xmart2k
Engineer
Engineer
Posts: 91
Joined: 04 May 2006 07:36
Contact:

Re: [patch] Improved Shares [ON HIATUS]

Post by xmart2k »

Great work! Keep it up. I always wanted this feature to be expanded. There was an old patch with subsidiaries that I liked a lot. I enjoyed the idea of separating my transport types. One company was using only trains, one, only trucks... It'll be interesting if an AI could be managing a player company. Anyway, congrats and hope this will get to trunk! :bow:
Baldy's Boss
Tycoon
Tycoon
Posts: 1396
Joined: 23 Feb 2014 22:02

Re: [patch] Improved Shares [ON HIATUS]

Post by Baldy's Boss »

xmart2k wrote:Great work! Keep it up. I always wanted this feature to be expanded. There was an old patch with subsidiaries that I liked a lot. I enjoyed the idea of separating my transport types. One company was using only trains, one, only trucks... It'll be interesting if an AI could be managing a player company. Anyway, congrats and hope this will get to trunk! :bow:
So perhaps an integrated group would use different colors for its trains,buses,and planes?

It would be nice to have some control over a company of which you owned a majority,rather than going straight from having no influence to its being an indistinguishable part of your company when you reach 100%.
User avatar
burty
Transport Coordinator
Transport Coordinator
Posts: 326
Joined: 16 Jun 2006 17:18
Location: Somwhere near a computer

Re: [patch] Improved Shares

Post by burty »

After nearly 2 years of Hiatus, I've taken another look at this and plan to finish it off.
First update however is only bump to the latest trunk. Next up on my TODO list is to finish that GUI window.

I'm looking for people who want to test this in both Single and Multiplayer games and find any bugs. If you are interested please let me know and I'll ensure I post an updated binary for Windows/Linux (let me know if you need Linux as I run Windows natively but have VMs for Linux that I should be able to compile OpenTTD)

Please see first post for full changelog.
Attachments
Improved Shares - 27747 - [V6.1].patch
(20.78 KiB) Downloaded 134 times
Improved Shares - 27747 - [V7.1].patch
Fixes and save game conversions
(26 KiB) Downloaded 135 times
Improved Shares - 27747 - [V7.2].patch
(27.07 KiB) Downloaded 138 times
User avatar
burty
Transport Coordinator
Transport Coordinator
Posts: 326
Joined: 16 Jun 2006 17:18
Location: Somwhere near a computer

Re: [patch] Improved Shares

Post by burty »

Attached are binaries compiled with the enhanced shares:v7.2 trunk:r27747

I hope you have fun and please let me know of any issues you encounter :)
Attachments
V7_2.tar.xz
Ubuntu 16.04 64bit build
(4.6 MiB) Downloaded 136 times
Enhanced Shares V7_2.zip
Windows 64 bit build
(8.48 MiB) Downloaded 137 times
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 6 guests