* Add all new industries to the industry array. Industry properties can be set at any * time in the GRF file, so we can only add a industry spec to the industry array * after the file has finished loading. */
| 1110 | * after the file has finished loading. |
| 1111 | */ |
| 1112 | static void FinaliseIndustriesArray() |
| 1113 | { |
| 1114 | for (auto &file : _grf_files) { |
| 1115 | for (auto &indsp : file.industryspec) { |
| 1116 | if (indsp == nullptr || !indsp->enabled) continue; |
| 1117 | |
| 1118 | _industry_mngr.SetEntitySpec(std::move(*indsp)); |
| 1119 | } |
| 1120 | |
| 1121 | for (auto &indtsp : file.indtspec) { |
| 1122 | if (indtsp != nullptr) { |
| 1123 | _industile_mngr.SetEntitySpec(std::move(*indtsp)); |
| 1124 | } |
| 1125 | } |
| 1126 | |
| 1127 | /* Won't be used again */ |
| 1128 | file.industryspec.clear(); |
| 1129 | file.industryspec.shrink_to_fit(); |
| 1130 | file.indtspec.clear(); |
| 1131 | file.indtspec.shrink_to_fit(); |
| 1132 | } |
| 1133 | |
| 1134 | for (auto &indsp : _industry_specs) { |
| 1135 | if (indsp.enabled && indsp.grf_prop.HasGrfFile()) { |
| 1136 | for (auto &conflicting : indsp.conflicting) { |
| 1137 | conflicting = MapNewGRFIndustryType(conflicting, indsp.grf_prop.grfid); |
| 1138 | } |
| 1139 | } |
| 1140 | if (!indsp.enabled) { |
| 1141 | indsp.name = STR_NEWGRF_INVALID_INDUSTRYTYPE; |
| 1142 | } |
| 1143 | |
| 1144 | /* Apply default cargo translation map for unset cargo slots */ |
| 1145 | for (size_t i = 0; i < std::size(indsp.produced_cargo_label); ++i) { |
| 1146 | if (!IsValidCargoType(indsp.produced_cargo[i])) indsp.produced_cargo[i] = GetCargoTypeByLabel(GetActiveCargoLabel(indsp.produced_cargo_label[i])); |
| 1147 | } |
| 1148 | for (size_t i = 0; i < std::size(indsp.accepts_cargo_label); ++i) { |
| 1149 | if (!IsValidCargoType(indsp.accepts_cargo[i])) indsp.accepts_cargo[i] = GetCargoTypeByLabel(GetActiveCargoLabel(indsp.accepts_cargo_label[i])); |
| 1150 | } |
| 1151 | } |
| 1152 | |
| 1153 | for (auto &indtsp : _industry_tile_specs) { |
| 1154 | /* Apply default cargo translation map for unset cargo slots */ |
| 1155 | for (size_t i = 0; i < std::size(indtsp.accepts_cargo_label); ++i) { |
| 1156 | if (!IsValidCargoType(indtsp.accepts_cargo[i])) indtsp.accepts_cargo[i] = GetCargoTypeByLabel(GetActiveCargoLabel(indtsp.accepts_cargo_label[i])); |
| 1157 | } |
| 1158 | } |
| 1159 | } |
| 1160 | |
| 1161 | /** |
| 1162 | * Add all new objects to the object array. Object properties can be set at any |
no test coverage detected