Skip to main content
Topic: Increasing maximum rail length (Read 13789 times) previous topic - next topic

Increasing maximum rail length

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.... ::)

Re: Increasing maximum rail length

Reply #1
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...

My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!

Re: Increasing maximum rail length

Reply #2
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).........

Re: Increasing maximum rail length

Reply #3
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

Re: Increasing maximum rail length

Reply #4
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

Re: Increasing maximum rail length

Reply #5
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.

Re: Increasing maximum rail length

Reply #6
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 ;)

My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!

Re: Increasing maximum rail length

Reply #7
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.....  ::)

Re: Increasing maximum rail length

Reply #8
Ok. I thought you used msvc since you started posting here so enthusiastically.

My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!

Re: Increasing maximum rail length

Reply #9
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.

Re: Increasing maximum rail length

Reply #10
It works.... ;D


Re: Increasing maximum rail length

Reply #11
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

My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!


Re: Increasing maximum rail length

Reply #13
Oh nooo!!.....

Re: Increasing maximum rail length

Reply #14

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

:) :) :D



Re: Increasing maximum rail length

Reply #16
I didn't noticed this feature implemented in any release. Is any chance it will be included?

 

Re: Increasing maximum rail length

Reply #17
It is already part of Simutrans-Experimental: see here on how to get it.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.