* Update the map with the right data for this structure. * @param s The structure to update on the map. */
| 1777 | * @param s The structure to update on the map. |
| 1778 | */ |
| 1779 | void Structure_UpdateMap(Structure *s) |
| 1780 | { |
| 1781 | const StructureInfo *si; |
| 1782 | uint16 layoutSize; |
| 1783 | const uint16 *layout; |
| 1784 | uint16 *iconMap; |
| 1785 | int i; |
| 1786 | |
| 1787 | if (s == NULL) return; |
| 1788 | if (!s->o.flags.s.used) return; |
| 1789 | if (s->o.flags.s.isNotOnMap) return; |
| 1790 | |
| 1791 | si = &g_table_structureInfo[s->o.type]; |
| 1792 | |
| 1793 | layout = g_table_structure_layoutTiles[si->layout]; |
| 1794 | layoutSize = g_table_structure_layoutTileCount[si->layout]; |
| 1795 | |
| 1796 | iconMap = &g_iconMap[g_iconMap[si->iconGroup] + layoutSize + layoutSize]; |
| 1797 | |
| 1798 | for (i = 0; i < layoutSize; i++) { |
| 1799 | uint16 position; |
| 1800 | Tile *t; |
| 1801 | |
| 1802 | position = Tile_PackTile(s->o.position) + layout[i]; |
| 1803 | |
| 1804 | t = &g_map[position]; |
| 1805 | t->houseID = s->o.houseID; |
| 1806 | t->hasStructure = true; |
| 1807 | t->index = s->o.index + 1; |
| 1808 | |
| 1809 | t->groundTileID = iconMap[i] + s->rotationSpriteDiff; |
| 1810 | |
| 1811 | if (Tile_IsUnveiled(t->overlayTileID)) t->overlayTileID = 0; |
| 1812 | |
| 1813 | Map_Update(position, 0, false); |
| 1814 | } |
| 1815 | |
| 1816 | s->o.flags.s.isDirty = true; |
| 1817 | |
| 1818 | if (s->state >= STRUCTURE_STATE_IDLE) { |
| 1819 | uint16 animationIndex = (s->state > STRUCTURE_STATE_READY) ? STRUCTURE_STATE_READY : s->state; |
| 1820 | |
| 1821 | if (si->animationIndex[animationIndex] == 0xFF) { |
| 1822 | Animation_Start(NULL, s->o.position, si->layout, s->o.houseID, (uint8)si->iconGroup); |
| 1823 | } else { |
| 1824 | uint8 animationID = si->animationIndex[animationIndex]; |
| 1825 | |
| 1826 | assert(animationID < 29); |
| 1827 | Animation_Start(g_table_animation_structure[animationID], s->o.position, si->layout, s->o.houseID, (uint8)si->iconGroup); |
| 1828 | } |
| 1829 | } else { |
| 1830 | Animation_Start(g_table_animation_structure[1], s->o.position, si->layout, s->o.houseID, (uint8)si->iconGroup); |
| 1831 | } |
| 1832 | } |
| 1833 | |
| 1834 | uint32 Structure_GetBuildable(Structure *s) |
| 1835 | { |
no test coverage detected