diff --git a/descriptor/reader/vehicle_reader.cc b/descriptor/reader/vehicle_reader.cc index 5c57568909..33718c6992 100644 --- a/descriptor/reader/vehicle_reader.cc +++ b/descriptor/reader/vehicle_reader.cc @@ -513,6 +513,7 @@ obj_desc_t *vehicle_reader_t::read_node(FILE *fp, obj_node_info_t &node) desc->can_be_at_rear = (bool)decode_uint8(p); desc->basic_constraint_prev = vehicle_desc_t::unknown_constraint; desc->basic_constraint_next = vehicle_desc_t::unknown_constraint; + desc->mixed_load_prohibition = false; } desc->increase_maintenance_after_years = decode_uint16(p); desc->increase_maintenance_by_percent = decode_uint16(p); @@ -542,6 +543,14 @@ obj_desc_t *vehicle_reader_t::read_node(FILE *fp, obj_node_info_t &node) { desc->is_tall = false; } + if (extended && extended_version >= 5) + { + desc->mixed_load_prohibition = decode_uint8(p); + } + else + { + desc->mixed_load_prohibition = false; + } } else { @@ -668,6 +677,7 @@ obj_desc_t *vehicle_reader_t::read_node(FILE *fp, obj_node_info_t &node) desc->is_tall = false; desc->basic_constraint_prev = vehicle_desc_t::unknown_constraint; desc->basic_constraint_next = vehicle_desc_t::unknown_constraint; + desc->mixed_load_prohibition = false; } desc->set_way_constraints(way_constraints); diff --git a/descriptor/vehicle_desc.h b/descriptor/vehicle_desc.h index 48cad8e723..8e0e4b7442 100644 --- a/descriptor/vehicle_desc.h +++ b/descriptor/vehicle_desc.h @@ -226,6 +226,9 @@ class vehicle_desc_t : public obj_desc_transport_related_t { //@jamespetts January 2017 bool is_tall; + // if true, can not mix another goods in the same car. @Ranran, July 2019(v14.6) + bool mixed_load_prohibition; + // @author: Bernd Gabriel, Dec 12, 2009: called as last action in read_node() void loaded(); @@ -807,6 +810,7 @@ class vehicle_desc_t : public obj_desc_transport_related_t { uint32 get_way_wear_factor() const { return way_wear_factor; } bool get_is_tall() const { return is_tall; } + bool get_mixed_load_prohibition() const { return mixed_load_prohibition; } void set_scale(uint16 scale_factor, uint32 way_wear_factor_rail, uint32 way_wear_factor_road, uint16 standard_axle_load) { diff --git a/descriptor/writer/vehicle_writer.cc b/descriptor/writer/vehicle_writer.cc index 3db8bdbbb3..c908030b4b 100644 --- a/descriptor/writer/vehicle_writer.cc +++ b/descriptor/writer/vehicle_writer.cc @@ -82,7 +82,7 @@ void vehicle_writer_t::write_obj(FILE* fp, obj_node_t& parent, tabfileobj_t& obj int i; uint8 uv8; - int total_len = 86; + int total_len = 87; // prissi: must be done here, since it may affect the len of the header! string sound_str = ltrim( obj.get("sound") ); @@ -1092,6 +1092,10 @@ void vehicle_writer_t::write_obj(FILE* fp, obj_node_t& parent, tabfileobj_t& obj node.write_uint8(fp, is_tall, pos); pos += sizeof(is_tall); + uint8 mixed_load_prohibition = obj.get_int("mixed_load_prohibition", 0); + node.write_uint8(fp, mixed_load_prohibition, pos); + pos += sizeof(mixed_load_prohibition); + sint8 sound_str_len = sound_str.size(); if (sound_str_len > 0) { node.write_sint8 (fp, sound_str_len, pos); diff --git a/gui/components/gui_convoy_assembler.cc b/gui/components/gui_convoy_assembler.cc index 5a043340fc..2ceb8c463f 100644 --- a/gui/components/gui_convoy_assembler.cc +++ b/gui/components/gui_convoy_assembler.cc @@ -2360,6 +2360,11 @@ void gui_convoy_assembler_t::draw_vehicle_info_text(const scr_coord& pos) "\0", translator::translate(veh_type->get_freight_type()->get_mass()), translator::translate(veh_type->get_freight_type()->get_catg_name())); + if (veh_type->get_mixed_load_prohibition()) + { + buf.printf(" %s", translator::translate("(mixed_load_prohibition)")); + } + buf.append("\n"); display_proportional(pos.x + 335 + left, top, buf, ALIGN_LEFT, SYSCOL_TEXT, true); buf.clear(); top += LINESPACE; diff --git a/gui/convoi_detail_t.cc b/gui/convoi_detail_t.cc index bd0aca2906..d6a41fdb22 100644 --- a/gui/convoi_detail_t.cc +++ b/gui/convoi_detail_t.cc @@ -775,7 +775,6 @@ void gui_convoy_cargo_info_t::draw(scr_coord offset) goods_desc_t const* const wtyp = ware.get_desc(); cargo_sum += ware.menge; - buf.clear(); // draw the goods loading bar int bar_end_offset = cargo_sum * LOADING_BAR_WIDTH / v->get_desc()->get_total_capacity(); COLOR_VAL goods_color = wtyp->get_color(); @@ -787,6 +786,12 @@ void gui_convoy_cargo_info_t::draw(scr_coord offset) } bar_start_offset += bar_end_offset - bar_start_offset; } + if (v->get_desc()->get_mixed_load_prohibition()) { + extra_y += LINESPACE; + buf.clear(); + buf.printf("%s", translator::translate("(mixed_load_prohibition)")); + display_proportional_clip(pos.x + extra_w + offset.x, pos.y + offset.y + total_height + extra_y - (LINESPACE - LOADING_BAR_HEIGHT) / 2, buf, ALIGN_LEFT, SYSCOL_TEXT, true); + } extra_y += LINESPACE + 2; } diff --git a/simhalt.cc b/simhalt.cc index 64382b9404..1565750f38 100644 --- a/simhalt.cc +++ b/simhalt.cc @@ -2345,7 +2345,7 @@ bool haltestelle_t::recall_ware( ware_t& w, uint32 menge ) } -bool haltestelle_t::fetch_goods(slist_tpl &load, const goods_desc_t *good_category, sint32 requested_amount, const schedule_t *schedule, const player_t *player, convoi_t* cnv, bool overcrowded, const uint8 g_class, const bool use_lower_classes, bool& other_classes_available) +bool haltestelle_t::fetch_goods(slist_tpl &load, const goods_desc_t *good_category, sint32 requested_amount, const schedule_t *schedule, const player_t *player, convoi_t* cnv, bool overcrowded, const uint8 g_class, const bool use_lower_classes, bool& other_classes_available, const bool mixed_load_prohibition, uint8 goods_restriction) { bool skipped = false; const uint8 catg_index = good_category->get_catg_index(); @@ -2361,7 +2361,19 @@ bool haltestelle_t::fetch_goods(slist_tpl &load, const goods_desc_t *goo if(ware->menge > 0) { i++; - if (ware->get_class() >= g_class) + if (mixed_load_prohibition) { + // this vehicle only load with the same kind of goods initially loaded + if (!goods_restriction) { + goods_restriction = ware->get_index(); + } + if (ware->get_index() == goods_restriction) { + goods_to_check.insert(ware); + } + else { + other_classes_available = true; + } + } + else if (ware->get_class() >= g_class) { // We know at this stage that we cannot load passengers of a *lower* class into higher class accommodation, // but we cannot yet know whether or not to load passengers of a higher class into lower class accommodation. diff --git a/simhalt.h b/simhalt.h index f98f920e1e..8b4ecd1820 100644 --- a/simhalt.h +++ b/simhalt.h @@ -741,7 +741,7 @@ class haltestelle_t * @param player Company that's requesting the fetch. * @author Dwachs */ - bool fetch_goods( slist_tpl &load, const goods_desc_t *good_category, sint32 requested_amount, const schedule_t *schedule, const player_t *player, convoi_t* cnv, bool overcrowd, const uint8 g_class, const bool use_lower_classes, bool& other_classes_available); + bool fetch_goods( slist_tpl &load, const goods_desc_t *good_category, sint32 requested_amount, const schedule_t *schedule, const player_t *player, convoi_t* cnv, bool overcrowd, const uint8 g_class, const bool use_lower_classes, bool& other_classes_available, const bool mixed_load_prohibition, uint8 goods_restriction); /* liefert ware an. Falls die Ware zu wartender Ware dazugenommen * werden kann, kann ware_t gelöscht werden! D.h. man darf ware nach diff --git a/simversion.h b/simversion.h index 25de09c4a5..0019afc0ff 100644 --- a/simversion.h +++ b/simversion.h @@ -33,8 +33,8 @@ extern "C" FILE * __cdecl __iob_func(void) { return _iob; } // Do not forget to increment the save game versions in settings_stats.cc when changing this -#define MAKEOBJ_VERSION "60.05" -// Transparency and new factories(60.0), railcar_tab(60.01), basic constraint extension(60.05). NOTE: standard now 60.2 +#define MAKEOBJ_VERSION "60.06" +// Transparency and new factories(60.0), railcar_tab(60.01), basic constraint + mixed_load_prohibition(60.06). NOTE: standard now 60.2 #ifndef QUOTEME # define QUOTEME_(x) #x diff --git a/vehicle/simvehicle.cc b/vehicle/simvehicle.cc index a1a7c3ccae..645ec3188c 100644 --- a/vehicle/simvehicle.cc +++ b/vehicle/simvehicle.cc @@ -1075,6 +1075,7 @@ bool vehicle_t::load_freight_internal(halthandle_t halt, bool overcrowd, bool *s { const uint16 total_capacity = desc->get_total_capacity() + (overcrowd ? desc->get_overcrowded_capacity() : 0); bool other_classes_available = false; + uint8 goods_restriction = 0; if (total_freight < total_capacity) { schedule_t *schedule = cnv->get_schedule(); @@ -1085,7 +1086,13 @@ bool vehicle_t::load_freight_internal(halthandle_t halt, bool overcrowd, bool *s uint8 lowest_class_with_nonzero_capacity = 255; *skip_vehicles = true; - + if (!fracht[0].empty() && desc->get_mixed_load_prohibition()) { + FOR(slist_tpl, const& w, fracht[0]) + { + goods_restriction = w.index; + break; + } + } for (uint8 i = 0; i < number_of_classes; i++) { capacity_this_class = get_accommodation_capacity(i); @@ -1126,7 +1133,7 @@ bool vehicle_t::load_freight_internal(halthandle_t halt, bool overcrowd, bool *s // the need for higher class passengers/mail to use lower class accommodation. if (capacity_left_this_class >= 0) { - *skip_vehicles &= halt->fetch_goods(freight_add, desc->get_freight_type(), capacity_left_this_class, schedule, cnv->get_owner(), cnv, overcrowd, class_reassignments[i], use_lower_classes, other_classes_available); + *skip_vehicles &= halt->fetch_goods(freight_add, desc->get_freight_type(), capacity_left_this_class, schedule, cnv->get_owner(), cnv, overcrowd, class_reassignments[i], use_lower_classes, other_classes_available, desc->get_mixed_load_prohibition(), goods_restriction); if (!freight_add.empty()) { cnv->invalidate_weight_summary();