In remove city by using tool_remove_t or change city size by using tool_change_city_size_t, the city is found by using find_nearest_city(koord).
However, this method can find wrong city, expecially when the more than one cities are overlapped.
So, I propose that we get the city not use position but check the building's city.
//tool_remover_t::tool_remover_intern()
if(gb->is_townhall()) {
stadt_t *stadt = gb->get_stadt();
if(!welt->remove_city( stadt )) {
msg = "Das Feld gehoert\neinem anderen Spieler\n";
return false;
}
}
//tool_change_city_size_t::work()
stadt_t *city=NULL;
// if there is the townhall at this position, we change this city size.
if( grund_t *gr = welt->lookup(pos) ) {
if( gebaeude_t *gb = gr->find<gebaeude_t>() ) {
if( gb->is_townhall() ) {
city = gb->get_stadt();
}
}
}
if( city==NULL ) {
// if no townhall, we find nearest city.
city = welt->find_nearest_city(pos.get_2d());
}
Very sensible idea. The town deletion code predated the existence of a city pointer with hosues ...
Incorporated in r11869
Thank you!
But it does not work in r11869
simtool.cc l1976 should be change:
- if(!city) {
+ if(city) {