MCPcopy Create free account
hub / github.com/OpenDUNE/OpenDUNE / Tools_Index_GetTile

Function Tools_Index_GetTile

src/tools.c:152–177  ·  view source on GitHub ↗

* Gets the tile corresponding to the given encoded index. * * @param id The encoded index to get the tile of. * @return The tile. */

Source from the content-addressed store, hash-verified

150 * @return The tile.
151 */
152tile32 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.

Callers 15

GameLoop_UnitFunction · 0.85
Unit_FindBestTargetUnitFunction · 0.85
Unit_MoveFunction · 0.85
Unit_CreateBulletFunction · 0.85
Script_Structure_FireFunction · 0.85
Script_Team_Unknown0543Function · 0.85
Script_Team_Unknown0788Function · 0.85

Calls 6

Tools_Index_DecodeFunction · 0.85
Tools_Index_GetTypeFunction · 0.85
Tile_UnpackTileFunction · 0.85
Unit_Get_ByIndexFunction · 0.85
Structure_Get_ByIndexFunction · 0.85
Tile_AddTileDiffFunction · 0.85

Tested by

no test coverage detected