I cannot reproduce the replacement of the maglev tracks in maglev track set v1 [FIXED]

Discussions about the technical aspects of graphics development, including NewGRF tools and utilities.

Moderator: Graphics Moderators

Post Reply
User avatar
Erato
Chief Executive
Chief Executive
Posts: 740
Joined: 25 May 2015 09:09
Location: The Netherlands

I cannot reproduce the replacement of the maglev tracks in maglev track set v1 [FIXED]

Post by Erato »

In Maglev Track Set v1 the tracks of the set could properly replace the base-game maglev "MGLV" when you set the proper parameters, so it doesn't contribute to the cap.
In Maglev Track Set v2 I reused most of the code from v1 in such a way that it should work in the same way. However in v2, it doesn't replace MGLV if you set the proper parameters. It just seems to hide MGLV and put something else there, so it contriutes to the cap.
Because of this you can only have 1 extra maglev tracktype added to the JapanSet, instead of the 2 extra ones you can get with Maglev Track Set v1.

I have not been able to see what could have caused this difference.

EDIT: With the help of Andrew I managed to determine that the problem seems to be the Urban Maglev Tracks. And it has nothing to do with MTS v1 vs v2

This works:
[+] Spoiler

Code: Select all

item(FEAT_RAILTYPES, MGLV, 4) {
     property {
         label:                      "MGLV";
         name:                       string(STR_LBAS);
         menu_text:                  string(STR_LBAS);
         build_window_caption:       string(STR_LBAS_BUILD_CAPTION);
         autoreplace_text:           string(STR_LBAS_AUTOREPLACE);
         new_engine_text:            string(STR_LBAS_NEW_ENGINE);
		 toolbar_caption:			 string(STR_LBAS_TB_CAPTION);
         compatible_railtype_list:   LBAS_M_TABLE;
         powered_railtype_list:      LBAS_M_TABLE;
		 alternative_railtype_list:  LBAS_M_TABLE;
         railtype_flags:             bitmask(RAILTYPE_FLAG_NO_LEVEL_CROSSING);
		 //introduction_date:			 date(1970,1,1);
		 map_colour:				 174;
         curve_speed_multiplier:     3;
         station_graphics:           RAILTYPE_STATION_MAGLEV;                  // It's a maglev innit
         construction_cost:          COSTPARAM(12,PARAM_MS_CONST);             // IDK I'll see
         speed_limit:                210 km/h;
         acceleration_model:         ACC_MODEL_MAGLEV;                         // It's a maglev innit
		 maintenance_cost:		     COSTPARAM(7,PARAM_MS_MAINT);			   // Maglev rail needs barely any maintenance
     }
     graphics {
         track_overlay:		LBAS_overlay;				// defines the sprites drawn as overlay for junctions and highlight
         underlay:			LBAS_underlay;				// defines the usual tracks and the underlay for junctions
         bridge_surfaces:	LBAS_bridge;				// defines the overlay drawn over bridges
		 tunnels:			LBAS_tunnel;				// defines the tracks drawn on a funnel tile
         depots:            switch_depot_LBAS;    				// defines the depot sprites
		 gui:				LBAS_gui;					// defines the gui sprites
		 tunnel_overlay:	UM_tunnel_overlay;			// Custom Tunnel portals since v2
         fences:          	switch_NO_UM_FENCE;             		// Custom Fences since v2
     }
 }
This does not work:
[+] Spoiler

Code: Select all

