mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-09 23:50:25 +00:00
Codechange: Replace CBlobT usage with std::vector
This commit is contained in:
parent
f481c9fc2c
commit
e8022a589d
@ -10,6 +10,8 @@
|
|||||||
#ifndef YAPF_COSTRAIL_HPP
|
#ifndef YAPF_COSTRAIL_HPP
|
||||||
#define YAPF_COSTRAIL_HPP
|
#define YAPF_COSTRAIL_HPP
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "../../pbs.h"
|
#include "../../pbs.h"
|
||||||
|
|
||||||
template <class Types>
|
template <class Types>
|
||||||
@ -53,8 +55,8 @@ protected:
|
|||||||
* @todo fix maximum cost failing with caching (e.g. FS#2900)
|
* @todo fix maximum cost failing with caching (e.g. FS#2900)
|
||||||
*/
|
*/
|
||||||
int m_max_cost;
|
int m_max_cost;
|
||||||
CBlobT<int> m_sig_look_ahead_costs;
|
|
||||||
bool m_disable_cache;
|
bool m_disable_cache;
|
||||||
|
std::vector<int> m_sig_look_ahead_costs;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool m_stopped_on_first_two_way_signal;
|
bool m_stopped_on_first_two_way_signal;
|
||||||
@ -68,9 +70,10 @@ protected:
|
|||||||
int p0 = Yapf().PfGetSettings().rail_look_ahead_signal_p0;
|
int p0 = Yapf().PfGetSettings().rail_look_ahead_signal_p0;
|
||||||
int p1 = Yapf().PfGetSettings().rail_look_ahead_signal_p1;
|
int p1 = Yapf().PfGetSettings().rail_look_ahead_signal_p1;
|
||||||
int p2 = Yapf().PfGetSettings().rail_look_ahead_signal_p2;
|
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++) {
|
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. */
|
/** The cost for reserved tiles, including skipped ones. */
|
||||||
inline int ReservationCost(Node &n, TileIndex tile, Trackdir trackdir, int skipped)
|
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 (!IsPbsSignal(n.m_last_signal_type)) return 0;
|
||||||
|
|
||||||
if (IsRailStationTile(tile) && IsAnyStationTileReserved(tile, trackdir, skipped)) {
|
if (IsRailStationTile(tile) && IsAnyStationTileReserved(tile, trackdir, skipped)) {
|
||||||
@ -184,7 +187,7 @@ public:
|
|||||||
n.m_last_signal_type = sig_type;
|
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 */
|
/* 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) {
|
if (sig_state != SIGNAL_STATE_RED) {
|
||||||
/* green signal */
|
/* green signal */
|
||||||
n.flags_u.flags_s.m_last_signal_was_red = false;
|
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
|
/* Apply min/max speed penalties only when inside the look-ahead radius. Otherwise
|
||||||
* it would cause desync in MP. */
|
* 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 min_speed = 0;
|
||||||
int max_speed = tf->GetSpeedLimit(&min_speed);
|
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
|
return !m_disable_cache
|
||||||
&& (n.m_parent != nullptr)
|
&& (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)
|
inline void ConnectNodeToCachedData(Node &n, CachedData &ci)
|
||||||
|
Loading…
Reference in New Issue
Block a user