* Gets the tile corresponding to the given encoded index. * * @param id The encoded index to get the tile of. * @return The tile. */
| 150 | * @return The tile. |
| 151 | */ |
| 152 | tile32 Tools_Index_GetTile(uint16 encoded) |
| 153 | { |
| 154 | uint16 index; |
| 155 | tile32 tile; |
| 156 | |
| 157 | index = Tools_Index_Decode(encoded); |
| 158 | tile.x = 0; |
| 159 | tile.y = 0; |
| 160 | |
| 161 | switch (Tools_Index_GetType(encoded)) { |
| 162 | case IT_TILE: return Tile_UnpackTile(index); |
| 163 | case IT_UNIT: return (index < UNIT_INDEX_MAX) ? Unit_Get_ByIndex(index)->o.position : tile; |
| 164 | case IT_STRUCTURE: { |
| 165 | const StructureInfo *si; |
| 166 | Structure *s; |
| 167 | |
| 168 | if (index >= STRUCTURE_INDEX_MAX_HARD) return tile; |
| 169 | |
| 170 | s = Structure_Get_ByIndex(index); |
| 171 | si = &g_table_structureInfo[s->o.type]; |
| 172 | |
| 173 | return Tile_AddTileDiff(s->o.position, g_table_structure_layoutTileDiff[si->layout]); |
| 174 | } |
| 175 | default: return tile; |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | /** |
| 180 | * Gets the Unit corresponding to the given encoded index. |
no test coverage detected