@@ -804,6 +804,13 @@ void GamePlayer::ToolOrderProcessed(Tool tool)
804804
805805bool GamePlayer::FindWarehouseForJob (const Job job, noRoadNode& goal) const
806806{
807+ // Optimization: return early if building is isolated
808+ if (goal.GetType () == NodalObjectType::Building || goal.GetType () == NodalObjectType::Buildingsite)
809+ {
810+ if (!static_cast <noBaseBuilding&>(goal).IsConnected ())
811+ return false ;
812+ }
813+
807814 nobBaseWarehouse* wh = FindWarehouse (goal, FW::HasFigure (job, true ), false , false );
808815
809816 if (wh)
@@ -1026,6 +1033,10 @@ noBaseBuilding* GamePlayer::FindClientForWare(const Ware& ware)
10261033 // Bei Baustellen die Extraliste abfragen
10271034 for (noBuildingSite* bldSite : buildings.GetBuildingSites ())
10281035 {
1036+ // Optimization: Ignore if unconnected
1037+ if (!bldSite->IsConnected ())
1038+ continue ;
1039+
10291040 unsigned points = bldSite->CalcDistributionPoints (gt);
10301041 if (!points)
10311042 continue ;
@@ -1039,6 +1050,10 @@ noBaseBuilding* GamePlayer::FindClientForWare(const Ware& ware)
10391050 // Für übrige Gebäude
10401051 for (nobUsual* bld : buildings.GetBuildings (bldType))
10411052 {
1053+ // Optimization: Ignore if unconnected
1054+ if (!bld->IsConnected ())
1055+ continue ;
1056+
10421057 unsigned points = bld->CalcDistributionPoints (gt);
10431058 if (!points)
10441059 continue ; // Ware not needed
@@ -1140,12 +1155,16 @@ nobBaseMilitary* GamePlayer::FindClientForCoin(const Ware& ware) const
11401155 // Militärgebäude durchgehen
11411156 for (nobMilitary* milBld : buildings.GetMilitaryBuildings ())
11421157 {
1143- unsigned way_points;
1158+ // Optimization: Ignore if unconnected
1159+ if (!milBld->IsConnected ())
1160+ continue ;
11441161
11451162 points = milBld->CalcCoinsPoints ();
11461163 // Wenn 0, will er gar keine Münzen (Goldzufuhr gestoppt)
11471164 if (points)
11481165 {
1166+ unsigned way_points;
1167+
11491168 // Weg dorthin berechnen
11501169 if (world.FindPathForWareOnRoads (*ware.GetLocation (), *milBld, &way_points) != RoadPathDirection::None)
11511170 {
0 commit comments