[v2.0.0] Template based train replacement

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

Eisenbaehr
Engineer
Engineer
Posts: 62
Joined: 29 May 2006 06:59
Location: Germany

Re: [v0.4c] Template based train replacement r24093

Post by Eisenbaehr » 02 May 2012 13:01

Thanks for your feedback ffpp!

Yes, the clone button is a good choice to clone templates. In my opinion this is the only choice.

> - During the creation of a template, it is complicated to get an engine to be the first vehicle in the chain: this is also the same when dealing with a train in a depot, only that there you have multiple lines available to make things easier. Should be improved as well.

The behavior is diffent from the depot. I am trying to create some screenshots later.

Eisenbaehr
Engineer
Engineer
Posts: 62
Joined: 29 May 2006 06:59
Location: Germany

Re: [v0.4c] Template based train replacement r24093

Post by Eisenbaehr » 02 May 2012 20:52

Look at the screen shots below. I have tried to document the facts in this way.

While creating the screen shots I pressed for few seconds the Ctrl key (+S). I held a waggon. When I release the (mouse or ctrl?) button, I got the following error message.

Code: Select all

Assertion failed at line 67 of src/train_gui.cpp: selection != INVALID_VEHICLE
This happened one time. I can not reproduce it again.
Assertion-failed-tbtr-hpps-r24122-2012-05-02.rar
(2.55 MiB) Downloaded 82 times
Attachments
01-try-to-move-first.png
01-try-to-move-first.png (16.2 KiB) Viewed 3753 times
02-move-forward-one-by-one.png
(19.78 KiB) Downloaded 3 times

Eisenbaehr
Engineer
Engineer
Posts: 62
Joined: 29 May 2006 06:59
Location: Germany

Re: [v0.4c] Template based train replacement r24093

Post by Eisenbaehr » 02 May 2012 21:01

Oh yes, I've seen another little problem. Look at the screen shot(s) again.
Attachments
waggons-overlap.png
waggons-overlap.png (12.73 KiB) Viewed 3750 times

User avatar
ffpp
Engineer
Engineer
Posts: 122
Joined: 29 Jan 2010 12:56

Re: [v0.4c] Template based train replacement r24093

Post by ffpp » 03 May 2012 11:20

@Eisenbaehr,

I checked the things you mentioned.

- You're right, the main gui needs the ability to scroll horizontally, I didn't notice this yet because my game settings don't allow for such long trains :)

- moving template vehicles inside the chain vs depot movement: I'm not sure if I understand you.
I think you mean that you cannot make a template vehicle the new head of its chain by moving it to the front. But this is the case for the real trains inside a depot as well. You cannot make a vehicle != first the new head of the chain, you have to make it the second vehicle and then move the current head backwards. Just tried it. Please correct me if you where meaning something else.

- I will look at the savegame with the crash, maybe it happens again for me.

Eisenbaehr
Engineer
Engineer
Posts: 62
Joined: 29 May 2006 06:59
Location: Germany

Re: [v0.4c] Template based train replacement r24093

Post by Eisenbaehr » 03 May 2012 11:44

> I did not notice this yet because my game settings do not allow for searching long trains

Long? The trains have 30 cars only :)

The move ... I think you misunderstood me, unfortunately. The problem is really very striking. So I think it might be due to NewGRF Train Set. However, there are no problems in the depot.

By, for example Cloning, is a train correctly in the template. The locomotive is at the start, the cars behind it.
If I simply click on a wagon, for example the 5th, the locomotive will be placed in this position. Now I have to click five times on a wagon behind the locomotive to get right back in the first place. It works no other way to do this.

The next time I make a video :D

handrake
Engineer
Engineer
Posts: 55
Joined: 26 Mar 2012 10:23

Re: [v0.4c] Template based train replacement r24093

Post by handrake » 03 May 2012 12:57

Eisenbaehr wrote:>Long? The trains have 30 cars only :)
I would say a train with 30 cars is pretty long...

User avatar
ffpp
Engineer
Engineer
Posts: 122
Joined: 29 Jan 2010 12:56

Re: [v0.4c] Template based train replacement r24093

Post by ffpp » 03 May 2012 13:59

