Page 1 of 18

Infrastructure Sharing

Posted: 05 May 2008 01:59
by Gedemon
I've made some change to Vikthor's tracksharing patch from subsidiaries & contracts thread.

I really hope this is MP stable, it seems to be ok on my LAN, but I would like to see it tested on the net (Ammler ? ;) )

what's in :
  • patch setting to enable sharing of :
  • railway tracks
  • railway stations
  • railway depots
  • airports (and air depots)
  • road stops
  • road depots
  • water depots
  • docks
  • and also :
  • depot owner provision (% of build cost)
  • cost of 1000 tons per tiles on shared tracks
  • landing fee (per tons of cargo capacity)
  • fee for harbours (new)
  • fee for road stops (new)
  • enable each activated patch settings to be selected by player (see screenshot)
  • set delay for individual settings validation (so you won't be surprised by brutal change of prices)
When activated, individual settings can be set via your company windows (button "sharing" under "build HQ")


*** latest version v0.3 r13031 ***

Changelog v0.3 :
- added : show cost or income animation above HQ when calculating tracks payments
- added : send news message when changing sharing settings
- fixed : Visual Studio project files
- update to r13031
- warning : savegame from 0.1 can't be loaded (0.2 to 0.3 should be ok)

changelog v0.2 :
- removed : max train size and min train speed. Those should be set by another patch (Waypoint or signals restriction)
- added : fee for road stops per tons of cargo capacity (patch & player setting)
- added : fee for harbours per tons of cargo capacity (patch & player setting)
- added : show cost or income animation on station fee paiement
- added : remove station fee from vehicle annual profit
- fixed : do not assume that a station (or tile) is owned by a player
- warning : won't load savegame from 0.1

changelog v0.1 :
- change : max train length value is now tiles instead of wagons
- fix : do not use v->max_speed to check min speed, as it can be lowered when entering depot or station. Use cached_max_speed instead
- fix : typo, variables, use MAX_PLAYERS, some code change
- fix : when max_lenght is set to 0, it means "no size limits" and not "no tracksharing at all"
- fix : sometimes min speed setting was not recorded
- added / fix : when using YAPF, train won't try to go where it can't because of speed or size (but not available to NPF)
- added / fix : can't order a train to go to a station/waypoint which doesn't allow it's speed or size (but this does not check the tracks between)

Re: Infrastructure Sharing

Posted: 05 May 2008 07:51
by planetmaker
Hi,

I think this sharing is a really nice feature. Unfortunately, when I compile I get two warnings related to track sharing. So far I have no idea about its consequences:

Code: Select all

[SRC] Compiling sharedinfrastructure.cpp
/home/ingo/ottd/trunk/src/sharedinfrastructure.cpp: In function ‘void SharedTracksPaiement()’:
/home/ingo/ottd/trunk/src/sharedinfrastructure.cpp:222: warning: cannot pass objects of non-POD type ‘class Money’ through ‘...’; 
call will abort at runtime
/home/ingo/ottd/trunk/src/sharedinfrastructure.cpp: In function ‘void SharedAirportLandingFee(Owner, Owner, uint16)’:
/home/ingo/ottd/trunk/src/sharedinfrastructure.cpp:288: warning: cannot pass objects of non-POD type ‘class Money’ through ‘...’; 
call will abort at runtime
Regards,
pm

EDIT: made lines shorter to not break table

Re: Infrastructure Sharing

Posted: 05 May 2008 08:06
by _Robbie_
There's a thought: If you split it into few small patches, prefferably as small as possible, you'll have bigger chance of getting it into trunk. I don't know how the quality of your code is - I didn't look at code yet, since I'm at school - but the feature itself is great. Especially track sharing in MP.

Re: Infrastructure Sharing

Posted: 05 May 2008 08:51
by planetmaker
We set up a test game on the openttdcoop dev server. Join us and help testing this patch! Check out the openttdcoop Blog for more and the binaries.
_Robbie_ wrote:There's a thought: If you split it into few small patches, prefferably as small as possible, you'll have bigger chance of getting it into trunk. I don't know how the quality of your code is - I didn't look at code yet, since I'm at school - but the feature itself is great. Especially track sharing in MP.
Probably a good idea. Though - if I read the code correctly - quite a large chunk is on the GUI and patch settings.
Maybe - for a start - leave out or move to an additiona patch the size and speed limit settings (though they're no big part, if I saw correctly). Not sure how sensible it is to split it into different patches wrt airports, trains, ships and vehicles.

On question which arose when looking at the code: isn't there a MAX_PLAYERS const declared which should be used instead of the 8 falling from the sky?
--- src/economy.cpp (revision 12949)
+++ src/economy.cpp (working copy)
@@ -1470,8 +1470,10 @@
int result = 0;

Money vehicle_profit = 0; // Money paid to the train
- Money route_profit = 0; // The grand total amount for the route. A-D of transfer chain A-B-C-D
+ Money route_profit[8] = {0, 0, 0, 0, 0, 0, 0, 0}; // The grand total amount for the route. A-D of transfer chain A-B-C-D
+ bool route_profit_change = false;
Money virtual_profit = 0; // The virtual profit for entire vehicle chain
+ const Player* p;

StationID last_visited = front_v->last_station_visited;
Station *st = GetStation(last_visited);
EDIT: added link to dev server

Re: Infrastructure Sharing

Posted: 05 May 2008 09:17
by Ammler
Gedemon wrote: I really hope this is MP stable, it seems to be ok on my LAN, but I would like to see it tested on the net (Ammler ? ;) )
Your wish is my order:

Server is up:
Image
(Linux and Windows binaries available there...)
IRC: [url=irc://irc.oftc.net/openttdcoop.dev]irc.oftc.net/openttdcoop.dev[/url]

Greets
Ammler

Failure to compile debug binary

Posted: 05 May 2008 11:44
by planetmaker
I got desynced on the dev server. In order to track the desync both, Ammler and me tried to compile a debug binary. Unlike without debuging it doesn't compile:

Code: Select all

[SRC] Compiling openttd.cpp
/home/ingo/ottd/trunk/src/openttd.cpp: In function ‘void StateGameLoop()’:
/home/ingo/ottd/trunk/src/openttd.cpp:997: error: ‘struct Vehicle’ has no member named ‘unitnumberlength’
/home/ingo/ottd/trunk/src/openttd.cpp:1014: error: ‘struct Vehicle’ has no member named ‘unitnumberlength’
/home/ingo/ottd/trunk/src/openttd.cpp:1026: error: ‘struct Vehicle’ has no member named ‘unitnumberlength’
make[1]: *** [openttd.o] Fehler 1
make[1]: Leaving directory `/home/ingo/ottd/trunk/objs/release'
make: *** [all] Fehler 2
EDIT: a fix by SmatZ (r12955) solved the issue. Thx a lot!

Also two things we noted:

a) When we connect two tracks, the train just wouldn't continue onto the track of the other company. (see !stuck in save)
EDIT: it's #of wagons, not tiles. Thx. Gedemon
b) When my company went bancrupt, a piece of track with another company's train on it got moved to another company. (make yellow company bankrupt or just wait)

For reference: the patch settings in the rcon:
+ "shared_railway_stations",
+ "shared_railway_tracks",
+ "shared_railway_depots",
+ "shared_road_stops",
+ "shared_road_depots",
+ "shared_harbours",
+ "shared_water_depots",
+ "shared_airports",
+ "shared_provision",
+ "shared_tontile_cost",
+ "shared_landing_fee",
+ "shared_player_level",
+ "shared_delay",

Re: Infrastructure Sharing

Posted: 05 May 2008 15:20
by combuster
b) When my company went bancrupt, a piece of track with another company's train on it got moved to another company. (make yellow company bankrupt or just wait)
that was my train :D

a more complete description would be that occupied track doesn't get removed upon bankruptcy, while it remembers the owner by company ID. At first it'd claim it was still owned by the bankrupt company ("Owned by Planet Transport"), until someone else created a new company and got ownership over the tile.

Re: Infrastructure Sharing

Posted: 05 May 2008 16:02
by Anunnaki
That is super... tomorow i will test it in one week long game on my dedicated server :).

BTW i try to translate all texts to SLOVAK and CZECH language and i send you back changes for lang files.

Re: Infrastructure Sharing

Posted: 05 May 2008 16:42
by Vikthor
Nice, I am glad somebody continues in development of this patch, though I have few concerns.
  • First was already mentioned - it's the size of current patch, it's almost double the size compared to the patch you posted to CIV. I think Rubidium somewhere mentioned that patches should be around 10kB max.
  • Second is addition of unnecessary features - minimum train speed and maximum train size would be better handled in programmable signals/waypoint patch, this sets limit globally, while when using programmable waypoints, you can do it differently on different parts of network and on per company basis.
  • The individual settings are certainly very interesting, but it would be even better if you could set different conditions for different companies - eg. Allowing railroad sharing only to players you know.
  • Anyway, I have made patch that should be applied to source patched by Gedemons patch, it changes tontiles from uint64 to OverflowSafeUint64, because I am not sure if it could not overflow when using high daylength, very heavy train with high speed. And it corrects one typo, as I believe that Paiement should be spelled Payment
Anunnaki: While I don't want to spoil your enthusiasm, please be aware that patches can be submitted to devs only in English and then will be translated by assigned translators.

Re: Infrastructure Sharing

Posted: 05 May 2008 20:26
by Gedemon
Thank you all for the current testing, feedbacks and help :D

now it seems that I've got some bugs to fix -> working on them right now...

Re: Infrastructure Sharing

Posted: 05 May 2008 23:41
by Gedemon
ok, first update :

changelog v0.1 :
- change : max train length value is now tiles instead of wagons
- fix : do not use v->max_speed to check min speed, as it can be lowered when entering depot or station. Use cached_max_speed instead (thx Vikthor)
- fix : typo, variables, use MAX_PLAYERS, some code change (thx planetmaker, Vikthor)
- fix : when max_lenght is set to 0, it means "no size limits" and not "no tracksharing at all" :oops:
- fix : sometimes min speed setting was not recorded
- added / fix : when using YAPF, train won't try to go where it can't because of speed or size :idea: (but not available to NPF :? )
- added / fix : can't order a train to go to a station/waypoint which doesn't allow it's speed or size (but this does not check the tracks between)

todo :
- show a message when a company change it's sharing settings
- reflect landing fee cost in aircraft annual income
- show cost animation for landing fee. players should see that 200$/tons is in fact a high fee :)
- do not block train in middle of tracks on sharing setting change (well, how ?)
- can't order a train to go to a shared depot which doesn't allow it's speed or size (and don't try to go there for service)

to discuss :
- what to do of tracks under a train when shared owner goes bankrupt (and what can be done of the train itself ?) :mrgreen:
- does infrastructure sharing something that may goes into trunck
- if yes, then size does matter and do not even think of more features yet, better think on how to split this. (and yes remove what should be done with programmable waypoint/signals, but that's not the big part of the patch - GUI is)
- if no, ok, I'll let you make the wishlist, but don't expect miracles
- "different conditions for different companies" ? yes, I'll like to have this. When ? don't know :O


And again, thanks for feedbacks, advices, and everyone at openttdcoop :D

Re: Infrastructure Sharing

Posted: 06 May 2008 00:06
by combuster
Gedemon wrote:to discuss :
- what to do of tracks under a train when shared owner goes bankrupt (and what can be done of the train itself ?) :mrgreen:
I'd say the track changes owner to the train currently occupying it. That'd be the cleanest solution. One alternative is to remove all trains on the track in the process (next time, do watch the news for bankruptcy announcements 8) )
- does infrastructure sharing something that may goes into trunck
It would be a nice feature to have in the trunk.
- if yes, then size does matter and do not even think of more features yet, better think on how to split this. (and yes remove what should be done with programmable waypoint/signals, but that's not the big part of the patch - GUI is)
Adjust the patch such that all gui elements are removed except a single patch option to allow track sharing, then make separate patches for various things you possibly want to configure. (i.e. one for payment rates, one for the additional patch settings, one for company subselection, etc)
- if no, ok, I'll let you make the wishlist, but don't expect miracles
we can still have a wishlist even if the plan is to go for trunk ;)

Re: Infrastructure Sharing

Posted: 06 May 2008 02:19
by stevenh
combuster wrote:
Gedemon wrote:to discuss :
- what to do of tracks under a train when shared owner goes bankrupt (and what can be done of the train itself ?) :mrgreen:
I'd say the track changes owner to the train currently occupying it. That'd be the cleanest solution. One alternative is to remove all trains on the track in the process (next time, do watch the news for bankruptcy announcements 8) )
I don't know if that's a good idea... you should only own that track if you bought out the company.... otherwise the train should check it's current tile for a bankrupt company and if it's now on 'dead' track then send itself to the nearest non-bankrupt company's depot that it can?

Re: Infrastructure Sharing

Posted: 06 May 2008 10:25
by burge
Hi, long time reader, first time poster, very long time TT player!

I love the idea of this patch! 8)

My suggestions on dealing with the bankrupcy issue that I would like to add to the discussion, from a gameplay POV, are as follows:

As soon as a company receives its first bankruptcy warning it should be treated as being in receivership and any current arrangements with other companies be put on hold. The deals can be reinstated 6 months/1 year (an option, perhaps) after the company gets back into the black.

This way, a player running a company as a service provider is affected as are any companies who have placed their bets through relying on a 3rd party network. The reason I like that is because then a big company in financial trouble can have an effect on the whole game economy and it's much more of a real-life situation :)

Vehicles caught on 3rd party owned track at the first warning of said 3rd party bankruptcy should be allowed to continue through to the nearest player owned track/depot/station. If the main company does go bankrupt, this could create a frantic scrambling for the new assets (services industries and new track route space) - again more like real-life - and even deals with other players to create new service agreements.

Re: Infrastructure Sharing

Posted: 06 May 2008 12:00
by Wolf01
Gedemon wrote:to discuss :
- what to do of tracks under a train when shared owner goes bankrupt (and what can be done of the train itself ?) :mrgreen:
Pause the game, popup an auction UI for all players to decide who wants to purchase the bankrupted company's stuff (and this is mandatory, the game won't be unpaused until somebody win the auction), so you don't have to remove anything :)

Re: Infrastructure Sharing

Posted: 06 May 2008 12:25
by Roujin
what if nobody wants to buy it then?

Re: Infrastructure Sharing

Posted: 06 May 2008 12:27
by Anunnaki
to discuss :
- what to do of tracks under a train when shared owner goes bankrupt (and what can be done of the train itself ?)
option 1 - more complicated:

when player have bancrupted (and no one will buy this company), his rails will stay there next 6 or 12months. In this time, every train on this shared tracks, and trains which have destination "bancrupted shared station/depo", will be rerouted to the nearest own depos, and stop there. The same is necessary for trains, which have destination reachable only thru shared tracks will be rerouted to the own depo too. When no own depo is avaible, there can be a second option - shared depo of other not bancrupted comapany.


option 2 - simple:

the pieces of shared tracks on which is actualy standing train would be assigned to the comany which own the train. Then is important, stoping payments for service, so train would no more spend money for "fuel" when is standing = the same way as in depos.

EDIT:
When someone buys bancrupted company and will not assign track sharing for other players...there woul be 1 yer not possible to change track sharing condition, and the trains will have time to make steps in options above too.

You know, when you are playing long game on server (DAYLENGHT 10-30), you will no have problem with "spending" and own bancrupcy when other company falls down and your stucked trains will suck your many and cause your own bancrupcy thru night, when you are not connected to the server.

PS: Thank you very much for your patch...i will release my own MODPACK (your TrackSharing,YAPP,Loans,Daylenght for about two weeks long game on my dedicated server. So wi will test that very intensive :) I start tomorow, now i am at work :( .

Re: Infrastructure Sharing

Posted: 06 May 2008 17:52
by zombie
Hi.

I just tried this incredible patch. Although my Windows binary is very slow and CPU cosuming it's fun to see different colored vehicle on the same track or in the same station. But I justed noticed this: The company rating in the town dialog if for the owner of the station and not for the owner of the vehicle that picks up the cargo. Is it possible to apply the ratings to the transporting company or doesn't the rating system allow this? As we all knwo building a statue imcreases station reatings a bit. According to ratings system the station owner has to build the statue to improve his ratings. The transporting companies cannot improve it by themselves, can they?

Kind regards

Zombie

Re: Infrastructure Sharing

Posted: 06 May 2008 17:58
by Wolf01
Roujin wrote:what if nobody wants to buy it then?
Local authority should take them, and put a lot of taxes on their use :twisted:

Re: Infrastructure Sharing

Posted: 06 May 2008 18:59
by zombie
Hi.

I kept my test game on my linux server running while figuring out why my Windows build was so stressful on the CPU. I recompiled the Windows version with VS2008 Pro. This time as a release and not a debug version which runs a lot smoother. After reconnecting to the game I stumbled over strange company finances. While the company operating the trains is charged with sharing fees, the company providing tracks and stations does not receive these fees. I compiled from revision 12972 with the latest patch from this thread. I attached a screenshot, the savegame and the openttd.cfg of the server.

Kind regards

Zombie