* Reserves a place in the mapping array for an entity to be installed * @param grf_local_id is an arbitrary id given by the grf's author. Also known as setid * @param grfid is the id of the grf file itself * @param substitute_id is the original entity from which data is copied for the new one * @return the proper usable slot id, or invalid marker if none is found */
| 108 | * @return the proper usable slot id, or invalid marker if none is found |
| 109 | */ |
| 110 | uint16_t OverrideManagerBase::AddEntityID(uint16_t grf_local_id, uint32_t grfid, uint16_t substitute_id) |
| 111 | { |
| 112 | uint16_t id = this->GetID(grf_local_id, grfid); |
| 113 | |
| 114 | /* Look to see if this entity has already been added. This is done |
| 115 | * separately from the loop below in case a GRF has been deleted, and there |
| 116 | * are any gaps in the array. |
| 117 | */ |
| 118 | if (id != this->invalid_id) return id; |
| 119 | |
| 120 | /* This entity hasn't been defined before, so give it an ID now. */ |
| 121 | for (id = this->max_offset; id < this->max_entities; id++) { |
| 122 | EntityIDMapping *map = &this->mappings[id]; |
| 123 | |
| 124 | if (CheckValidNewID(id) && map->entity_id == 0 && map->grfid == 0) { |
| 125 | map->entity_id = grf_local_id; |
| 126 | map->grfid = grfid; |
| 127 | map->substitute_id = substitute_id; |
| 128 | return id; |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | return this->invalid_id; |
| 133 | } |
| 134 | |
| 135 | /** |
| 136 | * Gives the GRFID of the file the entity belongs to. |
no test coverage detected