diff --git a/Client/CentrED.lpi b/Client/CentrED.lpi
index 5c1612f..6ff2e7a 100644
--- a/Client/CentrED.lpi
+++ b/Client/CentrED.lpi
@@ -4,6 +4,7 @@
+
diff --git a/Client/CentrED.lpr b/Client/CentrED.lpr
index ab2b16e..638b39b 100644
--- a/Client/CentrED.lpr
+++ b/Client/CentrED.lpr
@@ -33,17 +33,7 @@ uses
{$ENDIF}{$ENDIF}
SysUtils,
Interfaces, // this includes the LCL widgetset
- Forms, LResources, lnetvisual, LazOpenGLContext, UdmNetwork, UfrmMain,
- UfrmLogin, UfrmInitialize, UfrmAccountControl, virtualtreeview_package,
- multiloglaz, UfrmEditAccount, UfrmDrawSettings, UfrmBoundaries,
- UfrmElevateSettings, UOverlayUI, UResourceManager, UfrmConfirmation,
- UfrmMoveSettings, UfrmAbout, UfrmHueSettings, UfrmRadar,
- UfrmLargeScaleCommand, UfrmVirtualLayer, UfrmFilter,
- UGUIPlatformUtils, UPlatformTypes, UfrmRegionControl, UPackets,
- UPacketHandlers, UAdminHandling, UGameResources, ULandscape, UfrmToolWindow,
- Logging, UTileDataProvider, UMap, UWorldItem, UStatics, UTiledata, UAnimData,
- UGLFont, UAnimDataProvider, UMulManager, UArtProvider, UTexmapProvider,
-ULightManager, ULight, ULightProvider;
+ Forms, LResources, UdmNetwork;
{$IFDEF WINDOWS}{$R CentrED.rc}{$ENDIF}
diff --git a/Client/ULightManager.pas b/Client/ULightManager.pas
index 6add2ec..185519c 100644
--- a/Client/ULightManager.pas
+++ b/Client/ULightManager.pas
@@ -69,12 +69,12 @@ type
protected
FX: Integer;
FY: Integer;
- FZ: smallint;
+ FZ: SmallInt;
FMaterial: TLightMaterial;
public
property X: Integer read FX;
property Y: Integer read FY;
- property Z: smallint read FZ;
+ property Z: SmallInt read FZ;
property Material: TLightMaterial read FMaterial;
end;
@@ -89,13 +89,15 @@ type
FLightSources: TLightSources;
FOverlay: TSingleImage;
FOverlayTexture: GLuint;
- FLightLevel: byte;
+ FLightLevel: Byte;
FValid: Boolean;
FCalculateOffset: TCalculateOffset;
FLightCache: TLightCache;
function GetLight(AID: Integer): TLightMaterial;
+ procedure SetLightLevel(AValue: Byte);
procedure UpdateOverlay(AScreenRect: TRect);
public
+ property LightLevel: Byte read FLightLevel write SetLightLevel;
procedure UpdateLightMap(ALeft, AWidth, ATop, AHeight: Integer;
AScreenBuffer: TScreenBuffer);
procedure Draw(AScreenRect: TRect);
@@ -112,7 +114,7 @@ constructor TLightManager.Create(ACalculateOffset: TCalculateOffset);
begin
FCalculateOffset := ACalculateOffset;
FLightSources := TLightSources.Create(True);
- FLightLevel := 15; //TODO : 0 ...
+ FLightLevel := 0;
FLightCache := TLightCache.Create(32);
end;
@@ -142,6 +144,12 @@ begin
end;
end;
+procedure TLightManager.SetLightLevel(AValue: Byte);
+begin
+ FLightLevel := AValue;
+ FValid := False;
+end;
+
procedure TLightManager.UpdateOverlay(AScreenRect: TRect);
var
canvas, lightCanvas: TFastARGB32Canvas;
@@ -153,12 +161,12 @@ begin
glDeleteTextures(1, @FOverlayTexture);
color.A := $FF;
- color.R := ((32 - FLightLevel) * 255) div 32;
+ color.R := ((32 - FLightLevel) * 255) div 32;
color.G := color.R;
color.B := color.R;
- FOverlay := TSingleImage.CreateFromParams(AScreenRect.Right, AScreenRect.Bottom,
- ifA8R8G8B8);
+ FOverlay := TSingleImage.CreateFromParams(AScreenRect.Right,
+ AScreenRect.Bottom, ifA8R8G8B8);
canvas := TFastARGB32Canvas.CreateForImage(FOverlay);
try
canvas.FillColor32 := color.Color;
@@ -223,9 +231,10 @@ begin
if lightMap[x, y] <> nil then
begin
if ((itemMap[x, y] = nil) or (itemMap[x, y].Z < lightMap[x, y].Z + 3)) or
- ((itemMap[x + 1, y] = nil) or (itemMap[x + 1, y].Z < lightMap[x, y].Z + 3)) or
- ((itemMap[x + 1, y + 1] = nil) or (itemMap[x + 1, y + 1].Z < lightMap[x, y].Z + 3)) or
- ((itemMap[x, y + 1] = nil) or (itemMap[x, y + 1].Z < lightMap[x, y].Z + 3)) then
+ ((itemMap[x + 1, y] = nil) or (itemMap[x + 1, y].Z < lightMap[x, y].Z + 3)) or
+ ((itemMap[x + 1, y + 1] = nil) or (itemMap[x + 1, y + 1].Z <
+ lightMap[x, y].Z + 3)) or ((itemMap[x, y + 1] = nil) or
+ (itemMap[x, y + 1].Z < lightMap[x, y].Z + 3)) then
begin
FLightSources.Add(TLightSource.Create(Self, lightMap[x, y]));
end;
@@ -242,14 +251,14 @@ begin
glBindTexture(GL_TEXTURE_2D, FOverlayTexture);
glBlendFunc(GL_ZERO, GL_SRC_COLOR);
glBegin(GL_QUADS);
- glTexCoord2i(0, 0);
- glVertex2i(AScreenRect.Left, AScreenRect.Top);
- glTexCoord2i(0, 1);
- glVertex2i(AScreenRect.Left, AScreenRect.Bottom);
- glTexCoord2i(1, 1);
- glVertex2i(AScreenRect.Right, AScreenRect.Bottom);
- glTexCoord2i(1, 0);
- glVertex2i(AScreenRect.Right, AScreenRect.Top);
+ glTexCoord2i(0, 0);
+ glVertex2i(AScreenRect.Left, AScreenRect.Top);
+ glTexCoord2i(0, 1);
+ glVertex2i(AScreenRect.Left, AScreenRect.Bottom);
+ glTexCoord2i(1, 1);
+ glVertex2i(AScreenRect.Right, AScreenRect.Bottom);
+ glTexCoord2i(1, 0);
+ glVertex2i(AScreenRect.Right, AScreenRect.Top);
glEnd;
end;
diff --git a/Client/UfrmMain.pas b/Client/UfrmMain.pas
index 40cfd5a..08465cd 100644
--- a/Client/UfrmMain.pas
+++ b/Client/UfrmMain.pas
@@ -2389,7 +2389,8 @@ begin
blockInfo^.Text.Render(blockInfo^.ScreenRect);
end;
- FLightManager.Draw(oglGameWindow.ClientRect);
+ if (FLightManager.LightLevel > 0) and not acFlat.Checked then
+ FLightManager.Draw(oglGameWindow.ClientRect);
FOverlayUI.Draw(oglGameWindow);
end;
@@ -2435,7 +2436,7 @@ end;
procedure TfrmMain.OnMapChanged(AMapCell: TMapCell);
begin
PrepareMapCell(AMapCell);
- ForceUpdateCurrentTile;
+ InvalidateFilter;
end;
procedure TfrmMain.OnNewBlock(ABlock: TBlock);
@@ -2461,8 +2462,7 @@ begin
begin
PrepareScreenBlock(blockInfo);
Exclude(FScreenBufferState, sbsIndexed);
-
- ForceUpdateCurrentTile;
+ InvalidateFilter;
end;
end;
@@ -2477,6 +2477,7 @@ begin
begin
PrepareScreenBlock(blockInfo);
FRepaintNeeded := True;
+ InvalidateFilter;
Break;
end;
end;
@@ -2492,7 +2493,7 @@ begin
AStaticItem.PrioritySolver := FScreenBuffer.GetSerial;
PrepareScreenBlock(FScreenBuffer.Insert(AStaticItem));
FRepaintNeeded := True;
- ForceUpdateCurrentTile;
+ InvalidateFilter;
end;
end;
@@ -2591,11 +2592,11 @@ var
i, tileX, tileY: Integer;
virtualTile: TVirtualTile;
begin
- Logger.EnterMethod([lcClient], 'RebuildScreenBuffer');
+ //Logger.EnterMethod([lcClient], 'RebuildScreenBuffer');
FDrawDistance := Trunc(Sqrt(oglGameWindow.Width * oglGameWindow.Width +
oglGamewindow.Height * oglGamewindow.Height) / 44);
- Logger.Send([lcClient], 'DrawDistance', FDrawDistance);
+ //Logger.Send([lcClient], 'DrawDistance', FDrawDistance);
{$HINTS off}{$WARNINGS off}
if FX - FDrawDistance < 0 then FLowOffsetX := -FX else FLowOffsetX := -FDrawDistance;
@@ -2612,7 +2613,7 @@ begin
if frmVirtualLayer.cbShowLayer.Checked then
begin
- Logger.Send([lcClient, lcDebug], 'Preparing Virtual Layer');
+ //Logger.Send([lcClient, lcDebug], 'Preparing Virtual Layer');
if FVLayerMaterial = nil then
FVLayerMaterial := TSimpleMaterial.Create(FVLayerImage);
@@ -2657,7 +2658,7 @@ begin
FVirtualTiles.Delete(i);
end;
- Logger.Send([lcClient, lcDebug], 'VirtualTiles', FVirtualTiles.Count);
+ //Logger.Send([lcClient, lcDebug], 'VirtualTiles', FVirtualTiles.Count);
FLandscape.FillDrawList(FScreenBuffer, FX + FLowOffsetX, FY + FLowOffsetY,
FRangeX, FRangeY, tbTerrain.Down, tbStatics.Down, acNoDraw.Checked,
@@ -2671,7 +2672,7 @@ begin
FScreenBuffer.UpdateShortcuts;
FScreenBufferState := [sbsValid, sbsIndexed];
- Logger.ExitMethod([lcClient], 'RebuildScreenBuffer');
+ //Logger.ExitMethod([lcClient], 'RebuildScreenBuffer');
end;
procedure TfrmMain.UpdateCurrentTile;
@@ -2689,13 +2690,13 @@ procedure TfrmMain.UpdateCurrentTile(AX, AY: Integer);
var
blockInfo: PBlockInfo;
begin
- Logger.EnterMethod([lcClient, lcDebug], 'UpdateCurrentTile');
+ //Logger.EnterMethod([lcClient, lcDebug], 'UpdateCurrentTile');
FOverlayUI.ActiveArrow := FOverlayUI.HitTest(AX, AY);
if FOverlayUI.ActiveArrow > -1 then
begin
- Logger.Send([lcClient, lcDebug], 'Overlay active');
+ //Logger.Send([lcClient, lcDebug], 'Overlay active');
CurrentTile := nil;
- Logger.ExitMethod([lcClient, lcDebug], 'UpdateCurrentTile');
+ //Logger.ExitMethod([lcClient, lcDebug], 'UpdateCurrentTile');
Exit;
end;
@@ -2705,7 +2706,7 @@ begin
else
CurrentTile := nil;
- Logger.ExitMethod([lcClient, lcDebug], 'UpdateCurrentTile');
+ //Logger.ExitMethod([lcClient, lcDebug], 'UpdateCurrentTile');
end;
procedure TfrmMain.UpdateFilter;
@@ -2732,9 +2733,11 @@ begin
end;
Include(FScreenBufferState, sbsFiltered);
- //TODO : Check lightlevel first
- FLightManager.UpdateLightMap(FX + FLowOffsetX, FRangeX + 1, FY + FLowOffsetY,
- FRangeY + 1, FScreenBuffer);
+ ForceUpdateCurrentTile;
+
+ if (FLightManager.LightLevel > 0) and not acFlat.Checked then
+ FLightManager.UpdateLightMap(FX + FLowOffsetX, FRangeX + 1, FY + FLowOffsetY,
+ FRangeY + 1, FScreenBuffer);
end;
procedure TfrmMain.UpdateSelection;
@@ -2841,7 +2844,7 @@ var
cell: TMapCell;
i, tileX, tileY: Integer;
begin
- Logger.EnterMethod([lcClient, lcDebug], 'UpdateSelection');
+ //Logger.EnterMethod([lcClient, lcDebug], 'UpdateSelection');
//If the current tile is nil, but we still have a selected tile, the
//procedure is pointless - the selection should stay intact.
@@ -2853,7 +2856,7 @@ begin
selectedRect := GetSelectedRect;
//clean up old ghost tiles
- Logger.Send([lcClient, lcDebug], 'Cleaning ghost tiles');
+ //Logger.Send([lcClient, lcDebug], 'Cleaning ghost tiles');
for i := FVirtualTiles.Count - 1 downto 0 do
begin
item := FVirtualTiles[i];
@@ -2863,7 +2866,7 @@ begin
FVirtualTiles.Delete(i);
end;
end;
- Logger.Send([lcClient, lcDebug], 'FSelection', FSelection);
+ //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
@@ -2881,8 +2884,8 @@ begin
blockInfo := nil;
if (SelectedTile <> nil) and (CurrentTile <> SelectedTile) then
begin
- Logger.Send([lcClient, lcDebug], 'Multiple Targets');
- Logger.Send([lcClient, lcDebug], 'SelectedRect', selectedRect);
+ {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
@@ -2895,7 +2898,7 @@ begin
selectedRect) and not acDraw.Checked);
end else
begin
- Logger.Send([lcClient, lcDebug], 'Single Target');
+ //Logger.Send([lcClient, lcDebug], 'Single Target');
if acDraw.Checked and not IsInRect(CurrentTile.X, CurrentTile.Y,
FSelection) then
AddGhostTile(CurrentTile.X, CurrentTile.Y, CurrentTile);
@@ -2907,8 +2910,8 @@ begin
end;
FSelection := selectedRect;
end;
- Logger.Send([lcClient, lcDebug], 'Virtual Tiles', FVirtualTiles.Count);
- Logger.ExitMethod([lcClient, lcDebug], 'UpdateSelection');
+ {Logger.Send([lcClient, lcDebug], 'Virtual Tiles', FVirtualTiles.Count);
+ Logger.ExitMethod([lcClient, lcDebug], 'UpdateSelection');}
end;
procedure TfrmMain.OnTileRemoved(ATile: TMulBlock);