| 1219 | |
| 1220 | template <typename Tcallback> |
| 1221 | void ExecuteFoundTownCommand(TileIndex tile, bool random, StringID errstr, Tcallback cc) |
| 1222 | { |
| 1223 | std::string name; |
| 1224 | |
| 1225 | if (!this->townnamevalid) { |
| 1226 | name = this->townname_editbox.text.GetText(); |
| 1227 | } else { |
| 1228 | /* If user changed the name, send it */ |
| 1229 | std::string original_name = GetTownName(&this->params, this->townnameparts); |
| 1230 | if (original_name != this->townname_editbox.text.GetText()) name = this->townname_editbox.text.GetText(); |
| 1231 | } |
| 1232 | |
| 1233 | bool success = Command<CMD_FOUND_TOWN>::Post(errstr, cc, |
| 1234 | tile, this->town_size, this->city, this->town_layout, random, townnameparts, name); |
| 1235 | |
| 1236 | /* Rerandomise name, if success and no cost-estimation. */ |
| 1237 | if (success && !_shift_pressed) this->RandomTownName(); |
| 1238 | } |
| 1239 | |
| 1240 | void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override |
| 1241 | { |
no test coverage detected