summaryrefslogtreecommitdiff
path: root/src/pathfinder
diff options
context:
space:
mode:
Diffstat (limited to 'src/pathfinder')
-rw-r--r--src/pathfinder/yapf/yapf.hpp1
-rw-r--r--src/pathfinder/yapf/yapf_base.hpp2
-rw-r--r--src/pathfinder/yapf/yapf_node.hpp4
-rw-r--r--src/pathfinder/yapf/yapf_node_rail.hpp10
-rw-r--r--src/pathfinder/yapf/yapf_rail.cpp4
-rw-r--r--src/pathfinder/yapf/yapf_type.hpp12
6 files changed, 18 insertions, 15 deletions
diff --git a/src/pathfinder/yapf/yapf.hpp b/src/pathfinder/yapf/yapf.hpp
index 867c6188f..cac6c4c24 100644
--- a/src/pathfinder/yapf/yapf.hpp
+++ b/src/pathfinder/yapf/yapf.hpp
@@ -19,7 +19,6 @@
//#define inline inline
#include "../../misc/blob.hpp"
-#include "../../misc/str.hpp"
#include "../../misc/fixedsizearray.hpp"
#include "../../misc/array.hpp"
#include "../../misc/hashtable.hpp"
diff --git a/src/pathfinder/yapf/yapf_base.hpp b/src/pathfinder/yapf/yapf_base.hpp
index 0bdd81dff..c04fa2af9 100644
--- a/src/pathfinder/yapf/yapf_base.hpp
+++ b/src/pathfinder/yapf/yapf_base.hpp
@@ -317,7 +317,7 @@ public:
void DumpBase(DumpTarget &dmp) const
{
dmp.WriteStructT("m_nodes", &m_nodes);
- dmp.WriteLine("m_num_steps = %d", m_num_steps);
+ dmp.WriteValue("m_num_steps", m_num_steps);
}
/* methods that should be implemented at derived class Types::Tpf (derived from CYapfBaseT) */
diff --git a/src/pathfinder/yapf/yapf_node.hpp b/src/pathfinder/yapf/yapf_node.hpp
index 689a8e975..ce4ba3b28 100644
--- a/src/pathfinder/yapf/yapf_node.hpp
+++ b/src/pathfinder/yapf/yapf_node.hpp
@@ -126,8 +126,8 @@ struct CYapfNodeT {
{
dmp.WriteStructT("m_key", &m_key);
dmp.WriteStructT("m_parent", m_parent);
- dmp.WriteLine("m_cost = %d", m_cost);
- dmp.WriteLine("m_estimate = %d", m_estimate);
+ dmp.WriteValue("m_cost", m_cost);
+ dmp.WriteValue("m_estimate", m_estimate);
}
};
diff --git a/src/pathfinder/yapf/yapf_node_rail.hpp b/src/pathfinder/yapf/yapf_node_rail.hpp
index fce909ac9..df369fcdd 100644
--- a/src/pathfinder/yapf/yapf_node_rail.hpp
+++ b/src/pathfinder/yapf/yapf_node_rail.hpp
@@ -109,7 +109,7 @@ struct CYapfRailSegment
dmp.WriteStructT("m_key", &m_key);
dmp.WriteTile("m_last_tile", m_last_tile);
dmp.WriteEnumT("m_last_td", m_last_td);
- dmp.WriteLine("m_cost = %d", m_cost);
+ dmp.WriteValue("m_cost", m_cost);
dmp.WriteTile("m_last_signal_tile", m_last_signal_tile);
dmp.WriteEnumT("m_last_signal_td", m_last_signal_td);
dmp.WriteEnumT("m_end_segment_reason", m_end_segment_reason);
@@ -207,10 +207,10 @@ struct CYapfRailNodeT
{
base::Dump(dmp);
dmp.WriteStructT("m_segment", m_segment);
- dmp.WriteLine("m_num_signals_passed = %d", m_num_signals_passed);
- dmp.WriteLine("m_targed_seen = %s", flags_u.flags_s.m_targed_seen ? "Yes" : "No");
- dmp.WriteLine("m_choice_seen = %s", flags_u.flags_s.m_choice_seen ? "Yes" : "No");
- dmp.WriteLine("m_last_signal_was_red = %s", flags_u.flags_s.m_last_signal_was_red ? "Yes" : "No");
+ dmp.WriteValue("m_num_signals_passed", m_num_signals_passed);
+ dmp.WriteValue("m_targed_seen", flags_u.flags_s.m_targed_seen ? "Yes" : "No");
+ dmp.WriteValue("m_choice_seen", flags_u.flags_s.m_choice_seen ? "Yes" : "No");
+ dmp.WriteValue("m_last_signal_was_red", flags_u.flags_s.m_last_signal_was_red ? "Yes" : "No");
dmp.WriteEnumT("m_last_red_signal_type", m_last_red_signal_type);
}
};
diff --git a/src/pathfinder/yapf/yapf_rail.cpp b/src/pathfinder/yapf/yapf_rail.cpp
index 6922c0b89..3b6686f20 100644
--- a/src/pathfinder/yapf/yapf_rail.cpp
+++ b/src/pathfinder/yapf/yapf_rail.cpp
@@ -28,8 +28,8 @@ template <typename Tpf> void DumpState(Tpf &pf1, Tpf &pf2)
FILE *f2 = fopen("yapf2.txt", "wt");
assert(f1 != nullptr);
assert(f2 != nullptr);
- fwrite(dmp1.m_out.Data(), 1, dmp1.m_out.Size(), f1);
- fwrite(dmp2.m_out.Data(), 1, dmp2.m_out.Size(), f2);
+ fwrite(dmp1.m_out.c_str(), 1, dmp1.m_out.size(), f1);
+ fwrite(dmp2.m_out.c_str(), 1, dmp2.m_out.size(), f2);
fclose(f1);
fclose(f2);
}
diff --git a/src/pathfinder/yapf/yapf_type.hpp b/src/pathfinder/yapf/yapf_type.hpp
index ff63c1304..4f301b0fb 100644
--- a/src/pathfinder/yapf/yapf_type.hpp
+++ b/src/pathfinder/yapf/yapf_type.hpp
@@ -10,6 +10,9 @@
#ifndef YAPF_TYPE_HPP
#define YAPF_TYPE_HPP
+#include <iomanip>
+#include <sstream>
+
/* Enum used in PfCalcCost() to see why was the segment closed. */
enum EndSegmentReason {
/* The following reasons can be saved into cached segment */
@@ -66,7 +69,7 @@ enum EndSegmentReasonBits {
DECLARE_ENUM_AS_BIT_SET(EndSegmentReasonBits)
-inline CStrA ValueStr(EndSegmentReasonBits bits)
+inline std::string ValueStr(EndSegmentReasonBits bits)
{
static const char * const end_segment_reason_names[] = {
"DEAD_END", "RAIL_TYPE", "INFINITE_LOOP", "SEGMENT_TOO_LONG", "CHOICE_FOLLOWS",
@@ -74,9 +77,10 @@ inline CStrA ValueStr(EndSegmentReasonBits bits)
"PATH_TOO_LONG", "FIRST_TWO_WAY_RED", "LOOK_AHEAD_END", "TARGET_REACHED"
};
- CStrA out;
- out.Format("0x%04X (%s)", bits, ComposeNameT(bits, end_segment_reason_names, "UNK", ESRB_NONE, "NONE").Data());
- return out.Transfer();
+ std::stringstream ss;
+ ss << "0x" << std::setfill('0') << std::setw(4) << std::hex << bits; // 0x%04X
+ ss << " (" << ComposeNameT(bits, end_segment_reason_names, "UNK", ESRB_NONE, "NONE") << ")";
+ return ss.str();
}
#endif /* YAPF_TYPE_HPP */