refitting consist of articulated vehicle

Discuss, get help with, or post new graphics for TTDPatch and OpenTTD, using the NewGRF system, here. Graphics for plain TTD also acceptable here.

Moderator: Graphics Moderators

Post Reply
Wahazar
Tycoon
Tycoon
Posts: 1451
Joined: 18 Jan 2014 18:10

refitting consist of articulated vehicle

Post by Wahazar »

I tried to change number of trailers, using cargo subtype to choose different switches, but it fails:

Code: Select all

switch (FEAT_ROADVEHS, SELF, switch_myitem_articulated_0, extra_callback_info1) {
    return CB_RESULT_NO_MORE_ARTICULATED_PARTS;
}

switch (FEAT_ROADVEHS, SELF, switch_myitem_articulated_1, extra_callback_info1) {
	1:	return myitem;
    return CB_RESULT_NO_MORE_ARTICULATED_PARTS;
}

switch (FEAT_ROADVEHS, SELF, switch_myitem_articulated_2, extra_callback_info1) {
	1..2:	return myitem;
    return CB_RESULT_NO_MORE_ARTICULATED_PARTS;
}

switch (FEAT_ROADVEHS, SELF, switch_myitem_articulated, cargo_subtype) {
    0: switch_myitem_articulated_0;
    1: switch_myitem_articulated_1;
    2: switch_myitem_articulated_2;
   return CB_FAILED;
}
...
graphics {
	articulated_part:		switch_myitem_articulated;

I'm doing something wrong, or just trying something impossible to perform due to internal openttd structure (all those callback are still not quite clear to me)?

I know, that refitting length can be perfomed by replacing some vehicles by invisible 1-length carriage with no capacity,
but it is an ugly hack.
Is it possible to dynamically change consist of articulated vehicle?
"possible"=="fix code without large effort, without much code mock-up and risk of invalid pointers"
Formerly known as: McZapkie
Projects: Reproducible Map Generation patch, NewGRFs: Manpower industries, PolTrams, Polroad, 600mm narrow gauge, wired, ECS industry extension, V4 CEE train set, HotHut.
Another favorite games: freeciv longturn, OHOL/2HOL.
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5601
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: refitting consist of articulated vehicle

Post by PikkaBird »

McZapkie wrote:Is it possible to dynamically change consist of articulated vehicle?
No, it is not. Articulated parts are created when you buy the vehicle, and can't be added or removed on the fly.
Supercheese
Tycoon
Tycoon
Posts: 1660
Joined: 16 Dec 2007 22:24
Location: Idaho, USA

Re: refitting consist of articulated vehicle

Post by Supercheese »

McZapkie wrote:I know, that refitting length can be perfomed by replacing some vehicles by invisible 1-length carriage with no capacity,
but it is an ugly hack.
An ugly hack it may be, but darn, it works, so ya might as well use it. :wink:
Eyecandy Road Vehicles | Fake Subways | Supercheese's NewObjects

"Fashions and cultures change, but steam trains shall always be majestic."
-Professor Hershel Layton
Eddi
Tycoon
Tycoon
Posts: 8258
Joined: 17 Jan 2007 00:14

Re: refitting consist of articulated vehicle

Post by Eddi »

i'd be more willing to use it if it were possible to make the vehicles 0 length, because 1 causes some headaches...

(and i say this as the driving force behind andythenorth making use of that feature in HEQS)


also, i think there should be a way to influence the number of articulated parts from the vehicle purchase menu. (if you want to change the number of vehicles after the vehicle was purchased, use real wagons)
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5601
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: refitting consist of articulated vehicle

Post by PikkaBird »

Articulated road vehicles are a bad feature in any case. ;)
Wahazar
Tycoon
Tycoon
Posts: 1451
Joined: 18 Jan 2014 18:10

Re: refitting consist of articulated vehicle

Post by Wahazar »

PikkaBird wrote:Articulated road vehicles are a bad feature in any case. ;)
Why? Due to graphical glitches on road crossings?
Formerly known as: McZapkie
Projects: Reproducible Map Generation patch, NewGRFs: Manpower industries, PolTrams, Polroad, 600mm narrow gauge, wired, ECS industry extension, V4 CEE train set, HotHut.
Another favorite games: freeciv longturn, OHOL/2HOL.
TadeuszD
Transport Coordinator
Transport Coordinator
Posts: 329
Joined: 07 Nov 2011 19:32
Location: PL

