Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Infinite loop while loading a savegame #35

Open
krzychu124 opened this issue Aug 13, 2021 · 0 comments
Open

[BUG] Infinite loop while loading a savegame #35

krzychu124 opened this issue Aug 13, 2021 · 0 comments

Comments

@krzychu124
Copy link

If something go wrong and NetInfo of the node will be null (possible if not all assets are subscribed/enabled) this method will cause infinite loop - game never finish loading a savegame. I've noticed that while testing the user savegame

private static List<ushort> GetMetroNodes(Building building)
{
ushort nodeID = building.m_netNode;
List<ushort> stationNodeIDs = null;
while (nodeID > 0)
{
NetNode node = NodeFrom(nodeID);
if (node.Info != null)
{
if (node.Info.IsUndergroundMetroStationTrack() || node.Info.name == Util.GetMetroStationTrackName(NetInfoVersion.Tunnel, TrackStyle.Vanilla) || node.Info.IsUndergroundMetroTrack() || node.Info.name == Util.GetMetroTrackName(NetInfoVersion.Tunnel, TrackStyle.Vanilla))
{
if (stationNodeIDs == null)
{
stationNodeIDs = new List<ushort>();
}
stationNodeIDs.Add(nodeID);
}
nodeID = NodeFrom(nodeID).m_nextBuildingNode;
}
}
return stationNodeIDs;
}

The instruction from line 447 should be placed outside of if (node.Info != null) check to prevent infinite loop.

Similar situation you can find just a few lines below but the code is correct there.

private static List<ushort> GetStationNodes(Building building)
{
ushort nodeID = building.m_netNode;
List<ushort> stationNodeIDs = null;
while (nodeID > 0)
{
NetNode node = NodeFrom(nodeID);
if (node.Info != null && (node.Info.IsUndergroundMetroStationTrack() || node.Info.name == Util.GetMetroStationTrackName(NetInfoVersion.Tunnel, TrackStyle.Vanilla)))
{
if (stationNodeIDs == null)
{
stationNodeIDs = new List<ushort>();
}
stationNodeIDs.Add(nodeID);
}
nodeID = NodeFrom(nodeID).m_nextBuildingNode;
}
return stationNodeIDs;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant