I have a question from my recent investigation about this bug (http://forum.simutrans.com/index.php?topic=7735.0)
Why convoi_t::add_running_cost() is called every hop, but not at the end of vehikel_basis_t::fahre_basis?
Walk over all vehicles in convoy several times should hurt game speed.
Quote from: inkelyad on August 03, 2011, 05:45:47 PM
Why convoi_t::add_running_cost() is called every hop, but not at the end of vehikel_basis_t::fahre_basis?
hop() is called when a vehicle changes its position from one tile to the next. convoi_t::add_running_cost() is only called for the first vehicle of a convoi.
Quote
Walk over all vehicles in convoy several times should hurt game speed.
Thats true, but I do not see the possibility for an improvement here :/
For slow vehicles:
hop() is called only in some calls of vehikel_basis_t::fahre_basis. All good.
But for fast vehicles it is called several times.
Maybe (pseudo-code)
int hop_counter = 0;
while(steps_target>steps_next && hop_check()) {
..
hop_counter +=1;
..
}
if (hop_counter) {
hop(hop_counter)
}
will be better?
Quote from: inkelyad on August 03, 2011, 06:28:01 PM
Maybe (pseudo-code)
int hop_counter = 0;
while(steps_target>steps_next && hop_check()) {
..
hop_counter +=1;
..
}
if (hop_counter) {
hop(hop_counter)
}
will be better?
I do not know. At least updating the position and direction has to be done immediately as hop_check() and ist_weg_frei() rely on this afaik.
ist_weg_frei is more expensive for everything but ships and airplanes. And that needs to be done every hop before entering the next tile. On the other hand this is only done for the first vehicle in a convoi.