@@ -1866,13 +1866,13 @@ void stadt_t::step_passagiere()
18661866 }
18671867
18681868 // track number of generated passengers.
1869- city_history_year[0 ][history_type + HIST_OFFSET_GENERATED] += num_pax;
1869+ city_history_year [0 ][history_type + HIST_OFFSET_GENERATED] += num_pax;
18701870 city_history_month[0 ][history_type + HIST_OFFSET_GENERATED] += num_pax;
18711871
18721872 // only continue, if this is a good start halt
18731873 if ( !start_halts.empty () ) {
18741874 // Find passenger destination
1875- for ( uint pax_routed=0 , pax_left_to_do=0 ; pax_routed < num_pax; pax_routed += pax_left_to_do ) {
1875+ for ( uint32 pax_routed=0 , pax_left_to_do=0 ; pax_routed < num_pax; pax_routed += pax_left_to_do ) {
18761876 // number of passengers that want to travel
18771877 // for efficiency we try to route not every single pax, but packets.
18781878 // If possible, we do 7 passengers at a time
@@ -1883,7 +1883,9 @@ void stadt_t::step_passagiere()
18831883 pax_return_type will_return;
18841884 factory_entry_t *factory_entry = NULL ;
18851885 stadt_t *dest_city = NULL ;
1886+
18861887 const koord dest_pos = find_destination (target_factories, city_history_month[0 ][history_type + HIST_OFFSET_GENERATED], &will_return, factory_entry, dest_city);
1888+
18871889 if ( factory_entry ) {
18881890 if (welt->get_settings ().get_factory_enforce_demand ()) {
18891891 // ensure no more than remaining amount
@@ -1905,6 +1907,7 @@ void stadt_t::step_passagiere()
19051907 // now, finally search a route; this consumes most of the time
19061908 int const route_result = haltestelle_t::search_route ( &start_halts[0 ], start_halts.get_count (), welt->get_settings ().is_no_routing_over_overcrowding (), pax, &return_pax);
19071909 halthandle_t start_halt = return_pax.get_target_halt ();
1910+
19081911 if ( route_result==haltestelle_t ::ROUTE_OK ) {
19091912 // so we have happy traveling passengers
19101913 start_halt->starte_mit_route (pax);
@@ -1941,8 +1944,8 @@ void stadt_t::step_passagiere()
19411944 }
19421945 else {
19431946 // all routes to goal are overcrowded -> register at first stop (closest)
1944- for ( halthandle_t const s : start_halts) {
1945- s ->add_pax_unhappy (pax_left_to_do);
1947+ if (! start_halts. empty () ) {
1948+ start_halts[ 0 ] ->add_pax_unhappy (pax_left_to_do);
19461949 break ;
19471950 }
19481951 }
@@ -1952,9 +1955,8 @@ void stadt_t::step_passagiere()
19521955 }
19531956 else if ( route_result == haltestelle_t ::NO_ROUTE ) {
19541957 // since there is no route from any start halt -> register no route at first halts (closest)
1955- for (halthandle_t const s : start_halts) {
1956- s->add_pax_no_route (pax_left_to_do);
1957- break ;
1958+ if (!start_halts.empty ()) {
1959+ start_halts[0 ]->add_pax_no_route (pax_left_to_do);
19581960 }
19591961 merke_passagier_ziel (dest_pos, PAX_DEST_STATUS_NO_ROUTE);
19601962#ifdef DESTINATION_CITYCARS
@@ -2065,14 +2067,14 @@ void stadt_t::step_passagiere()
20652067 }
20662068 else {
20672069 // assume no free stop to start at all
2068- bool is_there_any_stop = false ;
2070+ halthandle_t src_halt ;
20692071
20702072 // the unhappy passengers will be added to the first stop if any
20712073 for ( uint h=0 ; h<plan->get_haltlist_count (); h++ ) {
20722074 halthandle_t halt = plan->get_haltlist ()[h];
20732075 if ( halt->is_enabled (wtyp) ) {
20742076 halt->add_pax_unhappy (num_pax);
2075- is_there_any_stop = true ; // only overcrowded
2077+ src_halt = halt ; // only overcrowded
20762078 break ;
20772079 }
20782080 }
@@ -2083,6 +2085,7 @@ void stadt_t::step_passagiere()
20832085 factory_entry_t *factory_entry = NULL ;
20842086 stadt_t *dest_city = NULL ;
20852087 const koord ziel = find_destination (target_factories, city_history_month[0 ][history_type + HIST_OFFSET_GENERATED], &will_return, factory_entry, dest_city);
2088+
20862089 if ( factory_entry ) {
20872090 // consider at most 1 packet's amount as factory-going
20882091 sint32 amount = min (PACKET_SIZE, num_pax);
@@ -2119,16 +2122,23 @@ void stadt_t::step_passagiere()
21192122 // passengers with no route will be added to the first stops near destination (might be none)
21202123 const planquadrat_t *const dest_plan = welt->access (ziel);
21212124 const halthandle_t *const dest_halt_list = dest_plan->get_haltlist ();
2125+
21222126 for (uint h = 0 ; h < dest_plan->get_haltlist_count (); h++) {
2123- halthandle_t halt = dest_halt_list[h];
2124- if ( halt->is_enabled (wtyp) ) {
2125- if ( is_there_any_stop ) {
2126- // "just" overcrowded
2127- halt->add_pax_unhappy (pax_return);
2127+ halthandle_t dst_halt = dest_halt_list[h];
2128+ if ( dst_halt->is_enabled (wtyp) ) {
2129+
2130+ // Check if the two networks are actually connected.
2131+ // If we have 2 networks:
2132+ // [N1] with halts A,B (both overcrowded)
2133+ // [N2] with halts C,D (none overcrowded)
2134+ // and a route is calculated from A to D,
2135+ // the return pax (from D to A) must not be logged as unhappy
2136+ // because no halts in N2 are overcrowded.
2137+ if ( src_halt.is_bound () && dst_halt->is_connected (src_halt, wtyp->get_catg_index ())==1 ) {
2138+ dst_halt->add_pax_unhappy (pax_return); // "just" overcrowded
21282139 }
21292140 else {
2130- // no stops at all
2131- halt->add_pax_no_route (pax_return);
2141+ dst_halt->add_pax_no_route (pax_return); // no connection at all
21322142 }
21332143 break ;
21342144 }
0 commit comments