MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / ExecuteFoundTownCommand

Method ExecuteFoundTownCommand

src/town_gui.cpp:1221–1238  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers 2

OnClickMethod · 0.95
OnPlaceObjectMethod · 0.95

Calls 3

RandomTownNameMethod · 0.95
GetTownNameFunction · 0.85
GetTextMethod · 0.45

Tested by

no test coverage detected