Index: gui/halt_info.cc =================================================================== --- gui/halt_info.cc (revision 7535) +++ gui/halt_info.cc (working copy) @@ -373,7 +373,7 @@ delta_t += 819; // ( (1 << (8+12)) / kmh_to_speed(100) ); } // waiting at signal? - if( cnv->get_state() != convoi_t::DRIVING ) { + if( !cnv->is_driving() ) { // extra time for acceleration delta_t += kmh_average * 25; } @@ -422,7 +422,7 @@ FOR( vector_tpl, line, halt->registered_lines ) { for( uint j = 0; j < line->count_convoys(); j++ ) { convoihandle_t cnv = line->get_convoy(j); - if( cnv.is_bound() && ( cnv->get_state() == convoi_t::DRIVING || cnv->is_waiting() ) && haltestelle_t::get_halt( cnv->get_schedule()->get_current_eintrag().pos, cnv->get_owner() ) == halt ) { + if( cnv.is_bound() && ( cnv->is_driving() || cnv->is_waiting() ) && haltestelle_t::get_halt( cnv->get_schedule()->get_current_eintrag().pos, cnv->get_owner() ) == halt ) { halthandle_t prev_halt = haltestelle_t::get_halt( cnv->front()->last_stop_pos, cnv->get_owner() ); sint32 delta_t = cur_ticks + calc_ticks_until_arrival( cnv ); if( prev_halt.is_bound() ) { @@ -447,7 +447,7 @@ } FOR( vector_tpl, cnv, halt->registered_convoys ) { - if( cnv.is_bound() && ( cnv->get_state() == convoi_t::DRIVING || cnv->is_waiting() ) && haltestelle_t::get_halt( cnv->get_schedule()->get_current_eintrag().pos, cnv->get_owner() ) == halt ) { + if( cnv.is_bound() && ( cnv->is_driving() || cnv->is_waiting() ) && haltestelle_t::get_halt( cnv->get_schedule()->get_current_eintrag().pos, cnv->get_owner() ) == halt ) { halthandle_t prev_halt = haltestelle_t::get_halt( cnv->front()->last_stop_pos, cnv->get_owner() ); sint32 delta_t = cur_ticks + calc_ticks_until_arrival( cnv ); if( prev_halt.is_bound() ) { Index: simconvoi.cc =================================================================== --- simconvoi.cc (revision 7535) +++ simconvoi.cc (working copy) @@ -86,7 +86,8 @@ "WAITING_FOR_CLEARANCE_TWO_MONTHS", "CAN_START_TWO_MONTHS", "LEAVING_DEPOT", - "ENTERING_DEPOT" + "ENTERING_DEPOT", + "DRIVING_TO_CHOOSE" }; @@ -270,7 +271,7 @@ */ void convoi_t::reserve_route() { - if( !route.empty() && anz_vehikel>0 && (is_waiting() || state==DRIVING || state==LEAVING_DEPOT) ) { + if( !route.empty() && anz_vehikel>0 && (is_waiting() || is_driving() || state==LEAVING_DEPOT) ) { for( int idx = back()->get_route_index(); idx < next_reservation_index /*&& idx < route.get_count()*/; idx++ ) { if( grund_t *gr = welt->lookup( route.position_bei(idx) ) ) { if( schiene_t *sch = (schiene_t *)gr->get_weg( front()->get_waytype() ) ) { @@ -390,7 +391,7 @@ // wrong alignment here => must relocate if(v->need_realignment()) { // diagonal => convoi must restart - realing_position |= ribi_t::ist_kurve(v->get_direction()) && (state==DRIVING || is_waiting()); + realing_position |= ribi_t::ist_kurve(v->get_direction()) && (is_driving() || is_waiting()); } // if version is 99.17 or lower, some convois are broken, i.e. had too large gaps between vehicles if( !realing_position && state!=INITIAL && state!=LEAVING_DEPOT ) { @@ -512,7 +513,7 @@ // remove wrong freight check_freight(); // some convois had wrong old direction in them - if( state?? alte_richtung = fahr[0]->get_direction(); } // Knightly : if lineless convoy -> register itself with stops @@ -938,6 +939,7 @@ break; // LEAVING_DEPOT case DRIVING: + case DRIVING_TO_CHOOSE: { calc_acceleration(delta_t); @@ -1281,6 +1283,23 @@ } break; + case DRIVING_TO_CHOOSE: + { + front()->set_target_halt( welt->lookup(get_route()->back())->get_halt() ); + + route_t target_rt; + const int richtung = ribi_typ(front()->get_pos(), front()->get_pos_next()); // to avoid confusion at diagonals + if( target_rt.find_route( welt, get_route()->position_bei(next_stop_index-1), front(), speed_to_kmh(get_min_top_speed()), richtung, MAX_CHOOSE_BLOCK_TILES ) ) { + access_route()->remove_koord_from(next_stop_index-1); + access_route()->append( &target_rt ); + set_driving(); + } + else { + front()->set_target_halt( halthandle_t() ); + } + } + break; + case WAITING_FOR_CLEARANCE_ONE_MONTH: case WAITING_FOR_CLEARANCE_TWO_MONTHS: case WAITING_FOR_CLEARANCE: @@ -1319,6 +1338,7 @@ case LEAVING_DEPOT: case ENTERING_DEPOT: case DRIVING: + case DRIVING_TO_CHOOSE: case DUMMY4: case DUMMY5: wait_lock = 0; Index: simconvoi.h =================================================================== --- simconvoi.h (revision 7535) +++ simconvoi.h (working copy) @@ -74,6 +74,7 @@ CAN_START_TWO_MONTHS, LEAVING_DEPOT, ENTERING_DEPOT, + DRIVING_TO_CHOOSE, MAX_STATES }; @@ -459,6 +460,10 @@ */ void reset_waiting() { state=WAITING_FOR_CLEARANCE; } + bool is_driving() const { return (state == DRIVING || state == DRIVING_TO_CHOOSE); } + void set_driving() { state = DRIVING; } + void set_driving_to_choose() { state = DRIVING_TO_CHOOSE; } + /** * The handle for ourselves. In Anlehnung an 'this' aber mit * allen checks beim Zugriff. Index: vehicle/simvehicle.cc =================================================================== --- vehicle/simvehicle.cc (revision 7535) +++ vehicle/simvehicle.cc (working copy) @@ -1743,6 +1743,7 @@ break; case convoi_t::DRIVING: + case convoi_t::DRIVING_TO_CHOOSE: if( state>=1 ) { grund_t const* const gr = welt->lookup(cnv->get_route()->back()); if( gr && gr->get_depot() ) { @@ -2409,7 +2410,7 @@ // set default next stop index c->set_next_stop_index( max(route_index,1)-1 ); // need to reserve new route? - if( !check_for_finish && c->get_state()!=convoi_t::SELF_DESTRUCT && (c->get_state()==convoi_t::DRIVING || c->get_state()>=convoi_t::LEAVING_DEPOT) ) { + if( !check_for_finish && c->get_state()!=convoi_t::SELF_DESTRUCT && (c->is_driving() || c->get_state()>=convoi_t::LEAVING_DEPOT) ) { sint32 num_index = cnv==(convoi_t *)1 ? 1001 : 0; // only during loadtype: cnv==1 indicates, that the convoi did reserve a stop uint16 next_signal, next_crossing; cnv = c; @@ -2473,10 +2474,10 @@ } } - if( target_halt.is_bound() && cnv->is_waiting() ) { + if( target_halt.is_bound() && (cnv->is_waiting() || cnv->get_state() == convoi_t::DRIVING_TO_CHOOSE) ) { // we are searching a stop here: // ok, we can go where we already are ... - if(bd->get_pos()==get_pos()) { + if(bd->get_pos()==get_pos()) { // needed for driving_to_choose??? return true; } // we cannot pass an end of choose area @@ -2720,6 +2721,7 @@ if(!cnv->is_waiting()) { restart_speed = -1; target_halt = halthandle_t(); + cnv->set_driving_to_choose(); return false; } // now we are in a step and can use the route search array @@ -2727,11 +2729,8 @@ // now it we are in a step and can use the route search route_t target_rt; const int richtung = ribi_typ(get_pos(), pos_next); // to avoid confusion at diagonals -#ifdef MAX_CHOOSE_BLOCK_TILES + if( !target_rt.find_route( welt, cnv->get_route()->position_bei(start_block), this, speed_to_kmh(cnv->get_min_top_speed()), richtung, MAX_CHOOSE_BLOCK_TILES ) ) { -#else - if( !target_rt.find_route( welt, cnv->get_route()->position_bei(start_block), this, speed_to_kmh(cnv->get_min_top_speed()), richtung, welt->get_size().x+welt->get_size().y ) ) { -#endif // nothing empty or not route with less than MAX_CHOOSE_BLOCK_TILES tiles target_halt = halthandle_t(); sig->set_zustand( roadsign_t::rot ); @@ -2754,6 +2753,7 @@ } sig->set_zustand( roadsign_t::gruen ); cnv->set_next_stop_index( min( next_crossing, next_signal ) ); + cnv->set_driving(); return true; } Index: vehicle/simvehicle.h =================================================================== --- vehicle/simvehicle.h (revision 7535) +++ vehicle/simvehicle.h (working copy) @@ -253,6 +253,7 @@ virtual void rotate90(); + void set_target_halt( halthandle_t halt ) { target_halt = halt; } /** * Method checks whether next tile is free to move on.