News:

Simutrans Chat Room
Where cool people of Simutrans can meet up.

Increasing maximum rail length

Started by vilvoh, October 22, 2008, 07:06:23 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

vilvoh

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

Escala Real...a blog about Simutrans in Spanish...

VS

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 classes 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!

vilvoh

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

Escala Real...a blog about Simutrans in Spanish...

vilvoh

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):
unsigned get_max_convoi_length() const { return convoi_t::max_rail_vehicle;]

by this:
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

Escala Real...a blog about Simutrans in Spanish...

isidoro

Quote from: 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.

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

Quote from: 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):
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

vilvoh

Quote from: isidoro on October 22, 2008, 11:56:40 PM
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

Quote from: isidoro on October 22, 2008, 11:56:40 PM
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.

Escala Real...a blog about Simutrans in Spanish...

VS

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!

vilvoh

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

Escala Real...a blog about Simutrans in Spanish...

VS

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!

vilvoh

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.

Escala Real...a blog about Simutrans in Spanish...

vilvoh


Escala Real...a blog about Simutrans in Spanish...

VS

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!

Zeno

Quote from: 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
A newly recruited developer!! You have no scape now, Vilvoh!  ;D ;D ;D

vilvoh


Escala Real...a blog about Simutrans in Spanish...

isidoro


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

:) :) :D


IgorEliezer

WOW! Seems Prissi will have a new trainee in devteam.

(sorry, I couldn't resist  ::) )

Sarrus

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

jamespetts

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.