Problems with coding refit cycle

Get help, info, news and advice about the Transport Tycoon Deluxe patch.

Moderator: TTDPatch Moderators

Locked
User avatar
Wile E. Coyote
Tycoon
Tycoon
Posts: 8514
Joined: 08 Jul 2004 22:14
Skype: wile.e.coyote2
Location: Belgrade, Serbia
Contact:

Problems with coding refit cycle

Post by Wile E. Coyote » 16 Jun 2008 08:10

New problems... :(

I tried to code refit cycle. I set in Action 0 cargo to passengers and in refit mask passengers only. I defined D0 strings for cargo subtype and used this code:

Code: Select all

  109 * 9	  02 01 00 01 01 00 00 00 00
  110 * 9	  02 01 01 01 01 01 00 01 00
  111 * 18	 02 01 10 81 F2 00 FF 02 30 FF 00 00 31 FF 01 01 FF FF
//Var. F2 (refit cycle) - text: use text D0 30 for first option and D0 31 for second option
  112 * 14	 02 01 11 81 F2 00 FF 01 01 00 01 01 00 00
//Var. F2 (refit cycle) - graphics: use c-ID 01 for second option, else use c-ID 00
  113 * 18	 02 01 20 81 10 00 FF 02 49 FF 01 02 0E FF 03 03 11 00 // set sound effects
  114 * 18	 02 01 21 81 0C 00 FF 02 20 00 33 33 10 00 19 19 11 00
//use c-ID 20 for sound callback and c-ID 10 for cargo subtype display callback
  115 * 7	  03 01 01 47 00 21 00
In refit menu appears only "Passengers", not two rows with two texts. Also, you can refit vehicle once, livery changes, twice, livery changes again, and you can't refit it anymore. Where is mistake?
Serbian rail set with Serbian scenario (ECS, PBI, FIRS and Tourist set compatible) Website | Topic and download | Latest version: 03.06.2015.
Serbian tram set Tracking table | TTD Patch tram set Latest version: 17.06.2015. | Open TTD Remix Latest version: 11.07.2015.
WIN-DOS GRF Converter Topic and download | Version 0.2.1: 09.01.2005.


Runner-up in "Best avatar Forums award" for years 2006 and 2010!

michael blunck
Tycoon
Tycoon
Posts: 5271
Joined: 27 Apr 2005 07:09
Contact:

Re: Problems with coding refit cycle

Post by michael blunck » 16 Jun 2008 10:09

How does your action0 look like? Did you set the bit for CB19 (cargo subtype)?

regards
Michael
Image

User avatar
Wile E. Coyote
Tycoon
Tycoon
Posts: 8514
Joined: 08 Jul 2004 22:14
Skype: wile.e.coyote2
Location: Belgrade, Serbia
Contact:

Re: Problems with coding refit cycle

Post by Wile E. Coyote » 16 Jun 2008 10:41

No! I forgot to set it! Thanx, Michael! :D

But second problem appears: I want to make refit to articulated or non-articulated vehicle. Code now looks like this:

Code: Select all

  109 * 9	  02 01 00 01 01 00 00 00 00
//tram graphics
  110 * 9	  02 01 01 01 01 01 00 01 00
//trailer graphics
  111 * 14	 02 01 02 81 0C 00 FF 01 03 FF 11 11 00 00
//shortened tram, c-id 02
  112 * 14	 02 01 03 81 0C 00 FF 01 03 FF 11 11 01 00
//shortened trailer, c-id 03

  113 * 18	 02 01 10 81 10 00 FF 02 49 FF 01 02 0E FF 03 03 02 00
//sound effects, else use c-id 02
  114 * 14	 02 01 11 81 0C 00 FF 01 10 00 33 33 02 00
//callback for tram without trailer, else use c-id 02; this is c-id 11

  115 * 14	 02 01 20 81 41 00 01 01 02 00 00 00 03 00
//sprite layout
  116 * 14	 02 01 21 81 10 00 FF 01 47 FF 01 01 FF FF
//build articulated vehicle for ID 47
  117 * 18	 02 01 22 81 10 00 FF 02 49 FF 01 02 0E FF 03 03 20 00
//sound effects, else use sprite layout
  118 * 18	 02 01 23 81 0C 00 FF 02 21 00 16 16 22 00 33 33 20 00
//callback for tram with trailer, else use sprite layout; this is c-id 23

  119 * 18	 02 01 30 81 F2 00 FF 02 30 FF 00 00 31 FF 01 01 FF FF
//texts cycle
  120 * 14	 02 01 31 81 F2 00 FF 01 23 00 01 01 11 00
//second in refit cycle is c-id 23, else use c-id 11

  121 * 14	 02 01 40 81 0C 00 FF 01 30 00 19 19 31 00
//use texts cycle 30 to display texts, else use refit cycle
  122 * 7	  03 01 01 47 00 40 00
//assign c-id 40 to ID 47
Texts are displayed, but in both cases is shown only non-articulated vehicle. I set bits for: length, building articulated vehicle, showing suffix text and sound effects (that is sum B2 in hex). I tried with setting bit for refitted capacity, but nothing is changed. Where is mistake now?
Serbian rail set with Serbian scenario (ECS, PBI, FIRS and Tourist set compatible) Website | Topic and download | Latest version: 03.06.2015.
Serbian tram set Tracking table | TTD Patch tram set Latest version: 17.06.2015. | Open TTD Remix Latest version: 11.07.2015.
WIN-DOS GRF Converter Topic and download | Version 0.2.1: 09.01.2005.


Runner-up in "Best avatar Forums award" for years 2006 and 2010!

User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5391
Joined: 13 Sep 2004 13:21
Location: The Moon
Contact:

Re: Problems with coding refit cycle

Post by PikkaBird » 16 Jun 2008 13:02

You cannot create or destroy articulated parts on the fly; the articulation callback is run only once when the vehicle is bought.

User avatar
Wile E. Coyote
Tycoon
Tycoon
Posts: 8514
Joined: 08 Jul 2004 22:14
Skype: wile.e.coyote2
Location: Belgrade, Serbia
Contact:

Re: Problems with coding refit cycle

Post by Wile E. Coyote » 16 Jun 2008 13:16

I was affraid of that...

I used fake trailer to display tram without trailer:

Code: Select all

  110 * 9	  02 01 00 01 01 00 00 00 00
//tram
  111 * 9	  02 01 01 01 01 01 00 01 00
//trailer
  112 * 14	 02 01 02 81 0C 00 FF 01 03 FF 11 11 00 00
//shortened tram, c-id 02
  113 * 14	 02 01 03 81 0C 00 FF 01 03 FF 11 11 01 00
//shortened trailer, c-id 03
  114 * 4	  01 01 01 01
  115 c:\igre\ttwin95\sprites/srvttw.pcx 178 104 09 1 1 0 0
  116 * 9	  02 01 04 01 01 00 00 00 00
//fake trailer
  117 * 14	 02 01 05 81 0C 00 FF 01 08 FF 11 11 04 00
//shortened fake trailer, c-id 05
  118 * 14	 02 01 10 81 41 00 01 01 02 00 00 00 05 00
//sprite layout (tram + fake trailer)
  119 * 14	 02 01 11 81 10 00 FF 01 47 FF 01 01 FF FF
//build one more vehicle with ID 47
  120 * 18	 02 01 13 81 0C 00 FF 02 11 00 16 16 22 FF 15 15 10 00
//callbacks: build articulated vehicle, set refitted capacity, else sprite layout, c-id 13
  121 * 14	 02 01 20 81 41 00 01 01 02 00 00 00 03 00
//sprite layout (tram + trailer)
  122 * 14	 02 01 21 81 10 00 FF 01 47 FF 01 01 FF FF
//build one more vehicle with ID 47
  123 * 18	 02 01 23 81 0C 00 FF 02 21 00 16 16 44 FF 15 15 20 00
//callbacks: build articulated vehicle, set refitted capacity, else sprite layout, c-id 13
  124 * 18	 02 01 30 81 F2 00 FF 02 30 FF 00 00 31 FF 01 01 FF FF
//text cycle
  125 * 14	 02 01 31 81 F2 00 FF 01 23 00 01 01 13 00
//vehicles cycle
  126 * 18	 02 01 39 81 10 00 FF 02 49 FF 01 02 0E FF 03 03 4A FF
//sound effects
  127 * 18	 02 01 40 81 0C 00 FF 02 30 00 19 19 39 00 33 33 31 00
//callbacks: cargo sub-type cycle, sound effects, else vehicles cycle
  128 * 7	  03 01 01 47 00 40 00//assign c-id 40 to ID 47
Of course, I set bit for refitted capacity in Action 0 as well. But when I click on refit, Patch crashes without crashlog. Did I make mistake, or I wish impossible thing again, or it's bug in Patch?
(With OTTD there is no crash, but all capacities, even in buy list, are doubled.)
Serbian rail set with Serbian scenario (ECS, PBI, FIRS and Tourist set compatible) Website | Topic and download | Latest version: 03.06.2015.
Serbian tram set Tracking table | TTD Patch tram set Latest version: 17.06.2015. | Open TTD Remix Latest version: 11.07.2015.
WIN-DOS GRF Converter Topic and download | Version 0.2.1: 09.01.2005.


Runner-up in "Best avatar Forums award" for years 2006 and 2010!

DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Re: Problems with coding refit cycle

Post by DaleStan » 16 Jun 2008 19:53

Wile E. Coyote wrote:Patch crashes without crashlog. Did I make mistake,
You mean, besides failing to follow the instructions in my signature?
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser

User avatar
Wile E. Coyote
Tycoon
Tycoon
Posts: 8514
Joined: 08 Jul 2004 22:14
Skype: wile.e.coyote2
Location: Belgrade, Serbia
Contact:

Re: Problems with coding refit cycle

Post by Wile E. Coyote » 17 Jun 2008 07:05

Does that question means that code is OK? I was convinced I did something impossible again. :) Here is debug. Configs are also attached. Maybe could help: callback does not crash Patch. Setting bit for refitting callback is enough. I had to run debug in TTD window mode because when I run it in fullscreen computer totally hangs.
Attachments
crash.png
(68.12 KiB) Downloaded 58 times
TTWin95.zip
(2.84 KiB) Downloaded 96 times
Serbian rail set with Serbian scenario (ECS, PBI, FIRS and Tourist set compatible) Website | Topic and download | Latest version: 03.06.2015.
Serbian tram set Tracking table | TTD Patch tram set Latest version: 17.06.2015. | Open TTD Remix Latest version: 11.07.2015.
WIN-DOS GRF Converter Topic and download | Version 0.2.1: 09.01.2005.


