- Fixed TfrmMain.SetCurrentTile to exit only under correct conditions
- Fixed ghost tile creation to handle random height - Changed UpdateSelection to only process the selection changes if necessary - Changed TMapCell.GhostZ to be readable (necessary for simplier increase with random altitude)
This commit is contained in:
		
							parent
							
								
									211866d6c1
								
							
						
					
					
						commit
						20747a4e0c
					
				| @ -1639,7 +1639,7 @@ end; | |||||||
| 
 | 
 | ||||||
| procedure TfrmMain.SetCurrentTile(const AValue: TWorldItem); | procedure TfrmMain.SetCurrentTile(const AValue: TWorldItem); | ||||||
| begin | begin | ||||||
|   if AValue = FSelectedTile then |   if AValue = FCurrentTile then | ||||||
|     Exit; |     Exit; | ||||||
| 
 | 
 | ||||||
|   if FCurrentTile <> nil then |   if FCurrentTile <> nil then | ||||||
| @ -2318,6 +2318,8 @@ procedure TfrmMain.UpdateSelection; | |||||||
|             cell.GhostZ := frmDrawSettings.seForceAltitude.Value |             cell.GhostZ := frmDrawSettings.seForceAltitude.Value | ||||||
|           else |           else | ||||||
|             cell.GhostZ := cell.RawZ; |             cell.GhostZ := cell.RawZ; | ||||||
|  |           if frmDrawSettings.cbRandomHeight.Checked then | ||||||
|  |             cell.GhostZ := cell.GhostZ + Random(frmDrawSettings.seRandomHeight.Value); | ||||||
| 
 | 
 | ||||||
|           OnMapChanged(cell); |           OnMapChanged(cell); | ||||||
|         end; |         end; | ||||||
| @ -2336,6 +2338,9 @@ procedure TfrmMain.UpdateSelection; | |||||||
|               ResMan.Tiledata.StaticTiles[ABaseTile.TileID].Height; |               ResMan.Tiledata.StaticTiles[ABaseTile.TileID].Height; | ||||||
|         end else |         end else | ||||||
|           ghostTile.Z := frmDrawSettings.seForceAltitude.Value; |           ghostTile.Z := frmDrawSettings.seForceAltitude.Value; | ||||||
|  |         if frmDrawSettings.cbRandomHeight.Checked then | ||||||
|  |           ghostTile.Z := ghostTile.Z + | ||||||
|  |             Random(frmDrawSettings.seRandomHeight.Value); | ||||||
| 
 | 
 | ||||||
|         ghostTile.UpdatePriorities(ResMan.Tiledata.StaticTiles[ghostTile.TileID], |         ghostTile.UpdatePriorities(ResMan.Tiledata.StaticTiles[ghostTile.TileID], | ||||||
|           MaxInt); |           MaxInt); | ||||||
| @ -2357,64 +2362,70 @@ var | |||||||
|   i, tileX, tileY: Integer; |   i, tileX, tileY: Integer; | ||||||
| begin | begin | ||||||
|   Logger.EnterMethod([lcClient, lcDebug], 'UpdateSelection'); |   Logger.EnterMethod([lcClient, lcDebug], 'UpdateSelection'); | ||||||
|   if CurrentTile = nil then |  | ||||||
|     selectedRect := Rect(-1, -1, -1, -1) |  | ||||||
|   else |  | ||||||
|     selectedRect := GetSelectedRect; |  | ||||||
| 
 | 
 | ||||||
|   //clean up old ghost tiles |   //If the current tile is nil, but we still have a selected tile, the | ||||||
|   Logger.Send([lcClient, lcDebug], 'Cleaning ghost tiles'); |   //procedure is pointless - the selection should stay intact. | ||||||
|   for i := FVirtualTiles.Count - 1 downto 0 do |   if (CurrentTile <> nil) or (SelectedTile = nil) then | ||||||
|   begin |   begin | ||||||
|     item := FVirtualTiles[i]; |     if CurrentTile = nil then | ||||||
|     if (item is TGhostTile) and not IsInRect(item.X, item.Y, selectedRect) then |       selectedRect := Rect(-1, -1, -1, -1) | ||||||
|  |     else | ||||||
|  |       selectedRect := GetSelectedRect; | ||||||
|  | 
 | ||||||
|  |     //clean up old ghost tiles | ||||||
|  |     Logger.Send([lcClient, lcDebug], 'Cleaning ghost tiles'); | ||||||
|  |     for i := FVirtualTiles.Count - 1 downto 0 do | ||||||
|     begin |     begin | ||||||
|       FScreenBuffer.Delete(item); |       item := FVirtualTiles[i]; | ||||||
|       FVirtualTiles.Delete(i); |       if (item is TGhostTile) and not IsInRect(item.X, item.Y, selectedRect) then | ||||||
|     end; |  | ||||||
|   end; |  | ||||||
|   Logger.Send([lcClient, lcDebug], 'FSelection', FSelection); |  | ||||||
|   for tileX := FSelection.Left to FSelection.Right do |  | ||||||
|     for tileY := FSelection.Top to FSelection.Bottom do |  | ||||||
|       if not IsInRect(tileX, tileY, selectedRect) then |  | ||||||
|       begin |       begin | ||||||
|         cell := FLandscape.MapCell[tileX, tileY]; |         FScreenBuffer.Delete(item); | ||||||
|         if (cell <> nil) and cell.IsGhost then |         FVirtualTiles.Delete(i); | ||||||
|         begin |  | ||||||
|           cell.IsGhost := False; |  | ||||||
|           OnMapChanged(cell); |  | ||||||
|         end; |  | ||||||
|       end; |       end; | ||||||
| 
 |  | ||||||
