block: added list of paths towards the block
(for detecting incoming trains without reservation)
Dieser Commit ist enthalten in:
Ursprung
81c7cde7dd
Commit
29eb8402ee
@ -463,7 +463,7 @@ void BlockRailTile::updatePaths()
|
||||
m_paths.clear(); // make sure it is empty, it problably is after the move
|
||||
auto found = BlockPath::find(*this);
|
||||
|
||||
while(!current.empty())
|
||||
while(!current.empty()) // handle existing paths
|
||||
{
|
||||
auto it = std::find_if(found.begin(), found.end(),
|
||||
[¤tPath=*current.front()](const auto& foundPath)
|
||||
@ -479,8 +479,18 @@ void BlockRailTile::updatePaths()
|
||||
current.erase(current.begin());
|
||||
}
|
||||
|
||||
for(auto& path : found)
|
||||
for(auto& path : current) // no longer existing paths
|
||||
{
|
||||
auto& pathsIn = path->toBlock()->m_pathsIn;
|
||||
if(auto it = std::find(pathsIn.begin(), pathsIn.end(), path); it != pathsIn.end())
|
||||
{
|
||||
pathsIn.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
for(auto& path : found) // new paths
|
||||
{
|
||||
path->toBlock()->m_pathsIn.emplace_back(path);
|
||||
m_paths.emplace_back(std::move(path));
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,8 +46,11 @@ class BlockRailTile : public RailTile
|
||||
CREATE_DEF(BlockRailTile)
|
||||
|
||||
private:
|
||||
using Paths = std::vector<std::shared_ptr<BlockPath>>;
|
||||
|
||||
Node m_node;
|
||||
std::vector<std::shared_ptr<BlockPath>> m_paths;
|
||||
Paths m_paths; //!< Paths from this block to other block
|
||||
Paths m_pathsIn; //!< Paths from other blocks to this block
|
||||
std::array<std::weak_ptr<BlockPath>, 2> m_reservedPaths; // index is BlockSide
|
||||
|
||||
void updatePaths();
|
||||
|
||||
Laden…
x
In neuem Issue referenzieren
Einen Benutzer sperren