Runner-up in "Best avatar Forums award" for years 2006 and 2010!

DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Re: Problems with coding refit cycle

Post by DaleStan » 18 Jun 2008 03:29

OK, I found the crash, but I'd rather not try to fix it blind. Chances are that the NFO is valid. Please post a test GRF.

The significant detail is that there be at least two vehicles in the consist for which the bit for CB15 is set.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser

User avatar
Wile E. Coyote
Tycoon
Tycoon
Posts: 8514
Joined: 08 Jul 2004 22:14
Skype: wile.e.coyote2
Location: Belgrade, Serbia
Contact:

Re: Problems with coding refit cycle

Post by Wile E. Coyote » 18 Jun 2008 06:06

OK, here is test GRF. ID which caused crash is 47 (named Les Ateliers Métallurgiques in game). Open refit list and click on any of two refit options. Patch crashes in that moment.

EDIT: Attachment removed. Download new attachment below.
Last edited by Wile E. Coyote on 19 Jun 2008 08:28, edited 1 time in total.
Serbian rail set with Serbian scenario (ECS, PBI, FIRS and Tourist set compatible) Website | Topic and download | Latest version: 03.06.2015.
Serbian tram set Tracking table | TTD Patch tram set Latest version: 17.06.2015. | Open TTD Remix Latest version: 11.07.2015.
WIN-DOS GRF Converter Topic and download | Version 0.2.1: 09.01.2005.


