[patch] Improved Shares
Moderator: OpenTTD Developers
[patch] Improved Shares
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.
[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
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.
[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 189 times
-
- Improved Shares - 27747 - [V7.1].patch
- Save fix, bump and convert
- (26 KiB) Downloaded 205 times
-
- Improved Shares - 27747 - [V7.2].patch
- Everything now saving
- (27.07 KiB) Downloaded 208 times
Last edited by burty on 20 Feb 2017 15:08, edited 17 times in total.
My Patches: Lifetime profit patch | Improved Shares [ON HIATUS]
Re: Improved Shares
">> 2" is nerdish for "/ 4".economy.cpp:1872 wrote: cost.AddCost(CalculateCompanyValue(c) >> 2);
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
Re: Improved Shares
Thank you frosch. It was a case of not seeing the wood for the trees 
Updated first post with patch file against 26228

Updated first post with patch file against 26228
My Patches: Lifetime profit patch | Improved Shares [ON HIATUS]
Re: [patch] Improved Shares
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.
Yes I like this idea 
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.


Skippern
OpenTTD Mac user
OpenTTD Mac user
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: [patch] Improved Shares
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.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.
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML
Re: [patch] Improved Shares
This already exists doesn't it?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)?
Company A window:
Company B owns 50%
Company C owns 10%
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: 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?
I am glad you like the idea and I hope to take this further and (maybe get it to trunk (unlikely but never know))skippern wrote: Yes I like this idea
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*
My Patches: Lifetime profit patch | Improved Shares [ON HIATUS]
Re: [patch] Improved Shares
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
OpenTTD Mac user
Re: [patch] Improved Shares
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 companiesplanetmaker wrote: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.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.
Skippern
OpenTTD Mac user
OpenTTD Mac user
Re: [patch] Improved Shares
You mean an aggregated type of view? Something like an extra window? Where you haveskippern 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 companiesplanetmaker wrote: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.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.
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%
My Patches: Lifetime profit patch | Improved Shares [ON HIATUS]
Re: [patch] Improved Shares
I would like something like that, though it could be combined with the existing part, something like:burty wrote:You mean an aggregated type of view? Something like an extra window? Where you haveskippern 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
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%
Company A owns shares in:
Company C - 10%
Company B - 5%
Company D owns 5%
Company E owns 10%
Skippern
OpenTTD Mac user
OpenTTD Mac user
Re: [patch] Improved Shares
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?skippern wrote:I would like something like that, though it could be combined with the existing part, something like:burty wrote:You mean an aggregated type of view? Something like an extra window? Where you haveskippern 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
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%
Company A owns shares in:
Company C - 10%
Company B - 5%
Company D owns 5%
Company E owns 10%
My Patches: Lifetime profit patch | Improved Shares [ON HIATUS]
Re: [patch] Improved Shares
For completenessburty 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?
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
OpenTTD Mac user
Re: [patch] Improved Shares
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
Sent from my iPhone using Tapatalk
My Patches: Lifetime profit patch | Improved Shares [ON HIATUS]
Re: [patch] Improved Shares
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
Hope you enjoy
- Attachments
-
- Improved Shares - 26277 - [V6].patch
- (20.72 KiB) Downloaded 218 times
My Patches: Lifetime profit patch | Improved Shares [ON HIATUS]
Re: [patch] Improved Shares [ON HIATUS]
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! 

-
- Tycoon
- Posts: 1397
- Joined: 23 Feb 2014 22:02
Re: [patch] Improved Shares [ON HIATUS]
So perhaps an integrated group would use different colors for its trains,buses,and planes?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!
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%.
Re: [patch] Improved Shares
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.
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 170 times
-
- Improved Shares - 27747 - [V7.1].patch
- Fixes and save game conversions
- (26 KiB) Downloaded 174 times
-
- Improved Shares - 27747 - [V7.2].patch
- (27.07 KiB) Downloaded 169 times
My Patches: Lifetime profit patch | Improved Shares [ON HIATUS]
Re: [patch] Improved Shares
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
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 173 times
-
- Enhanced Shares V7_2.zip
- Windows 64 bit build
- (8.48 MiB) Downloaded 170 times
My Patches: Lifetime profit patch | Improved Shares [ON HIATUS]
Who is online
Users browsing this forum: No registered users and 13 guests