| 1832 | } |
| 1833 | |
| 1834 | uint32 Structure_GetBuildable(Structure *s) |
| 1835 | { |
| 1836 | const StructureInfo *si; |
| 1837 | uint32 structuresBuilt; |
| 1838 | uint32 ret = 0; |
| 1839 | int i; |
| 1840 | |
| 1841 | if (s == NULL) return 0; |
| 1842 | |
| 1843 | si = &g_table_structureInfo[s->o.type]; |
| 1844 | |
| 1845 | structuresBuilt = House_Get_ByIndex(s->o.houseID)->structuresBuilt; |
| 1846 | |
| 1847 | switch (s->o.type) { |
| 1848 | case STRUCTURE_LIGHT_VEHICLE: |
| 1849 | case STRUCTURE_HEAVY_VEHICLE: |
| 1850 | case STRUCTURE_HIGH_TECH: |
| 1851 | case STRUCTURE_WOR_TROOPER: |
| 1852 | case STRUCTURE_BARRACKS: |
| 1853 | for (i = 0; i < UNIT_MAX; i++) { |
| 1854 | g_table_unitInfo[i].o.available = 0; |
| 1855 | } |
| 1856 | |
| 1857 | for (i = 0; i < 8; i++) { |
| 1858 | UnitInfo *ui; |
| 1859 | uint16 upgradeLevelRequired; |
| 1860 | uint8 unitType = si->buildableUnits[i]; |
| 1861 | |
| 1862 | if (unitType == UNIT_INVALID) continue; |
| 1863 | |
| 1864 | if (unitType == UNIT_TRIKE && s->creatorHouseID == HOUSE_ORDOS) unitType = UNIT_RAIDER_TRIKE; |
| 1865 | |
| 1866 | ui = &g_table_unitInfo[unitType]; |
| 1867 | upgradeLevelRequired = ui->o.upgradeLevelRequired; |
| 1868 | |
| 1869 | if (unitType == UNIT_SIEGE_TANK && s->creatorHouseID == HOUSE_ORDOS) upgradeLevelRequired--; |
| 1870 | |
| 1871 | if ((structuresBuilt & ui->o.structuresRequired) != ui->o.structuresRequired) continue; |
| 1872 | if ((ui->o.availableHouse & (1 << s->creatorHouseID)) == 0) continue; |
| 1873 | |
| 1874 | if (s->upgradeLevel >= upgradeLevelRequired) { |
| 1875 | ui->o.available = 1; |
| 1876 | |
| 1877 | ret |= (1 << unitType); |
| 1878 | continue; |
| 1879 | } |
| 1880 | |
| 1881 | if (s->upgradeTimeLeft != 0 && s->upgradeLevel + 1 >= upgradeLevelRequired) { |
| 1882 | ui->o.available = -1; |
| 1883 | } |
| 1884 | } |
| 1885 | return ret; |
| 1886 | |
| 1887 | case STRUCTURE_CONSTRUCTION_YARD: |
| 1888 | for (i = 0; i < STRUCTURE_MAX; i++) { |
| 1889 | StructureInfo *localsi = &g_table_structureInfo[i]; |
| 1890 | uint16 availableCampaign; |
| 1891 | uint32 structuresRequired; |
no test coverage detected