Runner-up in "Best avatar Forums award" for years 2006 and 2010!

User avatar
Lakie
TTDPatch Developer
TTDPatch Developer
Posts: 1804
Joined: 26 May 2004 16:37
Location: Britain
Contact:

Re: Problems with coding refit cycle

Post by Lakie » 18 Jun 2008 17:56

What refit values should we be getting, currently I get 17 (default), 68 for a single trailer and 136 for two trailers.

~ Lakie
TTDpatch Developer 2005 - 2010 ~ It all started because of shortened vehicle not loading correctly, now look where I've gone with it!
Grfs coded ~ Finnish Train Set (Teaser) | Bm73 (Release 3) | Emu 680 (Release 3)| Glass Station (Release 1) | UK Roadset (Version 1.1a) | New Water Coasts (Version 7)
Pikka: "Lakie's a good coder, but before he'll add any feature to TTDP you have to convince him that you're not going to use it to destroy the world as we know it."

User avatar
Lakie
TTDPatch Developer
TTDPatch Developer
Posts: 1804
Joined: 26 May 2004 16:37
Location: Britain
Contact:

Re: Problems with coding refit cycle

Post by Lakie » 18 Jun 2008 22:36

Having looked at the grf and debugging it seems like you are trying to spoof the refit code, so that both vehicles return 34 for one trailer and two trailers return 68, so basically 34 per part, however with articulated road vehicles like trains it loops through all parts of the articulated road vehicle getting the total cargo of the refit (which is the correct behaviour), so it acts like multiplying the cargo amount by 2. :o