Re: refitting consist of articulated vehicle

Post by TadeuszD »

McZapkie wrote:Why? Due to graphical glitches on road crossings?
Articulated road vehicles can not overtake each other. This does not apply to trams. They cannot overtake by default.
Image
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: refitting consist of articulated vehicle

Post by planetmaker »

McZapkie wrote:
PikkaBird wrote:Articulated road vehicles are a bad feature in any case. ;)
Why? Due to graphical glitches on road crossings?
'bad' as in 'use with great care and know its limitations' :)
As said, for trams it doesn't matter, but for "normal" road vehicles you buy it with a penalty. The penalty can be huge if you use many different with greatly varying max speeds - the speed differentiation then is basically negated.
Wahazar
Tycoon
Tycoon
Posts: 1451
Joined: 18 Jan 2014 18:10

Re: refitting consist of articulated vehicle

Post by Wahazar »

I was not aware about this overtake bug.
Now I understand, why eGRVTS horse carriages are making queues.
Currently I'm working on tram set,
but I see, that I must revise all my future ideas concerning tractors with trailers, semitrailer trucks etc :(
Formerly known as: McZapkie
Projects: Reproducible Map Generation patch, NewGRFs: Manpower industries, PolTrams, Polroad, 600mm narrow gauge, wired, ECS industry extension, V4 CEE train set, HotHut.
Another favorite games: freeciv longturn, OHOL/2HOL.
Wahazar
Tycoon
Tycoon
Posts: 1451
Joined: 18 Jan 2014 18:10

Re: refitting consist of articulated vehicle

Post by Wahazar »

Once more question - how running cost is calculated - as a sum of each articulated part, or only for heading unit?
Formerly known as: McZapkie
Projects: Reproducible Map Generation patch, NewGRFs: Manpower industries, PolTrams, Polroad, 600mm narrow gauge, wired, ECS industry extension, V4 CEE train set, HotHut.
Another favorite games: freeciv longturn, OHOL/2HOL.
Eddi
Tycoon
Tycoon
Posts: 8258
Joined: 17 Jan 2007 00:14

Re: refitting consist of articulated vehicle

Post by Eddi »

with most properties (weight, price, etc.), only the head unit is taken into account. the other units should return 0, in case this behaviour is ever changed.

the NFO specs have more information on which properties/callbacks are allowed for articulated parts.
Wahazar
Tycoon
Tycoon
Posts: 1451
Joined: 18 Jan 2014 18:10

Re: refitting consist of articulated vehicle

Post by Wahazar »

Indeed, everything is clearly noted here: http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles
I just didn't notice third column and thought, that every parameters is treated equally.
My inadvertency caused huge and faulty code:

Code: Select all

switch(FEAT_ROADVEHS, SELF, switch_KonstalN13_w1, position_in_consist) {
	0: return 18;
	1..2: return 0;
	return CB_FAILED;
}
switch(FEAT_ROADVEHS, SELF, switch_KonstalN13_w2, position_in_consist) {
	0..1: return 18;
	2: return 0;
	return CB_FAILED;
}
switch(FEAT_ROADVEHS, SELF, switch_KonstalN13_w3, position_in_consist) {
	0..2: return 18;
	return CB_FAILED;
}

switch(FEAT_ROADVEHS, SELF, switch_KonstalN13_weight, cargo_subtype) {
	0: switch_KonstalN13_w1;
	1: switch_KonstalN13_w2;
	2: switch_KonstalN13_w3;
	return CB_FAILED;
}
instead of

Code: Select all

switch(FEAT_ROADVEHS, SELF, switch_KonstalN13_weight, cargo_subtype) {
	0..2: return (cargo_subtype + 1) * 18;
	return CB_FAILED;
}

:)
Last edited by planetmaker on 16 Jun 2014 14:41, edited 1 time in total.
Reason: moved upon request
Formerly known as: McZapkie
Projects: Reproducible Map Generation patch, NewGRFs: Manpower industries, PolTrams, Polroad, 600mm narrow gauge, wired, ECS industry extension, V4 CEE train set, HotHut.
Another favorite games: freeciv longturn, OHOL/2HOL.
Post Reply

Return to “Graphics Development”

Who is online

Users browsing this forum: Bing [Bot] and 16 guests