From 2c1a7c1ff30224d05eaa19d25c9687fe1a4a233d Mon Sep 17 00:00:00 2001
From: jsalmon3 <>
Date: Sat, 26 Apr 2003 04:39:35 +0000
Subject: [PATCH] Make sure all tiles are explored when building a building

---
 src/ui/mouse.cpp | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/ui/mouse.cpp b/src/ui/mouse.cpp
index c972fdf94..3dcce55c1 100644
--- a/src/ui/mouse.cpp
+++ b/src/ui/mouse.cpp
@@ -1344,15 +1344,25 @@ global void UIHandleButtonDown(unsigned button)
 	    if( Selected[0] && (MouseButtons&LeftButton) ) {// enter select mode
 		int x;
 		int y;
+		int i;
+		int j;
+		int explored;
 
-		x = Viewport2MapX(TheUI.MouseViewport, CursorX);
-		y = Viewport2MapY(TheUI.MouseViewport, CursorY);
+		x=Viewport2MapX(TheUI.MouseViewport,CursorX);
+		y=Viewport2MapY(TheUI.MouseViewport,CursorY);
 		// FIXME: error messages
 
+		explored=1;
+		for( j=0; explored && j<Selected[0]->Type->Height; ++j ) {
+		    for( i=0; i<Selected[0]->Type->Width; ++i ) {
+			if( !IsMapFieldExplored(ThisPlayer,x+i,y+j) ) {
+			    explored=0;
+			    break;
+			}
+		    }
+		}
 		if( CanBuildUnitType(Selected[0],CursorBuilding,x,y)
-			// FIXME: vladi: should check all building footprint
-			// but not just MAPEXPLORED(x,y)
-			&& (IsMapFieldExplored(ThisPlayer,x,y) || ReplayRevealMap) ) {
+			&& (explored || ReplayRevealMap) ) {
 		    PlayGameSound(GameSounds.PlacementSuccess.Sound
 			    ,MaxSampleVolume);
 		    SendCommandBuildBuilding(Selected[0],x,y,CursorBuilding