(svn r16312) -Codechange: unduplicate yapf (rail) cache debugging.

This commit is contained in:
rubidium 2009-05-15 17:32:07 +00:00
parent 1205f02b43
commit 8e4ba4640f

View File

@ -13,6 +13,21 @@
#define DEBUG_YAPF_CACHE 0 #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; int _total_pf_time_us = 0;
template <class Types> template <class Types>
@ -208,6 +223,7 @@ public:
bool result2 = pf2.FindNearestDepotTwoWay(v, t1, td1, t2, td2, max_distance, reverse_penalty, &depot_tile2, &reversed2); 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))) { if (result1 != result2 || (result1 && (*depot_tile != depot_tile2 || *reversed != reversed2))) {
DEBUG(yapf, 0, "CACHE ERROR: FindNearestDepotTwoWay() = [%s, %s]", result1 ? "T" : "F", result2 ? "T" : "F"); DEBUG(yapf, 0, "CACHE ERROR: FindNearestDepotTwoWay() = [%s, %s]", result1 ? "T" : "F", result2 ? "T" : "F");
DumpState(pf1, pf2);
} }
#endif #endif
@ -292,15 +308,7 @@ public:
bool result1 = pf2.FindNearestSafeTile(v, t1, td, override_railtype, false); bool result1 = pf2.FindNearestSafeTile(v, t1, td, override_railtype, false);
if (result1 != result2) { if (result1 != result2) {
DEBUG(yapf, 0, "CACHE ERROR: FindSafeTile() = [%s, %s]", result2 ? "T" : "F", result1 ? "T" : "F"); DEBUG(yapf, 0, "CACHE ERROR: FindSafeTile() = [%s, %s]", result2 ? "T" : "F", result1 ? "T" : "F");
DumpTarget dmp1, dmp2; DumpState(pf1, pf2);
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);
} }
#endif #endif
@ -381,15 +389,7 @@ public:
Trackdir result2 = pf2.ChooseRailTrack(v, tile, enterdir, tracks, path_not_found, reserve_track, target); Trackdir result2 = pf2.ChooseRailTrack(v, tile, enterdir, tracks, path_not_found, reserve_track, target);
if (result1 != result2) { if (result1 != result2) {
DEBUG(yapf, 0, "CACHE ERROR: ChooseRailTrack() = [%d, %d]", result1, result2); DEBUG(yapf, 0, "CACHE ERROR: ChooseRailTrack() = [%d, %d]", result1, result2);
DumpTarget dmp1, dmp2; DumpState(pf1, pf2);
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);
} }
#endif #endif
@ -449,6 +449,7 @@ public:
bool result2 = pf2.CheckReverseTrain(v, t1, td1, t2, td2, reverse_penalty); bool result2 = pf2.CheckReverseTrain(v, t1, td1, t2, td2, reverse_penalty);
if (result1 != result2) { if (result1 != result2) {
DEBUG(yapf, 0, "CACHE ERROR: CheckReverseTrain() = [%s, %s]", result1 ? "T" : "F", result2 ? "T" : "F"); DEBUG(yapf, 0, "CACHE ERROR: CheckReverseTrain() = [%s, %s]", result1 ? "T" : "F", result2 ? "T" : "F");
DumpState(pf1, pf2);
} }
#endif #endif