Advanced Autoreplace Patch
Moderator: OpenTTD Developers
Advanced Autoreplace Patch
Hi all !
I've coded again Haukinger presents: advanced autoreplace.
With this patch, one can convert all enginetypes to all other. You select the engine to convert and the one to convert to, independent which one has which track-type. If a to-be-converted engine enters a depot, it will be replaced (as normal), but it will stay in the depot, if it can't leave it (Monorail can't drive out of electric depot for example). If all your trains are converted and waiting in depot, you convert all your tracks (as normal) and start all trains again. See screenshots.
I don't think this qualifies as a patch, it looks more like a hack to me. Perhaps some ottd-code-experts can suggest improvements...
TODOs:
* Find better solution for power-calculation (outside of VehicleEnter_Track())
* Replacement for red flag in depot-window for trains that can't leave the depot
* Replacement for start-stop-button-string in vehicle-window for trains that aren't allowed to be started
So long,
Haukinger
I've coded again Haukinger presents: advanced autoreplace.
With this patch, one can convert all enginetypes to all other. You select the engine to convert and the one to convert to, independent which one has which track-type. If a to-be-converted engine enters a depot, it will be replaced (as normal), but it will stay in the depot, if it can't leave it (Monorail can't drive out of electric depot for example). If all your trains are converted and waiting in depot, you convert all your tracks (as normal) and start all trains again. See screenshots.
I don't think this qualifies as a patch, it looks more like a hack to me. Perhaps some ottd-code-experts can suggest improvements...
TODOs:
* Find better solution for power-calculation (outside of VehicleEnter_Track())
* Replacement for red flag in depot-window for trains that can't leave the depot
* Replacement for start-stop-button-string in vehicle-window for trains that aren't allowed to be started
So long,
Haukinger
- Attachments
-
- steam engine being autoreplaced with monorail
- Before.png (196.36 KiB) Viewed 1229 times
-
- tracks converted to monorail
- After.png (196.12 KiB) Viewed 1279 times
Last edited by Haukinger on 05 Jul 2006 13:39, edited 3 times in total.
hmmmm...... you're right. simply forgotten. But there's a limit of three attachments anyway
EDIT: Cleaned up code, calling IsCompatibleRail() for trains only now.
EDIT: Changed diff for MiniIN
EDIT: Replacing waggons, too
EDIT: Cleaned up code, calling IsCompatibleRail() for trains only now.
EDIT: Changed diff for MiniIN
EDIT: Replacing waggons, too
- Attachments
-
- Advanced_Autoreplace_5461.diff
- advanced autoreplace for 5461
- (9.93 KiB) Downloaded 429 times
-
- Advanced_Autoreplace_5461_MiniIN.diff
- advanced autoreplace for MiniIN 5461
- (3.81 KiB) Downloaded 307 times
Last edited by Haukinger on 05 Jul 2006 13:45, edited 5 times in total.
Hmm, not bad. Some coding style tips (follow existing code...):
* Don't put spaces inside braces, i.e. "(foo)" not "( foo )"
* All comments in English please...
* Use tabs for indenting and spaces for aligning columns (only problem I saw was the comment in train_cmd.c)
* Use squiggly brackets, { }, if an if-statement is split, even if only onto 1 line.
* Remove code, don't comment it out. That's what the diff is for
But bear in mind, if I'm picking at the coding style, there can't be too much wrong
* Don't put spaces inside braces, i.e. "(foo)" not "( foo )"
* All comments in English please...
* Use tabs for indenting and spaces for aligning columns (only problem I saw was the comment in train_cmd.c)
* Use squiggly brackets, { }, if an if-statement is split, even if only onto 1 line.
* Remove code, don't comment it out. That's what the diff is for
But bear in mind, if I'm picking at the coding style, there can't be too much wrong
He's like, some kind of OpenTTD developer.
Peter: currently autoreplace only works on arrival of a train in the depot. If a train is in depot, and you set the autoreplace up, it doesnt get autoreplaced.peter1138 wrote:Hmm, not bad. Some coding style tips (follow existing code...):
* Don't put spaces inside braces, i.e. "(foo)" not "( foo )"
* All comments in English please...
* Use tabs for indenting and spaces for aligning columns (only problem I saw was the comment in train_cmd.c)
* Use squiggly brackets, { }, if an if-statement is split, even if only onto 1 line.
* Remove code, don't comment it out. That's what the diff is for
But bear in mind, if I'm picking at the coding style, there can't be too much wrong
Would it be easy to have a way to force the autoreplace on vehicles in depot too?
OTTD NewGRF_ports. Add an airport design via newgrf.Superceded by Yexo's NewGrf Airports 2
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
Hi !
You see, that diff comes directly from my working copy, that's why some code is commented out and not deleted. You never know if you're patching at the right place... removing '//' is the easiest way backpeter1138 wrote:Hmm, not bad. Some coding style tips (follow existing code...):
* Don't put spaces inside braces, i.e. "(foo)" not "( foo )"
* All comments in English please...
* Use tabs for indenting and spaces for aligning columns (only problem I saw was the comment in train_cmd.c)
* Use squiggly brackets, { }, if an if-statement is split, even if only onto 1 line.
* Remove code, don't comment it out. That's what the diff is for
That last one usually works pretty well.
...
Assuming, of course, that it's followed by a visit to The Manual whenever something doesn't work correctly.
...
Assuming, of course, that it's followed by a visit to The Manual whenever something doesn't work correctly.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
You set the autoreplacement as ever, just order a, say, asia star to be replaced with x2001. Then let your trains run around, and everytime a asia star enters a depot, it's converted to x2001 and stays in the depot. once all trains are converted and stopped in depots, you convert your network to monorail, including depots. Then start the trains againSlace wrote:a question on its usage. How do we do it? Do we convert the depo to the new rail type and then change the engine or do we do the engine 1st or should I just install it and just play around?
I just wrote it in VehicleEnterDepot(), but it's a function call that we can add elsewhere as well. Nobody complained before.richk67 wrote:Peter: currently autoreplace only works on arrival of a train in the depot. If a train is in depot, and you set the autoreplace up, it doesnt get autoreplaced.
Would it be easy to have a way to force the autoreplace on vehicles in depot too?
Also it's funny that you ask Peter even though it was me, who wrote autoreplace. I guess fame is an overnight thing
As for the idea in this patch. I talked about doing this, but it was turned down in the channel by the other developers (mainly Darkvater) because we can't have trains of the wrong type in depots. Actually I agree, so I found another solution. Build two depots next to each other and when a train is sold, a new one is bought in the other depot. Main issue in that solution: I haven't had time to code it so far
And how about replace trains while converting the train depot rail type?Bjarni wrote:I just wrote it in VehicleEnterDepot(), but it's a function call that we can add elsewhere as well. Nobody complained before.richk67 wrote:Peter: currently autoreplace only works on arrival of a train in the depot. If a train is in depot, and you set the autoreplace up, it doesnt get autoreplaced.
Would it be easy to have a way to force the autoreplace on vehicles in depot too?
Also it's funny that you ask Peter even though it was me, who wrote autoreplace. I guess fame is an overnight thing
As for the idea in this patch. I talked about doing this, but it was turned down in the channel by the other developers (mainly Darkvater) because we can't have trains of the wrong type in depots. Actually I agree, so I found another solution. Build two depots next to each other and when a train is sold, a new one is bought in the other depot. Main issue in that solution: I haven't had time to code it so far
As stated in the MiniIN-thread, I have to find a solution for waggons.
I think it would be best if one has to specify manually which normal waggons become which monorail/maglev waggons, with waggons without conversion rule being dropped. The main difficulty here is the fact that not all rail-types have all waggon-types, e.g. UKRS has only passenger/post/goods for maglev.
I think it would be best if one has to specify manually which normal waggons become which monorail/maglev waggons, with waggons without conversion rule being dropped. The main difficulty here is the fact that not all rail-types have all waggon-types, e.g. UKRS has only passenger/post/goods for maglev.
In fact I think you are one of the greates coders here.Bjarni wrote:I guess fame is an overnight thing
When I grow up I just want to be like you.
At school/work most of the people talk most of the time
about your projects and your improvements on OPENTTD.
If anybody gets a great idea they say he got a bjarni.
When me and my friend are talking about the game"Hey everybody! I finally got a bjarni."
- "Cool, now we can make billions with it."
we usually call it Bjarni's Open.
klogg
I've added waggon-replacement. It works just like replacing engines, select the railtype and replace to the desired waggon. Trains are converted from one railtype to another one only if all waggons and engines in the train have replacements assigned (of the same railtype). A side-effect - you can convert waggon-types now, if you convert from one railtype to another one, e.g. normal passenger-waggons to monorail-coal-waggons.
I get an assert failure if i merge the miniIN patch it into the current miniIN branch.
This happens if a train arrives in a depot.
Please fix it and post the file in the miniIN thread to get added into the branch.
Code: Select all
openttd: engine.h:162: GetEngine: Assertion `i < (sizeof(_engines)/sizeof(_engines[0]))' failed.
Please fix it and post the file in the miniIN thread to get added into the branch.
problem cloning replaced vehicles
r5476-MiniIN:
When trying to clone an autoreplaced train monorail->maglev i get the error: "can't build railway type"
this happens no matter depot type i try to clone from.
is this because of the wagons?
When trying to clone an autoreplaced train monorail->maglev i get the error: "can't build railway type"
this happens no matter depot type i try to clone from.
is this because of the wagons?
Re: problem cloning replaced vehicles
Yeah it is, Haukinger released a patch for that issue, but that produces that error two posts above.nonick37 wrote:r5476-MiniIN:
When trying to clone an autoreplaced train monorail->maglev i get the error: "can't build railway type"
this happens no matter depot type i try to clone from.
is this because of the wagons?
Who is online
Users browsing this forum: No registered users and 38 guests