Refit orders patch
Moderator: OpenTTD Developers
Refit orders patch
Hello,
When I was playing with newGRFs FIRS and openGFX+trains I noticed that refit at station 'didn't work properly'. I tried out other train GRFs and noticed that some even do not allow refit at stations. So I decided to dive into openTTD development to fix this 'bug'. After some hours of reading code I understood the game mechanic behind the refit at station orders and noticed that the behavior I saw is not a bug but is intended. But I was still unhappy with it. So I decided to create this patch to get my desired behavior. What I basically did is:
- introduced a setting to allow refit at station orders even if the GRF set does not
- introduced a setting that allows refitting at station even if it causes costs
- incorporated some logic that only refits as many trucks as needed.
My intension was that in my opinion a cargo truck does not need to go to a depot for refitting to all other cargos. For example a truck carrying some goods (lets say computers) can be used for carrying alcohol (lets say beer or bottles of spirits) without any refitting as everything is packaged in boxes. This ability is provided by the refit at station orders in openTTD. But these orders are currently only allowed if the GRF set allows it and if the refitting does not cause any costs. With my patch the player can decide by himself if he wants to use refitting orders for all vehicles/cargos or if he plays like it was intended by the GRF developer.
The patch file attached is be applied against release 1.4.2.
As these changes are my first steps in openTTD development I am happy about all of your comments especially I didn't know which flags I should use for the new settings.
Thanks!
Edit: I uploaded the wrong patch file. Sorry for that! Here is the correct one.
When I was playing with newGRFs FIRS and openGFX+trains I noticed that refit at station 'didn't work properly'. I tried out other train GRFs and noticed that some even do not allow refit at stations. So I decided to dive into openTTD development to fix this 'bug'. After some hours of reading code I understood the game mechanic behind the refit at station orders and noticed that the behavior I saw is not a bug but is intended. But I was still unhappy with it. So I decided to create this patch to get my desired behavior. What I basically did is:
- introduced a setting to allow refit at station orders even if the GRF set does not
- introduced a setting that allows refitting at station even if it causes costs
- incorporated some logic that only refits as many trucks as needed.
My intension was that in my opinion a cargo truck does not need to go to a depot for refitting to all other cargos. For example a truck carrying some goods (lets say computers) can be used for carrying alcohol (lets say beer or bottles of spirits) without any refitting as everything is packaged in boxes. This ability is provided by the refit at station orders in openTTD. But these orders are currently only allowed if the GRF set allows it and if the refitting does not cause any costs. With my patch the player can decide by himself if he wants to use refitting orders for all vehicles/cargos or if he plays like it was intended by the GRF developer.
The patch file attached is be applied against release 1.4.2.
As these changes are my first steps in openTTD development I am happy about all of your comments especially I didn't know which flags I should use for the new settings.
Thanks!
Edit: I uploaded the wrong patch file. Sorry for that! Here is the correct one.
- Attachments
-
- refit_vs_1.4.2.patch
- new version 16. September 2014
- (9.27 KiB) Downloaded 119 times
Last edited by Siggie on 16 Sep 2014 15:02, edited 1 time in total.
Re: Refit orders patch
Having automatic refits at stations even if they cost is a good way for a payer's route to quickly become unprofitable.
Do you like drones, quadcopters & flying toys? Check out Drone Strike Force!
Base Music Sets: OpenMSX | Scott Joplin Anthology | Traditional Winter Holiday Music | Modern Motion Music
Other Projects: 2CC Trams | Modern Waypoints | Sprite Sandbox & NewGRF Releases | Ideabox | Town Names | Isle of Sodor Scenario | Random Sprite Repository
Misc Topics: My Screenshots | Forgotten NewGRFs | Unfinished Graphics Sets | Stats Shack | GarryG's Auz Sets
Base Music Sets: OpenMSX | Scott Joplin Anthology | Traditional Winter Holiday Music | Modern Motion Music
Other Projects: 2CC Trams | Modern Waypoints | Sprite Sandbox & NewGRF Releases | Ideabox | Town Names | Isle of Sodor Scenario | Random Sprite Repository
Misc Topics: My Screenshots | Forgotten NewGRFs | Unfinished Graphics Sets | Stats Shack | GarryG's Auz Sets
-
- Transport Coordinator
- Posts: 260
- Joined: 09 Apr 2014 11:10
Re: Refit orders patch
I'm not sure a source code patch against a specific release which will (most likely) break savegame compatability with trunk is the best approach to this problem, it's like putting a new engine in your car just because the oil needs changing. The betterer solution would be to modify the refit properties of the OpenGFX+ vehicle sets, it will give the same gameplay but with much less nasty side-effects. Also many of the newGRF's released recently have already set the refits to behave in this way, I'm not sure why you say most sets do not allow station refit
Re: Refit orders patch
What do you do about the old sets that are no longer being maintained, the authors are gone and the source code is not available?
-
- Transport Coordinator
- Posts: 260
- Joined: 09 Apr 2014 11:10
Re: Refit orders patch
Source code is easily obtained for any newGRF if you understand grfcodec and nfo code, assuming the license allows it even old, unmaintained sets can be edited in this way. If not, no-one is forcing any particular grf to be used, you could always use one of the newer sets. My point was the place to fix grf issues is in the grf, hacking the core game code to achieve this creates too many unwanted side effects. Even a patch against latest trunk would be better than patching against an almost outdated stable release.
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: Refit orders patch
If you have anything in specific which needs improvement with OpenGFX+Trains, please say so. I made a bit of an effort so that the wagons there allow station refit when the refit seems reasonable to me (with or without cost, if memory serves me well). However refits which require "realistically" some modification to the wagon are only allowed in depots. Maybe the station refit rules could and should be relaxed more - but then I need to know what needs to get better where. Patches in the form of source code patches for that NewGRF would be especially welcome. If we want to discuss it further, we should use its own thread or its issue tracker (especially for patches).Siggie wrote:Hello,
When I was playing with newGRFs FIRS and openGFX+trains I noticed that refit at station 'didn't work properly'.
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: Refit orders patch
This isn't actually true; station refits can absolutely cost money with the current spec (using callback 15e or refit_cost). If every newgrf author who has implemented station refits has had the sense to make them free, perhaps that tells us something.Siggie wrote:But these orders are currently only allowed if the GRF set allows it and if the refitting does not cause any costs.
"Realism" is a bad feature.planetmaker wrote:However refits which require "realistically" some modification to the wagon are only allowed in depots. Maybe the station refit rules could and should be relaxed more
Limiting station refits by what was "realistic" was how I did it for UKRS2, too, but for Pineapple Trains I decided it was better for gameplay if every refit which could be done in the depot could also be done at a station. It's simply less confusing for players - and those players who don't like the "unrealism" of reusing an oil tanker for beer can just not do it!
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: Refit orders patch
Well, OpenGFX+Trains does not make (all) station refits free-of-charge. But that probably doesn't matter much. One example:PikkaBird wrote:This isn't actually true; station refits can absolutely cost money with the current spec (using callback 15e or refit_cost). If every newgrf author who has implemented station refits has had the sense to make them free, perhaps that tells us something.Siggie wrote:But these orders are currently only allowed if the GRF set allows it and if the refitting does not cause any costs.
"Realism" is a bad feature.planetmaker wrote:However refits which require "realistically" some modification to the wagon are only allowed in depots. Maybe the station refit rules could and should be relaxed more
Limiting station refits by what was "realistic" was how I did it for UKRS2, too, but for Pineapple Trains I decided it was better for gameplay if every refit which could be done in the depot could also be done at a station. It's simply less confusing for players - and those players who don't like the "unrealism" of reusing an oil tanker for beer can just not do it!
Code: Select all
switch (FEAT_CURRENT, SELF, bulk_refit_from_clean_switch, extra_callback_info1 & 0xFF) {
// The vehicle is clean, but we want to transport something else. Allow to
// clean it quickly in the station with a broom and some water at a cost.
CERE: return 20 | CB_RESULT_AUTOREFIT;
CTCD: return 20 | CB_RESULT_AUTOREFIT;
FICR: return 20 | CB_RESULT_AUTOREFIT;
FRUT: return 20 | CB_RESULT_AUTOREFIT;
FRVG: return 20 | CB_RESULT_AUTOREFIT;
GRAI: return 20 | CB_RESULT_AUTOREFIT;
MAIZ: return 20 | CB_RESULT_AUTOREFIT;
RSGR: return 20 | CB_RESULT_AUTOREFIT;
SGCN: return 20 | CB_RESULT_AUTOREFIT;
SGBT: return 20 | CB_RESULT_AUTOREFIT;
TOFF: return 20 | CB_RESULT_AUTOREFIT;
WHEA: return 20 | CB_RESULT_AUTOREFIT;
// The vehicle is clean and we want to transport dirty stuff. Just do so
// without costs:
return 0 | CB_RESULT_AUTOREFIT;
}
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
- andythenorth
- Tycoon
- Posts: 5658
- Joined: 31 Mar 2007 14:23
- Location: Lost in Music
Re: Refit orders patch
The cb should be removed in next version of grf spec, or limited to specify the cost only. Station refit should be 1:1 identical to depot refit.
Not only are limited refits it weird and annoying, they also make it easy for a player to set orders which are broken, and these fail silently.
Not only are limited refits it weird and annoying, they also make it easy for a player to set orders which are broken, and these fail silently.
FIRS Industry Replacement Set (released) | HEQS Heavy Equipment Set (trucks, industrial trams and more) (finished)
Unsinkable Sam (ships) (preview released) | CHIPS Has Improved Players' Stations (finished)
Iron Horse ((trains) (released) | Termite (tracks for Iron Horse) (released) | Busy Bee (game script) (released)
Road Hog (road vehicles and trams) (released)
Unsinkable Sam (ships) (preview released) | CHIPS Has Improved Players' Stations (finished)
Iron Horse ((trains) (released) | Termite (tracks for Iron Horse) (released) | Busy Bee (game script) (released)
Road Hog (road vehicles and trams) (released)
Re: Refit orders patch
This should not be a Problem, as only as many trucks as needed are refitted.kamnet wrote:Having automatic refits at stations even if they cost is a good way for a payer's route to quickly become unprofitable.
I didn't say that. But examples are the 2cc set (original version, don't know about the recoded), the DB-XL set or the ECS&FIRS original vehicle set.kamnet wrote:I'm not sure why you say most sets do not allow station refit
kamnet wrote:The betterer solution would be to modify the refit properties of the OpenGFX+ vehicle sets
I agree that a change request for an GRF would be a easier solution but the advantage of this patch is that I don't need to do this for every GRF I want to play. Also the community behind the a specific set may refuse my request. Using this patch I can just switch the options on and it works.Eddy Arfik wrote:If you have anything in specific which needs improvement with OpenGFX+Trains, please say so...
I'm quite sure it is: Try out the following savegame. Some general Questions: Why is it bad to create a patch against a release instead of the trunk? Isn't it some kind of part of the trunk? I just used SVN and checked out Tag 1.4.2. And what about the savegame incompatibilities. I currently can load the same savegames with my patched version and the release.planetmaker wrote:This isn't actually true; station refits can absolutely cost money with the current spec (using callback 15e or refit_cost)...Siggie wrote: But these orders are currently only allowed if the GRF set allows it and if the refitting does not cause any costs.
Regards
Re: Refit orders patch
If a single truck makes a $100 profit delivering one type of good, but the refit at the station costs more than $100, then the route has become unprofitable. If a player using your patch is unaware of the refit cost because they never see it because they didn't set it up in a depot, then they're going to be left confused.Siggie wrote:This should not be a Problem, as only as many trucks as needed are refitted.kamnet wrote:Having automatic refits at stations even if they cost is a good way for a payer's route to quickly become unprofitable.
The first reason is because once you apply your patch to an official release, that official release can no longer be considered stable, and it is not savegame-compatible with unpatched versions. A person playing with unpatched 1.4.2 will not be able to load your game. The second reason is that trunk releases contain newer, updated code and features, where the stable release had its development frozen months ago. Basing your patch on a nightly trunk puts your development ahead of the curve.Siggie wrote:Some general Questions: Why is it bad to create a patch against a release instead of the trunk? Isn't it some kind of part of the trunk? I just used SVN and checked out Tag 1.4.2. And what about the savegame incompatibilities. I currently can load the same savegames with my patched version and the release.
Do you like drones, quadcopters & flying toys? Check out Drone Strike Force!
Base Music Sets: OpenMSX | Scott Joplin Anthology | Traditional Winter Holiday Music | Modern Motion Music
Other Projects: 2CC Trams | Modern Waypoints | Sprite Sandbox & NewGRF Releases | Ideabox | Town Names | Isle of Sodor Scenario | Random Sprite Repository
Misc Topics: My Screenshots | Forgotten NewGRFs | Unfinished Graphics Sets | Stats Shack | GarryG's Auz Sets
Base Music Sets: OpenMSX | Scott Joplin Anthology | Traditional Winter Holiday Music | Modern Motion Music
Other Projects: 2CC Trams | Modern Waypoints | Sprite Sandbox & NewGRF Releases | Ideabox | Town Names | Isle of Sodor Scenario | Random Sprite Repository
Misc Topics: My Screenshots | Forgotten NewGRFs | Unfinished Graphics Sets | Stats Shack | GarryG's Auz Sets
Re: Refit orders patch
There is another solution to that: Make the game complain when an order fails. We already get notifications about "train with invalid order" when a depot/station is deleted. We could also have "train 15 attempted invalid refit from oil to beer at station X - only doable in depot". A clear warning, and soone enought he player knows what won't work.andythenorth wrote:The cb should be removed in next version of grf spec, or limited to specify the cost only. Station refit should be 1:1 identical to depot refit.
Not only are limited refits it weird and annoying, they also make it easy for a player to set orders which are broken, and these fail silently.
Ideally, the player should not be able to specify an invalid refit in the first place; but conditional orders means that some invalid refits are impossible to guard against. Still, many don't use conditional orders much, so most cases could get the warning immediately. I.e. whenever an order window without conditionals have an impossible sequence - highlight with red or something. But don't disallow completely, as the player may intend to produce a valid order by adding a depot refit in a later step.
Re: Refit orders patch
Except when you play with cargo-dist, which needws to know whether you can refit to a certain cargo, in a reliable way.Hafting wrote:There is another solution to that: Make the game complain when an order fails. We already get notifications about "train with invalid order" when a depot/station is deleted. We could also have "train 15 attempted invalid refit from oil to beer at station X - only doable in depot". A clear warning, and soone enought he player knows what won't work.andythenorth wrote:The cb should be removed in next version of grf spec, or limited to specify the cost only. Station refit should be 1:1 identical to depot refit.
Not only are limited refits it weird and annoying, they also make it easy for a player to set orders which are broken, and these fail silently.
Being a retired OpenTTD developer does not mean I know what I am doing.
Re: Refit orders patch
Cargodist will just assume that the refit works when calculating the distribution. So if you create bad refit orders you may get some misrouted cargo, but we can just say "that's your problem" again. That said, I also consider this feature as something between useless and harmful, and I'd be happy if we removed the extra restrictions to station-refit.
The guy on the picture is not me, it's Alonso.
Who is online
Users browsing this forum: No registered users and 57 guests