| 136 | } |
| 137 | |
| 138 | void OnInit() override |
| 139 | { |
| 140 | Town *t = ClosestTownFromTile(tile, _settings_game.economy.dist_local_authority); |
| 141 | |
| 142 | TileDesc td{}; |
| 143 | td.owner_type[0] = STR_LAND_AREA_INFORMATION_OWNER; // At least one owner is displayed, though it might be "N/A". |
| 144 | |
| 145 | CargoArray acceptance{}; |
| 146 | AddAcceptedCargo(tile, acceptance, nullptr); |
| 147 | GetTileDesc(tile, td); |
| 148 | |
| 149 | this->landinfo_data.clear(); |
| 150 | |
| 151 | /* Tiletype */ |
| 152 | this->landinfo_data.push_back(GetString(td.str, td.dparam)); |
| 153 | |
| 154 | /* Up to four owners */ |
| 155 | for (uint i = 0; i < 4; i++) { |
| 156 | if (td.owner_type[i] == STR_NULL) continue; |
| 157 | |
| 158 | if (td.owner[i] == OWNER_NONE || td.owner[i] == OWNER_WATER) { |
| 159 | this->landinfo_data.push_back(GetString(td.owner_type[i], STR_LAND_AREA_INFORMATION_OWNER_N_A, std::monostate{})); |
| 160 | } else { |
| 161 | auto params = GetParamsForOwnedBy(td.owner[i], tile); |
| 162 | this->landinfo_data.push_back(GetStringWithArgs(td.owner_type[i], params)); |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | /* Cost to clear/revenue when cleared */ |
| 167 | Company *c = Company::GetIfValid(_local_company); |
| 168 | if (c != nullptr) { |
| 169 | assert(_current_company == _local_company); |
| 170 | CommandCost costclear = Command<CMD_LANDSCAPE_CLEAR>::Do(DoCommandFlag::QueryCost, tile); |
| 171 | if (costclear.Succeeded()) { |
| 172 | Money cost = costclear.GetCost(); |
| 173 | StringID str; |
| 174 | if (cost < 0) { |
| 175 | cost = -cost; // Negate negative cost to a positive revenue |
| 176 | str = STR_LAND_AREA_INFORMATION_REVENUE_WHEN_CLEARED; |
| 177 | } else { |
| 178 | str = STR_LAND_AREA_INFORMATION_COST_TO_CLEAR; |
| 179 | } |
| 180 | this->landinfo_data.push_back(GetString(str, cost)); |
| 181 | } else { |
| 182 | this->landinfo_data.push_back(GetString(STR_LAND_AREA_INFORMATION_COST_TO_CLEAR_N_A)); |
| 183 | } |
| 184 | } else { |
| 185 | this->landinfo_data.push_back(GetString(STR_LAND_AREA_INFORMATION_COST_TO_CLEAR_N_A)); |
| 186 | } |
| 187 | |
| 188 | /* Location */ |
| 189 | this->landinfo_data.push_back(GetString(STR_LAND_AREA_INFORMATION_LANDINFO_COORDS, TileX(tile), TileY(tile), GetTileZ(tile))); |
| 190 | |
| 191 | /* Tile index */ |
| 192 | this->landinfo_data.push_back(GetString(STR_LAND_AREA_INFORMATION_LANDINFO_INDEX, tile, tile)); |
| 193 | |
| 194 | /* Local authority */ |
| 195 | if (t == nullptr) { |
nothing calls this directly
no test coverage detected