summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/yapf/yapf_rail.cpp37
1 files changed, 19 insertions, 18 deletions
diff --git a/src/yapf/yapf_rail.cpp b/src/yapf/yapf_rail.cpp
index 884b82ca2..e053f4c8d 100644
--- a/src/yapf/yapf_rail.cpp
+++ b/src/yapf/yapf_rail.cpp
@@ -13,6 +13,21 @@
#define DEBUG_YAPF_CACHE 0
+#if DEBUG_YAPF_CACHE
+template <typename Tpf> void DumpState(Tpf &pf1, Tpf &pf2)
+{
+ DumpTarget dmp1, dmp2;
+ pf1.DumpBase(dmp1);
+ pf2.DumpBase(dmp2);
+ FILE *f1 = fopen("yapf1.txt", "wt");
+ FILE *f2 = fopen("yapf2.txt", "wt");
+ fwrite(dmp1.m_out.Data(), 1, dmp1.m_out.Size(), f1);
+ fwrite(dmp2.m_out.Data(), 1, dmp2.m_out.Size(), f2);
+ fclose(f1);
+ fclose(f2);
+}
+#endif
+
int _total_pf_time_us = 0;
template <class Types>
@@ -208,6 +223,7 @@ public:
bool result2 = pf2.FindNearestDepotTwoWay(v, t1, td1, t2, td2, max_distance, reverse_penalty, &depot_tile2, &reversed2);
if (result1 != result2 || (result1 && (*depot_tile != depot_tile2 || *reversed != reversed2))) {
DEBUG(yapf, 0, "CACHE ERROR: FindNearestDepotTwoWay() = [%s, %s]", result1 ? "T" : "F", result2 ? "T" : "F");
+ DumpState(pf1, pf2);
}
#endif
@@ -292,15 +308,7 @@ public:
bool result1 = pf2.FindNearestSafeTile(v, t1, td, override_railtype, false);
if (result1 != result2) {
DEBUG(yapf, 0, "CACHE ERROR: FindSafeTile() = [%s, %s]", result2 ? "T" : "F", result1 ? "T" : "F");
- DumpTarget dmp1, dmp2;
- pf1.DumpBase(dmp1);
- pf2.DumpBase(dmp2);
- FILE *f1 = fopen("C:\\yapf1.txt", "wt");
- FILE *f2 = fopen("C:\\yapf2.txt", "wt");
- fwrite(dmp1.m_out.Data(), 1, dmp1.m_out.Size(), f1);
- fwrite(dmp2.m_out.Data(), 1, dmp2.m_out.Size(), f2);
- fclose(f1);
- fclose(f2);
+ DumpState(pf1, pf2);
}
#endif
@@ -381,15 +389,7 @@ public:
Trackdir result2 = pf2.ChooseRailTrack(v, tile, enterdir, tracks, path_not_found, reserve_track, target);
if (result1 != result2) {
DEBUG(yapf, 0, "CACHE ERROR: ChooseRailTrack() = [%d, %d]", result1, result2);
- DumpTarget dmp1, dmp2;
- pf1.DumpBase(dmp1);
- pf2.DumpBase(dmp2);
- FILE *f1 = fopen("C:\\yapf1.txt", "wt");
- FILE *f2 = fopen("C:\\yapf2.txt", "wt");
- fwrite(dmp1.m_out.Data(), 1, dmp1.m_out.Size(), f1);
- fwrite(dmp2.m_out.Data(), 1, dmp2.m_out.Size(), f2);
- fclose(f1);
- fclose(f2);
+ DumpState(pf1, pf2);
}
#endif
@@ -449,6 +449,7 @@ public:
bool result2 = pf2.CheckReverseTrain(v, t1, td1, t2, td2, reverse_penalty);
if (result1 != result2) {
DEBUG(yapf, 0, "CACHE ERROR: CheckReverseTrain() = [%s, %s]", result1 ? "T" : "F", result2 ? "T" : "F");
+ DumpState(pf1, pf2);
}
#endif