| 866 | } |
| 867 | |
| 868 | static void ChangeTileOwner_Object(TileIndex tile, Owner old_owner, Owner new_owner) |
| 869 | { |
| 870 | if (!IsTileOwner(tile, old_owner)) return; |
| 871 | |
| 872 | bool do_clear = false; |
| 873 | |
| 874 | ObjectType type = GetObjectType(tile); |
| 875 | if ((type == OBJECT_OWNED_LAND || type >= NEW_OBJECT_OFFSET) && new_owner != INVALID_OWNER) { |
| 876 | SetTileOwner(tile, new_owner); |
| 877 | if (GetWaterClass(tile) == WaterClass::Canal) { |
| 878 | Company::Get(old_owner)->infrastructure.water--; |
| 879 | Company::Get(new_owner)->infrastructure.water++; |
| 880 | } |
| 881 | } else if (type == OBJECT_STATUE) { |
| 882 | Town *t = Object::GetByTile(tile)->town; |
| 883 | t->statues.Reset(old_owner); |
| 884 | if (new_owner != INVALID_OWNER && !t->statues.Test(new_owner)) { |
| 885 | /* Transfer ownership to the new company */ |
| 886 | t->statues.Set(new_owner); |
| 887 | SetTileOwner(tile, new_owner); |
| 888 | } else { |
| 889 | do_clear = true; |
| 890 | } |
| 891 | |
| 892 | SetWindowDirty(WC_TOWN_AUTHORITY, t->index); |
| 893 | } else { |
| 894 | do_clear = true; |
| 895 | } |
| 896 | |
| 897 | if (do_clear) { |
| 898 | ReallyClearObjectTile(Object::GetByTile(tile)); |
| 899 | /* When clearing objects, they may turn into canal, which may require transferring ownership. */ |
| 900 | ChangeTileOwner(tile, old_owner, new_owner); |
| 901 | } |
| 902 | } |
| 903 | |
| 904 | static CommandCost TerraformTile_Object(TileIndex tile, DoCommandFlags flags, int z_new, Slope tileh_new) |
| 905 | { |
nothing calls this directly
no test coverage detected