summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKUDr <kudr@openttd.org>2007-01-12 15:43:00 +0000
committerKUDr <kudr@openttd.org>2007-01-12 15:43:00 +0000
commite896d7814a99cafc38b369cb81e2888c4df3da78 (patch)
tree19f3e95bf5579b0916e658e80962ef6c13f1cf49 /src
parentc48aa5db45e99981eff70be5f8406959dcba2237 (diff)
downloadopenttd-e896d7814a99cafc38b369cb81e2888c4df3da78.tar.xz
(svn r8079) -Fix [YAPF]: float division by zero when calculating stats (YAPF cache hit ratio). Caused BSOD on Win9x. (thanks 3iff for report, Darkvater for help)
Diffstat (limited to 'src')
-rw-r--r--src/yapf/yapf_base.hpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/yapf/yapf_base.hpp b/src/yapf/yapf_base.hpp
index e4ef5abc3..4382789cc 100644
--- a/src/yapf/yapf_base.hpp
+++ b/src/yapf/yapf_base.hpp
@@ -141,10 +141,14 @@ public:
int t = perf.Get(1000000);
_total_pf_time_us += t;
char ttc = Yapf().TransportTypeChar();
- float cache_hit_ratio = (float)m_stats_cache_hits / (float)(m_stats_cache_hits + m_stats_cost_calcs) * 100.0f;
- int cost = bDestFound ? m_pBestDestNode->m_cost : -1;
- int dist = bDestFound ? m_pBestDestNode->m_estimate - m_pBestDestNode->m_cost : -1;
- DEBUG(yapf, 3, "[YAPF%c]%c%4d- %d us - %d rounds - %d open - %d closed - CHR %4.1f%% - c%d(sc%d, ts%d, o%d) -- ", ttc, bDestFound ? '-' : '!', veh_idx, t, m_num_steps, m_nodes.OpenCount(), m_nodes.ClosedCount(), cache_hit_ratio, cost, dist, m_perf_cost.Get(1000000), m_perf_slope_cost.Get(1000000), m_perf_ts_cost.Get(1000000), m_perf_other_cost.Get(1000000));
+#ifndef NO_DEBUG_MESSAGES
+ if (_debug_yapf_level >= 3) {
+ float cache_hit_ratio = (m_stats_cache_hits == 0) ? 0.0f : ((float)m_stats_cache_hits / (float)(m_stats_cache_hits + m_stats_cost_calcs) * 100.0f);
+ int cost = bDestFound ? m_pBestDestNode->m_cost : -1;
+ int dist = bDestFound ? m_pBestDestNode->m_estimate - m_pBestDestNode->m_cost : -1;
+ DEBUG(yapf, 3, "[YAPF%c]%c%4d- %d us - %d rounds - %d open - %d closed - CHR %4.1f%% - c%d(sc%d, ts%d, o%d) -- ", ttc, bDestFound ? '-' : '!', veh_idx, t, m_num_steps, m_nodes.OpenCount(), m_nodes.ClosedCount(), cache_hit_ratio, cost, dist, m_perf_cost.Get(1000000), m_perf_slope_cost.Get(1000000), m_perf_ts_cost.Get(1000000), m_perf_other_cost.Get(1000000));
+ }
+#endif //!NO_DEBUG_MESSAGES
return bDestFound;
}