The International Simutrans Forum

Development => Patches & Projects => Topic started by: vilvoh on October 22, 2008, 07:06:23 am

Title: Increasing maximum rail length
Post by: vilvoh on October 22, 2008, 07:06:23 am
The point is that I don't know from where to start. I've programming skills but I wouldn't like to do something very complicate, mainly because I don't have time enough.

For that article, I was thinking on something easy like increase the max number of wagons a convoy can transport (as far as I know, you only have to change one line of code) or perhaps search in the forum archive for a reasonable, and easy-to-implement, extension request. Things like those, you know. I would like to show to people that Simutrans code is not as hard to hack as it seems.... ::)
Title: Re: Increasing maximum rail length
Post by: VS on October 22, 2008, 09:10:28 am
Regardless which project, the first attempt is hard because you do not know where is what. I would say it's sink or swim - try and see if you can find any place where to begin.

As to depot, maybe you could start from files that have depot in name and look at the include headers and cl****es and so on. That's what I would do. Alternatively you could search for the number you know is maximum...
Title: Re: Increasing maximum rail length
Post by: vilvoh on October 22, 2008, 09:26:58 am
Well, In this case I think I know where I must do the hack (prissi's comment from the old forum >> Extension Request >> Only 24 Wagons per train?) but thanks for the advices.
Quote
It is very easy to do it yourself. Download the source and compile it, you have just to change one parameter in simdepot.h I think. However, the vehicles will be shown outside the depot window and not be selectable any more (but you can still dissamble and sell a convoi).........
Title: Re: Increasing maximum rail length
Post by: vilvoh on October 22, 2008, 11:08:51 pm
I've tried to increase the max. number of wagons per convoy, modifying simudepot.h - line 245 , but seems it does not work. I mean, the game allows you to buy that amount of wagons, let's say 26, but the depot window shows 24 as maximun.

I've changed this (line 245):
Code: [Select]
unsigned get_max_convoi_length() const { return convoi_t::max_rail_vehicle;]

by this:
Code: [Select]
unsigned get_max_convoi_length() const { return 26;}

Indeed, when the convoy starts running, it has got not more than 24 wagons (1+23). The strange thing is that If put a lower limit, let's say 10, there's no problem. I can't buy a convoy with more than 10 wagons and when the convoy is out of the depot, it has 10 wagons max. I guess there's some kind of constraint somewhere in the code that do not allow to show such an amount of wagons. Any idea?

P.S: you can read the blog's article about it here (http://simutrans-escala-real.blogspot.com/2008/10/zambullndose-en-simutrans-iv-una-pequea.html)
Title: Re: Increasing maximum rail length
Post by: isidoro on October 22, 2008, 11:56:40 pm
The point is that I don't know from where to start. I've programming skills but I wouldn't like to do something very complicate, mainly because I don't have time enough.

So, you would like to make a sort of tutorial, wouldn't you?  Perhaps another easy one could be putting colors of players to line names in public stations, so that one can know to which player they belong.  Another one: to show numbers (in schedule order) in line preview in the map...

I've tried to increase the max. number of wagons per convoy, modifying simudepot.h - line 245 , but seems it does not work. I mean, the game allows you to buy that amount of wagons, let's say 26, but the depot window shows 24 as maximun.

I've changed this (line 245):
Code: [Select]
unsigned get_max_convoi_length() const { return convoi_t::max_rail_vehicle;]
[...]

I would follow up asking Window's search dog to find *.cc or *.h files with max_rail_vehicle.  Grep gives me these two lines in simconvoi.cc:
                fahr.resize(max_rail_vehicle, NULL);
                        fahr.resize(max_rail_vehicle, NULL);


These lines don't use the getter method and access the variable directly.  Moreover, it appears this line in simconvoi.h:
enum { max_vehicle=4, max_rail_vehicle = 24 };

Perhaps it is a better idea then to change that 24 for 26.  You can first revert files with svn to the version stored in the repository:
svn revert simudepot.h
Title: Re: Increasing maximum rail length
Post by: vilvoh on October 23, 2008, 06:55:35 am
another easy one could be putting colors of players to line names in public stations.
Another one: to show numbers (in schedule order) in line preview in the map...

Good ones, I'll include them in the future article's list

These lines don't use the getter method and access the variable directly.  Moreover, it appears this line in simconvoi.h:
enum { max_vehicle=4, max_rail_vehicle = 24 };

Perhaps it is a better idea then to change that 24 for 26.
Ahh! was that... I suspected that max_rail_vehicle has a fixed value specified in somewhere. That's why it lets you buy more wagons than the limit but it does not show them when the convoi is out of the window. Thanks again for the explanation, Isidore. I'll correct the article.
Title: Re: Increasing maximum rail length
Post by: VS on October 23, 2008, 08:44:14 am
Just so that you know - it's a GUI for a reason. Right click max_rail_vehicle, select Go To Definition and see for yourself ;)
Title: Re: Increasing maximum rail length
Post by: vilvoh on October 23, 2008, 08:58:58 am
I was using gvim, which is not really the best programming IDE, as MsVC or others. It's just a good text editor with some extra features.....  ::)
Title: Re: Increasing maximum rail length
Post by: VS on October 23, 2008, 09:15:08 am
Ok. I thought you used msvc since you started posting here so enthusiastically.
Title: Re: Increasing maximum rail length
Post by: vilvoh on October 23, 2008, 09:31:49 am
Well, In fact I use both in windows, but I usually program in Linux. Anyway, the point is that I didn't know from where was the program taking that value, because in that file (simudepot.h) max_rail_vehicle is also defined as a constant with zero value.
Title: Re: Increasing maximum rail length
Post by: vilvoh on October 24, 2008, 05:18:47 pm
It works.... ;D
(http://2.bp.blogspot.com/_dgV8cATuuJA/SQICCDmFfbI/AAAAAAAAA10/i4g7EU0U7ik/s800/30_wag_2.jpg)
(http://lh3.ggpht.com/XdXavier/SQIBUL4sFlI/AAAAAAAAA1s/XZY7G6ydzqI/s400/30wag_pre.jpg)
Title: Re: Increasing maximum rail length
Post by: VS on October 24, 2008, 05:24:11 pm
Great, now you could add a scrollbar and set it to 1024. And display little numbers under consists so that you don't get lost in your depot ;D
Title: Re: Increasing maximum rail length
Post by: Zeno on October 24, 2008, 06:29:41 pm
Great, now you could add a scrollbar and set it to 1024. And display little numbers under consists so that you don't get lost in your depot ;D
A newly recruited developer!! You have no scape now, Vilvoh!  ;D ;D ;D
Title: Re: Increasing maximum rail length
Post by: vilvoh on October 24, 2008, 06:39:12 pm
Oh nooo!!.....(http://www.greensmilies.com/smile/smiley_emoticons_dinosaurier02.gif)
Title: Re: Increasing maximum rail length
Post by: isidoro on October 24, 2008, 09:53:57 pm

Listen to the call of the Ring, Vilvooooh...

:) :) :D

Title: Re: Increasing maximum rail length
Post by: IgorEliezer on October 25, 2008, 02:38:29 am
WOW! Seems Prissi will have a new trainee in devteam.

(sorry, I couldn't resist  ::) )
Title: Re: Increasing maximum rail length
Post by: Sarrus on May 10, 2009, 03:19:14 pm
I didn't noticed this feature implemented in any release. Is any chance it will be included?
Title: Re: Increasing maximum rail length
Post by: jamespetts on May 10, 2009, 03:51:50 pm
It is already part of Simutrans-Experimental: see here (http://forum.simutrans.com/index.php?topic=1894.0) on how to get it.