src/unmovable_cmd.cpp
branchNewGRF_ports
changeset 6877 889301acc299
parent 6872 1c4a4a609f85
child 6878 7d1ff2f621c7
--- a/src/unmovable_cmd.cpp	Sun Feb 03 01:34:21 2008 +0000
+++ b/src/unmovable_cmd.cpp	Sun Feb 03 20:34:26 2008 +0000
@@ -264,8 +264,10 @@
 		return_cmd_error(STR_5800_OBJECT_IN_THE_WAY);
 
 	if (IsStatue(tile)) {
+		if (flags & DC_AUTO) return_cmd_error(STR_5800_OBJECT_IN_THE_WAY);
+
 		TownID town = GetStatueTownID(tile);
-		ClrBit(GetTown(town)->statues, _current_player);
+		ClrBit(GetTown(town)->statues, GetTileOwner(tile));
 		InvalidateWindow(WC_TOWN_AUTHORITY, town);
 	}
 
@@ -447,6 +449,19 @@
 
 	if (IsOwnedLand(tile) && new_player != PLAYER_SPECTATOR) {
 		SetTileOwner(tile, new_player);
+	} else if (IsStatueTile(tile)) {
+		TownID town = GetStatueTownID(tile);
+		Town *t = GetTown(town);
+		ClrBit(t->statues, old_player);
+		if (new_player != PLAYER_SPECTATOR && !HasBit(t->statues, new_player)) {
+			/* Transfer ownership to the new company */
+			SetBit(t->statues, new_player);
+			SetTileOwner(tile, new_player);
+		} else {
+			DoClearSquare(tile);
+		}
+
+		InvalidateWindow(WC_TOWN_AUTHORITY, town);
 	} else {
 		DoClearSquare(tile);
 	}