~ Lakie
TTDpatch Developer 2005 - 2010 ~ It all started because of shortened vehicle not loading correctly, now look where I've gone with it!
Grfs coded ~ Finnish Train Set (Teaser) | Bm73 (Release 3) | Emu 680 (Release 3)| Glass Station (Release 1) | UK Roadset (Version 1.1a) | New Water Coasts (Version 7)
Pikka: "Lakie's a good coder, but before he'll add any feature to TTDP you have to convince him that you're not going to use it to destroy the world as we know it."

User avatar
Wile E. Coyote
Tycoon
Tycoon
Posts: 8514
Joined: 08 Jul 2004 22:14
Skype: wile.e.coyote2
Location: Belgrade, Serbia
Contact:

Re: Problems with coding refit cycle

Post by Wile E. Coyote » 19 Jun 2008 06:24

I'm trying to obtain 34 for first (with fake trailer) and 68 for second, so I put 17 for default but obtained double double capacity. :?
EDIT: But it's not big problem, I just changed refitted capacities and obtained desired values. Bigger problems are becoming runaway trailers and total desintegrating of 5-part consist. Here is GRF for testing. Pay attention on tram which appears in 2007 (CROTRAM TMK 2200). Vehicle we discussed about has trailer problems too.
Attachments
stsw.grf
(92.06 KiB) Downloaded 94 times
Serbian rail set with Serbian scenario (ECS, PBI, FIRS and Tourist set compatible) Website | Topic and download | Latest version: 03.06.2015.
Serbian tram set Tracking table | TTD Patch tram set Latest version: 17.06.2015. | Open TTD Remix Latest version: 11.07.2015.
WIN-DOS GRF Converter Topic and download | Version 0.2.1: 09.01.2005.


Runner-up in "Best avatar Forums award" for years 2006 and 2010!

User avatar
Lakie
TTDPatch Developer
TTDPatch Developer
Posts: 1804
Joined: 26 May 2004 16:37
Location: Britain
Contact:

Re: Problems with coding refit cycle

Post by Lakie » 19 Jun 2008 15:53

Then simply returning 17 for the first instance and 34 for both would work, you need to remeber that like train articulated units it adds the cargo of the whole articulated consist, though this shouldn't be anything new to you.

As for the trams breaking up, I am aware that trams are by far more likely to breakup than plain articulated road vehicles, not sure what this is down too to be honest, although I do remember something about poor alignment causing more frequent breakups from previous testing a year or so ago with Steven (not sure how that works though). Also to cover all possibilities I recommend with shortened vehicles you do not go under 3/8's as I remember train consists explode under that value as well.

~ Lakie
TTDpatch Developer 2005 - 2010 ~ It all started because of shortened vehicle not loading correctly, now look where I've gone with it!
Grfs coded ~ Finnish Train Set (Teaser) | Bm73 (Release 3) | Emu 680 (Release 3)| Glass Station (Release 1) | UK Roadset (Version 1.1a) | New Water Coasts (Version 7)
Pikka: "Lakie's a good coder, but before he'll add any feature to TTDP you have to convince him that you're not going to use it to destroy the world as we know it."

User avatar
Wile E. Coyote
Tycoon
Tycoon
Posts: 8514
Joined: 08 Jul 2004 22:14
Skype: wile.e.coyote2
Location: Belgrade, Serbia
Contact:

Re: Problems with coding refit cycle

Post by Wile E. Coyote » 24 Jun 2008 09:01

Unfortunately, neither limiting vehicle shortening (I used 3/8 as shortest) haven't solved breaking problem. Strange thing is that first articulated vehicle (horse tram) is working properly, maybe because there was no shortening? I'll investigate further and inform you about what I obtained.

Thanx everybody for help! :bow:

EDIT: I investigated consist desintegration and spotted that shortening vehicle for minimum 3/8 causes breaking. 2/8 is working good. (Train vehicles are working good even with smaller length.) But this is not discussion under this topic, refitting is solved. :bow: So desintegrating we could discuss in original thread. This thread maybe could be locked?
Serbian rail set with Serbian scenario (ECS, PBI, FIRS and Tourist set compatible) Website | Topic and download | Latest version: 03.06.2015.
Serbian tram set Tracking table | TTD Patch tram set Latest version: 17.06.2015. | Open TTD Remix Latest version: 11.07.2015.
WIN-DOS GRF Converter Topic and download | Version 0.2.1: 09.01.2005.


Runner-up in "Best avatar Forums award" for years 2006 and 2010!

Locked

Return to “General TTDPatch”

Who is online

Users browsing this forum: No registered users and 4 guests