|   if (CurrentTile <> nil) and (not acSelect.Checked) then |  | ||||||
|   begin |  | ||||||
|     blockInfo := nil; |  | ||||||
|     if (SelectedTile <> nil) and (CurrentTile <> SelectedTile) then |  | ||||||
|     begin |  | ||||||
|       Logger.Send([lcClient, lcDebug], 'Multiple Targets'); |  | ||||||
|       Logger.Send([lcClient, lcDebug], 'SelectedRect', selectedRect); |  | ||||||
|       //set new ghost tiles |  | ||||||
|       if acDraw.Checked then |  | ||||||
|         for tileX := selectedRect.Left to selectedRect.Right do |  | ||||||
|           for tileY := selectedRect.Top to selectedRect.Bottom do |  | ||||||
|             if not IsInRect(tileX, tileY, FSelection) then |  | ||||||
|               AddGhostTile(tileX, tileY, SelectedTile); |  | ||||||
|       while FScreenBuffer.Iterate(blockInfo) do |  | ||||||
|         if (blockInfo^.State = ssNormal) then |  | ||||||
|           SetHighlight(blockInfo, IsInRect(blockInfo^.Item.X, blockInfo^.Item.Y, |  | ||||||
|             selectedRect) and not acDraw.Checked); |  | ||||||
|     end else |  | ||||||
|     begin |  | ||||||
|       Logger.Send([lcClient, lcDebug], 'Single Target'); |  | ||||||
|       if acDraw.Checked then |  | ||||||
|         AddGhostTile(CurrentTile.X, CurrentTile.Y, CurrentTile); |  | ||||||
|       while FScreenBuffer.Iterate(blockInfo) do |  | ||||||
|         if blockInfo^.State = ssNormal then |  | ||||||
|           SetHighlight(blockInfo, (blockInfo^.Item = CurrentTile) and |  | ||||||
|             not acDraw.Checked); |  | ||||||
|     end; |     end; | ||||||
|  |     Logger.Send([lcClient, lcDebug], 'FSelection', FSelection); | ||||||
|  |     for tileX := FSelection.Left to FSelection.Right do | ||||||
|  |       for tileY := FSelection.Top to FSelection.Bottom do | ||||||
|  |         if not IsInRect(tileX, tileY, selectedRect) then | ||||||
|  |         begin | ||||||
|  |           cell := FLandscape.MapCell[tileX, tileY]; | ||||||
|  |           if (cell <> nil) and cell.IsGhost then | ||||||
|  |           begin | ||||||
|  |             cell.IsGhost := False; | ||||||
|  |             OnMapChanged(cell); | ||||||
|  |           end; | ||||||
|  |         end; | ||||||
|  | 
 | ||||||
|  |     if (CurrentTile <> nil) and (not acSelect.Checked) then | ||||||
|  |     begin | ||||||
|  |       blockInfo := nil; | ||||||
|  |       if (SelectedTile <> nil) and (CurrentTile <> SelectedTile) then | ||||||
|  |       begin | ||||||
|  |         Logger.Send([lcClient, lcDebug], 'Multiple Targets'); | ||||||
|  |         Logger.Send([lcClient, lcDebug], 'SelectedRect', selectedRect); | ||||||
|  |         //set new ghost tiles | ||||||
|  |         if acDraw.Checked then | ||||||
|  |           for tileX := selectedRect.Left to selectedRect.Right do | ||||||
|  |             for tileY := selectedRect.Top to selectedRect.Bottom do | ||||||
|  |               if not IsInRect(tileX, tileY, FSelection) then | ||||||
|  |                 AddGhostTile(tileX, tileY, SelectedTile); | ||||||
|  |         while FScreenBuffer.Iterate(blockInfo) do | ||||||
|  |           if (blockInfo^.State = ssNormal) then | ||||||
|  |             SetHighlight(blockInfo, IsInRect(blockInfo^.Item.X, blockInfo^.Item.Y, | ||||||
|  |               selectedRect) and not acDraw.Checked); | ||||||
|  |       end else | ||||||
|  |       begin | ||||||
|  |         Logger.Send([lcClient, lcDebug], 'Single Target'); | ||||||
|  |         if acDraw.Checked then | ||||||
|  |           AddGhostTile(CurrentTile.X, CurrentTile.Y, CurrentTile); | ||||||
|  |         while FScreenBuffer.Iterate(blockInfo) do | ||||||
|  |           if blockInfo^.State = ssNormal then | ||||||
|  |             SetHighlight(blockInfo, (blockInfo^.Item = CurrentTile) and | ||||||
|  |               not acDraw.Checked); | ||||||
|  |       end; | ||||||
|  |     end; | ||||||
|  |     FSelection := selectedRect; | ||||||
|   end; |   end; | ||||||
|   FSelection := selectedRect; |  | ||||||
|   Logger.ExitMethod([lcClient, lcDebug], 'UpdateSelection'); |   Logger.ExitMethod([lcClient, lcDebug], 'UpdateSelection'); | ||||||
| end; | end; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -52,7 +52,7 @@ type | |||||||
|   public |   public | ||||||
|     property Altitude: ShortInt read GetZ write SetZ; |     property Altitude: ShortInt read GetZ write SetZ; | ||||||
|     property IsGhost: Boolean read FIsGhost write FIsGhost; |     property IsGhost: Boolean read FIsGhost write FIsGhost; | ||||||
|     property GhostZ: ShortInt write FGhostZ; |     property GhostZ: ShortInt read FGhostZ write FGhostZ; | ||||||
|     property GhostID: Word write FGhostID; |     property GhostID: Word write FGhostID; | ||||||
| 
 | 
 | ||||||
|     function Clone: TMapCell; override; |     function Clone: TMapCell; override; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user