diff --git a/src/pathfinder/yapf/CMakeLists.txt b/src/pathfinder/yapf/CMakeLists.txt
index 6717233352..e1c0e687be 100644
--- a/src/pathfinder/yapf/CMakeLists.txt
+++ b/src/pathfinder/yapf/CMakeLists.txt
@@ -4,6 +4,7 @@ add_files(
yapf.hpp
yapf_base.hpp
yapf_cache.h
+ yapf_common.cpp
yapf_common.hpp
yapf_costbase.hpp
yapf_costcache.hpp
diff --git a/src/pathfinder/yapf/yapf_common.cpp b/src/pathfinder/yapf/yapf_common.cpp
new file mode 100644
index 0000000000..82e940a773
--- /dev/null
+++ b/src/pathfinder/yapf/yapf_common.cpp
@@ -0,0 +1,27 @@
+/*
+ * This file is part of OpenTTD.
+ * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
+ * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see .
+ */
+
+/** @file yapf_common.cpp Pathfinding common functions. */
+
+#include "../../stdafx.h"
+
+#include "yapf.hpp"
+#include "../../string_func.h"
+
+#include "../../safeguards.h"
+
+std::string ValueStr(EndSegmentReasonBits bits)
+{
+ static const char * const end_segment_reason_names[] = {
+ "DEAD_END", "DEAD_END_EOL", "RAIL_TYPE", "INFINITE_LOOP", "SEGMENT_TOO_LONG", "CHOICE_FOLLOWS",
+ "DEPOT", "WAYPOINT", "STATION", "SAFE_TILE",
+ "PATH_TOO_LONG", "FIRST_TWO_WAY_RED", "LOOK_AHEAD_END", "TARGET_REACHED",
+ "REVERSE"
+ };
+
+ return stdstr_fmt("0x%04X (%s)", bits, ComposeNameT(bits, end_segment_reason_names, "UNK", ESRB_NONE, "NONE").c_str());
+}
diff --git a/src/pathfinder/yapf/yapf_type.hpp b/src/pathfinder/yapf/yapf_type.hpp
index 35d9b0e267..4aa20b8cb2 100644
--- a/src/pathfinder/yapf/yapf_type.hpp
+++ b/src/pathfinder/yapf/yapf_type.hpp
@@ -10,9 +10,6 @@
#ifndef YAPF_TYPE_HPP
#define YAPF_TYPE_HPP
-#include
-#include
-
/* Enum used in PfCalcCost() to see why was the segment closed. */
enum EndSegmentReason {
/* The following reasons can be saved into cached segment */
@@ -76,19 +73,6 @@ enum EndSegmentReasonBits {
DECLARE_ENUM_AS_BIT_SET(EndSegmentReasonBits)
-inline std::string ValueStr(EndSegmentReasonBits bits)
-{
- static const char * const end_segment_reason_names[] = {
- "DEAD_END", "DEAD_END_EOL", "RAIL_TYPE", "INFINITE_LOOP", "SEGMENT_TOO_LONG", "CHOICE_FOLLOWS",
- "DEPOT", "WAYPOINT", "STATION", "SAFE_TILE",
- "PATH_TOO_LONG", "FIRST_TWO_WAY_RED", "LOOK_AHEAD_END", "TARGET_REACHED",
- "REVERSE"
- };
-
- 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();
-}
+std::string ValueStr(EndSegmentReasonBits bits);
#endif /* YAPF_TYPE_HPP */