item(FEAT_RAILTYPES, MGLV, 4) {
     property {
         label:                      "MGLV";
         name:                       string(STR_TBAI);
         menu_text:                  string(STR_TBAI);
         build_window_caption:       string(STR_TBAI_BUILD_CAPTION);
         autoreplace_text:           string(STR_TBAI_AUTOREPLACE);
         new_engine_text:            string(STR_TBAI_NEW_ENGINE);
		 toolbar_caption:			 string(STR_TBAI_TB_CAPTION);
         compatible_railtype_list:   TBAI_M_TABLE;
         powered_railtype_list:      TBAI_M_TABLE;
		 alternative_railtype_list:  TBAI_M_TABLE;
         railtype_flags:             bitmask(RAILTYPE_FLAG_NO_LEVEL_CROSSING);
		 //introduction_date:			 date(1970,1,1);
		 map_colour:				 174;
         curve_speed_multiplier:     3;
         station_graphics:           RAILTYPE_STATION_MAGLEV;                  // It's a maglev innit
         construction_cost:          COSTPARAM(12,PARAM_MS_CONST);             // IDK I'll see
         speed_limit:                210 km/h;
         acceleration_model:         ACC_MODEL_MAGLEV;                         // It's a maglev innit
		 maintenance_cost:		     COSTPARAM(7,PARAM_MS_MAINT);			   // Maglev rail needs barely any maintenance
     }
     graphics {
         track_overlay:		TBAI_overlay;				// defines the sprites drawn as overlay for junctions and highlight
         underlay:			TBAI_underlay;				// defines the usual tracks and the underlay for junctions
         bridge_surfaces:	TBAI_bridge;				// defines the overlay drawn over bridges
		 tunnels:			TBAI_tunnel;				// defines the tracks drawn on a funnel tile
         depots:            switch_depot_TBAI;    				// defines the depot sprites
		 gui:				TBAI_gui;					// defines the gui sprites
		 tunnel_overlay:	UM_tunnel_overlay;			// Custom Tunnel portals since v2
         fences:          	switch_NO_UM_FENCE;             		// Custom Fences since v2
     }
 }
The full source is attached below. Would anyone know what the problem could be? I don't seem to be able to see the relevant difference.
Attachments
Maglev_Track_Set_2.0_Source.rar
Source of the newgrf where it does NOT work.
(179.43 KiB) Downloaded 90 times
Source_Maglev_Track_Set_1.1.rar
Source of the newgrf where it does work.
(390.59 KiB) Downloaded 84 times
Last edited by Erato on 27 Jul 2018 15:38, edited 2 times in total.
No pics no clicks. Seriously.
ImageImageImageImageImageImage
User avatar
Andrew350
Chairman
Chairman
Posts: 768
Joined: 19 Dec 2011 07:54
Location: Washington State, USA
Contact:

Re: I cannot reproduce the replacement of the maglev tracks in maglev track set v1

Post by Andrew350 »

Soo, two things:

1: The source you posted isn't really a source, it's just the .grf in a .tar in a .rar. Not really much we can do with that ;)

2: Maybe I'm missing something because of point 1 above, but in the code snippet you posted, v2 is clearly using a different railtype label than MGLV (which v1 is using).


Oops, it unpacked into 3 other folders I didn't see :oops:

EDIT: Even after looking through the files several times I can't seem to figure out where the decision is made on which railtype gets used. I see the parameters defined in the header, and I see the different railtypes defined both normally and as MGLV replacement, but I don't see the link between them? I could swear I've looked through all the files, did I just miss one somewhere or am I being thick?

EDIT 2: Aha, found it! It was irritating me that I couldn't figure it out :lol: Version 2.0 appears to be missing the 'metro_track_set.pnml' file found in version 1. This is where the logic happens to decide which tracktype to replace MGLV with; it appears you've simply left it out :)
User avatar
Erato
Chief Executive
Chief Executive
Posts: 740
Joined: 25 May 2015 09:09
Location: The Netherlands

Re: I cannot reproduce the replacement of the maglev tracks in maglev track set v1

Post by Erato »

Andrew350 wrote:Aha, found it! It was irritating me that I couldn't figure it out :lol: Version 2.0 appears to be missing the 'metro_track_set.pnml' file found in version 1. This is where the logic happens to decide which tracktype to replace MGLV with; it appears you've simply left it out :)
So sorry. Of course I can't leave that file out, because it needs that file to compile the newgrf. I accidentally sent an incorrect source. Attached is the missing file, which is the same as the one in version 1, and has been tried and tested and seems to work without any problems.

