News:

Use the "Forum Search"
It may help you to find anything in the forum ;).

Question about vehikel_basis_t::fahre_basis and convoi_t::add_running_cost.

Started by inkelyad, August 03, 2011, 05:45:47 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

inkelyad

I have a question from my recent investigation about this bug

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.

Dwachs

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 :/
Parsley, sage, rosemary, and maggikraut.

inkelyad

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?

Dwachs

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.
Parsley, sage, rosemary, and maggikraut.

prissi

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.