diff --git a/simconvoi.cc b/simconvoi.cc index 3ca4ab3a9..9c10033df 100644 --- a/simconvoi.cc +++ b/simconvoi.cc @@ -908,7 +908,10 @@ sync_result convoi_t::sync_step(uint32 delta_t) while(sp_soll>>12) { // Attempt to move one step. uint32 sp_hat = fahr[0]->do_drive(1<>4); + if( sp_hat>0 ) { + steps_driven++; + } + int v_nr = get_vehicle_at_length(steps_driven>>4); // stop when depot reached if (state==INITIAL) { return SYNC_REMOVE; @@ -916,12 +919,17 @@ sync_result convoi_t::sync_step(uint32 delta_t) if (state==ROUTING_1) { break; } - // until all are moving or something went wrong (sp_hat==0) - if(sp_hat==0 || v_nr==anz_vehikel) { + + if( v_nr==anz_vehikel ) { + // all are moving steps_driven = -1; state = DRIVING; return SYNC_OK; } + else if( sp_hat==0 ) { + // something went wrong. wait for next sync_step() + return SYNC_OK; + } // now only the right numbers for(int i=1; i<=v_nr; i++) { fahr[i]->do_drive(sp_hat);