equal
deleted
inserted
replaced
103 |
103 |
104 /* This entity hasn't been defined before, so give it an ID now. */ |
104 /* This entity hasn't been defined before, so give it an ID now. */ |
105 for (id = max_offset; id < max_new_entities; id++) { |
105 for (id = max_offset; id < max_new_entities; id++) { |
106 map = &mapping_ID[id]; |
106 map = &mapping_ID[id]; |
107 |
107 |
108 if (map->entity_id == 0 && map->grfid == 0) { |
108 if (CheckValidNewID(id) && map->entity_id == 0 && map->grfid == 0) { |
109 map->entity_id = grf_local_id; |
109 map->entity_id = grf_local_id; |
110 map->grfid = grfid; |
110 map->grfid = grfid; |
111 map->substitute_id = substitute_id; |
111 map->substitute_id = substitute_id; |
112 return id; |
112 return id; |
113 } |
113 } |
186 /** Method to install the new indistry data in its proper slot |
186 /** Method to install the new indistry data in its proper slot |
187 * The slot assigment is internal of this method, since it requires |
187 * The slot assigment is internal of this method, since it requires |
188 * checking what is available |
188 * checking what is available |
189 * @param inds Industryspec that comes from the grf decoding process |
189 * @param inds Industryspec that comes from the grf decoding process |
190 */ |
190 */ |
191 void IndustryOverrideManager::SetEntitySpec(const IndustrySpec *inds) |
191 void IndustryOverrideManager::SetEntitySpec(IndustrySpec *inds) |
192 { |
192 { |
193 /* First step : We need to find if this industry is already specified in the savegame data */ |
193 /* First step : We need to find if this industry is already specified in the savegame data */ |
194 IndustryType ind_id = this->GetID(inds->grf_prop.local_id, inds->grf_prop.grffile->grfid); |
194 IndustryType ind_id = this->GetID(inds->grf_prop.local_id, inds->grf_prop.grffile->grfid); |
195 |
195 |
196 if (ind_id == invalid_ID) { // not found? So this is the introduction of a new industry |
196 if (ind_id == invalid_ID) { // not found? So this is the introduction of a new industry |
204 } else { |
204 } else { |
205 /* It has already been overriden, so you've lost your place old boy. |
205 /* It has already been overriden, so you've lost your place old boy. |
206 * Or it is a simple substitute. |
206 * Or it is a simple substitute. |
207 * In both case, we need to find a free available slot */ |
207 * In both case, we need to find a free available slot */ |
208 ind_id = this->AddEntityID(inds->grf_prop.local_id, inds->grf_prop.grffile->grfid, inds->grf_prop.subst_id); |
208 ind_id = this->AddEntityID(inds->grf_prop.local_id, inds->grf_prop.grffile->grfid, inds->grf_prop.subst_id); |
|
209 inds->grf_prop.override = invalid_ID; // make sure it will not be detected as overriden |
209 } |
210 } |
210 } |
211 } |
211 |
212 |
212 if (ind_id == invalid_ID) { |
213 if (ind_id == invalid_ID) { |
213 grfmsg(1, "Industry.SetEntitySpec: Too many industries allocated. Ignoring."); |
214 grfmsg(1, "Industry.SetEntitySpec: Too many industries allocated. Ignoring."); |