Loading

Paste #puw7rxc8d

  1. Index: src/pathfinder/yapf/yapf_rail.cpp
  2. ===================================================================
  3. --- src/pathfinder/yapf/yapf_rail.cpp   (revision 27331)
  4. +++ src/pathfinder/yapf/yapf_rail.cpp   (working copy)
  5. @@ -21,9 +21,6 @@
  6.  
  7.  #include "../../safeguards.h"
  8.  
  9. -#define DEBUG_YAPF_CACHE 0
  10. -
  11. -#if DEBUG_YAPF_CACHE
  12.  template <typename Tpf> void DumpState(Tpf &pf1, Tpf &pf2)
  13.  {
  14.     DumpTarget dmp1, dmp2;
  15. @@ -36,7 +33,6 @@
  16.     fclose(f1);
  17.     fclose(f2);
  18.  }
  19. -#endif
  20.  
  21.  int _total_pf_time_us = 0;
  22.  
  23. @@ -242,17 +238,17 @@
  24.         if (max_penalty != 0) pf1.DisableCache(true);
  25.         bool result1 = pf1.FindNearestDepotTwoWay(v, t1, td1, t2, td2, max_penalty, reverse_penalty, depot_tile, reversed);
  26.  
  27. -#if DEBUG_YAPF_CACHE
  28. -       Tpf pf2;
  29. -       TileIndex depot_tile2 = INVALID_TILE;
  30. -       bool reversed2 = false;
  31. -       pf2.DisableCache(true);
  32. -       bool result2 = pf2.FindNearestDepotTwoWay(v, t1, td1, t2, td2, max_penalty, reverse_penalty, &depot_tile2, &reversed2);
  33. -       if (result1 != result2 || (result1 && (*depot_tile != depot_tile2 || *reversed != reversed2))) {
  34. -           DEBUG(yapf, 0, "CACHE ERROR: FindNearestDepotTwoWay() = [%s, %s]", result1 ? "T" : "F", result2 ? "T" : "F");
  35. -           DumpState(pf1, pf2);
  36. +       if (_debug_desync_level >= 2) {
  37. +           Tpf pf2;
  38. +           TileIndex depot_tile2 = INVALID_TILE;
  39. +           bool reversed2 = false;
  40. +           pf2.DisableCache(true);
  41. +           bool result2 = pf2.FindNearestDepotTwoWay(v, t1, td1, t2, td2, max_penalty, reverse_penalty, &depot_tile2, &reversed2);
  42. +           if (result1 != result2 || (result1 && (*depot_tile != depot_tile2 || *reversed != reversed2))) {
  43. +               DEBUG(yapf, 0, "CACHE ERROR: FindNearestDepotTwoWay() = [%s, %s]", result1 ? "T" : "F", result2 ? "T" : "F");
  44. +               DumpState(pf1, pf2);
  45. +           }
  46.         }
  47. -#endif
  48.  
  49.         return result1;
  50.     }
  51. @@ -327,19 +323,19 @@
  52.     {
  53.         /* Create pathfinder instance */
  54.         Tpf pf1;
  55. -#if !DEBUG_YAPF_CACHE
  56. -       bool result1 = pf1.FindNearestSafeTile(v, t1, td, override_railtype, false);
  57. -
  58. -#else
  59. -       bool result2 = pf1.FindNearestSafeTile(v, t1, td, override_railtype, true);
  60. -       Tpf pf2;
  61. -       pf2.DisableCache(true);
  62. -       bool result1 = pf2.FindNearestSafeTile(v, t1, td, override_railtype, false);
  63. -       if (result1 != result2) {
  64. -           DEBUG(yapf, 0, "CACHE ERROR: FindSafeTile() = [%s, %s]", result2 ? "T" : "F", result1 ? "T" : "F");
  65. -           DumpState(pf1, pf2);
  66. +       bool result1;
  67. +       if (_debug_desync_level < 2) {
  68. +           result1 = pf1.FindNearestSafeTile(v, t1, td, override_railtype, false);
  69. +       } else {
  70. +           bool result2 = pf1.FindNearestSafeTile(v, t1, td, override_railtype, true);
  71. +           Tpf pf2;
  72. +           pf2.DisableCache(true);
  73. +           result1 = pf2.FindNearestSafeTile(v, t1, td, override_railtype, false);
  74. +           if (result1 != result2) {
  75. +               DEBUG(yapf, 0, "CACHE ERROR: FindSafeTile() = [%s, %s]", result2 ? "T" : "F", result1 ? "T" : "F");
  76. +               DumpState(pf1, pf2);
  77. +           }
  78.         }
  79. -#endif
  80.  
  81.         return result1;
  82.     }
  83. @@ -410,19 +406,20 @@
  84.     {
  85.         /* create pathfinder instance */
  86.         Tpf pf1;
  87. -#if !DEBUG_YAPF_CACHE
  88. -       Trackdir result1 = pf1.ChooseRailTrack(v, tile, enterdir, tracks, path_found, reserve_track, target);
  89. +       Trackdir result1;
  90.  
  91. -#else
  92. -       Trackdir result1 = pf1.ChooseRailTrack(v, tile, enterdir, tracks, path_found, false, NULL);
  93. -       Tpf pf2;
  94. -       pf2.DisableCache(true);
  95. -       Trackdir result2 = pf2.ChooseRailTrack(v, tile, enterdir, tracks, path_found, reserve_track, target);
  96. -       if (result1 != result2) {
  97. -           DEBUG(yapf, 0, "CACHE ERROR: ChooseRailTrack() = [%d, %d]", result1, result2);
  98. -           DumpState(pf1, pf2);
  99. +       if (_debug_desync_level < 2) {
  100. +           result1 = pf1.ChooseRailTrack(v, tile, enterdir, tracks, path_found, reserve_track, target);
  101. +       } else {
  102. +           result1 = pf1.ChooseRailTrack(v, tile, enterdir, tracks, path_found, false, NULL);
  103. +           Tpf pf2;
  104. +           pf2.DisableCache(true);
  105. +           Trackdir result2 = pf2.ChooseRailTrack(v, tile, enterdir, tracks, path_found, reserve_track, target);
  106. +           if (result1 != result2) {
  107. +               DEBUG(yapf, 0, "CACHE ERROR: ChooseRailTrack() = [%d, %d]", result1, result2);
  108. +               DumpState(pf1, pf2);
  109. +           }
  110.         }
  111. -#endif
  112.  
  113.         return result1;
  114.     }
  115. @@ -472,15 +469,15 @@
  116.         Tpf pf1;
  117.         bool result1 = pf1.CheckReverseTrain(v, t1, td1, t2, td2, reverse_penalty);
  118.  
  119. -#if DEBUG_YAPF_CACHE
  120. -       Tpf pf2;
  121. -       pf2.DisableCache(true);
  122. -       bool result2 = pf2.CheckReverseTrain(v, t1, td1, t2, td2, reverse_penalty);
  123. -       if (result1 != result2) {
  124. -           DEBUG(yapf, 0, "CACHE ERROR: CheckReverseTrain() = [%s, %s]", result1 ? "T" : "F", result2 ? "T" : "F");
  125. -           DumpState(pf1, pf2);
  126. +       if (_debug_desync_level >= 2) {
  127. +           Tpf pf2;
  128. +           pf2.DisableCache(true);
  129. +           bool result2 = pf2.CheckReverseTrain(v, t1, td1, t2, td2, reverse_penalty);
  130. +           if (result1 != result2) {
  131. +               DEBUG(yapf, 0, "CACHE ERROR: CheckReverseTrain() = [%s, %s]", result1 ? "T" : "F", result2 ? "T" : "F");
  132. +               DumpState(pf1, pf2);
  133. +           }
  134.         }
  135. -#endif
  136.  
  137.         return result1;
  138.     }
  139.  

Comments