Eisenbaehr wrote: Long? The trains have 30 cars only :)
As long as the engine can still pull it ;)
Eisenbaehr wrote: By, for example Cloning, is a train correctly in the template. The locomotive is at the start, the cars behind it.
If I simply click on a wagon, for example the 5th, the locomotive will be placed in this position. Now I have to click five times on a wagon behind the locomotive to get right back in the first place. It works no other way to do this.
Ah, I know now what is going on... This is a known bug/stupidity which annoyed me such much as well, that I corrected it immediately for my playtesting version but it is not included in the v0.4c. But this bug will be gone in the next release. This is also the reason why I didn't understand you, I had totally forgotton that this issue was there in the last release version.
Eisenbaehr wrote: The next time I make a video :D
No need ! :D

Eisenbaehr
Engineer
Engineer
Posts: 62
Joined: 29 May 2006 06:59
Location: Germany

Re: [v0.4c] Template based train replacement r24093

Post by Eisenbaehr » 03 May 2012 17:48

Du Humpen!

Thx for the facility!

Btw.: ?? A 30-car long train is completely normal? Where do you live that you think this is not normal?? (Max. 250 axes or 700 meters.)

This old one has 21-23 (?) cars, 30-32 (?) cars, over 40 cars.

Eisenbaehr
Engineer
Engineer
Posts: 62
Joined: 29 May 2006 06:59
Location: Germany

Re: [v0.4c] Template based train replacement r24093

Post by Eisenbaehr » 04 May 2012 00:57

Now you can easily de- or increase the transported volumes by move a train (with Ctrl to get the complete route) from one to another group with a different template. Very very nice :)

But, I'm very afraid to say that there is the next assertiation-problem.

First a few words about a few priority issues.
To scrolling is dirty by click on an arrow of the scroll bar or mouse wheel.
You should disable sorting on template-id. It is better to sort by creation time. Or new templates never get old template-ids (auto increment).
When old templates will be deleted, there are many holes. Now, new templates created, they are scattered everywhere. But this is only a very small problem.

Now to the assert-problem.

Code: Select all

Assertion failed at line 535 of src/aaa_template_vehicle_func.cpp: !part_of_chain || new_head->IsPrimaryVehicle()
I had used the Replace All Templates-Function. By the NewGRF Train Set, there are two cars with the same name. "Schüttgutwagen" One for 80 and 120 km/h. In the interface, the difference was not seen, unfortunately. Whatever... first, I selected on the left side, so I think, the wrong car and clicked Replace All. Nothing happened. I chose the other, and clicked again on Replace All. What I chose on the right I can not remember. I selected Apply and the stone get to run... Maybe this has nothing to do with the error. But maybe it helps somehow.

In the attachment is the savegame before the assertiation fails.
First, pause game and stop all trains. Goto train 110. Let him go.
Train 110 will now go into the depot. When he arrived, so it crashes.
Assertion-failed-at-line-535-hpp-r24122.rar
(2.75 MiB) Downloaded 76 times
You will find most NewGRFs that I used here.

Please make a note of this post. I forgot that the error happened before. I wondered just why this is so familiar to me.

User avatar
ffpp
Engineer
Engineer
Posts: 122
Joined: 29 Jan 2010 12:56

Re: [v0.4c] Template based train replacement r24093

Post by ffpp » 05 May 2012 10:32

I also noticed some bugs but fortunately I was able to extract some cases where exactly those bugs happen. So I can actually fix them ;)
For example: Please don't use the ReplaceAll-Function as of now. It felt stable when I developed it but it seems my test cases weren't sufficient at all back then.
Another problem seems to be (for me at least) that when templates get switched around or changed, normally the [group->replacement->template]-connotations are being kept consistent. But with regards to multiple railtypes this seems to be lacking in some instances. Which leads to trains trying to use a nonexisting template which will lead to segfaults. (If the main gui says 'uses template of different railtype', better check if there really *is* a different railtype which has a legal template set of the selected group).

All this will be fixed in the future of course, I'm just very short on time at the moment.

Eisenbaehr
Engineer
Engineer
Posts: 62
Joined: 29 May 2006 06:59
Location: Germany

Re: [v0.4c] Template based train replacement r24093

Post by Eisenbaehr » 09 May 2012 00:04

> If the main gui says 'uses template of different railtype', better check if there really *is* a different railtype which has a legal template set of the selected group

I remember that the interface was confusing. Some templates showed "uses template of different railtype" although this was not true.

> > I would say a train with 30 cars is pretty long...
>
> Btw.: ?? A 30-car long train is completely normal?

Yesterday I read an article on Wikipedia about the first railroad in the world. :)

The English article differs from the German. This surprises me. ...however...

