Page 1 of 2
Variable F2 for lead locomotive
Posted: 30 May 2007 12:52
by PikkaBird
We just had this convo in IRC, but I'm noting it here so it doesn't get forgotten.
Currently, when refitting a train, variable F2 of the lead locomotive gets set even if it was not refitted. This may or may not be the desired behaviour:
If it's not, can it be changed so the locomotive only gets var F2 set if it is actually refitted?
If it is, can an action D variable 9E bit be used to effect the change as above?
(also, I can't decide what the past participle of "refit" is, half the time I want to use "refit" and half "refitted"

)
Posted: 06 Jun 2007 00:25
by DaleStan
I hope you mean "variable", not "property"?
I believe the desired effect is to reset F2 to 0, possibly with some exceptions for a recently sold locomotive in the same depot.
Posted: 06 Jun 2007 01:10
by Dave
refit
• verb (refitted, refitting) replace or repair machinery, equipment, and fittings in (a ship, building, etc.).
• noun an act of refitting.
^ Oxford English seems to think refitted is allowed, so...
Posted: 06 Jun 2007 03:05
by OzTrans
PikkaBird wrote: ... can it be changed so the locomotive only gets prop F2 set if it is actually refitted? ...
What about livery refitting of locos without cargo; if I refit a train to livery A, I may also like to show livery A for the loco. That is where I use variable F2; if F2 of the loco is 0 then I won't know what livery the wagons display.
Posted: 06 Jun 2007 04:43
by PikkaBird
OzTransLtd wrote:PikkaBird wrote: ... can it be changed so the locomotive only gets prop F2 set if it is actually refitted? ...
What about livery refitting of locos without cargo; if I refit a train to livery A, I may also like to show livery A for the loco. That is where I use variable F2; if F2 of the loco is 0 then I won't know what livery the wagons display.
One possibility is you can set prop 25 of the wagons using callback 36, and the loco can test for that with var 42. Or you can just check ii of var 42.
I am aware that people were using F2 to make matching locos; that's why I originally suggested the action D variable, so that both behaviours are possible.
Posted: 06 Jun 2007 07:12
by PikkaBird
DaleStan wrote:I hope you mean "variable", not "property"?
I believe the desired effect is to reset F2 to 0, possibly with some exceptions for a recently sold locomotive in the same depot.
Yes, I mean variable, sorry. Edited.
Reset F2 to 0 when? My desired effect is that F2 for the lead loco is the same as for any other vehicle; it is set when the vehicle is refitted, and not altered at any other time.
I suppose one possible solution would be that F2 for the lead loco is set when refitting any other wagon iff the lead loco has no cargo capacity. This would allow for matching non-cargo-carrying locomotives with their coaches, and also allow for explicit refitting of cargo-carrying locos. Or is this getting too complicated?
Posted: 06 Jun 2007 17:01
by DaleStan
Oh. For some reason I inserted an "on purchase" in your message; that is the other time that it is necessary to ensure that F2 is set properly.
I'm not sure how useful it would be to copy F2 from on of the other carriages. Especially when the carriages have different values for F2.
Posted: 06 Jun 2007 17:22
by PikkaBird
DaleStan wrote:I'm not sure how useful it would be to copy F2 from on of the other carriages.
Um, I'm not sure that's what anyone is suggesting. Also, that's basically what happens now, and what I'm asking to be changed.
Okay, here's a quick recap.
The situation at the moment
Refitting any vehicle in the train also sets var F2 for the lead locomotive. So if, for example, you refit five wagons in the train to the second refit cycle, they get an F2 value of 02. But so does the lead locomotive, regardless of what that locomotive carries, and even if it doesn't carry anything.
The problem
Locomotives may be explicitly refittable, and have livery refits of their own. Refitting any other vehicle in the train incorrectly alters the refit cycle of the lead locomotive.
The (proposed) solution
Refitting any other vehicle should not affect the var F2 of the lead locomotive. People who want non-cargo-carrying locos to match their livery refittable coaches can use ii of var 42 to get much the same effect.
Posted: 06 Jun 2007 23:19
by OzTrans
PikkaBird wrote: ... One possibility is you can set prop 25 of the wagons using callback 36, and the loco can test for that with var 42. Or you can just check ii of var 42. ...
Yes, we could use property 25 and uu of var 42 in conjunction with CB36. Unfortunately, these 8 bits are just not numerous enough. To really be able to use property 25 (User-defined bit mask) extensively, we need :
a) a new 2X vehicle property, i.e. a copy (in addition to) of prop 25, but at least a double-word.
b) a new veh var 4X (a train wide variable and accessible from every vehicle in the train), i.e. a copy (in addition to) of uu of var 42, but also at least a double word.
Posted: 07 Jun 2007 04:42
by PikkaBird
OzTransLtd wrote:Yes, we could use property 25 and uu of var 42 in conjunction with CB36. Unfortunately, these 8 bits are just not numerous enough.
Aren't 256 possible values enough, or are you using prop 25 extensively for other things too? And what about (and I'm just talking about a replacement for F2-of-the-lead-loco-here, mind) checking ii of var 42, won't that do the trick?
Posted: 07 Jun 2007 07:29
by michael blunck
PikkaBird wrote:Refitting any vehicle in the train also sets var F2 for the lead locomotive.
Are you possibly using "82" instead of "81" in checking var F2? If not, that´s a bug and should be reported.
Aren't 256 possible values enough
ORing prop25 bits from all vehicles in the train usually don´t give 256 values but rather 8. Nevertheless, demanding 32 bits is a little over the top, IMO. I´ve built a sophisticated system based on prop25 including engine repainting and push-pull service control for all DB Set coach classes and 8 bit are really sufficient.
or are you using prop 25 extensively for other things too[?]
For cargo-specific problems, those other bits of var42 should be used, indeed.
regards
Michael
Posted: 07 Jun 2007 07:39
by PikkaBird
michael blunck wrote:PikkaBird wrote:Refitting any vehicle in the train also sets var F2 for the lead locomotive.
Are you possibly using "82" instead of "81" in checking var F2?
Not at all, and I have discussed this with patchman. The problem is it's a "feature", not a "bug".
Give me a minute, I'll cook up a test grf so you can see exactly what I mean.
Posted: 07 Jun 2007 07:50
by michael blunck
> I'll cook up a test grf so you can see [...]
Well, I believe you. If Josef says it´s a "feature" it may well be a "bug".
regards
Michael
Posted: 07 Jun 2007 07:56
by PikkaBird
michael blunck wrote:Well, I believe you. If Josef says it´s a "feature" it may well be a "bug".
Well, the problem is not that patchman is unwilling to fix it. It's that some people (eg, OzTrans) have been using it as it is now.
Okay, here we go.
Slide 1 - new train bought, all refit cycles at 0. (F2 = 0)
Slide 2 - I refit the locomotives (passengers) to cycle 2.
Slide 3 - I refit the wagons (coal) to cycle 3. But oops, the lead loco changes too.
Here is the complete nfo if anyone wants to try this out for themselves.
Code: Select all
// Automatically generated by GRFCODEC. Do not modify!
// (Info version 7)
// Format: spritenum pcxfile xpos ypos compression ysize xsize xrel yrel
0 * 4 11 00 00 00
1 * 24 08 07 44 44 44 44 "Cargo Refit Test" 00 00
2 * 15 04 00 FF 01 A0 D0 " Refit 0" 00
3 * 15 04 00 FF 01 A1 D0 " Refit 1" 00
4 * 15 04 00 FF 01 A2 D0 " Refit 2" 00
5 * 15 04 00 FF 01 A3 D0 " Refit 3" 00
6 * 4 01 00 01 00
7 * 9 02 00 AA 01 01 00 00 00 00 // dummy graphic
// LOCO ID 00 =======================
8 * 26 02 00 20 81 F2 00 FF 04 // texts
A0 80 00 00
A1 80 01 01
A2 80 02 02
A3 80 03 03
FF FF
9 * 14 02 00 AA 81 0C 00 FF 01 20 00 19 19 AA 00
10 * 7 03 00 01 00 00 AA 00
11 * 21 04 00 7F 01 00 "Test Locomotive" 00
12 * 21 00 00 06 01 00 00 00 00 06 07 14 10 15 00 1E 20 1D 01 00 00 00
// WAGON ID 20 =======================
13 * 26 02 00 20 81 F2 00 FF 04 // texts
A0 80 00 00
A1 80 01 01
A2 80 02 02
A3 80 03 03
FF FF
14 * 14 02 00 AA 81 0C 00 FF 01 20 00 19 19 AA 00
15 * 7 03 00 01 20 00 AA 00
16 * 16 04 00 7F 01 20 "Test Wagon" 00
17 * 21 00 00 06 01 20 00 00 00 06 07 14 10 15 01 1E 20 1D 02 00 00 00
Posted: 08 Jun 2007 02:11
by OzTrans
PikkaBird wrote: ... (and I'm just talking about a replacement for F2-of-the-lead-loco-here, mind) ...
I am aware, you are just talking about var F2; but I wanted to make merely a suggestion about prop 25/var 42uu. But why, don't you use prop 25 ... ? Or, use global variable 9E, that is limited to the set it is set in. OTOH, the change you are proposing will upset many already existing sets.
PikkaBird wrote: ... Slide 3 - I refit the wagons (coal) to cycle 3. But oops, the lead loco changes too.
What about refitting the loco(s) last, i.e. after the wagon refit ?
Posted: 08 Jun 2007 03:06
by DaleStan
OzTransLtd wrote:OTOH, the change you are proposing will upset many already existing sets.
As far as I'm concerned, if you're relying on behaviour that isn't documented, it's your fault when it breaks. Especially if the new behaviour obeys either the documentation or the Principle of Least Surprise better than the undocumented behaviour.
Posted: 08 Jun 2007 08:29
by PikkaBird
OzTransLtd wrote:OTOH, the change you are proposing will upset many already existing sets.
As far as I'm aware, all the sets that use this use it merely for graphical representations; that is, while the change will affect the set, it won't affect gameplay at all.
Also, it's a fairly easy fix. As I've said already, I believe changing the F2 check to a check of ii of var 42 should give you much the same result.
OzTransLtd wrote:What about refitting the loco(s) last, i.e. after the wagon refit ?
Of course, and that is what I am forced to do at the moment. However, it's a pain, and will doubtless bemuse casual players, to remember to refit the locomotives after doing any other refitting in the consist.
Posted: 10 Jun 2007 00:51
by OzTrans
I've had a closer look at that test .grf. I believe we had our wires crossed a bit; the problem you have described is actually a bug and not a feature. The loco should not refit when wagons are refitted, because it cannot carry coal. The same goes for the wagons, they cannot carry passengers.
I expanded your test .grf a little bit; i.e. I added real sprites (OpenTTD does not show cargo sub-types in train window), then tested it with TTDPatch 2.5 beta 9 and OpenTTD nightly r9976. It's always good to have more than one application to test things with. I did the following :
a) bought train, 2 locos and 4 wagons
b) refitted to passengers L1 (locos)
c) refitted to coal W2 (wagons)
Here is the result :
TTDPatch : bug, loco 1 should not show L2
OpenTTD : everything works just fine.
Attached, the screenies, blue TTDPatch and yellow OpenTTD, plus the .grf if you are interested what I have done.
I suggest, you lodge a nice bug report and then prey it is going to be fixed.
Posted: 10 Jun 2007 01:12
by PikkaBird
OzTransLtd wrote:I've had a closer look at that test .grf. I believe we had our wires crossed a bit; the problem you have described is actually a bug and not a feature.
I don't think we had our wires crossed at all.. but still, this is good enough for me.

Re: Variable F2 for lead locomotive
Posted: 25 Apr 2008 05:05
by PikkaBird
*nudge*
Any movement on this one? It would be nice to have it fixed.
