summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCharles Pigott <charlespigott@googlemail.com>2021-04-02 21:16:51 +0100
committerCharles Pigott <charlespigott@googlemail.com>2021-04-04 08:01:54 +0100
commite8022a589d4f011cae4c3f449d91296ebcc3d947 (patch)
treeb2efee02156ef7ba32ae0c71630643cbb0dc497b /src
parentf481c9fc2c68ff7b83eef78d3e37982492dae981 (diff)
downloadopenttd-e8022a589d4f011cae4c3f449d91296ebcc3d947.tar.xz
Codechange: Replace CBlobT usage with std::vector
Diffstat (limited to 'src')
-rw-r--r--src/pathfinder/yapf/yapf_costrail.hpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/pathfinder/yapf/yapf_costrail.hpp b/src/pathfinder/yapf/yapf_costrail.hpp
index 2f4834633..6bed27cba 100644
--- a/src/pathfinder/yapf/yapf_costrail.hpp
+++ b/src/pathfinder/yapf/yapf_costrail.hpp
@@ -10,6 +10,8 @@
#ifndef YAPF_COSTRAIL_HPP
#define YAPF_COSTRAIL_HPP
+#include <vector>
+
#include "../../pbs.h"
template <class Types>
@@ -52,9 +54,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;
@@ -68,9 +70,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);
+ 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++) {
- pen[i] = p0 + i * (p1 + i * p2);
+ m_sig_look_ahead_costs.push_back(p0 + i * (p1 + i * p2));
}
}
@@ -152,7 +155,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)) {
@@ -184,7 +187,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;
@@ -460,7 +463,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);
@@ -615,7 +618,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)