http://en.wikipedia.org/wiki/Stockton_a ... operations
> ...in 1863 that, for the inaugural run, a locomotive pulling 33 waggons...

http://de.wikipedia.org/wiki/Stockton_a ... Lokomotive
> Am 26. September 1825 fanden Probefahrten und am darauf folgenden 27. September die Jungfernfahrt statt. Der Zug bestand aus 36 Wagen...
> On 26 September 1825 were trial runs and the following 27th September, the maiden voyage instead. The train consisted of 36 cars ...

User avatar
ffpp
Engineer
Engineer
Posts: 122
Joined: 29 Jan 2010 12:56

Re: [v0.4c] Template based train replacement r24093

Post by ffpp » 09 May 2012 09:23

Eisenbaehr wrote:> If the main gui says 'uses template of different railtype', better check if there really *is* a different railtype which has a legal template set of the selected group

I remember that the interface was confusing. Some templates showed "uses template of different railtype" although this was not true.
Yes, I'm currently looking for more instances during playing where this happens because during the more basic tests before the last release I didn't notice any such behaviour.

Eisenbaehr wrote: > > I would say a train with 30 cars is pretty long...
>
> Btw.: ?? A 30-car long train is completely normal?

Yesterday I read an article on Wikipedia about the first railroad in the world. :)

The English article differs from the German. This surprises me. ...however...

http://en.wikipedia.org/wiki/Stockton_a ... operations
> ...in 1863 that, for the inaugural run, a locomotive pulling 33 waggons...

http://de.wikipedia.org/wiki/Stockton_a ... Lokomotive
> Am 26. September 1825 fanden Probefahrten und am darauf folgenden 27. September die Jungfernfahrt statt. Der Zug bestand aus 36 Wagen...
> On 26 September 1825 were trial runs and the following 27th September, the maiden voyage instead. The train consisted of 36 cars ...
The only thing I would say against 30-cars long trains would be that it might not make too much sense with regards to the map size. I image it to look a bit weird when a train's length already covers half the distance between two cities.

I like to play with a 4x cargo weight multiplier, btw. This gives a stronger role to the slow-but-strong freight engines and also gives incentive to use multiple engines per train even later in the game.

Scay
Engineer
Engineer
Posts: 39
Joined: 30 May 2004 20:48

Re: [v0.4c] Template based train replacement r24093

Post by Scay » 08 Aug 2012 09:47

Having been away from OpenTTD for a while I find this a very interesting patch I'd like to try out.

I did actually about 5 years ago suggest that the current way of handling trains/routes which are more or less vehicle/set based should be changed to route based, and I guess this is as close as it gets:

"Routes" primary way to handle traffic: http://www.tt-forums.net/viewtopic.php?f=32&t=34086

User avatar
ffpp
Engineer
Engineer
Posts: 122
Joined: 29 Jan 2010 12:56

Re: [v0.4c] Template based train replacement r24093

Post by ffpp » 08 Aug 2012 16:51

Hello and thanks,

I've been away from the project for some time due to finishing my diploma and starting to work but I kept it in the back of my head that there are things left to do and things left to fix here.
I definitely want to finish and refine it and propose it for trunk integration once I meet the needed criteria.

User avatar
FLHerne
Tycoon
Tycoon
Posts: 1536
Joined: 12 Jul 2011 12:09
Location: St Ives, Cambs, UK

Re: [v0.4c] Template based train replacement r24093

Post by FLHerne » 08 Aug 2012 17:40

ffpp wrote:I've been away from the project for some time due to finishing my diploma and starting to work but I kept it in the back of my head that there are things left to do and things left to fix here.I definitely want to finish and refine it and propose it for trunk integration once I meet the needed criteria.
Good to know it isn't abandoned, it's become almost indispensable to me now I've got used to relying on it :D .
Temporary Permanent signature filling text. Content coming soon delayed indefinitely! Oh, and I have a screenshot thread now...
Linux user (XMonad DWM/KDE, Arch), IRC obsessive and rail enthusiast. No longer buiding robots.
Author of an incredibly boring stickied post about NewGRFs.

User avatar
ffpp
Engineer
Engineer
Posts: 122
Joined: 29 Jan 2010 12:56

Re: [v0.4c] Template based train replacement r24093

Post by ffpp » 29 Mar 2013 07:45

Finally resuming this.

I updated the first post with a plan/tasks for version0.5, namely:

- move the current version (v.0.4c) to newest trunk
- move to git
- split patch in smaller sub-patches

User avatar
FLHerne
Tycoon
Tycoon
Posts: 1536
Joined: 12 Jul 2011 12:09
Location: St Ives, Cambs, UK

Re: [v0.4c] Template based train replacement r24093

Post by FLHerne » 31 Mar 2013 22:02

It's good to see this patch back in development, I found it really useful for dealing with UKRS! :)
Temporary Permanent signature filling text. Content coming soon delayed indefinitely! Oh, and I have a screenshot thread now...
Linux user (XMonad DWM/KDE, Arch), IRC obsessive and rail enthusiast. No longer buiding robots.
Author of an incredibly boring stickied post about NewGRFs.

User avatar
ffpp
Engineer
Engineer
Posts: 122
Joined: 29 Jan 2010 12:56

Re: [v0.4c] Template based train replacement r24093

Post by ffpp » 22 Apr 2013 13:16

I fixed it up to compile against the newest trunk, it wasn't even that much work. I discovered that I couldn't make it compatible to trunk and cargodist at the same time anymore, but it is only a tiny fix that is necessary to get the trunk version to compile against cd as well.

It's in saveload.h:

Code: Select all

/** Type of reference (#SLE_REF, #SLE_CONDREF). */
enum SLRefType {
	REF_ORDER         = 0, ///< Load/save a reference to an order.
	REF_VEHICLE       = 1, ///< Load/save a reference to a vehicle.
	REF_STATION       = 2, ///< Load/save a reference to a station.
	REF_TOWN          = 3, ///< Load/save a reference to a town.
	REF_VEHICLE_OLD   = 4, ///< Load/save an old-style reference to a vehicle (for pre-4.4 savegames).
	REF_ROADSTOPS     = 5, ///< Load/save a reference to a bus/truck stop.
	REF_ENGINE_RENEWS = 6, ///< Load/save a reference to an engine renewal (autoreplace).
	REF_CARGO_PACKET  = 7, ///< Load/save a reference to a cargo packet.
	REF_ORDERLIST     = 8, ///< Load/save a reference to an orderlist.
	REF_STORAGE       = 9, ///< Load/save a reference to a persistent storage.
	REF_TEMPLATE_VEHICLE = 10, ///< Load/save a reference to a template vehicle,
where cargodist also has apended two items of its own. So this must be integrated manually.

I wanted to apply for getting my patch into trunk any time in the future but there is most likely a lot of work ahead for that to happen.
I've set up a git repository which will help in splitting the code up into reviewable sizes and I'm currently cleaning this up from debugging-leftovers and such.

There should still be instances of bad coding style inside, like using command functions not via the DoCommand() wrapper but rather directly. And I have to think about network-safety too.

Patch v0.5 will be simply a recent trunk-compilable one, with another version integrated into cargodist.

User avatar
DC-1
Engineer
Engineer
Posts: 88
Joined: 13 Mar 2013 13:53

Re: [v0.4c] Template based train replacement r24093

Post by DC-1 » 25 Nov 2013 23:58

A small bugreport via Trond: the crash when push template replace button in vehicle window which called from station gui.
Quick fix:
vehicle_gui.c near line 160:

Code: Select all

 DropDownList *BaseVehicleListWindow::BuildActionDropdownList(bool show_autoreplace, bool show_group)
 {
        DropDownList *list = new DropDownList();

-       if (show_autoreplace) list->push_back(new DropDownListStringItem(STR_VEHICLE_LIST_REPLACE_VEHICLES, ADI_REPLACE, false));
+       if (show_autoreplace) {
+           if (!_networking) list->push_back(new DropDownListStringItem(STR_TMPL_TEMPLATE_REPLACEMENT, ADI_TEMPLATE_REPLACE, false));
+           list->push_back(new DropDownListStringItem(STR_VEHICLE_LIST_REPLACE_VEHICLES, ADI_REPLACE, false));
+       } 
And yes: it also causes crash/desync on network games, so i've disabled it. :(

User avatar
ffpp
Engineer
Engineer
Posts: 122
Joined: 29 Jan 2010 12:56

Re: [v0.4c] Template based train replacement r24093

Post by ffpp » 26 Nov 2013 06:40

I didn't abandon this project, but I didn't have time to come back to it yet (this happens when you start too many projects at once and have only little time after work).
I didn't take care of any network compatibility with this mod so far, either ^^

Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 6 guests