Merge branch 'master' into jgrpp
# Conflicts: # .github/workflows/release.yml # bin/CMakeLists.txt # src/dock_gui.cpp # src/lang/brazilian_portuguese.txt # src/lang/catalan.txt # src/lang/czech.txt # src/lang/dutch.txt # src/lang/english.txt # src/lang/english_US.txt # src/lang/estonian.txt # src/lang/finnish.txt # src/lang/french.txt # src/lang/german.txt # src/lang/hungarian.txt # src/lang/indonesian.txt # src/lang/italian.txt # src/lang/japanese.txt # src/lang/korean.txt # src/lang/lithuanian.txt # src/lang/luxembourgish.txt # src/lang/norwegian_bokmal.txt # src/lang/polish.txt # src/lang/portuguese.txt # src/lang/romanian.txt # src/lang/russian.txt # src/lang/serbian.txt # src/lang/simplified_chinese.txt # src/lang/slovak.txt # src/lang/spanish.txt # src/lang/spanish_MX.txt # src/lang/swedish.txt # src/lang/tamil.txt # src/lang/ukrainian.txt # src/lang/vietnamese.txt # src/newgrf.cpp # src/newgrf_gui.cpp # src/object_gui.cpp # src/pathfinder/yapf/yapf_costrail.hpp # src/pathfinder/yapf/yapf_node_rail.hpp # src/rail_cmd.cpp # src/roadveh_cmd.cpp # src/town_cmd.cpp # src/vehicle.cpp # src/water_cmd.cpp
This commit is contained in:
@@ -18,8 +18,6 @@
|
||||
//#undef FORCEINLINE
|
||||
//#define inline inline
|
||||
|
||||
#include "../../misc/blob.hpp"
|
||||
#include "../../misc/str.hpp"
|
||||
#include "../../misc/fixedsizearray.hpp"
|
||||
#include "../../misc/array.hpp"
|
||||
#include "../../misc/hashtable.hpp"
|
||||
|
@@ -325,7 +325,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) */
|
||||
|
@@ -10,6 +10,8 @@
|
||||
#ifndef YAPF_COSTRAIL_HPP
|
||||
#define YAPF_COSTRAIL_HPP
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "../../pbs.h"
|
||||
#include "../../tracerestrict.h"
|
||||
|
||||
@@ -53,9 +55,9 @@ protected:
|
||||
* @note maximum cost doesn't work with caching enabled
|
||||
* @todo fix maximum cost failing with caching (e.g. FS#2900)
|
||||
*/
|
||||
int m_max_cost;
|
||||
CBlobT<int> m_sig_look_ahead_costs;
|
||||
bool m_disable_cache;
|
||||
int m_max_cost;
|
||||
bool m_disable_cache;
|
||||
std::vector<int> m_sig_look_ahead_costs;
|
||||
|
||||
public:
|
||||
bool m_stopped_on_first_two_way_signal;
|
||||
@@ -69,9 +71,10 @@ protected:
|
||||
int p0 = Yapf().PfGetSettings().rail_look_ahead_signal_p0;
|
||||
int p1 = Yapf().PfGetSettings().rail_look_ahead_signal_p1;
|
||||
int p2 = Yapf().PfGetSettings().rail_look_ahead_signal_p2;
|
||||
int *pen = m_sig_look_ahead_costs.GrowSizeNC(Yapf().PfGetSettings().rail_look_ahead_max_signals);
|
||||
for (int i = 0; i < (int) Yapf().PfGetSettings().rail_look_ahead_max_signals; i++) {
|
||||
pen[i] = std::max<int>(0, p0 + i * (p1 + i * p2));
|
||||
m_sig_look_ahead_costs.clear();
|
||||
m_sig_look_ahead_costs.reserve(Yapf().PfGetSettings().rail_look_ahead_max_signals);
|
||||
for (uint i = 0; i < Yapf().PfGetSettings().rail_look_ahead_max_signals; i++) {
|
||||
m_sig_look_ahead_costs.push_back(std::max<int>(0, p0 + i * (p1 + i * p2)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,7 +156,7 @@ public:
|
||||
/** The cost for reserved tiles, including skipped ones. */
|
||||
inline int ReservationCost(Node &n, TileIndex tile, Trackdir trackdir, int skipped)
|
||||
{
|
||||
if (n.m_num_signals_passed >= m_sig_look_ahead_costs.Size() / 2) return 0;
|
||||
if (n.m_num_signals_passed >= m_sig_look_ahead_costs.size() / 2) return 0;
|
||||
if (!IsPbsSignal(n.m_last_signal_type)) return 0;
|
||||
|
||||
if (IsRailStationTile(tile) && IsAnyStationTileReserved(tile, trackdir, skipped)) {
|
||||
@@ -170,7 +173,7 @@ private:
|
||||
// returns true if ExecuteTraceRestrict should be called
|
||||
inline bool ShouldCheckTraceRestrict(Node& n, TileIndex tile)
|
||||
{
|
||||
return n.m_num_signals_passed < m_sig_look_ahead_costs.Size() &&
|
||||
return n.m_num_signals_passed < m_sig_look_ahead_costs.size() &&
|
||||
IsRestrictedSignal(tile);
|
||||
}
|
||||
|
||||
@@ -313,7 +316,7 @@ public:
|
||||
n.m_last_signal_type = sig_type;
|
||||
|
||||
/* cache the look-ahead polynomial constant only if we didn't pass more signals than the look-ahead limit is */
|
||||
int look_ahead_cost = (n.m_num_signals_passed < m_sig_look_ahead_costs.Size()) ? m_sig_look_ahead_costs.Data()[n.m_num_signals_passed] : 0;
|
||||
int look_ahead_cost = (n.m_num_signals_passed < m_sig_look_ahead_costs.size()) ? m_sig_look_ahead_costs[n.m_num_signals_passed] : 0;
|
||||
if (sig_state != SIGNAL_STATE_RED) {
|
||||
/* green signal */
|
||||
n.flags_u.flags_s.m_last_signal_was_red = false;
|
||||
@@ -625,7 +628,7 @@ no_entry_cost: // jump here at the beginning if the node has no parent (it is th
|
||||
|
||||
/* Apply min/max speed penalties only when inside the look-ahead radius. Otherwise
|
||||
* it would cause desync in MP. */
|
||||
if (n.m_num_signals_passed < m_sig_look_ahead_costs.Size())
|
||||
if (n.m_num_signals_passed < m_sig_look_ahead_costs.size())
|
||||
{
|
||||
int min_speed = 0;
|
||||
int max_speed = tf->GetSpeedLimit(&min_speed);
|
||||
@@ -786,7 +789,7 @@ no_entry_cost: // jump here at the beginning if the node has no parent (it is th
|
||||
{
|
||||
return !m_disable_cache
|
||||
&& (n.m_parent != nullptr)
|
||||
&& (n.m_parent->m_num_signals_passed >= m_sig_look_ahead_costs.Size());
|
||||
&& (n.m_parent->m_num_signals_passed >= m_sig_look_ahead_costs.size());
|
||||
}
|
||||
|
||||
inline void ConnectNodeToCachedData(Node &n, CachedData &ci)
|
||||
|
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -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);
|
||||
@@ -219,13 +219,13 @@ 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_num_signals_res_through_passed = %d", m_num_signals_res_through_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.WriteLine("m_reverse_pending = %s", flags_u.flags_s.m_reverse_pending ? "Yes" : "No");
|
||||
dmp.WriteLine("m_teleport = %s", flags_u.flags_s.m_teleport ? "Yes" : "No");
|
||||
dmp.WriteValue("m_num_signals_passed", m_num_signals_passed);
|
||||
dmp.WriteValue("m_num_signals_res_through_passed", m_num_signals_res_through_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.WriteValue("m_reverse_pending", flags_u.flags_s.m_reverse_pending ? "Yes" : "No");
|
||||
dmp.WriteValue("m_teleport", flags_u.flags_s.m_teleport ? "Yes" : "No");
|
||||
dmp.WriteEnumT("m_last_red_signal_type", m_last_red_signal_type);
|
||||
}
|
||||
};
|
||||
|
@@ -60,8 +60,8 @@ template <typename Tpf> void DumpState(Tpf &pf1, Tpf &pf2)
|
||||
#endif
|
||||
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);
|
||||
}
|
||||
|
@@ -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 */
|
||||
@@ -71,7 +74,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",
|
||||
@@ -79,9 +82,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 */
|
||||
|
Reference in New Issue
Block a user