Skip to content

Commit

Permalink
CHG: tram system type way can be laid over other tracks as well (like…
Browse files Browse the repository at this point in the history
… pak192 narrowgauge over normal rails)

git-svn-id: svn://tron.homeunix.org/simutrans/simutrans/trunk@11607 8aca7d54-2c30-db11-9de9-000461428c89
  • Loading branch information
prissi committed Jan 19, 2025
1 parent 1abd90b commit 55ad759
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
1 change: 1 addition & 0 deletions simutrans/history.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
CHG: option for pakset dump versus all other debug by appending 'p' to the debug level, e.g. "-debug 0p" to show only pak details
CHG: tram system type way can be laid over other tracks as well (like pak192 narrowgauge over normal rails)

Release of 124.3 (r11590 on 10-Jan-2025):
FIX: open schedule get applied during rw (reload, quit, change language), line window crashes
Expand Down
32 changes: 29 additions & 3 deletions src/simutrans/vehicle/rail_vehicle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -745,9 +745,18 @@ bool rail_vehicle_t::block_reserver(const route_t *route, route_t::index_t start
count --;
next_signal_index = i;
}
if( !sch1->reserve( cnv->self, ribi_type( route->at(max(1u,i)-1u), route->at(min(route->get_count()-1u,i+1u)) ) ) ) {
if (!sch1->reserve(cnv->self, ribi_type(route->at(max(1u, i) - 1u), route->at(min(route->get_count() - 1u, i + 1u))))) {
success = false;
}
if (gr->has_two_ways()) {
// we may need to reserve the other way as well
if (schiene_t* sch0 = dynamic_cast<schiene_t*>(gr->get_weg_nr(gr->get_weg_nr(0) == sch1))) {
// the other way is reservable too => try to reserve it
if (!sch0->reserve(cnv->self, ribi_type(route->at(max(1u, i) - 1u), route->at(min(route->get_count() - 1u, i + 1u))))) {
success = false;
}
}
}
if(next_crossing_index==route_t::INVALID_INDEX && gr->get_crossing()) {
next_crossing_index = i;
}
Expand Down Expand Up @@ -786,8 +795,18 @@ bool rail_vehicle_t::block_reserver(const route_t *route, route_t::index_t start
if(!success) {
// free reservation
for ( route_t::index_t j=start_index; j<i; j++) {
schiene_t * sch1 = (schiene_t *)welt->lookup( route->at(j))->get_weg(get_waytype());
sch1->unreserve(cnv->self);
if (grund_t * gr=welt->lookup(route->at(j))) {
schiene_t* sch1 = (schiene_t*)gr->get_weg(get_waytype());
if(sch1) {
sch1->unreserve(cnv->self);
if (gr->has_two_ways()) {
// we may need to reserve the other way as well
if (schiene_t* sch0 = dynamic_cast<schiene_t*>(gr->get_weg_nr(gr->get_weg_nr(0) == sch1))) {
sch0->unreserve(cnv->self);
}
}
}
}
}
cnv->set_next_reservation_index( start_index );
return false;
Expand Down Expand Up @@ -821,6 +840,13 @@ void rail_vehicle_t::leave_tile()
sig->set_state(roadsign_t::STATE_RED);
}
}
if (gr->has_two_ways()) {
// we may need to reserve the other way as well
if (schiene_t* sch1 = dynamic_cast<schiene_t*>(gr->get_weg_nr(gr->get_weg_nr(0) == sch0))) {
// the other way is reservable too => unreserve it
sch1->unreserve(this);
}
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/simutrans/world/simcity.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3465,7 +3465,7 @@ bool stadt_t::build_road(const koord k, player_t* player_, bool forced)
{
grund_t* bd = welt->lookup_kartenboden(k);

if (bd->get_typ() != grund_t::boden) {
if (!bd || bd->get_typ() != grund_t::boden) {
// not on water, monorails, foundations, tunnel or bridges
return false;
}
Expand Down

0 comments on commit 55ad759

Please sign in to comment.