The International Simutrans Forum

 

Author Topic: Increasing maximum rail length  (Read 10863 times)

0 Members and 1 Guest are viewing this topic.

Offline vilvoh

  • One of the good guys
  • Administrator (Inactive)
  • *
  • Posts: 4504
  • I'm the constructor, the architect
    • Escala real
Increasing maximum rail length
« 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.... ::)
« Last Edit: October 23, 2008, 10:09:49 AM by prissi »

Offline VS

  • Senior Plumber (Devotee)
  • Devotees (Inactive)
  • *
  • Posts: 4856
  • Vladimír Slávik
    • VS's Simutrans site
  • Languages: CS,EN
Re: Increasing maximum rail length
« Reply #1 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 classes and so on. That's what I would do. Alternatively you could search for the number you know is maximum...

Offline vilvoh

  • One of the good guys
  • Administrator (Inactive)
  • *
  • Posts: 4504
  • I'm the constructor, the architect
    • Escala real
Re: Increasing maximum rail length
« Reply #2 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).........

Offline vilvoh

  • One of the good guys
  • Administrator (Inactive)
  • *
  • Posts: 4504
  • I'm the constructor, the architect
    • Escala real
Re: Increasing maximum rail length
« Reply #3 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

Offline isidoro

  • Devotee
  • *
  • Posts: 1140
Re: Increasing maximum rail length
« Reply #4 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

Offline vilvoh

  • One of the good guys
  • Administrator (Inactive)
  • *
  • Posts: 4504
  • I'm the constructor, the architect
    • Escala real
Re: Increasing maximum rail length
« Reply #5 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.

Offline VS

  • Senior Plumber (Devotee)
  • Devotees (Inactive)
  • *
  • Posts: 4856
  • Vladimír Slávik
    • VS's Simutrans site
  • Languages: CS,EN
Re: Increasing maximum rail length
« Reply #6 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 ;)

Offline vilvoh

  • One of the good guys
  • Administrator (Inactive)
  • *
  • Posts: 4504
  • I'm the constructor, the architect
    • Escala real
Re: Increasing maximum rail length
« Reply #7 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.....  ::)
« Last Edit: October 23, 2008, 09:05:38 AM by vilvoh »

Offline VS

  • Senior Plumber (Devotee)
  • Devotees (Inactive)
  • *
  • Posts: 4856
  • Vladimír Slávik
    • VS's Simutrans site
  • Languages: CS,EN
Re: Increasing maximum rail length
« Reply #8 on: October 23, 2008, 09:15:08 AM »
Ok. I thought you used msvc since you started posting here so enthusiastically.

Offline vilvoh

  • One of the good guys
  • Administrator (Inactive)
  • *
  • Posts: 4504
  • I'm the constructor, the architect
    • Escala real
Re: Increasing maximum rail length
« Reply #9 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.

Offline vilvoh

  • One of the good guys
  • Administrator (Inactive)
  • *
  • Posts: 4504
  • I'm the constructor, the architect
    • Escala real
Re: Increasing maximum rail length
« Reply #10 on: October 24, 2008, 05:18:47 PM »
It works.... ;D


Offline VS

  • Senior Plumber (Devotee)
  • Devotees (Inactive)
  • *
  • Posts: 4856
  • Vladimír Slávik
    • VS's Simutrans site
  • Languages: CS,EN
Re: Increasing maximum rail length
« Reply #11 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

Offline Zeno

  • ENASSA Designer
  • Devotees (Inactive)
  • *
  • Posts: 1997
    • Zeno's Simutrans Creations
  • Languages: ES, EN, CAT
Re: Increasing maximum rail length
« Reply #12 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

Offline vilvoh

  • One of the good guys
  • Administrator (Inactive)
  • *
  • Posts: 4504
  • I'm the constructor, the architect
    • Escala real
Re: Increasing maximum rail length
« Reply #13 on: October 24, 2008, 06:39:12 PM »
Oh nooo!!.....

Offline isidoro

  • Devotee
  • *
  • Posts: 1140
Re: Increasing maximum rail length
« Reply #14 on: October 24, 2008, 09:53:57 PM »

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

:) :) :D


Offline IgorEliezer

  • Devotee
  • Administrator
  • *
  • Posts: 4112
  • I have nothing to do with it!
    • Igor Eliezer Architect and Urban Planner/Arquiteto e Urbanista
  • Languages: PT, EN, AutoLISP, Python
Re: Increasing maximum rail length
« Reply #15 on: October 25, 2008, 02:38:29 AM »
WOW! Seems Prissi will have a new trainee in devteam.

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

Offline Sarrus

  • *
  • Posts: 54
  • Languages: EN, PL
Re: Increasing maximum rail length
« Reply #16 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?

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20805
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Increasing maximum rail length
« Reply #17 on: May 10, 2009, 03:51:50 PM »
It is already part of Simutrans-Experimental: see here on how to get it.