Skip to content

Commit

Permalink
ADD: constrait[prev][0]=any require a vehile in front (and same for […
Browse files Browse the repository at this point in the history
…next] to require a trailing vehicle)

git-svn-id: svn://tron.homeunix.org/simutrans/simutrans/trunk@8726 8aca7d54-2c30-db11-9de9-000461428c89
  • Loading branch information
prissi committed Mar 21, 2019
1 parent 2592752 commit 62957fb
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
7 changes: 7 additions & 0 deletions descriptor/reader/obj_reader.cc
Expand Up @@ -26,6 +26,7 @@

#include "../obj_desc.h"
#include "../obj_node_info.h"
#include "../vehicle_desc.h"

#include "obj_reader.h"

Expand All @@ -50,6 +51,12 @@ void obj_reader_t::register_reader()
*/
bool obj_reader_t::finish_loading()
{
// vehicle to follow to mark something cannot lead a convoi (prev[0]=any) or cannot end a convoi (next[0]=any)
vehicle_desc_t::any_vehicle = new vehicle_desc_t(ignore_wt, 1, vehicle_desc_t::unknown);

// first we add the any_vehicle to xrefs
obj_for_xref( obj_vehicle, "any", vehicle_desc_t::any_vehicle );

resolve_xrefs();

FOR(obj_map, const& i, *obj_reader) {
Expand Down
5 changes: 5 additions & 0 deletions descriptor/vehicle_desc.cc
Expand Up @@ -2,6 +2,10 @@
#include "xref_desc.h"
#include "../network/checksum.h"


vehicle_desc_t *vehicle_desc_t::any_vehicle = NULL;


void vehicle_desc_t::calc_checksum(checksum_t *chk) const
{
obj_desc_transport_related_t::calc_checksum(chk);
Expand All @@ -25,3 +29,4 @@ void vehicle_desc_t::calc_checksum(checksum_t *chk) const
chk->input(xref ? xref->get_name() : "NULL");
}
}

15 changes: 13 additions & 2 deletions descriptor/vehicle_desc.h
Expand Up @@ -86,6 +86,9 @@ class vehicle_desc_t : public obj_desc_transport_related_t {


public:
// dummy vehicle for the XREF reader
static vehicle_desc_t *any_vehicle;

// since we have a second constructor
vehicle_desc_t() { }

Expand Down Expand Up @@ -208,7 +211,11 @@ class vehicle_desc_t : public obj_desc_transport_related_t {
}
for( uint8 i=0; i<trailer_count; i++ ) {
vehicle_desc_t const* const veh = get_child<vehicle_desc_t>(6 + leader_count + i);
if(veh==next_veh) {
if( veh==next_veh ) {
return true;
}
// not leading and "any" => we can follow
if( next_veh!=NULL && veh==vehicle_desc_t::any_vehicle ) {
return true;
}
}
Expand All @@ -226,7 +233,11 @@ class vehicle_desc_t : public obj_desc_transport_related_t {
}
for( uint8 i=0; i<leader_count; i++ ) {
vehicle_desc_t const* const veh = get_child<vehicle_desc_t>(6 + i);
if(veh==prev_veh) {
if( veh==prev_veh ) {
return true;
}
// not leading and "any" => we can follow
if( prev_veh!=NULL && veh==vehicle_desc_t::any_vehicle ) {
return true;
}
}
Expand Down
1 change: 1 addition & 0 deletions simutrans/history.txt
Expand Up @@ -10,6 +10,7 @@
FIX: (ACarlotti) rotation of traffic light phases and overflow was broken for years
FIX: fields now check for allowed climate, not same height
ADD: (HyperSim inspired) new tool for merging distance stations (and lot of code cleanup of old merging tool)
ADD: constrait[prev][0]=any require a vehile in front (and same for [next] to require a trailing vehicle)


Release of 120.4.1 (r8600 on 23-Sep-2018):
Expand Down

0 comments on commit 62957fb

Please sign in to comment.