Edit: and of course I added the thing I uploaded to BaNaNaS instead of the main file... I should check these files before posting
Attachments
Maglev_Track_Set.pnml
The main .pnml file of Maglev Track Set v2.
(1.08 KiB) Downloaded 78 times
No pics no clicks. Seriously.
ImageImageImageImageImageImage
User avatar
Andrew350
Chairman
Chairman
Posts: 768
Joined: 19 Dec 2011 07:54
Location: Washington State, USA
Contact:

Re: I cannot reproduce the replacement of the maglev tracks in maglev track set v1

Post by Andrew350 »

Erato wrote:Because of this you can only have 1 extra maglev tracktype added to the JapanSet, instead of the 2 extra ones you can get with Maglev Track Set v1.
So I fired up OTTD to do some more testing of your parameters using the latest versions of RIMS, Japanese Tracks, Japanese Trains, and of course Maglev Track Set. Using version 1 of MTS, I could never activate more than two types without an error (i.e. the selected override tracktype + one other); I get the same limitation using version 2, with the minor exception of the SUMA tracktype, which can be selected as a third one (It never seems to appear in-game though).

The one big issue I found in version 2 however is that it seems the Urban Maglev tracks don't play well with any other type, whereas I can happily activate e.g. Transrapid and SC-Maglev or M-Bahn together. I could even do Transrapid, SC-Maglev, and SUMA (as noted above), but any combo using Urban Maglev fails miserably (unless used alone).

Since I can activate the same amount of tracktypes in both versions EXCEPT when using Urban Maglev, I'm guessing that's where the issue is. Maybe a conflict with the IDs or something?
User avatar
Erato
Chief Executive
Chief Executive
Posts: 740
Joined: 25 May 2015 09:09
Location: The Netherlands

Re: I cannot reproduce the replacement of the maglev tracks in maglev track set v1

Post by Erato »

Andrew350 wrote:
Erato wrote:Because of this you can only have 1 extra maglev tracktype added to the JapanSet, instead of the 2 extra ones you can get with Maglev Track Set v1.
So I fired up OTTD to do some more testing of your parameters using the latest versions of RIMS, Japanese Tracks, Japanese Trains, and of course Maglev Track Set. Using version 1 of MTS, I could never activate more than two types without an error (i.e. the selected override tracktype + one other); I get the same limitation using version 2, with the minor exception of the SUMA tracktype, which can be selected as a third one (It never seems to appear in-game though).

The one big issue I found in version 2 however is that it seems the Urban Maglev tracks don't play well with any other type, whereas I can happily activate e.g. Transrapid and SC-Maglev or M-Bahn together. I could even do Transrapid, SC-Maglev, and SUMA (as noted above), but any combo using Urban Maglev fails miserably (unless used alone).

Since I can activate the same amount of tracktypes in both versions EXCEPT when using Urban Maglev, I'm guessing that's where the issue is. Maybe a conflict with the IDs or something?
Thank you so much for this. Thanks to this I was able to find and fix the problem.

Turns out, I had this code to load the SUMA tracks:

Code: Select all

if (PARAM_MGLV == 3 && PARAM_TCAI == 1) {
    #include "src/Tracktypes/MGLV/TCAI.pnml"
} else if (PARAM_TBAI == 1) {
    #include "src/Tracktypes/TCAI.pnml"
}
Instead of:

Code: Select all

if (PARAM_MGLV == 3 && PARAM_TCAI == 1) {
    #include "src/Tracktypes/MGLV/TCAI.pnml"
} else if (PARAM_TCAI == 1) {
    #include "src/Tracktypes/TCAI.pnml"
}
(I used PARAM_TBAI instead of PARAM_TCAI; I was 1 letter off)
PARAM_TBAI being the parameter that loads up Urban maglevs, so when it checks what to load, and it sees that SUMA is turned off, it checks to see if Urban maglevs are on, and if they are, it loads the SUMA tracks before checking to see if it should load the Urban maglevs. JapanSet only allows 1 extra tracktype, so after it loads the SUMA tracks, it gives up and returns an error.
The only newgrf that has trains that use SUMA tracks are in MMT and a newgrf I'm currently working on, so when used with RIMS, it's invisible and doesn't show up, yet counts to the total nonetheless.
No pics no clicks. Seriously.
ImageImageImageImageImageImage
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 4 guests