- Added optional highlight for (un)walkable tiles
- Fixed lightmanager to draw in the correct color - Fixed TMapBlock and TStaticBlock to correctly initialize itself as "unchanged" - Cleanup in the server project
This commit is contained in:
parent
f2764e928e
commit
d461774816
File diff suppressed because it is too large
Load Diff
|
@ -1,376 +1,378 @@
|
|||
(*
|
||||
* CDDL HEADER START
|
||||
*
|
||||
* The contents of this file are subject to the terms of the
|
||||
* Common Development and Distribution License, Version 1.0 only
|
||||
* (the "License"). You may not use this file except in compliance
|
||||
* with the License.
|
||||
*
|
||||
* You can obtain a copy of the license at
|
||||
* http://www.opensource.org/licenses/cddl1.php.
|
||||
* See the License for the specific language governing permissions
|
||||
* and limitations under the License.
|
||||
*
|
||||
* When distributing Covered Code, include this CDDL HEADER in each
|
||||
* file and include the License file at
|
||||
* http://www.opensource.org/licenses/cddl1.php. If applicable,
|
||||
* add the following below this CDDL HEADER, with the fields enclosed
|
||||
* by brackets "[]" replaced with your own identifying * information:
|
||||
* Portions Copyright [yyyy] [name of copyright owner]
|
||||
*
|
||||
* CDDL HEADER END
|
||||
*
|
||||
*
|
||||
* Portions Copyright 2009 Andreas Schneider
|
||||
*)
|
||||
unit ULightManager;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Imaging, ImagingTypes, ImagingClasses, ImagingCanvases,
|
||||
ImagingOpenGL, GL, GLu, GLext, fgl, ULandscape, UWorldItem, UCacheManager;
|
||||
|
||||
type
|
||||
|
||||
TCalculateOffset = procedure(AX, AY: Integer; out DrawX, DrawY: Integer) of object;
|
||||
|
||||
{ TLightMaterial }
|
||||
|
||||
TLightMaterial = class(TSimpleMaterial)
|
||||
constructor Create(AGraphic: TBaseImage);
|
||||
destructor Destroy; override;
|
||||
protected
|
||||
FCanvas: TFastARGB32Canvas;
|
||||
public
|
||||
property Canvas: TFastARGB32Canvas read FCanvas;
|
||||
end;
|
||||
|
||||
TLightCache = specialize TCacheManager<TLightMaterial>;
|
||||
|
||||
TLightManager = class;
|
||||
|
||||
{ TLightSource }
|
||||
|
||||
TLightSource = class
|
||||
constructor Create(AManager: TLightManager; AWorldItem: TWorldItem);
|
||||
destructor Destroy; override;
|
||||
protected
|
||||
FX: Integer;
|
||||
FY: Integer;
|
||||
FZ: SmallInt;
|
||||
FMaterial: TLightMaterial;
|
||||
public
|
||||
property X: Integer read FX;
|
||||
property Y: Integer read FY;
|
||||
property Z: SmallInt read FZ;
|
||||
property Material: TLightMaterial read FMaterial;
|
||||
end;
|
||||
|
||||
TLightSources = specialize TFPGObjectList<TLightSource>;
|
||||
|
||||
{ TLightManager }
|
||||
|
||||
TLightManager = class
|
||||
constructor Create(ACalculateOffset: TCalculateOffset);
|
||||
destructor Destroy; override;
|
||||
protected
|
||||
FLightSources: TLightSources;
|
||||
FOverlay: TSingleImage;
|
||||
FOverlayTexture: GLuint;
|
||||
FLightLevel: Byte;
|
||||
FValid: Boolean;
|
||||
FCalculateOffset: TCalculateOffset;
|
||||
FLightCache: TLightCache;
|
||||
FUseFBO: Boolean;
|
||||
FInitialized: Boolean;
|
||||
function GetLight(AID: Integer): TLightMaterial;
|
||||
procedure SetLightLevel(AValue: Byte);
|
||||
procedure UpdateOverlay(AScreenRect: TRect);
|
||||
public
|
||||
property LightLevel: Byte read FLightLevel write SetLightLevel;
|
||||
procedure InitGL;
|
||||
procedure UpdateLightMap(ALeft, AWidth, ATop, AHeight: Integer;
|
||||
AScreenBuffer: TScreenBuffer);
|
||||
procedure Draw(AScreenRect: TRect);
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
UGameResources, UTiledata, UStatics, UMap, ULight, Logging;
|
||||
|
||||
{ TLightManager }
|
||||
|
||||
constructor TLightManager.Create(ACalculateOffset: TCalculateOffset);
|
||||
begin
|
||||
FCalculateOffset := ACalculateOffset;
|
||||
FLightSources := TLightSources.Create(True);
|
||||
FLightLevel := 0;
|
||||
FLightCache := TLightCache.Create(32);
|
||||
FInitialized := False;
|
||||
end;
|
||||
|
||||
destructor TLightManager.Destroy;
|
||||
begin
|
||||
FreeAndNil(FLightSources);
|
||||
FreeAndNil(FOverlay);
|
||||
FreeAndNil(FLightCache);
|
||||
glDeleteTextures(1, @FOverlayTexture);
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
function TLightManager.GetLight(AID: Integer): TLightMaterial;
|
||||
var
|
||||
light: TLight;
|
||||
begin
|
||||
Result := nil;
|
||||
if not FLightCache.QueryID(AID, Result) then
|
||||
begin
|
||||
if ResMan.Lights.Exists(AID) then
|
||||
begin
|
||||
light := ResMan.Lights.GetLight(AID);
|
||||
Result := TLightMaterial.Create(light.Graphic);
|
||||
FLightCache.StoreID(AID, Result);
|
||||
light.Free;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TLightManager.SetLightLevel(AValue: Byte);
|
||||
begin
|
||||
FLightLevel := AValue;
|
||||
FValid := False;
|
||||
end;
|
||||
|
||||
procedure TLightManager.UpdateOverlay(AScreenRect: TRect);
|
||||
var
|
||||
canvas: TFastARGB32Canvas;
|
||||
color: TColor32Rec;
|
||||
i: Integer;
|
||||
lightMaterial: TLightMaterial;
|
||||
colorGL: GLclampf;
|
||||
fbo: GLuint;
|
||||
begin
|
||||
glDeleteTextures(1, @FOverlayTexture);
|
||||
if FUseFBO then
|
||||
begin
|
||||
glGenTextures(1, @FOverlayTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, FOverlayTexture);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, AScreenRect.Right,
|
||||
AScreenRect.Bottom, 0, GL_RGBA, GL_UNSIGNED_BYTE, nil);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
glGenFramebuffersEXT(1, @fbo);
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
|
||||
GL_TEXTURE_2D, FOverlayTexture, 0);
|
||||
|
||||
colorGL :=(32 - lightLevel) / 32;
|
||||
glClearColor(colorGL, colorGL, colorGL, 1);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
for i := 0 to FLightSources.Count - 1 do
|
||||
begin
|
||||
lightMaterial := FLightSources[i].Material;
|
||||
if lightMaterial <> nil then
|
||||
begin
|
||||
glBindTexture(GL_TEXTURE_2D, lightMaterial.Texture);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2i(0, 0);
|
||||
glVertex2i(FLightSources[i].FX - lightMaterial.RealWidth div 2,
|
||||
FLightSources[i].FY - lightMaterial.RealHeight div 2);
|
||||
glTexCoord2i(0, 1);
|
||||
glVertex2i(FLightSources[i].FX - lightMaterial.RealWidth div 2,
|
||||
FLightSources[i].FY - lightMaterial.RealHeight div 2 +
|
||||
lightMaterial.Height);
|
||||
glTexCoord2i(1, 1);
|
||||
glVertex2i(FLightSources[i].FX - lightMaterial.RealWidth div 2 +
|
||||
lightMaterial.Width, FLightSources[i].FY -
|
||||
lightMaterial.RealHeight div 2 + lightMaterial.Height);
|
||||
glTexCoord2i(1, 0);
|
||||
glVertex2i(FLightSources[i].FX - lightMaterial.RealWidth div 2 +
|
||||
lightMaterial.Width,
|
||||
FLightSources[i].FY - lightMaterial.RealHeight div 2);
|
||||
glEnd;
|
||||
end;
|
||||
end;
|
||||
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
|
||||
glDeleteFramebuffersEXT(1, @fbo);
|
||||
end else
|
||||
begin
|
||||
FOverlay.Free;
|
||||
|
||||
color.A := $FF;
|
||||
color.R := ((32 - FLightLevel) * 255) div 32;
|
||||
color.G := color.R;
|
||||
color.B := color.R;
|
||||
|
||||
FOverlay := TSingleImage.CreateFromParams(AScreenRect.Right,
|
||||
AScreenRect.Bottom, ifA8R8G8B8);
|
||||
canvas := TFastARGB32Canvas.CreateForImage(FOverlay);
|
||||
try
|
||||
canvas.FillColor32 := color.Color;
|
||||
canvas.FillRect(AScreenRect);
|
||||
|
||||
for i := 0 to FLightSources.Count - 1 do
|
||||
begin
|
||||
lightMaterial := FLightSources[i].Material;
|
||||
if lightMaterial <> nil then
|
||||
begin
|
||||
lightMaterial.Canvas.DrawAdd(lightMaterial.Canvas.ClipRect, canvas,
|
||||
FLightSources[i].FX - lightMaterial.RealWidth div 2,
|
||||
FLightSources[i].FY - lightMaterial.RealHeight div 2);
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
canvas.Free;
|
||||
end;
|
||||
|
||||
FOverlayTexture := CreateGLTextureFromImage(FOverlay.ImageDataPointer^);
|
||||
end;
|
||||
|
||||
FValid := True;
|
||||
end;
|
||||
|
||||
procedure TLightManager.InitGL;
|
||||
begin
|
||||
FUseFBO := Load_GL_EXT_framebuffer_object;
|
||||
end;
|
||||
|
||||
procedure TLightManager.UpdateLightMap(ALeft, AWidth, ATop, AHeight: Integer;
|
||||
AScreenBuffer: TScreenBuffer);
|
||||
var
|
||||
blockInfo: PBlockInfo;
|
||||
lights: TWorldItemList;
|
||||
i, x, y, tileID: Integer;
|
||||
tileData: TTiledata;
|
||||
tileMap: array of array of TWorldItem;
|
||||
begin
|
||||
//Logger.EnterMethod([lcClient, lcDebug], 'UpdateLightMap');
|
||||
FLightSources.Clear;
|
||||
{Logger.Send([lcClient, lcDebug], 'AWidth', AWidth);
|
||||
Logger.Send([lcClient, lcDebug], 'AHeight', AHeight);}
|
||||
lights := TWorldItemList.Create(False);
|
||||
SetLength(tileMap, AWidth, AHeight);
|
||||
for x := 0 to AWidth - 1 do
|
||||
for y := 0 to AHeight - 1 do
|
||||
tileMap[x,y] := nil;
|
||||
|
||||
blockInfo := nil;
|
||||
while AScreenBuffer.Iterate(blockInfo) do
|
||||
begin
|
||||
if blockInfo^.State = ssNormal then
|
||||
begin
|
||||
if blockInfo^.Item is TStaticItem then
|
||||
tileID := blockInfo^.Item.TileID + $4000
|
||||
else
|
||||
tileID := blockInfo^.Item.TileID;
|
||||
tileData := ResMan.Tiledata.TileData[tileID];
|
||||
|
||||
if tdfLightSource in tileData.Flags then
|
||||
lights.Add(blockInfo^.Item)
|
||||
else
|
||||
tileMap[blockInfo^.Item.X - ALeft, blockInfo^.Item.Y - ATop] :=
|
||||
blockInfo^.Item;
|
||||
end;
|
||||
end;
|
||||
|
||||
for i := 0 to lights.Count - 1 do
|
||||
begin
|
||||
x := lights[i].X + 1 - ALeft;
|
||||
y := lights[i].Y + 1 - ATop;
|
||||
if (x = AWidth) or (y = AHeight) or (tileMap[x,y] = nil) or
|
||||
(tileMap[x,y].Z < lights[i].Z + 5) then
|
||||
FLightSources.Add(TLightSource.Create(Self, lights[i]));
|
||||
end;
|
||||
|
||||
lights.Free;
|
||||
|
||||
FValid := False;
|
||||
//Logger.ExitMethod([lcClient, lcDebug], 'UpdateLightMap');
|
||||
end;
|
||||
|
||||
procedure TLightManager.Draw(AScreenRect: TRect);
|
||||
begin
|
||||
if not FInitialized then
|
||||
InitGL;
|
||||
|
||||
if not FValid then
|
||||
UpdateOverlay(AScreenRect);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, FOverlayTexture);
|
||||
glBlendFunc(GL_ZERO, GL_SRC_COLOR);
|
||||
glBegin(GL_QUADS);
|
||||
if FUseFBO then
|
||||
begin
|
||||
glTexCoord2i(0, 1);
|
||||
glVertex2i(AScreenRect.Left, AScreenRect.Top);
|
||||
glTexCoord2i(0, 0);
|
||||
glVertex2i(AScreenRect.Left, AScreenRect.Bottom);
|
||||
glTexCoord2i(1, 0);
|
||||
glVertex2i(AScreenRect.Right, AScreenRect.Bottom);
|
||||
glTexCoord2i(1, 1);
|
||||
glVertex2i(AScreenRect.Right, AScreenRect.Top);
|
||||
end else
|
||||
begin
|
||||
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);
|
||||
end;
|
||||
glEnd;
|
||||
end;
|
||||
|
||||
{ TLightSource }
|
||||
|
||||
constructor TLightSource.Create(AManager: TLightManager; AWorldItem: TWorldItem);
|
||||
var
|
||||
lightID: Byte;
|
||||
begin
|
||||
lightID := ResMan.Tiledata.StaticTiles[AWorldItem.TileID].Quality;
|
||||
FMaterial := AManager.GetLight(lightID);
|
||||
if FMaterial <> nil then
|
||||
begin
|
||||
AManager.FCalculateOffset(AWorldItem.X, AWorldItem.Y, FX, FY);
|
||||
FZ := AWorldItem.Z * 4;
|
||||
FY := FY + 22 - FZ;
|
||||
FMaterial.AddRef;
|
||||
end;
|
||||
end;
|
||||
|
||||
destructor TLightSource.Destroy;
|
||||
begin
|
||||
if FMaterial <> nil then
|
||||
FMaterial.DelRef;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
{ TLightMaterial }
|
||||
|
||||
constructor TLightMaterial.Create(AGraphic: TBaseImage);
|
||||
begin
|
||||
inherited Create(AGraphic);
|
||||
FCanvas := TFastARGB32Canvas.CreateForImage(FGraphic);
|
||||
end;
|
||||
|
||||
destructor TLightMaterial.Destroy;
|
||||
begin
|
||||
FreeAndNil(FCanvas);
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
(*
|
||||
* CDDL HEADER START
|
||||
*
|
||||
* The contents of this file are subject to the terms of the
|
||||
* Common Development and Distribution License, Version 1.0 only
|
||||
* (the "License"). You may not use this file except in compliance
|
||||
* with the License.
|
||||
*
|
||||
* You can obtain a copy of the license at
|
||||
* http://www.opensource.org/licenses/cddl1.php.
|
||||
* See the License for the specific language governing permissions
|
||||
* and limitations under the License.
|
||||
*
|
||||
* When distributing Covered Code, include this CDDL HEADER in each
|
||||
* file and include the License file at
|
||||
* http://www.opensource.org/licenses/cddl1.php. If applicable,
|
||||
* add the following below this CDDL HEADER, with the fields enclosed
|
||||
* by brackets "[]" replaced with your own identifying * information:
|
||||
* Portions Copyright [yyyy] [name of copyright owner]
|
||||
*
|
||||
* CDDL HEADER END
|
||||
*
|
||||
*
|
||||
* Portions Copyright 2009 Andreas Schneider
|
||||
*)
|
||||
unit ULightManager;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Imaging, ImagingTypes, ImagingClasses, ImagingCanvases,
|
||||
ImagingOpenGL, GL, GLu, GLext, fgl, ULandscape, UWorldItem, UCacheManager;
|
||||
|
||||
type
|
||||
|
||||
TCalculateOffset = procedure(AX, AY: Integer; out DrawX, DrawY: Integer) of object;
|
||||
|
||||
{ TLightMaterial }
|
||||
|
||||
TLightMaterial = class(TSimpleMaterial)
|
||||
constructor Create(AGraphic: TBaseImage);
|
||||
destructor Destroy; override;
|
||||
protected
|
||||
FCanvas: TFastARGB32Canvas;
|
||||
public
|
||||
property Canvas: TFastARGB32Canvas read FCanvas;
|
||||
end;
|
||||
|
||||
TLightCache = specialize TCacheManager<TLightMaterial>;
|
||||
|
||||
TLightManager = class;
|
||||
|
||||
{ TLightSource }
|
||||
|
||||
TLightSource = class
|
||||
constructor Create(AManager: TLightManager; AWorldItem: TWorldItem);
|
||||
destructor Destroy; override;
|
||||
protected
|
||||
FX: Integer;
|
||||
FY: Integer;
|
||||
FZ: SmallInt;
|
||||
FMaterial: TLightMaterial;
|
||||
public
|
||||
property X: Integer read FX;
|
||||
property Y: Integer read FY;
|
||||
property Z: SmallInt read FZ;
|
||||
property Material: TLightMaterial read FMaterial;
|
||||
end;
|
||||
|
||||
TLightSources = specialize TFPGObjectList<TLightSource>;
|
||||
|
||||
{ TLightManager }
|
||||
|
||||
TLightManager = class
|
||||
constructor Create(ACalculateOffset: TCalculateOffset);
|
||||
destructor Destroy; override;
|
||||
protected
|
||||
FLightSources: TLightSources;
|
||||
FOverlay: TSingleImage;
|
||||
FOverlayTexture: GLuint;
|
||||
FLightLevel: Byte;
|
||||
FValid: Boolean;
|
||||
FCalculateOffset: TCalculateOffset;
|
||||
FLightCache: TLightCache;
|
||||
FUseFBO: Boolean;
|
||||
FInitialized: Boolean;
|
||||
function GetLight(AID: Integer): TLightMaterial;
|
||||
procedure SetLightLevel(AValue: Byte);
|
||||
procedure UpdateOverlay(AScreenRect: TRect);
|
||||
public
|
||||
property LightLevel: Byte read FLightLevel write SetLightLevel;
|
||||
procedure InitGL;
|
||||
procedure UpdateLightMap(ALeft, AWidth, ATop, AHeight: Integer;
|
||||
AScreenBuffer: TScreenBuffer);
|
||||
procedure Draw(AScreenRect: TRect);
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
UGameResources, UTiledata, UStatics, UMap, ULight, Logging;
|
||||
|
||||
{ TLightManager }
|
||||
|
||||
constructor TLightManager.Create(ACalculateOffset: TCalculateOffset);
|
||||
begin
|
||||
FCalculateOffset := ACalculateOffset;
|
||||
FLightSources := TLightSources.Create(True);
|
||||
FLightLevel := 0;
|
||||
FLightCache := TLightCache.Create(32);
|
||||
FInitialized := False;
|
||||
end;
|
||||
|
||||
destructor TLightManager.Destroy;
|
||||
begin
|
||||
FreeAndNil(FLightSources);
|
||||
FreeAndNil(FOverlay);
|
||||
FreeAndNil(FLightCache);
|
||||
glDeleteTextures(1, @FOverlayTexture);
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
function TLightManager.GetLight(AID: Integer): TLightMaterial;
|
||||
var
|
||||
light: TLight;
|
||||
begin
|
||||
Result := nil;
|
||||
if not FLightCache.QueryID(AID, Result) then
|
||||
begin
|
||||
if ResMan.Lights.Exists(AID) then
|
||||
begin
|
||||
light := ResMan.Lights.GetLight(AID);
|
||||
Result := TLightMaterial.Create(light.Graphic);
|
||||
FLightCache.StoreID(AID, Result);
|
||||
light.Free;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TLightManager.SetLightLevel(AValue: Byte);
|
||||
begin
|
||||
FLightLevel := AValue;
|
||||
FValid := False;
|
||||
end;
|
||||
|
||||
procedure TLightManager.UpdateOverlay(AScreenRect: TRect);
|
||||
var
|
||||
canvas: TFastARGB32Canvas;
|
||||
color: TColor32Rec;
|
||||
i: Integer;
|
||||
lightMaterial: TLightMaterial;
|
||||
colorGL: GLclampf;
|
||||
fbo: GLuint;
|
||||
begin
|
||||
glDeleteTextures(1, @FOverlayTexture);
|
||||
if FUseFBO then
|
||||
begin
|
||||
glGenTextures(1, @FOverlayTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, FOverlayTexture);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, AScreenRect.Right,
|
||||
AScreenRect.Bottom, 0, GL_RGBA, GL_UNSIGNED_BYTE, nil);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
glGenFramebuffersEXT(1, @fbo);
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
|
||||
GL_TEXTURE_2D, FOverlayTexture, 0);
|
||||
|
||||
colorGL :=(32 - lightLevel) / 32;
|
||||
glClearColor(colorGL, colorGL, colorGL, 1);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
for i := 0 to FLightSources.Count - 1 do
|
||||
begin
|
||||
lightMaterial := FLightSources[i].Material;
|
||||
if lightMaterial <> nil then
|
||||
begin
|
||||
glBindTexture(GL_TEXTURE_2D, lightMaterial.Texture);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2i(0, 0);
|
||||
glVertex2i(FLightSources[i].FX - lightMaterial.RealWidth div 2,
|
||||
FLightSources[i].FY - lightMaterial.RealHeight div 2);
|
||||
glTexCoord2i(0, 1);
|
||||
glVertex2i(FLightSources[i].FX - lightMaterial.RealWidth div 2,
|
||||
FLightSources[i].FY - lightMaterial.RealHeight div 2 +
|
||||
lightMaterial.Height);
|
||||
glTexCoord2i(1, 1);
|
||||
glVertex2i(FLightSources[i].FX - lightMaterial.RealWidth div 2 +
|
||||
lightMaterial.Width, FLightSources[i].FY -
|
||||
lightMaterial.RealHeight div 2 + lightMaterial.Height);
|
||||
glTexCoord2i(1, 0);
|
||||
glVertex2i(FLightSources[i].FX - lightMaterial.RealWidth div 2 +
|
||||
lightMaterial.Width,
|
||||
FLightSources[i].FY - lightMaterial.RealHeight div 2);
|
||||
glEnd;
|
||||
end;
|
||||
end;
|
||||
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
|
||||
glDeleteFramebuffersEXT(1, @fbo);
|
||||
end else
|
||||
begin
|
||||
FOverlay.Free;
|
||||
|
||||
color.A := $FF;
|
||||
color.R := ((32 - FLightLevel) * 255) div 32;
|
||||
color.G := color.R;
|
||||
color.B := color.R;
|
||||
|
||||
FOverlay := TSingleImage.CreateFromParams(AScreenRect.Right,
|
||||
AScreenRect.Bottom, ifA8R8G8B8);
|
||||
canvas := TFastARGB32Canvas.CreateForImage(FOverlay);
|
||||
try
|
||||
canvas.FillColor32 := color.Color;
|
||||
canvas.FillRect(AScreenRect);
|
||||
|
||||
for i := 0 to FLightSources.Count - 1 do
|
||||
begin
|
||||
lightMaterial := FLightSources[i].Material;
|
||||
if lightMaterial <> nil then
|
||||
begin
|
||||
lightMaterial.Canvas.DrawAdd(lightMaterial.Canvas.ClipRect, canvas,
|
||||
FLightSources[i].FX - lightMaterial.RealWidth div 2,
|
||||
FLightSources[i].FY - lightMaterial.RealHeight div 2);
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
canvas.Free;
|
||||
end;
|
||||
|
||||
FOverlayTexture := CreateGLTextureFromImage(FOverlay.ImageDataPointer^);
|
||||
end;
|
||||
|
||||
FValid := True;
|
||||
end;
|
||||
|
||||
procedure TLightManager.InitGL;
|
||||
begin
|
||||
FUseFBO := Load_GL_EXT_framebuffer_object;
|
||||
end;
|
||||
|
||||
procedure TLightManager.UpdateLightMap(ALeft, AWidth, ATop, AHeight: Integer;
|
||||
AScreenBuffer: TScreenBuffer);
|
||||
var
|
||||
blockInfo: PBlockInfo;
|
||||
lights: TWorldItemList;
|
||||
i, x, y, tileID: Integer;
|
||||
tileData: TTiledata;
|
||||
tileMap: array of array of TWorldItem;
|
||||
begin
|
||||
//Logger.EnterMethod([lcClient, lcDebug], 'UpdateLightMap');
|
||||
FLightSources.Clear;
|
||||
{Logger.Send([lcClient, lcDebug], 'AWidth', AWidth);
|
||||
Logger.Send([lcClient, lcDebug], 'AHeight', AHeight);}
|
||||
lights := TWorldItemList.Create(False);
|
||||
SetLength(tileMap, AWidth, AHeight);
|
||||
for x := 0 to AWidth - 1 do
|
||||
for y := 0 to AHeight - 1 do
|
||||
tileMap[x,y] := nil;
|
||||
|
||||
blockInfo := nil;
|
||||
while AScreenBuffer.Iterate(blockInfo) do
|
||||
begin
|
||||
if blockInfo^.State = ssNormal then
|
||||
begin
|
||||
if blockInfo^.Item is TStaticItem then
|
||||
tileID := blockInfo^.Item.TileID + $4000
|
||||
else
|
||||
tileID := blockInfo^.Item.TileID;
|
||||
tileData := ResMan.Tiledata.TileData[tileID];
|
||||
|
||||
if tdfLightSource in tileData.Flags then
|
||||
lights.Add(blockInfo^.Item)
|
||||
else
|
||||
tileMap[blockInfo^.Item.X - ALeft, blockInfo^.Item.Y - ATop] :=
|
||||
blockInfo^.Item;
|
||||
end;
|
||||
end;
|
||||
|
||||
for i := 0 to lights.Count - 1 do
|
||||
begin
|
||||
x := lights[i].X + 1 - ALeft;
|
||||
y := lights[i].Y + 1 - ATop;
|
||||
if (x = AWidth) or (y = AHeight) or (tileMap[x,y] = nil) or
|
||||
(tileMap[x,y].Z < lights[i].Z + 5) then
|
||||
FLightSources.Add(TLightSource.Create(Self, lights[i]));
|
||||
end;
|
||||
|
||||
lights.Free;
|
||||
|
||||
FValid := False;
|
||||
//Logger.ExitMethod([lcClient, lcDebug], 'UpdateLightMap');
|
||||
end;
|
||||
|
||||
procedure TLightManager.Draw(AScreenRect: TRect);
|
||||
begin
|
||||
if not FInitialized then
|
||||
InitGL;
|
||||
|
||||
glColor4f(1, 1, 1, 1);
|
||||
|
||||
if not FValid then
|
||||
UpdateOverlay(AScreenRect);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, FOverlayTexture);
|
||||
glBlendFunc(GL_ZERO, GL_SRC_COLOR);
|
||||
glBegin(GL_QUADS);
|
||||
if FUseFBO then
|
||||
begin
|
||||
glTexCoord2i(0, 1);
|
||||
glVertex2i(AScreenRect.Left, AScreenRect.Top);
|
||||
glTexCoord2i(0, 0);
|
||||
glVertex2i(AScreenRect.Left, AScreenRect.Bottom);
|
||||
glTexCoord2i(1, 0);
|
||||
glVertex2i(AScreenRect.Right, AScreenRect.Bottom);
|
||||
glTexCoord2i(1, 1);
|
||||
glVertex2i(AScreenRect.Right, AScreenRect.Top);
|
||||
end else
|
||||
begin
|
||||
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);
|
||||
end;
|
||||
glEnd;
|
||||
end;
|
||||
|
||||
{ TLightSource }
|
||||
|
||||
constructor TLightSource.Create(AManager: TLightManager; AWorldItem: TWorldItem);
|
||||
var
|
||||
lightID: Byte;
|
||||
begin
|
||||
lightID := ResMan.Tiledata.StaticTiles[AWorldItem.TileID].Quality;
|
||||
FMaterial := AManager.GetLight(lightID);
|
||||
if FMaterial <> nil then
|
||||
begin
|
||||
AManager.FCalculateOffset(AWorldItem.X, AWorldItem.Y, FX, FY);
|
||||
FZ := AWorldItem.Z * 4;
|
||||
FY := FY + 22 - FZ;
|
||||
FMaterial.AddRef;
|
||||
end;
|
||||
end;
|
||||
|
||||
destructor TLightSource.Destroy;
|
||||
begin
|
||||
if FMaterial <> nil then
|
||||
FMaterial.DelRef;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
{ TLightMaterial }
|
||||
|
||||
constructor TLightMaterial.Create(AGraphic: TBaseImage);
|
||||
begin
|
||||
inherited Create(AGraphic);
|
||||
FCanvas := TFastARGB32Canvas.CreateForImage(FGraphic);
|
||||
end;
|
||||
|
||||
destructor TLightMaterial.Destroy;
|
||||
begin
|
||||
FreeAndNil(FCanvas);
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
|
|
@ -967,14 +967,14 @@ object frmMain: TfrmMain
|
|||
OnClick = tbStaticsClick
|
||||
end
|
||||
object tbSeparator5: TToolButton
|
||||
Left = 438
|
||||
Left = 461
|
||||
Top = 2
|
||||
Width = 17
|
||||
Caption = 'tbSeparator5'
|
||||
Style = tbsDivider
|
||||
end
|
||||
object tbRadarMap: TToolButton
|
||||
Left = 455
|
||||
Left = 478
|
||||
Hint = 'Radar Map'
|
||||
Top = 2
|
||||
Caption = 'Radar Map'
|
||||
|
@ -996,7 +996,7 @@ object frmMain: TfrmMain
|
|||
OnMouseMove = tbFilterMouseMove
|
||||
end
|
||||
object tbFlat: TToolButton
|
||||
Left = 403
|
||||
Left = 426
|
||||
Top = 2
|
||||
Action = acFlat
|
||||
DropdownMenu = pmFlatViewSettings
|
||||
|
@ -1020,11 +1020,17 @@ object frmMain: TfrmMain
|
|||
Top = 2
|
||||
Action = acUndo
|
||||
end
|
||||
object ToolButton1: TToolButton
|
||||
Left = 380
|
||||
object tbLightlevel: TToolButton
|
||||
Left = 403
|
||||
Top = 2
|
||||
Action = acLightlevel
|
||||
end
|
||||
object tbWalkable: TToolButton
|
||||
Left = 380
|
||||
Top = 2
|
||||
Action = acWalkable
|
||||
Style = tbsCheck
|
||||
end
|
||||
end
|
||||
object pnlChatHeader: TPanel
|
||||
AnchorSideLeft.Control = pnlChat
|
||||
|
@ -1465,7 +1471,7 @@ object frmMain: TfrmMain
|
|||
left = 264
|
||||
top = 32
|
||||
Bitmap = {
|
||||
4C69160000001000000010000000000000000000000000000000000000000000
|
||||
4C69170000001000000010000000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000000000000000000000000000
|
||||
0000D9A781FFD39E76FF00000000000000000000000000000000000000000000
|
||||
0000000000000000000000000000ECBEA1FFE7BB9DFFE4B697FFE0B292FFDAAE
|
||||
|
@ -2169,7 +2175,39 @@ object frmMain: TfrmMain
|
|||
FF0088A7BB5D485055F5444545FE3F4141FE3F474AF67D9CB16AFFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||
FF006D9CD4896A9AD2FB6697CFEEFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00709ED6DB6D9C
|
||||
D4FF85B1DAFF5A91B9FF6093CBEAFFFFFF00FFFFFF00808080FF7E7E7EFF7C7C
|
||||
7CFF7A7A7AFF777777FF757575FF727272FF719ED4FF6F9ED6FF87B2DCFFABD3
|
||||
E8FFA9D0E6FF5890B8FF598EC6EAFFFFFF00FFFFFF007D7D7DFF999999FF9999
|
||||
99FF9A9A9AFF9A9A9AFF9B9B9BFF9B9B9BFF6F9DD3FFAAD1E7FFABD1E7FF98C7
|
||||
E1FF91C2DEFF568FB7FF5289C1EAFFFFFF00FFFFFF007A7A7AFF999999FF5291
|
||||
59FF999A99FF9B9B9BFF9C9C9CFF9C9C9CFF6C9AD0FFA7CEE5FF8FC1DFFF89BD
|
||||
DCFF8BBDDCFF538DB6FF4B84BCEAFFFFFF00FFFFFF00777777FF9A9A9AFF3D8A
|
||||
45FF498A4FFF9C9C9CFF9D9D9DFF9D9D9DFF6696CCFFA2CBE3FF89BDDCFF83B9
|
||||
DAFF84B9DAFF518BB5FF437EB6EA44944DFF42914BFF3F8D48FF3D8945FF5DA4
|
||||
65FF5AA061FF45834BFF9E9E9EFF9E9E9EFF6092C9FF9EC7E2FF83B8DAFF7DB4
|
||||
D7FF7EB3D7FF4F89B4FF3B79B1EA41904AFF94D29FFF91D09AFF8DCD96FF89CB
|
||||
92FF84C88DFF519858FF417C46FF9F9F9FFF5A8EC4FF98C3E0FF7CB3D7FF74AF
|
||||
D6FF5EC4EDFF4B88B3FF3473ABEA3E8B46FF8FCE99FF7DC687FF78C381FF73C0
|
||||
7CFF74C07CFF79C281FF49904FFF547F57FF5489BFFF94BFDDFF75ADD4FF63B8
|
||||
E1FF4BD4FFFF428BB8FF2C6EA6EA3B8742FF89CB92FF84C88DFF80C688FF7BC3
|
||||
83FF77C17FFF478F4DFF3B743FFFA1A1A1FF4C84BAFF8DBBDBFF6EA8D1FF66A6
|
||||
D1FF5FB4DFFF4785B1FF2569A1EA37823EFF347E3BFF317937FF2E7534FF4991
|
||||
50FF468F4CFF39733DFFA1A1A1FFA2A2A2FF457EB4FF88B7D9FF67A3CFFF619E
|
||||
CCFF639FCCFF4583B1FF1F649CEAFFFFFF00FFFFFF00606060FFA0A0A0FF3D76
|
||||
41FF367139FFA2A2A2FFA2A2A2FFA3A3A3FF3D79B0FF82B3D7FF629FCCFF5A9A
|
||||
C9FF5E9BCAFF4381AFFF196098EAFFFFFF00FFFFFF005C5C5CFFA1A1A1FF3C73
|
||||
40FFA0A1A1FFA3A3A3FFA3A3A3FFA4A4A4FF3674AAFF7DAFD4FF5B9AC9FF5495
|
||||
C7FF5896C8FF4180AEFF135C94EAFFFFFF00FFFFFF00585858FFA2A2A2FFA2A2
|
||||
A2FFA3A3A3FFA4A4A4FFA4A4A4FFA5A5A5FF2F6FA5FF78ABD2FF78ABD3FF73A7
|
||||
D1FF69A0CDFF407FAEFF0F5991EA999999FF717171FF545454FF515151FF4F4F
|
||||
4FFF4C4C4CFF4A4A4AFF474747FF454545FF25679DFF3274A8FF3D7CAFFF4784
|
||||
B5FF4E8ABAFF3E7EADFF0C578FEAFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF001D639B1619609839145D9562105A
|
||||
92880D5890A4135C92FC0C578FED
|
||||
}
|
||||
end
|
||||
object pmTileList: TPopupMenu
|
||||
|
@ -2657,6 +2695,15 @@ object frmMain: TfrmMain
|
|||
ImageIndex = 21
|
||||
OnExecute = acLightlevelExecute
|
||||
end
|
||||
object acWalkable: TAction
|
||||
Category = 'Settings'
|
||||
AutoCheck = True
|
||||
Caption = 'Walkable'
|
||||
Hint = 'Highlight (un)walkable surfaces'
|
||||
ImageIndex = 22
|
||||
OnExecute = acWalkableExecute
|
||||
ShortCut = 16471
|
||||
end
|
||||
end
|
||||
object tmGrabTileInfo: TTimer
|
||||
Enabled = False
|
||||
|
|
|
@ -69,6 +69,7 @@ type
|
|||
acFlat: TAction;
|
||||
acNoDraw: TAction;
|
||||
acLightlevel: TAction;
|
||||
acWalkable: TAction;
|
||||
acUndo: TAction;
|
||||
acVirtualLayer: TAction;
|
||||
ActionList1: TActionList;
|
||||
|
@ -149,7 +150,8 @@ type
|
|||
tbNoDraw: TToolButton;
|
||||
tbSeparator2: TToolButton;
|
||||
tbUndo: TToolButton;
|
||||
ToolButton1: TToolButton;
|
||||
tbLightlevel: TToolButton;
|
||||
tbWalkable: TToolButton;
|
||||
tsLocations: TTabSheet;
|
||||
tbSetHue: TToolButton;
|
||||
tmGrabTileInfo: TTimer;
|
||||
|
@ -190,6 +192,7 @@ type
|
|||
procedure acSelectExecute(Sender: TObject);
|
||||
procedure acUndoExecute(Sender: TObject);
|
||||
procedure acVirtualLayerExecute(Sender: TObject);
|
||||
procedure acWalkableExecute(Sender: TObject);
|
||||
procedure ApplicationProperties1Idle(Sender: TObject; var Done: Boolean);
|
||||
procedure ApplicationProperties1ShowHint(var HintStr: string;
|
||||
var CanShow: Boolean; var HintInfo: THintInfo);
|
||||
|
@ -525,6 +528,9 @@ end;
|
|||
procedure TfrmMain.oglGameWindowKeyDown(Sender: TObject; var Key: Word;
|
||||
Shift: TShiftState);
|
||||
begin
|
||||
if Shift <> [] then
|
||||
Exit;
|
||||
|
||||
case Key of
|
||||
VK_W, VK_NUMPAD8, VK_UP:
|
||||
MoveBy(-8, -8);
|
||||
|
@ -1125,6 +1131,12 @@ begin
|
|||
frmVirtualLayer.Show;
|
||||
end;
|
||||
|
||||
procedure TfrmMain.acWalkableExecute(Sender: TObject);
|
||||
begin
|
||||
InvalidateFilter;
|
||||
FRepaintNeeded := True;
|
||||
end;
|
||||
|
||||
procedure TfrmMain.acDrawExecute(Sender: TObject);
|
||||
begin
|
||||
acDraw.Checked := True;
|
||||
|
@ -2311,7 +2323,7 @@ end;
|
|||
procedure TfrmMain.Render;
|
||||
var
|
||||
highlight: Boolean;
|
||||
intensity: GLfloat;
|
||||
intensity, red, green, blue: GLfloat;
|
||||
blockInfo: PBlockInfo;
|
||||
item: TWorldItem;
|
||||
begin
|
||||
|
@ -2345,10 +2357,31 @@ begin
|
|||
SetDarkLights;
|
||||
end;
|
||||
|
||||
case blockInfo^.WalkRestriction of
|
||||
wrNone:
|
||||
begin
|
||||
red := 1;
|
||||
green := 1;
|
||||
blue := 1;
|
||||
end;
|
||||
wrCanWalk:
|
||||
begin
|
||||
red := 0.5;
|
||||
green := 1;
|
||||
blue := 0.5;
|
||||
end;
|
||||
wrCannotWalk:
|
||||
begin
|
||||
red := 1;
|
||||
green := 0.5;
|
||||
blue := 0.5;
|
||||
end;
|
||||
end;
|
||||
|
||||
if blockInfo^.Translucent then
|
||||
glColor4f(intensity, intensity, intensity, 0.8)
|
||||
glColor4f(intensity * red, intensity * green, intensity * blue, 0.8)
|
||||
else
|
||||
glColor4f(intensity, intensity, intensity, 1.0);
|
||||
glColor4f(intensity * red, intensity * green, intensity * blue, 1.0);
|
||||
|
||||
highlight := blockInfo^.Highlighted and item.CanBeEdited;
|
||||
|
||||
|
@ -2362,7 +2395,7 @@ begin
|
|||
begin
|
||||
glBindTexture(GL_TEXTURE_2D, blockInfo^.HighRes.Texture);
|
||||
|
||||
if not highlight then
|
||||
if not highlight and (blockInfo^.WalkRestriction = wrNone) then
|
||||
glEnable(GL_LIGHTING);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
|
@ -2376,7 +2409,7 @@ begin
|
|||
glTexCoord2i(1, 0); glVertex2iv(@blockInfo^.DrawQuad[1]);
|
||||
glEnd;
|
||||
|
||||
if not highlight then
|
||||
if not highlight and (blockInfo^.WalkRestriction = wrNone) then
|
||||
glDisable(GL_LIGHTING);
|
||||
end else
|
||||
begin
|
||||
|
@ -2722,8 +2755,13 @@ end;
|
|||
procedure TfrmMain.UpdateFilter;
|
||||
var
|
||||
blockInfo: PBlockInfo;
|
||||
tileData: TTiledata;
|
||||
staticTileData: TStaticTileData;
|
||||
lastSurface: PBlockInfo;
|
||||
surfaceTop: Integer;
|
||||
begin
|
||||
blockInfo := nil;
|
||||
lastSurface := nil;
|
||||
while FScreenBuffer.Iterate(blockInfo) do
|
||||
begin
|
||||
if blockInfo^.State in [ssNormal, ssFiltered] then
|
||||
|
@ -2739,8 +2777,56 @@ begin
|
|||
begin
|
||||
blockInfo^.State := ssFiltered;
|
||||
end;
|
||||
|
||||
blockInfo^.WalkRestriction := wrNone;
|
||||
if acWalkable.Checked then
|
||||
begin
|
||||
if blockInfo^.Item is TMapCell then
|
||||
begin
|
||||
tileData := ResMan.Tiledata.LandTiles[blockInfo^.Item.TileID];
|
||||
if tdfImpassable in tileData.Flags then
|
||||
begin
|
||||
blockInfo^.WalkRestriction := wrCannotWalk;
|
||||
lastSurface := nil;
|
||||
end else
|
||||
begin
|
||||
blockInfo^.WalkRestriction := wrCanWalk;
|
||||
lastSurface := blockInfo;
|
||||
surfaceTop := blockInfo^.Item.Z;
|
||||
end;
|
||||
end else
|
||||
begin
|
||||
staticTileData := ResMan.Tiledata.StaticTiles[blockInfo^.Item.TileID];
|
||||
if (lastSurface <> nil) and (lastSurface^.WalkRestriction = wrCanWalk) and
|
||||
(lastSurface^.Item.X = blockInfo^.Item.X) and
|
||||
(lastSurface^.Item.Y = blockInfo^.Item.Y) and ([tdfSurface,
|
||||
tdfImpassable] * staticTileData.Flags <> []) then
|
||||
begin
|
||||
if (blockInfo^.Item.Z < surfaceTop + 16) and
|
||||
((blockInfo^.Item.Z > lastSurface^.Item.Z + 2) or
|
||||
not (tdfSurface in staticTileData.Flags)) then
|
||||
lastSurface^.WalkRestriction := wrCannotWalk;
|
||||
end;
|
||||
|
||||
if tdfSurface in staticTileData.Flags then
|
||||
begin
|
||||
if tdfImpassable in staticTileData.Flags then
|
||||
begin
|
||||
blockInfo^.WalkRestriction := wrCannotWalk;
|
||||
lastSurface := nil;
|
||||
end else
|
||||
begin
|
||||
blockInfo^.WalkRestriction := wrCanWalk;
|
||||
lastSurface := blockInfo;
|
||||
surfaceTop := blockInfo^.Item.Z + staticTileData.Height;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end; //acWalkable.Checked
|
||||
|
||||
end;
|
||||
end;
|
||||
|
||||
Include(FScreenBufferState, sbsFiltered);
|
||||
|
||||
if (FLightManager.LightLevel > 0) and not acFlat.Checked then
|
||||
|
|
|
@ -30,7 +30,7 @@ unit ULandscape;
|
|||
interface
|
||||
|
||||
uses
|
||||
SysUtils, Classes, math, UGenericIndex, UMap, UStatics, UWorldItem, UMulBlock,
|
||||
SysUtils, Classes, math, UGenericIndex, UMap, UStatics, UWorldItem,
|
||||
UTileDataProvider, URadarMap,
|
||||
UCacheManager, ULinkedList, UBufferedStreams,
|
||||
UEnhancedMemoryStream, UPacketHandlers, UPackets, UNetState, UEnums;
|
||||
|
@ -207,6 +207,7 @@ begin
|
|||
end;
|
||||
block.Free;
|
||||
end;
|
||||
FChanged := False;
|
||||
end;
|
||||
|
||||
constructor TSeperatedStaticBlock.Create(AData: TStream; AIndex: TGenericIndex);
|
||||
|
@ -558,7 +559,7 @@ end;
|
|||
|
||||
procedure TLandscape.SaveBlock(AWorldBlock: TWorldBlock);
|
||||
var
|
||||
i, j, size: Integer;
|
||||
size: Integer;
|
||||
index: TGenericIndex;
|
||||
begin
|
||||
if AWorldBlock is TMapBlock then
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
<PackageName Value="lnetbase"/>
|
||||
</Item2>
|
||||
</RequiredPackages>
|
||||
<Units Count="15">
|
||||
<Units Count="16">
|
||||
<Unit0>
|
||||
<Filename Value="cedserver.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
|
@ -118,6 +118,11 @@
|
|||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="UStatics"/>
|
||||
</Unit14>
|
||||
<Unit15>
|
||||
<Filename Value="../UOLib/UMap.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="UMap"/>
|
||||
</Unit15>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
|
|
|
@ -1,76 +1,74 @@
|
|||
(*
|
||||
* CDDL HEADER START
|
||||
*
|
||||
* The contents of this file are subject to the terms of the
|
||||
* Common Development and Distribution License, Version 1.0 only
|
||||
* (the "License"). You may not use this file except in compliance
|
||||
* with the License.
|
||||
*
|
||||
* You can obtain a copy of the license at
|
||||
* http://www.opensource.org/licenses/cddl1.php.
|
||||
* See the License for the specific language governing permissions
|
||||
* and limitations under the License.
|
||||
*
|
||||
* When distributing Covered Code, include this CDDL HEADER in each
|
||||
* file and include the License file at
|
||||
* http://www.opensource.org/licenses/cddl1.php. If applicable,
|
||||
* add the following below this CDDL HEADER, with the fields enclosed
|
||||
* by brackets "[]" replaced with your own identifying * information:
|
||||
* Portions Copyright [yyyy] [name of copyright owner]
|
||||
*
|
||||
* CDDL HEADER END
|
||||
*
|
||||
*
|
||||
* Portions Copyright 2008 Andreas Schneider
|
||||
*)
|
||||
program cedserver;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
SysUtils, Classes, lnetbase, UConfig, UCEDServer, URadarMap,
|
||||
ULargeScaleOperations, UPackets, UAdminHandling, UClientHandling, ULandscape,
|
||||
UPacketHandlers, URegions, UStatics, Logging;
|
||||
|
||||
{$I version.inc}
|
||||
|
||||
{$IFDEF WINDOWS}{$R cedserver.rc}{$ENDIF}
|
||||
|
||||
begin
|
||||
Writeln('');
|
||||
Writeln('CentrED Server Version ', ProductVersion);
|
||||
Writeln('Copyright ', Copyright);
|
||||
//Writeln('================================');
|
||||
Writeln('');
|
||||
|
||||
{$IFDEF Windows}
|
||||
if FileExists(ConfigFile) then
|
||||
Config := TConfig.Create(ConfigFile)
|
||||
else
|
||||
Config := TConfig.Init(ConfigFile);
|
||||
{$ELSE}
|
||||
if ParamStr(1) = '--init' then
|
||||
Config := TConfig.Init(ConfigFile)
|
||||
else if FileExists(ConfigFile) then
|
||||
Config := TConfig.Create(ConfigFile)
|
||||
else begin
|
||||
Writeln('No valid config file was found. Use --init to create one.');
|
||||
Halt;
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
Writeln(TimeStamp, 'Initialization started');
|
||||
Randomize;
|
||||
CEDServerInstance := TCEDServer.Create;
|
||||
Writeln(TimeStamp, 'Initialization done');
|
||||
CEDServerInstance.Run;
|
||||
Write(TimeStamp, 'Shutting down ... ');
|
||||
FreeAndNil(CEDServerInstance);
|
||||
Config.Flush;
|
||||
FreeAndNil(Config);
|
||||
Writeln('done');
|
||||
end.
|
||||
|
||||
(*
|
||||
* CDDL HEADER START
|
||||
*
|
||||
* The contents of this file are subject to the terms of the
|
||||
* Common Development and Distribution License, Version 1.0 only
|
||||
* (the "License"). You may not use this file except in compliance
|
||||
* with the License.
|
||||
*
|
||||
* You can obtain a copy of the license at
|
||||
* http://www.opensource.org/licenses/cddl1.php.
|
||||
* See the License for the specific language governing permissions
|
||||
* and limitations under the License.
|
||||
*
|
||||
* When distributing Covered Code, include this CDDL HEADER in each
|
||||
* file and include the License file at
|
||||
* http://www.opensource.org/licenses/cddl1.php. If applicable,
|
||||
* add the following below this CDDL HEADER, with the fields enclosed
|
||||
* by brackets "[]" replaced with your own identifying * information:
|
||||
* Portions Copyright [yyyy] [name of copyright owner]
|
||||
*
|
||||
* CDDL HEADER END
|
||||
*
|
||||
*
|
||||
* Portions Copyright 2008 Andreas Schneider
|
||||
*)
|
||||
program cedserver;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
SysUtils, UConfig, UCEDServer;
|
||||
|
||||
{$I version.inc}
|
||||
|
||||
{$IFDEF WINDOWS}{$R cedserver.rc}{$ENDIF}
|
||||
|
||||
begin
|
||||
Writeln('');
|
||||
Writeln('CentrED Server Version ', ProductVersion);
|
||||
Writeln('Copyright ', Copyright);
|
||||
//Writeln('================================');
|
||||
Writeln('');
|
||||
|
||||
{$IFDEF Windows}
|
||||
if FileExists(ConfigFile) then
|
||||
Config := TConfig.Create(ConfigFile)
|
||||
else
|
||||
Config := TConfig.Init(ConfigFile);
|
||||
{$ELSE}
|
||||
if ParamStr(1) = '--init' then
|
||||
Config := TConfig.Init(ConfigFile)
|
||||
else if FileExists(ConfigFile) then
|
||||
Config := TConfig.Create(ConfigFile)
|
||||
else begin
|
||||
Writeln('No valid config file was found. Use --init to create one.');
|
||||
Halt;
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
Writeln(TimeStamp, 'Initialization started');
|
||||
Randomize;
|
||||
CEDServerInstance := TCEDServer.Create;
|
||||
Writeln(TimeStamp, 'Initialization done');
|
||||
CEDServerInstance.Run;
|
||||
Write(TimeStamp, 'Shutting down ... ');
|
||||
FreeAndNil(CEDServerInstance);
|
||||
Config.Flush;
|
||||
FreeAndNil(Config);
|
||||
Writeln('done');
|
||||
end.
|
||||
|
||||
|
|
|
@ -173,8 +173,9 @@ begin
|
|||
for iX := 0 to 7 do
|
||||
Cells[iY * 8 + iX] := TMapCell.Create(Self, buffer, AX * 8 + iX, AY * 8 + iY);
|
||||
finally
|
||||
if Assigned(buffer) then FreeAndNil(buffer);
|
||||
buffer.Free;
|
||||
end;
|
||||
FChanged := False;
|
||||
end;
|
||||
|
||||
constructor TMapBlock.Create(AData: TStream);
|
||||
|
|
|
@ -189,6 +189,7 @@ begin
|
|||
FItems.Add(TStaticItem.Create(Self, block, AX, AY));
|
||||
block.Free;
|
||||
end;
|
||||
FChanged := False;
|
||||
end;
|
||||
|
||||
constructor TStaticBlock.Create(AData: TStream; AIndex: TGenericIndex);
|
||||
|
|
Loading…
Reference in New Issue