Ok results for testing proposed procedure change.
After exhaustive testing and changing I come to the following end result:
Initial profiling showed that my new procedure was +/-3% slower than the old

I tried to shave off as much as possible unnecessary instructions. (still bit more possible but would make code ugly)
Below you can find the final result.
In zip file profiling is included in exl format + test game + tictoc code.
I found out that because of delaying the wormhole condition, the trains in tunnels were continuing to pass
section 1 (see previous discussion) for a longer time (till the end).
Ratio between visible and non visible = 7 : 3 or in old code, NOT TRACK_BIT_WORMHOLE || TRACK_BIT_WORMHOLE
This means that vehicles in tunnels were passing the last part of the train controller more often.
I included in section 1 the following code to simulate tunnel wormhole line 3078 in train_cmd.cpp.
This was done for proof of concept only.
Code: Select all
uint32 r = VehicleEnterTile(v, gp.new_tile, gp.x, gp.y);
if (HasBit(r, VETS_CANNOT_ENTER)) {
goto invalid_rail;
}
if (v->vehstatus & VS_HIDDEN) { // in tunnel
v->x_pos = gp.x;
v->y_pos = gp.y;
VehicleUpdatePosition(v);
continue;
}
if (HasBit(r, VETS_ENTERED_STATION)) {
All of a sudden my code was running as fast or even a bit faster than the existing code.
(see worksheet in zip file for details).
This proves that speed of my code is ok.

Testing was done on game with only tunnels and bridges. (see test game in zip file below)
So in reality the impact of speed loss (if procedure would be introduced) will be significantly lower.
It depends on the amount of tunnels constructed.
Coming back to the z == 0 issue.
I managed to get the earliest code of ottd release 0.1
already there that line exists. (??leftover??)
I have been investigating and the only place were z is 1 is when vehicle is climbing onto ramp
since that line is only significant when vehicle is near the middle of the tile z is 'ALWAYS' 0
so I eliminated the line.
Disclaimer: all testing was done with trains.