投稿者 トピック: [patch]渋滞時に自家用車が踏切上で止まる  (参照数 3152 回)

z9999+

  • 管理人
  • 急行
  • *
  • 投稿: 381
このパッチは次のバグを修正します。
- 渋滞時に自家用車が踏切上で止まる
また、次の仕様上の問題を修正します。
- 渋滞時に踏切の先が交差点の場合踏切上で止まる
- 渋滞時に自家用車が、踏切より先に道路がない(行き止まりの)場合踏切上で止まる

コード: [選択]
Index: vehicle/simvehikel.cc
===================================================================
--- vehicle/simvehikel.cc (リビジョン 3397)
+++ vehicle/simvehikel.cc (作業コピー)
@@ -1937,6 +1937,11 @@
 
  // do not block intersections
  if(dt==NULL  &&  ribi_t::is_threeway(str->get_ribi_unmasked())  &&  route_index+1u<cnv->get_route()->get_count()-1) {
+ // but leaving from railroad crossing is more important
+ grund_t *gr_here = welt->lookup(get_pos());
+ if(gr_here  &&  gr_here->ist_uebergang()) {
+ return true;
+ }
  // we have to test also next field
  const grund_t *gr = welt->lookup( cnv->get_route()->position_bei(route_index+1u) );
  if(gr) {
Index: vehicle/simverkehr.cc
===================================================================
--- vehicle/simverkehr.cc (リビジョン 3397)
+++ vehicle/simverkehr.cc (作業コピー)
@@ -552,6 +552,11 @@
  const uint8 next_fahrtrichtung = ribi_t::rueckwaerts(this_fahrtrichtung);
  frei = (NULL == no_cars_blocking( gr, NULL, next_fahrtrichtung, next_fahrtrichtung, next_fahrtrichtung ));
 
+ // do not block railroad crossing
+ if(frei  &&  str->is_crossing()) {
+ const grund_t *gr = welt->lookup(get_pos());
+ frei = (NULL == no_cars_blocking( gr, NULL, next_fahrtrichtung, next_fahrtrichtung, next_fahrtrichtung ));
+ }
  }
  else {
  // driving on: check for crossongs etc. too
@@ -559,6 +564,11 @@
 
  // do not block this crossing (if possible)
  if(ribi_t::is_threeway(str->get_ribi_unmasked())) {
+ // but leaving from railroad crossing is more important
+ grund_t *gr_here = welt->lookup(get_pos());
+ if(gr_here  &&  gr_here->ist_uebergang()) {
+ return true;
+ }
  grund_t *test = welt->lookup(pos_next_next);
  if(test) {
  uint8 next_90fahrtrichtung = this->calc_richtung(pos_next.get_2d(), pos_next_next.get_2d());
@@ -612,9 +622,9 @@
  if(frei  &&  str->is_crossing()) {
  // can we cross?
  crossing_t* cr = gr->find<crossing_t>(2);
- if(cr) {
+ if(  cr && !cr->request_crossing(this)) {
  // approaching railway crossing: check if empty
- return cr->request_crossing( this );
+ return false;
  }
  // no further check, when already entered a crossing (to alloew leaving it)
  grund_t *gr_here = welt->lookup(get_pos());
@@ -624,12 +634,14 @@
  // ok, now check for free exit
  koord dir = pos_next.get_2d()-get_pos().get_2d();
  koord3d checkpos = pos_next+dir;
- const uint8 nextnext_fahrtrichtung = ribi_typ(dir);
  while(1) {
  const grund_t *test = welt->lookup(checkpos);
  if(!test) {
+ // should not reach here ! (z9999)
  break;
  }
+ const uint8 next_fahrtrichtung = ribi_typ(dir);
+ const uint8 nextnext_fahrtrichtung = ribi_typ(dir);
  // test next field after way crossing
  if(no_cars_blocking( test, NULL, next_fahrtrichtung, nextnext_fahrtrichtung, nextnext_fahrtrichtung )) {
  return false;
@@ -640,6 +652,12 @@
  crossing_t* cr = gr->find<crossing_t>(2);
  return cr->request_crossing( this );
  }
+ else {
+ // seems to be a deadend. try to check reverse direction, too
+ if((test->get_weg_ribi(road_wt)&next_fahrtrichtung) ==0) {
+ dir = -dir;
+ }
+ }
  checkpos += dir;
  }
  }

« 最終編集: 2010/06/02 17:46 by z9999+ »

z9999+

  • 管理人
  • 急行
  • *
  • 投稿: 381
Re:[patch]渋滞時に自家用車が踏切上で止まる
« 返信 #1 on: 2010/06/26 00:37 »
更新です。
踏切が行き止まりで出口がない場合には中に入らないように変更しました。
といっても、向きを変えるために一度線路上に入る必要がありますが。

コードはpos_next_next=get_pos();を追加しただけです。